Exemplo n.º 1
0
 /**
  * Reset the cached container object if container changes
  *
  * @param KModelContextInterface $context
  */
 protected function _afterReset(KModelContextInterface $context)
 {
     $modified = (array) KObjectConfig::unbox($context->modified);
     if (in_array('container', $modified)) {
         unset($this->_container);
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param KObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Session write and close handlers are called after destructing objects since PHP 5.0.5.
     if (version_compare(phpversion(), '5.4.0', '>=')) {
         session_register_shutdown();
     } else {
         register_shutdown_function('session_write_close');
     }
     //Only configure the session if it's not active yet
     if (!$this->isActive()) {
         //Set the session options
         $this->setOptions($config->options);
         //Set the session name
         if (!empty($config->name)) {
             $this->setName($config->name);
         }
         //Set the session identifier
         if (!empty($config->id)) {
             $this->setId($config->id);
         }
         //Set the session handler
         $this->setHandler($config->handler, KObjectConfig::unbox($config));
     }
     //Set the session namespace
     $this->setNamespace($config->namespace);
     //Set lifetime time
     $this->getContainer('metadata')->setLifetime($config->lifetime);
 }
Exemplo n.º 3
0
 /**
  * Constructor.
  *
  * @param KObjectConfig $config Configuration options.
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     $this->_title_column = KObjectConfig::unbox($config->title_column);
     $this->_controller = $config->controller;
     $this->setActions(KObjectConfig::unbox($config->actions));
 }
Exemplo n.º 4
0
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     $this->setThumbnailSize(KObjectConfig::unbox($config->thumbnail_size));
     $this->_container = $config->container;
     $this->_folder = $config->folder;
 }
Exemplo n.º 5
0
 /**
  * Reset the cached container object if container changes
  *
  * @param KModelContextInterface $context
  */
 protected function _afterReset(KModelContextInterface $context)
 {
     $modified = (array) KObjectConfig::unbox($context->modified);
     if (in_array('container', $modified)) {
         self::$_container = null;
     }
 }
Exemplo n.º 6
0
 protected function _saveGroups(KDatabaseRowInterface $entity)
 {
     $table = $this->getObject('com://admin/docman.database.table.levels');
     $row = $table->select(array('entity' => $entity->uuid), KDatabase::FETCH_ROW);
     $groups = KObjectConfig::unbox($entity->groups);
     $access = null;
     if (is_array($groups) && count($groups)) {
         sort($groups);
         $row->groups = implode(',', array_map('intval', $groups));
         $row->entity = $entity->uuid;
         if ($row->save()) {
             $access = -1 * $row->id;
         }
     } elseif ($entity->inherit || $groups) {
         if (!$row->isNew()) {
             $row->delete();
         }
         $access = $groups ?: self::INHERIT;
     }
     if ($access !== null) {
         if ($entity->getIdentifier()->name === 'document') {
             $entity->access = $access;
         } else {
             $entity->access_raw = $access;
         }
     }
 }
Exemplo n.º 7
0
    public function __construct(KObjectConfig $config)
    {
        parent::__construct($config);

        $this->_redirect_schemes = KObjectConfig::unbox($config->redirect_schemes);
        $this->_redirect_unknown = $config->redirect_unknown;
    }
Exemplo n.º 8
0
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     if (isset($config->adapters)) {
         $this->_adapters = KObjectConfig::unbox($config->adapters);
     }
 }
Exemplo n.º 9
0
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     if ($config->fields) {
         $this->_fields = KObjectConfig::unbox($config->fields);
     }
 }
Exemplo n.º 10
0
 /**
  * Object constructor
  *
  * @param   KObjectConfig $config Configuration options
  * @throws InvalidArgumentException
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     if (is_null($config->command_chain)) {
         throw new InvalidArgumentException('command_chain [KCommandChainInterface] config option is required');
     }
     //Create a command chain object
     $this->__command_chain = $config->command_chain;
     //Add the event subscribers
     $handlers = (array) KObjectConfig::unbox($config->command_handlers);
     foreach ($handlers as $key => $value) {
         if (is_numeric($key)) {
             $this->addCommandHandler($value);
         } else {
             $this->addCommandHandler($key, $value);
         }
     }
     //Add the command callbacks
     foreach ($this->getMixer()->getMethods() as $method) {
         $match = array();
         if (preg_match('/_(after|before)([A-Z]\\S*)/', $method, $match)) {
             $this->addCommandCallback($match[1] . '.' . strtolower($match[2]), $method);
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Constructor.
  *
  * @param KObjectConfig $config	An optional ObjectConfig object with configuration options.
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Set the supported methods
     $this->_methods = KObjectConfig::unbox($config->methods);
     //Load the dispatcher translations
     $this->addCommandCallback('before.dispatch', '_loadTranslations');
 }
Exemplo n.º 12
0
 /**
  * Constructor
  *
  * @param KObjectConfig $config  An optional KObjectConfig object with configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     $headers = KObjectConfig::unbox($config->headers);
     foreach ($headers as $key => $values) {
         $this->set($key, $values);
     }
 }
Exemplo n.º 13
0
 protected function _initialize(KObjectConfig $config)
 {
     $size = KObjectConfig::unbox($config->size);
     if (empty($size)) {
         $config->size = array('x' => 200, 'y' => 150);
     }
     parent::_initialize($config);
 }
Exemplo n.º 14
0
 /**
  * Constructor.
  *
  * @param   KObjectConfig $config Configuration options
  */
 public function __construct(KObjectConfig $config = null)
 {
     parent::__construct($config);
     $this->_title = $config->title;
     $this->_class = $config->class;
     $this->_styles = KObjectConfig::unbox($config->styles);
     $this->_attribs = KObjectConfig::unbox($config->attribs);
 }
Exemplo n.º 15
0
 /**
  * Creates a tab panel with title and starts that panel
  *
  * @param   array|KObjectConfig $config An optional array with configuration options
  * @return  string Html
  */
 public function startPanel($config = array())
 {
     $translator = $this->getObject('translator');
     $config = new KObjectConfigJson($config);
     $config->append(array('title' => $translator->translate('Slide'), 'id' => '', 'translate' => true));
     $title = $config->translate ? $translator->translate($config->title) : $config->title;
     return JHtml::_('sliders.panel', $title, KObjectConfig::unbox($config->attribs));
 }
Exemplo n.º 16
0
 public function validate($entity)
 {
     $allowed = KObjectConfig::unbox($entity->getContainer()->getParameters()->allowed_extensions);
     $value = $entity->extension;
     if (is_array($allowed) && (empty($value) || !in_array(strtolower($value), $allowed))) {
         return $this->_error($this->getObject('translator')->translate('Invalid file extension'));
     }
 }
Exemplo n.º 17
0
 /**
  * Constructor.
  *
  * @param   KObjectConfig $config Configuration options
  */
 public function __construct(KObjectConfig $config = null)
 {
     parent::__construct($config);
     $this->_columns = (array) KObjectConfig::unbox($config->columns);
     $this->_separator = $config->separator;
     $this->_updatable = $config->updatable;
     $this->_length = $config->length;
     $this->_unique = $config->unique;
 }
Exemplo n.º 18
0
 /**
  * Returns the groups the user is part of
  *
  * @return array An array of group id's
  */
 public function getGroups()
 {
     $data = $this->getData();
     $groups = KObjectConfig::unbox($data->groups);
     if (empty($groups)) {
         $this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
     }
     return parent::getGroups();
 }
Exemplo n.º 19
0
 /**
  * Recalculate offset
  *
  * @param   KModelContextInterface $context A model context object
  * @return    void
  */
 protected function _afterReset(KModelContextInterface $context)
 {
     $modified = (array) KObjectConfig::unbox($context->modified);
     if (in_array('limit', $modified)) {
         $limit = $context->state->limit;
         if ($limit) {
             $context->state->offset = floor($context->state->offset / $limit) * $limit;
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Sets the folder name as created by the OS (encoding) in the filesystem
  *
  * @param KDatabaseContextInterface $context
  */
 protected function _afterSave(KDatabaseContextInterface $context)
 {
     if ($context->siblings && count($context->siblings)) {
         $siblings = KObjectConfig::unbox($context->siblings);
         $name = array_diff(scandir(dirname($context->getSubject()->fullpath)), array_pop($siblings));
         if (count($name) == 1) {
             $this->name = current($name);
         }
         $context->siblings = $siblings;
     }
 }
Exemplo n.º 21
0
 /**
  * Creates a tab panel with title and starts that panel
  *
  * @param   array   $config An optional array with configuration options
  * @return  string  Html
  */
 public function startPanel($config = array())
 {
     $config = new KObjectConfigJson($config);
     $config->append(array('title' => '', 'class' => '', 'translate' => true));
     $title = $config->translate ? $this->getObject('translator')->translate($config->title) : $config->title;
     $class = KObjectConfig::unbox($config->class);
     if (is_array($class)) {
         $class = implode(' ', $class);
     }
     return JHtml::_('tabs.panel', $title, $class);
 }
Exemplo n.º 22
0
 /**
  * Generates an HTML editor
  *
  * @param   array   $config An optional array with configuration options
  * @return  string  Html
  */
 public function display($config = array())
 {
     $config = new KObjectConfigJson($config);
     $config->append(array('editor' => null, 'name' => 'description', 'value' => '', 'width' => '100%', 'height' => '500', 'cols' => '75', 'rows' => '20', 'buttons' => true, 'options' => array()));
     $editor = JFactory::getEditor($config->editor);
     $options = KObjectConfig::unbox($config->options);
     $result = $editor->display($config->name, $config->value, $config->width, $config->height, $config->cols, $config->rows, KObjectConfig::unbox($config->buttons), $config->name, null, null, $options);
     // Some editors like CKEditor return inline JS.
     $result = str_replace('<script', '<script data-inline', $result);
     return $result;
 }
Exemplo n.º 23
0
 protected function _getPageConditions($pages)
 {
     $pages = (array) KObjectConfig::unbox($pages);
     $document_pages = array_intersect($pages, array_keys($this->_getDocumentPages()->toArray()));
     // Return an empty list of categories if the model is filtered against single document pages only.
     if (count($document_pages) === count($pages)) {
         $conditions = array(array('categories', array(-1)));
     } else {
         $conditions = parent::_getPageConditions($pages);
     }
     return $conditions;
 }
Exemplo n.º 24
0
 /**
  * Constructor
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An array that holds the plugin configuration
  */
 public function __construct(&$subject, $config)
 {
     if ($this->bootFramework()) {
         $configuration = new KObjectConfig();
         $this->_initialize($configuration);
         foreach ($configuration as $key => $value) {
             $this->{$key} = KObjectConfig::unbox($value);
         }
     }
     parent::__construct($subject, $config);
     $this->loadLanguage();
 }
Exemplo n.º 25
0
 /**
  * Constructor
  *
  * @param   KObjectConfig $config Configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     $this->_version = $config->version;
     $this->_text_fields = KObjectConfig::unbox($config->text_fields);
     $this->_fields = KObjectConfig::unbox($config->fields);
     $query = $this->getUrl()->getQuery(true);
     if (!empty($query['fields'])) {
         $fields = explode(',', rawurldecode($query['fields']));
         $this->_fields = array_merge($this->_fields, $fields);
     }
 }
Exemplo n.º 26
0
 /**
  * Constructor
  *
  * @param KObjectConfig $config An optional ObjectConfig object with configuration options.
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Add the behaviors in FIFO order
     $behaviors = (array) KObjectConfig::unbox($config->behaviors);
     foreach ($behaviors as $key => $value) {
         if (is_numeric($key)) {
             $this->addBehavior($value);
         } else {
             $this->addBehavior($key, $value);
         }
     }
 }
Exemplo n.º 27
0
 /**
  * Constructor
  *
  * @param KObjectConfig $config  An optional ObjectConfig object with configuration options.
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Add the toolbars
     $toolbars = (array) KObjectConfig::unbox($config->toolbars);
     foreach ($toolbars as $key => $value) {
         if (is_numeric($key)) {
             $this->addToolbar($value);
         } else {
             $this->addToolbar($key, $value);
         }
     }
 }
Exemplo n.º 28
0
 /**
  * Constructor.
  *
  * @param KObjectConfig $config Configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Register the engines
     $engines = KObjectConfig::unbox($config->engines);
     foreach ($engines as $key => $value) {
         if (is_numeric($key)) {
             $this->registerEngine($value);
         } else {
             $this->registerEngine($key, $value);
         }
     }
 }
Exemplo n.º 29
0
 /**
  * Constructor
  *
  * Prevent creating instances of this class by making the constructor private
  *
  * @param KObjectConfig $config   An optional ObjectConfig object with configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Reset the data
     $this->_data = array();
     //Reset the content
     $this->_source = null;
     //Register the functions
     $functions = (array) KObjectConfig::unbox($config->functions);
     foreach ($functions as $name => $callback) {
         $this->registerFunction($name, $callback);
     }
 }
Exemplo n.º 30
0
 /**
  * Constructor.
  *
  * @param KObjectConfig $config Configuration options
  */
 public function __construct(KObjectConfig $config)
 {
     parent::__construct($config);
     //Register the locators
     $locators = KObjectConfig::unbox($config->locators);
     foreach ($locators as $key => $value) {
         if (is_numeric($key)) {
             $this->registerLocator($value);
         } else {
             $this->registerLocator($key, $value);
         }
     }
 }