Пример #1
0
 protected function _getList()
 {
     $data = parent::_getList();
     $convert = array();
     $convert['items'] = array_map(array($this, 'convert'), $data['items']);
     return array_merge($data, $convert);
 }
Пример #2
0
 protected function _getItem()
 {
     $data = parent::_getItem();
     if ($this->getModel()->getItem()->days instanceof KDatabaseRowsetAbstract) {
         $data['item'] = array_merge($data['item'], array('days' => array_values($this->getModel()->getItem()->days->toArray())));
     }
     return $data;
 }
Пример #3
0
 /**
  * Get the list data
  *
  * @return array The array with data to be encoded to json
  */
 protected function _getList()
 {
     if ($this->getLayout() == 'stream') {
         $list = $this->_getStream();
     } else {
         $list = parent::_getList();
     }
     return $list;
 }
Пример #4
0
 protected function _getItem()
 {
     $row = $this->getModel()->getItem();
     $output = parent::_getItem();
     $status = $row->getStatus() !== KDatabase::STATUS_FAILED;
     $output['status'] = $status;
     if ($status === false) {
         $output['error'] = $row->getStatusMessage();
     }
     return $output;
 }
Пример #5
0
 public function display()
 {
     $model = $this->getModel();
     if (KInflector::isPlural($this->getName())) {
         $data = array('settings' => $model->getList()->toArray());
     } else {
         $data = $model->getItem()->toArray();
     }
     $this->output = $data;
     return parent::display();
 }
Пример #6
0
 /**
  * Renders and echo's the views output wrapping it in a js callback if present
  *
  * @return string JSON data
  */
 public function display()
 {
     if (!KRequest::has('get.callback')) {
         return parent::display();
     }
     $callback = KRequest::get('get.callback', 'cmd');
     $json = $callback . '(';
     $json .= parent::display();
     //Set the correct mime type
     $this->_document->setMimeEncoding('application/javascript');
     $json .= ');';
     return $json;
 }
Пример #7
0
 protected function _renderData()
 {
     $output = parent::_renderData();
     if (!$this->isCollection()) {
         $entity = $this->getModel()->fetch();
         $status = $entity->getStatus() !== KDatabase::STATUS_FAILED;
         $output['status'] = $status;
         if ($status === false) {
             $output['error'] = $entity->getStatusMessage();
         }
     }
     return $output;
 }
Пример #8
0
 protected function _actionRender(KViewContext $context)
 {
     if (ini_get('display_errors')) {
         $this->message = $this->exception . " with message '" . $this->message . "' in " . $this->file . ":" . $this->line;
     }
     $properties = array('message' => $this->message, 'code' => $this->code);
     if (ini_get('display_errors')) {
         $properties['data'] = array('file' => $this->file, 'line' => $this->line, 'function' => $this->function, 'class' => $this->class, 'args' => $this->args, 'info' => $this->info);
     }
     $content = json_encode(array('version' => '1.0', 'errors' => array($properties)));
     $this->setContent($content);
     return parent::_actionRender($context);
 }
Пример #9
0
    public function display()
    {
    	$model = $this->getModel();

        if(KInflector::isPlural($this->getName())) {
            $data = $this->_getList($model);
        } else {
            $data = $this->_getItem($model);
        }

        $this->output = $data;

        return parent::display();
    }
Пример #10
0
 /**
  * Initializes the options for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KObjectConfig $config Configuration options.
  */
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('renderer' => 'activity'));
     parent::_initialize($config);
 }
Пример #11
0
    protected function _getEntityRoute(KModelEntityInterface $entity)
    {
        if ($entity instanceof ComDocmanModelEntityDocument)
        {
            $router = $this->getObject('com://admin/docman.template.helper.route');
            $router->setRouter(array($this, 'getRoute'));

            return $router->document(array('entity' => $entity, 'format' => 'json'));
        }

        return parent::_getEntityRoute($entity);
    }