2014-01-22 07:40:01 -08:00
< ? php
/*
* e107 website system
*
* Copyright ( C ) 2008 - 2014 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Related configuration module - News
*
*
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
class page_related // replace 'e_' with 'plugin-folder_'
{
private $chapterSef = array ();
private $chapterParent = array ();
2014-01-22 08:35:35 -08:00
private $chapterName = array ();
2014-01-22 07:40:01 -08:00
function __construct ()
{
$sql = e107 :: getDb ();
2014-01-22 08:35:35 -08:00
$books = $sql -> retrieve ( " SELECT chapter_id,chapter_sef,chapter_parent,chapter_name FROM #page_chapters ORDER BY chapter_id ASC " , true );
2014-01-22 07:40:01 -08:00
foreach ( $books as $row )
{
$id = $row [ 'chapter_id' ];
$this -> chapterSef [ $id ] = $row [ 'chapter_sef' ];
$this -> chapterParent [ $id ] = $row [ 'chapter_parent' ];
2014-01-22 08:35:35 -08:00
$this -> chapterName [ $id ] = $row [ 'chapter_name' ];
2014-01-22 07:40:01 -08:00
}
}
private function getSef ( $chapter )
{
return vartrue ( $this -> chapterSef [ $chapter ], '--sef-not-assigned--' );
}
private function getParent ( $chapter )
{
return varset ( $this -> chapterParent [ $chapter ], false );
}
function compile ( $tags , $parm = array ())
{
$sql = e107 :: getDb ();
$items = array ();
2014-10-04 11:26:29 -07:00
$tag_regexp = " '(^|,)( " . str_replace ( " , " , " | " , $tags ) . " )(,| $ )' " ;
2014-01-22 07:40:01 -08:00
$query = " SELECT * FROM #page WHERE page_id != " . $parm [ 'current' ] . " AND page_class REGEXP ' " . e_CLASS_REGEXP . " ' AND page_metakeys REGEXP " . $tag_regexp . " ORDER BY page_datestamp DESC LIMIT " . $parm [ 'limit' ];
if ( $sql -> gen ( $query ))
{
while ( $row = $sql -> fetch ())
{
$row [ 'chapter_sef' ] = $this -> getSef ( $row [ 'page_chapter' ]);
$book = $this -> getParent ( $row [ 'page_chapter' ]);
$row [ 'book_sef' ] = $this -> getSef ( $book );
2014-01-22 08:35:35 -08:00
$id = $row [ 'page_chapter' ];
$title = ( vartrue ( $this -> chapterName [ $id ])) ? $this -> chapterName [ $id ] . " | " . $row [ 'page_title' ] : $row [ 'page_title' ];
2014-01-22 07:40:01 -08:00
$items [] = array (
2014-01-22 08:35:35 -08:00
'title' => $title ,
2014-01-22 07:40:01 -08:00
'url' => e107 :: getUrl () -> create ( 'page/view/index' , $row ), // '{e_BASE}news.php?extend.'.$row['news_id'],
2016-03-10 17:32:36 -08:00
'summary' => $row [ 'page_metadescr' ],
'image' => $row [ 'menu_image' ]
2014-01-22 07:40:01 -08:00
);
}
return $items ;
}
else
{
2014-01-22 07:51:38 -08:00
// return array(array('title'=>$query,'url'=>''));
2014-01-22 07:40:01 -08:00
}
}
}
?>