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.

785 lines
35 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 MenuItem 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 MenuItem 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 MenuItemMetaControl
  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 MenuItem $MenuItem the actual MenuItem 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 $LabelControl
  26. * property-read QLabel $LabelLabel
  27. * property QTextBox $UriControl
  28. * property-read QLabel $UriLabel
  29. * property QCheckBox $IsLocalControl
  30. * property-read QLabel $IsLocalLabel
  31. * property QCheckBox $IsSslControl
  32. * property-read QLabel $IsSslLabel
  33. * property QIntegerTextBox $SortOrderControl
  34. * property-read QLabel $SortOrderLabel
  35. * property QListBox $StatusIdControl
  36. * property-read QLabel $StatusIdLabel
  37. * property QListBox $TypeIdControl
  38. * property-read QLabel $TypeIdLabel
  39. * property QListBox $PageIdControl
  40. * property-read QLabel $PageIdLabel
  41. * property QListBox $MenuControl
  42. * property-read QLabel $MenuLabel
  43. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  44. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  45. */
  46. class MenuItemMetaControlGen extends QBaseClass {
  47. // General Variables
  48. protected $objMenuItem;
  49. protected $objParentObject;
  50. protected $strTitleVerb;
  51. protected $blnEditMode;
  52. // Controls that allow the editing of MenuItem's individual data fields
  53. protected $lblId;
  54. protected $txtName;
  55. protected $txtCssClass;
  56. protected $txtLabel;
  57. protected $txtUri;
  58. protected $chkIsLocal;
  59. protected $chkIsSsl;
  60. protected $txtSortOrder;
  61. protected $lstStatus;
  62. protected $lstType;
  63. protected $lstPage;
  64. // Controls that allow the viewing of MenuItem's individual data fields
  65. protected $lblName;
  66. protected $lblCssClass;
  67. protected $lblLabel;
  68. protected $lblUri;
  69. protected $lblIsLocal;
  70. protected $lblIsSsl;
  71. protected $lblSortOrder;
  72. protected $lblStatusId;
  73. protected $lblTypeId;
  74. protected $lblPageId;
  75. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  76. protected $lstMenus;
  77. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  78. protected $lblMenus;
  79. /**
  80. * Main constructor. Constructor OR static create methods are designed to be called in either
  81. * a parent QPanel or the main QForm when wanting to create a
  82. * MenuItemMetaControl to edit a single MenuItem object within the
  83. * QPanel or QForm.
  84. *
  85. * This constructor takes in a single MenuItem object, while any of the static
  86. * create methods below can be used to construct based off of individual PK ID(s).
  87. *
  88. * @param mixed $objParentObject QForm or QPanel which will be using this MenuItemMetaControl
  89. * @param MenuItem $objMenuItem new or existing MenuItem object
  90. */
  91. public function __construct($objParentObject, MenuItem $objMenuItem) {
  92. // Setup Parent Object (e.g. QForm or QPanel which will be using this MenuItemMetaControl)
  93. $this->objParentObject = $objParentObject;
  94. // Setup linked MenuItem object
  95. $this->objMenuItem = $objMenuItem;
  96. // Figure out if we're Editing or Creating New
  97. if ($this->objMenuItem->__Restored) {
  98. $this->strTitleVerb = QApplication::Translate('Edit');
  99. $this->blnEditMode = true;
  100. } else {
  101. $this->strTitleVerb = QApplication::Translate('Create');
  102. $this->blnEditMode = false;
  103. }
  104. }
  105. /**
  106. * Static Helper Method to Create using PK arguments
  107. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  108. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  109. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  110. * edit, or if we are also allowed to create a new one, etc.
  111. *
  112. * @param mixed $objParentObject QForm or QPanel which will be using this MenuItemMetaControl
  113. * @param integer $intId primary key value
  114. * @param QMetaControlCreateType $intCreateType rules governing MenuItem object creation - defaults to CreateOrEdit
  115. * @return MenuItemMetaControl
  116. */
  117. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  118. // Attempt to Load from PK Arguments
  119. if (strlen($intId)) {
  120. $objMenuItem = MenuItem::Load($intId);
  121. // MenuItem was found -- return it!
  122. if ($objMenuItem)
  123. return new MenuItemMetaControl($objParentObject, $objMenuItem);
  124. // If CreateOnRecordNotFound not specified, throw an exception
  125. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  126. throw new QCallerException('Could not find a MenuItem object with PK arguments: ' . $intId);
  127. // If EditOnly is specified, throw an exception
  128. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  129. throw new QCallerException('No PK arguments specified');
  130. // If we are here, then we need to create a new record
  131. return new MenuItemMetaControl($objParentObject, new MenuItem());
  132. }
  133. /**
  134. * Static Helper Method to Create using PathInfo arguments
  135. *
  136. * @param mixed $objParentObject QForm or QPanel which will be using this MenuItemMetaControl
  137. * @param QMetaControlCreateType $intCreateType rules governing MenuItem object creation - defaults to CreateOrEdit
  138. * @return MenuItemMetaControl
  139. */
  140. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  141. $intId = QApplication::PathInfo(0);
  142. return MenuItemMetaControl::Create($objParentObject, $intId, $intCreateType);
  143. }
  144. /**
  145. * Static Helper Method to Create using QueryString arguments
  146. *
  147. * @param mixed $objParentObject QForm or QPanel which will be using this MenuItemMetaControl
  148. * @param QMetaControlCreateType $intCreateType rules governing MenuItem object creation - defaults to CreateOrEdit
  149. * @return MenuItemMetaControl
  150. */
  151. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  152. $intId = QApplication::QueryString('intId');
  153. return MenuItemMetaControl::Create($objParentObject, $intId, $intCreateType);
  154. }
  155. ///////////////////////////////////////////////
  156. // PUBLIC CREATE and REFRESH METHODS
  157. ///////////////////////////////////////////////
  158. /**
  159. * Create and setup QLabel lblId
  160. * @param string $strControlId optional ControlId to use
  161. * @return QLabel
  162. */
  163. public function lblId_Create($strControlId = null) {
  164. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  165. $this->lblId->Name = QApplication::Translate('Id');
  166. if ($this->blnEditMode)
  167. $this->lblId->Text = $this->objMenuItem->Id;
  168. else
  169. $this->lblId->Text = 'N/A';
  170. return $this->lblId;
  171. }
  172. /**
  173. * Create and setup QTextBox txtName
  174. * @param string $strControlId optional ControlId to use
  175. * @return QTextBox
  176. */
  177. public function txtName_Create($strControlId = null) {
  178. $this->txtName = new QTextBox($this->objParentObject, $strControlId);
  179. $this->txtName->Name = QApplication::Translate('Name');
  180. $this->txtName->Text = $this->objMenuItem->Name;
  181. $this->txtName->Required = true;
  182. $this->txtName->MaxLength = MenuItem::NameMaxLength;
  183. return $this->txtName;
  184. }
  185. /**
  186. * Create and setup QLabel lblName
  187. * @param string $strControlId optional ControlId to use
  188. * @return QLabel
  189. */
  190. public function lblName_Create($strControlId = null) {
  191. $this->lblName = new QLabel($this->objParentObject, $strControlId);
  192. $this->lblName->Name = QApplication::Translate('Name');
  193. $this->lblName->Text = $this->objMenuItem->Name;
  194. $this->lblName->Required = true;
  195. return $this->lblName;
  196. }
  197. /**
  198. * Create and setup QTextBox txtCssClass
  199. * @param string $strControlId optional ControlId to use
  200. * @return QTextBox
  201. */
  202. public function txtCssClass_Create($strControlId = null) {
  203. $this->txtCssClass = new QTextBox($this->objParentObject, $strControlId);
  204. $this->txtCssClass->Name = QApplication::Translate('Css Class');
  205. $this->txtCssClass->Text = $this->objMenuItem->CssClass;
  206. $this->txtCssClass->MaxLength = MenuItem::CssClassMaxLength;
  207. return $this->txtCssClass;
  208. }
  209. /**
  210. * Create and setup QLabel lblCssClass
  211. * @param string $strControlId optional ControlId to use
  212. * @return QLabel
  213. */
  214. public function lblCssClass_Create($strControlId = null) {
  215. $this->lblCssClass = new QLabel($this->objParentObject, $strControlId);
  216. $this->lblCssClass->Name = QApplication::Translate('Css Class');
  217. $this->lblCssClass->Text = $this->objMenuItem->CssClass;
  218. return $this->lblCssClass;
  219. }
  220. /**
  221. * Create and setup QTextBox txtLabel
  222. * @param string $strControlId optional ControlId to use
  223. * @return QTextBox
  224. */
  225. public function txtLabel_Create($strControlId = null) {
  226. $this->txtLabel = new QTextBox($this->objParentObject, $strControlId);
  227. $this->txtLabel->Name = QApplication::Translate('Label');
  228. $this->txtLabel->Text = $this->objMenuItem->Label;
  229. $this->txtLabel->MaxLength = MenuItem::LabelMaxLength;
  230. return $this->txtLabel;
  231. }
  232. /**
  233. * Create and setup QLabel lblLabel
  234. * @param string $strControlId optional ControlId to use
  235. * @return QLabel
  236. */
  237. public function lblLabel_Create($strControlId = null) {
  238. $this->lblLabel = new QLabel($this->objParentObject, $strControlId);
  239. $this->lblLabel->Name = QApplication::Translate('Label');
  240. $this->lblLabel->Text = $this->objMenuItem->Label;
  241. return $this->lblLabel;
  242. }
  243. /**
  244. * Create and setup QTextBox txtUri
  245. * @param string $strControlId optional ControlId to use
  246. * @return QTextBox
  247. */
  248. public function txtUri_Create($strControlId = null) {
  249. $this->txtUri = new QTextBox($this->objParentObject, $strControlId);
  250. $this->txtUri->Name = QApplication::Translate('Uri');
  251. $this->txtUri->Text = $this->objMenuItem->Uri;
  252. $this->txtUri->Required = true;
  253. $this->txtUri->MaxLength = MenuItem::UriMaxLength;
  254. return $this->txtUri;
  255. }
  256. /**
  257. * Create and setup QLabel lblUri
  258. * @param string $strControlId optional ControlId to use
  259. * @return QLabel
  260. */
  261. public function lblUri_Create($strControlId = null) {
  262. $this->lblUri = new QLabel($this->objParentObject, $strControlId);
  263. $this->lblUri->Name = QApplication::Translate('Uri');
  264. $this->lblUri->Text = $this->objMenuItem->Uri;
  265. $this->lblUri->Required = true;
  266. return $this->lblUri;
  267. }
  268. /**
  269. * Create and setup QCheckBox chkIsLocal
  270. * @param string $strControlId optional ControlId to use
  271. * @return QCheckBox
  272. */
  273. public function chkIsLocal_Create($strControlId = null) {
  274. $this->chkIsLocal = new QCheckBox($this->objParentObject, $strControlId);
  275. $this->chkIsLocal->Name = QApplication::Translate('Is Local');
  276. $this->chkIsLocal->Checked = $this->objMenuItem->IsLocal;
  277. return $this->chkIsLocal;
  278. }
  279. /**
  280. * Create and setup QLabel lblIsLocal
  281. * @param string $strControlId optional ControlId to use
  282. * @return QLabel
  283. */
  284. public function lblIsLocal_Create($strControlId = null) {
  285. $this->lblIsLocal = new QLabel($this->objParentObject, $strControlId);
  286. $this->lblIsLocal->Name = QApplication::Translate('Is Local');
  287. $this->lblIsLocal->Text = ($this->objMenuItem->IsLocal) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  288. return $this->lblIsLocal;
  289. }
  290. /**
  291. * Create and setup QCheckBox chkIsSsl
  292. * @param string $strControlId optional ControlId to use
  293. * @return QCheckBox
  294. */
  295. public function chkIsSsl_Create($strControlId = null) {
  296. $this->chkIsSsl = new QCheckBox($this->objParentObject, $strControlId);
  297. $this->chkIsSsl->Name = QApplication::Translate('Is Ssl');
  298. $this->chkIsSsl->Checked = $this->objMenuItem->IsSsl;
  299. return $this->chkIsSsl;
  300. }
  301. /**
  302. * Create and setup QLabel lblIsSsl
  303. * @param string $strControlId optional ControlId to use
  304. * @return QLabel
  305. */
  306. public function lblIsSsl_Create($strControlId = null) {
  307. $this->lblIsSsl = new QLabel($this->objParentObject, $strControlId);
  308. $this->lblIsSsl->Name = QApplication::Translate('Is Ssl');
  309. $this->lblIsSsl->Text = ($this->objMenuItem->IsSsl) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  310. return $this->lblIsSsl;
  311. }
  312. /**
  313. * Create and setup QIntegerTextBox txtSortOrder
  314. * @param string $strControlId optional ControlId to use
  315. * @return QIntegerTextBox
  316. */
  317. public function txtSortOrder_Create($strControlId = null) {
  318. $this->txtSortOrder = new QIntegerTextBox($this->objParentObject, $strControlId);
  319. $this->txtSortOrder->Name = QApplication::Translate('Sort Order');
  320. $this->txtSortOrder->Text = $this->objMenuItem->SortOrder;
  321. $this->txtSortOrder->Required = true;
  322. return $this->txtSortOrder;
  323. }
  324. /**
  325. * Create and setup QLabel lblSortOrder
  326. * @param string $strControlId optional ControlId to use
  327. * @param string $strFormat optional sprintf format to use
  328. * @return QLabel
  329. */
  330. public function lblSortOrder_Create($strControlId = null, $strFormat = null) {
  331. $this->lblSortOrder = new QLabel($this->objParentObject, $strControlId);
  332. $this->lblSortOrder->Name = QApplication::Translate('Sort Order');
  333. $this->lblSortOrder->Text = $this->objMenuItem->SortOrder;
  334. $this->lblSortOrder->Required = true;
  335. $this->lblSortOrder->Format = $strFormat;
  336. return $this->lblSortOrder;
  337. }
  338. /**
  339. * Create and setup QListBox lstStatus
  340. * @param string $strControlId optional ControlId to use
  341. * @return QListBox
  342. */
  343. public function lstStatus_Create($strControlId = null) {
  344. $this->lstStatus = new QListBox($this->objParentObject, $strControlId);
  345. $this->lstStatus->Name = QApplication::Translate('Status');
  346. $this->lstStatus->Required = true;
  347. foreach (MenuStatusType::$NameArray as $intId => $strValue)
  348. $this->lstStatus->AddItem(new QListItem($strValue, $intId, $this->objMenuItem->StatusId == $intId));
  349. return $this->lstStatus;
  350. }
  351. /**
  352. * Create and setup QLabel lblStatusId
  353. * @param string $strControlId optional ControlId to use
  354. * @return QLabel
  355. */
  356. public function lblStatusId_Create($strControlId = null) {
  357. $this->lblStatusId = new QLabel($this->objParentObject, $strControlId);
  358. $this->lblStatusId->Name = QApplication::Translate('Status');
  359. $this->lblStatusId->Text = ($this->objMenuItem->StatusId) ? MenuStatusType::$NameArray[$this->objMenuItem->StatusId] : null;
  360. $this->lblStatusId->Required = true;
  361. return $this->lblStatusId;
  362. }
  363. /**
  364. * Create and setup QListBox lstType
  365. * @param string $strControlId optional ControlId to use
  366. * @return QListBox
  367. */
  368. public function lstType_Create($strControlId = null) {
  369. $this->lstType = new QListBox($this->objParentObject, $strControlId);
  370. $this->lstType->Name = QApplication::Translate('Type');
  371. $this->lstType->Required = true;
  372. foreach (MenuItemType::$NameArray as $intId => $strValue)
  373. $this->lstType->AddItem(new QListItem($strValue, $intId, $this->objMenuItem->TypeId == $intId));
  374. return $this->lstType;
  375. }
  376. /**
  377. * Create and setup QLabel lblTypeId
  378. * @param string $strControlId optional ControlId to use
  379. * @return QLabel
  380. */
  381. public function lblTypeId_Create($strControlId = null) {
  382. $this->lblTypeId = new QLabel($this->objParentObject, $strControlId);
  383. $this->lblTypeId->Name = QApplication::Translate('Type');
  384. $this->lblTypeId->Text = ($this->objMenuItem->TypeId) ? MenuItemType::$NameArray[$this->objMenuItem->TypeId] : null;
  385. $this->lblTypeId->Required = true;
  386. return $this->lblTypeId;
  387. }
  388. /**
  389. * Create and setup QListBox lstPage
  390. * @param string $strControlId optional ControlId to use
  391. * @return QListBox
  392. */
  393. public function lstPage_Create($strControlId = null) {
  394. $this->lstPage = new QListBox($this->objParentObject, $strControlId);
  395. $this->lstPage->Name = QApplication::Translate('Page');
  396. $this->lstPage->AddItem(QApplication::Translate('- Select One -'), null);
  397. $objPageArray = Page::LoadAll();
  398. if ($objPageArray) foreach ($objPageArray as $objPage) {
  399. $objListItem = new QListItem($objPage->__toString(), $objPage->Id);
  400. if (($this->objMenuItem->Page) && ($this->objMenuItem->Page->Id == $objPage->Id))
  401. $objListItem->Selected = true;
  402. $this->lstPage->AddItem($objListItem);
  403. }
  404. return $this->lstPage;
  405. }
  406. /**
  407. * Create and setup QLabel lblPageId
  408. * @param string $strControlId optional ControlId to use
  409. * @return QLabel
  410. */
  411. public function lblPageId_Create($strControlId = null) {
  412. $this->lblPageId = new QLabel($this->objParentObject, $strControlId);
  413. $this->lblPageId->Name = QApplication::Translate('Page');
  414. $this->lblPageId->Text = ($this->objMenuItem->Page) ? $this->objMenuItem->Page->__toString() : null;
  415. return $this->lblPageId;
  416. }
  417. /**
  418. * Create and setup QListBox lstMenus
  419. * @param string $strControlId optional ControlId to use
  420. * @return QListBox
  421. */
  422. public function lstMenus_Create($strControlId = null) {
  423. $this->lstMenus = new QListBox($this->objParentObject, $strControlId);
  424. $this->lstMenus->Name = QApplication::Translate('Menus');
  425. $this->lstMenus->SelectionMode = QSelectionMode::Multiple;
  426. $objAssociatedArray = $this->objMenuItem->GetMenuArray();
  427. $objMenuArray = Menu::LoadAll();
  428. if ($objMenuArray) foreach ($objMenuArray as $objMenu) {
  429. $objListItem = new QListItem($objMenu->__toString(), $objMenu->Id);
  430. foreach ($objAssociatedArray as $objAssociated) {
  431. if ($objAssociated->Id == $objMenu->Id)
  432. $objListItem->Selected = true;
  433. }
  434. $this->lstMenus->AddItem($objListItem);
  435. }
  436. return $this->lstMenus;
  437. }
  438. /**
  439. * Create and setup QLabel lblMenus
  440. * @param string $strControlId optional ControlId to use
  441. * @param string $strGlue glue to display in between each associated object
  442. * @return QLabel
  443. */
  444. public function lblMenus_Create($strControlId = null, $strGlue = ', ') {
  445. $this->lblMenus = new QLabel($this->objParentObject, $strControlId);
  446. $this->lblMenus->Name = QApplication::Translate('Menus');
  447. $objAssociatedArray = $this->objMenuItem->GetMenuArray();
  448. $strItems = array();
  449. foreach ($objAssociatedArray as $objAssociated)
  450. $strItems[] = $objAssociated->__toString();
  451. $this->lblMenus->Text = implode($strGlue, $strItems);
  452. return $this->lblMenus;
  453. }
  454. /**
  455. * Refresh this MetaControl with Data from the local MenuItem object.
  456. * @param boolean $blnReload reload MenuItem from the database
  457. * @return void
  458. */
  459. public function Refresh($blnReload = false) {
  460. if ($blnReload)
  461. $this->objMenuItem->Reload();
  462. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objMenuItem->Id;
  463. if ($this->txtName) $this->txtName->Text = $this->objMenuItem->Name;
  464. if ($this->lblName) $this->lblName->Text = $this->objMenuItem->Name;
  465. if ($this->txtCssClass) $this->txtCssClass->Text = $this->objMenuItem->CssClass;
  466. if ($this->lblCssClass) $this->lblCssClass->Text = $this->objMenuItem->CssClass;
  467. if ($this->txtLabel) $this->txtLabel->Text = $this->objMenuItem->Label;
  468. if ($this->lblLabel) $this->lblLabel->Text = $this->objMenuItem->Label;
  469. if ($this->txtUri) $this->txtUri->Text = $this->objMenuItem->Uri;
  470. if ($this->lblUri) $this->lblUri->Text = $this->objMenuItem->Uri;
  471. if ($this->chkIsLocal) $this->chkIsLocal->Checked = $this->objMenuItem->IsLocal;
  472. if ($this->lblIsLocal) $this->lblIsLocal->Text = ($this->objMenuItem->IsLocal) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  473. if ($this->chkIsSsl) $this->chkIsSsl->Checked = $this->objMenuItem->IsSsl;
  474. if ($this->lblIsSsl) $this->lblIsSsl->Text = ($this->objMenuItem->IsSsl) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  475. if ($this->txtSortOrder) $this->txtSortOrder->Text = $this->objMenuItem->SortOrder;
  476. if ($this->lblSortOrder) $this->lblSortOrder->Text = $this->objMenuItem->SortOrder;
  477. if ($this->lstStatus) $this->lstStatus->SelectedValue = $this->objMenuItem->StatusId;
  478. if ($this->lblStatusId) $this->lblStatusId->Text = ($this->objMenuItem->StatusId) ? MenuStatusType::$NameArray[$this->objMenuItem->StatusId] : null;
  479. if ($this->lstType) $this->lstType->SelectedValue = $this->objMenuItem->TypeId;
  480. if ($this->lblTypeId) $this->lblTypeId->Text = ($this->objMenuItem->TypeId) ? MenuItemType::$NameArray[$this->objMenuItem->TypeId] : null;
  481. if ($this->lstPage) {
  482. $this->lstPage->RemoveAllItems();
  483. $this->lstPage->AddItem(QApplication::Translate('- Select One -'), null);
  484. $objPageArray = Page::LoadAll();
  485. if ($objPageArray) foreach ($objPageArray as $objPage) {
  486. $objListItem = new QListItem($objPage->__toString(), $objPage->Id);
  487. if (($this->objMenuItem->Page) && ($this->objMenuItem->Page->Id == $objPage->Id))
  488. $objListItem->Selected = true;
  489. $this->lstPage->AddItem($objListItem);
  490. }
  491. }
  492. if ($this->lblPageId) $this->lblPageId->Text = ($this->objMenuItem->Page) ? $this->objMenuItem->Page->__toString() : null;
  493. if ($this->lstMenus) {
  494. $this->lstMenus->RemoveAllItems();
  495. $objAssociatedArray = $this->objMenuItem->GetMenuArray();
  496. $objMenuArray = Menu::LoadAll();
  497. if ($objMenuArray) foreach ($objMenuArray as $objMenu) {
  498. $objListItem = new QListItem($objMenu->__toString(), $objMenu->Id);
  499. foreach ($objAssociatedArray as $objAssociated) {
  500. if ($objAssociated->Id == $objMenu->Id)
  501. $objListItem->Selected = true;
  502. }
  503. $this->lstMenus->AddItem($objListItem);
  504. }
  505. }
  506. if ($this->lblMenus) {
  507. $objAssociatedArray = $this->objMenuItem->GetMenuArray();
  508. $strItems = array();
  509. foreach ($objAssociatedArray as $objAssociated)
  510. $strItems[] = $objAssociated->__toString();
  511. $this->lblMenus->Text = implode($strGlue, $strItems);
  512. }
  513. }
  514. ///////////////////////////////////////////////
  515. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  516. ///////////////////////////////////////////////
  517. protected function lstMenus_Update() {
  518. if ($this->lstMenus) {
  519. $this->objMenuItem->UnassociateAllMenus();
  520. $objSelectedListItems = $this->lstMenus->SelectedItems;
  521. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  522. $this->objMenuItem->AssociateMenu(Menu::Load($objListItem->Value));
  523. }
  524. }
  525. }
  526. ///////////////////////////////////////////////
  527. // PUBLIC MENUITEM OBJECT MANIPULATORS
  528. ///////////////////////////////////////////////
  529. /**
  530. * This will save this object's MenuItem instance,
  531. * updating only the fields which have had a control created for it.
  532. */
  533. public function SaveMenuItem() {
  534. try {
  535. // Update any fields for controls that have been created
  536. if ($this->txtName) $this->objMenuItem->Name = $this->txtName->Text;
  537. if ($this->txtCssClass) $this->objMenuItem->CssClass = $this->txtCssClass->Text;
  538. if ($this->txtLabel) $this->objMenuItem->Label = $this->txtLabel->Text;
  539. if ($this->txtUri) $this->objMenuItem->Uri = $this->txtUri->Text;
  540. if ($this->chkIsLocal) $this->objMenuItem->IsLocal = $this->chkIsLocal->Checked;
  541. if ($this->chkIsSsl) $this->objMenuItem->IsSsl = $this->chkIsSsl->Checked;
  542. if ($this->txtSortOrder) $this->objMenuItem->SortOrder = $this->txtSortOrder->Text;
  543. if ($this->lstStatus) $this->objMenuItem->StatusId = $this->lstStatus->SelectedValue;
  544. if ($this->lstType) $this->objMenuItem->TypeId = $this->lstType->SelectedValue;
  545. if ($this->lstPage) $this->objMenuItem->PageId = $this->lstPage->SelectedValue;
  546. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  547. // Save the MenuItem object
  548. $this->objMenuItem->Save();
  549. // Finally, update any ManyToManyReferences (if any)
  550. $this->lstMenus_Update();
  551. } catch (QCallerException $objExc) {
  552. $objExc->IncrementOffset();
  553. throw $objExc;
  554. }
  555. }
  556. /**
  557. * This will DELETE this object's MenuItem instance from the database.
  558. * It will also unassociate itself from any ManyToManyReferences.
  559. */
  560. public function DeleteMenuItem() {
  561. $this->objMenuItem->UnassociateAllMenus();
  562. $this->objMenuItem->Delete();
  563. }
  564. ///////////////////////////////////////////////
  565. // PUBLIC GETTERS and SETTERS
  566. ///////////////////////////////////////////////
  567. /**
  568. * Override method to perform a property "Get"
  569. * This will get the value of $strName
  570. *
  571. * @param string $strName Name of the property to get
  572. * @return mixed
  573. */
  574. public function __get($strName) {
  575. switch ($strName) {
  576. // General MetaControlVariables
  577. case 'MenuItem': return $this->objMenuItem;
  578. case 'TitleVerb': return $this->strTitleVerb;
  579. case 'EditMode': return $this->blnEditMode;
  580. // Controls that point to MenuItem fields -- will be created dynamically if not yet created
  581. case 'IdControl':
  582. if (!$this->lblId) return $this->lblId_Create();
  583. return $this->lblId;
  584. case 'IdLabel':
  585. if (!$this->lblId) return $this->lblId_Create();
  586. return $this->lblId;
  587. case 'NameControl':
  588. if (!$this->txtName) return $this->txtName_Create();
  589. return $this->txtName;
  590. case 'NameLabel':
  591. if (!$this->lblName) return $this->lblName_Create();
  592. return $this->lblName;
  593. case 'CssClassControl':
  594. if (!$this->txtCssClass) return $this->txtCssClass_Create();
  595. return $this->txtCssClass;
  596. case 'CssClassLabel':
  597. if (!$this->lblCssClass) return $this->lblCssClass_Create();
  598. return $this->lblCssClass;
  599. case 'LabelControl':
  600. if (!$this->txtLabel) return $this->txtLabel_Create();
  601. return $this->txtLabel;
  602. case 'LabelLabel':
  603. if (!$this->lblLabel) return $this->lblLabel_Create();
  604. return $this->lblLabel;
  605. case 'UriControl':
  606. if (!$this->txtUri) return $this->txtUri_Create();
  607. return $this->txtUri;
  608. case 'UriLabel':
  609. if (!$this->lblUri) return $this->lblUri_Create();
  610. return $this->lblUri;
  611. case 'IsLocalControl':
  612. if (!$this->chkIsLocal) return $this->chkIsLocal_Create();
  613. return $this->chkIsLocal;
  614. case 'IsLocalLabel':
  615. if (!$this->lblIsLocal) return $this->lblIsLocal_Create();
  616. return $this->lblIsLocal;
  617. case 'IsSslControl':
  618. if (!$this->chkIsSsl) return $this->chkIsSsl_Create();
  619. return $this->chkIsSsl;
  620. case 'IsSslLabel':
  621. if (!$this->lblIsSsl) return $this->lblIsSsl_Create();
  622. return $this->lblIsSsl;
  623. case 'SortOrderControl':
  624. if (!$this->txtSortOrder) return $this->txtSortOrder_Create();
  625. return $this->txtSortOrder;
  626. case 'SortOrderLabel':
  627. if (!$this->lblSortOrder) return $this->lblSortOrder_Create();
  628. return $this->lblSortOrder;
  629. case 'StatusIdControl':
  630. if (!$this->lstStatus) return $this->lstStatus_Create();
  631. return $this->lstStatus;
  632. case 'StatusIdLabel':
  633. if (!$this->lblStatusId) return $this->lblStatusId_Create();
  634. return $this->lblStatusId;
  635. case 'TypeIdControl':
  636. if (!$this->lstType) return $this->lstType_Create();
  637. return $this->lstType;
  638. case 'TypeIdLabel':
  639. if (!$this->lblTypeId) return $this->lblTypeId_Create();
  640. return $this->lblTypeId;
  641. case 'PageIdControl':
  642. if (!$this->lstPage) return $this->lstPage_Create();
  643. return $this->lstPage;
  644. case 'PageIdLabel':
  645. if (!$this->lblPageId) return $this->lblPageId_Create();
  646. return $this->lblPageId;
  647. case 'MenuControl':
  648. if (!$this->lstMenus) return $this->lstMenus_Create();
  649. return $this->lstMenus;
  650. case 'MenuLabel':
  651. if (!$this->lblMenus) return $this->lblMenus_Create();
  652. return $this->lblMenus;
  653. default:
  654. try {
  655. return parent::__get($strName);
  656. } catch (QCallerException $objExc) {
  657. $objExc->IncrementOffset();
  658. throw $objExc;
  659. }
  660. }
  661. }
  662. /**
  663. * Override method to perform a property "Set"
  664. * This will set the property $strName to be $mixValue
  665. *
  666. * @param string $strName Name of the property to set
  667. * @param string $mixValue New value of the property
  668. * @return mixed
  669. */
  670. public function __set($strName, $mixValue) {
  671. try {
  672. switch ($strName) {
  673. // Controls that point to MenuItem fields
  674. case 'IdControl':
  675. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  676. case 'NameControl':
  677. return ($this->txtName = QType::Cast($mixValue, 'QControl'));
  678. case 'CssClassControl':
  679. return ($this->txtCssClass = QType::Cast($mixValue, 'QControl'));
  680. case 'LabelControl':
  681. return ($this->txtLabel = QType::Cast($mixValue, 'QControl'));
  682. case 'UriControl':
  683. return ($this->txtUri = QType::Cast($mixValue, 'QControl'));
  684. case 'IsLocalControl':
  685. return ($this->chkIsLocal = QType::Cast($mixValue, 'QControl'));
  686. case 'IsSslControl':
  687. return ($this->chkIsSsl = QType::Cast($mixValue, 'QControl'));
  688. case 'SortOrderControl':
  689. return ($this->txtSortOrder = QType::Cast($mixValue, 'QControl'));
  690. case 'StatusIdControl':
  691. return ($this->lstStatus = QType::Cast($mixValue, 'QControl'));
  692. case 'TypeIdControl':
  693. return ($this->lstType = QType::Cast($mixValue, 'QControl'));
  694. case 'PageIdControl':
  695. return ($this->lstPage = QType::Cast($mixValue, 'QControl'));
  696. case 'MenuControl':
  697. return ($this->lstMenus = QType::Cast($mixValue, 'QControl'));
  698. default:
  699. return parent::__set($strName, $mixValue);
  700. }
  701. } catch (QCallerException $objExc) {
  702. $objExc->IncrementOffset();
  703. throw $objExc;
  704. }
  705. }
  706. }
  707. ?>