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.

934 lines
44 KiB

  1. <?php
  2. /**
  3. * This is a MetaControl class, providing a QForm or QPanel access to event handlers
  4. * and QControls to perform the Create, Edit, and Delete functionality
  5. * of the ContentBlock class. This code-generated class
  6. * contains all the basic elements to help a QPanel or QForm display an HTML form that can
  7. * manipulate a single ContentBlock object.
  8. *
  9. * To take advantage of some (or all) of these control objects, you
  10. * must create a new QForm or QPanel which instantiates a ContentBlockMetaControl
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent
  14. * code re-generation.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage MetaControls
  18. * property-read ContentBlock $ContentBlock the actual ContentBlock data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QTextBox $NameControl
  22. * property-read QLabel $NameLabel
  23. * property QTextBox $CssclassControl
  24. * property-read QLabel $CssclassLabel
  25. * property QTextBox $TitleControl
  26. * property-read QLabel $TitleLabel
  27. * property QTextBox $DescriptionControl
  28. * property-read QLabel $DescriptionLabel
  29. * property QCheckBox $ShowTitleControl
  30. * property-read QLabel $ShowTitleLabel
  31. * property QCheckBox $ShowDescriptionControl
  32. * property-read QLabel $ShowDescriptionLabel
  33. * property QCheckBox $CollapsableControl
  34. * property-read QLabel $CollapsableLabel
  35. * property QIntegerTextBox $SortOrderControl
  36. * property-read QLabel $SortOrderLabel
  37. * property QIntegerTextBox $ParentContentBlockIdControl
  38. * property-read QLabel $ParentContentBlockIdLabel
  39. * property QIntegerTextBox $LocationIdControl
  40. * property-read QLabel $LocationIdLabel
  41. * property QListBox $PageControl
  42. * property-read QLabel $PageLabel
  43. * property QListBox $ContentItemControl
  44. * property-read QLabel $ContentItemLabel
  45. * property QListBox $MenuControl
  46. * property-read QLabel $MenuLabel
  47. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  48. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  49. */
  50. class ContentBlockMetaControlGen extends QBaseClass {
  51. // General Variables
  52. protected $objContentBlock;
  53. protected $objParentObject;
  54. protected $strTitleVerb;
  55. protected $blnEditMode;
  56. // Controls that allow the editing of ContentBlock's individual data fields
  57. protected $lblId;
  58. protected $txtName;
  59. protected $txtCssclass;
  60. protected $txtTitle;
  61. protected $txtDescription;
  62. protected $chkShowTitle;
  63. protected $chkShowDescription;
  64. protected $chkCollapsable;
  65. protected $txtSortOrder;
  66. protected $txtParentContentBlockId;
  67. protected $txtLocationId;
  68. // Controls that allow the viewing of ContentBlock's individual data fields
  69. protected $lblName;
  70. protected $lblCssclass;
  71. protected $lblTitle;
  72. protected $lblDescription;
  73. protected $lblShowTitle;
  74. protected $lblShowDescription;
  75. protected $lblCollapsable;
  76. protected $lblSortOrder;
  77. protected $lblParentContentBlockId;
  78. protected $lblLocationId;
  79. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  80. protected $lstPages;
  81. protected $lstContentItems;
  82. protected $lstMenus;
  83. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  84. protected $lblPages;
  85. protected $lblContentItems;
  86. protected $lblMenus;
  87. /**
  88. * Main constructor. Constructor OR static create methods are designed to be called in either
  89. * a parent QPanel or the main QForm when wanting to create a
  90. * ContentBlockMetaControl to edit a single ContentBlock object within the
  91. * QPanel or QForm.
  92. *
  93. * This constructor takes in a single ContentBlock object, while any of the static
  94. * create methods below can be used to construct based off of individual PK ID(s).
  95. *
  96. * @param mixed $objParentObject QForm or QPanel which will be using this ContentBlockMetaControl
  97. * @param ContentBlock $objContentBlock new or existing ContentBlock object
  98. */
  99. public function __construct($objParentObject, ContentBlock $objContentBlock) {
  100. // Setup Parent Object (e.g. QForm or QPanel which will be using this ContentBlockMetaControl)
  101. $this->objParentObject = $objParentObject;
  102. // Setup linked ContentBlock object
  103. $this->objContentBlock = $objContentBlock;
  104. // Figure out if we're Editing or Creating New
  105. if ($this->objContentBlock->__Restored) {
  106. $this->strTitleVerb = QApplication::Translate('Edit');
  107. $this->blnEditMode = true;
  108. } else {
  109. $this->strTitleVerb = QApplication::Translate('Create');
  110. $this->blnEditMode = false;
  111. }
  112. }
  113. /**
  114. * Static Helper Method to Create using PK arguments
  115. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  116. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  117. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  118. * edit, or if we are also allowed to create a new one, etc.
  119. *
  120. * @param mixed $objParentObject QForm or QPanel which will be using this ContentBlockMetaControl
  121. * @param integer $intId primary key value
  122. * @param QMetaControlCreateType $intCreateType rules governing ContentBlock object creation - defaults to CreateOrEdit
  123. * @return ContentBlockMetaControl
  124. */
  125. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  126. // Attempt to Load from PK Arguments
  127. if (strlen($intId)) {
  128. $objContentBlock = ContentBlock::Load($intId);
  129. // ContentBlock was found -- return it!
  130. if ($objContentBlock)
  131. return new ContentBlockMetaControl($objParentObject, $objContentBlock);
  132. // If CreateOnRecordNotFound not specified, throw an exception
  133. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  134. throw new QCallerException('Could not find a ContentBlock object with PK arguments: ' . $intId);
  135. // If EditOnly is specified, throw an exception
  136. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  137. throw new QCallerException('No PK arguments specified');
  138. // If we are here, then we need to create a new record
  139. return new ContentBlockMetaControl($objParentObject, new ContentBlock());
  140. }
  141. /**
  142. * Static Helper Method to Create using PathInfo arguments
  143. *
  144. * @param mixed $objParentObject QForm or QPanel which will be using this ContentBlockMetaControl
  145. * @param QMetaControlCreateType $intCreateType rules governing ContentBlock object creation - defaults to CreateOrEdit
  146. * @return ContentBlockMetaControl
  147. */
  148. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  149. $intId = QApplication::PathInfo(0);
  150. return ContentBlockMetaControl::Create($objParentObject, $intId, $intCreateType);
  151. }
  152. /**
  153. * Static Helper Method to Create using QueryString arguments
  154. *
  155. * @param mixed $objParentObject QForm or QPanel which will be using this ContentBlockMetaControl
  156. * @param QMetaControlCreateType $intCreateType rules governing ContentBlock object creation - defaults to CreateOrEdit
  157. * @return ContentBlockMetaControl
  158. */
  159. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  160. $intId = QApplication::QueryString('intId');
  161. return ContentBlockMetaControl::Create($objParentObject, $intId, $intCreateType);
  162. }
  163. ///////////////////////////////////////////////
  164. // PUBLIC CREATE and REFRESH METHODS
  165. ///////////////////////////////////////////////
  166. /**
  167. * Create and setup QLabel lblId
  168. * @param string $strControlId optional ControlId to use
  169. * @return QLabel
  170. */
  171. public function lblId_Create($strControlId = null) {
  172. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  173. $this->lblId->Name = QApplication::Translate('Id');
  174. if ($this->blnEditMode)
  175. $this->lblId->Text = $this->objContentBlock->Id;
  176. else
  177. $this->lblId->Text = 'N/A';
  178. return $this->lblId;
  179. }
  180. /**
  181. * Create and setup QTextBox txtName
  182. * @param string $strControlId optional ControlId to use
  183. * @return QTextBox
  184. */
  185. public function txtName_Create($strControlId = null) {
  186. $this->txtName = new QTextBox($this->objParentObject, $strControlId);
  187. $this->txtName->Name = QApplication::Translate('Name');
  188. $this->txtName->Text = $this->objContentBlock->Name;
  189. $this->txtName->MaxLength = ContentBlock::NameMaxLength;
  190. return $this->txtName;
  191. }
  192. /**
  193. * Create and setup QLabel lblName
  194. * @param string $strControlId optional ControlId to use
  195. * @return QLabel
  196. */
  197. public function lblName_Create($strControlId = null) {
  198. $this->lblName = new QLabel($this->objParentObject, $strControlId);
  199. $this->lblName->Name = QApplication::Translate('Name');
  200. $this->lblName->Text = $this->objContentBlock->Name;
  201. return $this->lblName;
  202. }
  203. /**
  204. * Create and setup QTextBox txtCssclass
  205. * @param string $strControlId optional ControlId to use
  206. * @return QTextBox
  207. */
  208. public function txtCssclass_Create($strControlId = null) {
  209. $this->txtCssclass = new QTextBox($this->objParentObject, $strControlId);
  210. $this->txtCssclass->Name = QApplication::Translate('Cssclass');
  211. $this->txtCssclass->Text = $this->objContentBlock->Cssclass;
  212. $this->txtCssclass->MaxLength = ContentBlock::CssclassMaxLength;
  213. return $this->txtCssclass;
  214. }
  215. /**
  216. * Create and setup QLabel lblCssclass
  217. * @param string $strControlId optional ControlId to use
  218. * @return QLabel
  219. */
  220. public function lblCssclass_Create($strControlId = null) {
  221. $this->lblCssclass = new QLabel($this->objParentObject, $strControlId);
  222. $this->lblCssclass->Name = QApplication::Translate('Cssclass');
  223. $this->lblCssclass->Text = $this->objContentBlock->Cssclass;
  224. return $this->lblCssclass;
  225. }
  226. /**
  227. * Create and setup QTextBox txtTitle
  228. * @param string $strControlId optional ControlId to use
  229. * @return QTextBox
  230. */
  231. public function txtTitle_Create($strControlId = null) {
  232. $this->txtTitle = new QTextBox($this->objParentObject, $strControlId);
  233. $this->txtTitle->Name = QApplication::Translate('Title');
  234. $this->txtTitle->Text = $this->objContentBlock->Title;
  235. $this->txtTitle->MaxLength = ContentBlock::TitleMaxLength;
  236. return $this->txtTitle;
  237. }
  238. /**
  239. * Create and setup QLabel lblTitle
  240. * @param string $strControlId optional ControlId to use
  241. * @return QLabel
  242. */
  243. public function lblTitle_Create($strControlId = null) {
  244. $this->lblTitle = new QLabel($this->objParentObject, $strControlId);
  245. $this->lblTitle->Name = QApplication::Translate('Title');
  246. $this->lblTitle->Text = $this->objContentBlock->Title;
  247. return $this->lblTitle;
  248. }
  249. /**
  250. * Create and setup QTextBox txtDescription
  251. * @param string $strControlId optional ControlId to use
  252. * @return QTextBox
  253. */
  254. public function txtDescription_Create($strControlId = null) {
  255. $this->txtDescription = new QTextBox($this->objParentObject, $strControlId);
  256. $this->txtDescription->Name = QApplication::Translate('Description');
  257. $this->txtDescription->Text = $this->objContentBlock->Description;
  258. $this->txtDescription->MaxLength = ContentBlock::DescriptionMaxLength;
  259. return $this->txtDescription;
  260. }
  261. /**
  262. * Create and setup QLabel lblDescription
  263. * @param string $strControlId optional ControlId to use
  264. * @return QLabel
  265. */
  266. public function lblDescription_Create($strControlId = null) {
  267. $this->lblDescription = new QLabel($this->objParentObject, $strControlId);
  268. $this->lblDescription->Name = QApplication::Translate('Description');
  269. $this->lblDescription->Text = $this->objContentBlock->Description;
  270. return $this->lblDescription;
  271. }
  272. /**
  273. * Create and setup QCheckBox chkShowTitle
  274. * @param string $strControlId optional ControlId to use
  275. * @return QCheckBox
  276. */
  277. public function chkShowTitle_Create($strControlId = null) {
  278. $this->chkShowTitle = new QCheckBox($this->objParentObject, $strControlId);
  279. $this->chkShowTitle->Name = QApplication::Translate('Show Title');
  280. $this->chkShowTitle->Checked = $this->objContentBlock->ShowTitle;
  281. return $this->chkShowTitle;
  282. }
  283. /**
  284. * Create and setup QLabel lblShowTitle
  285. * @param string $strControlId optional ControlId to use
  286. * @return QLabel
  287. */
  288. public function lblShowTitle_Create($strControlId = null) {
  289. $this->lblShowTitle = new QLabel($this->objParentObject, $strControlId);
  290. $this->lblShowTitle->Name = QApplication::Translate('Show Title');
  291. $this->lblShowTitle->Text = ($this->objContentBlock->ShowTitle) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  292. return $this->lblShowTitle;
  293. }
  294. /**
  295. * Create and setup QCheckBox chkShowDescription
  296. * @param string $strControlId optional ControlId to use
  297. * @return QCheckBox
  298. */
  299. public function chkShowDescription_Create($strControlId = null) {
  300. $this->chkShowDescription = new QCheckBox($this->objParentObject, $strControlId);
  301. $this->chkShowDescription->Name = QApplication::Translate('Show Description');
  302. $this->chkShowDescription->Checked = $this->objContentBlock->ShowDescription;
  303. return $this->chkShowDescription;
  304. }
  305. /**
  306. * Create and setup QLabel lblShowDescription
  307. * @param string $strControlId optional ControlId to use
  308. * @return QLabel
  309. */
  310. public function lblShowDescription_Create($strControlId = null) {
  311. $this->lblShowDescription = new QLabel($this->objParentObject, $strControlId);
  312. $this->lblShowDescription->Name = QApplication::Translate('Show Description');
  313. $this->lblShowDescription->Text = ($this->objContentBlock->ShowDescription) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  314. return $this->lblShowDescription;
  315. }
  316. /**
  317. * Create and setup QCheckBox chkCollapsable
  318. * @param string $strControlId optional ControlId to use
  319. * @return QCheckBox
  320. */
  321. public function chkCollapsable_Create($strControlId = null) {
  322. $this->chkCollapsable = new QCheckBox($this->objParentObject, $strControlId);
  323. $this->chkCollapsable->Name = QApplication::Translate('Collapsable');
  324. $this->chkCollapsable->Checked = $this->objContentBlock->Collapsable;
  325. return $this->chkCollapsable;
  326. }
  327. /**
  328. * Create and setup QLabel lblCollapsable
  329. * @param string $strControlId optional ControlId to use
  330. * @return QLabel
  331. */
  332. public function lblCollapsable_Create($strControlId = null) {
  333. $this->lblCollapsable = new QLabel($this->objParentObject, $strControlId);
  334. $this->lblCollapsable->Name = QApplication::Translate('Collapsable');
  335. $this->lblCollapsable->Text = ($this->objContentBlock->Collapsable) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  336. return $this->lblCollapsable;
  337. }
  338. /**
  339. * Create and setup QIntegerTextBox txtSortOrder
  340. * @param string $strControlId optional ControlId to use
  341. * @return QIntegerTextBox
  342. */
  343. public function txtSortOrder_Create($strControlId = null) {
  344. $this->txtSortOrder = new QIntegerTextBox($this->objParentObject, $strControlId);
  345. $this->txtSortOrder->Name = QApplication::Translate('Sort Order');
  346. $this->txtSortOrder->Text = $this->objContentBlock->SortOrder;
  347. $this->txtSortOrder->Required = true;
  348. return $this->txtSortOrder;
  349. }
  350. /**
  351. * Create and setup QLabel lblSortOrder
  352. * @param string $strControlId optional ControlId to use
  353. * @param string $strFormat optional sprintf format to use
  354. * @return QLabel
  355. */
  356. public function lblSortOrder_Create($strControlId = null, $strFormat = null) {
  357. $this->lblSortOrder = new QLabel($this->objParentObject, $strControlId);
  358. $this->lblSortOrder->Name = QApplication::Translate('Sort Order');
  359. $this->lblSortOrder->Text = $this->objContentBlock->SortOrder;
  360. $this->lblSortOrder->Required = true;
  361. $this->lblSortOrder->Format = $strFormat;
  362. return $this->lblSortOrder;
  363. }
  364. /**
  365. * Create and setup QIntegerTextBox txtParentContentBlockId
  366. * @param string $strControlId optional ControlId to use
  367. * @return QIntegerTextBox
  368. */
  369. public function txtParentContentBlockId_Create($strControlId = null) {
  370. $this->txtParentContentBlockId = new QIntegerTextBox($this->objParentObject, $strControlId);
  371. $this->txtParentContentBlockId->Name = QApplication::Translate('Parent Content Block Id');
  372. $this->txtParentContentBlockId->Text = $this->objContentBlock->ParentContentBlockId;
  373. return $this->txtParentContentBlockId;
  374. }
  375. /**
  376. * Create and setup QLabel lblParentContentBlockId
  377. * @param string $strControlId optional ControlId to use
  378. * @param string $strFormat optional sprintf format to use
  379. * @return QLabel
  380. */
  381. public function lblParentContentBlockId_Create($strControlId = null, $strFormat = null) {
  382. $this->lblParentContentBlockId = new QLabel($this->objParentObject, $strControlId);
  383. $this->lblParentContentBlockId->Name = QApplication::Translate('Parent Content Block Id');
  384. $this->lblParentContentBlockId->Text = $this->objContentBlock->ParentContentBlockId;
  385. $this->lblParentContentBlockId->Format = $strFormat;
  386. return $this->lblParentContentBlockId;
  387. }
  388. /**
  389. * Create and setup QIntegerTextBox txtLocationId
  390. * @param string $strControlId optional ControlId to use
  391. * @return QIntegerTextBox
  392. */
  393. public function txtLocationId_Create($strControlId = null) {
  394. $this->txtLocationId = new QIntegerTextBox($this->objParentObject, $strControlId);
  395. $this->txtLocationId->Name = QApplication::Translate('Location Id');
  396. $this->txtLocationId->Text = $this->objContentBlock->LocationId;
  397. $this->txtLocationId->Required = true;
  398. return $this->txtLocationId;
  399. }
  400. /**
  401. * Create and setup QLabel lblLocationId
  402. * @param string $strControlId optional ControlId to use
  403. * @param string $strFormat optional sprintf format to use
  404. * @return QLabel
  405. */
  406. public function lblLocationId_Create($strControlId = null, $strFormat = null) {
  407. $this->lblLocationId = new QLabel($this->objParentObject, $strControlId);
  408. $this->lblLocationId->Name = QApplication::Translate('Location Id');
  409. $this->lblLocationId->Text = $this->objContentBlock->LocationId;
  410. $this->lblLocationId->Required = true;
  411. $this->lblLocationId->Format = $strFormat;
  412. return $this->lblLocationId;
  413. }
  414. /**
  415. * Create and setup QListBox lstPages
  416. * @param string $strControlId optional ControlId to use
  417. * @return QListBox
  418. */
  419. public function lstPages_Create($strControlId = null) {
  420. $this->lstPages = new QListBox($this->objParentObject, $strControlId);
  421. $this->lstPages->Name = QApplication::Translate('Pages');
  422. $this->lstPages->SelectionMode = QSelectionMode::Multiple;
  423. $objAssociatedArray = $this->objContentBlock->GetPageArray();
  424. $objPageArray = Page::LoadAll();
  425. if ($objPageArray) foreach ($objPageArray as $objPage) {
  426. $objListItem = new QListItem($objPage->__toString(), $objPage->Id);
  427. foreach ($objAssociatedArray as $objAssociated) {
  428. if ($objAssociated->Id == $objPage->Id)
  429. $objListItem->Selected = true;
  430. }
  431. $this->lstPages->AddItem($objListItem);
  432. }
  433. return $this->lstPages;
  434. }
  435. /**
  436. * Create and setup QLabel lblPages
  437. * @param string $strControlId optional ControlId to use
  438. * @param string $strGlue glue to display in between each associated object
  439. * @return QLabel
  440. */
  441. public function lblPages_Create($strControlId = null, $strGlue = ', ') {
  442. $this->lblPages = new QLabel($this->objParentObject, $strControlId);
  443. $this->lblPages->Name = QApplication::Translate('Pages');
  444. $objAssociatedArray = $this->objContentBlock->GetPageArray();
  445. $strItems = array();
  446. foreach ($objAssociatedArray as $objAssociated)
  447. $strItems[] = $objAssociated->__toString();
  448. $this->lblPages->Text = implode($strGlue, $strItems);
  449. return $this->lblPages;
  450. }
  451. /**
  452. * Create and setup QListBox lstContentItems
  453. * @param string $strControlId optional ControlId to use
  454. * @return QListBox
  455. */
  456. public function lstContentItems_Create($strControlId = null) {
  457. $this->lstContentItems = new QListBox($this->objParentObject, $strControlId);
  458. $this->lstContentItems->Name = QApplication::Translate('Content Items');
  459. $this->lstContentItems->SelectionMode = QSelectionMode::Multiple;
  460. $objAssociatedArray = $this->objContentBlock->GetContentItemArray();
  461. $objContentItemArray = ContentItem::LoadAll();
  462. if ($objContentItemArray) foreach ($objContentItemArray as $objContentItem) {
  463. $objListItem = new QListItem($objContentItem->__toString(), $objContentItem->Id);
  464. foreach ($objAssociatedArray as $objAssociated) {
  465. if ($objAssociated->Id == $objContentItem->Id)
  466. $objListItem->Selected = true;
  467. }
  468. $this->lstContentItems->AddItem($objListItem);
  469. }
  470. return $this->lstContentItems;
  471. }
  472. /**
  473. * Create and setup QLabel lblContentItems
  474. * @param string $strControlId optional ControlId to use
  475. * @param string $strGlue glue to display in between each associated object
  476. * @return QLabel
  477. */
  478. public function lblContentItems_Create($strControlId = null, $strGlue = ', ') {
  479. $this->lblContentItems = new QLabel($this->objParentObject, $strControlId);
  480. $this->lblContentItems->Name = QApplication::Translate('Content Items');
  481. $objAssociatedArray = $this->objContentBlock->GetContentItemArray();
  482. $strItems = array();
  483. foreach ($objAssociatedArray as $objAssociated)
  484. $strItems[] = $objAssociated->__toString();
  485. $this->lblContentItems->Text = implode($strGlue, $strItems);
  486. return $this->lblContentItems;
  487. }
  488. /**
  489. * Create and setup QListBox lstMenus
  490. * @param string $strControlId optional ControlId to use
  491. * @return QListBox
  492. */
  493. public function lstMenus_Create($strControlId = null) {
  494. $this->lstMenus = new QListBox($this->objParentObject, $strControlId);
  495. $this->lstMenus->Name = QApplication::Translate('Menus');
  496. $this->lstMenus->SelectionMode = QSelectionMode::Multiple;
  497. $objAssociatedArray = $this->objContentBlock->GetMenuArray();
  498. $objMenuArray = Menu::LoadAll();
  499. if ($objMenuArray) foreach ($objMenuArray as $objMenu) {
  500. $objListItem = new QListItem($objMenu->__toString(), $objMenu->Id);
  501. foreach ($objAssociatedArray as $objAssociated) {
  502. if ($objAssociated->Id == $objMenu->Id)
  503. $objListItem->Selected = true;
  504. }
  505. $this->lstMenus->AddItem($objListItem);
  506. }
  507. return $this->lstMenus;
  508. }
  509. /**
  510. * Create and setup QLabel lblMenus
  511. * @param string $strControlId optional ControlId to use
  512. * @param string $strGlue glue to display in between each associated object
  513. * @return QLabel
  514. */
  515. public function lblMenus_Create($strControlId = null, $strGlue = ', ') {
  516. $this->lblMenus = new QLabel($this->objParentObject, $strControlId);
  517. $this->lblMenus->Name = QApplication::Translate('Menus');
  518. $objAssociatedArray = $this->objContentBlock->GetMenuArray();
  519. $strItems = array();
  520. foreach ($objAssociatedArray as $objAssociated)
  521. $strItems[] = $objAssociated->__toString();
  522. $this->lblMenus->Text = implode($strGlue, $strItems);
  523. return $this->lblMenus;
  524. }
  525. /**
  526. * Refresh this MetaControl with Data from the local ContentBlock object.
  527. * @param boolean $blnReload reload ContentBlock from the database
  528. * @return void
  529. */
  530. public function Refresh($blnReload = false) {
  531. if ($blnReload)
  532. $this->objContentBlock->Reload();
  533. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objContentBlock->Id;
  534. if ($this->txtName) $this->txtName->Text = $this->objContentBlock->Name;
  535. if ($this->lblName) $this->lblName->Text = $this->objContentBlock->Name;
  536. if ($this->txtCssclass) $this->txtCssclass->Text = $this->objContentBlock->Cssclass;
  537. if ($this->lblCssclass) $this->lblCssclass->Text = $this->objContentBlock->Cssclass;
  538. if ($this->txtTitle) $this->txtTitle->Text = $this->objContentBlock->Title;
  539. if ($this->lblTitle) $this->lblTitle->Text = $this->objContentBlock->Title;
  540. if ($this->txtDescription) $this->txtDescription->Text = $this->objContentBlock->Description;
  541. if ($this->lblDescription) $this->lblDescription->Text = $this->objContentBlock->Description;
  542. if ($this->chkShowTitle) $this->chkShowTitle->Checked = $this->objContentBlock->ShowTitle;
  543. if ($this->lblShowTitle) $this->lblShowTitle->Text = ($this->objContentBlock->ShowTitle) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  544. if ($this->chkShowDescription) $this->chkShowDescription->Checked = $this->objContentBlock->ShowDescription;
  545. if ($this->lblShowDescription) $this->lblShowDescription->Text = ($this->objContentBlock->ShowDescription) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  546. if ($this->chkCollapsable) $this->chkCollapsable->Checked = $this->objContentBlock->Collapsable;
  547. if ($this->lblCollapsable) $this->lblCollapsable->Text = ($this->objContentBlock->Collapsable) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  548. if ($this->txtSortOrder) $this->txtSortOrder->Text = $this->objContentBlock->SortOrder;
  549. if ($this->lblSortOrder) $this->lblSortOrder->Text = $this->objContentBlock->SortOrder;
  550. if ($this->txtParentContentBlockId) $this->txtParentContentBlockId->Text = $this->objContentBlock->ParentContentBlockId;
  551. if ($this->lblParentContentBlockId) $this->lblParentContentBlockId->Text = $this->objContentBlock->ParentContentBlockId;
  552. if ($this->txtLocationId) $this->txtLocationId->Text = $this->objContentBlock->LocationId;
  553. if ($this->lblLocationId) $this->lblLocationId->Text = $this->objContentBlock->LocationId;
  554. if ($this->lstPages) {
  555. $this->lstPages->RemoveAllItems();
  556. $objAssociatedArray = $this->objContentBlock->GetPageArray();
  557. $objPageArray = Page::LoadAll();
  558. if ($objPageArray) foreach ($objPageArray as $objPage) {
  559. $objListItem = new QListItem($objPage->__toString(), $objPage->Id);
  560. foreach ($objAssociatedArray as $objAssociated) {
  561. if ($objAssociated->Id == $objPage->Id)
  562. $objListItem->Selected = true;
  563. }
  564. $this->lstPages->AddItem($objListItem);
  565. }
  566. }
  567. if ($this->lblPages) {
  568. $objAssociatedArray = $this->objContentBlock->GetPageArray();
  569. $strItems = array();
  570. foreach ($objAssociatedArray as $objAssociated)
  571. $strItems[] = $objAssociated->__toString();
  572. $this->lblPages->Text = implode($strGlue, $strItems);
  573. }
  574. if ($this->lstContentItems) {
  575. $this->lstContentItems->RemoveAllItems();
  576. $objAssociatedArray = $this->objContentBlock->GetContentItemArray();
  577. $objContentItemArray = ContentItem::LoadAll();
  578. if ($objContentItemArray) foreach ($objContentItemArray as $objContentItem) {
  579. $objListItem = new QListItem($objContentItem->__toString(), $objContentItem->Id);
  580. foreach ($objAssociatedArray as $objAssociated) {
  581. if ($objAssociated->Id == $objContentItem->Id)
  582. $objListItem->Selected = true;
  583. }
  584. $this->lstContentItems->AddItem($objListItem);
  585. }
  586. }
  587. if ($this->lblContentItems) {
  588. $objAssociatedArray = $this->objContentBlock->GetContentItemArray();
  589. $strItems = array();
  590. foreach ($objAssociatedArray as $objAssociated)
  591. $strItems[] = $objAssociated->__toString();
  592. $this->lblContentItems->Text = implode($strGlue, $strItems);
  593. }
  594. if ($this->lstMenus) {
  595. $this->lstMenus->RemoveAllItems();
  596. $objAssociatedArray = $this->objContentBlock->GetMenuArray();
  597. $objMenuArray = Menu::LoadAll();
  598. if ($objMenuArray) foreach ($objMenuArray as $objMenu) {
  599. $objListItem = new QListItem($objMenu->__toString(), $objMenu->Id);
  600. foreach ($objAssociatedArray as $objAssociated) {
  601. if ($objAssociated->Id == $objMenu->Id)
  602. $objListItem->Selected = true;
  603. }
  604. $this->lstMenus->AddItem($objListItem);
  605. }
  606. }
  607. if ($this->lblMenus) {
  608. $objAssociatedArray = $this->objContentBlock->GetMenuArray();
  609. $strItems = array();
  610. foreach ($objAssociatedArray as $objAssociated)
  611. $strItems[] = $objAssociated->__toString();
  612. $this->lblMenus->Text = implode($strGlue, $strItems);
  613. }
  614. }
  615. ///////////////////////////////////////////////
  616. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  617. ///////////////////////////////////////////////
  618. protected function lstPages_Update() {
  619. if ($this->lstPages) {
  620. $this->objContentBlock->UnassociateAllPages();
  621. $objSelectedListItems = $this->lstPages->SelectedItems;
  622. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  623. $this->objContentBlock->AssociatePage(Page::Load($objListItem->Value));
  624. }
  625. }
  626. }
  627. protected function lstContentItems_Update() {
  628. if ($this->lstContentItems) {
  629. $this->objContentBlock->UnassociateAllContentItems();
  630. $objSelectedListItems = $this->lstContentItems->SelectedItems;
  631. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  632. $this->objContentBlock->AssociateContentItem(ContentItem::Load($objListItem->Value));
  633. }
  634. }
  635. }
  636. protected function lstMenus_Update() {
  637. if ($this->lstMenus) {
  638. $this->objContentBlock->UnassociateAllMenus();
  639. $objSelectedListItems = $this->lstMenus->SelectedItems;
  640. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  641. $this->objContentBlock->AssociateMenu(Menu::Load($objListItem->Value));
  642. }
  643. }
  644. }
  645. ///////////////////////////////////////////////
  646. // PUBLIC CONTENTBLOCK OBJECT MANIPULATORS
  647. ///////////////////////////////////////////////
  648. /**
  649. * This will save this object's ContentBlock instance,
  650. * updating only the fields which have had a control created for it.
  651. */
  652. public function SaveContentBlock() {
  653. try {
  654. // Update any fields for controls that have been created
  655. if ($this->txtName) $this->objContentBlock->Name = $this->txtName->Text;
  656. if ($this->txtCssclass) $this->objContentBlock->Cssclass = $this->txtCssclass->Text;
  657. if ($this->txtTitle) $this->objContentBlock->Title = $this->txtTitle->Text;
  658. if ($this->txtDescription) $this->objContentBlock->Description = $this->txtDescription->Text;
  659. if ($this->chkShowTitle) $this->objContentBlock->ShowTitle = $this->chkShowTitle->Checked;
  660. if ($this->chkShowDescription) $this->objContentBlock->ShowDescription = $this->chkShowDescription->Checked;
  661. if ($this->chkCollapsable) $this->objContentBlock->Collapsable = $this->chkCollapsable->Checked;
  662. if ($this->txtSortOrder) $this->objContentBlock->SortOrder = $this->txtSortOrder->Text;
  663. if ($this->txtParentContentBlockId) $this->objContentBlock->ParentContentBlockId = $this->txtParentContentBlockId->Text;
  664. if ($this->txtLocationId) $this->objContentBlock->LocationId = $this->txtLocationId->Text;
  665. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  666. // Save the ContentBlock object
  667. $this->objContentBlock->Save();
  668. // Finally, update any ManyToManyReferences (if any)
  669. $this->lstPages_Update();
  670. $this->lstContentItems_Update();
  671. $this->lstMenus_Update();
  672. } catch (QCallerException $objExc) {
  673. $objExc->IncrementOffset();
  674. throw $objExc;
  675. }
  676. }
  677. /**
  678. * This will DELETE this object's ContentBlock instance from the database.
  679. * It will also unassociate itself from any ManyToManyReferences.
  680. */
  681. public function DeleteContentBlock() {
  682. $this->objContentBlock->UnassociateAllPages();
  683. $this->objContentBlock->UnassociateAllContentItems();
  684. $this->objContentBlock->UnassociateAllMenus();
  685. $this->objContentBlock->Delete();
  686. }
  687. ///////////////////////////////////////////////
  688. // PUBLIC GETTERS and SETTERS
  689. ///////////////////////////////////////////////
  690. /**
  691. * Override method to perform a property "Get"
  692. * This will get the value of $strName
  693. *
  694. * @param string $strName Name of the property to get
  695. * @return mixed
  696. */
  697. public function __get($strName) {
  698. switch ($strName) {
  699. // General MetaControlVariables
  700. case 'ContentBlock': return $this->objContentBlock;
  701. case 'TitleVerb': return $this->strTitleVerb;
  702. case 'EditMode': return $this->blnEditMode;
  703. // Controls that point to ContentBlock fields -- will be created dynamically if not yet created
  704. case 'IdControl':
  705. if (!$this->lblId) return $this->lblId_Create();
  706. return $this->lblId;
  707. case 'IdLabel':
  708. if (!$this->lblId) return $this->lblId_Create();
  709. return $this->lblId;
  710. case 'NameControl':
  711. if (!$this->txtName) return $this->txtName_Create();
  712. return $this->txtName;
  713. case 'NameLabel':
  714. if (!$this->lblName) return $this->lblName_Create();
  715. return $this->lblName;
  716. case 'CssclassControl':
  717. if (!$this->txtCssclass) return $this->txtCssclass_Create();
  718. return $this->txtCssclass;
  719. case 'CssclassLabel':
  720. if (!$this->lblCssclass) return $this->lblCssclass_Create();
  721. return $this->lblCssclass;
  722. case 'TitleControl':
  723. if (!$this->txtTitle) return $this->txtTitle_Create();
  724. return $this->txtTitle;
  725. case 'TitleLabel':
  726. if (!$this->lblTitle) return $this->lblTitle_Create();
  727. return $this->lblTitle;
  728. case 'DescriptionControl':
  729. if (!$this->txtDescription) return $this->txtDescription_Create();
  730. return $this->txtDescription;
  731. case 'DescriptionLabel':
  732. if (!$this->lblDescription) return $this->lblDescription_Create();
  733. return $this->lblDescription;
  734. case 'ShowTitleControl':
  735. if (!$this->chkShowTitle) return $this->chkShowTitle_Create();
  736. return $this->chkShowTitle;
  737. case 'ShowTitleLabel':
  738. if (!$this->lblShowTitle) return $this->lblShowTitle_Create();
  739. return $this->lblShowTitle;
  740. case 'ShowDescriptionControl':
  741. if (!$this->chkShowDescription) return $this->chkShowDescription_Create();
  742. return $this->chkShowDescription;
  743. case 'ShowDescriptionLabel':
  744. if (!$this->lblShowDescription) return $this->lblShowDescription_Create();
  745. return $this->lblShowDescription;
  746. case 'CollapsableControl':
  747. if (!$this->chkCollapsable) return $this->chkCollapsable_Create();
  748. return $this->chkCollapsable;
  749. case 'CollapsableLabel':
  750. if (!$this->lblCollapsable) return $this->lblCollapsable_Create();
  751. return $this->lblCollapsable;
  752. case 'SortOrderControl':
  753. if (!$this->txtSortOrder) return $this->txtSortOrder_Create();
  754. return $this->txtSortOrder;
  755. case 'SortOrderLabel':
  756. if (!$this->lblSortOrder) return $this->lblSortOrder_Create();
  757. return $this->lblSortOrder;
  758. case 'ParentContentBlockIdControl':
  759. if (!$this->txtParentContentBlockId) return $this->txtParentContentBlockId_Create();
  760. return $this->txtParentContentBlockId;
  761. case 'ParentContentBlockIdLabel':
  762. if (!$this->lblParentContentBlockId) return $this->lblParentContentBlockId_Create();
  763. return $this->lblParentContentBlockId;
  764. case 'LocationIdControl':
  765. if (!$this->txtLocationId) return $this->txtLocationId_Create();
  766. return $this->txtLocationId;
  767. case 'LocationIdLabel':
  768. if (!$this->lblLocationId) return $this->lblLocationId_Create();
  769. return $this->lblLocationId;
  770. case 'PageControl':
  771. if (!$this->lstPages) return $this->lstPages_Create();
  772. return $this->lstPages;
  773. case 'PageLabel':
  774. if (!$this->lblPages) return $this->lblPages_Create();
  775. return $this->lblPages;
  776. case 'ContentItemControl':
  777. if (!$this->lstContentItems) return $this->lstContentItems_Create();
  778. return $this->lstContentItems;
  779. case 'ContentItemLabel':
  780. if (!$this->lblContentItems) return $this->lblContentItems_Create();
  781. return $this->lblContentItems;
  782. case 'MenuControl':
  783. if (!$this->lstMenus) return $this->lstMenus_Create();
  784. return $this->lstMenus;
  785. case 'MenuLabel':
  786. if (!$this->lblMenus) return $this->lblMenus_Create();
  787. return $this->lblMenus;
  788. default:
  789. try {
  790. return parent::__get($strName);
  791. } catch (QCallerException $objExc) {
  792. $objExc->IncrementOffset();
  793. throw $objExc;
  794. }
  795. }
  796. }
  797. /**
  798. * Override method to perform a property "Set"
  799. * This will set the property $strName to be $mixValue
  800. *
  801. * @param string $strName Name of the property to set
  802. * @param string $mixValue New value of the property
  803. * @return mixed
  804. */
  805. public function __set($strName, $mixValue) {
  806. try {
  807. switch ($strName) {
  808. // Controls that point to ContentBlock fields
  809. case 'IdControl':
  810. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  811. case 'NameControl':
  812. return ($this->txtName = QType::Cast($mixValue, 'QControl'));
  813. case 'CssclassControl':
  814. return ($this->txtCssclass = QType::Cast($mixValue, 'QControl'));
  815. case 'TitleControl':
  816. return ($this->txtTitle = QType::Cast($mixValue, 'QControl'));
  817. case 'DescriptionControl':
  818. return ($this->txtDescription = QType::Cast($mixValue, 'QControl'));
  819. case 'ShowTitleControl':
  820. return ($this->chkShowTitle = QType::Cast($mixValue, 'QControl'));
  821. case 'ShowDescriptionControl':
  822. return ($this->chkShowDescription = QType::Cast($mixValue, 'QControl'));
  823. case 'CollapsableControl':
  824. return ($this->chkCollapsable = QType::Cast($mixValue, 'QControl'));
  825. case 'SortOrderControl':
  826. return ($this->txtSortOrder = QType::Cast($mixValue, 'QControl'));
  827. case 'ParentContentBlockIdControl':
  828. return ($this->txtParentContentBlockId = QType::Cast($mixValue, 'QControl'));
  829. case 'LocationIdControl':
  830. return ($this->txtLocationId = QType::Cast($mixValue, 'QControl'));
  831. case 'PageControl':
  832. return ($this->lstPages = QType::Cast($mixValue, 'QControl'));
  833. case 'ContentItemControl':
  834. return ($this->lstContentItems = QType::Cast($mixValue, 'QControl'));
  835. case 'MenuControl':
  836. return ($this->lstMenus = QType::Cast($mixValue, 'QControl'));
  837. default:
  838. return parent::__set($strName, $mixValue);
  839. }
  840. } catch (QCallerException $objExc) {
  841. $objExc->IncrementOffset();
  842. throw $objExc;
  843. }
  844. }
  845. }
  846. ?>