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(); }
protected function _getAsset($asset, $url, $extension = null) { if (!$extension) { $extension = KRequest::get('get.option', 'cmd'); } $template = KFactory::get('lib.joomla.application')->getTemplate(); $isMorph = $template == 'morph'; $custom = '/images/' . $extension . $url; $framework = '/media/plg_koowa/' . $asset . $url; $fallback = '/media/com_ninja/' . $asset . $url; $default = '/media/' . $extension . '/' . $asset . $url; $overriden = '/templates/' . $template . '/' . $asset . '/' . $extension . $url; if ($isMorph) { $overriden = '/templates/' . $template . '/core/' . $asset . '/' . $extension . $url; if (class_exists('Morph')) { $themelet = '/morph_assets/themelets/' . Morph::getInstance()->themelet . '/' . $asset . '/' . $extension . $url; } else { $themelet = null; } } //Maybe support more types of assets for $custom in the future if ($asset == 'images' && file_exists(JPATH_ROOT . $custom)) { return KRequest::root() . $custom; } elseif ($isMorph && file_exists(JPATH_ROOT . $themelet)) { return KRequest::root() . $themelet; } elseif (file_exists(JPATH_BASE . $overriden)) { return KRequest::base() . $overriden; } elseif (file_exists(JPATH_ROOT . $default)) { return KRequest::root() . $default; } elseif (file_exists(JPATH_ROOT . $fallback)) { return KRequest::root() . $fallback; } elseif (file_exists(JPATH_ROOT . $framework)) { return KRequest::root() . $framework; } return false; }