Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function initialize()
 {
     $key = $this->getProperty('key');
     $context_key = $this->getProperty('context_key', $this->getProperty('fk'));
     if (!$key || !$context_key) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     $this->context = $this->modx->getContext($context_key);
     if (!$this->context) {
         return $this->modx->lexicon($this->objectType . '_err_nf');
     }
     if (!$this->context->checkPolicy('save')) {
         return $this->modx->lexicon('permission_denied');
     }
     $this->object = $this->modx->getObject($this->classKey, array('key' => $key, 'context_key' => $context_key));
     if (!$this->object) {
         return $this->modx->lexicon($this->objectType . '_err_nf');
     }
     return true;
 }
Ejemplo n.º 2
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;
 }