PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/canoo/tests/testcases/level0/2.8.2/plug-ins/plugins/invocationTags/oxInvocationTags/adlayer.class.php

https://bitbucket.org/valmy/openx
PHP | 285 lines | 160 code | 26 blank | 99 comment | 27 complexity | 2893ccfaf7b7c1c075aac5229208a209 MD5 | raw file
  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v2.8 |
  5. | ========== |
  6. | |
  7. | Copyright (c) 2003-2009 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: adlayer.class.php 40991 2009-08-05 06:13:34Z matteo.beccati $
  25. */
  26. /**
  27. * @package OpenXPlugin
  28. * @subpackage InvocationTags
  29. * @author Radek Maciaszek <radek@m3.net>
  30. *
  31. */
  32. define('PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE', 'geocities');
  33. require_once LIB_PATH . '/Extension/invocationTags/InvocationTags.php';
  34. require_once MAX_PATH . '/lib/max/Plugin/Translation.php';
  35. require_once MAX_PATH . '/www/admin/lib-zones.inc.php';
  36. /**
  37. *
  38. * Invocation tag plugin.
  39. *
  40. */
  41. class Plugins_InvocationTags_OxInvocationTags_adlayer extends Plugins_InvocationTags
  42. {
  43. /**
  44. * Use only for factory default plugin
  45. * @see MAX_Admin_Invocation::placeInvocationForm()
  46. */
  47. var $defaultZone = phpAds_ZoneInterstitial;
  48. /**
  49. * Return name of plugin
  50. *
  51. * @return string
  52. */
  53. function getName()
  54. {
  55. return $this->translate("Interstitial or Floating DHTML Tag");
  56. }
  57. /**
  58. * Return the English name of the plugin. Used when
  59. * generating translation keys based on the plugin
  60. * name.
  61. *
  62. * @return string An English string describing the class.
  63. */
  64. function getNameEN()
  65. {
  66. return 'Interstitial or Floating DHTML Tag';
  67. }
  68. /**
  69. * Check if plugin is allowed
  70. *
  71. * @return boolean True - allowed, false - not allowed
  72. */
  73. function isAllowed($extra)
  74. {
  75. $isAllowed = parent::isAllowed($extra);
  76. if(is_array($extra) || (is_array($extra) && $extra['delivery'] == phpAds_ZoneText)) {
  77. return false;
  78. } else {
  79. return $isAllowed;
  80. }
  81. }
  82. /**
  83. * Check if plugin has enough data to perform tag generation
  84. *
  85. * @return boolean
  86. */
  87. function canGenerate()
  88. {
  89. return !empty($this->maxInvocation->submitbutton);
  90. }
  91. /**
  92. * Return list of options
  93. *
  94. * @return array Group of options
  95. */
  96. function getOptionsList()
  97. {
  98. if (empty($this->maxInvocation->layerstyle)) {
  99. $this->maxInvocation->layerstyle = PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE;
  100. }
  101. $invocation = $this->getInvocationLayer($this->maxInvocation->layerstyle);
  102. if($invocation !== false) {
  103. return $invocation->getlayerShowVar();
  104. } else {
  105. return array();
  106. }
  107. }
  108. /**
  109. * Return invocation code for this plugin (codetype)
  110. *
  111. * @return string
  112. */
  113. function generateInvocationCode()
  114. {
  115. $conf = $GLOBALS['_MAX']['CONF'];
  116. $aComments = array(
  117. 'Cache Buster Comment' => $this->translate("
  118. * Replace all instances of {random} with
  119. * a generated random number (or timestamp).
  120. *"),
  121. 'Third Party Comment' => $this->translate("
  122. * Don't forget to replace the '{clickurl}' text with
  123. * the click tracking URL if this ad is to be delivered through a 3rd
  124. * party (non-Max) adserver.
  125. *"),
  126. 'SSL Delivery Comment' => $this->translate("
  127. * This tag has been generated for use on a non-SSL page. If this tag
  128. * is to be placed on an SSL page, change the
  129. * 'http://%s/...'
  130. * to
  131. * 'https://%s/...'
  132. *", array ($conf['webpath']['delivery'],$conf['webpath']['deliverySSL'])),
  133. 'SSL Backup Comment' => '',
  134. );
  135. if (isset($GLOBALS['layerstyle']) &&
  136. ($GLOBALS['layerstyle'] == 'geocities' || $GLOBALS['layerstyle'] == 'simple')) {
  137. $aComments['Comment'] = $this->translate("
  138. *------------------------------------------------------------*
  139. * This interstitial invocation code requires the images from:
  140. * /www/images/layerstyles/%s/...
  141. * To be accessible via: http(s)://%s/layerstyles/%s/...
  142. *------------------------------------------------------------*",
  143. array($GLOBALS['layerstyle'], $conf['webpath']['images'], $GLOBALS['layerstyle']));
  144. } else {
  145. $aComments['Comment'] = '';
  146. }
  147. parent::prepareCommonInvocationData($aComments);
  148. $mi = &$this->maxInvocation;
  149. $buffer = $mi->buffer;
  150. if(empty($mi->layerstyle)) {
  151. $mi->layerstyle = PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE;
  152. }
  153. $invocation = $this->getInvocationLayer($mi->layerstyle);
  154. if($invocation !== false) {
  155. $buffer .= $invocation->generateLayerCode($this->maxInvocation)."\n";
  156. return $buffer;
  157. } else {
  158. return false;
  159. }
  160. }
  161. /**
  162. * Factory the "invocation" layer
  163. *
  164. * @return string A string describing the class.
  165. */
  166. function getInvocationLayer($style = PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE)
  167. {
  168. return $this->factoryLayer($style, 'invocation');
  169. }
  170. /**
  171. * Factory the specific layer for invocation tag plugin
  172. *
  173. * @static
  174. * @param string $layerName Name of the invocation tag layer
  175. *
  176. * @return object Plugin object or false if any error occured
  177. *
  178. */
  179. function factoryLayer($style = PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE, $type = 'invocation')
  180. {
  181. $fileName = dirname(__FILE__)."/layerstyles/{$style}/{$type}.inc.php";
  182. if(!file_exists($fileName)) {
  183. MAX::raiseError("Unable to include the {$fileName} file");
  184. return false;
  185. } else {
  186. include_once $fileName;
  187. }
  188. $className = "Plugins_" . ucfirst($this->group) . '_' . ucfirst($this->component) . '_Layerstyles_'
  189. . ucfirst($style) . '_' . ucfirst($type);
  190. if (!class_exists($className)) {
  191. MAX::raiseError("Plugin file included but class '$className' doesn't exists");
  192. return false;
  193. }
  194. $obj = new $className;
  195. // Assign this component group's translation resource to the created layer object
  196. $obj->oTrans = $this->oTrans;
  197. return $obj;
  198. }
  199. /* -----------------------------------------------------------------------------------
  200. * Custom methods
  201. * -----------------------------------------------------------------------------------
  202. */
  203. /**
  204. * Generate the HTML option
  205. *
  206. * @return string A string containing html for option
  207. */
  208. function layerstyle()
  209. {
  210. $option = '';
  211. $layerstyles = array();
  212. $layerStylesFolder = dirname(__FILE__) . '/layerstyles';
  213. $stylesdir = opendir($layerStylesFolder);
  214. while ($stylefile = readdir($stylesdir)) {
  215. if (is_dir($layerStylesFolder.'/'.$stylefile) &&
  216. file_exists($layerStylesFolder.'/'.$stylefile.'/invocation.inc.php')) {
  217. if (ereg('^[^.]', $stylefile)) {
  218. $layerstyles[$stylefile] = isset($GLOBALS['strAdLayerStyleName'][$stylefile]) ?
  219. $GLOBALS['strAdLayerStyleName'][$stylefile] :
  220. str_replace("- ", "-",
  221. ucwords(str_replace("-", "- ", $stylefile)));
  222. }
  223. }
  224. }
  225. closedir($stylesdir);
  226. asort($layerstyles, SORT_STRING);
  227. $option .= "<tr><td width='30'>&nbsp;</td>";
  228. $option .= "<td width='200'>". $this->translate("Style") ."</td><td width='370'>";
  229. $option .= "<select name='layerstyle' onChange='this.form.submit()' style='width:175px;' tabindex='".($this->maxInvocation->tabindex++)."'>";
  230. reset($layerstyles);
  231. while (list($k, $v) = each($layerstyles)) {
  232. $option .= "<option value='$k'".($this->maxInvocation->layerstyle == $k ? ' selected' : '').">$v</option>";
  233. }
  234. $option .= "</select>";
  235. $option .= "</td></tr>";
  236. $option .= "<tr><td width='30'><img src='" . OX::assetPath() . "/images/spacer.gif' height='1' width='100%'></td></tr>";
  237. return $option;
  238. }
  239. /**
  240. * Generate the HTML option
  241. *
  242. * @return string A string containing html for option
  243. */
  244. function layercustom()
  245. {
  246. if (empty($this->maxInvocation->layerstyle)) {
  247. $this->maxInvocation->layerstyle = PLUGINS_INVOCATIONS_TAGS_ADLAYER_DEFAULT_LAYERSTYLE;
  248. }
  249. $invocation = $this->getInvocationLayer($this->maxInvocation->layerstyle);
  250. if($invocation !== false) {
  251. return $invocation->placeLayerSettings();
  252. } else {
  253. return false;
  254. }
  255. }
  256. }
  257. ?>