public function onAfterInitialise(){
$this->getCheckBoxes(self::$o,$this->params->get('pluginOptions'));//setup basic parameters
self::$o['debug'] =$this->params->get('debug');
if($this->app->isAdmin())
return;
self::$o['baselen'] =strlen(JURI::root());
self::$o['rootlen'] =strlen(JURI::root(true));
$p =JPluginHelper::getPlugin('content', 'pagebreak');
if(empty($p)){
self::$o['pageplugin'] =false;
return;
}
$p =new JRegistry($p->params);
$s =$p->get('style');
if(isset($s))
self::$o['pagestyle'] =$s;
if(self::$o['pagestyle']!="pages")
return;
if(self::$o["ysefpagination"]):
$router=$this->app->getRouter();
$router->attachParseRule(function(&$siteRouter,&$uri){//incoming URIs
$query=$uri->getQuery(true); //query as array
$path=$uri->getPath(); //path from base withourt leading slash
$this->queueMessage('parse: '.$path,1);
if(preg_match('~(.*?)(/?)section(s_all|_(\d+))$~',$path,$matches)){
if($matches[3]=='s-all'){
$query['showall']=1;//only on articles, not blogs
$query['limitstart']='';
}elseif($matches[4]==1){
$query['showall']='';
$query['limitstart']='';
}else{
$query['showall']='';
$q=$matches[4]-1;
$query['start']=$q;
}
$uri->setQuery($query);
$uri->setPath($matches[1]);
}
return array();
});
$router->attachBuildRule(function(&$siteRouter,&$uri){ //outgoing URIs
$query=$uri->getQuery(true); //query as array
$path=$uri->getPath(); //path from base withourt leading slash
if(!empty($query['showall']) && $query['showall']==1){
$path.="/sections_all"; //using underscore to avoid router hyphen bug in Joomla 3.3.6-
}else{
if(isset($query['limitstart'])){
if(!empty($query['limitstart'])){//if empty it is page 1
$p=$query['limitstart']+1;
$path.="/section_".$p;
}//else $path.="/section_0";
unset($query['limitstart']);
}if(isset($query['start'])){
$p=$query['start']+1;
$path.="/section_".$p;
}
}
unset($query['showall']);
unset($query['limitstart']);
unset($query['start']);
$uri->setPath($path);
$uri->setQuery($query);
return $uri;
},'postprocess');
endif;
//* end onAfterInitialise ----*///
}
public function onAfterRoute(){
if($this->app->isAdmin()) return;
$input =$this->app->input;
$option =$input->get('option'); //com_content,....
$view =$input->get('view'); //article,category,categories,or featured
self::$o['showall'] =$input->get('showall'); //pagination
if(self::$o['pagestyle']=='pages' && self::$o['showall']!=1){
self::$o['showall'] =false;
}else{
self::$o['showall'] =true; //whether whole page is displaying
}
if(is_null($input->get('format'))): //output is not rss or template
if($option=='com_content'):
switch($view):
case ('article'):
case('featured'):
self::$o['view']=$view; break;
case('category'):
case('categories'):
if($input->get('layout')=="blog") self::$o['view']="blog";
else self::$o['view']="list";
break;
default:
self::$o['view']="content"; //for addons
break;
endswitch;
elseif($view!='print' && $view!='form'):
self::$o['view']="other"; //it is another kind of HTML page, not RSS or form or printing
else:
return;
endif;
else:
return; //self::$o['view'] is now 'article', 'featured', 'blog', 'list', 'other', or false.
endif;
if(!((self::$o["ysefcontent"]||self::$o["ycanonical"]) &&self::$o['view']!=false && self::$o['view']!="other"))
return;//done with setting up view, proceeding to SEF
$id =$input->get('id'); //ID for article
$start =$input->get('start'); //pagination
$limitstart=$input->get('limitstart'); //
$Itemid =$input->get('Itemid'); //
if(empty($lang))$lang=0;
$menu =$this->app->getMenu();
$url='index.php?option='.$option.'&view='.$view;
if(self::$o['view']=='blog')$url.='&layout=blog';
if(is_null($id)&& $view=="categories")$id=0;//id isn't set for top-level categories list.
if($view=="featured"){ //featured may not be home page
$this->menuCheck('index.php?option=com_content&view=featured',$menu,$Itemid);
if(isset($Itemid)){ //featured page may be amywhere, so check menu
$this->menuCheck($url,$menu,$Itemid);
$url.='&Itemid='.$Itemid;
}else{
$menuItem=$menu->getItems('link',$url,true);
if(!empty($menuitem))$url.='&Itemid='.$Itemid;
}
}elseif(isset($id)){ //can't assume menu ID is correct
require_once (JPATH_SITE . '/components/com_content/helpers/route.php');
if($view=="article"){ //if its article, get ID for category to compare SEF url.
$ydb=JFactory::getDbo();
$catid =$input->get('catid');
$ydb->setQuery('select catid from #__content where id='.$id);
$cat=$ydb->loadResult();
if(isset($catid) && $cat!=$catid)
$this->redirect(JRoute::_($url.'&catid='.$catid));
$url=ContentHelperRoute::getArticleRoute($id, $catid,$lang);
}else{ //if its category or categories, get route.
$url=ContentHelperRoute::getCategoryRoute($id,$lang);
}
}elseif(isset($Itemid)){ //no content ID, determine ID from menu ID and issue redirect
$menuitem=$menu->getItem($Itemid);
if(!empty($menuitem)){
$menuid=$menuitem->id;
$url=new JURI($menuitem->link);
$this->redirect($url);
}else{
return;//404 condition
}
}else{
//todo: add additional checks to find article or category name in menu or in database
return;//404 condition
}
...