Location: PHPKode > projects > FarODP > farodp/includes/html/OpenDirectoryHTMLController.php
<?php

class OpenDirectoryHTMLController
{
	function doMainPage(&$node) {
		if (readURL('', BROWSE_HOST, $data))
		{
			if (($data = preprocessMainPage($data)) !== false)
			{
				if (processMainPage($data, $node) !== false)
				{
					return true;
				}
				else
				{
				    return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
		    $GLOBALS['action']->setAction('cannotBrowse');
		    return false;
		}
	}

	function doBrowse(&$cat, &$node) {
	    $writeCache = true;

		$cache = new OpenDirectoryXMLCacheObject(CACHE_DIR);

		if (ENABLE_CACHE)
		{
		    $cache->setName($cat);
		    if ($cache->exists())
		    {
		        if ((processBrowse($cache->read(), $node)) !== false)
		        {
					return true;
				}
				else
				{
				    return false;
				}

				$writeCache = false;
		    }
		}

		if (readURL(catURL($cat), BROWSE_HOST, $data))
		{
			if (($data = preprocessBrowse($data)) !== false)
			{
				if (processBrowse($data, $node) !== false)
				{
				    if (ENABLE_CACHE)
				    {
				        $cache->write($data);
				    }

				    return true;
				}
				else
				{
				    return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
		    $GLOBALS['action']->setAction('cannotBrowse');
		    return false;
		}
	}

	function doSearch(&$request, &$node) {
		// get queries

		$search = $request->getString('search', '');
		$searchResultStart = $request->getInt('start', 0);
		$searchResultCatAll = $request->getString('all', 'yes');
		$searchResultCat = $request->getString('cat', '', 500);
		$searchResultMoreCat = $request->getInt('morecat', 0);

		if (ROOT_CAT)
		{
			// if ROOT_CAT is enabled, only search in the ROOT_CAT

			if (($searchResultCatAll !== 'no'))
			{
				$searchResultCatAll = 'no';
				$searchResultCat = ROOT_CAT;
			}
			else
			{
				$searchResultCat = ROOT_CAT . $searchResultCat;
			}
		}
		else
		{
			if (!($searchResultCatAll === 'yes' || $searchResultCatAll === 'no'))
			{
				$searchResultCatAll = 'yes';
			}
		}

		// urlencode the searchstring so words with spaces are searched
		if (readURL(
		SEARCH_PATH . urlencode($search) .
		'&start=' . (($searchResultStart !== 0) ? $searchResultStart : '') .
		'&all=' . urlencode($searchResultCatAll) .
		'&cat=' . urlencode($searchResultCat) .
		(($searchResultMoreCat !== '') ? '&morecat=' . urlencode($searchResultMoreCat) : ''),
		SEARCH_HOST,
		$data))
		{
			if (($data = preprocessSearch($data)) !== false)
			{
				if (processSearch($data, $node) !== false)
				{
					return true;
				}
				else
				{
				    return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
		    $GLOBALS['action']->setAction('cannotSearch');
		    return false;
		}
	}
}

?>
Return current item: FarODP