PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/OA/Dll/BannerInfo.php

https://github.com/orchestra-io/sample-openx
PHP | 344 lines | 106 code | 43 blank | 195 comment | 11 complexity | 8b46f6bfa90f9762ff5a370b904ad1a5 MD5 | raw file
  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v${RELEASE_MAJOR_MINOR} |
  5. | =======${RELEASE_MAJOR_MINOR_DOUBLE_UNDERLINE} |
  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: BannerInfo.php 67065 2010-11-17 23:16:15Z chris.nutting $
  25. */
  26. /**
  27. * @package OpenXDll
  28. * @author Ivan Klishch <iklishch@lohika.com>
  29. *
  30. */
  31. // Require the base Info class.
  32. require_once MAX_PATH . '/lib/OA/Info.php';
  33. /**
  34. * The OA_Dll_BannerInfo class extends the base OA_Info class and contains
  35. * information about the banner.
  36. *
  37. */
  38. class OA_Dll_BannerInfo extends OA_Info
  39. {
  40. /**
  41. * This field provides the ID of the banner.
  42. *
  43. * @var integer $bannerId
  44. */
  45. var $bannerId;
  46. /**
  47. * This field provides the ID of the campaign to associate with the banner.
  48. *
  49. * @var integer $campaignId
  50. */
  51. var $campaignId;
  52. /**
  53. * This field provides the name of the banner.
  54. *
  55. * @var integer $bannerName
  56. */
  57. var $bannerName;
  58. /**
  59. * This field provides the storageType for the banner, which is one of
  60. * 'sql','web','url','html','txt'.
  61. *
  62. * @var string $storageType
  63. */
  64. var $storageType;
  65. /**
  66. * This field provides the URL for the image file for an external banner.
  67. *
  68. * @var string $imageURL
  69. */
  70. var $imageURL;
  71. /**
  72. * This field provides the HTML template for a HTML banner.
  73. *
  74. * @var text $htmlTemplate
  75. */
  76. var $htmlTemplate;
  77. /**
  78. * This field provides the width of the banner.
  79. *
  80. * @var integer $width
  81. */
  82. var $width;
  83. /**
  84. * This field provides the height of the banner.
  85. *
  86. * @var integer $height
  87. */
  88. var $height;
  89. /**
  90. * This field provides the priority weight of the banner.
  91. *
  92. * @var integer $weight
  93. */
  94. var $weight;
  95. /**
  96. * This field provides the HTML target of the banner (e.g. _blank, _self)
  97. *
  98. * @var text $target
  99. */
  100. var $target;
  101. /**
  102. * This field provides the destination URL of the banner.
  103. *
  104. * @var text $url
  105. */
  106. var $url;
  107. /**
  108. * This field provides the Text value of the text banner.
  109. *
  110. * @var string $bannerText
  111. */
  112. var $bannerText;
  113. /**
  114. * A boolean field to indicate if the banner is active
  115. *
  116. * @var int $status
  117. */
  118. var $status;
  119. /**
  120. * A text field for HTML banners to indicate which adserver this ad is from
  121. *
  122. * @var string $adserver
  123. */
  124. var $adserver;
  125. /**
  126. * This field provides transparency information for SWF banners
  127. *
  128. * @var boolean
  129. */
  130. var $transparent;
  131. /**
  132. * Frequency capping: total views per user.
  133. *
  134. * @var integer $capping
  135. */
  136. var $capping;
  137. /**
  138. * Frequency capping: total views per period.
  139. * (defined in seconds by "block").
  140. *
  141. * @var integer $sessionCapping
  142. */
  143. var $sessionCapping;
  144. /**
  145. * Frequency capping: reset period, in seconds.
  146. *
  147. * @var integer $block
  148. */
  149. var $block;
  150. /**
  151. * An array field for SQL/Web banners to contain the image name and binary data
  152. *
  153. * Array
  154. * (
  155. * [filename] => banner.swf
  156. * [content] => {binarydata}
  157. * [editswf] => true
  158. * )
  159. *
  160. * If the editswf member is present and true, any SWF files will be scanned for hardcoded
  161. * links and eventually converted
  162. *
  163. * @var array
  164. */
  165. var $aImage;
  166. /**
  167. * An array field for SQL/Web banners to contain the backup image name and binary data
  168. * in case the primary image is a swf file
  169. *
  170. * Array
  171. * (
  172. * [filename] => banner.gif
  173. * [content] => {binarydata}
  174. * )
  175. *
  176. * @var array
  177. */
  178. var $aBackupImage;
  179. /**
  180. * This field provides any additional comments to be stored.
  181. *
  182. * @var string $comments
  183. */
  184. var $comments;
  185. /**
  186. * This field provides the alt value for SQL/Web/External banners.
  187. *
  188. * @var string $alt
  189. */
  190. var $alt;
  191. /**
  192. * This field provides the filename of the banner.
  193. *
  194. * @var string $filename
  195. */
  196. var $filename;
  197. /**
  198. * This field provides appended code for this banner.
  199. *
  200. * @var string $append
  201. */
  202. var $append;
  203. /**
  204. * This field provides the filename of the banner.
  205. *
  206. * @var string $prepend
  207. */
  208. var $prepend;
  209. /**
  210. * This method sets all default values when adding a new banner.
  211. *
  212. * @access public
  213. *
  214. */
  215. function setDefaultForAdd() {
  216. if (!isset($this->storageType)) {
  217. $this->storageType = 'html';
  218. }
  219. if (!isset($this->width)) {
  220. $this->width = 0;
  221. }
  222. if (!isset($this->height)) {
  223. $this->height = 0;
  224. }
  225. if (!isset($this->weight)) {
  226. $this->weight = 1;
  227. }
  228. if (!isset($this->status)) {
  229. $this->status = OA_ENTITY_STATUS_RUNNING;
  230. }
  231. if (!isset($this->transparent)) {
  232. $this->transparent = false;
  233. }
  234. if (is_null($this->capping)) {
  235. // Leave null
  236. }
  237. if (is_null($this->sessionCapping)) {
  238. // Leave null
  239. }
  240. if (is_null($this->block)) {
  241. // Leave null
  242. }
  243. }
  244. function encodeImage($aImage)
  245. {
  246. return new XML_RPC_Value(array(
  247. 'filename' => new XML_RPC_Value($aImage['filename']),
  248. 'content' => new XML_RPC_Value($aImage['content'], 'base64'),
  249. 'editswf' => new XML_RPC_Value(!empty($aImage['editswf']), 'boolean'),
  250. ), 'struct');
  251. }
  252. function toArray()
  253. {
  254. $aInfo = parent::toArray();
  255. if (isset($this->aImage)) {
  256. $aInfo['aImage'] = $this->encodeImage($this->aImage);
  257. }
  258. if (isset($this->aBackupImage)) {
  259. $aInfo['aBackupImage'] = $this->encodeImage($this->aBackupImage);
  260. }
  261. return $aInfo;
  262. }
  263. /**
  264. * This method returns an array of fields with their corresponding types.
  265. *
  266. * @access public
  267. *
  268. * @return array
  269. */
  270. function getFieldsTypes()
  271. {
  272. return array(
  273. 'bannerId' => 'integer',
  274. 'campaignId' => 'integer',
  275. 'bannerName' => 'string',
  276. 'storageType' => 'string',
  277. 'imageURL' => 'string',
  278. 'htmlTemplate' => 'string',
  279. 'width' => 'integer',
  280. 'height' => 'integer',
  281. 'weight' => 'integer',
  282. 'target' => 'string',
  283. 'url' => 'string',
  284. 'bannerText' => 'string',
  285. 'status' => 'integer',
  286. 'adserver' => 'string',
  287. 'transparent' => 'integer',
  288. 'capping' => 'integer',
  289. 'sessionCapping' => 'integer',
  290. 'block' => 'integer',
  291. 'aImage' => 'custom',
  292. 'aBackupImage' => 'custom',
  293. 'comments' => 'string',
  294. 'alt' => 'string',
  295. 'filename' => 'string',
  296. 'append' => 'string',
  297. 'prepend' => 'string',
  298. );
  299. }
  300. }
  301. ?>