Click here to Skip to main content
16,020,568 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi.

I am new in PHP and I cant find where is the error in the code below and all
the time I get the error:

C#
Parse error: syntax error, unexpected end of file in cook.php on line 1


The code I have is

PHP
<?php /**
 * @version 1.0
 *
 */ 
defined('_JEXEC') or die('Restricted access');
function DJTabsBuildRoute(&$query)
{
	$segments = array();
	$app		= JFactory::getApplication();
	$menu		= $app->getMenu('site');
	if (empty($query['Itemid'])) {
		$menuItem = $menu->getActive();
	} else {
		$menuItem = $menu->getItem($query['Itemid']);
	}
	$mView	= (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
	$mId	= (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
	
	if(isset($query['view'])) {
		switch ($query['view']) {
			case 'category': {
				if ($mView && $query['view'] == $mView && isset($query['id'])) {
						
					unset($query['view']);
					
					if (intval($query['id']) == $mId) {
						unset($query['id']);
					} else {
						$segments[] = $query['id'];
						unset($query['id']);
					}
					
				} else {
											
					$segments[] = $query['view'];
					$segments[] = $query['id'];
					unset($query['view']);
					unset($query['id']);						
				}
				
				break;
			}
			case 'categories': {
				if ($query['view'] == $mView && isset($query['id'])) {
					
					unset($query['view']);
					
					if (intval($query['id']) == $mId) {
						unset($query['id']);						
					} else {
						$segments[] = $query['id'] ? $query['id'] : 'all';
						unset($query['id']);
					}
				}
				else {
					$segments[] = $query['view'];
					$segments[] = $query['id'] ? $query['id'] : 'all';
					unset($query['view']);
					unset($query['id']);					
				}
				break;
			}
		}
	}
	
	return $segments;
}
function DJTabsParseRoute($segments) {
	
	$app	= JFactory::getApplication();
	$menu	= $app->getMenu();
	$activemenu = $menu->getActive();
	$db = JFactory::getDBO();
	
	//$app->enqueueMessage(print_r($segments, true));
	$query=array();
	if (isset($segments[0])) {
		switch($segments[0]) {
			case 'categories': {
				$query['view'] = 'categories';
				if (isset($segments[1])) {
					$query['id'] = ($segments[1] == 'all') ? 0 : $segments[1];
				} 
				break;
			}
			case 'category': {
				$query['view'] = 'category';
				if (isset($segments[1])) {
					$query['id']= $segments[1];
				} 
				break;
			}
			default: {
				
				$query['view'] = 'category';
				if (isset($segments[0])) {
					$query['id']= $segments[0];
				} 
				
				break;
			}
		}
	}
	return $query;
} 
?>


Any help?

Thank you for your time.
Posted
Comments
Sergey Alexandrovich Kryukov 31-Jan-16 13:24pm    
Balance all your brackets...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900