NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/public_html/plugins/system/falangdriver/routers/com_content/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/public_html/plugins/system/falangdriver/routers/com_content/router.php
<?php
/**
 * @package     Falang for Joomla!
 * @author      Stéphane Bouey <stephane.bouey@faboba.com> - http://www.faboba.com
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @copyright   Copyright (C) 2010-2017. Faboba.com All rights reserved.
 */

defined('_JEXEC') or die;

/**
 * Routing class of com_content
 *
 * @since  3.3
 */
require_once JPATH_ROOT . '/components/com_content/router.php';

class FalangContentRouter extends ContentRouter
{

	/**
	 * Content Component router constructor
	 *
	 * @param   JApplicationCms $app  The application object
	 * @param   JMenu           $menu The menu object to work with
	 */
	public function __construct($app = null, $menu = null)
	{
		parent::__construct($app, $menu);
		//need to override router name
		$this->name = 'content';

	}



	/**
	 * Method to get the segment(s) for an article
	 *
	 * @param   string $id    ID of the article to retrieve the segments for
	 * @param   array  $query The request that is built right now
	 *
	 * @return  array|string  The segments of this item
	 */

	public function getArticleSegment($id, $query)
	{
		if (!strpos($id, ':'))
		{
			$db      = JFactory::getDbo();
			$dbquery = $db->getQuery(true);
			//add id in the query to use falang override query
			$dbquery->select($dbquery->qn(array('alias', 'id')))
				->from($dbquery->qn('#__content'))
				->where('id = ' . $dbquery->q($id));
			$db->setQuery($dbquery);
			$id .= ':' . $db->loadResult();
		}

		if ($this->noIDs)
		{
			list($void, $segment) = explode(':', $id, 2);

			return array($void => $segment);
		}

		return array((int) $id => $id);
	}


	public function getArticleId($segment, $query)
	{
		if ($this->noIDs)
		{
			$lang         = JFactory::getLanguage()->getTag();
			$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');

			//look in Falang Table
			if ($default_lang != $lang)
			{
				$fManager = FalangManager::getInstance();
				$id_lang  = $fManager->getLanguageID($lang);

				$db      = JFactory::getDbo();
				$dbQuery = $db->getQuery(true);
				$dbQuery->select('fc.reference_id')
					->from('#__falang_content fc')
					->where('fc.value = ' . $dbQuery->q($segment))
					->where('fc.language_id = ' . $dbQuery->q($id_lang))
					->where('fc.reference_field = ' . $dbQuery->q('alias'))
					->where('fc.published = 1')
					->where('fc.reference_table = ' . $dbQuery->q('content'));

				$db->setQuery($dbQuery);
				$db->execute();
				$num_rows = $db->getNumRows();
				//case no alias translated by falang need to find the content alias
				//TODO filter by catid too in case
				if (empty($num_rows)){
					//get category
					if (isset($query['view']) && $query['view'] == 'category'){
						$cat_id = $query['id'];
					}

					$dbQuery = $db->getQuery(true);
					$dbQuery->select('c.id');
					$dbQuery->from('#__content c');
					$dbQuery->where('c.alias = ' . $dbQuery->q($segment));

					if (isset($cat_id)){
						$dbQuery->where('c.catid = ' . $dbQuery->q($cat_id));
					}

					$db->setQuery($dbQuery);
					$db->execute();
					$article_id = $db->loadResult();
					return (int) $article_id;
				}
				//most case only 1 alias
				if (isset($num_rows) && $num_rows == 1){
					$article_id = $db->loadResult();
					if (isset($article_id))
					{
						return (int) $article_id;
					}
				} else {
					$article_ids = $db->loadObjectList();
					//2 alias with the same name look the right one
					foreach ($article_ids as $id){
						$dbquery = $db->getQuery(true);
						$dbquery->select($dbquery->qn('id'))
							->from($dbquery->qn('#__content'))
							->where('id = ' . $dbquery->q($id->reference_id))
							->where('catid = ' . $dbquery->q($query['id']));
						$db->setQuery($dbquery);
						$db->execute();
						$num_rows = $db->getNumRows();
						if (isset($num_rows)) {
							return (int) $db->loadResult();
						}
					}
				}
			} else	{
				$db      = JFactory::getDbo();
				$dbquery = $db->getQuery(true);
				$dbquery->select($dbquery->qn('id'))
					->from($dbquery->qn('#__content'))
					->where('alias = ' . $dbquery->q($segment))
					->where('catid = ' . $dbquery->q($query['id']));
				$db->setQuery($dbquery);

				return (int) $db->loadResult();
			}
		}

		return (int) $segment;
	}

}

NexusLeads