コード例 #1
0
 /**
  * Custom logic code here for setting placeholders, etc
  * @param array $scriptProperties
  * @return mixed
  */
 public function process(array $scriptProperties = array())
 {
     $placeholders = array();
     /* grab chunk */
     if (empty($scriptProperties['id']) || strlen($scriptProperties['id']) !== strlen((int) $scriptProperties['id'])) {
         return $this->failure($this->modx->lexicon('chunk_err_ns'));
     }
     $this->chunk = $this->modx->getObject('modChunk', array('id' => $scriptProperties['id']));
     if (empty($this->chunk)) {
         return $this->failure($this->modx->lexicon('chunk_err_nfs', array('id' => $scriptProperties['id'])));
     }
     if (!$this->chunk->checkPolicy('view')) {
         return $this->failure($this->modx->lexicon('access_denied'));
     }
     if ($this->chunk->get('locked') && !$this->modx->hasPermission('edit_locked')) {
         return $this->failure($this->modx->lexicon('chunk_err_locked'));
     }
     /* grab category for chunk, assign to parser */
     $placeholders['chunk'] = $this->chunk;
     /* invoke OnChunkFormRender event */
     $placeholders['onChunkFormRender'] = $this->fireRenderEvent();
     /* get properties */
     $properties = $this->chunk->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->chunkArray = $this->chunk->toArray();
     $this->chunkArray['properties'] = $data;
     $this->chunkArray['snippet'] = $this->chunk->getContent();
     $this->prepareElement();
     /* invoke OnRichTextEditorInit event */
     $placeholders['onRTEInit'] = $this->loadRte();
     /* check unlock default element properties permission */
     $placeholders['unlock_element_properties'] = $this->modx->hasPermission('unlock_element_properties') ? 1 : 0;
     return $placeholders;
 }
コード例 #2
0
 /**
  * @return void
  */
 public function testGetContent()
 {
     $this->assertEquals($this->chunk->get('snippet'), $this->chunk->getContent());
 }