protected static function _findItem($needles, $notCheckId = 0)
{
//$component =& JComponentHelper::getComponent('com_phocagallery');
// Don't check ID for specific views
$notCheckIdArray = array('categories');
$app = Factory::getApplication();
$menus = $app->getMenu('site', array());
$items = $menus->getItems('component', 'com_phocagallery');
if (!$items) {
return Factory::getApplication()->input->get('Itemid', 0, '', 'int');
//return null;
}
$match = null;
foreach ($needles as $needle => $id) {
if ($notCheckId == 0) {
foreach ($items as $item) {
// The view must match
// In case the view does not have any ID like categories view
// there is no need to compare to ID
if (@$item->query['view'] == $needle && (in_array($needle, $notCheckIdArray) || @$item->query['id'] == $id)) {
$match = $item;
break;
}
}
} else {
foreach ($items as $item) {
if (@$item->query['view'] == $needle) {
$match = $item;
break;
}
}
}
if (isset($match)) {
break;
}
}
return $match;
}