2006-12-02 04:36:16 +00:00
< ? php
/*
2009-01-27 21:34:02 +00:00
* e107 website system
*
2013-03-26 12:16:55 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2009-01-27 21:34:02 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* List Class
*
*
2006-12-02 04:36:16 +00:00
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
2009-01-27 21:34:02 +00:00
/**
2010-01-10 12:19:53 +00:00
* Base class for list_new plugin
*
* @ package e107_plugins
* @ subpackage list_new
2009-01-27 21:34:02 +00:00
*/
2010-01-10 12:19:53 +00:00
2009-01-27 21:34:02 +00:00
/**
* class listclass
* The base class
*/
class listclass
{
var $defaultArray ;
var $sections ;
var $titles ;
2021-01-22 13:44:10 -08:00
private $content_types = array ();
2009-01-27 21:34:02 +00:00
var $content_name ;
var $list_pref ;
var $mode ;
2011-05-28 11:17:03 +00:00
var $shortcodes = FALSE ;
2021-01-08 17:00:23 -08:00
private $pf ; // profanity filter class.
public $data ;
2009-01-27 21:34:02 +00:00
/**
* constructor
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $mode the mode of the caller ( default , admin )
* @ return void
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
2016-12-17 10:15:10 -08:00
function __construct ( $mode = '' )
2009-01-27 21:34:02 +00:00
{
global $TEMPLATE_LIST_NEW , $list_shortcodes ;
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
$this -> plugin_dir = e_PLUGIN . " list_new/ " ;
$this -> e107 = e107 :: getInstance ();
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//language
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( $this -> plugin_dir . " languages/ " . e_LANGUAGE . " .php " );
2009-05-04 19:57:48 +00:00
2009-01-27 21:34:02 +00:00
//template
if ( is_readable ( THEME . " list_template.php " ))
{
require_once ( THEME . " list_template.php " );
}
2009-05-04 19:57:48 +00:00
else
2009-01-27 21:34:02 +00:00
{
require_once ( $this -> plugin_dir . " list_template.php " );
}
$this -> template = $TEMPLATE_LIST_NEW ;
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//shortcodes
require_once ( $this -> plugin_dir . " list_shortcodes.php " );
2011-05-28 11:17:03 +00:00
// $this->shortcodes = $list_shortcodes;
$this -> shortcodes = new list_shortcodes ();
$this -> shortcodes -> rc = $this ;
2006-12-02 04:36:16 +00:00
2016-12-03 13:07:14 -08:00
2009-01-27 21:34:02 +00:00
if ( $mode == 'admin' )
{
require_once ( $this -> plugin_dir . " list_admin_class.php " );
$this -> admin = new list_admin ( $this );
}
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//default sections (present in this list plugin)
2009-05-04 19:57:48 +00:00
$this -> defaultArray = array ( " news " , " comment " , " members " );
2009-01-27 21:34:02 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
/**
* helper method , parse the template
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $template the template to parse
* @ return string
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function parseTemplate ( $template )
{
//for each call to the template, provide the correct data set through load_globals
2011-05-28 11:17:03 +00:00
//list_shortcodes::load_globals();
2021-01-22 13:44:10 -08:00
return e107 :: getParser () -> parseTemplate ( varset ( $this -> template [ $template ]), true , $this -> shortcodes );
2009-01-27 21:34:02 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
/**
* get preferences , retrieve all preferences from core table
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
2006-12-02 04:36:16 +00:00
function getListPrefs ()
{
2017-11-17 21:25:42 +01:00
$listPrefs = e107 :: pref ( 'list_new' ); //TODO Convert from old format to new.
2014-05-28 22:37:33 -07:00
2017-11-17 15:37:01 +01:00
//insert default preferences
if ( empty ( $listPrefs ))
{
$listPrefs = $this -> list_pref = $this -> getDefaultPrefs ();
e107 :: getPlugConfig ( 'list_new' ) -> reset () -> setPref ( $listPrefs ) -> save ( true );
}
return $listPrefs ;
2014-05-28 22:37:33 -07:00
/*
2013-03-26 12:16:55 +01:00
$sql = e107 :: getDb ();
2006-12-02 04:36:16 +00:00
//check preferences from database
2013-03-26 12:16:55 +01:00
$num_rows = $sql -> gen ( " SELECT * FROM #core WHERE e107_name='list' " );
$row = $sql -> fetch ();
2006-12-02 04:36:16 +00:00
//insert default preferences
2009-01-27 21:34:02 +00:00
if ( empty ( $row [ 'e107_value' ]))
{
$this -> getSections ();
$this -> list_pref = $this -> getDefaultPrefs ();
$tmp = $this -> e107 -> arrayStorage -> WriteArray ( $this -> list_pref );
2006-12-02 04:36:16 +00:00
2013-03-26 12:16:55 +01:00
$sql -> insert ( " core " , " 'list', ' $tmp ' " );
$sql -> gen ( " SELECT * FROM #core WHERE e107_name='list' " );
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
$this -> list_pref = $this -> e107 -> arrayStorage -> ReadArray ( $row [ 'e107_value' ]);
return $this -> list_pref ;
2014-05-28 22:37:33 -07:00
*/
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
/**
* prepareSection checks if the sections should be displayed
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $mode the mode of the area ( menu / page - new / recent )
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function prepareSection ( $mode )
{
2006-12-02 04:36:16 +00:00
$len = strlen ( $mode ) + 9 ;
2009-01-27 21:34:02 +00:00
$sections = array ();
2006-12-02 04:36:16 +00:00
//get all sections to use
2009-01-27 21:34:02 +00:00
foreach ( $this -> list_pref as $key => $value )
{
if ( substr ( $key , - $len ) == " _ { $mode } _display " && $value == " 1 " )
{
2006-12-02 04:36:16 +00:00
$sections [] = substr ( $key , 0 , - $len );
}
}
return $sections ;
}
2009-01-27 21:34:02 +00:00
/**
* prepareSectionArray parses the preferences for each section
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $mode the mode of the area ( menu / page - new / recent )
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function prepareSectionArray ( $mode )
{
2006-12-02 04:36:16 +00:00
//section reference
2020-12-20 11:50:10 -08:00
for ( $i = 0 , $iMax = count ( $this -> sections ); $i < $iMax ; $i ++ )
2009-01-27 21:34:02 +00:00
{
$s = $this -> sections [ $i ];
2015-02-14 23:34:15 -08:00
if ( vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _display " ]) == '1' )
2009-01-27 21:34:02 +00:00
{
2015-02-14 23:34:15 -08:00
$arr [ $s ][ 'caption' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _caption " ]);
$arr [ $s ][ 'display' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _display " ]);
$arr [ $s ][ 'open' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _open " ]);
$arr [ $s ][ 'author' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _author " ]);
$arr [ $s ][ 'category' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _category " ]);
$arr [ $s ][ 'date' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _date " ]);
$arr [ $s ][ 'icon' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _icon " ]);
$arr [ $s ][ 'amount' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _amount " ]);
$arr [ $s ][ 'order' ] = vartrue ( $this -> list_pref [ $s . " _ " . $mode . " _order " ]);
2013-03-26 12:16:55 +01:00
$arr [ $s ][ 'section' ] = $s ;
2021-01-08 17:00:23 -08:00
2006-12-02 04:36:16 +00:00
}
2021-01-08 17:00:23 -08:00
2006-12-02 04:36:16 +00:00
}
//sort array on order values set in preferences
2020-12-08 12:21:12 -08:00
usort ( $arr , function ( $e , $f )
{
return $e [ " order " ] == $f [ " order " ] ? 0 : ( $e [ " order " ] > $f [ " order " ] ? 1 : - 1 );
});
2006-12-02 04:36:16 +00:00
return $arr ;
}
2009-01-27 21:34:02 +00:00
/**
* getDefaultSections loads all default 'core' sections from the constructor
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return void
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function getDefaultSections ()
{
2006-12-02 04:36:16 +00:00
//default always present sections
2020-12-20 11:50:10 -08:00
for ( $i = 0 , $iMax = count ( $this -> defaultArray ); $i < $iMax ; $i ++ )
2009-01-27 21:34:02 +00:00
{
$this -> sections [] = $this -> defaultArray [ $i ];
$this -> titles [] = $this -> defaultArray [ $i ];
2006-12-02 04:36:16 +00:00
}
return ;
}
//content needs this to split each main parent into separate sections
2009-01-27 21:34:02 +00:00
/**
* getContentSections loads all top level content categories
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $mode ( default , add )
* @ return void
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function getContentSections ( $mode = '' )
2006-12-02 04:36:16 +00:00
{
2013-03-29 00:03:36 +01:00
$sql = e107 :: getDb ();
2009-01-27 21:34:02 +00:00
global $pref ;
2006-12-02 04:36:16 +00:00
2009-05-04 19:57:48 +00:00
if ( ! $content_install = isset ( $pref [ 'plug_installed' ][ 'content' ]))
2007-08-08 19:34:52 +00:00
{
2009-01-27 21:34:02 +00:00
return ;
2006-12-02 04:36:16 +00:00
}
2021-01-08 17:00:23 -08:00
$content_name = '' ;
2009-01-27 21:34:02 +00:00
$content_types = array ();
//get top level categories
2013-03-26 12:16:55 +01:00
if ( $mainparents = $sql -> gen ( " SELECT content_id, content_heading FROM #pcontent WHERE content_parent = '0' AND (content_datestamp=0 || content_datestamp < " . time () . " ) AND (content_enddate=0 || content_enddate> " . time () . " ) ORDER BY content_heading " ))
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
$content_name = 'content' ;
2013-03-26 12:16:55 +01:00
while ( $row = $sql -> fetch ())
2006-12-02 04:36:16 +00:00
{
$content_types [] = " content_ " . $row [ 'content_id' ];
2015-02-14 23:34:15 -08:00
if ( vartrue ( $mode ) == " add " )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
$this -> sections [] = " content_ " . $row [ 'content_id' ];
$this -> titles [] = $content_name . " : " . $row [ 'content_heading' ];
2006-12-02 04:36:16 +00:00
}
}
2006-12-31 14:46:30 +00:00
}
2009-01-27 21:34:02 +00:00
$this -> content_types = array_unique ( $content_types );
$this -> content_name = $content_name ;
2006-12-02 04:36:16 +00:00
return ;
}
2009-01-27 21:34:02 +00:00
/**
* getSections loads all sections
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return void
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
2006-12-02 04:36:16 +00:00
function getSections ()
{
2021-01-22 13:44:10 -08:00
$list = e107 :: getPref ( 'e_list_list' , array ());
2009-01-27 21:34:02 +00:00
$this -> getDefaultSections ();
2006-12-02 04:36:16 +00:00
2021-01-22 13:44:10 -08:00
if ( ! empty ( $list ))
2006-12-02 04:36:16 +00:00
{
2021-01-22 13:44:10 -08:00
foreach ( $list as $file )
2006-12-02 04:36:16 +00:00
{
2021-01-22 13:44:10 -08:00
if ( $plugin_installed = e107 :: isInstalled ( $file ))
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
if ( $file == " content " )
{
$this -> getContentSections ( " add " );
}
else
{
$this -> sections [] = $file ;
$this -> titles [] = $file ;
}
2006-12-02 04:36:16 +00:00
}
}
}
return ;
}
2009-01-27 21:34:02 +00:00
/**
* getDefaultPrefs retrieve all default preferences ( if none present )
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
2006-12-02 04:36:16 +00:00
function getDefaultPrefs ()
{
2021-01-22 13:44:10 -08:00
$pref = e107 :: getPref ();
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
$prf = array ();
2006-12-02 04:36:16 +00:00
//section preferences
2020-12-20 11:50:10 -08:00
for ( $i = 0 , $iMax = count ( $this -> sections ); $i < $iMax ; $i ++ )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
$s = $this -> sections [ $i ];
if ( ! in_array ( $this -> sections [ $i ], $this -> defaultArray ))
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
if ( ! in_array ( $s , $this -> content_types ))
2006-12-02 04:36:16 +00:00
{
2013-03-26 12:16:55 +01:00
if ( $plugin_installed = isset ( $pref [ 'plug_installed' ][ e107 :: getParser () -> toDB ( $s , true )]))
2006-12-02 04:36:16 +00:00
{
2021-01-08 17:00:23 -08:00
$prf [ $s . " _recent_menu_caption " ] = $s ;
$prf [ $s . " _recent_page_caption " ] = $s ;
$prf [ $s . " _new_menu_caption " ] = $s ;
$prf [ $s . " _new_page_caption " ] = $s ;
2006-12-02 04:36:16 +00:00
}
}
else
{
2021-01-08 17:00:23 -08:00
$prf [ $s . " _recent_menu_caption " ] = $this -> titles [ $i ];
$prf [ $s . " _recent_page_caption " ] = $this -> titles [ $i ];
$prf [ $s . " _new_menu_caption " ] = $this -> titles [ $i ];
$prf [ $s . " _new_page_caption " ] = $this -> titles [ $i ];
2006-12-02 04:36:16 +00:00
}
}
else
{
2021-01-08 17:00:23 -08:00
$prf [ $s . " _recent_menu_caption " ] = $s ;
$prf [ $s . " _recent_page_caption " ] = $s ;
$prf [ $s . " _new_menu_caption " ] = $s ;
$prf [ $s . " _new_page_caption " ] = $s ;
2006-12-02 04:36:16 +00:00
}
2021-01-08 17:00:23 -08:00
$prf [ $s . " _recent_menu_display " ] = " 1 " ;
$prf [ $s . " _recent_menu_open " ] = " 0 " ;
$prf [ $s . " _recent_menu_author " ] = " 0 " ;
$prf [ $s . " _recent_menu_category " ] = " 0 " ;
$prf [ $s . " _recent_menu_date " ] = " 1 " ;
$prf [ $s . " _recent_menu_amount " ] = " 5 " ;
$prf [ $s . " _recent_menu_order " ] = ( $i + 1 );
$prf [ $s . " _recent_menu_icon " ] = '' ;
$prf [ $s . " _recent_page_display " ] = " 1 " ;
$prf [ $s . " _recent_page_open " ] = " 1 " ;
$prf [ $s . " _recent_page_author " ] = " 1 " ;
$prf [ $s . " _recent_page_category " ] = " 1 " ;
$prf [ $s . " _recent_page_date " ] = " 1 " ;
$prf [ $s . " _recent_page_amount " ] = " 10 " ;
$prf [ $s . " _recent_page_order " ] = ( $i + 1 );
$prf [ $s . " _recent_page_icon " ] = " 1 " ;
$prf [ $s . " _new_menu_display " ] = " 1 " ;
$prf [ $s . " _new_menu_open " ] = " 0 " ;
$prf [ $s . " _new_menu_author " ] = " 0 " ;
$prf [ $s . " _new_menu_category " ] = " 0 " ;
$prf [ $s . " _new_menu_date " ] = " 1 " ;
$prf [ $s . " _new_menu_amount " ] = " 5 " ;
$prf [ $s . " _new_menu_order " ] = ( $i + 1 );
$prf [ $s . " _new_menu_icon " ] = " 1 " ;
$prf [ $s . " _new_page_display " ] = " 1 " ;
$prf [ $s . " _new_page_open " ] = " 1 " ;
$prf [ $s . " _new_page_author " ] = " 1 " ;
$prf [ $s . " _new_page_category " ] = " 1 " ;
$prf [ $s . " _new_page_date " ] = " 1 " ;
$prf [ $s . " _new_page_amount " ] = " 10 " ;
$prf [ $s . " _new_page_order " ] = ( $i + 1 );
$prf [ $s . " _new_page_icon " ] = " 1 " ;
2006-12-02 04:36:16 +00:00
}
2006-12-31 14:46:30 +00:00
2006-12-02 04:36:16 +00:00
//new menu preferences
2009-01-27 21:34:02 +00:00
$prf [ 'new_menu_caption' ] = LIST_ADMIN_15 ;
$prf [ 'new_menu_icon_use' ] = " 1 " ;
$prf [ 'new_menu_icon_default' ] = " 1 " ;
$prf [ 'new_menu_char_heading' ] = " 20 " ;
$prf [ 'new_menu_char_postfix' ] = " ... " ;
$prf [ 'new_menu_datestyle' ] = " %d %b " ;
$prf [ 'new_menu_datestyletoday' ] = " %H:%M " ;
$prf [ 'new_menu_showempty' ] = " 1 " ;
$prf [ 'new_menu_openifrecords' ] = '' ;
2006-12-02 04:36:16 +00:00
//new page preferences
2009-01-27 21:34:02 +00:00
$prf [ 'new_page_caption' ] = LIST_ADMIN_15 ;
$prf [ 'new_page_icon_use' ] = " 1 " ;
$prf [ 'new_page_icon_default' ] = " 1 " ;
$prf [ 'new_page_char_heading' ] = '' ;
$prf [ 'new_page_char_postfix' ] = '' ;
$prf [ 'new_page_datestyle' ] = " %d %b " ;
$prf [ 'new_page_datestyletoday' ] = " %H:%M " ;
$prf [ 'new_page_showempty' ] = " 1 " ;
$prf [ 'new_page_colomn' ] = " 1 " ;
$prf [ 'new_page_welcometext' ] = LIST_ADMIN_16 ;
$prf [ 'new_page_timelapse' ] = " 1 " ;
$prf [ 'new_page_timelapse_days' ] = " 30 " ;
$prf [ 'new_page_openifrecords' ] = '' ;
2006-12-02 04:36:16 +00:00
//recent menu preferences
2009-01-27 21:34:02 +00:00
$prf [ 'recent_menu_caption' ] = LIST_ADMIN_14 ;
$prf [ 'recent_menu_icon_use' ] = " 1 " ;
$prf [ 'recent_menu_icon_default' ] = " 1 " ;
$prf [ 'recent_menu_char_heading' ] = " 20 " ;
$prf [ 'recent_menu_char_postfix' ] = " ... " ;
$prf [ 'recent_menu_datestyle' ] = " %d %b " ;
$prf [ 'recent_menu_datestyletoday' ] = " %H:%M " ;
$prf [ 'recent_menu_showempty' ] = '' ;
$prf [ 'recent_menu_openifrecords' ] = '' ;
2006-12-02 04:36:16 +00:00
//recent page preferences
2009-01-27 21:34:02 +00:00
$prf [ 'recent_page_caption' ] = LIST_ADMIN_14 ;
$prf [ 'recent_page_icon_use' ] = " 1 " ;
$prf [ 'recent_page_icon_default' ] = " 1 " ;
$prf [ 'recent_page_char_heading' ] = '' ;
$prf [ 'recent_page_char_postfix' ] = '' ;
$prf [ 'recent_page_datestyle' ] = " %d %b " ;
$prf [ 'recent_page_datestyletoday' ] = " %H:%M " ;
$prf [ 'recent_page_showempty' ] = '' ;
$prf [ 'recent_page_colomn' ] = " 1 " ;
$prf [ 'recent_page_welcometext' ] = LIST_ADMIN_13 ;
$prf [ 'recent_page_openifrecords' ] = '' ;
return $prf ;
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
/**
* displaySection , prepare and render a section
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param array $arr the array of preferences for this section
* @ return string
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function displaySection ( $arr )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
//set settings
$this -> settings = $arr ;
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//get content sections
$this -> getContentSections ();
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//load e_list file
$this -> data = $this -> load_elist ();
2011-05-28 11:17:03 +00:00
//$this->shortcodes->rc->data = $this->data;
2006-12-02 04:36:16 +00:00
2016-12-03 13:07:14 -08:00
2009-01-27 21:34:02 +00:00
//set record variables
$this -> row = array ();
$this -> row [ 'caption' ] = '' ;
$this -> row [ 'icon' ] = '' ;
$this -> row [ 'date' ] = '' ;
$this -> row [ 'heading' ] = '' ;
$this -> row [ 'author' ] = '' ;
$this -> row [ 'category' ] = '' ;
$this -> row [ 'info' ] = '' ;
$text = '' ;
switch ( $this -> mode )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
case 'recent_menu' :
$text .= $this -> parseRecord ( 'MENU_RECENT' );
break ;
case 'new_menu' :
$text .= $this -> parseRecord ( 'MENU_NEW' );
break ;
case 'recent_page' :
$text .= $this -> parseRecord ( 'PAGE_RECENT' );
break ;
case 'new_page' :
$text .= $this -> parseRecord ( 'PAGE_NEW' );
break ;
}
return $text ;
}
/**
* parseRecord renders the items within a section
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $area the area for display
* @ return string
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function parseRecord ( $area )
{
if ( ! in_array ( $area , array ( 'MENU_RECENT' , 'MENU_NEW' , 'PAGE_RECENT' , 'PAGE_NEW' )))
{
return ;
}
//echo "parse: ".$area."_START<br />";
$text = $this -> parseTemplate ( $area . '_START' );
if ( is_array ( $this -> data [ 'records' ]))
{
foreach ( $this -> data [ 'records' ] as $this -> row )
2006-12-02 04:36:16 +00:00
{
2011-05-28 11:17:03 +00:00
$this -> shortcodes -> row = $this -> row ;
2009-01-27 21:34:02 +00:00
//echo "parse: ".$area."<br />";
$text .= $this -> parseTemplate ( $area );
2006-12-02 04:36:16 +00:00
}
}
2009-01-27 21:34:02 +00:00
elseif ( ! is_array ( $this -> data [ 'records' ]) && $this -> data [ 'records' ] != " " )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
if ( $this -> list_pref [ $this -> mode . " _showempty " ])
2006-12-02 04:36:16 +00:00
{
2011-05-28 11:17:03 +00:00
// $this->row['heading'] = $this->data['records'];
$this -> shortcodes -> row [ 'heading' ] = $this -> data [ 'records' ];
2009-01-27 21:34:02 +00:00
//echo "parse: ".$area."<br />";
$text .= $this -> parseTemplate ( $area );
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
}
//echo "parse: ".$area."_END<br />";
$text .= $this -> parseTemplate ( $area . '_END' );
return $text ;
}
/**
* load_elist loads and checks all e_list . php files
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function load_elist ()
{
$listArray = '' ;
//require is needed here instead of require_once, since both the menu and the page could be visible at the same time
if ( is_array ( $this -> content_types ) && in_array ( $this -> settings [ 'section' ], $this -> content_types ))
{
$file = $this -> content_name ;
if ( is_readable ( e_PLUGIN . $file . " /e_list.php " ))
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
$this -> mode_content = $this -> settings [ 'section' ];
//echo "require: ".e_PLUGIN.$file."/e_list.php<br />";
require_once ( e_PLUGIN . $file . " /e_list.php " );
$listArray = $this -> load_data ( $file );
2006-12-02 04:36:16 +00:00
}
}
2009-01-27 21:34:02 +00:00
else
{
$file = $this -> settings [ 'section' ];
if ( in_array ( $file , $this -> defaultArray ))
2006-12-31 14:46:30 +00:00
{
2009-01-27 21:34:02 +00:00
//echo "require: ".$this->plugin_dir."section/list_".$file.".php<br />";
require_once ( $this -> plugin_dir . " section/list_ " . $file . " .php " );
$listArray = $this -> load_data ( $file );
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
else
{
2015-02-07 13:38:29 -08:00
if ( e107 :: isInstalled ( $file ))
2009-01-27 21:34:02 +00:00
{
if ( is_readable ( e_PLUGIN . $file . " /e_list.php " ))
{
//echo "require: ".e_PLUGIN.$file."/e_list.php<br />";
require_once ( e_PLUGIN . $file . " /e_list.php " );
$listArray = $this -> load_data ( $file );
}
2006-12-02 04:36:16 +00:00
}
}
}
2009-01-27 21:34:02 +00:00
return $listArray ;
}
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
/**
* load_data calls the class from the e_list file and retrieves the data
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $file the section to load ( class name )
* @ return array
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function load_data ( $file )
{
$name = " list_ " . $file ;
2006-12-31 14:46:30 +00:00
2020-12-18 19:55:12 -08:00
$listArray = array ();
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//instantiate the class with this as parm
2020-12-18 19:55:12 -08:00
if ( class_exists ( $name ))
2009-01-27 21:34:02 +00:00
{
$class = new $name ( $this );
//call method
if ( ! method_exists ( $class , 'getListData' ))
{
2020-12-18 19:55:12 -08:00
return $listArray ;
2009-01-27 21:34:02 +00:00
//echo "method getListData doesn't exist in class $class<br />";
}
else
{
$listArray = $class -> getListData ();
2011-05-28 11:17:03 +00:00
if ( e107 :: getPref ( 'profanity_filter' ))
{
2013-03-26 12:16:55 +01:00
$tp = e107 :: getParser ();
2021-01-08 17:00:23 -08:00
if ( ! is_object ( $this -> pf ))
2011-05-28 11:17:03 +00:00
{
2021-01-08 17:00:23 -08:00
$this -> pf = new e_profanityFilter ;
2011-05-28 11:17:03 +00:00
}
foreach ( $listArray as $k => $v )
{
if ( isset ( $v [ 'heading' ]))
{
2021-01-08 17:00:23 -08:00
$listArray [ $k ][ 'heading' ] = $this -> pf -> filterProfanities ( $v [ 'heading' ]);
2011-05-28 11:17:03 +00:00
}
}
}
2006-12-02 04:36:16 +00:00
}
}
2020-12-18 19:55:12 -08:00
2009-01-27 21:34:02 +00:00
return $listArray ;
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
/**
* get datestamp last visit
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return int datestamp
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function getlvisit ()
{
global $qs ;
2006-12-02 04:36:16 +00:00
2010-11-01 22:10:42 +00:00
$lvisit = defined ( 'USERLV' ) ? USERLV : time () + 1000 ; // Set default value
2017-01-11 13:30:26 -08:00
if ( ! empty ( $qs [ 0 ]) && $qs [ 0 ] === " new " )
2009-01-27 21:34:02 +00:00
{
2017-01-11 13:30:26 -08:00
if ( ! empty ( $this -> list_pref [ 'new_page_timelapse' ]))
2009-01-27 21:34:02 +00:00
{
2017-01-11 13:30:26 -08:00
if ( ! empty ( $this -> list_pref [ 'new_page_timelapse_days' ]) && is_numeric ( $this -> list_pref [ 'new_page_timelapse_days' ]))
2009-01-27 21:34:02 +00:00
{
$days = $this -> list_pref [ 'new_page_timelapse_days' ];
}
else
{
2006-12-02 04:36:16 +00:00
$days = " 30 " ;
}
2009-01-27 21:34:02 +00:00
if ( isset ( $qs [ 1 ]) && is_numeric ( $qs [ 1 ]) && $qs [ 1 ] <= $days )
{
2006-12-02 04:36:16 +00:00
$lvisit = time () - $qs [ 1 ] * 86400 ;
}
}
}
return $lvisit ;
}
2009-01-27 21:34:02 +00:00
/**
* get bullet icon , either use the icon set in admin or the default theme bullet
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $icon the icon to use as set in admin
* @ return string $bullet
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function getBullet ( $icon )
2006-12-02 04:36:16 +00:00
{
2009-01-27 21:34:02 +00:00
$default_bullet = '' ;
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
if ( $this -> list_pref [ $this -> mode . " _icon_default " ])
2006-12-02 04:36:16 +00:00
{
2009-08-23 10:57:51 +00:00
if ( defined ( 'BULLET' ))
2006-12-02 04:36:16 +00:00
{
2009-08-23 10:57:51 +00:00
$default_bullet = '<img src="' . THEME . 'images/' . BULLET . '" alt="" class="icon" />' ;
}
elseif ( file_exists ( THEME . 'images/bullet2.gif' ))
{
$default_bullet = '<img src="' . THEME . 'images/bullet2.gif" alt="" class="icon" />' ;
2006-12-02 04:36:16 +00:00
}
}
2009-01-27 21:34:02 +00:00
$icon_width = '8' ;
$icon_height = '8' ;
$style_pre = '' ;
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
if ( $this -> list_pref [ $this -> mode . " _icon_use " ])
{
if ( $icon )
{
if ( is_readable ( $this -> plugin_dir . " images/ " . $icon ))
{
2009-01-27 23:46:12 +00:00
$bullet = " <img src=' " . $this -> plugin_dir . " images/ " . $icon . " ' alt='' /> " ;
2006-12-02 04:36:16 +00:00
}
}
}
2015-02-14 23:34:15 -08:00
$bullet = vartrue ( $bullet , $default_bullet );
2006-12-02 04:36:16 +00:00
return $bullet ;
}
2009-01-27 21:34:02 +00:00
/**
* helper method , parse heading to specific length with postfix
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param string $heading the heading from the item record
* @ return string $heading the parsed heading
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function parse_heading ( $heading )
{
if ( $this -> list_pref [ $this -> mode . " _char_heading " ] && strlen ( $heading ) > $this -> list_pref [ $this -> mode . " _char_heading " ])
{
$heading = substr ( $heading , 0 , $this -> list_pref [ $this -> mode . " _char_heading " ]) . $this -> list_pref [ $this -> mode . " _char_postfix " ];
2006-12-02 04:36:16 +00:00
}
return $heading ;
}
2009-01-27 21:34:02 +00:00
/**
* helper method , format the date
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ param int $datestamp the datestamp of the item record
* @ return string the formatted date
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function getListDate ( $datestamp )
{
2006-12-02 04:36:16 +00:00
$datestamp += TIMEOFFSET ;
$todayarray = getdate ();
$current_day = $todayarray [ 'mday' ];
$current_month = $todayarray [ 'mon' ];
$current_year = $todayarray [ 'year' ];
$thisday = date ( " d " , $datestamp );
$thismonth = date ( " m " , $datestamp );
$thisyear = date ( " Y " , $datestamp );
//check and use the today date style if day is today
2009-01-27 21:34:02 +00:00
if ( $thisyear == $current_year )
{
if ( $thismonth == $current_month )
{
if ( $thisday == $current_day )
{
$datepreftoday = $this -> list_pref [ $this -> mode . " _datestyletoday " ];
2021-11-25 10:18:53 -08:00
return eShims :: strftime ( $datepreftoday , $datestamp );
2006-12-02 04:36:16 +00:00
}
}
}
//else use default date style
2009-01-27 21:34:02 +00:00
$datepref = $this -> list_pref [ $this -> mode . " _datestyle " ];
2021-11-25 10:18:53 -08:00
return eShims :: strftime ( $datepref , $datestamp );
2006-12-02 04:36:16 +00:00
}
2009-01-27 21:34:02 +00:00
/**
* display timelapse element ( on newpage )
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return string the timelapse element
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function displayTimelapse ()
{
2013-03-26 12:16:55 +01:00
global $rs ; //FIXME $frm
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
if ( isset ( $this -> list_pref [ 'new_page_timelapse' ]) && $this -> list_pref [ 'new_page_timelapse' ])
{
if ( isset ( $this -> list_pref [ 'new_page_timelapse_days' ]) && is_numeric ( $this -> list_pref [ 'new_page_timelapse_days' ]))
{
$days = $this -> list_pref [ 'new_page_timelapse_days' ];
}
else
{
$days = '30' ;
}
$timelapse = 0 ;
if ( isset ( $qs [ 1 ]) && is_numeric ( $qs [ 1 ]) && $qs [ 1 ] <= $days )
{
$timelapse = $qs [ 1 ];
}
$url = $this -> plugin_dir . " list.php?new " ;
$selectjs = " onchange= \" if(this.options[this.selectedIndex].value != 'none') { return document.location=this.options[this.selectedIndex].value; } \" " ;
$this -> row [ 'timelapse' ] = LIST_MENU_6 ;
$this -> row [ 'timelapse' ] .= $rs -> form_select_open ( " timelapse " , $selectjs ) . $rs -> form_option ( LIST_MENU_5 , 0 , $url );
for ( $a = 1 ; $a <= $days ; $a ++ )
{
$this -> row [ 'timelapse' ] .= $rs -> form_option ( $a , ( $timelapse == $a ? '1' : '0' ), $url . " . " . $a );
}
$this -> row [ 'timelapse' ] .= $rs -> form_select_close ();
return $this -> parseTemplate ( 'TIMELAPSE_TABLE' );
}
return ;
}
/**
* display the page ( either recent or new )
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return string
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function displayPage ()
{
global $qs ;
2006-12-02 04:36:16 +00:00
2021-01-08 17:00:23 -08:00
$text = '' ;
2009-01-27 21:34:02 +00:00
//get preferences
if ( ! isset ( $this -> list_pref ))
{
$this -> list_pref = $this -> getListPrefs ();
2011-05-28 11:17:03 +00:00
$this -> shortcodes -> list_pref = $this -> list_pref ;
2009-01-27 21:34:02 +00:00
}
2009-05-04 19:57:48 +00:00
2009-01-27 21:34:02 +00:00
//get sections
$this -> sections = $this -> prepareSection ( $this -> mode );
$arr = $this -> prepareSectionArray ( $this -> mode );
//timelapse
2015-02-14 23:34:15 -08:00
if ( vartrue ( $qs [ 0 ]) == " new " )
2009-01-27 21:34:02 +00:00
{
$text .= $this -> displayTimelapse ();
}
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
$text .= $this -> parseTemplate ( 'COL_START' );
2006-12-02 04:36:16 +00:00
2009-01-27 21:34:02 +00:00
//welcometext
if ( $this -> list_pref [ $this -> mode . " _welcometext " ])
{
$text .= $this -> parseTemplate ( 'COL_WELCOME' );
}
//display the sections
$k = 0 ;
2016-12-03 13:07:14 -08:00
// print_a($arr);
2009-01-27 21:34:02 +00:00
foreach ( $arr as $sect )
{
2016-12-03 13:07:14 -08:00
$this -> shortcodes -> plugin = $sect [ 'section' ];
2009-01-27 21:34:02 +00:00
if ( $sect [ 'display' ] == '1' )
{
$sectiontext = $this -> displaySection ( $sect );
if ( $sectiontext != '' )
{
$v = $k / $this -> list_pref [ $this -> mode . " _colomn " ];
if ( intval ( $v ) == $v )
{
$text .= $this -> parseTemplate ( 'COL_ROWSWITCH' );
}
$text .= $this -> parseTemplate ( 'COL_CELL_START' );
$text .= $sectiontext ;
$text .= $this -> parseTemplate ( 'COL_CELL_END' );
$k ++ ;
}
}
}
$text .= $this -> parseTemplate ( 'COL_END' );
2006-12-02 04:36:16 +00:00
return $text ;
}
2009-01-27 21:34:02 +00:00
/**
* display the menu ( either recent or new )
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
* @ return string
2009-05-04 19:57:48 +00:00
*
2009-01-27 21:34:02 +00:00
*/
function displayMenu ()
{
//get preferences
if ( ! isset ( $this -> list_pref ))
{
$this -> list_pref = $this -> getListPrefs ();
2011-05-28 11:17:03 +00:00
$this -> shortcodes -> list_pref = $this -> list_pref ;
2009-01-27 21:34:02 +00:00
}
//get sections
$this -> sections = $this -> prepareSection ( $this -> mode );
$arr = $this -> prepareSectionArray ( $this -> mode );
2011-05-28 11:17:03 +00:00
2009-01-27 21:34:02 +00:00
//display the sections
$text = '' ;
foreach ( $arr as $sect )
{
if ( $sect [ 'display' ] == '1' )
{
$sectiontext = $this -> displaySection ( $sect );
if ( $sectiontext != '' )
{
$text .= $sectiontext ;
}
}
}
return $text ;
}
2006-12-02 04:36:16 +00:00
}
2020-08-10 15:49:44 -07:00