Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_custom_form.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/page/page.inc';
19 
31 class Page_Custom_Form extends Page
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
58  function _createAdditional(&$link)
59  {
60  if (!parent::_createAdditional($link)) return FALSE;
61 
62  // create a new form_email (form with emailing abilities)
63  $GLOBALS['SQ_SYSTEM']->am->includeAsset('form_email');
64  $form = new Form_Email();
65  $copy_link = Array('asset' => &$this, 'link_type' => SQ_LINK_TYPE_2, 'is_dependant' => 1, 'is_exclusive' => 1);
66 
67  $form->setAttrValue('name', translate('cms_form_contents'));
68  return $form->create($copy_link);
69 
70  }//end _createAdditional()
71 
72 
80  function _getAllowedLinks()
81  {
82  $page_links = parent::_getAllowedLinks();
83  $page_links[SQ_LINK_TYPE_2]['form_email'] = Array('card' => '1', 'exclusive' => TRUE);
84 
85  return $page_links;
86 
87  }//end _getAllowedLinks()
88 
89 
101  function printFrontend()
102  {
103  $form = $this->getForm();
104 
105  if (is_null($form) && !array_get_index($this->_tmp, '__creating__', FALSE)) {
106  trigger_localised_error('CMS0023', E_USER_ERROR, $this->name, $this->id);
107  return FALSE;
108  }
109 
110  return parent::printFrontend();
111 
112  }//end printFrontend()
113 
114 
122  function printBody()
123  {
124  // start performance mode timer
125  $GLOBALS['SQ_SYSTEM']->pm->startTimer($this);
126 
127  $form = $this->getForm();
128 
129  // If we are still being created, we will not have the "form" asset yet (bug #5979)
130  if (!array_get_index($this->_tmp, '__creating__', FALSE)) {
131  if (is_null($form)) {
132  trigger_localised_error('CMS0023', E_USER_ERROR, $this->name, $this->id);
133  return FALSE;
134  }
135  $form->printBody();
136  }
137 
138  // stop performance mode timer
139  $GLOBALS['SQ_SYSTEM']->pm->stopTimer($this);
140  return TRUE;
141 
142  }//end printBody()
143 
144 
151  function &getForm()
152  {
153  $form = NULL;
154 
155  $form_link = $GLOBALS['SQ_SYSTEM']->am->getLink($this->id, SQ_LINK_TYPE_2, 'form', FALSE, '', 'major');
156  if (!empty($form_link)) {
157  $form = $GLOBALS['SQ_SYSTEM']->am->getAsset($form_link['minorid'], $form_link['minor_type_code']);
158  }
159 
160  return $form;
161 
162  }//end getForm()
163 
164 
165 }//end class
166 ?>