Example #1
0
 /**
  * Custom logic code here for setting placeholders, etc
  * @param array $scriptProperties
  * @return mixed
  */
 public function process(array $scriptProperties = array())
 {
     if (empty($this->context)) {
         return $this->failure(sprintf($this->modx->lexicon('context_with_key_not_found'), $this->scriptProperties['key']));
     }
     if (!$this->context->checkPolicy(array('view' => true, 'save' => true))) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     /* prepare context data for display */
     if (!$this->context->prepare()) {
         return $this->failure($this->modx->lexicon('context_err_load_data'), $this->context->toArray());
     }
     /* invoke OnContextFormPrerender event */
     $this->setPlaceholder('OnContextFormPrerender', $this->onPreRender());
     /* invoke OnContextFormRender event */
     $this->setPlaceholder('OnContextFormRender', $this->onRender());
     /*  assign context to smarty and display */
     $this->setPlaceholder('context', $this->context);
     $this->setPlaceholder('_ctx', $this->context->get('key'));
     return null;
 }
Example #2
0
 /**
  * @param modContext $context
  *
  * @return array
  */
 protected function _prepareContextRow(modContext $context)
 {
     $row = $context->toArray('', false, true);
     $row['type'] = 'context';
     if (empty($row['name'])) {
         $row['name'] = $row['key'];
     }
     return $row;
 }