Esempio n. 1
0
    /**
     * Generates an HTML editor
     *
     * @param   array   An optional array with configuration options
     * @return  string  Html
     */
    public function display($config = array())
    {
        $config = new KConfig($config);
        $config->append(array(
            'editor'    => null,
            'name'      => 'description',
            'width'     => '100%',
            'height'    => '500',
            'cols'      => '75',
            'rows'      => '20',
            'buttons'   => true,
            'options'   => array()
        ));

        $editor  = KFactory::get('joomla:editor', array($config->editor));
        $options = KConfig::toData($config->options);

        if (version_compare(JVERSION, '1.6.0', 'ge')) { 
            $result = $editor->display($config->name, $config->{$config->name}, $config->width, $config->height, $config->cols, $config->rows, KConfig::toData($config->buttons), $config->name, null, null, $options); 
        } else { 
            $result = $editor->display($config->name, $config->{$config->name}, $config->width, $config->height, $config->cols, $config->rows, KConfig::toData($config->buttons), $options); 
        } 
        
        return $result;
    }
Esempio n. 2
0
	public function humanize($config = array())
	{
		$config = new KConfig($config);
		$config->append(array(
			'sizes' => array('Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')
		));
		$bytes = $config->size;
		$result = '';
		$format = (($bytes > 1024*1024 && $bytes % 1024 !== 0) ? '%.2f' : '%d').' %s';

		foreach ($config->sizes as $s) {
			$size = $s;
			if ($bytes < 1024) {
				$result = $bytes;
				break;
			}
			$bytes /= 1024;
		}

		if ($result == 1) {
			$size = KInflector::singularize($size);
		}

		return sprintf($format, $result, JText::_($size));
	}
Esempio n. 3
0
 /**
  * Initializes the options for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('template_paths' => array(dirname(__FILE__) . '/html')));
     parent::_initialize($config);
     $config->append(array('template_paths' => array(JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_actors/actor')));
     $this->enabled_apps = null;
 }
Esempio n. 4
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 protected function _initialize(KConfig $config)
 {
     $package = KInflector::humanize($this->getIdentifier()->package);
     $name = KInflector::humanize(KInflector::pluralize($this->getName()));
     $config->append(array('title' => $package . ' - ' . $name));
     parent::_initialize($config);
 }
Esempio n. 5
0
 public function _initialize(KConfig $config)
 {
     $this->mixin($this->getService('com://admin/kutafuta.controller.behavior.indexable'));
     $this->mixin($this->getService('com://admin/moyo.controller.behavior.copyable'));
     $config->append(array('behaviors' => array('com://admin/cck.controller.behavior.autosavable')));
     parent::_initialize($config);
 }
Esempio n. 6
0
 /**
  * Renders a password input with the validation.
  *
  * @param bool $required A boolean flag whether the password is
  *                       required or not
  */
 public function input($options = array())
 {
     $options = new KConfig($options);
     $options->append(array('id' => 'person-password', 'name' => 'password', 'class' => 'input-block-level', 'required' => 'required', 'minlength' => ComPeopleFilterPassword::$MIN_LENGTH));
     $html = $this->getService('com:base.template.helper.html');
     return $html->passwordfield($options['name'], $options)->class($options['class'])->id($options['id'])->required($options['required'])->minlength($options['minlength']);
 }
Esempio n. 7
0
 /**
  * Decodes json data on each field
  * 
  * @return boolean	true.
  */
 protected function _afterTableSelect(KCommandContext $context)
 {
     //We should only run this on row objects
     if ($context->mode == KDatabase::FETCH_FIELD) {
         return;
     }
     $rows = $context['data'];
     $identifier = clone $rows->getTable();
     $identifier->path = array('model');
     $identifier->name = 'settings';
     $defaults = KFactory::get($identifier)->getParams()->toArray();
     if (is_a($rows, 'KDatabaseRowInterface')) {
         $rows = array($rows);
     }
     foreach ($rows as $row) {
         //if(is_array($row->params)) continue;
         //echo $row->params;
         //if(is_array($row->params)) die('<pre>'.var_export(is_string($row->params) && !is_null($row->params), true).'</pre>');
         //$true = false;
         //if(is_array($row->params)) $true = true;
         $params = is_string($row->params) ? json_decode($row->params, true) : $row->params;
         //if(!is_array($params)) $params = array();
         //if($true) die('<pre>'.__CLASS__.' '.var_export($params, true).'</pre>');
         $params = new KConfig($params);
         //@TODO Make this configurable, instead of hardcoding the defaults to only apply when JSite
         if (KFactory::get('lib.joomla.application')->isSite()) {
             $params->append($defaults);
         }
         $row->params = $params;
     }
 }
Esempio n. 8
0
 /**
  * Initializes the options for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $child = clone $this->_parent;
     $child->name = KInflector::singularize($config->name);
     $config->append(array('entityset' => 'anahita:domain.entityset.onetomany', 'cardinality' => 'many', 'child_key' => $this->_parent->name, 'parent_delete' => AnDomain::DELETE_CASCADE, 'child' => $child));
     parent::_initialize($config);
 }
Esempio n. 9
0
 	/**
     * Generates a list over positions
     *
     * The list is the array over positions coming from the application template merged with the module positions currently in use
     * that may not be defined in the xml
     *
     * @param   array   An optional array with configuration options
     * @return  string  Html
     */
    public function positions($config = array())
    {
        $config = new KConfig($config);
        $config->append(array(
            'position'    => 'left',
            'application' => 'site'
        ));

        $positions  = KFactory::get('com://admin/extensions.model.modules')->application($config->application)->getList()->getColumn('position');
        
		$template   = KFactory::get('com://admin/extensions.model.templates')
                          ->application($config->application)
                          ->default(1)
                          ->getItem();
                          
        $positions  = array_unique(array_merge($template->positions, $positions));
		sort($positions);
	
        // @TODO combobox behavior should be in the framework
        JHTML::_('behavior.combobox');
        
        $html[] = '<input type="text" id="position" class="combobox" name="position" value="'.$config->position.'" />';
        $html[] = '<ul id="combobox-position" style="display:none;">';
        
        foreach($positions as $position) {
        	$html[] = '<li>'.$position.'</li>';
        }
        $html[] = '</ul>';

        return implode(PHP_EOL, $html);
    }
 public function bootstrap($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('namespace' => null, 'javascript' => array(), 'package' => null, 'type' => null));
     $html = '';
     if (count($config->javascript) && !isset(self::$_loaded['jquery'])) {
         $html .= $this->jquery();
     }
     if (empty($config->package)) {
         $config->package = $this->getTemplate()->getIdentifier()->package;
     }
     if (empty($config->type) && $config->type !== false) {
         $config->type = $this->getTemplate()->getIdentifier()->application;
     }
     foreach ($config->javascript as $js) {
         if (!isset(self::$_loaded[$config->package . '-bootsrap-' . $js])) {
             $html .= '<script src="media://com_' . $config->package . '/bootstrap/js/bootstrap-' . $js . '.js" />';
             self::$_loaded['bootsrap-' . $js] = true;
         }
     }
     $filename = 'bootstrap' . ($config->type ? '-' . $config->type : '');
     if (!isset(self::$_loaded[$config->package . '-' . $filename])) {
         if ($config->type) {
             $html .= '<style src="media://com_' . $config->package . '/bootstrap/css/bootstrap.css" />';
         }
         $html .= '<style src="media://com_' . $config->package . '/bootstrap/css/' . $filename . '.css" />';
         self::$_loaded[$config->package . '-' . $filename] = true;
     }
     $this->getTemplate()->addFilter('bootstrap');
     if (!empty($config->namespace) || $config->namespace === false) {
         $this->getTemplate()->getFilter('bootstrap')->setNamespace($config->namespace);
     }
     return $html;
 }
Esempio n. 11
0
 public function _initialize(KConfig $config)
 {
     $config->identity_column = 'id';
     $orderable = $this->getBehavior('com://admin/categories.database.behavior.orderable', array('parent_column' => 'section_id'));
     $config->append(array('name' => 'categories', 'behaviors' => array('lockable', $orderable, 'sluggable', 'cascadable'), 'column_map' => array('enabled' => 'published', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out', 'slug' => 'alias', 'section_id' => 'section')));
     parent::_initialize($config);
 }
Esempio n. 12
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(KConfig $config)
 {
     $paths[] = dirname($this->getIdentifier()->filepath) . '/html';
     $paths[] = implode(DS, array(JPATH_THEMES, JFactory::getApplication()->getTemplate(), 'html', $this->getIdentifier()->type . '_' . $this->getIdentifier()->package, $this->getName()));
     $config->append(array('template_paths' => $paths));
     parent::_initialize($config);
 }
Esempio n. 13
0
    public function  _initialize(KConfig $config)
    {
        $config->identity_column = 'id';
        
        $config->append(array(
            'name' => 'content',
            'behaviors' => array(
            	'creatable', 'modifiable', 'lockable', 'orderable', 'sluggable', 'revisable'  
            ),
            'column_map' => array(
                'locked_on'        => 'checked_out_time',
                'locked_by'        => 'checked_out',
                'slug'       	   => 'alias',
                'section_id'       => 'sectionid',
                'category_id'	   => 'catid',
                'created_on' 	   => 'created',
                'modified_on'      => 'modified',
                'description'      => 'metadesc',
                'params'		   => 'attribs'
            ),
            'filters' => array(
                'introtext'   => array('html', 'tidy'),
                'fulltext'    => array('html', 'tidy'),
                'attribs'	  => 'ini'
		    )
        ));

        parent::_initialize($config);
    }
Esempio n. 14
0
 /**
  * Constructor.
  *
  * @param 	object 	An optional KConfig object with configuration options
  */
 public function __construct(KConfig $config)
 {
     $this->_root = $config->root;
     $this->_property = $config->property;
     $config->object = $config->service_container->get($config->repository->getEntityset(), $config->toArray());
     parent::__construct($config);
 }
Esempio n. 15
0
 public function translations($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('row' => null, 'table' => ''));
     // First for our knowledge we get the original language (if exists.)
     $original = $this->_getOriginalLanguage($config->row, $config->table);
     $html = '<style src="media://com_translations/css/translations.css" />';
     $view = KInflector::singularize(KRequest::get('get.view', 'string'));
     foreach ($this->_getLanguages() as $language) {
         $relation = $this->_getLanguage($config, $language->lang_code);
         if ($language->lang_code == $original->iso_code) {
             $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-info">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
         } else {
             if ($relation->translated) {
                 $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-success">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
             } else {
                 if (strtotime('+ 2 weeks', strtotime($original->created_on)) > strtotime(date('d-m-Y H:i:s'))) {
                     $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-warning">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
                 } else {
                     if (strtotime('+ 2 weeks', strtotime($original->created_on)) < strtotime(date('d-m-Y H:i:s'))) {
                         $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-important">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
                     }
                 }
             }
         }
     }
     return $html;
 }
Esempio n. 16
0
 public function groups(array $config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => 'group', 'core' => null));
     $attribs = KHelperArray::toString($config->attribs);
     $groups = $this->getService('com://admin/groups.model.groups')->set('core', is_null($config->core) ? null : $config->core)->getList();
     if ($config->exclude instanceof KDatabaseRowInterface && $config->exclude->id) {
         foreach (clone $groups as $group) {
             if ($group->lft >= $config->exclude->lft && $group->rgt <= $config->exclude->rgt) {
                 $groups->extract($group);
             }
         }
     }
     foreach ($groups as $group) {
         $checked = $config->selected == $group->id ? ' checked' : '';
         if ($group->depth) {
             $html[] = '<div style="padding-left: ' . $group->depth * 15 . 'px" class="clearfix">';
             $html[] = '<input type="radio" name="' . $config->name . '" id="' . $config->name . $group->id . '" value="' . $group->id . '"' . $checked . ' ' . $attribs . '/>';
             $html[] = '<label for="' . $config->name . $group->id . '">' . $group->name . '</label>';
             $html[] = '</div>';
         } else {
             $html[] = '<h4>' . $group->name . '</h4>';
         }
     }
     return implode(PHP_EOL, $html);
 }
Esempio n. 17
0
	public function select($config = array()) 
	{
		$config = new KConfig($config);
		$config->append(array(
			'name' => '',
			'visible' => true,
			'link' => '',
			'link_text' => JText::_('Select')
		))->append(array(
			'value' => $config->name
		));
		
		$input = '<input name="%1$s" id="%1$s" value="%2$s" %3$s size="40" />';
		
		$link = '<a class="modal-button"
					rel="{\'ajaxOptions\': {\'method\': \'get\'}, \'handler\': \'iframe\', \'size\': {\'x\': 700}}"
					href="%s">'
				.$config->link_text
				.'</a>';
				
		$html = sprintf($input, $config->name, $config->value, $config->visible ? 'type="text" readonly' : 'type="hidden"');
		$html .= sprintf($link, $config->link);
		
		return $html;
	}
Esempio n. 18
0
 /**
  * Constructor
  *
  * @param array Associative array of values
  */
 public function __construct(KConfig $options)
 {
     //Create an object holding our default settings
     $defaults = array('path' => false, 'changelog' => false);
     //Override default settings
     $options->append($defaults);
     if (!$options->path) {
         $manifests = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR, '.xml$', 0, true);
         foreach ($manifests as $manifest) {
             $xml = simplexml_load_file($manifest);
             if (isset($xml['type'])) {
                 break;
             }
         }
         $options->path = $manifest;
     }
     //load the file, and save it to our object
     $this->_xml = simplexml_load_file($options->path);
     if (!$options->changelog) {
         $changelog = false;
         $manifests = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR, '.xml$', 0, true);
         foreach ($manifests as $manifest) {
             $xml = simplexml_load_file($manifest);
             if ($xml->getName() == 'changelogs') {
                 $changelog = $xml;
                 break;
             }
         }
         if ($changelog) {
             $this->_changelog = $changelog;
         }
     }
 }
Esempio n. 19
0
	protected function _initialize(KConfig $config)
	{
		$config->append(array(
			'auto_assign' => false
		));
		parent::_initialize($config);
	}
Esempio n. 20
0
    public function users($config = array())
    {
        $config = new KConfig($config);
		$config->append(array(
		    'deselect'  => true,
		    'prompt'	=> '- Select -'
		));

		$list = KFactory::get('com://admin/users.model.users')
		    ->set('sort', 'name')
		    ->set('limit', 0)
		    ->getList();

 		if($config->deselect) {
         	$options[] = $this->option(array('text' => $config->prompt, 'value' => -1));
        }

        foreach($list as $item) {
			$options[] = $this->option(array('text' => $item->name, 'value' => $item->id));
		}

		$config->options = $options;

		return $this->optionlist($config);
    }
 /**
  * Render item pagination
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  * @see     http://developer.yahoo.com/ypatterns/navigation/pagination/
  */
 public function pagination($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('total' => 0, 'display' => 4, 'offset' => 0, 'limit' => 0, 'show_limit' => true, 'show_count' => true));
     $this->_initialize($config);
     $j15 = version_compare(JVERSION, '1.6', '<');
     $html = '';
     if ($j15) {
         $html .= '<div class="container">';
     }
     $html .= '<div class="pagination">';
     if ($config->show_limit) {
         $html .= '<div class="limit">' . $this->translate('Display NUM') . ' ' . $this->limit($config) . '</div>';
     }
     $html .= $this->_pages($this->_items($config));
     if ($config->show_count) {
         if ($j15) {
             $html .= '<div class="limit"> ' . $this->translate('Page') . ' ' . $config->current . ' ' . $this->translate('of') . ' ' . $config->count . '</div>';
         } else {
             $html .= sprintf($this->translate('JLIB_HTML_PAGE_CURRENT_OF_TOTAL'), $config->current, $config->count);
         }
     }
     $html .= '</div>';
     if ($j15) {
         $html .= '</div>';
     }
     return $html;
 }
Esempio n. 22
0
 protected function _initialize(KConfig $config)
 {
     $config->append(array(
     	'controller' => 'items',
     ));
     parent::_initialize($config);
 }
Esempio n. 23
0
 public function _initialize(KConfig $config)
 {
     $sluggable = $this->getBehavior('sluggable', array('columns' => array('name')));
     $orderable = $this->getBehavior('com://admin/categories.database.behavior.orderable', array('parent_column' => 'catid'));
     $config->append(array('identity_column' => 'bid', 'base' => 'banner', 'name' => 'banner', 'behaviors' => array('creatable', 'lockable', $sluggable, $orderable, 'hittable'), 'column_map' => array('enabled' => 'showBanner', 'created_on' => 'date', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out', 'slug' => 'alias', 'hits' => 'clicks'), 'filters' => array('custombannercode' => array('html', 'tidy'), 'params' => 'ini')));
     parent::_initialize($config);
 }
Esempio n. 24
0
 public function radiolist($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('list' => null, 'name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => null, 'translate' => false));
     $name = $config->name;
     $attribs = KHelperArray::toString($config->attribs);
     $html = array();
     foreach ($config->list as $row) {
         $key = $row->{$config->key};
         $text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
         $id = isset($row->id) ? $row->id : null;
         $extra = '';
         if ($config->selected instanceof KConfig) {
             foreach ($config->selected as $value) {
                 $sel = is_object($value) ? $value->{$config->key} : $value;
                 if ($key == $sel) {
                     $extra .= 'selected="selected"';
                     break;
                 }
             }
         } else {
             $extra .= $key == $config->selected ? 'checked="checked"' : '';
         }
         $html[] = '<label class="radio" for="' . $name . $id . '">' . $text;
         $html[] = '<input type="radio" name="' . $name . '" id="' . $name . $id . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />';
         $html[] = '</label>';
     }
     return implode(PHP_EOL, $html);
 }
Esempio n. 25
0
 public function display()
 {
     $apps = $this->getService('com://site/actors.domain.entityset.component', array('actor' => $this->_state->getItem(), 'can_enable' => true));
     $config = new KConfig();
     foreach ($this->_state->getItem()->components as $component) {
         $permissions = array();
         if (!$component->isAssignable()) {
             continue;
         }
         if (!count($component->getPermissions())) {
             continue;
         }
         foreach ($component->getPermissions() as $identifier => $actions) {
             if (strpos($identifier, '.') === false) {
                 $name = $identifier;
                 $identifier = clone $component->getIdentifier();
                 $identifier->path = array('domain', 'entity');
                 $identifier->name = $name;
             }
             $identifier = $this->getIdentifier($identifier);
             foreach ($actions as $action) {
                 $key = $identifier->package . ':' . $identifier->name . ':' . $action;
                 $value = $this->_state->getItem()->getPermission($key);
                 $permissions[] = array('name' => $key, 'value' => $value);
             }
             $config->append(array($component->component => array('name' => $component->component, 'enabled' => true, 'permissions' => $permissions)));
         }
     }
     foreach ($apps as $app) {
         $config->append(array($app->component => array('name' => $app->component, 'enabled' => $app->enabledForActor($this->_state->getItem()))));
     }
     $data['followRequests'] = $this->_state->getItem()->requesters->toArray();
     $data['apps'] = array_values($config->toArray());
     return json_encode($data);
 }
Esempio n. 26
0
 public function _initialize(KConfig $config)
 {
     $config->identity_column = 'id';
     $sluggable = $this->getBehavior('sluggable', array('columns' => array('name')));
     $config->append(array('name' => 'contact_details', 'behaviors' => array('orderable', 'lockable', $sluggable), 'column_map' => array('enabled' => 'published', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out', 'slug' => 'alias', 'category' => 'catid'), 'filters' => array('params' => 'ini')));
     parent::_initialize($config);
 }
Esempio n. 27
0
     public function order($config = array())
     {
         $config = new KConfig($config);
         $config->append(array(
             'name'          => 'order',
             'state'         => null,
             'attribs'       => array(),
             'model'         => null,
             'package'       => $this->getIdentifier()->package,
             'selected'      => 0
        ));
        
        //@TODO can be removed when name collisions fixed
        $config->name = 'order'; 

        $app        = $this->getIdentifier()->application;
        $identifier = 'com://'.$app.'/'.$config->package.'.model.'.($config->model ? $config->model : KInflector::pluralize($config->package));

        $list = KFactory::get($identifier)->limit(0)->set($config->filter)->getList();

        $options = array();
        foreach($list as $item) {
			$options[] =  $this->option(array('text' => $item->ordering, 'value' => $item->ordering - $config->ordering));
		}
		
        $list = $this->optionlist(array(
            'options'  => $options,
            'name'     => $config->name,
            'attribs'  => $config->attribs,
            'selected' => $config->selected
        )); 
        return $list;
     }
Esempio n. 28
0
 /**
  * Initializes the default configuration for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     if ($config->repository) {
         $config->append(array('identifier' => $config->repository->getDescription()->getInheritanceColumnValue()->getIdentifier(), 'node_type' => (string) $config->repository->getDescription()->getInheritanceColumnValue(), 'commentable' => $config->repository->isCommentable(), 'ownable' => $config->repository->isOwnable(), 'hashtagable' => $config->repository->isHashtagable()));
     }
     parent::_initialize($config);
 }
Esempio n. 29
0
 /**
  * Initializes the default configuration for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('inheritance' => array('abstract' => $this->getIdentifier()->classname === __CLASS__), 'relationships' => array('author' => array('parent' => 'com:people.domain.entity.person', 'child_column' => 'created_by', 'required' => true)), 'attributes' => array('name' => array('read' => 'public'), 'enabled' => array('default' => 1)), 'behaviors' => array('votable', 'authorizer', 'privatable', 'ownable', 'dictionariable', 'subscribable', 'describable', 'com://site/hashtags.domain.behavior.hashtagable', 'com://site/people.domain.behavior.mentionable')));
     $behaviors = $config->behaviors;
     $behaviors->append(array('modifiable' => array('modifiable_properties' => array('name', 'body')), 'commentable' => array('comment' => array('length' => 5000))));
     parent::_initialize($config);
 }
Esempio n. 30
0
 /**
  * @return mixed
  */
 public function display()
 {
     $menu = JFactory::getApplication()->getMenu();
     $lang = JFactory::getLanguage();
     $category = $this->getModel()->getItem();
     $category->layout = end(explode(':', $category->layout));
     $this->setLayout($category->layout ? $category->layout : 'default');
     header('X-Category-ID: ' . $category->id);
     $doc =& JFactory::getDocument();
     if ($category->title) {
         $doc->setTitle($category->title);
     }
     if ($category->meta_keywords) {
         $doc->setMetaData('Keywords', $category->meta_keywords);
     }
     if ($category->meta_description) {
         $doc->setMetaData('Description', $category->meta_description);
     }
     if ($menu->getActive() == $menu->getDefault($lang->getTag()) || !$menu->getActive()) {
         $pathway = JFactory::getApplication()->getPathway();
         if (!JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_makundi&view=category&id=' . $category->id, true)) {
             foreach ($category->getAncestors(array('level' => 1)) as $ancestor) {
                 $item = JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_makundi&view=category&id=' . $ancestor->id, true);
                 if ($item) {
                     $i = 0;
                     foreach (explode('/', $item->route) as $part) {
                         $pathway->addItem(ucfirst($part), 'index.php?Itemid=' . $item->tree[$i]);
                         $i++;
                     }
                 } else {
                     if (!JSite::getMenu()->getActive()->id) {
                         $pathway->addItem($ancestor->title, JRoute::_('index.php?option=com_makundi&view=category&parent_slug_path=' . $ancestor->parent_slug_path . '&slug=' . $ancestor->slug));
                     }
                 }
             }
             $pathway->addItem($category->title);
         }
     }
     $descendants = array();
     $descendants[] = $category->id;
     $config = new KConfig();
     if ($params = $menu->getActive()->params) {
         $config->append($params->toArray());
     }
     if ($config->show_subcategories) {
         $descendants = array_merge($descendants, $category->getDescendants(array('level' => 1))->getColumn('id'));
     }
     $config->append(array('show_description' => 1, 'show_articles' => 1));
     // TODO: Set the limit default limit inside $category so we can make this more flexable.
     $limit = $this->getModel()->getState()->limit;
     if (!$limit) {
         $this->getModel()->getState()->limit = $config->limit;
     } else {
         $this->getModel()->getState()->limit = 4;
     }
     $this->assign('params', $config);
     $this->assign('parent', $this->getModel()->getItem()->getParent());
     $this->assign('descendants', $descendants);
     return parent::display();
 }