コード例 #1
0
ファイル: update.class.php プロジェクト: e-gob/apps.gob.cl
 /**
  * Custom logic code here for setting placeholders, etc
  * @param array $scriptProperties
  * @return mixed
  */
 public function process(array $scriptProperties = array())
 {
     $placeholders = array();
     /* load template */
     if (empty($scriptProperties['id'])) {
         return $this->failure($this->modx->lexicon('template_err_ns'));
     }
     $this->template = $this->modx->getObject('modTemplate', $scriptProperties['id']);
     if ($this->template == null) {
         return $this->failure($this->modx->lexicon('template_err_nf'));
     }
     if (!$this->template->checkPolicy('view')) {
         return $this->failure($this->modx->lexicon('access_denied'));
     }
     /* get properties */
     $properties = $this->template->get('properties');
     if (!is_array($properties)) {
         $properties = array();
     }
     $data = array();
     foreach ($properties as $property) {
         $data[] = array($property['name'], $property['desc'], !empty($property['type']) ? $property['type'] : 'textfield', !empty($property['options']) ? $property['options'] : array(), $property['value'], !empty($property['lexicon']) ? $property['lexicon'] : '', false, $property['desc_trans'], !empty($property['area']) ? $property['area'] : '', !empty($property['area_trans']) ? $property['area_trans'] : '');
     }
     $this->templateArray = $this->template->toArray();
     $this->templateArray['properties'] = $data;
     $this->templateArray['content'] = $this->template->getContent();
     $this->prepareElement();
     /* load template into parser */
     $placeholders['template'] = $this->template;
     /* invoke OnTempFormRender event */
     $placeholders['onTempFormRender'] = $this->fireRenderEvent();
     return $placeholders;
 }
コード例 #2
0
 /**
  * Prepare object for iteration
  *
  * @param modTemplate $template
  * @return array
  */
 public function prepareRow(modTemplate $template)
 {
     $templateArray = $template->toArray();
     $templateArray['access'] = $template->get('tmplvarid');
     $templateArray['access'] = empty($templateArray['access']) ? false : true;
     unset($templateArray['content']);
     return $templateArray;
 }