? GR0V Shell

GR0V shell

Linux www.koreapackagetour.com 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64

Path : /home/admin/public_html/old/modules/mod_jmb_tree/
File Upload :
Current File : /home/admin/public_html/old/modules/mod_jmb_tree/helper.php

<?php
/**
 * @package    Jmb_Tree
 * @author     Sherza & Dmitry Rekun <support@norrnext.com>
 * @copyright  Copyright (C) 2012 - 2015 NorrNext. All rights reserved.
 * @license    GNU General Public License version 3 or later; see license.txt
 */

defined('_JEXEC') or die;

/**
 * JMB Tree helper class.
 *
 * @package  Jmb_Tree
 * @since    1.0
 */
abstract class ModJmbTreeHelper
{
	/**
	 * Children only parameter.
	 *
	 * @var  int
	 */
	public static $childrenonly = null;

	/**
	 * Current category.
	 *
	 * @var  int
	 */
	public static $curcat = null;

	/**
	 * End level parameter.
	 *
	 * @var  int
	 */
	public static $endLevel = null;

	/**
	 * Real end level.
	 *
	 * @var  int
	 */
	public static $endLevelReal = null;

	/**
	 * Method to get the list of items.
	 *
	 * @param   array  &$params  Additional parameters.
	 *
	 * @return  array  The list of items.
	 */
	public static function &getList(&$params)
	{
		if ($params->get('type', 'category') == 'category')
		{
			$list = self::getCategories($params);
		}
		else
		{
			$list = self::getMenuItems($params);
		}

		return $list;
	}

	/**
	 * Method to get the list of menu items.
	 *
	 * @param   array  $params  Additional parameters.
	 *
	 * @return  array  The list of items.
	 */
	private static function getMenuItems($params)
	{
		$menuParamsPre = $params->get('menuitems');
		$menuParams = array();

		foreach ($menuParamsPre as $k => $mpp)
		{
			$menuParams[$k] = $mpp;
		}

		$menutype = $menuParams[0];
		$checkedElems = explode(',', $menuParams[2]);

		$app = JFactory::getApplication();
		$menu = $app->getMenu();
		$items = $menu->getItems('menutype', $menutype);

		$excludedMenus = array_map('trim', explode(',', $menuParams[3]));

		$links = array();
		$excludedParentsLevels = array();

		self::$childrenonly = $params->get('childrenonly');
		$endLevel = $params->get('endLevel');
		$endLevelReal = 0;

		$curItemid = $app->input->getInt('Itemid', 0);
		$curMenuLevel = 0;
		$childrenOfCurMenu = false;

		// Level separator
		$levelSeparator = '';

		if ($params->get('use_sep', 1))
		{
			$levelSeparator = $params->get('level_sep', '');

			if (strlen($levelSeparator) > 1 || empty($levelSeparator))
			{
				$levelSeparator = '&nbsp;';
			}
		}

		foreach ($items as $k => $mlink)
		{
			if (self::$childrenonly)
			{
				if ($childrenOfCurMenu
					&& $curMenuLevel
					&& $mlink->level <= $curMenuLevel)
				{
					$childrenOfCurMenu = false;
					$curMenuLevel = 0;
				}

				if ($mlink->id == $curItemid)
				{
					$childrenOfCurMenu = true;
					$curMenuLevel = $mlink->id;
				}

				if (!$childrenOfCurMenu || $mlink->id == $curItemid)
				{
					//continue;
				}
			}

			if (!empty($excludedParentsLevels)
				&& isset($items[$k - 1])
				&& ($items[$k - 1]->level >= $mlink->level))
			{
				foreach ($excludedParentsLevels as $j => $lev)
				{
					if ($j >= $mlink->level)
					{
						unset($excludedParentsLevels[$j]);
					}
				}
			}

			$checked = (in_array('zmenu' . $mlink->id, $checkedElems)) ? true : false;
			$excluded = (in_array($mlink->id, $excludedMenus)) ? true : false;

			if ($checked && !$excluded)
			{
				if (!$endLevelReal)
				{
					$endLevelReal = $mlink->level + $endLevel;
				}

				if (!$endLevel || $mlink->level < $endLevelReal)
				{
					$link = new stdClass;
					$link->id = $mlink->id;
					$link->href = $mlink->link;

					$internal = false;
					$external = false;

					switch ($mlink->type)
					{
						case 'separator':
							$link->href = '';
							break;

						case 'url':
							if ((strpos($mlink->link, 'index.php?') === 0) && (strpos($mlink->link, 'Itemid=') === false))
							{
								// If this is an internal Joomla link, ensure the Itemid is set.
								$link->href = $mlink->link . '&Itemid=' . $mlink->id;
								$internal   = true;
							}
							else
							{
								$external = true;
							}
							break;

						case 'alias':
							// If this is an alias use the item id stored in the parameters to make the link.
							$link->href = 'index.php?Itemid=' . $mlink->params->get('aliasoptions');
							break;

						default:
							$router = JFactory::getApplication()->getRouter();

							if ($router->getMode() == JROUTER_MODE_SEF)
							{
								$link->href = 'index.php?Itemid=' . $mlink->id;
							}
							else
							{
								$link->href .= '&Itemid=' . $mlink->id;
								$internal = true;
							}
							break;
					}

					if (strcasecmp(substr($link->href, 0, 4), 'http') && (strpos($link->href, 'index.php?') !== false))
					{
						$link->href = JRoute::_($link->href, false, $mlink->params->get('secure'));
					}
					else
					{
						$link->href = JRoute::_($link->href, false);
					}

					$excludedParentsCount = 0;

					if (!empty($excludedParentsLevels))
					{
						foreach ($excludedParentsLevels as $j => $lev)
						{
							if ($j < $mlink->level)
							{
								$excludedParentsCount++;
							}
						}
					}

					$link->level = ($mlink->level - $excludedParentsCount - $curMenuLevel);

					$link->levelSeparator = '';

					if ($link->level > 1)
					{
						$link->levelSeparator = str_repeat($levelSeparator . ' ', $link->level - 1);
					}

					// Nofollow
					$addNofollow     = $params->get('add_nofollow', '');
					$nofollowExclude = explode(',', $params->get('exclude_nofollow', ''));
					$link->nofollow  = '';

					switch ($addNofollow)
					{
						case 'all':
							$link->nofollow = 'rel="nofollow"';
							break;

						case 'internal':
							if ($internal)
							{
								$link->nofollow = 'rel="nofollow"';
							}
							break;

						case 'external':
							if ($external)
							{
								$link->nofollow = 'rel="nofollow"';
							}
							break;
					}

					if (in_array($link->id, $nofollowExclude))
					{
						$link->nofollow = '';
					}

					$link->text			= htmlspecialchars($mlink->title, ENT_COMPAT, 'UTF-8', false);
					$link->anchor_css	= htmlspecialchars($mlink->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
					$link->anchor_title = htmlspecialchars($mlink->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
					$link->menu_image	= $mlink->params->get('menu_image', '')
						? htmlspecialchars($mlink->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false)
						: '';
					$link->params		= $mlink->params;
					$link->browserNav	= $mlink->browserNav;

					$links[] = $link;
				}
			}

			if ($excluded)
			{
				$excludedParentsLevels[$mlink->level] = true;
			}
		}

		return $links;
	}

	/**
	 * Method to get the list of categories.
	 *
	 * @param   array  $params  Additional parameters.
	 *
	 * @return  array  The list of categories.
	 */
	private static function getCategories($params)
	{
		include_once JPATH_BASE . '/components/com_content/helpers/route.php';

		$cat = '';
		$cats = JCategories::getInstance('content', array($cat));
		$catRoot = $cats->get($cat);
		$categories = $catRoot->getChildren();
		$level = 0;

		$catParamsPre = $params->get('category');
		$catParams = array();

		foreach ($catParamsPre as $k => $cpp)
		{
			$catParams[$k] = $cpp;
		}

		$checkedElems = explode(',', $catParams[1]);
		$links = array();

		$excludedCats = array_map('trim', explode(',', $catParams[2]));

		self::$endLevel = $params->get('endLevel');

		self::$childrenonly = $params->get('childrenonly');

		if (self::$childrenonly)
		{
			if (JFactory::getApplication()->input->getVar('option') == 'com_content')
			{
				$view = JFactory::getApplication()->input->getVar('view');

				if ($view == 'category' || $view == 'categories')
				{
					self::$curcat = JFactory::getApplication()->input->getInt('id', 0);
				}
				elseif ($view == 'article')
				{
					$db = JFactory::getDbo();
					$db->setQuery('SELECT catid FROM #__content WHERE id = ' . JFactory::getApplication()->input->getInt('id', 0));
					self::$curcat = $db->loadResult();
				}
			}
		}

		self::getCatListRecurse($categories, $level, $checkedElems, $links, $excludedCats, $params);

		return $links;
	}

	/**
	 * Method to recurse the list of categories.
	 *
	 * @param   array    $categories          Categories.
	 * @param   int      &$level              Hierarchy level.
	 * @param   array    $checkedElems        Checked elements.
	 * @param   array    &$links              Links.
	 * @param   array    $excludedCats        Excluded categories.
	 * @param   array    $params              Additional parameters.
	 * @param   boolean  $childrenOfSelected  Children categories of selected one.
	 *
	 * @return  void
	 */
	private static function getCatListRecurse($categories, &$level, $checkedElems, &$links, $excludedCats, $params, $childrenOfSelected = false)
	{
		$childrenOfSelectedTop = $childrenOfSelected;

		$level++;

		// Level separator
		$levelSeparator = '';

		if ($params->get('use_sep', 1))
		{
			$levelSeparator = $params->get('level_sep', '');

			if (strlen($levelSeparator) > 1 || empty($levelSeparator))
			{
				$levelSeparator = '&nbsp;';
			}
		}

		foreach ($categories as $cat)
		{
			$childrenOfSelected = (!self::$childrenonly || ($childrenOfSelectedTop || ($cat->id == self::$curcat))) ? true : false;

			$childrenCategories = $cat->getChildren();

			$showCatid = (!self::$childrenonly || ($cat->id != self::$curcat && $childrenOfSelected)) ? true : false;

			if ($showCatid)
			{
				$checked = (in_array('zcat' . $cat->id, $checkedElems)) ? true : false;
				$excluded = (in_array($cat->id, $excludedCats)) ? true : false;

				if ($checked && !$excluded)
				{
					if (!self::$endLevelReal)
					{
						self::$endLevelReal = $level + self::$endLevel;
					}

					if (!self::$endLevel || $level < self::$endLevelReal)
					{
						$link = new stdClass;
						$link->id = $cat->id;
						$link->href = JRoute::_(ContentHelperRoute::getCategoryRoute($cat->id), false);

						$link->levelSeparator = '';

						if ($level > 1)
						{
							$link->levelSeparator = str_repeat($levelSeparator . ' ', $level - 1);
						}

						$link->text = $cat->title;
						$link->textNoDef = $cat->title;
						$link->level = $level;
						$links[] = $link;
					}
				}
			}
			else
			{
				$level--;
			}

			if ($childrenCategories)
			{
				if ($excluded)
				{
					$level--;
				}

				self::getCatListRecurse($childrenCategories, $level, $checkedElems, $links, $excludedCats, $params, $childrenOfSelected);

				if ($excluded)
				{
					$level++;
				}
			}

			if (!$showCatid)
			{
				$level++;
			}
		}

		$level--;
	}
}

T1KUS90T
  root-grov@210.1.60.28:~$