2009-12-17 16:00:56 +00:00
< ? php
/*
* e107 website system
*
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Sitelinks configuration module - News
*
2011-11-25 17:53:20 +00:00
* $URL $
* $Id $
2009-12-17 16:00:56 +00:00
*
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
//TODO Lans
2013-02-26 03:43:52 -08:00
class news_sitelink // include plugin-folder in the name.
2009-12-17 16:00:56 +00:00
{
function config ()
{
$links = array ();
2013-12-23 04:52:32 -08:00
$links [] = array (
'name' => " News Category List " ,
'function' => " news_category_list " ,
'description' => " "
);
$links [] = array (
'name' => " News Category Pages " ,
'function' => " news_category_page " ,
'description' => " "
);
2009-12-17 16:00:56 +00:00
$links [] = array (
'name' => " Last 10 News Items " ,
'function' => " last_ten " ,
'description' => " "
2017-03-15 15:56:17 -07:00
);
2009-12-17 16:00:56 +00:00
return $links ;
}
2013-12-23 04:52:32 -08:00
2017-03-15 15:56:17 -07:00
2013-12-23 04:52:32 -08:00
function news_category_page ()
{
return $this -> news_category_list ( 'category' );
}
2009-12-17 16:00:56 +00:00
2013-12-23 04:52:32 -08:00
function news_cats () // BC
{
return $this -> news_category_list ();
}
function news_category_list ( $type = null )
{
$sql = e107 :: getDb ();
$sublinks = array ();
// $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$query = " SELECT * FROM #news_category " ;
// $query .= "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") ";
$query .= " ORDER BY category_order ASC " ;
if ( $type == null )
{
$type = 'short' ;
}
$urlPath = 'news/list/' . $type ;
if ( $sql -> gen ( $query ))
{
while ( $row = $sql -> fetch ())
{
2016-12-15 09:22:54 -08:00
$row [ 'id' ] = $row [ 'category_id' ];
2013-12-23 04:52:32 -08:00
$sublinks [] = array (
'link_name' => $row [ 'category_name' ],
2016-12-15 09:22:54 -08:00
'link_url' => e107 :: getUrl () -> create ( $urlPath , $row , array ( 'allow' => 'id,category_sef,category_name,category_id' )), // 'news.php?extend.'.$row['news_id'],
2013-12-23 04:52:32 -08:00
'link_description' => $row [ 'category_meta_description' ],
'link_button' => '' ,
'link_category' => '' ,
'link_order' => '' ,
'link_parent' => '' ,
'link_open' => '' ,
'link_class' => 0
);
}
$sublinks [] = array (
'link_name' => LAN_MORE ,
'link_url' => e107 :: getUrl () -> create ( 'news/list/all' ),
'link_description' => '' ,
'link_button' => '' ,
'link_category' => '' ,
'link_order' => '' ,
'link_parent' => '' ,
'link_open' => '' ,
'link_class' => 0
);
return $sublinks ;
};
}
2009-12-17 16:00:56 +00:00
2017-03-15 15:56:17 -07:00
function last_ten ()
2009-12-17 16:00:56 +00:00
{
$sql = e107 :: getDb ();
$sublinks = array ();
$nobody_regexp = " '(^|,)( " . str_replace ( " , " , " | " , e_UC_NOBODY ) . " )(,| $ )' " ;
$query = " SELECT * FROM #news WHERE news_class REGEXP ' " . e_CLASS_REGEXP . " ' AND NOT (news_class REGEXP " . $nobody_regexp . " ) ORDER BY news_datestamp DESC LIMIT 10 " ;
2017-03-15 15:56:17 -07:00
2013-12-20 09:45:27 -08:00
if ( $sql -> gen ( $query ))
2009-12-17 16:00:56 +00:00
{
2013-12-20 09:45:27 -08:00
while ( $row = $sql -> fetch ())
2009-12-17 16:00:56 +00:00
{
$sublinks [] = array (
'link_name' => $row [ 'news_title' ],
2013-12-19 22:50:40 -08:00
'link_url' => e107 :: getUrl () -> create ( 'news/view/item' , $row , array ( 'allow' => 'news_sef,news_title,news_id' )), // 'news.php?extend.'.$row['news_id'],
2009-12-17 16:00:56 +00:00
'link_description' => $row [ 'news_summary' ],
'link_button' => '' ,
'link_category' => '' ,
'link_order' => '' ,
'link_parent' => '' ,
'link_open' => '' ,
'link_class' => intval ( $row [ 'news_class' ])
);
2017-03-15 15:56:17 -07:00
2009-12-17 16:00:56 +00:00
}
$sublinks [] = array (
2013-12-20 09:45:27 -08:00
'link_name' => LAN_MORE ,
'link_url' => e107 :: getUrl () -> create ( 'news/list/all' ),
2009-12-17 16:00:56 +00:00
'link_description' => '' ,
'link_button' => '' ,
'link_category' => '' ,
'link_order' => '' ,
'link_parent' => '' ,
'link_open' => '' ,
2020-12-29 08:04:52 -08:00
'link_class' => 0
2009-12-17 16:00:56 +00:00
);
2017-03-15 15:56:17 -07:00
2009-12-17 16:00:56 +00:00
return $sublinks ;
};
}
2013-12-23 04:52:32 -08:00
2009-12-17 16:00:56 +00:00
}