/**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config  An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     //Clone the identifier
     $identifier = clone $this->getIdentifier();
     $config->append(array('data' => array(), 'layout' => '', 'template' => $this->getName(), 'template_filters' => array('shorttag', 'function', 'url', 'decorator'), 'auto_assign' => true));
     parent::_initialize($config);
 }
Example #2
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  ObjectConfig $config An optional ObjectConfig object with configuration options
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     if (empty($config->resolvers)) {
         $config->append(array('resolvers' => array('extension')));
     }
     parent::_initialize($config);
 }
Example #3
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     //Create permission identifier
     $permission = clone $this->getIdentifier();
     $permission->path = array('controller', 'permission');
     $config->append(array('view' => $this->getIdentifier()->name, 'behaviors' => array($permission)));
     parent::_initialize($config);
 }
Example #4
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  ObjectConfig $config An optional ObjectConfig object with configuration options
  */
 protected function _initialize(ObjectConfig $config)
 {
     $self = $this;
     $config->append(array('autoescape' => true, 'strict_variables' => false, 'optimizations' => -1, 'functions' => array('import' => function ($url, $data) use($self) {
         return $self->renderPartial($url, $data);
     })));
     parent::_initialize($config);
 }
Example #5
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config 	An optional ObjectConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(ObjectConfig $config)
 {
     //Create permission identifier
     $permission = clone $this->getIdentifier();
     $permission->path = array('dispatcher', 'permission');
     $config->append(array('controller' => $this->getIdentifier()->package, 'request' => 'lib:dispatcher.request', 'response' => 'lib:dispatcher.response', 'user' => 'lib:dispatcher.user', 'behaviors' => array($permission)));
     parent::_initialize($config);
 }
Example #6
0
 /**
  * Generates an HTML image preview listbox
  *
  * $config options:
  *
  * name			string		column name of helper
  * directory	string		image directory (relative to docroot)
  * width		int			image width
  * height		int			image height
  * border		int			border width
  * style		string		style string
  * selected		string		currently selected vallue
  *
  * @param 	array 	$config An optional array with configuration options
  * @return  string  Html
  */
 public function preview($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('name' => 'image_name', 'directory' => JPATH_IMAGES . '/stories', 'width' => 80, 'height' => 80, 'border' => 2, 'style' => 'margin: 10px 0;'))->append(array('selected' => $config->{$config->name}));
     $image = $this->getObject('request')->getBasePath() . str_replace(JPATH_ROOT, '', $config->directory) . '/' . $config->selected;
     $path = $config->selected ? $image : 'media://images/blank.png';
     $html = '<img ' . $this->_buildAttributes(array('src' => $path, 'id' => $config->name . '-preview', 'class' => 'preview', 'width' => $config->width, 'height' => $config->height, 'border' => $config->border, 'alt' => \JText::_('Preview'), 'style' => $config->style)) . ' />';
     return $html;
 }
Example #7
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config 	An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $toolbars = array();
     if ($config->dispatched && $config->user->isAuthentic()) {
         $toolbars[] = $this->getIdentifier()->name;
     }
     $config->append(array('toolbars' => $toolbars, 'model' => $this->getIdentifier()->name));
     parent::_initialize($config);
 }
Example #8
0
 /**
  * Returns human readable date.
  *
  * @param  array  $config An optional array with configuration options.
  * @return string Formatted date.
  */
 public function humanize($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => \JText::_('Never'), 'smallest_period' => 'second'));
     $result = $config->default;
     if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
         $periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year');
         $lengths = array(60, 60, 24, 7, 4.35, 12, 10);
         $now = new \DateTime();
         try {
             $date = new Date(array('date' => $config->date, 'timezone' => 'UTC'));
             $date->setTimezone(new \DateTimeZone($config->timezone));
             if ($now != $date) {
                 // TODO: Use DateTime::getTimeStamp().
                 if ($now > $date) {
                     $difference = $now->format('U') - $date->format('U');
                     $tense = 'ago';
                 } else {
                     $difference = $date->format('U') - $now->format('U');
                     $tense = 'from now';
                 }
                 for ($i = 0; $difference >= $lengths[$i] && $i < 6; $i++) {
                     $difference /= $lengths[$i];
                 }
                 $difference = round($difference);
                 $period_index = array_search($config->smallest_period, $periods);
                 $omitted_periods = $periods;
                 array_splice($omitted_periods, $period_index);
                 if (in_array($periods[$i], $omitted_periods)) {
                     $difference = 1;
                     $i = $period_index;
                 }
                 if ($periods[$i] == 'day' && ($difference == 1 || $difference == 2)) {
                     if ($difference == 1) {
                         $result = \JText::_('Today');
                     } else {
                         $result = $tense == 'ago' ? \JText::_('Yesterday') : \JText::_('Tomorrow');
                     }
                 } else {
                     if ($difference != 1) {
                         $periods[$i] .= 's';
                     }
                     $result = sprintf(\JText::_('%d ' . $periods[$i] . ' ' . $tense), $difference);
                 }
             } else {
                 $result = \JText::_('Now');
             }
         } catch (\Exception $e) {
         }
     }
     return $result;
 }
Example #9
0
 /**
  * Generates a select option list
  *
  * @param   array   $config An optional array with configuration options
  * @return  array   An array of objects containing the option attributes
  */
 public function options($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('entity' => array(), 'name' => 'id', 'value' => 'id', 'label' => 'id', 'disabled' => null, 'attribs' => array()));
     $options = array();
     foreach ($config->entity as $entity) {
         $option = array('id' => isset($entity->{$config->name}) ? $entity->{$config->name} : null, 'name' => $config->name, 'disabled' => $config->disabled, 'attribs' => ObjectConfig::unbox($config->attribs), 'value' => $entity->{$config->value}, 'label' => $entity->{$config->label});
         if ($config->entity instanceof \RecursiveIteratorIterator) {
             $option['level'] = $config->entity->getDepth() + 1;
         }
         $options[] = $this->option($option);
     }
     return $options;
 }
Example #10
0
 /**
  * Returns human readable date.
  *
  * @param  array $config An optional array with configuration options.
  * @return string  Formatted date.
  */
 public function humanize($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => $this->getObject('translator')->translate('Never'), 'period' => 'second'));
     $result = $config->default;
     if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
         try {
             $date = $this->getObject('date', array('date' => $config->date, 'timezone' => 'UTC'));
             $date->setTimezone(new \DateTimeZone($config->timezone));
             $result = $date->humanize($config->period);
         } catch (Exception $e) {
         }
     }
     return $result;
 }
Example #11
0
 /**
  * Returns human readable date.
  *
  * @param  array  $config An optional array with configuration options.
  * @return string Formatted date.
  */
 public function humanize($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => $this->translate('Never'), 'smallest_period' => 'second'));
     $result = $config->default;
     if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
         $periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year');
         $lengths = array(60, 60, 24, 7, 4.35, 12, 10);
         $now = new \DateTime();
         try {
             $date = new Date(array('date' => $config->date, 'timezone' => 'UTC'));
             $date->setTimezone(new \DateTimeZone($config->timezone));
             $result = $date->humanize($config->period);
         } catch (\Exception $e) {
         }
     }
     return $result;
 }
Example #12
0
 /**
  * Initializes the options for the date object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional ObjectConfig object with configuration options.
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('date' => 'now', 'timezone' => date_default_timezone_get()));
 }
Example #13
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('state' => 'lib:model.state'));
     parent::_initialize($config);
 }
Example #14
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config    An optional ObjectConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('content' => null, 'transports' => array('redirect', 'json', 'http')));
     parent::_initialize($config);
 }
Example #15
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config An optional ObjectConfig object with configuration options
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('priority' => self::PRIORITY_NORMAL));
     parent::_initialize($config);
 }
Example #16
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config	An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('version' => '1.0', 'disposition' => 'inline', 'quote' => '"', 'separator' => ',', 'eol' => "\n"))->append(array('mimetype' => 'text/csv; version=' . $config->version));
     parent::_initialize($config);
 }
Example #17
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $object An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('class_loader' => null, 'cache_enabled' => false, 'cache_prefix' => 'nooku-registry-object'));
 }
Example #18
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('auto_register' => false));
     parent::_initialize($config);
 }
Example #19
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('priority' => TemplateFilterChain::PRIORITY_LOWEST));
     parent::_initialize($config);
 }
Example #20
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('formats' => array('ini' => 'Nooku\\Library\\Object\\ObjectConfigIni', 'json' => 'Nooku\\Library\\Object\\ObjectConfigJson', 'xml' => 'Nooku\\Library\\Object\\ObjectConfigXml', 'yaml' => 'Nooku\\Library\\Object\\ObjectConfigYaml')));
     parent::_initialize($config);
 }
Example #21
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $object An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('controller' => null));
     parent::_initialize($config);
 }
Example #22
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('controller' => $this->getIdentifier()->package, 'behaviors' => array('persistable', 'resettable'), 'limit' => array('max' => 1000, 'default' => 20)));
     parent::_initialize($config);
 }
Example #23
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config Configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('aliases' => array('assets://' => '/assets/')));
     parent::_initialize($config);
 }
Example #24
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('method' => self::GET, 'url' => '', 'headers' => array()));
     parent::_initialize($config);
 }
Example #25
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config An optional ObjectConfig object with configuration options
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('model' => null, 'defaults' => array()));
     parent::_initialize($config);
 }
Example #26
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  ObjectConfig $config An optional ObjectConfig object with configuration options
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('protocol' => '', 'type' => FilesystemStreamInterface::TYPE_UNKNOWN));
 }
Example #27
0
 /**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('encoding' => 'utf8', 'options' => array('clean' => true, 'drop-proprietary-attributes' => true, 'output-html' => true, 'show-body-only' => true, 'bare' => true, 'wrap' => 0, 'word-2000' => true)));
     parent::_initialize($config);
 }
Example #28
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('save_path' => ini_get('session.save_path')));
     parent::_initialize($config);
 }
Example #29
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $config Configuration options.
  * @return  void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('mixins' => array(), 'decorators' => array()));
 }
Example #30
0
 /**
  * Renders a listbox with autocomplete behavior
  *
  * @see    TemplateHelperBehavior::autocomplete
  * @return string	The html output
  */
 protected function _autocomplete($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('name' => '', 'attribs' => array(), 'model' => StringInflector::pluralize($this->getIdentifier()->package), 'validate' => true))->append(array('value' => $config->name, 'selected' => $config->{$config->name}, 'identifier' => 'com:' . $this->getIdentifier()->package . '.model.' . StringInflector::pluralize($config->model)))->append(array('text' => $config->value))->append(array('filter' => array('sort' => $config->text)));
     //For the autocomplete behavior
     $config->element = $config->value;
     $config->path = $config->text;
     $html = $this->getTemplate()->getHelper('behavior')->autocomplete($config);
     return $html;
 }