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}