Exemple #1
0
 public function display()
 {
     $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
     $thing = reset($targets);
     $string = substr($thing['title'], 3);
     $option = strtolower(substr($string, 0, stripos($string, 'controller')));
     $view = strtolower(substr($string, stripos($string, 'controller') + 10));
     $model = KInflector::pluralize($view);
     $list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData();
     $array = array();
     foreach ($list as $item) {
         $array[] = $item['id'];
     }
     //Get the list of posts
     $activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList();
     $myactivities = array();
     foreach (@$activities as $activity) {
         if (!in_array($activity->parent_target_id, $array)) {
             continue;
         } else {
             $myactivities[] = $activity;
         }
     }
     $this->assign('myactivities', $myactivities);
     $this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination);
     return parent::display();
 }
Exemple #2
0
 public function setModel($model)
 {
     $model = parent::setModel($model);
     $model->package = KInflector::pluralize($this->_identifier->name);
     
     return $model; 
 }
Exemple #3
0
	/**
	 * Get the path based on an identifier
	 *
	 * @param  object  			An Identifier object - com:[//application/]component.view.[.path].name
	 * @return string|false		Returns the path on success FALSE on failure
	 */
	protected function _pathFromIdentifier($identifier)
	{
		$path = false;
		
		if($identifier->type == 'yaml')
		{
			$parts = $identifier->path;
	
			$component = 'com_'.strtolower($identifier->package);
			
			//Store the basepath for re-use
		    if($identifier->basepath) {
	            $this->_basepath = $identifier->basepath;
		    }

			if(!empty($identifier->name))
			{
				if(count($parts)) 
				{
					$path    = KInflector::pluralize(array_shift($parts));
					$path   .= count($parts) ? '/'.implode('/', $parts) : '';
					$path   .= '/'.strtolower($identifier->name);	
				} 
				else $path  = strtolower($identifier->name);	
			}
				
			$path = $this->_basepath.'/components/'.$component.'/'.$path.'.yaml';
		}	
		
		return $path;
	}
Exemple #4
0
    /**
     * Get the list of commands
     *
     * Prepending a special command not found in the manifest.xml
     *
     * @return  array
     */
    public function getCommands()
    {
        $option  = $this->getController()->getRequest()->option;
        //@TODO figure out why option=com_installer&view=components sets $request->option to NULL
        $active  = !$option || $option == 'com_installer';
        $view    = $active ? 'components' : KInflector::pluralize($this->getController()->getIdentifier()->name);

        $this->addCommand('Install/Uninstall', array(
            'href'   => JRoute::_('index.php?option=com_installer&view='.$view),
            'active' => $active
        ));

        $commands = parent::getCommands();

        //If the com_installer command is active, then following commands cannot be active
        if($commands['Install/Uninstall']->active)
        {
            foreach($commands as $key => $command)
            {
                if($key != 'Install/Uninstall') $command->active = false;
            }
        }

        return $commands;
    }
Exemple #5
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);
 }
Exemple #6
0
 /**
  * Deletes dependent rows.
  *
  * This performs an intelligent delete 
  *
  * @return KDatabaseRowAbstract
  */
 protected function _beforeTableDelete(KCommandContext $context)
 {
     $result = true;
     $section = $this->section;
     if (is_numeric($section) || !$section) {
         $section = 'com_articles';
     }
     $parts = explode('_', $section);
     //@TODO : Remove when refactoring is completed
     switch ($parts[1]) {
         case 'contact':
             $name = 'contacts';
             $package = 'contact';
             break;
         default:
             $name = KInflector::pluralize($parts[1]);
             $package = $name;
     }
     $identifier = 'com://admin/' . $package . '.model.' . $name;
     $rowset = $this->getService($identifier)->category($this->id)->getList();
     if ($rowset->count()) {
         $result = $rowset->delete();
     }
     return $result;
 }
Exemple #7
0
 /**
  * @param KDatabaseQuery $query
  */
 protected function _buildQueryJoins(KDatabaseQuery $query)
 {
     $state = $this->_state;
     parent::_buildQueryJoins($query);
     $iso_code = substr(JFactory::getLanguage()->getTag(), 0, 2);
     if ($iso_code != 'en') {
         $prefix = $iso_code . '_';
     }
     if (is_array($state->type)) {
         $subquery = '(';
         $i = 1;
         foreach ($state->type as $type) {
             $subquery .= 'SELECT ' . KInflector::pluralize($type) . '_' . KInflector::singularize($type) . '_id AS id, LOWER("' . strtoupper(KInflector::pluralize($type)) . '_' . strtoupper(KInflector::pluralize($type)) . '") AS test FROM #__' . $prefix . KInflector::pluralize($type) . '_' . KInflector::pluralize($type) . ' AS ' . KInflector::pluralize($type) . '
             WHERE enabled = 1 AND frontpage = 1';
             if (KInflector::singularize($type) == 'event') {
                 $subquery .= ' AND start_date >= CURDATE()';
             }
             if ($i < count($state->type)) {
                 $subquery .= ' UNION ALL ';
             }
             $i++;
         }
         $subquery .= ')';
         $query->join[] = array('type' => 'INNER', 'table' => $subquery . 'AS b', 'condition' => array('tbl.row = b.id AND tbl.table = b.test'));
     }
 }
Exemple #8
0
 /**
  * Helper for creating DOM element ids used by javascript behaviors
  *
  * If no type and package identifiers were supplied,
  * uses the current option $_GET variable, and changing com_foo_bar to com-foo_bar.
  * '-' are used as separators, and in our javascript used to parse identifier strings.
  * If a form got the id com-foo_bar-people, 
  * then we can assume that the toolbar will have the id toolbar-people,
  *
  * @author Stian Didriksen <*****@*****.**>
  * @param  array | int $parts
  * @return string
  */
 public function id($parts = array())
 {
     if (!is_array($parts) && is_int($parts)) {
         $parts['id'] = (int) $parts;
     }
     // If we pass a string, set $parts back as an array in order to proceed.
     if (!is_array($parts)) {
         settype($parts, 'array');
     }
     // Set the defaults, if needed
     $defaults = array();
     if (!isset($parts['type.package'])) {
         // We only want to replace the first underscore, not the rest.
         $defaults['type_package'] = str_replace('com_', 'com-', KRequest::get('get.option', 'cmd'));
     }
     if (!isset($parts['view'])) {
         $view = KRequest::get('get.view', 'cmd');
         // The view part always needs to be plural to allow ajax BREAD.
         if (KInflector::isSingular($view)) {
             $view = KInflector::pluralize($view);
         }
         $defaults['view'] = $view;
     }
     if (!isset($parts['id']) && KRequest::has('get.id', 'int')) {
         $defaults['id'] = KRequest::get('get.id', 'int');
     }
     // Filter away parts that are unset on purpose using a null value, or a negative boolean.
     return implode('-', array_filter(array_merge($defaults, $parts)));
 }
Exemple #9
0
 /**
  * Get the path based on a class name
  *
  * @param  string		  	The class name 
  * @return string|false		Returns the path on success FALSE on failure
  */
 public function findPath($classname, $basepath = null)
 {
     $path = false;
     if (strpos($classname, $this->_prefix) === 0) {
         $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $classname));
         $parts = explode('_', $word);
         if (array_shift($parts) == 'tmpl') {
             $name = array_shift($parts);
             $file = array_pop($parts);
             if (count($parts)) {
                 if ($parts[0] != 'view') {
                     foreach ($parts as $key => $value) {
                         $parts[$key] = KInflector::pluralize($value);
                     }
                 } else {
                     $parts[0] = KInflector::pluralize($parts[0]);
                 }
                 $path = implode('/', $parts) . '/' . $file;
             } else {
                 $path = $file;
             }
             $path = $this->_basepath . '/templates/' . $name . '/' . $path . '.php';
         }
     }
     return $path;
 }
Exemple #10
0
 public function render()
 {
     $name = $this->getName();
     $img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png');
     if ($img) {
         KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }');
     }
     $text = JText::_($this->_options['text']);
     $view = KRequest::get('get.view', 'cmd');
     $link = ' href="' . JRoute::_($this->getLink()) . '"';
     $html = array();
     // Sanitize the url since we can't trust the server var
     $url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink());
     // Create the URI object
     $uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url));
     $query = $uri->getQuery(1);
     $html[] = '<td class="button" id="' . $this->getId() . '">';
     $active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view']));
     $hide = !KInflector::isPlural($view);
     if ($active || $hide || !$this->modal) {
         $html[] = '<a class="toolbar inactive">';
     } else {
         $html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">';
     }
     $html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">';
     $html[] = '</span>';
     $html[] = $text;
     if (!$active && !$hide || $this->modal) {
         $html[] = '</a>';
     } else {
         $html[] = '</a>';
     }
     $html[] = '</td>';
     return implode(PHP_EOL, $html);
 }
Exemple #11
0
 public function _updateLanguages($id, $items)
 {
     foreach ($items as $language => $item) {
         $model_identifier = clone $item->getIdentifier();
         $model_identifier->path = array('model');
         $model_identifier->name = KInflector::pluralize($model_identifier->name);
         // Original Data
         $data = $item->getData();
         unset($data['id']);
         if (isset($data['featured'])) {
             unset($data['featured']);
         }
         $this->_checkName($item, false);
         $title = $item->title . ' (' . $this->count . ')';
         $slug = $item->slug . '-' . $this->count;
         JFactory::getLanguage()->setLanguage($language);
         $row = $this->getService($model_identifier)->id($id)->getItem();
         $row->setData($data);
         $row->title = $title;
         $row->enabled = 0;
         $row->slug = $slug;
         $row->translated = 0;
         if ($row->isRelationable()) {
             $row->setData(json_decode($row->ancestors));
             $row->setData(json_decode($row->descendants));
         }
         $row->save();
     }
 }
 /**
  * Load the file for a class
  *
  * @param   string  $class  The class that will be loaded
  * @return  boolean True on success
  */
 public static function loadClass($class)
 {
     // pre-empt further searching for the named class or interface.
     // do not use autoload, because this method is registered with
     // spl_autoload already.
     if (class_exists($class, false) || interface_exists($class, false)) {
         return;
     }
     // if class start with a 'Nooku' it is a Nooku class.
     // create the path and register it with the loader.
     switch (substr($class, 0, 6)) {
         case 'Picman':
             $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', substr_replace($class, '', 0, 6)));
             $parts = explode('_', $word);
             if (count($parts) > 1) {
                 $path = KInflector::pluralize(array_shift($parts)) . DS . implode(DS, $parts);
             } else {
                 $path = $word;
             }
             if (is_file(dirname(__FILE__) . DS . $path . '.php')) {
                 KLoader::register($class, dirname(__FILE__) . DS . $path . '.php');
             }
             break;
     }
     $classes = KLoader::register();
     if (array_key_exists(strtolower($class), $classes)) {
         include $classes[strtolower($class)];
         return true;
     }
     return false;
 }
Exemple #13
0
 /**
  * Delete Command for an entity.
  *
  * @param LibBaseTemplateObject $command The action object
  */
 protected function _commandDelete($command)
 {
     $entity = $this->getController()->getItem();
     $name = KInflector::pluralize($this->getController()->getIdentifier()->name);
     $redirect = 'option=com_' . $this->getIdentifier()->package . '&view=' . $name;
     $command->append(array('label' => JText::_('LIB-AN-ACTION-DELETE')))->href(JRoute::_($entity->getURL()))->setAttribute('data-action', 'delete')->setAttribute('data-redirect', JRoute::_($redirect))->class('action-delete');
 }
Exemple #14
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;
     }
Exemple #15
0
 /**
  * Get the path based on a class name
  *
  * @param  string		  	The class name 
  * @return string|false		Returns the path on success FALSE on failure
  */
 public function findPath($classname, $basepath = null)
 {
     $path = false;
     $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
     $parts = explode(' ', $word);
     if (array_shift($parts) == 'com') {
         //Switch the basepath
         if (!empty($basepath)) {
             $this->_basepath = $basepath;
         }
         $component = 'com_' . strtolower(array_shift($parts));
         $file = array_pop($parts);
         if (count($parts)) {
             if ($parts[0] != 'view') {
                 foreach ($parts as $key => $value) {
                     $parts[$key] = KInflector::pluralize($value);
                 }
             } else {
                 $parts[0] = KInflector::pluralize($parts[0]);
             }
             $path = implode('/', $parts);
             $path = $path . '/' . $file;
         } else {
             $path = $file;
         }
         $path = $this->_basepath . '/components/' . $component . '/' . $path . '.php';
     }
     return $path;
 }
Exemple #16
0
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if ($text) {
         $rows = array();
         $rowset = KService::get('com://admin/kutafuta.model.terms')->type($phrase)->search($text)->getList();
         foreach ($rowset as $row) {
             // We have table and row.
             // Row is always multiple but we check non the less.
             $parts = explode('_', $row->table);
             $data = KService::get('com://site/' . $parts[0] . '.model.' . KInflector::pluralize($parts[1]))->id($row->row)->getItem();
             if (empty($data->id)) {
                 continue;
             }
             $result = new stdClass();
             $result->title = $data->title;
             $result->metadesc = $data->meta_description;
             $result->metakey = $data->meta_keywords;
             $result->created = $data->created_on;
             $result->text = $data->introtext . $data->fulltext;
             $result->href = 'index.php?option=com_' . $parts[0] . '&view=' . KInflector::singularize($parts[1]) . '&id=' . $row->row;
             $rows[] = $result;
         }
         return $rows;
     }
 }
 /**
  * Generates an HTML optionlist based on the distinct data from a model column.
  * 
  * The column used will be defined by the name -> value => column options in
  * cascading order. 
  * 
  * If no 'model' name is specified the model identifier will be created using 
  * the helper identifier. The model name will be the pluralised package name. 
  * 
  * If no 'value' option is specified the 'name' option will be used instead. 
  * If no 'text'  option is specified the 'value' option will be used instead.
  * 
  * @param 	array 	An optional array with configuration options
  * @return	string	Html
  * @see __call()
  */
 protected function _splitview($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('id' => 'splitview', 'name' => '', 'package' => 'com_' . $this->getIdentifier()->package))->append(array('master_view' => KInflector::pluralize($config->name), 'detail_view' => KInflector::singularize($config->name)))->append(array('options' => array('master_url' => '?option=' . $config->package . '&view=' . $config->master_view . '&format=json&sort=created_on&direction=desc', 'detail_url' => '?option=' . $config->package . '&view=' . $config->detail_view . '&format=raw', 'label' => array('empty' => JText::_('No ' . KInflector::humanize($config->master_view) . '.'), 'select' => JText::_('No ' . KInflector::humanize($config->detail_view) . ' selected.')))));
     KFactory::get('admin::com.ninja.helper.default')->js('/splitview.js');
     KFactory::get('admin::com.ninja.helper.default')->js("\njQuery(function(\$){\n\t\t\t\$('#" . $config->id . "').splitview(" . json_encode($config->options->toArray()) . ");\n\t\t});\n");
     return '<div id="' . $config->id . '" class="splitview"></div>';
 }
 /**
  * Method to get a table object, load it if necessary.
  *
  * @param	array	Options array for view. Optional.
  * @return	object	The table object
  */
 public function getPath(array $options = array())
 {
     if (!is_object($this->_path)) {
         $package = $this->_identifier->package;
         $this->_path = JPATH_ROOT . DS . 'components' . DS . 'com_' . $package . DS . KInflector::pluralize($this->_identifier->name);
     }
     return $this->_path;
 }
Exemple #19
0
 /**
  * Search the mixin method map and call the method or trigger an error
  * 
  * This function check to see if the method exists in the mixing map if not
  * it will call the 'autocomplete' function. The method name will become the 'name'
  * in the config array.
  * 
  * This can be used to auto-magically create autocomplete select lists based on the 
  * function name.
  *
  * @param  string   The function name
  * @param  array    The function arguments
  * @throws BadMethodCallException   If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     if (!in_array($method, $this->getMethods())) {
         $config = $arguments[0];
         $config['model'] = KInflector::pluralize(strtolower($method));
         return $this->_autocomplete($config);
     }
     return parent::__call($method, $arguments);
 }
Exemple #20
0
 /**
  * Set the necessary redirect.
  *
  * @param KCommandContext $context
  */
 public function redirect(KCommandContext $context)
 {
     $url['view'] = KInflector::pluralize($this->getIdentifier()->name);
     $url['option'] = $this->getIdentifier()->package;
     if ($context->action == 'add') {
         $url['id'] = $this->getItem()->id;
     } elseif ($context->action == 'delete') {
         $url['oid'] = $this->getItem()->owner->id;
     }
     $this->getResponse()->setRedirect(JRoute::_($url));
 }
Exemple #21
0
 /**
  * @param array $config
  * @return string
  */
 public function direction($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('model' => 'categories', 'name' => 'id', 'attribs' => array(), 'key' => 'id'))->append(array('indent' => '&nbsp;&nbsp;&nbsp;', 'value' => $config->name, 'selected' => $config->{$config->name}, 'identifier' => 'com://' . $this->getIdentifier()->application . '/' . $this->getIdentifier()->package . '.model.' . KInflector::pluralize($config->model)))->append(array('text' => $config->value))->append(array('filter' => array('sort' => $config->text)));
     $options = array();
     $options[] = $this->option(array('text' => '- ' . JText::_('Select') . ' -', 'value' => null));
     $options[] = $this->option(array('text' => JText::_('Ascending'), 'value' => 'ASC'));
     $options[] = $this->option(array('text' => JText::_('Descending'), 'value' => 'DESC'));
     $config->options = $options;
     return parent::optionlist($config);
 }
 /**
  * Get the children rowset
  *
  * @return	object
  */
 public function getChildren()
 {
     if (!$this->_children instanceof KDatabaseRowsetInterface) {
         $identifier = clone $this->getIdentifier();
         $identifier->path = array('database', 'rowset');
         $identifier->name = KInflector::pluralize($this->getIdentifier()->name);
         //The row default options
         $options = array('identity_column' => $this->getIdentityColumn());
         $this->_children = $this->getService($identifier, $options);
     }
     return $this->_children;
 }
Exemple #23
0
 /**
  * Get the path based on a class name.
  *
  * @param  string		  	The class name
  *
  * @return string|false Returns the path on success FALSE on failure
  */
 public function findPath($classname, $basepath = null)
 {
     $path = false;
     /*
      * Exception rule for Exception classes
      *
      * Transform class to lower case to always load the exception class from the /exception/ folder.
      */
     if ($pos = strpos($classname, 'Exception')) {
         $filename = substr($classname, $pos + strlen('Exception'));
         $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
     }
     $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
     $parts = explode(' ', $word);
     if (array_shift($parts) == 'com') {
         //Switch the basepath
         if (!empty($basepath)) {
             $this->_basepath = $basepath;
         }
         $component = 'com_' . strtolower(array_shift($parts));
         $file = array_pop($parts);
         $path = null;
         if (count($parts)) {
             if ($parts[0] != 'view') {
                 foreach ($parts as $key => $value) {
                     $parts[$key] = KInflector::pluralize($value);
                 }
             } else {
                 $parts[0] = KInflector::pluralize($parts[0]);
             }
             $path = implode('/', $parts);
         }
         $path = '/components/' . $component . '/' . $path;
         $filepath = $path . '/' . $file . '.php';
         $basepath = $this->_basepath;
         if (array_value($parts, -1) == 'exceptions') {
             if (!file_exists($basepath . $filepath)) {
                 $filepath = $path . '/default.php';
             }
         }
         if (count($parts) == 2 && $parts[0] == 'domains') {
             if ($parts[1] == 'entities' && JPATH_SITE != $this->_basepath) {
                 //set the basepath of entities to the site
                 if (!file_exists($basepath . $filepath)) {
                     $basepath = JPATH_SITE;
                 }
             }
         }
         $path = $basepath . $filepath;
     }
     return $path;
 }
Exemple #24
0
 /**
  * Method to set a view object attached to the controller
  *
  * @param	mixed	An object that implements KObjectServiceable, KServiceIdentifier object 
  * 					or valid identifier string
  * @throws	KControllerException	If the identifier is not a view identifier
  * @return	KControllerAbstract
  */
 public function setView($view)
 {
     if (is_string($view) && strpos($view, '.') === false) {
         if (!isset($this->_request->view)) {
             if ($this->getModel()->getState()->isUnique()) {
                 $view = KInflector::singularize($view);
             } else {
                 $view = KInflector::pluralize($view);
             }
         }
     }
     return parent::setView($view);
 }
Exemple #25
0
 /**
  * Saves/Add an entity and then redirects
  *
  * @param KCommandContext $context Context parameter
  *
  * @return AnDomainEntitysetAbstract
  */
 protected function _actionPost(KCommandContext $context)
 {
     if ($context->action == 'save') {
         $context->response->setRedirect('option=com_' . $this->getIdentifier()->package . '&view=' . KInflector::pluralize($this->getIdentifier()->name));
     }
     $data = $context->data;
     if ($this->getItem()) {
         $this->execute('edit', $context);
     } else {
         $this->execute('add', $context);
     }
     return $this->getItem();
 }
Exemple #26
0
 /**
  * @param $context
  */
 protected function _saveCache($context)
 {
     if ($context->data->getModified()) {
         $redis = $this->_getRedis();
         $identifier = clone $context->caller->getIdentifier();
         $identifier->path = array('model');
         $row = $this->getService($identifier)->id($context->data->id)->cache(0)->getItem();
         $filter = $this->getService('koowa:filter.slug');
         $redis->set(KInflector::singularize($identifier->name) . ':' . $row->id, serialize($row->toArray()));
         $redis->lpush(KInflector::pluralize($identifier->name), $row->id);
         $redis->sadd('ctas_involvement:' . $filter->sanitize($row->ctas_involvement), $row->id);
     }
 }
Exemple #27
0
 public function display()
 {
     //Add the template override path
     $parts = $this->_identifier->path;
     array_shift($parts);
     if (count($parts) > 1) {
         $path = KInflector::pluralize(array_shift($parts));
         $path .= count($parts) ? DS . implode(DS, $parts) : '';
         $path .= DS . strtolower($this->getName());
     } else {
         $path = strtolower($this->getName());
     }
     $template = KFactory::get('lib.joomla.application')->getTemplate();
     $override = JPATH_THEMES . DS . $template . DS . 'html' . DS . 'com_' . $this->_identifier->package . DS . $path;
     KFactory::get($this->getTemplate())->addPath($override);
     if ($template == 'morph' && class_exists('Morph')) {
         $override = JPATH_ROOT . '/morph_assets/themelets/' . Morph::getInstance()->themelet . '/html/' . 'com_' . $this->_identifier->package . '/' . $path;
         KFactory::get($this->getTemplate())->addPath($override);
     }
     $model = KFactory::get($this->getModel());
     $identifier = $model->getIdentifier();
     $type = $identifier->type;
     $package = $identifier->package;
     $isAdmin = KFactory::get('lib.joomla.application')->isAdmin();
     //Set the document title
     if ($this->_auto_title) {
         $this->setDocumentTitle();
     }
     // Hide the toolbar if we're in an iframe
     if (KRequest::get('get.tmpl', 'cmd') == 'component') {
         $this->_toolbar = false;
     }
     $this->assign('length', KFactory::tmp($this->getModel()->getIdentifier())->getTotal());
     if ($this->_toolbar) {
         $toolbar = $this->_createToolbar();
         if (!$this->length && KInflector::isPlural($this->getName())) {
             $toolbar->removeListButtons();
         }
         $this->_document->setBuffer($toolbar->renderTitle(), 'modules', 'title');
         $this->_document->setBuffer($toolbar->render(), 'modules', 'toolbar');
         //Needed for templates like AdminPraise2
         //@TODO submit patch to com_default's dispatcher
         KFactory::get('lib.joomla.application')->set('JComponentTitle', $toolbar->renderTitle());
     }
     KFactory::map('admin::com.' . $package . '.form.default', 'admin::com.ninja.form.default');
     //Add admin.css from the extension or current template if it exists.
     if ($isAdmin) {
         $this->css('/admin.css');
     }
     return parent::display();
 }
Exemple #28
0
 public function _actionIndex(KCommandContext $context)
 {
     // We will get all the items of the database and resave them to index everything.
     set_time_limit(1440);
     $modelIdentifier = clone $context->caller->getIdentifier();
     $modelIdentifier->path = array('model');
     $modelIdentifier->name = KInflector::pluralize($modelIdentifier->name);
     $model = $this->getService($modelIdentifier);
     $items = $model->limit(0)->getList();
     foreach ($items as $item) {
         $item->save();
     }
     JFactory::getApplication()->redirect(KRequest::referrer(), JText::_(ucfirst($modelIdentifier->name) . ' reindexed'));
 }
Exemple #29
0
 public function _createToolbar()
 {
     $identifier = $this->getToolbar();
     $name = $identifier->name;
     $package = $identifier->package;
     KFactory::get('admin::com.ninja.helper.default')->css('/toolbar.css');
     $img = KInflector::isPLural($name) ? KFactory::get('admin::com.ninja.helper.default')->img('/48/' . $name . '.png') : KFactory::get('admin::com.ninja.helper.default')->img('/48/' . KInflector::pluralize($name) . '.png');
     if (!$img) {
         $img = KInflector::isSingular($name) ? KFactory::get('admin::com.ninja.helper.default')->img('/48/' . $name . '.png') : KFactory::get('admin::com.ninja.helper.default')->img('/48/' . KInflector::singularize($name) . '.png');
     }
     if ($img) {
         KFactory::get('admin::com.ninja.helper.default')->css('.header.icon-48-' . $name . ' { background-image: url(' . $img . '); }');
     }
     return KFactory::get($identifier, array('icon' => $name));
 }
Exemple #30
0
 /**
  * Set the referrer
  *
  * @return void
  */
 public function setReferrer()
 {
     $identifier = $this->getMixer()->getIdentifier();
     if (!KRequest::has('cookie.referrer_locked')) {
         $request = KRequest::url();
         $referrer = KRequest::referrer();
         //Compare request url and referrer
         if (!isset($referrer) || (string) $referrer == (string) $request) {
             $option = 'com_' . $identifier->package;
             $view = KInflector::pluralize($identifier->name);
             $url = 'index.php?option=' . $option . '&view=' . $view;
             $referrer = $this->getService('koowa:http.url', array('url' => $url));
         }
         KRequest::set('cookie.referrer', (string) $referrer);
     }
 }