PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/canoo/tests/testcases/level0/2.7.29-beta/plug-ins/extensions/invocationTags/oxInvocationTags/adframe.class.php

https://github.com/yabba/openx
PHP | 228 lines | 154 code | 11 blank | 63 comment | 7 complexity | c6ee8633548b82e3b126697edb3310ff MD5 | raw file
  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v${RELEASE_MAJOR_MINOR} |
  5. | =======${RELEASE_MAJOR_MINOR_DOUBLE_UNDERLINE} |
  6. | |
  7. | Copyright (c) 2003-2008 OpenX Limited |
  8. | For contact details, see: http://www.openx.org/ |
  9. | |
  10. | This program is free software; you can redistribute it and/or modify |
  11. | it under the terms of the GNU General Public License as published by |
  12. | the Free Software Foundation; either version 2 of the License, or |
  13. | (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  23. +---------------------------------------------------------------------------+
  24. $Id: adframe.class.php 28801 2008-11-11 11:58:14Z radek.maciaszek $
  25. */
  26. /**
  27. * @package OpenXPlugin
  28. * @subpackage InvocationTags
  29. * @author Radek Maciaszek <radek@m3.net>
  30. *
  31. */
  32. require_once LIB_PATH . '/Extension/invocationTags/InvocationTags.php';
  33. require_once MAX_PATH . '/lib/max/Plugin/Translation.php';
  34. /**
  35. *
  36. * Invocation tag plugin.
  37. *
  38. */
  39. class Plugins_InvocationTags_OxInvocationTags_adframe extends Plugins_InvocationTags
  40. {
  41. /**
  42. * Return name of plugin
  43. *
  44. * @return string
  45. */
  46. function getName()
  47. {
  48. return $this->translate("iFrame Tag");
  49. }
  50. /**
  51. * Return the English name of the plugin. Used when
  52. * generating translation keys based on the plugin
  53. * name.
  54. *
  55. * @return string An English string describing the class.
  56. */
  57. function getNameEN()
  58. {
  59. return 'iFrame Tag';
  60. }
  61. /**
  62. * Check if plugin is allowed
  63. *
  64. * @return boolean True - allowed, false - not allowed
  65. */
  66. function isAllowed($extra)
  67. {
  68. $isAllowed = parent::isAllowed($extra);
  69. if ((is_array($extra) && $extra['delivery'] == phpAds_ZoneText)) {
  70. return false;
  71. } else {
  72. return $isAllowed;
  73. }
  74. }
  75. function getOrder()
  76. {
  77. parent::getOrder();
  78. return 2;
  79. }
  80. /**
  81. * Return list of options
  82. *
  83. * @return array Group of options
  84. */
  85. function getOptionsList()
  86. {
  87. $options = array (
  88. 'spacer' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  89. 'what' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  90. //'clientid' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  91. 'campaignid' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  92. 'target' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  93. 'source' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  94. 'refresh' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  95. 'size' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  96. 'resize' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  97. 'transparent' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  98. 'ilayer' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  99. 'iframetracking' => MAX_PLUGINS_INVOCATION_TAGS_STANDARD,
  100. );
  101. return $options;
  102. }
  103. /**
  104. * Return invocation code for this plugin (codetype)
  105. *
  106. * @return string
  107. */
  108. function generateInvocationCode()
  109. {
  110. $aComments['Comment'] = $this->translate("
  111. * If iFrames are not supported by the viewer's browser, then this
  112. * tag only shows image banners. There is no width or height in these
  113. * banners, so if you want these tags to allocate space for the ad
  114. * before it shows, you will need to add this information to the <img>
  115. * tag.");
  116. parent::prepareCommonInvocationData($aComments);
  117. $conf = $GLOBALS['_MAX']['CONF'];
  118. $mi = &$this->maxInvocation;
  119. $buffer = $mi->buffer;
  120. $uniqueid = 'a'.substr(md5(uniqid('', 1)), 0, 7);
  121. if (!isset($mi->iframetracking) || $mi->iframetracking == 1) {
  122. // Add n as first parameter
  123. array_unshift($mi->parameters, "{$conf['var']['n']}={$uniqueid}");
  124. }
  125. if (isset($mi->refresh) && $mi->refresh != '') {
  126. if (is_array($mi->parameters)) {
  127. $mi->parameters = array('refresh' => "refresh=".$mi->refresh) + $mi->parameters;
  128. } else {
  129. $mi->parameters['refresh'] = "refresh=".$mi->refresh;
  130. }
  131. }
  132. if (isset($mi->resize) && $mi->resize == '1') {
  133. if (is_array($mi->parameters)) {
  134. $mi->parameters = array('resize' => "resize=1") + $mi->parameters;
  135. } else {
  136. $mi->parameters['resize'] = "resize=1";
  137. }
  138. }
  139. if (empty($mi->frame_width )) { $mi->frame_width = $mi->width; }
  140. if (empty($mi->frame_height)) { $mi->frame_height = $mi->height; }
  141. $buffer .= "<iframe id='{$uniqueid}' name='{$uniqueid}' src='".MAX_commonConstructDeliveryUrl($conf['file']['frame']);
  142. if (sizeof($mi->parameters) > 0) {
  143. $buffer .= "?".implode ("&amp;", $mi->parameters);
  144. }
  145. $buffer .= "' frameborder='0' scrolling='no'";
  146. if (isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1') {
  147. $buffer .= " width='".$mi->frame_width."'";
  148. }
  149. if (isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
  150. $buffer .= " height='".$mi->frame_height."'";
  151. }
  152. if (isset($mi->transparent) && $mi->transparent == '1') {
  153. $buffer .= " allowtransparency='true'";
  154. }
  155. $buffer .= ">";
  156. if (isset($mi->refresh) && $mi->refresh != '') {
  157. unset ($mi->parameters['refresh']);
  158. }
  159. if (isset($mi->resize) && $mi->resize == '1') {
  160. unset ($mi->parameters['resize']);
  161. }
  162. if (isset($mi->ilayer) && $mi->ilayer == 1 && isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1' && isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
  163. $buffer .= "<script type='text/javascript'>\n";
  164. $buffer .= "<!--// <![CDATA[\n";
  165. $buffer .= " document.write (\"<nolayer>\");\n";
  166. $buffer .= " document.write (\"{$mi->backupImage}\");\n";
  167. $buffer .= " document.write (\"</nolayer>\");\n";
  168. $buffer .= " document.write (\"<ilayer id='layer".$uniqueid."' visibility='hidden' width='".$mi->frame_width."' height='".$mi->frame_height."'></ilayer>\");\n";
  169. $buffer .= "// ]]> -->\n";
  170. $buffer .= "</script>";
  171. $buffer .= "<noscript>\n <a href='".MAX_commonConstructDeliveryUrl($conf['file']['click']);
  172. $buffer .= "?n=".$uniqueid;
  173. $buffer .= "'";
  174. if (isset($mi->target) && $mi->target != '') {
  175. $buffer .= " target='$mi->target'";
  176. }
  177. $buffer .= ">\n <img src='".MAX_commonConstructDeliveryUrl($conf['file']['view']);
  178. if (sizeof($mi->parameters) > 0) {
  179. $buffer .= "?".implode ("&", $mi->parameters);
  180. }
  181. $buffer .= "' border='0' alt='' /></a></noscript>";
  182. } else {
  183. $buffer .= $mi->backupImage;
  184. }
  185. $buffer .= "</iframe>\n";
  186. if (isset($mi->target) && $mi->target != '') {
  187. $mi->parameters['target'] = "target=".urlencode($mi->target);
  188. }
  189. if (isset($mi->ilayer) && $mi->ilayer == 1 && isset($mi->frame_width) && $mi->frame_width != '' && $mi->frame_width != '-1' && isset($mi->frame_height) && $mi->frame_height != '' && $mi->frame_height != '-1') {
  190. // Do no rewrite target frames
  191. $mi->parameters['rewrite'] = 'rewrite=0';
  192. $buffer .= "\n\n";
  193. $buffer .= "<!-- " . $this->translate("Placement Comment") . " -->\n";
  194. $buffer .= "<layer src='".MAX_commonConstructDeliveryUrl($conf['file']['frame']);
  195. $buffer .= "?n=".$uniqueid;
  196. if (sizeof($mi->parameters) > 0) {
  197. $buffer .= "&".implode ("&", $mi->parameters);
  198. }
  199. $buffer .= "' width='".$mi->frame_width."' height='".$mi->frame_height."' visibility='hidden' onload=\"moveToAbsolute(layer".$uniqueid.".pageX,layer".$uniqueid.".pageY);clip.width=".$mi->frame_width.";clip.height=".$mi->frame_height.";visibility='show';\"></layer>";
  200. }
  201. if (!isset($mi->iframetracking) || $mi->iframetracking != 0) {
  202. $buffer .= "<script type='text/javascript' src='".MAX_commonConstructDeliveryUrl($conf['file']['google'])."'></script>";
  203. }
  204. return $buffer;
  205. }
  206. }
  207. ?>