本文整理汇总了PHP中JRegistry::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::getInstance方法的具体用法?PHP JRegistry::getInstance怎么用?PHP JRegistry::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders a module script and returns the results as a string
*
* @param string $name The name of the module to render
* @param array $attribs Associative array of values
*
* @return string The output of the script
* @since 1.0
*/
public function render($module, $attribs = array(), $content = null)
{
// add the environment data to attributes of module
$registry = JRegistry::getInstance('document.environment');
$env = $registry->getValue('params', array());
$attribs = array_merge($env, $attribs);
if (!is_object($module)) {
$title = isset($attribs['title']) ? $attribs['title'] : null;
$module = MigurModuleHelper::getModule($module, $title);
if (!is_object($module)) {
if (is_null($content)) {
return '';
} else {
/**
* If module isn't found in the database but data has been pushed in the buffer
* we want to render it
*/
$tmp = $module;
$module = new stdClass();
$module->params = null;
$module->module = $tmp;
$module->id = 0;
$module->user = 0;
}
}
}
// get the user and configuration object
//$user = JFactory::getUser();
$conf = JFactory::getConfig();
// set the module content
if (!is_null($content)) {
$module->content = $content;
}
//get module parameters
$params = new JRegistry();
$params->loadJSON($module->params);
// use parameters from template
if (isset($attribs['params'])) {
$template_params = new JRegistry();
$template_params->loadJSON(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
$params->merge($template_params);
$module = clone $module;
$module->params = (string) $params;
}
$contents = '';
$cachemode = $params->get('cachemode', 'oldstatic');
// default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the module instead
if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') {
// default to itemid creating mehod and workarounds on
$cacheparams = new stdClass();
$cacheparams->cachemode = $cachemode;
$cacheparams->class = 'JModuleHelper';
$cacheparams->method = 'renderModule';
$cacheparams->methodparams = array($module, $attribs);
$contents = MigurModuleHelper::ModuleCache($module, $params, $cacheparams);
} else {
$contents = MigurModuleHelper::renderModule($module, $attribs);
}
return $contents;
}
示例2: __construct
public function __construct($config = array())
{
parent::__construct($config);
$this->app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get project id.
$this->projectId = $this->input->getUint('pid');
// Prepare log object
$registry = JRegistry::getInstance('com_crowdfunding');
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get('logger.file');
$tableName = $registry->get('logger.table');
$file = JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . $fileName);
$this->log = new Prism\Log\Log();
$this->log->addAdapter(new Prism\Log\Adapter\Database(JFactory::getDbo(), $tableName));
$this->log->addAdapter(new Prism\Log\Adapter\File($file));
// Create an object that contains a data used during the payment process.
$this->paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->projectId;
$this->paymentProcess = $this->app->getUserState($this->paymentProcessContext);
// Set payment service name.
if (!isset($this->paymentProcess->paymentService)) {
$this->paymentProcess->paymentService = '';
}
// Local executing tasks. It needs to provide form token.
$this->registerTask('checkout', 'process');
// Remote executing tasks. It does not need to provide form token.
$this->registerTask('doCheckout', 'process');
$this->registerTask('completeCheckout', 'process');
}
示例3: __construct
public function __construct($config = array())
{
parent::__construct($config);
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get project id.
$this->projectId = $this->input->getUint("pid");
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
$file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log = new ITPrismLog();
$this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
$this->log->addWriter(new ITPrismLogWriterFile($file));
// Create an object that contains a data used during the payment process.
$this->paymentProcessContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->projectId;
$this->paymentProcess = $app->getUserState($this->paymentProcessContext);
// Prepare context
$filter = new JFilterInput();
$paymentService = JString::trim(JString::strtolower($this->input->getCmd("payment_service")));
$paymentService = $filter->clean($paymentService, "ALNUM");
$this->context = !empty($paymentService) ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
// Prepare params
$this->params = JComponentHelper::getParams("com_crowdfunding");
}
示例4: getDetailBody
public static function getDetailBody($modid)
{
if (trim($modid) == "") {
return false;
}
$reg = JRegistry::getInstance("com_jevents");
$moddata = $reg->get("dynamicmodules");
if (isset($moddata[$modid])) {
return $moddata[$modid];
}
return false;
}
示例5: __construct
public function __construct($config = array())
{
parent::__construct($config);
$this->option = $this->input->getCmd("option");
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
$file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log = new Prism\Log\Log();
$this->log->addWriter(new Prism\Log\Writer\Database(JFactory::getDbo(), $tableName));
$this->log->addWriter(new Prism\Log\Writer\File($file));
}
示例6: _cb_strftime
/**
* Callback function
*
* @static
* @param mixed $pattern array() search pattern or int date
*/
public static function _cb_strftime($pattern)
{
// timestamp used during callback
$registry = JRegistry::getInstance('jevents');
$ts = $registry->get('jevents.strftime', time());
switch ($pattern[0]) {
case '%C':
return sprintf("%02d", date("Y", $ts) / 100);
break;
case '%D':
return '%m/%d/%y';
break;
case '%e':
return sprintf("%' 2d", date("j", $ts));
break;
case '%g':
return JevDate::strftime('%y', JEV_CompatWin::_getThursdayOfWeek($ts));
break;
case '%G':
return JevDate::strftime('%Y', JEV_CompatWin::_getThursdayOfWeek($ts));
break;
case '%h':
return '%b';
break;
case '%n':
return "\n";
break;
case '%r':
return '%I:%M:%S %p';
break;
case '%R':
return '%H:%M';
break;
case '%t':
return "\t";
break;
case '%T':
return '%H:%M:%S';
break;
case '%u':
return ($w = date("w", $ts)) ? $w : 7;
break;
case '%V':
return JEV_CompatWin::_getWeekNumberISO8601($ts);
break;
default:
return ' unknown specifier! ';
}
}
示例7: init
public function init()
{
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
// Create log object
$this->log = new ITPrismLog();
// Set database writer.
$this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
// Set file writer.
if (!empty($fileName)) {
$file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log->addWriter(new ITPrismLogWriterFile($file));
}
// Load language
$this->loadLanguage();
}
示例8: __construct
public function __construct(&$subject, $config = array())
{
parent::__construct($subject, $config);
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
// Create log object
$this->log = new ITPrismLog();
// Set database writer.
$this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
// Set file writer.
if (!empty($fileName)) {
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$file = JPath::clean($app->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log->addWriter(new ITPrismLogWriterFile($file));
}
}
示例9: __construct
public function __construct($config = array())
{
parent::__construct($config);
$app = JFactory::getApplication();
/** @var $app JApplicationSite * */
// Get project id.
$this->projectId = $this->input->getUint("pid");
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
$file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log = new ITPrismLog();
$this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
$this->log->addWriter(new ITPrismLogWriterFile($file));
// Create an object that contains a data used during the payment process.
$this->paymentProcessContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->projectId;
$this->paymentProcess = $app->getUserState($this->paymentProcessContext);
}
示例10: jevFilter
function jevFilter($tablename, $filterfield, $isString = false)
{
$registry = JRegistry::getInstance("jevents");
$indexedvisiblefilters = $registry->get("indexedvisiblefilters", array());
if (!is_array($indexedvisiblefilters)) {
$indexedvisiblefilters = array();
}
// This is our best guess as to whether this filter is visible on this page.
$this->isVisible(in_array($this->filterType, $indexedvisiblefilters));
// If using caching should disable session filtering if not logged in
$cfg = JEVConfig::getInstance();
$joomlaconf = JFactory::getConfig();
$useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
// New special code in jevents.php sets the session variables in the cache id calculation!
$useCache = false;
// Is the filter module setup to reset automatically
$module = JModuleHelper::getModule("mod_jevents_filter");
if ($module) {
$modparams = new JRegistry($module->params);
$option = JRequest::getCmd("option");
if ($modparams->get("resetfilters") == "nonjevents" && $option != "com_jevents" && $option != "com_jevlocations" && $option != "com_jevpeople" && $option != "com_rsvppro" && $option != "com_jevtags") {
JRequest::setVar('filter_reset', 1);
JFactory::getApplication()->setUserState('active_filter_menu ', JRequest::getInt("Itemid", 0));
} else {
if ($modparams->get("resetfilters") == "newmenu" && !JRequest::getCmd("jevents_filter_submit", false, "POST")) {
// Must use JRequest::getInt("Itemid") since missing event finder resets active menu item!
if (JRequest::getInt("Itemid", 0) && JRequest::getInt("Itemid", 0) != JFactory::getApplication()->getUserState("jevents.filtermenuitem", 0)) {
JRequest::setVar('filter_reset', 1);
JFactory::getApplication()->setUserState('active_filter_menu ', JRequest::getInt("Itemid", 0));
}
}
}
}
$user = JFactory::getUser();
// TODO chek this logic
if (intval(JRequest::getVar('filter_reset', 0))) {
$this->filter_value = $this->filterNullValue;
for ($v = 0; $v < $this->valueNum; $v++) {
$this->filter_values[$v] = $this->filterNullValues[$v];
}
$this->filter_value = JFactory::getApplication()->setUserState($this->filterType . '_fv_ses', $this->filterNullValue);
for ($v = 0; $v < $this->valueNum; $v++) {
$this->filter_values[$v] = JFactory::getApplication()->setUserState($this->filterType . '_fvs_ses' . $v, $this->filterNullValues[$v]);
}
} else {
if ($user->get('id') == 0 && $useCache || !$this->visible) {
$this->filter_value = JRequest::getVar($this->filterType . '_fv', $this->filterNullValue);
for ($v = 0; $v < $this->valueNum; $v++) {
$this->filter_values[$v] = JRequest::getVar($this->filterType . '_fvs' . $v, $this->filterNullValues[$v]);
}
} else {
$this->filter_value = JFactory::getApplication()->getUserStateFromRequest($this->filterType . '_fv_ses', $this->filterType . '_fv', $this->filterNullValue);
for ($v = 0; $v < $this->valueNum; $v++) {
$this->filter_values[$v] = JFactory::getApplication()->getUserStateFromRequest($this->filterType . '_fvs_ses' . $v, $this->filterType . '_fvs' . $v, $this->filterNullValues[$v]);
}
}
}
/*
}
else {
$this->filter_value = JRequest::getString($this->filterType.'_fv', $this->filterNullValue );
for ($v=0;$v<$this->valueNum;$v++){
$this->filter_values[$v] = JRequest::getInt($this->filterType."_fvs".$v, $this->filterNullValues[$v] );
}
}
*/
$this->tableName = $tablename;
$this->filterField = $filterfield;
$this->filterIsString = $isString;
}
示例11: updateDatabase
protected function updateDatabase($step)
{
$db = JFactory::getDBO();
$html = '';
$status = true;
$stopUpdate = false;
$continue = false;
// Insert configuration codes if needed
$hasConfig = $this->dbhelper->_isExistDefaultConfig();
if (!$hasConfig) {
$html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_UPDATE_CONFIG') . '</div>';
$obj = new stdClass();
$obj->name = 'dbversion';
$obj->params = DBVERSION;
if (!$db->insertObject('#__community_config', $obj)) {
$html .= $this->failedStatus;
$status = false;
$errorCode = '7a';
} else {
$default = JPATH_BASE . '/components/com_community/default.ini';
$registry = JRegistry::getInstance('community');
$registry->loadFile($default, 'INI', 'community');
// Set the site name
$app = JFactory::getApplication();
$registry->setValue('community.sitename', $app->getCfg('sitename'));
// Set the photos path
$photoPath = rtrim(dirname(JPATH_BASE), '/');
$registry->setValue('community.photospath', $photoPath . '/images');
// Set the videos folder
$registry->setValue('community.videofolder', 'images');
// Store the config
$obj = new stdClass();
$obj->name = 'config';
$obj->params = $registry->toString('INI', 'community');
if (!$this->dbhelper->insertTableEntry('#__community_config', $obj)) {
$html .= $this->failedStatus;
ob_start();
?>
<div>
Error when trying to create default configurations.
Please proceed to the configuration and set your own configuration instead.
</div>
<?php
$html .= ob_get_contents();
@ob_end_clean();
} else {
$html .= $this->successStatus;
}
}
} else {
$dbversionConfig = $this->dbhelper->getDBVersion();
$dbversion = empty($dbversionConfig) ? 0 : $dbversionConfig;
if ($dbversion < DBVERSION) {
$updater = new CommunityInstallerUpdate();
$html .= '<div style="width:150px; float:left;">' . JText::_('Updating DB from version ' . $dbversion) . '</div>';
$updateResult = call_user_func(array($updater, 'update_' . $dbversion));
$stopUpdate = empty($updateResult->stopUpdate) ? false : true;
if ($updateResult->status) {
$html .= $this->successStatus;
$status = true;
$dbversion++;
if ($dbversionConfig === null && $dbversionConfig !== 0) {
$this->dbhelper->insertDBVersion($dbversion);
} else {
$this->dbhelper->updateDBVersion($dbversion);
}
if ($dbversion < DBVERSION) {
$continue = true;
}
} else {
$html .= $this->failedStatus;
$status = false;
$errorCode = $updateResult->errorCode;
}
$html .= $updateResult->html;
}
}
if (!$stopUpdate) {
if (!$continue) {
// Need to update the menu's component id if this is a reinstall
if (menuExist()) {
$html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_UPDATE_MENU_ITEMS') . '</div>';
if (!updateMenuItems()) {
ob_start();
?>
<p style="font-weight: 700; color: red;">
System encountered an error while trying to update the existing menu items. You will need
to update the existing menu structure manually.
</p>
<?php
$html .= ob_get_contents();
@ob_end_clean();
$html .= $this->failedStatus;
} else {
$html .= $this->successStatus;
}
} else {
$html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_CREATE_MENU_ITEMS') . '</div>';
if (!addMenuItems()) {
ob_start();
//.........这里部分代码省略.........
示例12: findInstalledExtensions
/**
* Fetch all installed extensions from the database
*
* @return array
*/
public static function findInstalledExtensions()
{
$registry = JRegistry::getInstance('JSNTplFramework');
$installedExtensions = $registry->get('extension.installed', array());
if (empty($installedExtensions)) {
$db = JFactory::getDbo();
$q = $db->getQuery(true);
$q->select('element, manifest_cache');
$q->from('#__extensions');
$q->where('type IN ("component", "plugin", "module")');
$db->setQuery($q);
foreach ($db->loadObjectList() as $extension) {
$installedExtensions[$extension->element] = json_decode($extension->manifest_cache);
}
$registry->set('extension.installed', $installedExtensions);
}
return $installedExtensions;
}
示例13: getTemplate
/**
* Get the template
*
* @return string The template name
* @since 1.0
*/
public function getTemplate($params = false)
{
if(is_object($this->template))
{
if ($params) {
return $this->template;
}
return $this->template->template;
}
$id = 0;
$condition = '';
$tid = JRequest::getVar('templateStyle', 0);
if (is_numeric($tid) && (int) $tid > 0) {
$id = (int) $tid;
}
$cache = JFactory::getCache('com_templates', '');
if ($this->_language_filter) {
$tag = JFactory::getLanguage()->getTag();
}
else {
$tag ='';
}
$templates = array((object)array(
'template' => 'default',
'params' => JRegistry::getInstance('foobarTemplateParams')
));
if (isset($templates[$id])) {
$template = $templates[$id];
}
else {
$template = $templates[0];
}
// Allows for overriding the active template from the request
$template->template = JRequest::getCmd('template', $template->template);
$template->template = JFilterInput::getInstance()->clean($template->template, 'cmd'); // need to filter the default value as well
// Fallback template
if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) {
JError::raiseWarning(0, JText::_('JERROR_ALERTNOTEMPLATE'));
$template->template = 'beez_20';
if (!file_exists(JPATH_THEMES . '/beez_20/index.php')) {
$template->template = '';
}
}
// Cache the result
$this->template = $template;
if ($params) {
return $template;
}
return $template->template;
}
示例14: DefaultLoadedFromTemplate
//.........这里部分代码省略.........
}
if (is_null($templates[$template_name])) {
return false;
}
$catids = $event->catids() && count($event->catids()) ? $event->catids() : array($event->catid());
$catids[] = 0;
// find the overlap
$catids = array_intersect($catids, array_keys($templates[$template_name]));
// At present must be an EXACT category match - no inheriting allowed!
if (count($catids) == 0) {
if (!isset($templates[$template_name][0]) || $templates[$template_name][0]->value == "") {
return false;
}
}
$template = false;
foreach ($catids as $catid) {
// use the first matching non-empty layout
if ($templates[$template_name][$catid]->value != "") {
$template = $templates[$template_name][$catid];
break;
}
}
if (!$template) {
return false;
}
$template_value = $template->value;
$specialmodules = $template->params;
$matchesarray = $template->matchesarray;
} else {
// This is a special scenario where we call this function externally e.g. from RSVP Pro messages
// In this scenario we have not gone through the displaycustomfields plugin
static $pluginscalled = array();
if (!isset($pluginscalled[$event->rp_id()])) {
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin("jevents");
$customresults = $dispatcher->trigger('onDisplayCustomFields', array(&$event));
$pluginscalled[$event->rp_id()] = $event;
} else {
$event = $pluginscalled[$event->rp_id()];
}
// Adjust template_value to include dynamic module output then strip it out afterwards
if ($specialmodules) {
$modids = $specialmodules->get("modid", array());
if (count($modids) > 0) {
$modvals = $specialmodules->get("modval", array());
// not sure how this can arise :(
if (is_object($modvals)) {
$modvals = get_object_vars($modvals);
}
for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
$template_value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
// cleaned later!
//$template_value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
$template_value .= $modvals[$count];
$template_value .= "{{module end:MODULEEND}}";
}
}
}
// strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
$template_value = str_replace("\r", '', $template_value);
$template_value = str_replace("\n", '', $template_value);
// non greedy replacement - because of the ?
$template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value);
$matchesarray = array();
preg_match_all('|{{.*?}}|', $template_value, $matchesarray);
}
示例15: _load
/**
* Load method - our version MUST set the access level correctly for iCal exports!
*
* @param integer $id Id of category to load
*
* @return void
*
* @since 11.1
*/
protected function _load($id)
{
$registry = JRegistry::getInstance("jevents");
// need both paths for Joomla 2.5 and 3.0
$puser = $registry->get("jevents.icaluser", $registry->get("icaluser", false));
if (!$puser) {
$this->_options['currentlang'] = 0;
return parent::_load($id);
}
$db = JFactory::getDbo();
$app = JFactory::getApplication();
// overload permissions for iCal Export
$user = $puser;
$extension = $this->_extension;
// Record that has this $id has been checked
$this->_checkedCategories[$id] = true;
$query = $db->getQuery(true);
// Right join with c for category
$query->select('c.*');
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('c.alias');
$case_when .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $c_id . ' END as slug';
$query->select($case_when);
$query->from('#__categories as c');
$query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')');
if ($this->_options['access']) {
$query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
}
if ($this->_options['published'] == 1) {
$query->where('c.published = 1');
}
$query->order('c.lft');
// s for selected id
if ($id != 'root') {
// Get the selected category
$query->where('s.id=' . (int) $id);
if ($app->isSite() && $app->getLanguageFilter()) {
$query->leftJoin('#__categories AS s ON (s.lft < c.lft AND s.rgt > c.rgt AND c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')) OR (s.lft >= c.lft AND s.rgt <= c.rgt)');
} else {
$query->leftJoin('#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)');
}
} else {
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')');
}
}
$subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' . 'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) . ' AND parent.published != 1 GROUP BY cat.id) ';
$query->leftJoin($subQuery . 'AS badcats ON badcats.id = c.id');
$query->where('badcats.id is null');
// i for item
if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1) {
if ($this->_options['published'] == 1) {
$query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1');
} else {
$query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id');
}
$query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems');
}
// Group by
$query->group('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
c.path, c.published, c.rgt, c.title, c.modified_user_id');
// Get the results
$db->setQuery($query);
$results = $db->loadObjectList('id');
$childrenLoaded = false;
if (count($results)) {
// Foreach categories
foreach ($results as $result) {
// Deal with root category
if ($result->id == 1) {
$result->id = 'root';
}
// Deal with parent_id
if ($result->parent_id == 1) {
$result->parent_id = 'root';
}
// Create the node
if (!isset($this->_nodes[$result->id])) {
// Create the JCategoryNode and add to _nodes
$this->_nodes[$result->id] = new JCategoryNode($result, $this);
// If this is not root and if the current node's parent is in the list or the current node parent is 0
if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1)) {
// Compute relationship between node and its parent - set the parent in the _nodes field
$this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
}
//.........这里部分代码省略.........