From 931187da9b57274fe96f4ae1139727483ebb3c11 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 9 Mar 2014 21:23:20 -0500 Subject: [PATCH] Making it easer to manage ads --- indefero/src/IDF/Middleware/GoogleAds.php | 80 +++++++++++++++++++ indefero/src/IDF/templates/idf/base.html | 2 +- .../src/IDF/templates/idf/project/home.html | 2 +- 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 indefero/src/IDF/Middleware/GoogleAds.php diff --git a/indefero/src/IDF/Middleware/GoogleAds.php b/indefero/src/IDF/Middleware/GoogleAds.php new file mode 100644 index 0000000..8a7fc2f --- /dev/null +++ b/indefero/src/IDF/Middleware/GoogleAds.php @@ -0,0 +1,80 @@ +status_code, + array(200, 201, 202, 203, 204, 205, 206, 404, 501))) { + return $response; + } + $ok = false; + $cts = array('text/html', 'text/html', 'application/xhtml+xml'); + foreach ($cts as $ct) { + if (false !== strripos($response->headers['Content-Type'], $ct)) { + $ok = true; + break; + } + } + if ($ok == false) { + return $response; + } + $replacead1 = $this->makead(Pluf::f("google_ads")["AD1"]); + $replacead2 = $this->makead(Pluf::f("google_ads")["AD2"]); + $response->content = str_replace('', $replacead1, $response->content); + $response->content = str_replace('', $replacead2, $response->content); + return $response; + } + + private function makead($ad) + { + $ret = '"; + $ret .= ''; + return $ret; + + } +} diff --git a/indefero/src/IDF/templates/idf/base.html b/indefero/src/IDF/templates/idf/base.html index 586ae71..81d3e6c 100644 --- a/indefero/src/IDF/templates/idf/base.html +++ b/indefero/src/IDF/templates/idf/base.html @@ -60,7 +60,7 @@ {if $project.enableads}

- +

{/if}

{block titleicon}{/block}{block title}{$page_title}{/block}

diff --git a/indefero/src/IDF/templates/idf/project/home.html b/indefero/src/IDF/templates/idf/project/home.html index 61e776e..7a6094a 100644 --- a/indefero/src/IDF/templates/idf/project/home.html +++ b/indefero/src/IDF/templates/idf/project/home.html @@ -40,7 +40,7 @@

{if $project.enableads} - + {/if}

{/block}