PageRenderTime 52ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/vb/item/content.php

https://github.com/ProjectBenelux/Website
PHP | 206 lines | 52 code | 35 blank | 119 comment | 2 complexity | 39427467665ace4f8e4d5265a13b8e84 MD5 | raw file
  1. <?php if (!defined('VB_ENTRY')) die('Access denied.');
  2. /*======================================================================*\
  3. || #################################################################### ||
  4. || # vBulletin 4.1.5
  5. || # ---------------------------------------------------------------- # ||
  6. || # Copyright ©2000-2011 vBulletin Solutions Inc. All Rights Reserved. ||
  7. || # This file may not be redistributed in whole or significant part. # ||
  8. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  10. || #################################################################### ||
  11. \*======================================================================*/
  12. /**
  13. * Content Item Model.
  14. * The content item model is responsible for providing an interface to access content
  15. * info that is both common to all content types and specific to a content type.
  16. *
  17. * @package vBulletin
  18. * @author vBulletin Development Team
  19. * @version $Revision: 28694 $
  20. * @since $Date: 2008-12-04 16:12:22 +0000 (Thu, 04 Dec 2008) $
  21. * @copyright vBulletin Solutions Inc.
  22. */
  23. abstract class vB_Item_Content extends vB_Item
  24. {
  25. /*Properties====================================================================*/
  26. /**
  27. * A package identifier.
  28. * This is used to resolve any related class names.
  29. * It is also used by client code to resolve the class name of this content.
  30. *
  31. * @var string
  32. */
  33. protected $package;
  34. /**
  35. * A class identifier.
  36. * This is used to resolve any related class names.
  37. * It is also used by client code to resolve the class name of this content.
  38. * Note: The class should always be resolvable from a contenttypeid using the
  39. * contenttype table.
  40. *
  41. * @var string
  42. */
  43. protected $class;
  44. /*ModelProperties===============================================================*/
  45. /**
  46. * Array of all valid model properties.
  47. * This is used to check if a class property can be set as a property and allows
  48. * automagic setting of properties from db info results.
  49. * @see Load()
  50. * @see setInfo()
  51. *
  52. * @var array string
  53. */
  54. protected $item_properties = array(
  55. 'title', 'userid',
  56. 'description'
  57. );
  58. /*INFO_BASIC==================*/
  59. /**
  60. * The title of the content item.
  61. *
  62. * @var string
  63. */
  64. protected $title;
  65. /**
  66. * The id of the user that created the content.
  67. *
  68. * @var int
  69. */
  70. protected $userid;
  71. /**
  72. * A description of the content.
  73. *
  74. * @var string
  75. */
  76. protected $description;
  77. /*Initialisation================================================================*/
  78. /**
  79. * Constructs the content item.
  80. * The id passed will usually be the primary key of the model data in the
  81. * database but as this is model specific it can be interpreted in other ways.
  82. *
  83. * @param mixed $itemid - The id of the item
  84. * @param int $load_flags - Any required info prenotification
  85. */
  86. public function __construct($itemid = false, $load_flags = false)
  87. {
  88. if (!$this->package OR !$this->class)
  89. {
  90. throw (new vB_Exception_Content('No package or contenttype class defined for content item '));
  91. }
  92. parent::__construct($itemid, $load_flags);
  93. }
  94. /**
  95. * Factory method for creating a type specific content item.
  96. * Note: The contentid is interpreted at each contenttype's descretion.
  97. *
  98. * @param string $package_class - The class identifier for the package
  99. * @param string $contenttype_class - The class identifier for the contenttype
  100. * @param int $contentid - The primary key value of the content
  101. * @param int $load_flags - Notify flags for loading info
  102. */
  103. public static function create($package_class, $contenttype_class, $contentid = false)
  104. {
  105. $class = $package_class . '_Item_Content_' . $contenttype_class;
  106. return new $class($contentid);
  107. }
  108. /*Accessors=====================================================================*/
  109. /**
  110. * Returns the class identifier.
  111. * This is used to resolve related classes.
  112. *
  113. * @return string
  114. */
  115. public function getClass()
  116. {
  117. return $this->class;
  118. }
  119. /**
  120. * Returns the package identifier.
  121. * This is used to resolve related classes.
  122. *
  123. * @return string
  124. */
  125. public function getPackage()
  126. {
  127. return $this->package;
  128. }
  129. /**
  130. * Returns the creator userid.
  131. *
  132. * @return int
  133. */
  134. public function getUserId()
  135. {
  136. $this->Load();
  137. return $this->userid;
  138. }
  139. /**
  140. * Returns a human readable title for the content.
  141. *
  142. * @return string
  143. */
  144. public function getTitle()
  145. {
  146. $this->Load();
  147. return $this->title;
  148. }
  149. /**
  150. * Returns a user friendly description of the content.
  151. *
  152. * @return string
  153. */
  154. public function getDescription()
  155. {
  156. return '';
  157. }
  158. /**
  159. * Returns a user friendly title of the content's contenttype.
  160. */
  161. public function getTypeTitle()
  162. {
  163. return vB_Types::instance()->getContentTypeTitle(array('package' => $this->getPackage(), 'class' => $this->getClass()));
  164. }
  165. }
  166. /*======================================================================*\
  167. || ####################################################################
  168. || #
  169. || # SVN: $Revision: 28694 $
  170. || ####################################################################
  171. \*======================================================================*/