A QCodo powered CMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2983 lines
129 KiB

  1. <?php
  2. /**
  3. * The abstract PageGen class defined here is
  4. * code-generated and contains all the basic CRUD-type functionality as well as
  5. * basic methods to handle relationships and index-based loading.
  6. *
  7. * To use, you should use the Page subclass which
  8. * extends this PageGen class.
  9. *
  10. * Because subsequent re-code generations will overwrite any changes to this
  11. * file, you should leave this file unaltered to prevent yourself from losing
  12. * any information or code changes. All customizations should be done by
  13. * overriding existing or implementing new methods, properties and variables
  14. * in the Page class.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage GeneratedDataObjects
  18. * @property-read integer $Id the value for intId (Read-Only PK)
  19. * @property-read string $CreationDate the value for strCreationDate (Read-Only Timestamp)
  20. * @property-read string $LastModification the value for strLastModification (Read-Only Timestamp)
  21. * @property string $Name the value for strName (Unique)
  22. * @property string $Title the value for strTitle
  23. * @property string $Uri the value for strUri
  24. * @property boolean $HasHeader the value for blnHasHeader (Not Null)
  25. * @property boolean $HasLeftColumn the value for blnHasLeftColumn (Not Null)
  26. * @property boolean $HasRightColumn the value for blnHasRightColumn (Not Null)
  27. * @property boolean $HasFooter the value for blnHasFooter (Not Null)
  28. * @property integer $TypeId the value for intTypeId
  29. * @property integer $DocTypeId the value for intDocTypeId (Not Null)
  30. * @property integer $StatusId the value for intStatusId (Not Null)
  31. * @property-read ContentBlock $_ContentBlock the value for the private _objContentBlock (Read-Only) if set due to an expansion on the content_block_page_assn association table
  32. * @property-read ContentBlock[] $_ContentBlockArray the value for the private _objContentBlockArray (Read-Only) if set due to an ExpandAsArray on the content_block_page_assn association table
  33. * @property-read ContentCategory $_ContentCategory the value for the private _objContentCategory (Read-Only) if set due to an expansion on the page_content_category_assn association table
  34. * @property-read ContentCategory[] $_ContentCategoryArray the value for the private _objContentCategoryArray (Read-Only) if set due to an ExpandAsArray on the page_content_category_assn association table
  35. * @property-read HtmlMetaTag $_HtmlMetaTag the value for the private _objHtmlMetaTag (Read-Only) if set due to an expansion on the page_html_meta_tag_assn association table
  36. * @property-read HtmlMetaTag[] $_HtmlMetaTagArray the value for the private _objHtmlMetaTagArray (Read-Only) if set due to an ExpandAsArray on the page_html_meta_tag_assn association table
  37. * @property-read JavaScript $_JavaScript the value for the private _objJavaScript (Read-Only) if set due to an expansion on the page_java_script_assn association table
  38. * @property-read JavaScript[] $_JavaScriptArray the value for the private _objJavaScriptArray (Read-Only) if set due to an ExpandAsArray on the page_java_script_assn association table
  39. * @property-read StyleSheet $_StyleSheet the value for the private _objStyleSheet (Read-Only) if set due to an expansion on the page_style_sheet_assn association table
  40. * @property-read StyleSheet[] $_StyleSheetArray the value for the private _objStyleSheetArray (Read-Only) if set due to an ExpandAsArray on the page_style_sheet_assn association table
  41. * @property-read Usergroup $_Usergroup the value for the private _objUsergroup (Read-Only) if set due to an expansion on the page_usergroup_assn association table
  42. * @property-read Usergroup[] $_UsergroupArray the value for the private _objUsergroupArray (Read-Only) if set due to an ExpandAsArray on the page_usergroup_assn association table
  43. * @property-read MenuItem $_MenuItem the value for the private _objMenuItem (Read-Only) if set due to an expansion on the menu_item.page_id reverse relationship
  44. * @property-read MenuItem[] $_MenuItemArray the value for the private _objMenuItemArray (Read-Only) if set due to an ExpandAsArray on the menu_item.page_id reverse relationship
  45. * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
  46. */
  47. class PageGen extends QBaseClass
  48. {
  49. ///////////////////////////////////////////////////////////////////////
  50. // PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
  51. ///////////////////////////////////////////////////////////////////////
  52. /////////// Object properties ////////////
  53. /**
  54. * Protected member variable that maps to the database PK Identity column page.id
  55. * @var integer intId
  56. *
  57. */
  58. protected $intId = null;
  59. /**
  60. * Protected member variable that maps to the database column page.creation_date
  61. * @var string strCreationDate
  62. *
  63. */
  64. protected $strCreationDate = null;
  65. /**
  66. * Protected member variable that maps to the database column page.last_modification
  67. * @var string strLastModification
  68. *
  69. */
  70. protected $strLastModification = null;
  71. /**
  72. * Protected member variable that maps to the database column page.name
  73. * @var string strName
  74. *
  75. */
  76. protected $strName = null;
  77. const NameMaxLength = 128;
  78. /**
  79. * Protected member variable that maps to the database column page.title
  80. * @var string strTitle
  81. *
  82. */
  83. protected $strTitle = null;
  84. const TitleMaxLength = 256;
  85. /**
  86. * Protected member variable that maps to the database column page.uri
  87. * @var string strUri
  88. *
  89. */
  90. protected $strUri = null;
  91. const UriMaxLength = 256;
  92. /**
  93. * Protected member variable that maps to the database column page.has_header
  94. * @var boolean blnHasHeader
  95. *
  96. */
  97. protected $blnHasHeader = null;
  98. /**
  99. * Protected member variable that maps to the database column page.has_left_column
  100. * @var boolean blnHasLeftColumn
  101. *
  102. */
  103. protected $blnHasLeftColumn = null;
  104. /**
  105. * Protected member variable that maps to the database column page.has_right_column
  106. * @var boolean blnHasRightColumn
  107. *
  108. */
  109. protected $blnHasRightColumn = null;
  110. /**
  111. * Protected member variable that maps to the database column page.has_footer
  112. * @var boolean blnHasFooter
  113. *
  114. */
  115. protected $blnHasFooter = null;
  116. /**
  117. * Protected member variable that maps to the database column page.type_id
  118. * @var integer intTypeId
  119. *
  120. */
  121. protected $intTypeId = null;
  122. /**
  123. * Protected member variable that maps to the database column page.doc_type_id
  124. * @var integer intDocTypeId
  125. *
  126. */
  127. protected $intDocTypeId = null;
  128. /**
  129. * Protected member variable that maps to the database column page.status_id
  130. * @var integer intStatusId
  131. *
  132. */
  133. protected $intStatusId = null;
  134. /**
  135. * Private member variable that stores a reference to a single ContentBlock object
  136. * (of type ContentBlock), if this Page object was restored with
  137. * an expansion on the content_block_page_assn association table.
  138. * @var ContentBlock _objContentBlock;
  139. */
  140. private $_objContentBlock;
  141. /**
  142. * Private member variable that stores a reference to an array of ContentBlock objects
  143. * (of type ContentBlock[]), if this Page object was restored with
  144. * an ExpandAsArray on the content_block_page_assn association table.
  145. * @var ContentBlock[] _objContentBlockArray;
  146. */
  147. private $_objContentBlockArray = array();
  148. /**
  149. * Private member variable that stores a reference to a single ContentCategory object
  150. * (of type ContentCategory), if this Page object was restored with
  151. * an expansion on the page_content_category_assn association table.
  152. * @var ContentCategory _objContentCategory;
  153. */
  154. private $_objContentCategory;
  155. /**
  156. * Private member variable that stores a reference to an array of ContentCategory objects
  157. * (of type ContentCategory[]), if this Page object was restored with
  158. * an ExpandAsArray on the page_content_category_assn association table.
  159. * @var ContentCategory[] _objContentCategoryArray;
  160. */
  161. private $_objContentCategoryArray = array();
  162. /**
  163. * Private member variable that stores a reference to a single HtmlMetaTag object
  164. * (of type HtmlMetaTag), if this Page object was restored with
  165. * an expansion on the page_html_meta_tag_assn association table.
  166. * @var HtmlMetaTag _objHtmlMetaTag;
  167. */
  168. private $_objHtmlMetaTag;
  169. /**
  170. * Private member variable that stores a reference to an array of HtmlMetaTag objects
  171. * (of type HtmlMetaTag[]), if this Page object was restored with
  172. * an ExpandAsArray on the page_html_meta_tag_assn association table.
  173. * @var HtmlMetaTag[] _objHtmlMetaTagArray;
  174. */
  175. private $_objHtmlMetaTagArray = array();
  176. /**
  177. * Private member variable that stores a reference to a single JavaScript object
  178. * (of type JavaScript), if this Page object was restored with
  179. * an expansion on the page_java_script_assn association table.
  180. * @var JavaScript _objJavaScript;
  181. */
  182. private $_objJavaScript;
  183. /**
  184. * Private member variable that stores a reference to an array of JavaScript objects
  185. * (of type JavaScript[]), if this Page object was restored with
  186. * an ExpandAsArray on the page_java_script_assn association table.
  187. * @var JavaScript[] _objJavaScriptArray;
  188. */
  189. private $_objJavaScriptArray = array();
  190. /**
  191. * Private member variable that stores a reference to a single StyleSheet object
  192. * (of type StyleSheet), if this Page object was restored with
  193. * an expansion on the page_style_sheet_assn association table.
  194. * @var StyleSheet _objStyleSheet;
  195. */
  196. private $_objStyleSheet;
  197. /**
  198. * Private member variable that stores a reference to an array of StyleSheet objects
  199. * (of type StyleSheet[]), if this Page object was restored with
  200. * an ExpandAsArray on the page_style_sheet_assn association table.
  201. * @var StyleSheet[] _objStyleSheetArray;
  202. */
  203. private $_objStyleSheetArray = array();
  204. /**
  205. * Private member variable that stores a reference to a single Usergroup object
  206. * (of type Usergroup), if this Page object was restored with
  207. * an expansion on the page_usergroup_assn association table.
  208. * @var Usergroup _objUsergroup;
  209. */
  210. private $_objUsergroup;
  211. /**
  212. * Private member variable that stores a reference to an array of Usergroup objects
  213. * (of type Usergroup[]), if this Page object was restored with
  214. * an ExpandAsArray on the page_usergroup_assn association table.
  215. * @var Usergroup[] _objUsergroupArray;
  216. */
  217. private $_objUsergroupArray = array();
  218. /**
  219. * Private member variable that stores a reference to a single MenuItem object
  220. * (of type MenuItem), if this Page object was restored with
  221. * an expansion on the menu_item association table.
  222. * @var MenuItem _objMenuItem;
  223. */
  224. private $_objMenuItem;
  225. /**
  226. * Private member variable that stores a reference to an array of MenuItem objects
  227. * (of type MenuItem[]), if this Page object was restored with
  228. * an ExpandAsArray on the menu_item association table.
  229. * @var MenuItem[] _objMenuItemArray;
  230. */
  231. private $_objMenuItemArray = array();
  232. /**
  233. * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
  234. * columns from the run-time database query result for this object). Used by InstantiateDbRow and
  235. * GetVirtualAttribute.
  236. * @var string[] $__strVirtualAttributeArray
  237. */
  238. protected $__strVirtualAttributeArray = array();
  239. /**
  240. * Protected internal member variable that specifies whether or not this object is Restored from the database.
  241. * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
  242. * @var bool __blnRestored;
  243. */
  244. protected $__blnRestored;
  245. ///////////////////////////////
  246. // PROTECTED MEMBER OBJECTS
  247. ///////////////////////////////
  248. ///////////////////////////////
  249. // CLASS-WIDE LOAD AND COUNT METHODS
  250. ///////////////////////////////
  251. /**
  252. * Static method to retrieve the Database object that owns this class.
  253. * @return QDatabaseBase reference to the Database object that can query this class
  254. */
  255. public static function GetDatabase() {
  256. return QApplication::$Database[1];
  257. }
  258. /**
  259. * Load a Page from PK Info
  260. * @param integer $intId
  261. * @return Page
  262. */
  263. public static function Load($intId) {
  264. // Use QuerySingle to Perform the Query
  265. return Page::QuerySingle(
  266. QQ::Equal(QQN::Page()->Id, $intId)
  267. );
  268. }
  269. /**
  270. * Load all Pages
  271. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  272. * @return Page[]
  273. */
  274. public static function LoadAll($objOptionalClauses = null) {
  275. // Call Page::QueryArray to perform the LoadAll query
  276. try {
  277. return Page::QueryArray(QQ::All(), $objOptionalClauses);
  278. } catch (QCallerException $objExc) {
  279. $objExc->IncrementOffset();
  280. throw $objExc;
  281. }
  282. }
  283. /**
  284. * Count all Pages
  285. * @return int
  286. */
  287. public static function CountAll() {
  288. // Call Page::QueryCount to perform the CountAll query
  289. return Page::QueryCount(QQ::All());
  290. }
  291. ///////////////////////////////
  292. // QCODO QUERY-RELATED METHODS
  293. ///////////////////////////////
  294. /**
  295. * Internally called method to assist with calling Qcodo Query for this class
  296. * on load methods.
  297. * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
  298. * @param QQCondition $objConditions any conditions on the query, itself
  299. * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
  300. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
  301. * @param boolean $blnCountOnly only select a rowcount
  302. * @return string the query statement
  303. */
  304. protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
  305. // Get the Database Object for this Class
  306. $objDatabase = Page::GetDatabase();
  307. // Create/Build out the QueryBuilder object with Page-specific SELET and FROM fields
  308. $objQueryBuilder = new QQueryBuilder($objDatabase, 'page');
  309. Page::GetSelectFields($objQueryBuilder);
  310. $objQueryBuilder->AddFromItem('page');
  311. // Set "CountOnly" option (if applicable)
  312. if ($blnCountOnly)
  313. $objQueryBuilder->SetCountOnlyFlag();
  314. // Apply Any Conditions
  315. if ($objConditions)
  316. try {
  317. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  318. } catch (QCallerException $objExc) {
  319. $objExc->IncrementOffset();
  320. throw $objExc;
  321. }
  322. // Iterate through all the Optional Clauses (if any) and perform accordingly
  323. if ($objOptionalClauses) {
  324. if ($objOptionalClauses instanceof QQClause)
  325. $objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
  326. else if (is_array($objOptionalClauses))
  327. foreach ($objOptionalClauses as $objClause)
  328. $objClause->UpdateQueryBuilder($objQueryBuilder);
  329. else
  330. throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
  331. }
  332. // Get the SQL Statement
  333. $strQuery = $objQueryBuilder->GetStatement();
  334. // Prepare the Statement with the Query Parameters (if applicable)
  335. if ($mixParameterArray) {
  336. if (is_array($mixParameterArray)) {
  337. if (count($mixParameterArray))
  338. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  339. // Ensure that there are no other Unresolved Named Parameters
  340. if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
  341. throw new QCallerException('Unresolved named parameters in the query');
  342. } else
  343. throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
  344. }
  345. // Return the Objects
  346. return $strQuery;
  347. }
  348. /**
  349. * Static Qcodo Query method to query for a single Page object.
  350. * Uses BuildQueryStatment to perform most of the work.
  351. * @param QQCondition $objConditions any conditions on the query, itself
  352. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  353. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  354. * @return Page the queried object
  355. */
  356. public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  357. // Get the Query Statement
  358. try {
  359. $strQuery = Page::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  360. } catch (QCallerException $objExc) {
  361. $objExc->IncrementOffset();
  362. throw $objExc;
  363. }
  364. // Perform the Query, Get the First Row, and Instantiate a new Page object
  365. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  366. return Page::InstantiateDbRow($objDbResult->GetNextRow(), null, null, null, $objQueryBuilder->ColumnAliasArray);
  367. }
  368. /**
  369. * Static Qcodo Query method to query for an array of Page objects.
  370. * Uses BuildQueryStatment to perform most of the work.
  371. * @param QQCondition $objConditions any conditions on the query, itself
  372. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  373. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  374. * @return Page[] the queried objects as an array
  375. */
  376. public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  377. // Get the Query Statement
  378. try {
  379. $strQuery = Page::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  380. } catch (QCallerException $objExc) {
  381. $objExc->IncrementOffset();
  382. throw $objExc;
  383. }
  384. // Perform the Query and Instantiate the Array Result
  385. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  386. return Page::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  387. }
  388. /**
  389. * Static Qcodo Query method to query for a count of Page objects.
  390. * Uses BuildQueryStatment to perform most of the work.
  391. * @param QQCondition $objConditions any conditions on the query, itself
  392. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  393. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  394. * @return integer the count of queried objects as an integer
  395. */
  396. public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  397. // Get the Query Statement
  398. try {
  399. $strQuery = Page::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
  400. } catch (QCallerException $objExc) {
  401. $objExc->IncrementOffset();
  402. throw $objExc;
  403. }
  404. // Perform the Query and return the row_count
  405. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  406. // Figure out if the query is using GroupBy
  407. $blnGrouped = false;
  408. if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
  409. if ($objClause instanceof QQGroupBy) {
  410. $blnGrouped = true;
  411. break;
  412. }
  413. }
  414. if ($blnGrouped)
  415. // Groups in this query - return the count of Groups (which is the count of all rows)
  416. return $objDbResult->CountRows();
  417. else {
  418. // No Groups - return the sql-calculated count(*) value
  419. $strDbRow = $objDbResult->FetchRow();
  420. return QType::Cast($strDbRow[0], QType::Integer);
  421. }
  422. }
  423. /* public static function QueryArrayCached($strConditions, $mixParameterArray = null) {
  424. // Get the Database Object for this Class
  425. $objDatabase = Page::GetDatabase();
  426. // Lookup the QCache for This Query Statement
  427. $objCache = new QCache('query', 'page_' . serialize($strConditions));
  428. if (!($strQuery = $objCache->GetData())) {
  429. // Not Found -- Go ahead and Create/Build out a new QueryBuilder object with Page-specific fields
  430. $objQueryBuilder = new QQueryBuilder($objDatabase);
  431. Page::GetSelectFields($objQueryBuilder);
  432. Page::GetFromFields($objQueryBuilder);
  433. // Ensure the Passed-in Conditions is a string
  434. try {
  435. $strConditions = QType::Cast($strConditions, QType::String);
  436. } catch (QCallerException $objExc) {
  437. $objExc->IncrementOffset();
  438. throw $objExc;
  439. }
  440. // Create the Conditions object, and apply it
  441. $objConditions = eval('return ' . $strConditions . ';');
  442. // Apply Any Conditions
  443. if ($objConditions)
  444. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  445. // Get the SQL Statement
  446. $strQuery = $objQueryBuilder->GetStatement();
  447. // Save the SQL Statement in the Cache
  448. $objCache->SaveData($strQuery);
  449. }
  450. // Prepare the Statement with the Parameters
  451. if ($mixParameterArray)
  452. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  453. // Perform the Query and Instantiate the Array Result
  454. $objDbResult = $objDatabase->Query($strQuery);
  455. return Page::InstantiateDbResult($objDbResult);
  456. }*/
  457. /**
  458. * Updates a QQueryBuilder with the SELECT fields for this Page
  459. * @param QQueryBuilder $objBuilder the Query Builder object to update
  460. * @param string $strPrefix optional prefix to add to the SELECT fields
  461. */
  462. public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
  463. if ($strPrefix) {
  464. $strTableName = $strPrefix;
  465. $strAliasPrefix = $strPrefix . '__';
  466. } else {
  467. $strTableName = 'page';
  468. $strAliasPrefix = '';
  469. }
  470. $objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
  471. $objBuilder->AddSelectItem($strTableName, 'creation_date', $strAliasPrefix . 'creation_date');
  472. $objBuilder->AddSelectItem($strTableName, 'last_modification', $strAliasPrefix . 'last_modification');
  473. $objBuilder->AddSelectItem($strTableName, 'name', $strAliasPrefix . 'name');
  474. $objBuilder->AddSelectItem($strTableName, 'title', $strAliasPrefix . 'title');
  475. $objBuilder->AddSelectItem($strTableName, 'uri', $strAliasPrefix . 'uri');
  476. $objBuilder->AddSelectItem($strTableName, 'has_header', $strAliasPrefix . 'has_header');
  477. $objBuilder->AddSelectItem($strTableName, 'has_left_column', $strAliasPrefix . 'has_left_column');
  478. $objBuilder->AddSelectItem($strTableName, 'has_right_column', $strAliasPrefix . 'has_right_column');
  479. $objBuilder->AddSelectItem($strTableName, 'has_footer', $strAliasPrefix . 'has_footer');
  480. $objBuilder->AddSelectItem($strTableName, 'type_id', $strAliasPrefix . 'type_id');
  481. $objBuilder->AddSelectItem($strTableName, 'doc_type_id', $strAliasPrefix . 'doc_type_id');
  482. $objBuilder->AddSelectItem($strTableName, 'status_id', $strAliasPrefix . 'status_id');
  483. }
  484. ///////////////////////////////
  485. // INSTANTIATION-RELATED METHODS
  486. ///////////////////////////////
  487. /**
  488. * Instantiate a Page from a Database Row.
  489. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  490. * is calling this Page::InstantiateDbRow in order to perform
  491. * early binding on referenced objects.
  492. * @param DatabaseRowBase $objDbRow
  493. * @param string $strAliasPrefix
  494. * @param string $strExpandAsArrayNodes
  495. * @param QBaseClass $objPreviousItem
  496. * @param string[] $strColumnAliasArray
  497. * @return Page
  498. */
  499. public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) {
  500. // If blank row, return null
  501. if (!$objDbRow)
  502. return null;
  503. // See if we're doing an array expansion on the previous item
  504. $strAlias = $strAliasPrefix . 'id';
  505. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  506. if (($strExpandAsArrayNodes) && ($objPreviousItem) &&
  507. ($objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer'))) {
  508. // We are. Now, prepare to check for ExpandAsArray clauses
  509. $blnExpandedViaArray = false;
  510. if (!$strAliasPrefix)
  511. $strAliasPrefix = 'page__';
  512. $strAlias = $strAliasPrefix . 'contentblock__content_block_id__id';
  513. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  514. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  515. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  516. if ($intPreviousChildItemCount = count($objPreviousItem->_objContentBlockArray)) {
  517. $objPreviousChildItem = $objPreviousItem->_objContentBlockArray[$intPreviousChildItemCount - 1];
  518. $objChildItem = ContentBlock::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentblock__content_block_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  519. if ($objChildItem)
  520. $objPreviousItem->_objContentBlockArray[] = $objChildItem;
  521. } else
  522. $objPreviousItem->_objContentBlockArray[] = ContentBlock::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentblock__content_block_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  523. $blnExpandedViaArray = true;
  524. }
  525. $strAlias = $strAliasPrefix . 'contentcategory__content_category_id__id';
  526. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  527. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  528. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  529. if ($intPreviousChildItemCount = count($objPreviousItem->_objContentCategoryArray)) {
  530. $objPreviousChildItem = $objPreviousItem->_objContentCategoryArray[$intPreviousChildItemCount - 1];
  531. $objChildItem = ContentCategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentcategory__content_category_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  532. if ($objChildItem)
  533. $objPreviousItem->_objContentCategoryArray[] = $objChildItem;
  534. } else
  535. $objPreviousItem->_objContentCategoryArray[] = ContentCategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentcategory__content_category_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  536. $blnExpandedViaArray = true;
  537. }
  538. $strAlias = $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__id';
  539. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  540. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  541. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  542. if ($intPreviousChildItemCount = count($objPreviousItem->_objHtmlMetaTagArray)) {
  543. $objPreviousChildItem = $objPreviousItem->_objHtmlMetaTagArray[$intPreviousChildItemCount - 1];
  544. $objChildItem = HtmlMetaTag::InstantiateDbRow($objDbRow, $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  545. if ($objChildItem)
  546. $objPreviousItem->_objHtmlMetaTagArray[] = $objChildItem;
  547. } else
  548. $objPreviousItem->_objHtmlMetaTagArray[] = HtmlMetaTag::InstantiateDbRow($objDbRow, $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  549. $blnExpandedViaArray = true;
  550. }
  551. $strAlias = $strAliasPrefix . 'javascript__java_script_id__id';
  552. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  553. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  554. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  555. if ($intPreviousChildItemCount = count($objPreviousItem->_objJavaScriptArray)) {
  556. $objPreviousChildItem = $objPreviousItem->_objJavaScriptArray[$intPreviousChildItemCount - 1];
  557. $objChildItem = JavaScript::InstantiateDbRow($objDbRow, $strAliasPrefix . 'javascript__java_script_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  558. if ($objChildItem)
  559. $objPreviousItem->_objJavaScriptArray[] = $objChildItem;
  560. } else
  561. $objPreviousItem->_objJavaScriptArray[] = JavaScript::InstantiateDbRow($objDbRow, $strAliasPrefix . 'javascript__java_script_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  562. $blnExpandedViaArray = true;
  563. }
  564. $strAlias = $strAliasPrefix . 'stylesheet__style_sheet_id__id';
  565. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  566. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  567. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  568. if ($intPreviousChildItemCount = count($objPreviousItem->_objStyleSheetArray)) {
  569. $objPreviousChildItem = $objPreviousItem->_objStyleSheetArray[$intPreviousChildItemCount - 1];
  570. $objChildItem = StyleSheet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'stylesheet__style_sheet_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  571. if ($objChildItem)
  572. $objPreviousItem->_objStyleSheetArray[] = $objChildItem;
  573. } else
  574. $objPreviousItem->_objStyleSheetArray[] = StyleSheet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'stylesheet__style_sheet_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  575. $blnExpandedViaArray = true;
  576. }
  577. $strAlias = $strAliasPrefix . 'usergroup__usergroup_id__id';
  578. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  579. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  580. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  581. if ($intPreviousChildItemCount = count($objPreviousItem->_objUsergroupArray)) {
  582. $objPreviousChildItem = $objPreviousItem->_objUsergroupArray[$intPreviousChildItemCount - 1];
  583. $objChildItem = Usergroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'usergroup__usergroup_id__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  584. if ($objChildItem)
  585. $objPreviousItem->_objUsergroupArray[] = $objChildItem;
  586. } else
  587. $objPreviousItem->_objUsergroupArray[] = Usergroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'usergroup__usergroup_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  588. $blnExpandedViaArray = true;
  589. }
  590. $strAlias = $strAliasPrefix . 'menuitem__id';
  591. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  592. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  593. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  594. if ($intPreviousChildItemCount = count($objPreviousItem->_objMenuItemArray)) {
  595. $objPreviousChildItem = $objPreviousItem->_objMenuItemArray[$intPreviousChildItemCount - 1];
  596. $objChildItem = MenuItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'menuitem__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  597. if ($objChildItem)
  598. $objPreviousItem->_objMenuItemArray[] = $objChildItem;
  599. } else
  600. $objPreviousItem->_objMenuItemArray[] = MenuItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'menuitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  601. $blnExpandedViaArray = true;
  602. }
  603. // Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
  604. if ($blnExpandedViaArray)
  605. return false;
  606. else if ($strAliasPrefix == 'page__')
  607. $strAliasPrefix = null;
  608. }
  609. // Create a new instance of the Page object
  610. $objToReturn = new Page();
  611. $objToReturn->__blnRestored = true;
  612. $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
  613. $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
  614. $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date';
  615. $objToReturn->strCreationDate = $objDbRow->GetColumn($strAliasName, 'VarChar');
  616. $strAliasName = array_key_exists($strAliasPrefix . 'last_modification', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_modification'] : $strAliasPrefix . 'last_modification';
  617. $objToReturn->strLastModification = $objDbRow->GetColumn($strAliasName, 'VarChar');
  618. $strAliasName = array_key_exists($strAliasPrefix . 'name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name'] : $strAliasPrefix . 'name';
  619. $objToReturn->strName = $objDbRow->GetColumn($strAliasName, 'VarChar');
  620. $strAliasName = array_key_exists($strAliasPrefix . 'title', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'title'] : $strAliasPrefix . 'title';
  621. $objToReturn->strTitle = $objDbRow->GetColumn($strAliasName, 'VarChar');
  622. $strAliasName = array_key_exists($strAliasPrefix . 'uri', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'uri'] : $strAliasPrefix . 'uri';
  623. $objToReturn->strUri = $objDbRow->GetColumn($strAliasName, 'VarChar');
  624. $strAliasName = array_key_exists($strAliasPrefix . 'has_header', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'has_header'] : $strAliasPrefix . 'has_header';
  625. $objToReturn->blnHasHeader = $objDbRow->GetColumn($strAliasName, 'Bit');
  626. $strAliasName = array_key_exists($strAliasPrefix . 'has_left_column', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'has_left_column'] : $strAliasPrefix . 'has_left_column';
  627. $objToReturn->blnHasLeftColumn = $objDbRow->GetColumn($strAliasName, 'Bit');
  628. $strAliasName = array_key_exists($strAliasPrefix . 'has_right_column', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'has_right_column'] : $strAliasPrefix . 'has_right_column';
  629. $objToReturn->blnHasRightColumn = $objDbRow->GetColumn($strAliasName, 'Bit');
  630. $strAliasName = array_key_exists($strAliasPrefix . 'has_footer', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'has_footer'] : $strAliasPrefix . 'has_footer';
  631. $objToReturn->blnHasFooter = $objDbRow->GetColumn($strAliasName, 'Bit');
  632. $strAliasName = array_key_exists($strAliasPrefix . 'type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'type_id'] : $strAliasPrefix . 'type_id';
  633. $objToReturn->intTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
  634. $strAliasName = array_key_exists($strAliasPrefix . 'doc_type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'doc_type_id'] : $strAliasPrefix . 'doc_type_id';
  635. $objToReturn->intDocTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
  636. $strAliasName = array_key_exists($strAliasPrefix . 'status_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status_id'] : $strAliasPrefix . 'status_id';
  637. $objToReturn->intStatusId = $objDbRow->GetColumn($strAliasName, 'Integer');
  638. // Instantiate Virtual Attributes
  639. foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
  640. $strVirtualPrefix = $strAliasPrefix . '__';
  641. $strVirtualPrefixLength = strlen($strVirtualPrefix);
  642. if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
  643. $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
  644. }
  645. // Prepare to Check for Early/Virtual Binding
  646. if (!$strAliasPrefix)
  647. $strAliasPrefix = 'page__';
  648. // Check for ContentBlock Virtual Binding
  649. $strAlias = $strAliasPrefix . 'contentblock__content_block_id__id';
  650. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  651. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  652. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  653. $objToReturn->_objContentBlockArray[] = ContentBlock::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentblock__content_block_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  654. else
  655. $objToReturn->_objContentBlock = ContentBlock::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentblock__content_block_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  656. }
  657. // Check for ContentCategory Virtual Binding
  658. $strAlias = $strAliasPrefix . 'contentcategory__content_category_id__id';
  659. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  660. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  661. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  662. $objToReturn->_objContentCategoryArray[] = ContentCategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentcategory__content_category_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  663. else
  664. $objToReturn->_objContentCategory = ContentCategory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'contentcategory__content_category_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  665. }
  666. // Check for HtmlMetaTag Virtual Binding
  667. $strAlias = $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__id';
  668. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  669. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  670. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  671. $objToReturn->_objHtmlMetaTagArray[] = HtmlMetaTag::InstantiateDbRow($objDbRow, $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  672. else
  673. $objToReturn->_objHtmlMetaTag = HtmlMetaTag::InstantiateDbRow($objDbRow, $strAliasPrefix . 'htmlmetatag__html_meta_tag_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  674. }
  675. // Check for JavaScript Virtual Binding
  676. $strAlias = $strAliasPrefix . 'javascript__java_script_id__id';
  677. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  678. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  679. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  680. $objToReturn->_objJavaScriptArray[] = JavaScript::InstantiateDbRow($objDbRow, $strAliasPrefix . 'javascript__java_script_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  681. else
  682. $objToReturn->_objJavaScript = JavaScript::InstantiateDbRow($objDbRow, $strAliasPrefix . 'javascript__java_script_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  683. }
  684. // Check for StyleSheet Virtual Binding
  685. $strAlias = $strAliasPrefix . 'stylesheet__style_sheet_id__id';
  686. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  687. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  688. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  689. $objToReturn->_objStyleSheetArray[] = StyleSheet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'stylesheet__style_sheet_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  690. else
  691. $objToReturn->_objStyleSheet = StyleSheet::InstantiateDbRow($objDbRow, $strAliasPrefix . 'stylesheet__style_sheet_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  692. }
  693. // Check for Usergroup Virtual Binding
  694. $strAlias = $strAliasPrefix . 'usergroup__usergroup_id__id';
  695. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  696. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  697. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  698. $objToReturn->_objUsergroupArray[] = Usergroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'usergroup__usergroup_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  699. else
  700. $objToReturn->_objUsergroup = Usergroup::InstantiateDbRow($objDbRow, $strAliasPrefix . 'usergroup__usergroup_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  701. }
  702. // Check for MenuItem Virtual Binding
  703. $strAlias = $strAliasPrefix . 'menuitem__id';
  704. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  705. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  706. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  707. $objToReturn->_objMenuItemArray[] = MenuItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'menuitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  708. else
  709. $objToReturn->_objMenuItem = MenuItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'menuitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  710. }
  711. return $objToReturn;
  712. }
  713. /**
  714. * Instantiate an array of Pages from a Database Result
  715. * @param DatabaseResultBase $objDbResult
  716. * @param string $strExpandAsArrayNodes
  717. * @param string[] $strColumnAliasArray
  718. * @return Page[]
  719. */
  720. public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
  721. $objToReturn = array();
  722. if (!$strColumnAliasArray)
  723. $strColumnAliasArray = array();
  724. // If blank resultset, then return empty array
  725. if (!$objDbResult)
  726. return $objToReturn;
  727. // Load up the return array with each row
  728. if ($strExpandAsArrayNodes) {
  729. $objLastRowItem = null;
  730. while ($objDbRow = $objDbResult->GetNextRow()) {
  731. $objItem = Page::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
  732. if ($objItem) {
  733. $objToReturn[] = $objItem;
  734. $objLastRowItem = $objItem;
  735. }
  736. }
  737. } else {
  738. while ($objDbRow = $objDbResult->GetNextRow())
  739. $objToReturn[] = Page::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
  740. }
  741. return $objToReturn;
  742. }
  743. ///////////////////////////////////////////////////
  744. // INDEX-BASED LOAD METHODS (Single Load and Array)
  745. ///////////////////////////////////////////////////
  746. /**
  747. * Load a single Page object,
  748. * by Id Index(es)
  749. * @param integer $intId
  750. * @return Page
  751. */
  752. public static function LoadById($intId) {
  753. return Page::QuerySingle(
  754. QQ::Equal(QQN::Page()->Id, $intId)
  755. );
  756. }
  757. /**
  758. * Load a single Page object,
  759. * by Name Index(es)
  760. * @param string $strName
  761. * @return Page
  762. */
  763. public static function LoadByName($strName) {
  764. return Page::QuerySingle(
  765. QQ::Equal(QQN::Page()->Name, $strName)
  766. );
  767. }
  768. /**
  769. * Load an array of Page objects,
  770. * by DocTypeId Index(es)
  771. * @param integer $intDocTypeId
  772. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  773. * @return Page[]
  774. */
  775. public static function LoadArrayByDocTypeId($intDocTypeId, $objOptionalClauses = null) {
  776. // Call Page::QueryArray to perform the LoadArrayByDocTypeId query
  777. try {
  778. return Page::QueryArray(
  779. QQ::Equal(QQN::Page()->DocTypeId, $intDocTypeId),
  780. $objOptionalClauses);
  781. } catch (QCallerException $objExc) {
  782. $objExc->IncrementOffset();
  783. throw $objExc;
  784. }
  785. }
  786. /**
  787. * Count Pages
  788. * by DocTypeId Index(es)
  789. * @param integer $intDocTypeId
  790. * @return int
  791. */
  792. public static function CountByDocTypeId($intDocTypeId) {
  793. // Call Page::QueryCount to perform the CountByDocTypeId query
  794. return Page::QueryCount(
  795. QQ::Equal(QQN::Page()->DocTypeId, $intDocTypeId)
  796. );
  797. }
  798. /**
  799. * Load an array of Page objects,
  800. * by TypeId Index(es)
  801. * @param integer $intTypeId
  802. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  803. * @return Page[]
  804. */
  805. public static function LoadArrayByTypeId($intTypeId, $objOptionalClauses = null) {
  806. // Call Page::QueryArray to perform the LoadArrayByTypeId query
  807. try {
  808. return Page::QueryArray(
  809. QQ::Equal(QQN::Page()->TypeId, $intTypeId),
  810. $objOptionalClauses);
  811. } catch (QCallerException $objExc) {
  812. $objExc->IncrementOffset();
  813. throw $objExc;
  814. }
  815. }
  816. /**
  817. * Count Pages
  818. * by TypeId Index(es)
  819. * @param integer $intTypeId
  820. * @return int
  821. */
  822. public static function CountByTypeId($intTypeId) {
  823. // Call Page::QueryCount to perform the CountByTypeId query
  824. return Page::QueryCount(
  825. QQ::Equal(QQN::Page()->TypeId, $intTypeId)
  826. );
  827. }
  828. /**
  829. * Load an array of Page objects,
  830. * by StatusId Index(es)
  831. * @param integer $intStatusId
  832. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  833. * @return Page[]
  834. */
  835. public static function LoadArrayByStatusId($intStatusId, $objOptionalClauses = null) {
  836. // Call Page::QueryArray to perform the LoadArrayByStatusId query
  837. try {
  838. return Page::QueryArray(
  839. QQ::Equal(QQN::Page()->StatusId, $intStatusId),
  840. $objOptionalClauses);
  841. } catch (QCallerException $objExc) {
  842. $objExc->IncrementOffset();
  843. throw $objExc;
  844. }
  845. }
  846. /**
  847. * Count Pages
  848. * by StatusId Index(es)
  849. * @param integer $intStatusId
  850. * @return int
  851. */
  852. public static function CountByStatusId($intStatusId) {
  853. // Call Page::QueryCount to perform the CountByStatusId query
  854. return Page::QueryCount(
  855. QQ::Equal(QQN::Page()->StatusId, $intStatusId)
  856. );
  857. }
  858. ////////////////////////////////////////////////////
  859. // INDEX-BASED LOAD METHODS (Array via Many to Many)
  860. ////////////////////////////////////////////////////
  861. /**
  862. * Load an array of ContentBlock objects for a given ContentBlock
  863. * via the content_block_page_assn table
  864. * @param integer $intContentBlockId
  865. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  866. * @return Page[]
  867. */
  868. public static function LoadArrayByContentBlock($intContentBlockId, $objOptionalClauses = null) {
  869. // Call Page::QueryArray to perform the LoadArrayByContentBlock query
  870. try {
  871. return Page::QueryArray(
  872. QQ::Equal(QQN::Page()->ContentBlock->ContentBlockId, $intContentBlockId),
  873. $objOptionalClauses
  874. );
  875. } catch (QCallerException $objExc) {
  876. $objExc->IncrementOffset();
  877. throw $objExc;
  878. }
  879. }
  880. /**
  881. * Count Pages for a given ContentBlock
  882. * via the content_block_page_assn table
  883. * @param integer $intContentBlockId
  884. * @return int
  885. */
  886. public static function CountByContentBlock($intContentBlockId) {
  887. return Page::QueryCount(
  888. QQ::Equal(QQN::Page()->ContentBlock->ContentBlockId, $intContentBlockId)
  889. );
  890. }
  891. /**
  892. * Load an array of ContentCategory objects for a given ContentCategory
  893. * via the page_content_category_assn table
  894. * @param integer $intContentCategoryId
  895. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  896. * @return Page[]
  897. */
  898. public static function LoadArrayByContentCategory($intContentCategoryId, $objOptionalClauses = null) {
  899. // Call Page::QueryArray to perform the LoadArrayByContentCategory query
  900. try {
  901. return Page::QueryArray(
  902. QQ::Equal(QQN::Page()->ContentCategory->ContentCategoryId, $intContentCategoryId),
  903. $objOptionalClauses
  904. );
  905. } catch (QCallerException $objExc) {
  906. $objExc->IncrementOffset();
  907. throw $objExc;
  908. }
  909. }
  910. /**
  911. * Count Pages for a given ContentCategory
  912. * via the page_content_category_assn table
  913. * @param integer $intContentCategoryId
  914. * @return int
  915. */
  916. public static function CountByContentCategory($intContentCategoryId) {
  917. return Page::QueryCount(
  918. QQ::Equal(QQN::Page()->ContentCategory->ContentCategoryId, $intContentCategoryId)
  919. );
  920. }
  921. /**
  922. * Load an array of HtmlMetaTag objects for a given HtmlMetaTag
  923. * via the page_html_meta_tag_assn table
  924. * @param integer $intHtmlMetaTagId
  925. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  926. * @return Page[]
  927. */
  928. public static function LoadArrayByHtmlMetaTag($intHtmlMetaTagId, $objOptionalClauses = null) {
  929. // Call Page::QueryArray to perform the LoadArrayByHtmlMetaTag query
  930. try {
  931. return Page::QueryArray(
  932. QQ::Equal(QQN::Page()->HtmlMetaTag->HtmlMetaTagId, $intHtmlMetaTagId),
  933. $objOptionalClauses
  934. );
  935. } catch (QCallerException $objExc) {
  936. $objExc->IncrementOffset();
  937. throw $objExc;
  938. }
  939. }
  940. /**
  941. * Count Pages for a given HtmlMetaTag
  942. * via the page_html_meta_tag_assn table
  943. * @param integer $intHtmlMetaTagId
  944. * @return int
  945. */
  946. public static function CountByHtmlMetaTag($intHtmlMetaTagId) {
  947. return Page::QueryCount(
  948. QQ::Equal(QQN::Page()->HtmlMetaTag->HtmlMetaTagId, $intHtmlMetaTagId)
  949. );
  950. }
  951. /**
  952. * Load an array of JavaScript objects for a given JavaScript
  953. * via the page_java_script_assn table
  954. * @param integer $intJavaScriptId
  955. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  956. * @return Page[]
  957. */
  958. public static function LoadArrayByJavaScript($intJavaScriptId, $objOptionalClauses = null) {
  959. // Call Page::QueryArray to perform the LoadArrayByJavaScript query
  960. try {
  961. return Page::QueryArray(
  962. QQ::Equal(QQN::Page()->JavaScript->JavaScriptId, $intJavaScriptId),
  963. $objOptionalClauses
  964. );
  965. } catch (QCallerException $objExc) {
  966. $objExc->IncrementOffset();
  967. throw $objExc;
  968. }
  969. }
  970. /**
  971. * Count Pages for a given JavaScript
  972. * via the page_java_script_assn table
  973. * @param integer $intJavaScriptId
  974. * @return int
  975. */
  976. public static function CountByJavaScript($intJavaScriptId) {
  977. return Page::QueryCount(
  978. QQ::Equal(QQN::Page()->JavaScript->JavaScriptId, $intJavaScriptId)
  979. );
  980. }
  981. /**
  982. * Load an array of StyleSheet objects for a given StyleSheet
  983. * via the page_style_sheet_assn table
  984. * @param integer $intStyleSheetId
  985. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  986. * @return Page[]
  987. */
  988. public static function LoadArrayByStyleSheet($intStyleSheetId, $objOptionalClauses = null) {
  989. // Call Page::QueryArray to perform the LoadArrayByStyleSheet query
  990. try {
  991. return Page::QueryArray(
  992. QQ::Equal(QQN::Page()->StyleSheet->StyleSheetId, $intStyleSheetId),
  993. $objOptionalClauses
  994. );
  995. } catch (QCallerException $objExc) {
  996. $objExc->IncrementOffset();
  997. throw $objExc;
  998. }
  999. }
  1000. /**
  1001. * Count Pages for a given StyleSheet
  1002. * via the page_style_sheet_assn table
  1003. * @param integer $intStyleSheetId
  1004. * @return int
  1005. */
  1006. public static function CountByStyleSheet($intStyleSheetId) {
  1007. return Page::QueryCount(
  1008. QQ::Equal(QQN::Page()->StyleSheet->StyleSheetId, $intStyleSheetId)
  1009. );
  1010. }
  1011. /**
  1012. * Load an array of Usergroup objects for a given Usergroup
  1013. * via the page_usergroup_assn table
  1014. * @param integer $intUsergroupId
  1015. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1016. * @return Page[]
  1017. */
  1018. public static function LoadArrayByUsergroup($intUsergroupId, $objOptionalClauses = null) {
  1019. // Call Page::QueryArray to perform the LoadArrayByUsergroup query
  1020. try {
  1021. return Page::QueryArray(
  1022. QQ::Equal(QQN::Page()->Usergroup->UsergroupId, $intUsergroupId),
  1023. $objOptionalClauses
  1024. );
  1025. } catch (QCallerException $objExc) {
  1026. $objExc->IncrementOffset();
  1027. throw $objExc;
  1028. }
  1029. }
  1030. /**
  1031. * Count Pages for a given Usergroup
  1032. * via the page_usergroup_assn table
  1033. * @param integer $intUsergroupId
  1034. * @return int
  1035. */
  1036. public static function CountByUsergroup($intUsergroupId) {
  1037. return Page::QueryCount(
  1038. QQ::Equal(QQN::Page()->Usergroup->UsergroupId, $intUsergroupId)
  1039. );
  1040. }
  1041. //////////////////////////
  1042. // SAVE, DELETE AND RELOAD
  1043. //////////////////////////
  1044. /**
  1045. * Save this Page
  1046. * @param bool $blnForceInsert
  1047. * @param bool $blnForceUpdate
  1048. * @return int
  1049. */
  1050. public function Save($blnForceInsert = false, $blnForceUpdate = false) {
  1051. // Get the Database Object for this Class
  1052. $objDatabase = Page::GetDatabase();
  1053. $mixToReturn = null;
  1054. try {
  1055. if ((!$this->__blnRestored) || ($blnForceInsert)) {
  1056. // Perform an INSERT query
  1057. $objDatabase->NonQuery('
  1058. INSERT INTO `page` (
  1059. `name`,
  1060. `title`,
  1061. `uri`,
  1062. `has_header`,
  1063. `has_left_column`,
  1064. `has_right_column`,
  1065. `has_footer`,
  1066. `type_id`,
  1067. `doc_type_id`,
  1068. `status_id`
  1069. ) VALUES (
  1070. ' . $objDatabase->SqlVariable($this->strName) . ',
  1071. ' . $objDatabase->SqlVariable($this->strTitle) . ',
  1072. ' . $objDatabase->SqlVariable($this->strUri) . ',
  1073. ' . $objDatabase->SqlVariable($this->blnHasHeader) . ',
  1074. ' . $objDatabase->SqlVariable($this->blnHasLeftColumn) . ',
  1075. ' . $objDatabase->SqlVariable($this->blnHasRightColumn) . ',
  1076. ' . $objDatabase->SqlVariable($this->blnHasFooter) . ',
  1077. ' . $objDatabase->SqlVariable($this->intTypeId) . ',
  1078. ' . $objDatabase->SqlVariable($this->intDocTypeId) . ',
  1079. ' . $objDatabase->SqlVariable($this->intStatusId) . '
  1080. )
  1081. ');
  1082. // Update Identity column and return its value
  1083. $mixToReturn = $this->intId = $objDatabase->InsertId('page', 'id');
  1084. } else {
  1085. // Perform an UPDATE query
  1086. // First checking for Optimistic Locking constraints (if applicable)
  1087. if (!$blnForceUpdate) {
  1088. // Perform the Optimistic Locking check
  1089. $objResult = $objDatabase->Query('
  1090. SELECT
  1091. `creation_date`
  1092. FROM
  1093. `page`
  1094. WHERE
  1095. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1096. ');
  1097. $objRow = $objResult->FetchArray();
  1098. if ($objRow[0] != $this->strCreationDate)
  1099. throw new QOptimisticLockingException('Page');
  1100. }
  1101. if (!$blnForceUpdate) {
  1102. // Perform the Optimistic Locking check
  1103. $objResult = $objDatabase->Query('
  1104. SELECT
  1105. `last_modification`
  1106. FROM
  1107. `page`
  1108. WHERE
  1109. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1110. ');
  1111. $objRow = $objResult->FetchArray();
  1112. if ($objRow[0] != $this->strLastModification)
  1113. throw new QOptimisticLockingException('Page');
  1114. }
  1115. // Perform the UPDATE query
  1116. $objDatabase->NonQuery('
  1117. UPDATE
  1118. `page`
  1119. SET
  1120. `name` = ' . $objDatabase->SqlVariable($this->strName) . ',
  1121. `title` = ' . $objDatabase->SqlVariable($this->strTitle) . ',
  1122. `uri` = ' . $objDatabase->SqlVariable($this->strUri) . ',
  1123. `has_header` = ' . $objDatabase->SqlVariable($this->blnHasHeader) . ',
  1124. `has_left_column` = ' . $objDatabase->SqlVariable($this->blnHasLeftColumn) . ',
  1125. `has_right_column` = ' . $objDatabase->SqlVariable($this->blnHasRightColumn) . ',
  1126. `has_footer` = ' . $objDatabase->SqlVariable($this->blnHasFooter) . ',
  1127. `type_id` = ' . $objDatabase->SqlVariable($this->intTypeId) . ',
  1128. `doc_type_id` = ' . $objDatabase->SqlVariable($this->intDocTypeId) . ',
  1129. `status_id` = ' . $objDatabase->SqlVariable($this->intStatusId) . '
  1130. WHERE
  1131. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1132. ');
  1133. }
  1134. } catch (QCallerException $objExc) {
  1135. $objExc->IncrementOffset();
  1136. throw $objExc;
  1137. }
  1138. // Update __blnRestored and any Non-Identity PK Columns (if applicable)
  1139. $this->__blnRestored = true;
  1140. // Update Local Timestamp
  1141. $objResult = $objDatabase->Query('
  1142. SELECT
  1143. `creation_date`
  1144. FROM
  1145. `page`
  1146. WHERE
  1147. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1148. ');
  1149. $objRow = $objResult->FetchArray();
  1150. $this->strCreationDate = $objRow[0];
  1151. // Update Local Timestamp
  1152. $objResult = $objDatabase->Query('
  1153. SELECT
  1154. `last_modification`
  1155. FROM
  1156. `page`
  1157. WHERE
  1158. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1159. ');
  1160. $objRow = $objResult->FetchArray();
  1161. $this->strLastModification = $objRow[0];
  1162. // Return
  1163. return $mixToReturn;
  1164. }
  1165. /**
  1166. * Delete this Page
  1167. * @return void
  1168. */
  1169. public function Delete() {
  1170. if ((is_null($this->intId)))
  1171. throw new QUndefinedPrimaryKeyException('Cannot delete this Page with an unset primary key.');
  1172. // Get the Database Object for this Class
  1173. $objDatabase = Page::GetDatabase();
  1174. // Perform the SQL Query
  1175. $objDatabase->NonQuery('
  1176. DELETE FROM
  1177. `page`
  1178. WHERE
  1179. `id` = ' . $objDatabase->SqlVariable($this->intId) . '');
  1180. }
  1181. /**
  1182. * Delete all Pages
  1183. * @return void
  1184. */
  1185. public static function DeleteAll() {
  1186. // Get the Database Object for this Class
  1187. $objDatabase = Page::GetDatabase();
  1188. // Perform the Query
  1189. $objDatabase->NonQuery('
  1190. DELETE FROM
  1191. `page`');
  1192. }
  1193. /**
  1194. * Truncate page table
  1195. * @return void
  1196. */
  1197. public static function Truncate() {
  1198. // Get the Database Object for this Class
  1199. $objDatabase = Page::GetDatabase();
  1200. // Perform the Query
  1201. $objDatabase->NonQuery('
  1202. TRUNCATE `page`');
  1203. }
  1204. /**
  1205. * Reload this Page from the database.
  1206. * @return void
  1207. */
  1208. public function Reload() {
  1209. // Make sure we are actually Restored from the database
  1210. if (!$this->__blnRestored)
  1211. throw new QCallerException('Cannot call Reload() on a new, unsaved Page object.');
  1212. // Reload the Object
  1213. $objReloaded = Page::Load($this->intId);
  1214. // Update $this's local variables to match
  1215. $this->strCreationDate = $objReloaded->strCreationDate;
  1216. $this->strLastModification = $objReloaded->strLastModification;
  1217. $this->strName = $objReloaded->strName;
  1218. $this->strTitle = $objReloaded->strTitle;
  1219. $this->strUri = $objReloaded->strUri;
  1220. $this->blnHasHeader = $objReloaded->blnHasHeader;
  1221. $this->blnHasLeftColumn = $objReloaded->blnHasLeftColumn;
  1222. $this->blnHasRightColumn = $objReloaded->blnHasRightColumn;
  1223. $this->blnHasFooter = $objReloaded->blnHasFooter;
  1224. $this->TypeId = $objReloaded->TypeId;
  1225. $this->DocTypeId = $objReloaded->DocTypeId;
  1226. $this->StatusId = $objReloaded->StatusId;
  1227. }
  1228. ////////////////////
  1229. // GETTORS AND SETTORS
  1230. ////////////////////
  1231. /**
  1232. * Lookup a VirtualAttribute value (if applicable). Returns NULL if none found.
  1233. * @param string $strName
  1234. * @return string
  1235. */
  1236. public function GetVirtualAttribute($strName)
  1237. {
  1238. if (array_key_exists($strName, $this->__strVirtualAttributeArray))
  1239. return $this->__strVirtualAttributeArray[$strName];
  1240. return null;
  1241. }
  1242. /**
  1243. * Override method to perform a property "Get"
  1244. * This will get the value of $strName
  1245. *
  1246. * @param string $strName Name of the property to get
  1247. * @return mixed
  1248. */
  1249. public function __get($strName)
  1250. {
  1251. switch ($strName)
  1252. {
  1253. ///////////////////
  1254. // Member Variables
  1255. ///////////////////
  1256. case 'Id':
  1257. /**
  1258. * Gets the value for intId (Read-Only PK)
  1259. * @return integer
  1260. */
  1261. return $this->intId;
  1262. case 'CreationDate':
  1263. /**
  1264. * Gets the value for strCreationDate (Read-Only Timestamp)
  1265. * @return string
  1266. */
  1267. return $this->strCreationDate;
  1268. case 'LastModification':
  1269. /**
  1270. * Gets the value for strLastModification (Read-Only Timestamp)
  1271. * @return string
  1272. */
  1273. return $this->strLastModification;
  1274. case 'Name':
  1275. /**
  1276. * Gets the value for strName (Unique)
  1277. * @return string
  1278. */
  1279. return $this->strName;
  1280. case 'Title':
  1281. /**
  1282. * Gets the value for strTitle
  1283. * @return string
  1284. */
  1285. return $this->strTitle;
  1286. case 'Uri':
  1287. /**
  1288. * Gets the value for strUri
  1289. * @return string
  1290. */
  1291. return $this->strUri;
  1292. case 'HasHeader':
  1293. /**
  1294. * Gets the value for blnHasHeader (Not Null)
  1295. * @return boolean
  1296. */
  1297. return $this->blnHasHeader;
  1298. case 'HasLeftColumn':
  1299. /**
  1300. * Gets the value for blnHasLeftColumn (Not Null)
  1301. * @return boolean
  1302. */
  1303. return $this->blnHasLeftColumn;
  1304. case 'HasRightColumn':
  1305. /**
  1306. * Gets the value for blnHasRightColumn (Not Null)
  1307. * @return boolean
  1308. */
  1309. return $this->blnHasRightColumn;
  1310. case 'HasFooter':
  1311. /**
  1312. * Gets the value for blnHasFooter (Not Null)
  1313. * @return boolean
  1314. */
  1315. return $this->blnHasFooter;
  1316. case 'TypeId':
  1317. /**
  1318. * Gets the value for intTypeId
  1319. * @return integer
  1320. */
  1321. return $this->intTypeId;
  1322. case 'DocTypeId':
  1323. /**
  1324. * Gets the value for intDocTypeId (Not Null)
  1325. * @return integer
  1326. */
  1327. return $this->intDocTypeId;
  1328. case 'StatusId':
  1329. /**
  1330. * Gets the value for intStatusId (Not Null)
  1331. * @return integer
  1332. */
  1333. return $this->intStatusId;
  1334. ///////////////////
  1335. // Member Objects
  1336. ///////////////////
  1337. ////////////////////////////
  1338. // Virtual Object References (Many to Many and Reverse References)
  1339. // (If restored via a "Many-to" expansion)
  1340. ////////////////////////////
  1341. case '_ContentBlock':
  1342. /**
  1343. * Gets the value for the private _objContentBlock (Read-Only)
  1344. * if set due to an expansion on the content_block_page_assn association table
  1345. * @return ContentBlock
  1346. */
  1347. return $this->_objContentBlock;
  1348. case '_ContentBlockArray':
  1349. /**
  1350. * Gets the value for the private _objContentBlockArray (Read-Only)
  1351. * if set due to an ExpandAsArray on the content_block_page_assn association table
  1352. * @return ContentBlock[]
  1353. */
  1354. return (array) $this->_objContentBlockArray;
  1355. case '_ContentCategory':
  1356. /**
  1357. * Gets the value for the private _objContentCategory (Read-Only)
  1358. * if set due to an expansion on the page_content_category_assn association table
  1359. * @return ContentCategory
  1360. */
  1361. return $this->_objContentCategory;
  1362. case '_ContentCategoryArray':
  1363. /**
  1364. * Gets the value for the private _objContentCategoryArray (Read-Only)
  1365. * if set due to an ExpandAsArray on the page_content_category_assn association table
  1366. * @return ContentCategory[]
  1367. */
  1368. return (array) $this->_objContentCategoryArray;
  1369. case '_HtmlMetaTag':
  1370. /**
  1371. * Gets the value for the private _objHtmlMetaTag (Read-Only)
  1372. * if set due to an expansion on the page_html_meta_tag_assn association table
  1373. * @return HtmlMetaTag
  1374. */
  1375. return $this->_objHtmlMetaTag;
  1376. case '_HtmlMetaTagArray':
  1377. /**
  1378. * Gets the value for the private _objHtmlMetaTagArray (Read-Only)
  1379. * if set due to an ExpandAsArray on the page_html_meta_tag_assn association table
  1380. * @return HtmlMetaTag[]
  1381. */
  1382. return (array) $this->_objHtmlMetaTagArray;
  1383. case '_JavaScript':
  1384. /**
  1385. * Gets the value for the private _objJavaScript (Read-Only)
  1386. * if set due to an expansion on the page_java_script_assn association table
  1387. * @return JavaScript
  1388. */
  1389. return $this->_objJavaScript;
  1390. case '_JavaScriptArray':
  1391. /**
  1392. * Gets the value for the private _objJavaScriptArray (Read-Only)
  1393. * if set due to an ExpandAsArray on the page_java_script_assn association table
  1394. * @return JavaScript[]
  1395. */
  1396. return (array) $this->_objJavaScriptArray;
  1397. case '_StyleSheet':
  1398. /**
  1399. * Gets the value for the private _objStyleSheet (Read-Only)
  1400. * if set due to an expansion on the page_style_sheet_assn association table
  1401. * @return StyleSheet
  1402. */
  1403. return $this->_objStyleSheet;
  1404. case '_StyleSheetArray':
  1405. /**
  1406. * Gets the value for the private _objStyleSheetArray (Read-Only)
  1407. * if set due to an ExpandAsArray on the page_style_sheet_assn association table
  1408. * @return StyleSheet[]
  1409. */
  1410. return (array) $this->_objStyleSheetArray;
  1411. case '_Usergroup':
  1412. /**
  1413. * Gets the value for the private _objUsergroup (Read-Only)
  1414. * if set due to an expansion on the page_usergroup_assn association table
  1415. * @return Usergroup
  1416. */
  1417. return $this->_objUsergroup;
  1418. case '_UsergroupArray':
  1419. /**
  1420. * Gets the value for the private _objUsergroupArray (Read-Only)
  1421. * if set due to an ExpandAsArray on the page_usergroup_assn association table
  1422. * @return Usergroup[]
  1423. */
  1424. return (array) $this->_objUsergroupArray;
  1425. case '_MenuItem':
  1426. /**
  1427. * Gets the value for the private _objMenuItem (Read-Only)
  1428. * if set due to an expansion on the menu_item.page_id reverse relationship
  1429. * @return MenuItem
  1430. */
  1431. return $this->_objMenuItem;
  1432. case '_MenuItemArray':
  1433. /**
  1434. * Gets the value for the private _objMenuItemArray (Read-Only)
  1435. * if set due to an ExpandAsArray on the menu_item.page_id reverse relationship
  1436. * @return MenuItem[]
  1437. */
  1438. return (array) $this->_objMenuItemArray;
  1439. case '__Restored':
  1440. return $this->__blnRestored;
  1441. default:
  1442. try {
  1443. return parent::__get($strName);
  1444. } catch (QCallerException $objExc) {
  1445. $objExc->IncrementOffset();
  1446. throw $objExc;
  1447. }
  1448. }
  1449. }
  1450. /**
  1451. * Override method to perform a property "Set"
  1452. * This will set the property $strName to be $mixValue
  1453. *
  1454. * @param string $strName Name of the property to set
  1455. * @param string $mixValue New value of the property
  1456. * @return mixed
  1457. */
  1458. public function __set($strName, $mixValue) {
  1459. switch ($strName) {
  1460. ///////////////////
  1461. // Member Variables
  1462. ///////////////////
  1463. case 'Name':
  1464. /**
  1465. * Sets the value for strName (Unique)
  1466. * @param string $mixValue
  1467. * @return string
  1468. */
  1469. try {
  1470. return ($this->strName = QType::Cast($mixValue, QType::String));
  1471. } catch (QCallerException $objExc) {
  1472. $objExc->IncrementOffset();
  1473. throw $objExc;
  1474. }
  1475. case 'Title':
  1476. /**
  1477. * Sets the value for strTitle
  1478. * @param string $mixValue
  1479. * @return string
  1480. */
  1481. try {
  1482. return ($this->strTitle = QType::Cast($mixValue, QType::String));
  1483. } catch (QCallerException $objExc) {
  1484. $objExc->IncrementOffset();
  1485. throw $objExc;
  1486. }
  1487. case 'Uri':
  1488. /**
  1489. * Sets the value for strUri
  1490. * @param string $mixValue
  1491. * @return string
  1492. */
  1493. try {
  1494. return ($this->strUri = QType::Cast($mixValue, QType::String));
  1495. } catch (QCallerException $objExc) {
  1496. $objExc->IncrementOffset();
  1497. throw $objExc;
  1498. }
  1499. case 'HasHeader':
  1500. /**
  1501. * Sets the value for blnHasHeader (Not Null)
  1502. * @param boolean $mixValue
  1503. * @return boolean
  1504. */
  1505. try {
  1506. return ($this->blnHasHeader = QType::Cast($mixValue, QType::Boolean));
  1507. } catch (QCallerException $objExc) {
  1508. $objExc->IncrementOffset();
  1509. throw $objExc;
  1510. }
  1511. case 'HasLeftColumn':
  1512. /**
  1513. * Sets the value for blnHasLeftColumn (Not Null)
  1514. * @param boolean $mixValue
  1515. * @return boolean
  1516. */
  1517. try {
  1518. return ($this->blnHasLeftColumn = QType::Cast($mixValue, QType::Boolean));
  1519. } catch (QCallerException $objExc) {
  1520. $objExc->IncrementOffset();
  1521. throw $objExc;
  1522. }
  1523. case 'HasRightColumn':
  1524. /**
  1525. * Sets the value for blnHasRightColumn (Not Null)
  1526. * @param boolean $mixValue
  1527. * @return boolean
  1528. */
  1529. try {
  1530. return ($this->blnHasRightColumn = QType::Cast($mixValue, QType::Boolean));
  1531. } catch (QCallerException $objExc) {
  1532. $objExc->IncrementOffset();
  1533. throw $objExc;
  1534. }
  1535. case 'HasFooter':
  1536. /**
  1537. * Sets the value for blnHasFooter (Not Null)
  1538. * @param boolean $mixValue
  1539. * @return boolean
  1540. */
  1541. try {
  1542. return ($this->blnHasFooter = QType::Cast($mixValue, QType::Boolean));
  1543. } catch (QCallerException $objExc) {
  1544. $objExc->IncrementOffset();
  1545. throw $objExc;
  1546. }
  1547. case 'TypeId':
  1548. /**
  1549. * Sets the value for intTypeId
  1550. * @param integer $mixValue
  1551. * @return integer
  1552. */
  1553. try {
  1554. return ($this->intTypeId = QType::Cast($mixValue, QType::Integer));
  1555. } catch (QCallerException $objExc) {
  1556. $objExc->IncrementOffset();
  1557. throw $objExc;
  1558. }
  1559. case 'DocTypeId':
  1560. /**
  1561. * Sets the value for intDocTypeId (Not Null)
  1562. * @param integer $mixValue
  1563. * @return integer
  1564. */
  1565. try {
  1566. return ($this->intDocTypeId = QType::Cast($mixValue, QType::Integer));
  1567. } catch (QCallerException $objExc) {
  1568. $objExc->IncrementOffset();
  1569. throw $objExc;
  1570. }
  1571. case 'StatusId':
  1572. /**
  1573. * Sets the value for intStatusId (Not Null)
  1574. * @param integer $mixValue
  1575. * @return integer
  1576. */
  1577. try {
  1578. return ($this->intStatusId = QType::Cast($mixValue, QType::Integer));
  1579. } catch (QCallerException $objExc) {
  1580. $objExc->IncrementOffset();
  1581. throw $objExc;
  1582. }
  1583. ///////////////////
  1584. // Member Objects
  1585. ///////////////////
  1586. default:
  1587. try {
  1588. return parent::__set($strName, $mixValue);
  1589. } catch (QCallerException $objExc) {
  1590. $objExc->IncrementOffset();
  1591. throw $objExc;
  1592. }
  1593. }
  1594. }
  1595. ///////////////////////////////
  1596. // ASSOCIATED OBJECTS' METHODS
  1597. ///////////////////////////////
  1598. // Related Objects' Methods for MenuItem
  1599. //-------------------------------------------------------------------
  1600. /**
  1601. * Gets all associated MenuItems as an array of MenuItem objects
  1602. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1603. * @return MenuItem[]
  1604. */
  1605. public function GetMenuItemArray($objOptionalClauses = null) {
  1606. if ((is_null($this->intId)))
  1607. return array();
  1608. try {
  1609. return MenuItem::LoadArrayByPageId($this->intId, $objOptionalClauses);
  1610. } catch (QCallerException $objExc) {
  1611. $objExc->IncrementOffset();
  1612. throw $objExc;
  1613. }
  1614. }
  1615. /**
  1616. * Counts all associated MenuItems
  1617. * @return int
  1618. */
  1619. public function CountMenuItems() {
  1620. if ((is_null($this->intId)))
  1621. return 0;
  1622. return MenuItem::CountByPageId($this->intId);
  1623. }
  1624. /**
  1625. * Associates a MenuItem
  1626. * @param MenuItem $objMenuItem
  1627. * @return void
  1628. */
  1629. public function AssociateMenuItem(MenuItem $objMenuItem) {
  1630. if ((is_null($this->intId)))
  1631. throw new QUndefinedPrimaryKeyException('Unable to call AssociateMenuItem on this unsaved Page.');
  1632. if ((is_null($objMenuItem->Id)))
  1633. throw new QUndefinedPrimaryKeyException('Unable to call AssociateMenuItem on this Page with an unsaved MenuItem.');
  1634. // Get the Database Object for this Class
  1635. $objDatabase = Page::GetDatabase();
  1636. // Perform the SQL Query
  1637. $objDatabase->NonQuery('
  1638. UPDATE
  1639. `menu_item`
  1640. SET
  1641. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1642. WHERE
  1643. `id` = ' . $objDatabase->SqlVariable($objMenuItem->Id) . '
  1644. ');
  1645. }
  1646. /**
  1647. * Unassociates a MenuItem
  1648. * @param MenuItem $objMenuItem
  1649. * @return void
  1650. */
  1651. public function UnassociateMenuItem(MenuItem $objMenuItem) {
  1652. if ((is_null($this->intId)))
  1653. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this unsaved Page.');
  1654. if ((is_null($objMenuItem->Id)))
  1655. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this Page with an unsaved MenuItem.');
  1656. // Get the Database Object for this Class
  1657. $objDatabase = Page::GetDatabase();
  1658. // Perform the SQL Query
  1659. $objDatabase->NonQuery('
  1660. UPDATE
  1661. `menu_item`
  1662. SET
  1663. `page_id` = null
  1664. WHERE
  1665. `id` = ' . $objDatabase->SqlVariable($objMenuItem->Id) . ' AND
  1666. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1667. ');
  1668. }
  1669. /**
  1670. * Unassociates all MenuItems
  1671. * @return void
  1672. */
  1673. public function UnassociateAllMenuItems() {
  1674. if ((is_null($this->intId)))
  1675. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this unsaved Page.');
  1676. // Get the Database Object for this Class
  1677. $objDatabase = Page::GetDatabase();
  1678. // Perform the SQL Query
  1679. $objDatabase->NonQuery('
  1680. UPDATE
  1681. `menu_item`
  1682. SET
  1683. `page_id` = null
  1684. WHERE
  1685. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1686. ');
  1687. }
  1688. /**
  1689. * Deletes an associated MenuItem
  1690. * @param MenuItem $objMenuItem
  1691. * @return void
  1692. */
  1693. public function DeleteAssociatedMenuItem(MenuItem $objMenuItem) {
  1694. if ((is_null($this->intId)))
  1695. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this unsaved Page.');
  1696. if ((is_null($objMenuItem->Id)))
  1697. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this Page with an unsaved MenuItem.');
  1698. // Get the Database Object for this Class
  1699. $objDatabase = Page::GetDatabase();
  1700. // Perform the SQL Query
  1701. $objDatabase->NonQuery('
  1702. DELETE FROM
  1703. `menu_item`
  1704. WHERE
  1705. `id` = ' . $objDatabase->SqlVariable($objMenuItem->Id) . ' AND
  1706. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1707. ');
  1708. }
  1709. /**
  1710. * Deletes all associated MenuItems
  1711. * @return void
  1712. */
  1713. public function DeleteAllMenuItems() {
  1714. if ((is_null($this->intId)))
  1715. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMenuItem on this unsaved Page.');
  1716. // Get the Database Object for this Class
  1717. $objDatabase = Page::GetDatabase();
  1718. // Perform the SQL Query
  1719. $objDatabase->NonQuery('
  1720. DELETE FROM
  1721. `menu_item`
  1722. WHERE
  1723. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1724. ');
  1725. }
  1726. // Related Many-to-Many Objects' Methods for ContentBlock
  1727. //-------------------------------------------------------------------
  1728. /**
  1729. * Gets all many-to-many associated ContentBlocks as an array of ContentBlock objects
  1730. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1731. * @return ContentBlock[]
  1732. */
  1733. public function GetContentBlockArray($objOptionalClauses = null) {
  1734. if ((is_null($this->intId)))
  1735. return array();
  1736. try {
  1737. return ContentBlock::LoadArrayByPage($this->intId, $objOptionalClauses);
  1738. } catch (QCallerException $objExc) {
  1739. $objExc->IncrementOffset();
  1740. throw $objExc;
  1741. }
  1742. }
  1743. /**
  1744. * Counts all many-to-many associated ContentBlocks
  1745. * @return int
  1746. */
  1747. public function CountContentBlocks() {
  1748. if ((is_null($this->intId)))
  1749. return 0;
  1750. return ContentBlock::CountByPage($this->intId);
  1751. }
  1752. /**
  1753. * Checks to see if an association exists with a specific ContentBlock
  1754. * @param ContentBlock $objContentBlock
  1755. * @return bool
  1756. */
  1757. public function IsContentBlockAssociated(ContentBlock $objContentBlock) {
  1758. if ((is_null($this->intId)))
  1759. throw new QUndefinedPrimaryKeyException('Unable to call IsContentBlockAssociated on this unsaved Page.');
  1760. if ((is_null($objContentBlock->Id)))
  1761. throw new QUndefinedPrimaryKeyException('Unable to call IsContentBlockAssociated on this Page with an unsaved ContentBlock.');
  1762. $intRowCount = Page::QueryCount(
  1763. QQ::AndCondition(
  1764. QQ::Equal(QQN::Page()->Id, $this->intId),
  1765. QQ::Equal(QQN::Page()->ContentBlock->ContentBlockId, $objContentBlock->Id)
  1766. )
  1767. );
  1768. return ($intRowCount > 0);
  1769. }
  1770. /**
  1771. * Associates a ContentBlock
  1772. * @param ContentBlock $objContentBlock
  1773. * @return void
  1774. */
  1775. public function AssociateContentBlock(ContentBlock $objContentBlock) {
  1776. if ((is_null($this->intId)))
  1777. throw new QUndefinedPrimaryKeyException('Unable to call AssociateContentBlock on this unsaved Page.');
  1778. if ((is_null($objContentBlock->Id)))
  1779. throw new QUndefinedPrimaryKeyException('Unable to call AssociateContentBlock on this Page with an unsaved ContentBlock.');
  1780. // Get the Database Object for this Class
  1781. $objDatabase = Page::GetDatabase();
  1782. // Perform the SQL Query
  1783. $objDatabase->NonQuery('
  1784. INSERT INTO `content_block_page_assn` (
  1785. `page_id`,
  1786. `content_block_id`
  1787. ) VALUES (
  1788. ' . $objDatabase->SqlVariable($this->intId) . ',
  1789. ' . $objDatabase->SqlVariable($objContentBlock->Id) . '
  1790. )
  1791. ');
  1792. }
  1793. /**
  1794. * Unassociates a ContentBlock
  1795. * @param ContentBlock $objContentBlock
  1796. * @return void
  1797. */
  1798. public function UnassociateContentBlock(ContentBlock $objContentBlock) {
  1799. if ((is_null($this->intId)))
  1800. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateContentBlock on this unsaved Page.');
  1801. if ((is_null($objContentBlock->Id)))
  1802. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateContentBlock on this Page with an unsaved ContentBlock.');
  1803. // Get the Database Object for this Class
  1804. $objDatabase = Page::GetDatabase();
  1805. // Perform the SQL Query
  1806. $objDatabase->NonQuery('
  1807. DELETE FROM
  1808. `content_block_page_assn`
  1809. WHERE
  1810. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  1811. `content_block_id` = ' . $objDatabase->SqlVariable($objContentBlock->Id) . '
  1812. ');
  1813. }
  1814. /**
  1815. * Unassociates all ContentBlocks
  1816. * @return void
  1817. */
  1818. public function UnassociateAllContentBlocks() {
  1819. if ((is_null($this->intId)))
  1820. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllContentBlockArray on this unsaved Page.');
  1821. // Get the Database Object for this Class
  1822. $objDatabase = Page::GetDatabase();
  1823. // Perform the SQL Query
  1824. $objDatabase->NonQuery('
  1825. DELETE FROM
  1826. `content_block_page_assn`
  1827. WHERE
  1828. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1829. ');
  1830. }
  1831. // Related Many-to-Many Objects' Methods for ContentCategory
  1832. //-------------------------------------------------------------------
  1833. /**
  1834. * Gets all many-to-many associated ContentCategories as an array of ContentCategory objects
  1835. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1836. * @return ContentCategory[]
  1837. */
  1838. public function GetContentCategoryArray($objOptionalClauses = null) {
  1839. if ((is_null($this->intId)))
  1840. return array();
  1841. try {
  1842. return ContentCategory::LoadArrayByPage($this->intId, $objOptionalClauses);
  1843. } catch (QCallerException $objExc) {
  1844. $objExc->IncrementOffset();
  1845. throw $objExc;
  1846. }
  1847. }
  1848. /**
  1849. * Counts all many-to-many associated ContentCategories
  1850. * @return int
  1851. */
  1852. public function CountContentCategories() {
  1853. if ((is_null($this->intId)))
  1854. return 0;
  1855. return ContentCategory::CountByPage($this->intId);
  1856. }
  1857. /**
  1858. * Checks to see if an association exists with a specific ContentCategory
  1859. * @param ContentCategory $objContentCategory
  1860. * @return bool
  1861. */
  1862. public function IsContentCategoryAssociated(ContentCategory $objContentCategory) {
  1863. if ((is_null($this->intId)))
  1864. throw new QUndefinedPrimaryKeyException('Unable to call IsContentCategoryAssociated on this unsaved Page.');
  1865. if ((is_null($objContentCategory->Id)))
  1866. throw new QUndefinedPrimaryKeyException('Unable to call IsContentCategoryAssociated on this Page with an unsaved ContentCategory.');
  1867. $intRowCount = Page::QueryCount(
  1868. QQ::AndCondition(
  1869. QQ::Equal(QQN::Page()->Id, $this->intId),
  1870. QQ::Equal(QQN::Page()->ContentCategory->ContentCategoryId, $objContentCategory->Id)
  1871. )
  1872. );
  1873. return ($intRowCount > 0);
  1874. }
  1875. /**
  1876. * Associates a ContentCategory
  1877. * @param ContentCategory $objContentCategory
  1878. * @return void
  1879. */
  1880. public function AssociateContentCategory(ContentCategory $objContentCategory) {
  1881. if ((is_null($this->intId)))
  1882. throw new QUndefinedPrimaryKeyException('Unable to call AssociateContentCategory on this unsaved Page.');
  1883. if ((is_null($objContentCategory->Id)))
  1884. throw new QUndefinedPrimaryKeyException('Unable to call AssociateContentCategory on this Page with an unsaved ContentCategory.');
  1885. // Get the Database Object for this Class
  1886. $objDatabase = Page::GetDatabase();
  1887. // Perform the SQL Query
  1888. $objDatabase->NonQuery('
  1889. INSERT INTO `page_content_category_assn` (
  1890. `page_id`,
  1891. `content_category_id`
  1892. ) VALUES (
  1893. ' . $objDatabase->SqlVariable($this->intId) . ',
  1894. ' . $objDatabase->SqlVariable($objContentCategory->Id) . '
  1895. )
  1896. ');
  1897. }
  1898. /**
  1899. * Unassociates a ContentCategory
  1900. * @param ContentCategory $objContentCategory
  1901. * @return void
  1902. */
  1903. public function UnassociateContentCategory(ContentCategory $objContentCategory) {
  1904. if ((is_null($this->intId)))
  1905. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateContentCategory on this unsaved Page.');
  1906. if ((is_null($objContentCategory->Id)))
  1907. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateContentCategory on this Page with an unsaved ContentCategory.');
  1908. // Get the Database Object for this Class
  1909. $objDatabase = Page::GetDatabase();
  1910. // Perform the SQL Query
  1911. $objDatabase->NonQuery('
  1912. DELETE FROM
  1913. `page_content_category_assn`
  1914. WHERE
  1915. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  1916. `content_category_id` = ' . $objDatabase->SqlVariable($objContentCategory->Id) . '
  1917. ');
  1918. }
  1919. /**
  1920. * Unassociates all ContentCategories
  1921. * @return void
  1922. */
  1923. public function UnassociateAllContentCategories() {
  1924. if ((is_null($this->intId)))
  1925. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllContentCategoryArray on this unsaved Page.');
  1926. // Get the Database Object for this Class
  1927. $objDatabase = Page::GetDatabase();
  1928. // Perform the SQL Query
  1929. $objDatabase->NonQuery('
  1930. DELETE FROM
  1931. `page_content_category_assn`
  1932. WHERE
  1933. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1934. ');
  1935. }
  1936. // Related Many-to-Many Objects' Methods for HtmlMetaTag
  1937. //-------------------------------------------------------------------
  1938. /**
  1939. * Gets all many-to-many associated HtmlMetaTags as an array of HtmlMetaTag objects
  1940. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1941. * @return HtmlMetaTag[]
  1942. */
  1943. public function GetHtmlMetaTagArray($objOptionalClauses = null) {
  1944. if ((is_null($this->intId)))
  1945. return array();
  1946. try {
  1947. return HtmlMetaTag::LoadArrayByPage($this->intId, $objOptionalClauses);
  1948. } catch (QCallerException $objExc) {
  1949. $objExc->IncrementOffset();
  1950. throw $objExc;
  1951. }
  1952. }
  1953. /**
  1954. * Counts all many-to-many associated HtmlMetaTags
  1955. * @return int
  1956. */
  1957. public function CountHtmlMetaTags() {
  1958. if ((is_null($this->intId)))
  1959. return 0;
  1960. return HtmlMetaTag::CountByPage($this->intId);
  1961. }
  1962. /**
  1963. * Checks to see if an association exists with a specific HtmlMetaTag
  1964. * @param HtmlMetaTag $objHtmlMetaTag
  1965. * @return bool
  1966. */
  1967. public function IsHtmlMetaTagAssociated(HtmlMetaTag $objHtmlMetaTag) {
  1968. if ((is_null($this->intId)))
  1969. throw new QUndefinedPrimaryKeyException('Unable to call IsHtmlMetaTagAssociated on this unsaved Page.');
  1970. if ((is_null($objHtmlMetaTag->Id)))
  1971. throw new QUndefinedPrimaryKeyException('Unable to call IsHtmlMetaTagAssociated on this Page with an unsaved HtmlMetaTag.');
  1972. $intRowCount = Page::QueryCount(
  1973. QQ::AndCondition(
  1974. QQ::Equal(QQN::Page()->Id, $this->intId),
  1975. QQ::Equal(QQN::Page()->HtmlMetaTag->HtmlMetaTagId, $objHtmlMetaTag->Id)
  1976. )
  1977. );
  1978. return ($intRowCount > 0);
  1979. }
  1980. /**
  1981. * Associates a HtmlMetaTag
  1982. * @param HtmlMetaTag $objHtmlMetaTag
  1983. * @return void
  1984. */
  1985. public function AssociateHtmlMetaTag(HtmlMetaTag $objHtmlMetaTag) {
  1986. if ((is_null($this->intId)))
  1987. throw new QUndefinedPrimaryKeyException('Unable to call AssociateHtmlMetaTag on this unsaved Page.');
  1988. if ((is_null($objHtmlMetaTag->Id)))
  1989. throw new QUndefinedPrimaryKeyException('Unable to call AssociateHtmlMetaTag on this Page with an unsaved HtmlMetaTag.');
  1990. // Get the Database Object for this Class
  1991. $objDatabase = Page::GetDatabase();
  1992. // Perform the SQL Query
  1993. $objDatabase->NonQuery('
  1994. INSERT INTO `page_html_meta_tag_assn` (
  1995. `page_id`,
  1996. `html_meta_tag_id`
  1997. ) VALUES (
  1998. ' . $objDatabase->SqlVariable($this->intId) . ',
  1999. ' . $objDatabase->SqlVariable($objHtmlMetaTag->Id) . '
  2000. )
  2001. ');
  2002. }
  2003. /**
  2004. * Unassociates a HtmlMetaTag
  2005. * @param HtmlMetaTag $objHtmlMetaTag
  2006. * @return void
  2007. */
  2008. public function UnassociateHtmlMetaTag(HtmlMetaTag $objHtmlMetaTag) {
  2009. if ((is_null($this->intId)))
  2010. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateHtmlMetaTag on this unsaved Page.');
  2011. if ((is_null($objHtmlMetaTag->Id)))
  2012. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateHtmlMetaTag on this Page with an unsaved HtmlMetaTag.');
  2013. // Get the Database Object for this Class
  2014. $objDatabase = Page::GetDatabase();
  2015. // Perform the SQL Query
  2016. $objDatabase->NonQuery('
  2017. DELETE FROM
  2018. `page_html_meta_tag_assn`
  2019. WHERE
  2020. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  2021. `html_meta_tag_id` = ' . $objDatabase->SqlVariable($objHtmlMetaTag->Id) . '
  2022. ');
  2023. }
  2024. /**
  2025. * Unassociates all HtmlMetaTags
  2026. * @return void
  2027. */
  2028. public function UnassociateAllHtmlMetaTags() {
  2029. if ((is_null($this->intId)))
  2030. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllHtmlMetaTagArray on this unsaved Page.');
  2031. // Get the Database Object for this Class
  2032. $objDatabase = Page::GetDatabase();
  2033. // Perform the SQL Query
  2034. $objDatabase->NonQuery('
  2035. DELETE FROM
  2036. `page_html_meta_tag_assn`
  2037. WHERE
  2038. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2039. ');
  2040. }
  2041. // Related Many-to-Many Objects' Methods for JavaScript
  2042. //-------------------------------------------------------------------
  2043. /**
  2044. * Gets all many-to-many associated JavaScripts as an array of JavaScript objects
  2045. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2046. * @return JavaScript[]
  2047. */
  2048. public function GetJavaScriptArray($objOptionalClauses = null) {
  2049. if ((is_null($this->intId)))
  2050. return array();
  2051. try {
  2052. return JavaScript::LoadArrayByPage($this->intId, $objOptionalClauses);
  2053. } catch (QCallerException $objExc) {
  2054. $objExc->IncrementOffset();
  2055. throw $objExc;
  2056. }
  2057. }
  2058. /**
  2059. * Counts all many-to-many associated JavaScripts
  2060. * @return int
  2061. */
  2062. public function CountJavaScripts() {
  2063. if ((is_null($this->intId)))
  2064. return 0;
  2065. return JavaScript::CountByPage($this->intId);
  2066. }
  2067. /**
  2068. * Checks to see if an association exists with a specific JavaScript
  2069. * @param JavaScript $objJavaScript
  2070. * @return bool
  2071. */
  2072. public function IsJavaScriptAssociated(JavaScript $objJavaScript) {
  2073. if ((is_null($this->intId)))
  2074. throw new QUndefinedPrimaryKeyException('Unable to call IsJavaScriptAssociated on this unsaved Page.');
  2075. if ((is_null($objJavaScript->Id)))
  2076. throw new QUndefinedPrimaryKeyException('Unable to call IsJavaScriptAssociated on this Page with an unsaved JavaScript.');
  2077. $intRowCount = Page::QueryCount(
  2078. QQ::AndCondition(
  2079. QQ::Equal(QQN::Page()->Id, $this->intId),
  2080. QQ::Equal(QQN::Page()->JavaScript->JavaScriptId, $objJavaScript->Id)
  2081. )
  2082. );
  2083. return ($intRowCount > 0);
  2084. }
  2085. /**
  2086. * Associates a JavaScript
  2087. * @param JavaScript $objJavaScript
  2088. * @return void
  2089. */
  2090. public function AssociateJavaScript(JavaScript $objJavaScript) {
  2091. if ((is_null($this->intId)))
  2092. throw new QUndefinedPrimaryKeyException('Unable to call AssociateJavaScript on this unsaved Page.');
  2093. if ((is_null($objJavaScript->Id)))
  2094. throw new QUndefinedPrimaryKeyException('Unable to call AssociateJavaScript on this Page with an unsaved JavaScript.');
  2095. // Get the Database Object for this Class
  2096. $objDatabase = Page::GetDatabase();
  2097. // Perform the SQL Query
  2098. $objDatabase->NonQuery('
  2099. INSERT INTO `page_java_script_assn` (
  2100. `page_id`,
  2101. `java_script_id`
  2102. ) VALUES (
  2103. ' . $objDatabase->SqlVariable($this->intId) . ',
  2104. ' . $objDatabase->SqlVariable($objJavaScript->Id) . '
  2105. )
  2106. ');
  2107. }
  2108. /**
  2109. * Unassociates a JavaScript
  2110. * @param JavaScript $objJavaScript
  2111. * @return void
  2112. */
  2113. public function UnassociateJavaScript(JavaScript $objJavaScript) {
  2114. if ((is_null($this->intId)))
  2115. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateJavaScript on this unsaved Page.');
  2116. if ((is_null($objJavaScript->Id)))
  2117. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateJavaScript on this Page with an unsaved JavaScript.');
  2118. // Get the Database Object for this Class
  2119. $objDatabase = Page::GetDatabase();
  2120. // Perform the SQL Query
  2121. $objDatabase->NonQuery('
  2122. DELETE FROM
  2123. `page_java_script_assn`
  2124. WHERE
  2125. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  2126. `java_script_id` = ' . $objDatabase->SqlVariable($objJavaScript->Id) . '
  2127. ');
  2128. }
  2129. /**
  2130. * Unassociates all JavaScripts
  2131. * @return void
  2132. */
  2133. public function UnassociateAllJavaScripts() {
  2134. if ((is_null($this->intId)))
  2135. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllJavaScriptArray on this unsaved Page.');
  2136. // Get the Database Object for this Class
  2137. $objDatabase = Page::GetDatabase();
  2138. // Perform the SQL Query
  2139. $objDatabase->NonQuery('
  2140. DELETE FROM
  2141. `page_java_script_assn`
  2142. WHERE
  2143. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2144. ');
  2145. }
  2146. // Related Many-to-Many Objects' Methods for StyleSheet
  2147. //-------------------------------------------------------------------
  2148. /**
  2149. * Gets all many-to-many associated StyleSheets as an array of StyleSheet objects
  2150. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2151. * @return StyleSheet[]
  2152. */
  2153. public function GetStyleSheetArray($objOptionalClauses = null) {
  2154. if ((is_null($this->intId)))
  2155. return array();
  2156. try {
  2157. return StyleSheet::LoadArrayByPage($this->intId, $objOptionalClauses);
  2158. } catch (QCallerException $objExc) {
  2159. $objExc->IncrementOffset();
  2160. throw $objExc;
  2161. }
  2162. }
  2163. /**
  2164. * Counts all many-to-many associated StyleSheets
  2165. * @return int
  2166. */
  2167. public function CountStyleSheets() {
  2168. if ((is_null($this->intId)))
  2169. return 0;
  2170. return StyleSheet::CountByPage($this->intId);
  2171. }
  2172. /**
  2173. * Checks to see if an association exists with a specific StyleSheet
  2174. * @param StyleSheet $objStyleSheet
  2175. * @return bool
  2176. */
  2177. public function IsStyleSheetAssociated(StyleSheet $objStyleSheet) {
  2178. if ((is_null($this->intId)))
  2179. throw new QUndefinedPrimaryKeyException('Unable to call IsStyleSheetAssociated on this unsaved Page.');
  2180. if ((is_null($objStyleSheet->Id)))
  2181. throw new QUndefinedPrimaryKeyException('Unable to call IsStyleSheetAssociated on this Page with an unsaved StyleSheet.');
  2182. $intRowCount = Page::QueryCount(
  2183. QQ::AndCondition(
  2184. QQ::Equal(QQN::Page()->Id, $this->intId),
  2185. QQ::Equal(QQN::Page()->StyleSheet->StyleSheetId, $objStyleSheet->Id)
  2186. )
  2187. );
  2188. return ($intRowCount > 0);
  2189. }
  2190. /**
  2191. * Associates a StyleSheet
  2192. * @param StyleSheet $objStyleSheet
  2193. * @return void
  2194. */
  2195. public function AssociateStyleSheet(StyleSheet $objStyleSheet) {
  2196. if ((is_null($this->intId)))
  2197. throw new QUndefinedPrimaryKeyException('Unable to call AssociateStyleSheet on this unsaved Page.');
  2198. if ((is_null($objStyleSheet->Id)))
  2199. throw new QUndefinedPrimaryKeyException('Unable to call AssociateStyleSheet on this Page with an unsaved StyleSheet.');
  2200. // Get the Database Object for this Class
  2201. $objDatabase = Page::GetDatabase();
  2202. // Perform the SQL Query
  2203. $objDatabase->NonQuery('
  2204. INSERT INTO `page_style_sheet_assn` (
  2205. `page_id`,
  2206. `style_sheet_id`
  2207. ) VALUES (
  2208. ' . $objDatabase->SqlVariable($this->intId) . ',
  2209. ' . $objDatabase->SqlVariable($objStyleSheet->Id) . '
  2210. )
  2211. ');
  2212. }
  2213. /**
  2214. * Unassociates a StyleSheet
  2215. * @param StyleSheet $objStyleSheet
  2216. * @return void
  2217. */
  2218. public function UnassociateStyleSheet(StyleSheet $objStyleSheet) {
  2219. if ((is_null($this->intId)))
  2220. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStyleSheet on this unsaved Page.');
  2221. if ((is_null($objStyleSheet->Id)))
  2222. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateStyleSheet on this Page with an unsaved StyleSheet.');
  2223. // Get the Database Object for this Class
  2224. $objDatabase = Page::GetDatabase();
  2225. // Perform the SQL Query
  2226. $objDatabase->NonQuery('
  2227. DELETE FROM
  2228. `page_style_sheet_assn`
  2229. WHERE
  2230. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  2231. `style_sheet_id` = ' . $objDatabase->SqlVariable($objStyleSheet->Id) . '
  2232. ');
  2233. }
  2234. /**
  2235. * Unassociates all StyleSheets
  2236. * @return void
  2237. */
  2238. public function UnassociateAllStyleSheets() {
  2239. if ((is_null($this->intId)))
  2240. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllStyleSheetArray on this unsaved Page.');
  2241. // Get the Database Object for this Class
  2242. $objDatabase = Page::GetDatabase();
  2243. // Perform the SQL Query
  2244. $objDatabase->NonQuery('
  2245. DELETE FROM
  2246. `page_style_sheet_assn`
  2247. WHERE
  2248. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2249. ');
  2250. }
  2251. // Related Many-to-Many Objects' Methods for Usergroup
  2252. //-------------------------------------------------------------------
  2253. /**
  2254. * Gets all many-to-many associated Usergroups as an array of Usergroup objects
  2255. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2256. * @return Usergroup[]
  2257. */
  2258. public function GetUsergroupArray($objOptionalClauses = null) {
  2259. if ((is_null($this->intId)))
  2260. return array();
  2261. try {
  2262. return Usergroup::LoadArrayByPage($this->intId, $objOptionalClauses);
  2263. } catch (QCallerException $objExc) {
  2264. $objExc->IncrementOffset();
  2265. throw $objExc;
  2266. }
  2267. }
  2268. /**
  2269. * Counts all many-to-many associated Usergroups
  2270. * @return int
  2271. */
  2272. public function CountUsergroups() {
  2273. if ((is_null($this->intId)))
  2274. return 0;
  2275. return Usergroup::CountByPage($this->intId);
  2276. }
  2277. /**
  2278. * Checks to see if an association exists with a specific Usergroup
  2279. * @param Usergroup $objUsergroup
  2280. * @return bool
  2281. */
  2282. public function IsUsergroupAssociated(Usergroup $objUsergroup) {
  2283. if ((is_null($this->intId)))
  2284. throw new QUndefinedPrimaryKeyException('Unable to call IsUsergroupAssociated on this unsaved Page.');
  2285. if ((is_null($objUsergroup->Id)))
  2286. throw new QUndefinedPrimaryKeyException('Unable to call IsUsergroupAssociated on this Page with an unsaved Usergroup.');
  2287. $intRowCount = Page::QueryCount(
  2288. QQ::AndCondition(
  2289. QQ::Equal(QQN::Page()->Id, $this->intId),
  2290. QQ::Equal(QQN::Page()->Usergroup->UsergroupId, $objUsergroup->Id)
  2291. )
  2292. );
  2293. return ($intRowCount > 0);
  2294. }
  2295. /**
  2296. * Associates a Usergroup
  2297. * @param Usergroup $objUsergroup
  2298. * @return void
  2299. */
  2300. public function AssociateUsergroup(Usergroup $objUsergroup) {
  2301. if ((is_null($this->intId)))
  2302. throw new QUndefinedPrimaryKeyException('Unable to call AssociateUsergroup on this unsaved Page.');
  2303. if ((is_null($objUsergroup->Id)))
  2304. throw new QUndefinedPrimaryKeyException('Unable to call AssociateUsergroup on this Page with an unsaved Usergroup.');
  2305. // Get the Database Object for this Class
  2306. $objDatabase = Page::GetDatabase();
  2307. // Perform the SQL Query
  2308. $objDatabase->NonQuery('
  2309. INSERT INTO `page_usergroup_assn` (
  2310. `page_id`,
  2311. `usergroup_id`
  2312. ) VALUES (
  2313. ' . $objDatabase->SqlVariable($this->intId) . ',
  2314. ' . $objDatabase->SqlVariable($objUsergroup->Id) . '
  2315. )
  2316. ');
  2317. }
  2318. /**
  2319. * Unassociates a Usergroup
  2320. * @param Usergroup $objUsergroup
  2321. * @return void
  2322. */
  2323. public function UnassociateUsergroup(Usergroup $objUsergroup) {
  2324. if ((is_null($this->intId)))
  2325. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateUsergroup on this unsaved Page.');
  2326. if ((is_null($objUsergroup->Id)))
  2327. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateUsergroup on this Page with an unsaved Usergroup.');
  2328. // Get the Database Object for this Class
  2329. $objDatabase = Page::GetDatabase();
  2330. // Perform the SQL Query
  2331. $objDatabase->NonQuery('
  2332. DELETE FROM
  2333. `page_usergroup_assn`
  2334. WHERE
  2335. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . ' AND
  2336. `usergroup_id` = ' . $objDatabase->SqlVariable($objUsergroup->Id) . '
  2337. ');
  2338. }
  2339. /**
  2340. * Unassociates all Usergroups
  2341. * @return void
  2342. */
  2343. public function UnassociateAllUsergroups() {
  2344. if ((is_null($this->intId)))
  2345. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllUsergroupArray on this unsaved Page.');
  2346. // Get the Database Object for this Class
  2347. $objDatabase = Page::GetDatabase();
  2348. // Perform the SQL Query
  2349. $objDatabase->NonQuery('
  2350. DELETE FROM
  2351. `page_usergroup_assn`
  2352. WHERE
  2353. `page_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2354. ');
  2355. }
  2356. }
  2357. /////////////////////////////////////
  2358. // ADDITIONAL CLASSES for QCODO QUERY
  2359. /////////////////////////////////////
  2360. class QQNodePageContentBlock extends QQAssociationNode {
  2361. protected $strType = 'association';
  2362. protected $strName = 'contentblock';
  2363. protected $strTableName = 'content_block_page_assn';
  2364. protected $strPrimaryKey = 'page_id';
  2365. protected $strClassName = 'ContentBlock';
  2366. public function __get($strName) {
  2367. switch ($strName) {
  2368. case 'ContentBlockId':
  2369. return new QQNode('content_block_id', 'ContentBlockId', 'integer', $this);
  2370. case 'ContentBlock':
  2371. return new QQNodeContentBlock('content_block_id', 'ContentBlockId', 'integer', $this);
  2372. case '_ChildTableNode':
  2373. return new QQNodeContentBlock('content_block_id', 'ContentBlockId', 'integer', $this);
  2374. default:
  2375. try {
  2376. return parent::__get($strName);
  2377. } catch (QCallerException $objExc) {
  2378. $objExc->IncrementOffset();
  2379. throw $objExc;
  2380. }
  2381. }
  2382. }
  2383. }
  2384. class QQNodePageContentCategory extends QQAssociationNode {
  2385. protected $strType = 'association';
  2386. protected $strName = 'contentcategory';
  2387. protected $strTableName = 'page_content_category_assn';
  2388. protected $strPrimaryKey = 'page_id';
  2389. protected $strClassName = 'ContentCategory';
  2390. public function __get($strName) {
  2391. switch ($strName) {
  2392. case 'ContentCategoryId':
  2393. return new QQNode('content_category_id', 'ContentCategoryId', 'integer', $this);
  2394. case 'ContentCategory':
  2395. return new QQNodeContentCategory('content_category_id', 'ContentCategoryId', 'integer', $this);
  2396. case '_ChildTableNode':
  2397. return new QQNodeContentCategory('content_category_id', 'ContentCategoryId', 'integer', $this);
  2398. default:
  2399. try {
  2400. return parent::__get($strName);
  2401. } catch (QCallerException $objExc) {
  2402. $objExc->IncrementOffset();
  2403. throw $objExc;
  2404. }
  2405. }
  2406. }
  2407. }
  2408. class QQNodePageHtmlMetaTag extends QQAssociationNode {
  2409. protected $strType = 'association';
  2410. protected $strName = 'htmlmetatag';
  2411. protected $strTableName = 'page_html_meta_tag_assn';
  2412. protected $strPrimaryKey = 'page_id';
  2413. protected $strClassName = 'HtmlMetaTag';
  2414. public function __get($strName) {
  2415. switch ($strName) {
  2416. case 'HtmlMetaTagId':
  2417. return new QQNode('html_meta_tag_id', 'HtmlMetaTagId', 'integer', $this);
  2418. case 'HtmlMetaTag':
  2419. return new QQNodeHtmlMetaTag('html_meta_tag_id', 'HtmlMetaTagId', 'integer', $this);
  2420. case '_ChildTableNode':
  2421. return new QQNodeHtmlMetaTag('html_meta_tag_id', 'HtmlMetaTagId', 'integer', $this);
  2422. default:
  2423. try {
  2424. return parent::__get($strName);
  2425. } catch (QCallerException $objExc) {
  2426. $objExc->IncrementOffset();
  2427. throw $objExc;
  2428. }
  2429. }
  2430. }
  2431. }
  2432. class QQNodePageJavaScript extends QQAssociationNode {
  2433. protected $strType = 'association';
  2434. protected $strName = 'javascript';
  2435. protected $strTableName = 'page_java_script_assn';
  2436. protected $strPrimaryKey = 'page_id';
  2437. protected $strClassName = 'JavaScript';
  2438. public function __get($strName) {
  2439. switch ($strName) {
  2440. case 'JavaScriptId':
  2441. return new QQNode('java_script_id', 'JavaScriptId', 'integer', $this);
  2442. case 'JavaScript':
  2443. return new QQNodeJavaScript('java_script_id', 'JavaScriptId', 'integer', $this);
  2444. case '_ChildTableNode':
  2445. return new QQNodeJavaScript('java_script_id', 'JavaScriptId', 'integer', $this);
  2446. default:
  2447. try {
  2448. return parent::__get($strName);
  2449. } catch (QCallerException $objExc) {
  2450. $objExc->IncrementOffset();
  2451. throw $objExc;
  2452. }
  2453. }
  2454. }
  2455. }
  2456. class QQNodePageStyleSheet extends QQAssociationNode {
  2457. protected $strType = 'association';
  2458. protected $strName = 'stylesheet';
  2459. protected $strTableName = 'page_style_sheet_assn';
  2460. protected $strPrimaryKey = 'page_id';
  2461. protected $strClassName = 'StyleSheet';
  2462. public function __get($strName) {
  2463. switch ($strName) {
  2464. case 'StyleSheetId':
  2465. return new QQNode('style_sheet_id', 'StyleSheetId', 'integer', $this);
  2466. case 'StyleSheet':
  2467. return new QQNodeStyleSheet('style_sheet_id', 'StyleSheetId', 'integer', $this);
  2468. case '_ChildTableNode':
  2469. return new QQNodeStyleSheet('style_sheet_id', 'StyleSheetId', 'integer', $this);
  2470. default:
  2471. try {
  2472. return parent::__get($strName);
  2473. } catch (QCallerException $objExc) {
  2474. $objExc->IncrementOffset();
  2475. throw $objExc;
  2476. }
  2477. }
  2478. }
  2479. }
  2480. class QQNodePageUsergroup extends QQAssociationNode {
  2481. protected $strType = 'association';
  2482. protected $strName = 'usergroup';
  2483. protected $strTableName = 'page_usergroup_assn';
  2484. protected $strPrimaryKey = 'page_id';
  2485. protected $strClassName = 'Usergroup';
  2486. public function __get($strName) {
  2487. switch ($strName) {
  2488. case 'UsergroupId':
  2489. return new QQNode('usergroup_id', 'UsergroupId', 'integer', $this);
  2490. case 'Usergroup':
  2491. return new QQNodeUsergroup('usergroup_id', 'UsergroupId', 'integer', $this);
  2492. case '_ChildTableNode':
  2493. return new QQNodeUsergroup('usergroup_id', 'UsergroupId', 'integer', $this);
  2494. default:
  2495. try {
  2496. return parent::__get($strName);
  2497. } catch (QCallerException $objExc) {
  2498. $objExc->IncrementOffset();
  2499. throw $objExc;
  2500. }
  2501. }
  2502. }
  2503. }
  2504. class QQNodePage extends QQNode {
  2505. protected $strTableName = 'page';
  2506. protected $strPrimaryKey = 'id';
  2507. protected $strClassName = 'Page';
  2508. public function __get($strName) {
  2509. switch ($strName) {
  2510. case 'Id':
  2511. return new QQNode('id', 'Id', 'integer', $this);
  2512. case 'CreationDate':
  2513. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  2514. case 'LastModification':
  2515. return new QQNode('last_modification', 'LastModification', 'string', $this);
  2516. case 'Name':
  2517. return new QQNode('name', 'Name', 'string', $this);
  2518. case 'Title':
  2519. return new QQNode('title', 'Title', 'string', $this);
  2520. case 'Uri':
  2521. return new QQNode('uri', 'Uri', 'string', $this);
  2522. case 'HasHeader':
  2523. return new QQNode('has_header', 'HasHeader', 'boolean', $this);
  2524. case 'HasLeftColumn':
  2525. return new QQNode('has_left_column', 'HasLeftColumn', 'boolean', $this);
  2526. case 'HasRightColumn':
  2527. return new QQNode('has_right_column', 'HasRightColumn', 'boolean', $this);
  2528. case 'HasFooter':
  2529. return new QQNode('has_footer', 'HasFooter', 'boolean', $this);
  2530. case 'TypeId':
  2531. return new QQNode('type_id', 'TypeId', 'integer', $this);
  2532. case 'DocTypeId':
  2533. return new QQNode('doc_type_id', 'DocTypeId', 'integer', $this);
  2534. case 'StatusId':
  2535. return new QQNode('status_id', 'StatusId', 'integer', $this);
  2536. case 'ContentBlock':
  2537. return new QQNodePageContentBlock($this);
  2538. case 'ContentCategory':
  2539. return new QQNodePageContentCategory($this);
  2540. case 'HtmlMetaTag':
  2541. return new QQNodePageHtmlMetaTag($this);
  2542. case 'JavaScript':
  2543. return new QQNodePageJavaScript($this);
  2544. case 'StyleSheet':
  2545. return new QQNodePageStyleSheet($this);
  2546. case 'Usergroup':
  2547. return new QQNodePageUsergroup($this);
  2548. case 'MenuItem':
  2549. return new QQReverseReferenceNodeMenuItem($this, 'menuitem', 'reverse_reference', 'page_id');
  2550. case '_PrimaryKeyNode':
  2551. return new QQNode('id', 'Id', 'integer', $this);
  2552. default:
  2553. try {
  2554. return parent::__get($strName);
  2555. } catch (QCallerException $objExc) {
  2556. $objExc->IncrementOffset();
  2557. throw $objExc;
  2558. }
  2559. }
  2560. }
  2561. }
  2562. class QQReverseReferenceNodePage extends QQReverseReferenceNode {
  2563. protected $strTableName = 'page';
  2564. protected $strPrimaryKey = 'id';
  2565. protected $strClassName = 'Page';
  2566. public function __get($strName) {
  2567. switch ($strName) {
  2568. case 'Id':
  2569. return new QQNode('id', 'Id', 'integer', $this);
  2570. case 'CreationDate':
  2571. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  2572. case 'LastModification':
  2573. return new QQNode('last_modification', 'LastModification', 'string', $this);
  2574. case 'Name':
  2575. return new QQNode('name', 'Name', 'string', $this);
  2576. case 'Title':
  2577. return new QQNode('title', 'Title', 'string', $this);
  2578. case 'Uri':
  2579. return new QQNode('uri', 'Uri', 'string', $this);
  2580. case 'HasHeader':
  2581. return new QQNode('has_header', 'HasHeader', 'boolean', $this);
  2582. case 'HasLeftColumn':
  2583. return new QQNode('has_left_column', 'HasLeftColumn', 'boolean', $this);
  2584. case 'HasRightColumn':
  2585. return new QQNode('has_right_column', 'HasRightColumn', 'boolean', $this);
  2586. case 'HasFooter':
  2587. return new QQNode('has_footer', 'HasFooter', 'boolean', $this);
  2588. case 'TypeId':
  2589. return new QQNode('type_id', 'TypeId', 'integer', $this);
  2590. case 'DocTypeId':
  2591. return new QQNode('doc_type_id', 'DocTypeId', 'integer', $this);
  2592. case 'StatusId':
  2593. return new QQNode('status_id', 'StatusId', 'integer', $this);
  2594. case 'ContentBlock':
  2595. return new QQNodePageContentBlock($this);
  2596. case 'ContentCategory':
  2597. return new QQNodePageContentCategory($this);
  2598. case 'HtmlMetaTag':
  2599. return new QQNodePageHtmlMetaTag($this);
  2600. case 'JavaScript':
  2601. return new QQNodePageJavaScript($this);
  2602. case 'StyleSheet':
  2603. return new QQNodePageStyleSheet($this);
  2604. case 'Usergroup':
  2605. return new QQNodePageUsergroup($this);
  2606. case 'MenuItem':
  2607. return new QQReverseReferenceNodeMenuItem($this, 'menuitem', 'reverse_reference', 'page_id');
  2608. case '_PrimaryKeyNode':
  2609. return new QQNode('id', 'Id', 'integer', $this);
  2610. default:
  2611. try {
  2612. return parent::__get($strName);
  2613. } catch (QCallerException $objExc) {
  2614. $objExc->IncrementOffset();
  2615. throw $objExc;
  2616. }
  2617. }
  2618. }
  2619. }
  2620. ?>