2009-10-28 23:52:56 +00:00
< ? php
2006-12-02 04:36:16 +00:00
/*
2009-08-27 12:58:29 +00:00
* e107 website system
*
2016-12-20 20:26:00 +00:00
* Copyright ( C ) 2008 - 2016 e107 Inc ( e107 . org )
2009-08-27 12:58:29 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* e107 Admin Theme Handler
*
2009-10-28 23:45:46 +00:00
*/
2006-12-02 04:36:16 +00:00
2009-10-28 23:45:46 +00:00
if ( ! defined ( 'e107_INIT' ))
{
exit ;
}
2006-12-02 04:36:16 +00:00
2013-06-13 16:03:45 +02:00
2017-01-04 18:08:58 -08:00
// new in v.2.1.4
/**
2017-01-06 13:27:48 -08:00
* Retrieve info about themes on the system . - optimized for speed .
2017-01-04 18:08:58 -08:00
* Class e_theme
*/
class e_theme
{
private static $allowedCategories = array (
2021-01-27 08:45:34 -08:00
'generic' => 'generic' ,
'adult' => 'adult' ,
'blog' => 'blog' ,
// 'clan' => 'clan',
// 'children' => 'children',
'corporate' => 'corporate' ,
// 'forum' => 'forum',
'gaming' => 'gaming' ,
// 'gallery' => 'gallery',
'news' => 'news' ,
// 'social' => 'social',
// 'video' => 'video',
// 'multimedia' => 'multimedia'
2017-01-04 18:08:58 -08:00
);
2017-02-02 16:42:11 -08:00
private $_data = array ();
private $_current = null ;
private $_frontcss = null ;
private $_admincss = null ;
private $_legacy_themes = array ();
2017-01-04 18:08:58 -08:00
2017-01-30 07:52:25 -08:00
const CACHETIME = 120 ; // 2 hours
const CACHETAG = " Meta_theme " ;
2017-01-04 18:08:58 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $options
*/
2017-02-02 16:42:11 -08:00
function __construct ( $options = array ())
2017-01-04 18:08:58 -08:00
{
2020-01-18 11:59:18 +01:00
$options [ 'force' ] = isset ( $options [ 'force' ]) ? $options [ 'force' ] : false ;
2017-02-02 16:42:11 -08:00
if ( ! empty ( $options [ 'themedir' ]))
{
$this -> _current = $options [ 'themedir' ];
}
if ( ! defined ( 'E107_INSTALL' ))
{
$this -> _frontcss = e107 :: getPref ( 'themecss' );
$this -> _admincss = e107 :: getPref ( 'admincss' );
}
if ( empty ( $this -> _data ) || $options [ 'force' ] === true )
{
$this -> load ( $options [ 'force' ]);
}
2017-01-04 18:08:58 -08:00
2017-02-02 16:42:11 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return string []
*/
2021-01-27 08:45:34 -08:00
function getCategoryList ()
{
return self :: $allowedCategories ;
}
2019-06-11 15:53:08 -07:00
/**
* Load theme layout from html files
2020-04-28 14:00:19 -07:00
* Requires theme . html file in the theme root directory .
2019-06-11 15:53:08 -07:00
* @ param string $key layout name
* @ return array | bool
*/
2019-06-17 10:16:27 -07:00
public static function loadLayout ( $key = null , $theme = null )
2019-06-11 15:53:08 -07:00
{
2019-06-17 10:16:27 -07:00
if ( $theme === null )
{
2021-01-01 12:29:43 -08:00
$theme = deftrue ( 'USERTHEME' , e107 :: pref ( 'core' , 'sitetheme' ));
2021-01-01 14:05:51 -08:00
if ( defined ( 'PREVIEWTHEME' ))
{
$theme = PREVIEWTHEME ;
}
2019-06-17 10:16:27 -07:00
}
2019-06-11 15:53:08 -07:00
2021-01-01 14:05:51 -08:00
2019-06-11 15:53:08 -07:00
if ( ! is_readable ( e_THEME . $theme . " /layouts/ " . $key . " _layout.html " ) || ! is_readable ( e_THEME . $theme . " /theme.html " ))
{
return false ;
}
e107 :: getDebug () -> log ( " Using HTML layout: " . $key . " .html " );
$tmp = file_get_contents ( e_THEME . $theme . " /theme.html " );
$LAYOUT = array ();
list ( $LAYOUT [ '_header_' ], $LAYOUT [ '_footer_' ]) = explode ( " { ---LAYOUT---} " , $tmp , 2 );
2019-08-22 14:28:59 -07:00
$tp = e107 :: getParser ();
e107 :: getScParser () -> loadThemeShortcodes ( $theme );
if ( strpos ( $LAYOUT [ '_header_' ], '{---HEADER---}' ) !== false )
{
2021-01-27 08:45:34 -08:00
$LAYOUT [ '_header_' ] = str_replace ( '{---HEADER---}' , $tp -> parseTemplate ( '{HEADER}' ), $LAYOUT [ '_header_' ]);
2019-08-22 14:28:59 -07:00
}
if ( strpos ( $LAYOUT [ '_footer_' ], '{---FOOTER---}' ) !== false )
{
2021-01-27 08:45:34 -08:00
$LAYOUT [ '_footer_' ] = str_replace ( '{---FOOTER---}' , $tp -> parseTemplate ( '{FOOTER}' ), $LAYOUT [ '_footer_' ]);
2019-08-22 14:28:59 -07:00
}
2019-06-11 15:53:08 -07:00
$LAYOUT [ $key ] = file_get_contents ( e_THEME . $theme . " /layouts/ " . $key . " _layout.html " );
return $LAYOUT ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2021-01-01 14:05:51 -08:00
public static function showPreview ()
{
/*
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_theme.php " );
$text = " <br /><div class='indent'> " . TPVLAN_1 . " .</div><br /> " ;
$srch = array (
'{PREVIEWTHEMENAME}' => PREVIEWTHEME ,
'{e_ADMIN}' => e_ADMIN
); */
// $text = str_replace(array_keys($srch),$srch,$text);
echo " <div class='alert alert-warning alert-block'>Theme Preview Mode: <b> " . PREVIEWTHEME . " </b></div> " ;
// global $ns;
// $ns->tablerender(TPVLAN_2, $text);
}
2021-02-11 08:51:02 -08:00
/**
2021-02-11 16:39:50 -08:00
* Return an array of theme library or stylesheet values ( as defined in theme . xml ) that match the desired scope .
* @ note New in v2 . 3.1 +
2022-04-05 19:49:08 -07:00
* @ param string $type library | css
2021-02-11 08:51:02 -08:00
* @ param string $scope front | admin | all | auto ( as defined in theme . xml )
2021-02-11 16:39:50 -08:00
* @ return array
2021-02-11 08:51:02 -08:00
*/
public function getScope ( $type , $scope )
{
2021-02-11 16:39:50 -08:00
$validScopes = array ( 'auto' , 'all' , 'front' , 'admin' , 'wysiwyg' );
2021-02-11 08:51:02 -08:00
if ( $scope === 'auto' )
{
$scope = 'front' ;
if ( deftrue ( 'e_ADMIN_AREA' , false ))
{
$scope = 'admin' ;
}
}
2021-02-11 16:39:50 -08:00
elseif ( ! in_array ( $scope , $validScopes ))
{
return false ;
}
2021-02-11 08:51:02 -08:00
if ( $type === 'library' )
{
$themeXMLData = $this -> get ( 'library' );
}
2021-02-11 16:39:50 -08:00
elseif ( $type === 'css' )
2021-02-11 08:51:02 -08:00
{
$themeXMLData = $this -> get ( 'css' );
}
$ret = [];
2021-11-24 13:08:04 -08:00
if ( empty ( $themeXMLData ))
{
return $ret ;
}
2021-02-11 08:51:02 -08:00
foreach ( $themeXMLData as $info )
{
2021-02-11 16:39:50 -08:00
if ( ! isset ( $info [ 'scope' ]))
{
continue ;
}
2021-02-11 08:51:02 -08:00
$tmp = explode ( ',' , $info [ 'scope' ]);
2021-02-11 16:39:50 -08:00
$name = $info [ 'name' ];
2021-02-11 08:51:02 -08:00
foreach ( $tmp as $scp )
{
$scp = trim ( $scp );
2021-02-11 16:39:50 -08:00
if ( $scp === $scope || $scp === 'all' || $scope === 'all' )
2021-02-11 08:51:02 -08:00
{
unset ( $info [ 'scope' ]);
2021-02-11 16:39:50 -08:00
2021-02-11 08:51:02 -08:00
$ret [ $name ] = $info ;
}
}
}
return $ret ;
}
2021-02-11 16:39:50 -08:00
/**
* Returns an array of all files defined in theme . xml based on the specified scope .
* @ param $type
* @ param $scope
* @ return array
*/
function getThemeFiles ( $type , $scope )
{
$data = $this -> getScope ( $type , $scope );
$ret = [];
2021-02-11 08:51:02 -08:00
2021-02-11 16:39:50 -08:00
if ( $type === 'library' )
{
foreach ( $data as $name => $var )
{
2021-10-11 12:33:59 -07:00
$files = ! empty ( $var [ 'files' ]) ? array ( $var [ 'files' ]) : null ;
if ( strpos ( $name , 'fontawesome' ) !== false && ( $files === null ))
{
$files = array ( 'css' );
}
2021-02-11 16:39:50 -08:00
if ( $name === 'bootstrap' && (( int ) $var [ 'version' ] > 3 )) // quick fix.
{
$name .= ( string ) $var [ 'version' ];
}
elseif ( $name === 'fontawesome' && (( int ) $var [ 'version' ] > 4 )) // quick fix.
{
$name .= ( string ) $var [ 'version' ];
}
2021-10-11 12:33:59 -07:00
$ret [] = e107 :: library ( 'files' , $name , null , $files );
2021-02-11 16:39:50 -08:00
}
}
elseif ( $type === 'css' )
{
$ret [ 'css' ] = array ();
foreach ( $data as $file => $var )
{
$ret [ 'css' ][] = '{e_THEME}' . $this -> get ( 'path' ) . '/' . $file ;
}
}
return $ret ;
}
2021-02-11 08:51:02 -08:00
2019-06-17 10:16:27 -07:00
2017-02-02 16:42:11 -08:00
/**
2017-03-02 20:55:31 +01:00
* Load library dependencies .
*
2022-04-05 19:49:08 -07:00
* @ param string $scope front | admin | all | auto
2017-03-02 20:55:31 +01:00
*/
public function loadLibrary ( $scope = 'auto' )
{
2021-02-11 16:39:50 -08:00
$libraries = $this -> getScope ( 'library' , $scope );
2017-03-02 20:55:31 +01:00
if ( empty ( $libraries ))
{
return ;
}
2021-02-11 08:51:02 -08:00
$loaded = [];
2019-02-22 14:59:45 -08:00
2022-04-05 19:49:08 -07:00
$excludeCSS = ( string ) $this -> cssAttribute ( 'auto' , 'exclude' ); // current theme style
2021-02-11 16:39:50 -08:00
foreach ( $libraries as $name => $library )
2017-03-02 20:55:31 +01:00
{
2021-02-11 16:39:50 -08:00
if ( empty ( $name ))
2017-03-02 20:55:31 +01:00
{
continue ;
}
2022-04-05 19:49:08 -07:00
if ( $name === $excludeCSS )
{
$library [ 'files' ] = 'js' ; // load only JS, but not CSS since the style excluded it.
}
2021-02-11 16:39:50 -08:00
if ( $name === 'bootstrap' && ! empty ( $library [ 'version' ]))
2017-03-02 20:55:31 +01:00
{
2021-02-11 16:39:50 -08:00
if (( int ) $library [ 'version' ] > 3 ) // quick fix.
2018-03-08 13:45:08 -08:00
{
2021-02-11 16:39:50 -08:00
$name .= ( string ) $library [ 'version' ];
}
2018-03-08 13:45:08 -08:00
2021-02-11 16:39:50 -08:00
e107 :: getParser () -> setBootstrap ( $library [ 'version' ]);
2019-02-28 14:20:33 -08:00
2021-02-11 16:39:50 -08:00
if ( ! defined ( 'BOOTSTRAP' ))
{
define ( 'BOOTSTRAP' , ( int ) $library [ 'version' ]);
2019-02-22 14:59:45 -08:00
}
2021-02-11 16:39:50 -08:00
}
elseif ( $name === 'fontawesome' && ! empty ( $library [ 'version' ]))
{
if (( int ) $library [ 'version' ] > 4 ) // quick fix.
2019-02-22 14:59:45 -08:00
{
2021-02-11 16:39:50 -08:00
$name .= ( string ) $library [ 'version' ];
}
2019-02-22 14:59:45 -08:00
2021-02-11 16:39:50 -08:00
e107 :: getParser () -> setFontAwesome ( $library [ 'version' ]);
2019-02-28 14:20:33 -08:00
2021-02-11 16:39:50 -08:00
if ( ! defined ( 'FONTAWESOME' ))
{
define ( 'FONTAWESOME' , ( int ) $library [ 'version' ]);
2018-03-08 13:45:08 -08:00
}
2021-10-11 12:33:59 -07:00
if ( empty ( $library [ 'files' ])) // force CSS only for backward compatibility.
{
$library [ 'files' ] = 'css' ;
}
2021-02-11 16:39:50 -08:00
}
2018-03-08 13:45:08 -08:00
2021-10-11 12:33:59 -07:00
// support for 'files' attribute in theme.xml library tag. Specific which part of library to load. js || css or leave empty for both.
/* @see theme.xml <library name="fontawesome" version="5" scope="front" files=XXX /> */
$files = ! empty ( $library [ 'files' ]) ? array ( $library [ 'files' ]) : [ 'js' , 'css' ];
e107 :: library ( 'load' , $name , null , $files );
2021-02-11 16:39:50 -08:00
e107 :: library ( 'preload' , $name );
2020-12-02 13:17:23 -08:00
2021-02-11 16:39:50 -08:00
$loaded [] = $name ;
2017-03-02 20:55:31 +01:00
}
2021-02-11 08:51:02 -08:00
return $loaded ;
2017-03-02 20:55:31 +01:00
}
/**
* Get info on the current front or admin theme and selected style .
* ( ie . as found in theme . xml < stylesheets > )
*
2017-02-02 16:42:11 -08:00
* @ param string $mode
2017-03-02 20:55:31 +01:00
* front | admin | auto
* @ param string $var
* file | name | scope | exclude
*
* @ return mixed
2017-02-02 16:42:11 -08:00
*/
2017-03-02 20:55:31 +01:00
public function cssAttribute ( $mode = 'front' , $var = null )
2017-02-02 16:42:11 -08:00
{
$css = $this -> get ( 'css' );
if ( empty ( $css ))
{
return false ;
}
2017-03-02 20:55:31 +01:00
if ( $mode === 'auto' )
{
$mode = 'front' ;
if ( deftrue ( 'e_ADMIN_AREA' , false ))
{
$mode = 'admin' ;
}
}
foreach ( $css as $k => $v )
2017-02-02 16:42:11 -08:00
{
if ( $mode === 'front' && $v [ 'name' ] === $this -> _frontcss )
{
2017-03-02 20:55:31 +01:00
return ! empty ( $var ) ? varset ( $v [ $var ], null ) : $v ;
2017-02-02 16:42:11 -08:00
}
if ( $mode === 'admin' && $v [ 'name' ] === $this -> _admincss )
{
2017-03-02 20:55:31 +01:00
return ! empty ( $var ) ? varset ( $v [ $var ], null ) : $v ;
2017-02-02 16:42:11 -08:00
}
}
return false ;
2017-01-30 07:52:25 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return $this
*/
2017-01-30 07:52:25 -08:00
public function clearCache ()
{
e107 :: getCache () -> clear ( self :: CACHETAG , true );
2017-01-31 07:52:19 -08:00
return $this ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $text
* @ return array | string | string []
*/
2017-01-31 07:52:19 -08:00
public function upgradeThemeCode ( $text )
{
$search = array ();
$replace = array ();
$search [ 0 ] = '$HEADER ' ;
$replace [ 0 ] = '$HEADER["default"] ' ;
$search [ 1 ] = '$FOOTER ' ;
$replace [ 1 ] = '$FOOTER["default"] ' ;
// Early 0.6 and 0.7 Themes
$search [ 2 ] = '$CUSTOMHEADER ' ;
$replace [ 2 ] = '$HEADER["custom"] ' ;
$search [ 3 ] = '$CUSTOMFOOTER ' ;
$replace [ 3 ] = '$FOOTER["custom"] ' ;
//TODO Handle v1.x style themes. eg. $CUSTOMHEADER['something'];
$text = str_replace ( $_SESSION [ 'themebulder-remove' ], " " , $text );
$text = str_replace ( $search , $replace , $text );
return $text ;
2017-01-30 07:52:25 -08:00
2017-01-04 18:08:58 -08:00
}
2017-02-02 16:42:11 -08:00
/**
* Load data for all themes in theme directory .
* @ param bool | false $force
* @ return $this
*/
private function load ( $force = false )
{
$themeArray = array ();
2017-01-31 07:52:19 -08:00
2020-12-22 09:29:12 -08:00
2017-01-31 07:52:19 -08:00
2017-02-02 16:42:11 -08:00
$cacheTag = self :: CACHETAG ;
if ( $force === false && $tmp = e107 :: getCache () -> retrieve ( $cacheTag , self :: CACHETIME , true , true ))
{
$this -> _data = e107 :: unserialize ( $tmp );
return $this ;
}
2020-12-22 09:29:12 -08:00
// $array = scandir(e_THEME);
$array = e107 :: getFile () -> get_dirs ( e_THEME );
$tloop = 1 ;
2017-02-02 16:42:11 -08:00
foreach ( $array as $file )
{
2020-12-22 09:29:12 -08:00
if ( $file != " CVS " && $file != " templates " && is_readable ( e_THEME . $file . " /theme.php " ))
2017-02-02 16:42:11 -08:00
{
$themeArray [ $file ] = self :: getThemeInfo ( $file );
$themeArray [ $file ][ 'id' ] = $tloop ;
$tloop ++ ;
}
}
$cacheSet = e107 :: serialize ( $themeArray , 'json' );
e107 :: getCache () -> set ( $cacheTag , $cacheSet , true , true , true );
$this -> _data = $themeArray ;
}
/**
2020-12-22 09:29:12 -08:00
* Return a var from the current theme or all vars if $var is empty .
* @ param string | null $var
2017-02-02 16:42:11 -08:00
* @ param null $key
* @ return array | bool
*/
2017-02-03 07:56:54 -08:00
public function get ( $var = null , $key = null )
2017-02-02 16:42:11 -08:00
{
2017-02-03 07:56:54 -08:00
if ( empty ( $var ) && isset ( $this -> _data [ $this -> _current ]))
{
return $this -> _data [ $this -> _current ];
}
2017-02-02 16:42:11 -08:00
return isset ( $this -> _data [ $this -> _current ][ $var ]) ? $this -> _data [ $this -> _current ][ $var ] : false ;
}
2021-01-30 19:21:23 -08:00
/**
* Returns the fontawesome version of the currently loaded theme .
* @ return integer | false
*/
public function getFontAwesome ()
2022-03-27 12:10:41 -07:00
{
return $this -> getLibVersion ( 'fontawesome' );
}
/**
* Returns the libarie ' s version of the currently loaded theme .
* @ param string $name eg . 'fontawesome' or 'bootstrap'
* @ return false | int
*/
public function getLibVersion ( $name )
2021-01-30 19:21:23 -08:00
{
$lib = $this -> get ( 'library' );
foreach ( $lib as $var )
{
2022-03-27 12:10:41 -07:00
if ( $var [ 'name' ] === $name && ! empty ( $var [ 'version' ]) )
2021-01-30 19:21:23 -08:00
{
return ( int ) $var [ 'version' ];
}
}
return false ;
2022-03-27 12:10:41 -07:00
2021-01-30 19:21:23 -08:00
}
2019-01-24 11:36:14 -08:00
/**
* Rebuild URL without trackers , for matching against theme_layout prefs .
* @ param string $url
* @ return string
*/
2021-02-14 10:36:45 -08:00
private static function filterTrackers ( $url )
2019-01-24 11:36:14 -08:00
{
if ( strpos ( $url , '?' ) === false || empty ( $url ))
{
return $url ;
}
list ( $site , $query ) = explode ( '?' , $url );
parse_str ( $query , $get );
$get = eHelper :: removeTrackers ( $get );
2021-01-24 17:00:02 -08:00
return empty ( $get ) ? $site : $site . '?' . http_build_query ( $get );
2019-01-24 11:36:14 -08:00
}
2019-01-23 19:06:03 -08:00
/**
2021-02-14 10:36:45 -08:00
* Calculate THEME_LAYOUT constant based on theme preferences and current request . ( url , script , route )
2019-02-26 13:56:07 -08:00
*
2021-02-14 10:36:45 -08:00
* @ param array $cusPagePref
2019-02-26 13:56:07 -08:00
* @ param string $defaultLayout
2021-02-14 10:36:45 -08:00
* @ param array $request url => ( optional ) defaults to e_REQUEST_URL , 'script' => $_SERVER [ 'SCRIPT_FILENAME' ], 'route' => e_ROUTE
2019-02-26 13:56:07 -08:00
* @ return int | string
2019-01-23 19:06:03 -08:00
*/
2021-02-14 10:36:45 -08:00
public static function getThemeLayout ( $cusPagePref , $defaultLayout , $request )
2019-01-23 19:06:03 -08:00
{
2021-02-14 10:36:45 -08:00
$request_url = isset ( $request [ 'url' ]) ? $request [ 'url' ] : null ;
$request_script = isset ( $request [ 'script' ]) ? $request [ 'script' ] : null ;
2019-02-26 13:56:07 -08:00
2019-01-23 19:06:03 -08:00
if ( $request_url === null )
{
$request_url = e_REQUEST_URL ;
}
$def = " " ; // no custom pages found yet.
2019-07-02 09:00:43 -07:00
$matches = array ();
2019-01-23 19:06:03 -08:00
if ( is_array ( $cusPagePref ) && count ( $cusPagePref ) > 0 ) // check if we match a page in layout custompages.
{
//e_SELF.(e_QUERY ? '?'.e_QUERY : '');
$c_url = str_replace ( array ( '&' ), array ( '&' ), $request_url ); //.(e_QUERY ? '?'.e_QUERY : '');// mod_rewrite support
// FIX - check against urldecoded strings
$c_url = rtrim ( rawurldecode ( $c_url ), '?' );
2021-02-14 10:36:45 -08:00
$c_url = self :: filterTrackers ( $c_url );
2019-01-24 11:36:14 -08:00
2019-02-28 14:20:33 -08:00
// First check all layouts for exact matches - possible fix for future issues?.
/*
foreach ( $cusPagePref as $lyout => $cusPageArray )
{
if ( ! is_array ( $cusPageArray )) { continue ; }
$base = basename ( $request_url );
if ( in_array ( " / " . $base , $cusPageArray ) || in_array ( $base , $cusPageArray ))
{
return $lyout ;
}
} */
2019-07-02 09:00:43 -07:00
2019-01-23 19:06:03 -08:00
foreach ( $cusPagePref as $lyout => $cusPageArray )
{
2019-02-28 14:20:33 -08:00
2019-01-23 19:06:03 -08:00
if ( ! is_array ( $cusPageArray )) { continue ; }
// NEW - Front page template check - early
2021-02-14 10:36:45 -08:00
if ( in_array ( 'FRONTPAGE' , $cusPageArray ) && ( $c_url == SITEURL || rtrim ( $c_url , '/' ) === SITEURL . 'index.php' ))
2019-01-23 19:06:03 -08:00
{
2019-02-28 14:20:33 -08:00
return $lyout ;
2019-01-23 19:06:03 -08:00
}
2019-02-28 14:20:33 -08:00
2019-01-23 19:06:03 -08:00
foreach ( $cusPageArray as $kpage )
{
2021-02-14 10:36:45 -08:00
// e_ROUTE
2021-02-26 11:56:10 -08:00
if ( ! empty ( $request [ 'route' ]) && ( strpos ( ':' . $request [ 'route' ], $kpage ) === 0 ))
2021-02-14 10:36:45 -08:00
{
return $lyout ;
}
2019-08-22 14:36:03 -07:00
$kpage = str_replace ( '$' , '$' , $kpage ); // convert database encoding.
2019-03-26 12:05:01 -07:00
$lastChar = substr ( $kpage , - 1 );
if ( $lastChar === '$' ) // script name match.
{
$kpage = rtrim ( $kpage , '$' );
2019-04-06 12:11:05 -07:00
if ( ! empty ( $request_script ) && strpos ( $request_script , '/' . $kpage ) !== false )
2019-03-26 12:05:01 -07:00
{
return $lyout ;
}
}
if ( $lastChar === '!' )
2019-01-23 19:06:03 -08:00
{
2019-02-28 14:20:33 -08:00
2019-01-23 19:06:03 -08:00
$kpage = rtrim ( $kpage , '!' );
2019-02-28 14:20:33 -08:00
2019-03-02 10:17:27 -08:00
if ( basename ( $request_url ) === $kpage ) // exact match specified by '!', skip other processing.
2019-02-28 14:20:33 -08:00
{
2019-03-02 10:17:27 -08:00
return $lyout ;
2019-02-28 14:20:33 -08:00
}
elseif ( substr ( $c_url , - strlen ( $kpage )) === $kpage )
2019-01-23 19:06:03 -08:00
{
2019-02-28 14:20:33 -08:00
$def = $lyout ;
2019-01-23 19:06:03 -08:00
}
2019-02-28 14:20:33 -08:00
2019-01-23 19:06:03 -08:00
continue ;
}
2019-02-28 14:20:33 -08:00
if ( ! empty ( $kpage ) && ( strpos ( $c_url , $kpage ) !== false )) // partial URL match
{
2019-07-02 09:00:43 -07:00
similar_text ( $c_url , $kpage , $perc );
$matches [ $lyout ] = round ( $perc , 2 ); // rank the match
// echo $c_url." : ".$kpage." --- ".$perc."\n";
2019-02-28 14:20:33 -08:00
}
2019-03-26 12:05:01 -07:00
2019-01-23 19:06:03 -08:00
}
}
}
2019-07-02 09:00:43 -07:00
if ( ! empty ( $matches )) // return the highest ranking match.
{
$top = array_keys ( $matches , max ( $matches ));
$def = $top [ 0 ];
//print_r($matches);
}
2019-01-23 19:06:03 -08:00
if ( $def ) // custom-page layout.
{
$layout = $def ;
}
else // default layout.
{
2019-02-26 13:56:07 -08:00
$layout = $defaultLayout ;
2019-01-23 19:06:03 -08:00
}
return $layout ;
}
2017-02-02 16:42:11 -08:00
/**
* Return a list of all local themes in various formats .
* Replaces getThemeList
2020-12-22 09:29:12 -08:00
* @ param null | string $mode null , 'version' | 'id' | 'xml'
2017-02-02 16:42:11 -08:00
* @ return array | bool a list or false if no results
*/
public function getList ( $mode = null )
{
$arr = array ();
2020-12-22 09:29:12 -08:00
switch ( $mode )
2017-02-02 16:42:11 -08:00
{
2020-12-22 09:29:12 -08:00
case " version " :
foreach ( $this -> _data as $dir => $v )
{
$arr [ $dir ] = array ( 'version' => $v [ 'version' ], 'author' => $v [ 'author' ]);
}
break ;
2017-02-02 16:42:11 -08:00
2020-12-22 09:29:12 -08:00
case " id " :
$count = 1 ;
foreach ( $this -> _data as $dir => $v )
{
$arr [ $count ] = $dir ;
$count ++ ;
}
break ;
case 'xml' :
$count = 1 ;
foreach ( $this -> _data as $dir => $v )
{
if ( $v [ 'legacy' ] === true )
{
continue ;
}
$v [ 'id' ] = $count ; // reset the counter.
$arr [ $dir ] = $v ;
$count ++ ;
}
break ;
default :
$arr = $this -> _data ;
2017-02-02 16:42:11 -08:00
}
return ! empty ( $arr ) ? $arr : false ;
}
2017-01-31 07:52:19 -08:00
2020-12-22 09:29:12 -08:00
2017-01-04 18:08:58 -08:00
/**
* Get a list of all themes in theme folder and its data .
2020-12-22 14:48:28 -08:00
* @ deprecated Use getList ( $mode ) instead
2017-02-02 16:42:11 -08:00
* @ see load ();
2017-01-04 18:08:58 -08:00
* @ param bool | false xml | false
* @ param bool | false $force force a refresh ie . ignore cached list .
* @ return array
2021-01-27 08:45:34 -08:00
*//*
2017-01-04 18:08:58 -08:00
public static function getThemeList ( $mode = false , $force = false )
{
2020-12-22 14:48:28 -08:00
trigger_error ( '<b>' . __METHOD__ . ' is deprecated.</b> Use getList() instead.' , E_USER_DEPRECATED ); // NO LAN
2020-12-21 10:00:28 -08:00
2017-01-04 18:08:58 -08:00
$themeArray = array ();
$tloop = 1 ;
2017-02-02 11:48:13 -08:00
$cacheTag = self :: CACHETAG ;
2017-01-04 18:08:58 -08:00
2017-02-02 11:48:13 -08:00
if ( ! empty ( $mode ))
{
$cacheTag = self :: CACHETAG . '_' . $mode ;
}
2017-01-04 18:08:58 -08:00
2017-02-02 11:48:13 -08:00
if ( $force === false && $tmp = e107 :: getCache () -> retrieve ( $cacheTag , self :: CACHETIME , true , true ))
2017-01-04 18:08:58 -08:00
{
return e107 :: unserialize ( $tmp );
}
2017-02-02 11:48:13 -08:00
$array = scandir ( e_THEME );
2017-01-04 18:08:58 -08:00
foreach ( $array as $file )
{
if (( $mode == 'xml' ) && ! is_readable ( e_THEME . $file . " /theme.xml " ))
{
continue ;
}
if ( $file != " . " && $file != " .. " && $file != " CVS " && $file != " templates " && is_dir ( e_THEME . $file ) && is_readable ( e_THEME . $file . " /theme.php " ))
{
2017-02-02 11:48:13 -08:00
if ( $mode === " id " )
2017-01-04 18:08:58 -08:00
{
$themeArray [ $tloop ] = $file ;
}
2017-02-02 11:48:13 -08:00
elseif ( $mode === 'version' )
{
$data = self :: getThemeInfo ( $file );
$themeArray [ $file ] = $data [ 'version' ];
}
2017-01-04 18:08:58 -08:00
else
{
$themeArray [ $file ] = self :: getThemeInfo ( $file );
$themeArray [ $file ][ 'id' ] = $tloop ;
}
$tloop ++ ;
}
}
$cacheSet = e107 :: serialize ( $themeArray , 'json' );
2017-02-02 11:48:13 -08:00
e107 :: getCache () -> set ( $cacheTag , $cacheSet , true , true , true );
2017-01-04 18:08:58 -08:00
return $themeArray ;
}
2021-01-27 08:45:34 -08:00
*/
2017-01-04 18:08:58 -08:00
2017-02-02 16:42:11 -08:00
/**
* Internal Use . Heavy CPU usage .
* Use e107 :: getTheme ( $themeDir , $force ) -> get () instead .
2022-04-04 10:54:24 -07:00
* @ param string $file theme directory name .
2017-02-02 16:42:11 -08:00
* @ return mixed
*/
2017-01-04 18:08:58 -08:00
public static function getThemeInfo ( $file )
{
$reject = array ( 'e_.*' );
$handle2 = e107 :: getFile () -> get_files ( e_THEME . $file . " / " , " \ .php| \ .css| \ .xml|preview \ .jpg|preview \ .png " , $reject , 1 );
$themeArray = array ();
2020-12-22 09:29:12 -08:00
$themeArray [ $file ] = array ();
2017-01-04 18:08:58 -08:00
foreach ( $handle2 as $fln )
{
$file2 = str_replace ( e_THEME . $file . " / " , " " , $fln [ 'path' ]) . $fln [ 'fname' ];
$themeArray [ $file ][ 'files' ][] = $file2 ;
2020-12-20 11:50:10 -08:00
if ( strpos ( $file2 , " preview. " ) !== false )
2017-01-04 18:08:58 -08:00
{
$themeArray [ $file ][ 'preview' ] = e_THEME . $file . " / " . $file2 ;
}
// ---------------- get information string for css file - Legacy mode (no theme.xml)
2020-12-20 11:50:10 -08:00
if ( strpos ( $file2 , " .css " ) !== false && strpos ( $file2 , " menu.css " ) === false && strpos ( $file2 , " e_ " ) !== 0 )
2017-01-04 18:08:58 -08:00
{
if ( $cssContents = file_get_contents ( e_THEME . $file . " / " . $file2 ))
{
$nonadmin = preg_match ( '/\* Non-Admin(.*?)\*\//' , $cssContents ) ? true : false ;
preg_match ( '/\* info:(.*?)\*\//' , $cssContents , $match );
2021-01-27 08:45:34 -08:00
$match [ 1 ] = varset ( $match [ 1 ]);
2017-01-04 18:08:58 -08:00
$scope = ( $nonadmin == true ) ? 'front' : '' ;
$themeArray [ $file ][ 'css' ][] = array ( " name " => $file2 , " info " => $match [ 1 ], " scope " => $scope , " nonadmin " => $nonadmin );
}
2020-12-18 19:55:12 -08:00
//else
//{
2017-01-04 18:08:58 -08:00
// $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2);
2020-12-18 19:55:12 -08:00
// }
2017-01-04 18:08:58 -08:00
}
} // end foreach
// Load Theme information and merge with existing array. theme.xml (v2.x theme) is given priority over theme.php (v1.x).
2020-12-22 09:29:12 -08:00
if ( ! empty ( $themeArray [ $file ][ 'files' ]))
2017-01-04 18:08:58 -08:00
{
2020-12-22 09:29:12 -08:00
if ( in_array ( " theme.xml " , $themeArray [ $file ][ 'files' ]))
{
$themeArray [ $file ] = array_merge ( $themeArray [ $file ], self :: parse_theme_xml ( $file ));
}
elseif ( in_array ( " theme.php " , $themeArray [ $file ][ 'files' ]))
{
$themeArray [ $file ] = array_merge ( $themeArray [ $file ], self :: parse_theme_php ( $file ));
}
2017-01-04 18:08:58 -08:00
}
if ( ! empty ( $themeArray [ $file ][ 'css' ]) && count ( $themeArray [ $file ][ 'css' ]) > 1 )
{
$themeArray [ $file ][ 'multipleStylesheets' ] = true ;
2022-04-05 19:49:08 -07:00
}
2017-01-04 18:08:58 -08:00
return $themeArray [ $file ];
}
2022-04-04 10:54:24 -07:00
/**
* Legacy Plugin theme . php meta data parser .
* @ param string $path theme folder name
* @ return array
*/
2017-01-06 13:50:15 -08:00
public static function parse_theme_php ( $path )
2017-01-04 18:08:58 -08:00
{
2019-05-27 10:45:35 -07:00
$CUSTOMPAGES = null ;
2017-02-02 16:42:11 -08:00
$tp = e107 :: getParser (); // could be used by a theme file.
$sql = e107 :: getDb (); // could be used by a theme file.
2017-01-04 18:08:58 -08:00
$fp = fopen ( e_THEME . $path . " /theme.php " , " r " );
$themeContents = fread ( $fp , filesize ( e_THEME . $path . " /theme.php " ));
fclose ( $fp );
preg_match ( '/themename(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'name' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themeversion(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'version' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themeauthor(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'author' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themeemail(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'email' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themewebsite(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'website' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themedate(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'date' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/themeinfo(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2021-01-27 08:45:34 -08:00
$themeArray [ 'info' ] = varset ( $match [ 3 ]);
2017-01-04 18:08:58 -08:00
preg_match ( '/xhtmlcompliant(\s*?=\s*?)(\S*?);/si' , $themeContents , $match );
2021-09-27 10:45:06 -07:00
$xhtml = ! empty ( $match [ 2 ]) ? strtolower ( $match [ 2 ]) : '' ;
2017-01-04 18:08:58 -08:00
$themeArray [ 'xhtmlcompliant' ] = ( $xhtml == " true " ? " 1.1 " : false );
preg_match ( '/csscompliant(\s*?=\s*?)(\S*?);/si' , $themeContents , $match );
2021-09-27 10:45:06 -07:00
$css = ! empty ( $match [ 2 ]) ? strtolower ( $match [ 2 ]) : '' ;
2017-01-04 18:08:58 -08:00
$themeArray [ 'csscompliant' ] = ( $css == " true " ? " 2.1 " : false );
2021-09-27 10:45:06 -07:00
if ( ! empty ( $themeArray [ 'version' ]))
{
$themeArray [ 'version' ] = str_replace ( array ( '<br />' , '<br>' , '<br/>' ), ' ' , $themeArray [ 'version' ]);
}
2017-02-01 09:16:31 -08:00
2017-01-04 18:08:58 -08:00
/* preg_match ( '/CUSTOMPAGES(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
$themeArray [ 'custompages' ] = array_filter ( explode ( " " , $match [ 3 ])); */
$themeContentsArray = explode ( " \n " , $themeContents );
preg_match_all ( " # \\ $ " . " CUSTOMHEADER \ [( \" |')(.*?)('| \" ) \ ].*?# " , $themeContents , $match );
$customHeaderArray = $match [ 2 ];
preg_match_all ( " # \\ $ " . " CUSTOMFOOTER \ [( \" |')(.*?)('| \" ) \ ].*?# " , $themeContents , $match );
$customFooterArray = $match [ 2 ];
if ( ! $themeArray [ 'name' ])
{
unset ( $themeArray );
}
$lays [ 'legacyDefault' ][ '@attributes' ] = array ( 'title' => 'Default' ,
'plugins' => '' ,
'default' => 'true' );
// load custompages from theme.php only when theme.xml doesn't exist.
if ( ! file_exists ( e_THEME . $path . " theme.xml " ))
{
foreach ( $themeContentsArray as $line )
{
2020-12-20 11:50:10 -08:00
if ( strpos ( $line , " CUSTOMPAGES " ) !== false )
2017-01-04 18:08:58 -08:00
{
2017-02-03 07:39:20 -08:00
try
{
@ eval ( str_replace ( " $ " , " \$ " , $line )); // detect arrays also.
}
catch ( ParseError $e )
{
}
2017-01-04 18:08:58 -08:00
}
}
if ( is_array ( $CUSTOMPAGES ))
{
foreach ( $CUSTOMPAGES as $key => $val )
{
2017-01-26 18:46:10 -08:00
$themeArray [ 'custompages' ][ $key ] = explode ( " " , trim ( $val ));
$lays [ $key ][ 'custompages' ] = trim ( $val );
2017-01-04 18:08:58 -08:00
}
}
elseif ( $CUSTOMPAGES )
{
$themeArray [ 'custompages' ][ 'legacyCustom' ] = explode ( " " , $CUSTOMPAGES );
$lays [ 'legacyCustom' ][ '@attributes' ] = array ( 'title' => 'Custom' ,
'plugins' => '' );
}
foreach ( $customHeaderArray as $tm )
{
$lays [ $tm ][ '@attributes' ] = array ( 'title' => str_replace ( " _ " , " " , $tm ),
'plugins' => '' );
}
foreach ( $customFooterArray as $tm )
{
$lays [ $tm ][ '@attributes' ] = array ( 'title' => str_replace ( " _ " , " " , $tm ),
'plugins' => '' );
}
}
$themeArray [ 'path' ] = $path ;
$themeArray [ 'layouts' ] = $lays ;
2017-01-10 17:57:04 -08:00
$themeArray [ 'description' ] = $themeArray [ 'info' ];
2017-01-04 18:08:58 -08:00
if ( file_exists ( e_THEME . $path . " /preview.jpg " ))
{
$themeArray [ 'preview' ] = array ( " preview.jpg " );
$themeArray [ 'thumbnail' ] = " preview.jpg " ;
}
if ( file_exists ( e_THEME . $path . " /preview.png " ))
{
$themeArray [ 'preview' ] = array ( " preview.png " );
$themeArray [ 'thumbnail' ] = " preview.png " ;
}
// echo "<h2>".$themeArray['name']."</h2>";
// print_a($lays);
2017-02-02 16:42:11 -08:00
$themeArray [ 'legacy' ] = true ;
2019-06-22 11:43:46 -07:00
$themeArray [ 'html' ] = false ;
2020-12-29 08:04:52 -08:00
$themeArray [ 'compatibility' ] = '1' ;
2017-01-04 18:08:58 -08:00
return $themeArray ;
}
2022-04-04 10:54:24 -07:00
/**
* Reads theme . xml and returns an array of data from it .
* @ param string $path theme folder name
* @ return array
*/
2017-01-06 13:50:15 -08:00
public static function parse_theme_xml ( $path )
2017-01-04 18:08:58 -08:00
{
$tp = e107 :: getParser ();
$xml = e107 :: getXml ();
// loadLanFiles($path, 'admin'); // Look for LAN files on default paths
// layout should always be an array.
2017-01-06 13:50:15 -08:00
$xml -> setOptArrayTags ( 'layout,screenshots/image,plugins/plugin' );
2017-01-04 18:08:58 -08:00
$xml -> setOptStringTags ( 'menuPresets,customPages,custompages' );
2017-01-06 13:50:15 -08:00
//
2017-01-04 18:08:58 -08:00
// $vars = $xml->loadXMLfile(e_THEME.$path.'/theme.xml', true, true);
// $oldvars =
$vars = $xml -> loadXMLfile ( e_THEME . $path . '/theme.xml' , 'advanced' , true ); // must be 'advanced'
2020-12-18 19:55:12 -08:00
//if($path == "bootstrap3" )
// {
2017-01-04 18:08:58 -08:00
// echo "<table class='table table-bordered'>
// <tr><th>old</th><th>new parser</th></tr>
// <tr><td>".print_a($oldvars,true)."</td><td>".print_a($vars,true)."</td></tr></table>";
2020-12-18 19:55:12 -08:00
// }
2017-01-04 18:08:58 -08:00
$vars [ 'name' ] = varset ( $vars [ '@attributes' ][ 'name' ]);
$vars [ 'version' ] = varset ( $vars [ '@attributes' ][ 'version' ]);
$vars [ 'date' ] = varset ( $vars [ '@attributes' ][ 'date' ]);
2020-07-01 13:00:34 -07:00
$vars [ 'compatibility' ] = ! empty ( $vars [ '@attributes' ][ 'compatibility' ]) ? $tp -> filter ( $vars [ '@attributes' ][ 'compatibility' ], 'version' ) : '' ;
2017-01-04 18:08:58 -08:00
$vars [ 'releaseUrl' ] = varset ( $vars [ '@attributes' ][ 'releaseUrl' ]);
$vars [ 'email' ] = varset ( $vars [ 'author' ][ '@attributes' ][ 'email' ]);
$vars [ 'website' ] = varset ( $vars [ 'author' ][ '@attributes' ][ 'url' ]);
$vars [ 'author' ] = varset ( $vars [ 'author' ][ '@attributes' ][ 'name' ]);
2017-12-15 14:50:54 -08:00
$vars [ 'info' ] = ! empty ( $vars [ 'description' ][ '@value' ]) ? $vars [ 'description' ][ '@value' ] : varset ( $vars [ 'description' ]);
2017-01-04 18:08:58 -08:00
$vars [ 'category' ] = self :: getThemeCategory ( varset ( $vars [ 'category' ]));
$vars [ 'xhtmlcompliant' ] = varset ( $vars [ 'compliance' ][ '@attributes' ][ 'xhtml' ]);
$vars [ 'csscompliant' ] = varset ( $vars [ 'compliance' ][ '@attributes' ][ 'css' ]);
$vars [ '@attributes' ][ 'default' ] = ( varset ( $vars [ '@attributes' ][ 'default' ]) && strtolower ( $vars [ '@attributes' ][ 'default' ]) == 'true' ) ? 1 : 0 ;
$vars [ 'preview' ] = varset ( $vars [ 'screenshots' ][ 'image' ]);
2017-02-01 08:54:28 -08:00
$vars [ 'thumbnail' ] = isset ( $vars [ 'preview' ][ 0 ]) && file_exists ( e_THEME . $path . '/' . $vars [ 'preview' ][ 0 ]) ? $vars [ 'preview' ][ 0 ] : '' ;
2021-01-24 17:00:02 -08:00
$vars [ 'html' ] = ( file_exists ( e_THEME . $path . '/theme.html' ) && is_dir ( e_THEME . $path . '/layouts' ));
2017-01-04 18:08:58 -08:00
2017-01-10 17:57:04 -08:00
2017-01-04 18:08:58 -08:00
if ( ! empty ( $vars [ 'themePrefs' ]))
{
foreach ( $vars [ 'themePrefs' ][ 'pref' ] as $k => $val )
{
$name = $val [ '@attributes' ][ 'name' ];
$vars [ 'preferences' ][ $name ] = $val [ '@value' ];
}
}
2017-01-10 17:57:04 -08:00
unset ( $vars [ 'authorEmail' ], $vars [ 'authorUrl' ], $vars [ 'xhtmlCompliant' ], $vars [ 'cssCompliant' ], $vars [ 'screenshots' ]);
2017-01-04 18:08:58 -08:00
// Compile layout information into a more usable format.
$custom = array ();
/*
foreach ( $vars [ 'layouts' ] as $layout )
{
foreach ( $layout as $key => $val )
{
$name = $val [ '@attributes' ][ 'name' ];
unset ( $val [ '@attributes' ][ 'name' ]);
$lays [ $name ] = $val ;
if ( isset ( $val [ 'customPages' ]))
{
$cusArray = explode ( " " , $val [ 'customPages' ]);
$custom [ $name ] = array_filter ( $cusArray );
}
if ( isset ( $val [ 'custompages' ]))
{
$cusArray = explode ( " " , $val [ 'custompages' ]);
$custom [ $name ] = array_filter ( explode ( " " , $val [ 'custompages' ]));
}
}
}
*/
$lays = array ();
foreach ( $vars [ 'layouts' ][ 'layout' ] as $k => $val )
{
$name = $val [ '@attributes' ][ 'name' ];
unset ( $val [ '@attributes' ][ 'name' ]);
$lays [ $name ] = $val ;
if ( isset ( $val [ 'custompages' ]))
{
if ( is_string ( $val [ 'custompages' ]))
{
$custom [ $name ] = array_filter ( explode ( " " , $val [ 'custompages' ]));
}
elseif ( is_array ( $val [ 'custompages' ]))
{
$custom [ $name ] = $val [ 'custompages' ];
}
}
}
2017-03-02 20:55:31 +01:00
$vars [ 'layouts' ] = $lays ;
$vars [ 'path' ] = $path ;
$vars [ 'custompages' ] = $custom ;
$vars [ 'legacy' ] = false ;
$vars [ 'library' ] = array ();
if ( ! empty ( $vars [ 'libraries' ][ 'library' ]))
{
$vars [ 'css' ] = array ();
2021-10-11 12:33:59 -07:00
foreach ( $vars [ 'libraries' ][ 'library' ] as $c => $val )
2017-03-02 20:55:31 +01:00
{
2021-10-11 12:33:59 -07:00
foreach ( $val [ '@attributes' ] as $k => $v )
{
$vars [ 'library' ][ $c ][ $k ] = $v ;
}
/* $vars [ 'library' ][] = array (
2017-03-02 20:55:31 +01:00
'name' => $val [ '@attributes' ][ 'name' ],
2018-03-08 13:45:08 -08:00
'version' => varset ( $val [ '@attributes' ][ 'version' ]),
2021-02-13 06:50:17 -08:00
'scope' => varset ( $val [ '@attributes' ][ 'scope' ], 'front' ),
2021-10-11 12:33:59 -07:00
); */
2017-03-02 20:55:31 +01:00
}
unset ( $vars [ 'libraries' ]);
}
2021-04-06 18:41:15 -07:00
else // detect defined constants in legacy theme.php file.
{
if ( $data = self :: getLegacyBSFA ( $path ))
{
$vars [ 'library' ] = $data ;
}
}
2017-01-04 18:08:58 -08:00
if ( ! empty ( $vars [ 'stylesheets' ][ 'css' ]))
{
$vars [ 'css' ] = array ();
foreach ( $vars [ 'stylesheets' ][ 'css' ] as $val )
{
2017-01-31 16:39:00 -08:00
// $notadmin = vartrue($val['@attributes']['admin']) ? false : true;
2021-01-24 17:00:02 -08:00
$notadmin = varset ( $val [ '@attributes' ][ 'scope' ]) !== 'admin' ;
2017-02-02 16:42:11 -08:00
$vars [ 'css' ][] = array (
2021-02-11 16:39:50 -08:00
" name " => $val [ '@attributes' ][ 'file' ],
" info " => $val [ '@attributes' ][ 'name' ],
" nonadmin " => $notadmin ,
2022-04-06 08:37:13 -07:00
'default' => vartrue ( $val [ '@attributes' ][ 'default' ], false ),
2021-03-11 09:27:38 -08:00
'scope' => vartrue ( $val [ '@attributes' ][ 'scope' ], 'front' ),
2021-02-11 16:39:50 -08:00
'exclude' => vartrue ( $val [ '@attributes' ][ 'exclude' ]),
2017-10-12 13:14:04 -07:00
'description' => vartrue ( $val [ '@attributes' ][ 'description' ]),
2021-02-11 16:39:50 -08:00
'thumbnail' => vartrue ( $val [ '@attributes' ][ 'thumbnail' ])
2017-02-02 16:42:11 -08:00
);
2017-01-04 18:08:58 -08:00
}
unset ( $vars [ 'stylesheets' ]);
}
$vars [ 'glyphs' ] = array ();
if ( ! empty ( $vars [ 'glyphicons' ][ 'glyph' ]))
{
foreach ( $vars [ 'glyphicons' ][ 'glyph' ] as $val )
{
$vars [ 'glyphs' ][] = array (
2017-12-10 11:26:47 +01:00
'name' => isset ( $val [ '@attributes' ][ 'name' ]) ? $val [ '@attributes' ][ 'name' ] : '' ,
'pattern' => isset ( $val [ '@attributes' ][ 'pattern' ]) ? $val [ '@attributes' ][ 'pattern' ] : '' ,
'path' => isset ( $val [ '@attributes' ][ 'path' ]) ? $val [ '@attributes' ][ 'path' ] : '' ,
'class' => isset ( $val [ '@attributes' ][ 'class' ]) ? $val [ '@attributes' ][ 'class' ] : '' ,
'prefix' => isset ( $val [ '@attributes' ][ 'prefix' ]) ? $val [ '@attributes' ][ 'prefix' ] : '' ,
'tag' => isset ( $val [ '@attributes' ][ 'tag' ]) ? $val [ '@attributes' ][ 'tag' ] : '' ,
2017-01-04 18:08:58 -08:00
);
}
unset ( $vars [ 'glyphicons' ]);
}
2020-12-18 19:55:12 -08:00
//if($path == "bootstrap3" )
// {
2020-04-13 16:43:25 -07:00
// e107::getMessage()->addDebug("<h2>".$path."</h2>");
// e107::getMessage()->addDebug(print_a($vars,true));
// print_a($vars);
// echo "<table class='table'><tr><td>".print_a($vars,true)."</td><td>".print_a($adv,true)."</td></tr></table>";
2020-12-18 19:55:12 -08:00
// }
2017-01-04 18:08:58 -08:00
return $vars ;
}
2021-04-06 18:41:15 -07:00
/**
* Read legacy bootstrap / fontawesome constants from theme . php
* @ param string $path theme directory
*/
public static function getLegacyBSFA ( $path )
{
if ( ! $content = file_get_contents ( e_THEME . $path . '/theme.php' ))
{
return false ;
}
$ret = [];
2021-08-13 10:58:42 -07:00
if ( preg_match ( '/define[ ]*?\([\'|"]BOOTSTRAP[\'|"],[ \t]*(\d)\);/' , $content , $m ) && strpos ( $content , 'bootstrap.min.css' ) === false && strpos ( $content , 'bootstrap.min.js' ) === false )
2021-04-06 18:41:15 -07:00
{
$ret [] = array ( 'name' => 'bootstrap' ,
'version' => $m [ 1 ],
'scope' => 'front,wysiwyg' ,
);
}
2021-08-13 10:58:42 -07:00
if ( preg_match ( '/define[ ]*?\([\'|"]FONTAWESOME[\'|"],[ \t]*(\d)\);/' , $content , $m ) && strpos ( $content , 'font-awesome.min.css' ) === false )
2021-04-06 18:41:15 -07:00
{
$ret [] = array ( 'name' => 'fontawesome' ,
'version' => $m [ 1 ],
'scope' => 'front,wysiwyg' ,
);
}
2021-09-24 13:08:45 -07:00
// e107::getDebug()->log($ret);
2021-08-13 10:58:42 -07:00
2021-04-06 18:41:15 -07:00
return $ret ;
}
2017-01-04 18:08:58 -08:00
/**
* Validate and return the name of the categories .
*
* @ param string [ optional ] $categoryfromXML
* @ return string
*/
private static function getThemeCategory ( $categoryfromXML = '' )
{
if ( ! $categoryfromXML )
{
return 'generic' ;
}
$tmp = explode ( " , " , $categoryfromXML );
$category = array ();
foreach ( $tmp as $cat )
{
$cat = trim ( $cat );
if ( in_array ( $cat , self :: $allowedCategories ))
{
$category [] = $cat ;
}
else
{
$category [] = 'generic' ;
}
}
return implode ( ', ' , $category );
}
2022-04-04 10:54:24 -07:00
/**
* @ param $themeDir
* @ param $layout
* @ return void
*/
2021-01-01 14:11:56 -08:00
private static function initThemePreview ( $themeDir , $layout = null )
2020-12-21 17:46:32 -08:00
{
2021-01-01 14:05:51 -08:00
$themeDir = filter_var ( $themeDir );
$themeDir = basename ( $themeDir );
2020-12-21 17:46:32 -08:00
2021-01-01 14:05:51 -08:00
$themeobj = new themeHandler ;
2021-01-01 14:11:56 -08:00
$defLayout = ! empty ( $layout ) ? $layout : $themeobj -> findDefault ( $themeDir );
2020-12-21 17:46:32 -08:00
2021-01-01 14:11:56 -08:00
define ( 'THEME_LAYOUT' , $defLayout );
2021-01-01 14:05:51 -08:00
define ( 'PREVIEWTHEME' , $themeDir );
define ( 'THEME' , e_THEME . $themeDir . '/' );
define ( 'THEME_ABS' , e_THEME_ABS . $themeDir . '/' );
2020-12-21 17:46:32 -08:00
2021-01-01 14:05:51 -08:00
$legacy = ( file_exists ( e_THEME . $themeDir . '/theme.xml' ) === false );
if ( $legacy === true )
{
$version = 1.0 ;
}
else
{
$version = ( file_exists ( e_THEME . $themeDir . '/theme.html' )) ? 2.3 : 2.0 ;
}
2020-12-21 17:46:32 -08:00
2021-01-01 14:05:51 -08:00
define ( 'THEME_VERSION' , $version );
2020-12-21 17:46:32 -08:00
define ( 'THEME_LEGACY' , $legacy );
}
2021-02-14 10:36:45 -08:00
/**
* Define the THEME_STYLE constant
* @ param $pref
*/
2021-02-13 18:55:44 -08:00
public static function initThemeStyle ( $pref )
2020-12-21 17:46:32 -08:00
{
2020-12-25 10:23:56 -08:00
2020-12-21 17:46:32 -08:00
e107 :: getDebug () -> logTime ( 'Find/Load Theme-Layout' ); // needs to run after checkvalidtheme() (for theme previewing).
if ( deftrue ( 'e_ADMIN_AREA' ))
{
define ( 'THEME_STYLE' , $pref [ 'admincss' ]);
2021-02-13 18:55:44 -08:00
self :: initThemeLayout (); // the equivalent for frontend is in header_default.php
2020-12-21 17:46:32 -08:00
}
2022-04-05 19:49:08 -07:00
elseif ( ! empty ( $pref [ 'themecss' ]) && ( file_exists ( THEME . $pref [ 'themecss' ]) || strpos ( $pref [ 'themecss' ], 'https' ) === 0 ))
2020-12-21 17:46:32 -08:00
{
define ( 'THEME_STYLE' , $pref [ 'themecss' ]);
}
else
{
define ( 'THEME_STYLE' , 'style.css' );
}
2021-02-13 18:55:44 -08:00
}
2021-02-14 10:36:45 -08:00
/**
* define the THEME_LAYOUT constant .
* @ return null
*/
2021-02-13 18:55:44 -08:00
public static function initThemeLayout ()
{
2021-02-14 10:36:45 -08:00
if ( defined ( 'THEME_LAYOUT' ))
2020-12-21 17:46:32 -08:00
{
2021-02-14 10:36:45 -08:00
return null ;
}
2021-02-13 18:55:44 -08:00
2021-02-14 10:36:45 -08:00
$sitetheme_custompages = e107 :: getPref ( 'sitetheme_custompages' , array ());
$sitetheme_deflayout = e107 :: getPref ( 'sitetheme_deflayout' );
$user_pref = e107 :: getUser () -> getPref ();
$cusPagePref = ! empty ( $user_pref [ 'sitetheme_custompages' ]) ? $user_pref [ 'sitetheme_custompages' ] : $sitetheme_custompages ;
$cusPageDef = ! empty ( $user_pref [ 'sitetheme_deflayout' ]) ? $user_pref [ 'sitetheme_deflayout' ] : $sitetheme_deflayout ;
$request = [
'url' => e_REQUEST_URL ,
'script' => varset ( $_SERVER [ 'SCRIPT_FILENAME' ], null ),
2021-11-01 15:46:39 -07:00
'route' => e107 :: route (),
2021-02-14 10:36:45 -08:00
];
$deflayout = self :: getThemeLayout ( $cusPagePref , $cusPageDef , $request );
define ( 'THEME_LAYOUT' , $deflayout );
2020-12-21 17:46:32 -08:00
}
2021-02-13 18:55:44 -08:00
2020-12-21 17:46:32 -08:00
/**
* Replacement of checkvalidtheme ()
* @ param string $themeDir
*/
public static function initTheme ( $themeDir )
{
$sql = e107 :: getDb ();
$e107 = e107 :: getInstance ();
$tp = e107 :: getParser ();
2020-12-25 10:23:56 -08:00
$pref = e107 :: getPref ();
2020-12-21 17:46:32 -08:00
e107 :: getDebug () -> logTime ( 'Theme Check' );
// e_QUERY not set when in single entry mod
2021-01-01 14:05:51 -08:00
if ( getperms ( '0' ) && ! empty ( $_GET [ 'themepreview' ]))
2020-12-21 17:46:32 -08:00
{
2021-01-01 14:11:56 -08:00
$layout = ! empty ( $_GET [ 'layout' ]) ? $_GET [ 'layout' ] : null ;
self :: initThemePreview ( $_GET [ 'themepreview' ], $layout );
2021-02-13 18:55:44 -08:00
self :: initThemeStyle ( $pref );
2020-12-21 17:46:32 -08:00
return ;
}
// check for valid theme.
if ( @ fopen ( e_THEME . $themeDir . '/theme.php' , 'r' ))
{
define ( 'THEME' , e_THEME . $themeDir . '/' );
define ( 'THEME_ABS' , e_THEME_ABS . $themeDir . '/' );
$legacy = ( file_exists ( e_THEME . $themeDir . '/theme.xml' ) === false );
define ( 'THEME_LEGACY' , $legacy );
2020-12-28 09:48:44 -08:00
if ( $legacy === true )
{
2020-12-28 10:29:17 -08:00
$version = 1.0 ;
2020-12-28 09:48:44 -08:00
}
else
{
$version = ( file_exists ( e_THEME . $themeDir . '/theme.html' )) ? 2.3 : 2.0 ;
}
define ( 'THEME_VERSION' , $version );
2020-12-21 17:46:32 -08:00
$e107 -> site_theme = $themeDir ;
e107 :: getDebug () -> logTime ( 'Theme Check End' );
2021-02-13 18:55:44 -08:00
self :: initThemeStyle ( $pref );
2020-12-21 17:46:32 -08:00
return ;
}
// fallback in case selected theme failed.
$ADMIN_DIRECTORY = e107 :: getFolder ( 'admin' );
$e107tmp_theme = 'bootstrap3' ; // set to bootstrap3 by default.
define ( 'THEME' , e_THEME . $e107tmp_theme . '/' );
define ( 'THEME_ABS' , e_THEME_ABS . $e107tmp_theme . '/' );
2020-12-28 09:48:44 -08:00
define ( 'THEME_VERSION' , 2.3 );
2021-01-01 12:29:43 -08:00
define ( 'THEME_LEGACY' , false );
define ( 'USERTHEME' , 'bootstrap3' );
define ( 'BOOTSTRAP' , 3 );
2021-02-14 10:36:45 -08:00
define ( 'FONTAWESOME' , 5 );
2020-12-21 17:46:32 -08:00
2021-01-01 12:29:43 -08:00
if ( ADMIN && ( e_ADMIN_AREA !== true ))
2020-12-21 17:46:32 -08:00
{
2021-01-01 12:29:43 -08:00
echo " <div class='alert alert-danger'><b> " . $themeDir . " </b> " . str_replace ( '\n' , '<br />' , CORE_LAN1 ) . " </div> " ;
2020-12-21 17:46:32 -08:00
}
e107 :: getDebug () -> logTime ( 'Theme Check End' );
2021-02-13 18:55:44 -08:00
self :: initThemeStyle ( $pref );
2020-12-21 17:46:32 -08:00
}
2017-01-04 18:08:58 -08:00
}
2022-04-04 10:54:24 -07:00
/**
*
*/
2009-10-28 23:45:46 +00:00
class themeHandler
{
2009-10-28 23:52:56 +00:00
2006-12-02 04:36:16 +00:00
var $themeArray ;
var $action ;
var $id ;
2009-07-06 05:59:42 +00:00
var $frm ;
2009-07-12 14:44:57 +00:00
var $fl ;
2009-08-17 11:25:01 +00:00
var $themeConfigObj = null ;
2017-11-02 14:30:19 -07:00
var $themeConfigFormObj = null ;
2009-09-17 00:13:40 +00:00
var $noLog = FALSE ;
2016-11-28 16:27:17 -08:00
private $curTheme = null ;
2012-11-29 22:03:36 -08:00
2021-01-27 08:45:34 -08:00
// private $approvedAdminThemes = array('bootstrap','bootstrap3', 'bootstrap5');
2012-11-29 22:03:36 -08:00
2021-01-27 08:45:34 -08:00
/* public $allowedCategories = array ( 'generic' ,
2009-10-28 23:45:46 +00:00
'adult' ,
'blog' ,
'clan' ,
'children' ,
'corporate' ,
'forum' ,
'gaming' ,
'gallery' ,
'news' ,
'social' ,
'video' ,
2021-01-27 08:45:34 -08:00
'multimedia' ); */
2013-05-17 16:24:50 +03:00
/**
* Marketplace handler instance
* @ var e_marketplace
*/
protected $mp ;
2017-02-01 08:54:28 -08:00
2021-01-27 08:45:34 -08:00
// const RENDER_THUMBNAIL = 0;
2017-02-01 08:54:28 -08:00
const RENDER_SITEPREFS = 1 ;
const RENDER_ADMINPREFS = 2 ;
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
/* constructor */
2009-10-28 23:45:46 +00:00
2013-05-17 16:24:50 +03:00
function __construct ()
2009-10-28 23:45:46 +00:00
{
2009-10-28 23:52:56 +00:00
2012-11-28 02:22:23 -08:00
global $e107cache , $pref ;
$mes = e107 :: getMessage ();
2015-02-27 14:35:07 -08:00
2021-01-27 08:45:34 -08:00
2009-10-28 23:45:46 +00:00
require_once ( e_HANDLER . " form_handler.php " );
2012-11-28 04:32:05 -08:00
2009-10-28 23:52:56 +00:00
//enable inner tabindex counter
2016-02-11 20:57:30 -08:00
if ( ! deftrue ( " E107_INSTALL " ))
{
$this -> frm = new e_form ();
}
2009-10-28 23:45:46 +00:00
$this -> fl = e107 :: getFile ();
2017-04-05 12:42:42 -07:00
$this -> postObserver ();
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2017-04-05 12:42:42 -07:00
public function postObserver ()
{
$mes = e107 :: getMessage ();
$pref = e107 :: getPref ();
2015-02-10 23:13:53 -08:00
if ( ! empty ( $_POST [ 'upload' ]))
{
$unzippedTheme = $this -> themeUpload ();
}
2016-11-28 16:27:17 -08:00
if ( ! empty ( $_POST [ 'curTheme' ]))
{
2016-12-04 07:50:27 -08:00
$this -> curTheme = e107 :: getParser () -> filter ( $_POST [ 'curTheme' ], 'file' );
2016-11-28 16:27:17 -08:00
}
2017-04-05 12:42:42 -07:00
if ( ! empty ( $_POST [ 'setUploadTheme' ]) && ! empty ( $unzippedTheme ))
2009-07-18 03:41:49 +00:00
{
2020-12-22 09:29:12 -08:00
$themeArray = e107 :: getTheme () -> getList ();
2015-02-10 23:13:53 -08:00
$this -> id = $themeArray [ $unzippedTheme ][ 'id' ];
2017-04-05 12:42:42 -07:00
2015-02-10 23:13:53 -08:00
if ( $this -> setTheme ())
{
2017-04-13 08:54:59 -07:00
2015-02-10 23:13:53 -08:00
$mes -> addSuccess ( TPVLAN_3 );
}
else
{
2016-11-02 11:12:09 +01:00
$mes -> addError ( TPVLAN_86 );
2015-02-10 23:13:53 -08:00
}
2017-04-05 12:42:42 -07:00
2006-12-02 04:36:16 +00:00
}
2017-04-05 12:42:42 -07:00
2015-02-10 23:13:53 -08:00
if ( ! empty ( $_POST [ 'installContent' ]))
2013-03-08 04:46:02 -08:00
{
2017-04-05 12:42:42 -07:00
$this -> installContent ( $_POST [ 'installContent' ]);
2013-03-08 04:46:02 -08:00
}
2017-04-05 12:42:42 -07:00
2020-12-22 09:29:12 -08:00
$this -> themeArray = ( defined ( 'E107_INSTALL' )) ? e107 :: getTheme () -> getList ( 'xml' ) : e107 :: getTheme () -> getList ();
2017-04-05 12:42:42 -07:00
2009-10-28 23:45:46 +00:00
// print_a($this -> themeArray);
2017-04-05 12:42:42 -07:00
2017-04-13 08:54:59 -07:00
2009-10-28 23:45:46 +00:00
foreach ( $_POST as $key => $post )
2006-12-02 04:36:16 +00:00
{
2020-12-20 11:50:10 -08:00
if ( strpos ( $key , " preview " ) !== false )
2006-12-02 04:36:16 +00:00
{
2009-10-28 23:45:46 +00:00
// $this -> id = str_replace("preview_", "", $key);
$this -> id = key ( $post );
$this -> themePreview ();
2006-12-02 04:36:16 +00:00
}
2017-04-13 08:54:59 -07:00
/* if ( strstr ( $key , " selectmain " ))
2006-12-02 04:36:16 +00:00
{
2009-10-28 23:45:46 +00:00
// $this -> id = str_replace("selectmain_", "", $key);
$this -> id = key ( $post );
2013-03-28 00:41:29 -07:00
if ( $this -> setTheme ())
{
$mes -> addSuccess ( TPVLAN_3 );
}
else
{
$mes -> addError ( TPVLAN_3 );
}
2017-04-13 08:54:59 -07:00
} */
2017-04-05 12:42:42 -07:00
2021-01-27 12:20:58 -08:00
/* if ( strpos ( $key , " selectadmin " ) !== false )
2006-12-02 04:36:16 +00:00
{
2009-10-28 23:45:46 +00:00
$this -> id = key ( $post );
$this -> setAdminTheme ();
$this -> refreshPage ( 'admin' );
2021-01-27 12:20:58 -08:00
} */
2006-12-02 04:36:16 +00:00
}
2017-04-05 12:42:42 -07:00
2006-12-02 04:36:16 +00:00
if ( isset ( $_POST [ 'submit_adminstyle' ]))
{
2016-11-28 16:27:17 -08:00
$this -> id = $this -> curTheme ;
2020-12-17 13:13:29 -08:00
$this -> setAdminStyle (); // this redirects.
/* if ( $this -> setAdminStyle ())
2009-08-17 14:40:23 +00:00
{
eMessage :: getInstance () -> add ( TPVLAN_43 , E_MESSAGE_SUCCESS );
}
2020-12-17 13:13:29 -08:00
e107 :: getConfig () -> save ( true ); */
2006-12-02 04:36:16 +00:00
}
2017-04-05 12:42:42 -07:00
2006-12-02 04:36:16 +00:00
if ( isset ( $_POST [ 'submit_style' ]))
{
2016-11-28 16:27:17 -08:00
$this -> id = $this -> curTheme ;
2017-04-05 12:42:42 -07:00
$this -> setLayouts (); // Update the layouts in case they have been manually changed.
2009-10-28 23:45:46 +00:00
$this -> SetCustomPages ( $_POST [ 'custompages' ]);
$this -> setStyle ();
2017-04-05 12:42:42 -07:00
2021-01-27 08:45:34 -08:00
e107 :: getConfig () -> save ();
2017-04-05 12:42:42 -07:00
2006-12-02 04:36:16 +00:00
}
2016-06-02 19:20:58 -07:00
if ( ! empty ( $_POST [ 'git_pull' ]))
{
2017-10-15 11:55:46 -07:00
$gitTheme = e107 :: getParser () -> filter ( $_POST [ 'git_pull' ], 'w' );
$return = e107 :: getFile () -> gitPull ( $gitTheme , 'theme' );
2016-06-02 19:20:58 -07:00
$mes -> addSuccess ( $return );
}
2017-04-05 12:42:42 -07:00
2009-07-14 03:18:17 +00:00
if ( isset ( $_POST [ 'installplugin' ]))
{
$key = key ( $_POST [ 'installplugin' ]);
2017-04-05 12:42:42 -07:00
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_plugin.php " );
2009-10-28 23:45:46 +00:00
require_once ( e_HANDLER . " plugin_class.php " );
2017-04-05 12:42:42 -07:00
2009-07-14 03:18:17 +00:00
$eplug = new e107plugin ;
2009-10-28 23:45:46 +00:00
$message = $eplug -> install_plugin ( $key );
2012-11-28 02:22:23 -08:00
$mes -> add ( $message , E_MESSAGE_SUCCESS );
2009-07-14 03:18:17 +00:00
}
2017-04-05 12:42:42 -07:00
2009-07-16 02:55:19 +00:00
if ( isset ( $_POST [ 'setMenuPreset' ]))
{
2009-10-28 23:45:46 +00:00
$key = key ( $_POST [ 'setMenuPreset' ]);
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_menus.php " );
2009-10-28 23:45:46 +00:00
require_once ( e_HANDLER . " menumanager_class.php " );
2009-08-16 16:30:56 +00:00
$men = new e_menuManager ();
2009-07-16 02:55:19 +00:00
$men -> curLayout = $key ;
2009-10-28 23:52:56 +00:00
//menu_layout is left blank when it's default.
$men -> dbLayout = ( $men -> curLayout != $pref [ 'sitetheme_deflayout' ]) ? $men -> curLayout : " " ;
2017-04-05 12:42:42 -07:00
2009-07-16 02:55:19 +00:00
if ( $areas = $men -> menuSetPreset ())
{
2017-04-05 12:42:42 -07:00
$message = '' ;
2009-10-28 23:45:46 +00:00
foreach ( $areas as $val )
2009-07-16 02:55:19 +00:00
{
2009-10-28 23:45:46 +00:00
$ar [ $val [ 'menu_location' ]][] = $val [ 'menu_name' ];
2009-07-16 02:55:19 +00:00
}
2009-10-28 23:45:46 +00:00
foreach ( $ar as $k => $v )
2009-07-16 02:55:19 +00:00
{
2009-10-28 23:45:46 +00:00
$message .= MENLAN_14 . " " . $k . " : " . implode ( " , " , $v ) . " <br /> " ;
2009-07-16 02:55:19 +00:00
}
2017-04-05 12:42:42 -07:00
2012-11-28 02:22:23 -08:00
$mes -> add ( MENLAN_43 . " : " . $key . " <br /> " . $message , E_MESSAGE_SUCCESS );
2009-07-16 02:55:19 +00:00
}
2017-04-05 12:42:42 -07:00
2009-07-16 02:55:19 +00:00
}
2006-12-02 04:36:16 +00:00
2017-04-05 12:42:42 -07:00
}
2020-12-22 09:29:12 -08:00
/**
* Returns a list of themes and their information .
* @ deprecated
* @ param false $mode
* @ return array | bool
*/
public function getThemes ( $mode = FALSE )
2006-12-02 04:36:16 +00:00
{
2020-12-22 09:29:12 -08:00
trigger_error ( '<b>' . __METHOD__ . ' is deprecated.</b> Use e107::getTheme()->getList($mode); instead. ' , E_USER_DEPRECATED );
return e107 :: getTheme () -> getList ( $mode );
2009-07-12 14:44:57 +00:00
}
2020-12-22 09:29:12 -08:00
/**
* @ param string $file - theme folder name .
2022-04-04 10:54:24 -07:00
* @ return array | bool
*@ deprecated Use e107 :: getTheme ( $file ) -> get (); instead .
2020-12-22 09:29:12 -08:00
*/
2009-10-28 23:45:46 +00:00
function getThemeInfo ( $file )
2009-07-12 14:44:57 +00:00
{
2020-12-22 09:29:12 -08:00
trigger_error ( '<b>' . __METHOD__ . '</b> is deprecated. Use e107::getTheme($themedir)->get(); instead. ' , E_USER_DEPRECATED );
return e107 :: getTheme ( $file ) -> get ();
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2009-09-02 02:38:50 +00:00
/**
2009-11-17 14:50:37 +00:00
* Validate and return the name of the categories .
*
* @ param string [ optional ] $categoryfromXML
* @ return string
2009-09-02 02:38:50 +00:00
*/
2021-01-27 08:45:34 -08:00
/*
2009-10-28 23:45:46 +00:00
function getThemeCategory ( $categoryfromXML = '' )
2009-09-02 02:38:50 +00:00
{
2009-09-17 00:13:40 +00:00
if ( ! $categoryfromXML )
{
2009-10-28 23:45:46 +00:00
return 'generic' ;
2009-09-17 00:13:40 +00:00
}
2009-10-28 23:45:46 +00:00
$tmp = explode ( " , " , $categoryfromXML );
2009-09-02 02:38:50 +00:00
$category = array ();
2009-10-28 23:45:46 +00:00
foreach ( $tmp as $cat )
2009-09-02 02:38:50 +00:00
{
$cat = trim ( $cat );
2009-10-28 23:45:46 +00:00
if ( in_array ( $cat , $this -> allowedCategories ))
2009-09-02 02:38:50 +00:00
{
$category [] = $cat ;
}
else
{
2009-10-28 23:45:46 +00:00
$category [] = 'generic' ;
2009-09-02 02:38:50 +00:00
}
}
2009-10-28 23:45:46 +00:00
return implode ( ', ' , $category );
2009-10-28 23:52:56 +00:00
2009-09-02 02:38:50 +00:00
}
2009-07-12 14:44:57 +00:00
2021-01-27 08:45:34 -08:00
*/
2006-12-02 04:36:16 +00:00
function themeUpload ()
{
2009-10-28 23:45:46 +00:00
if ( ! $_POST [ 'ac' ] == md5 ( ADMINPWCHANGE ))
{
2006-12-02 04:36:16 +00:00
exit ;
}
2012-11-28 02:22:23 -08:00
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
2015-02-10 23:13:53 -08:00
// extract($_FILES);
2013-06-15 15:02:45 +02:00
//print_a($_FILES);
2015-02-10 23:13:53 -08:00
if ( ! is_writable ( e_TEMP ))
2008-11-17 07:17:23 +00:00
{
2013-06-13 16:03:45 +02:00
$mes -> addInfo ( TPVLAN_20 );
2009-07-18 03:41:49 +00:00
return FALSE ;
2008-11-17 07:17:23 +00:00
}
2015-02-10 23:13:53 -08:00
$fl = e107 :: getFile ();
$mp = $this -> getMarketplace ();
$status = $fl -> getUploaded ( e_TEMP );
if ( ! empty ( $status [ 0 ][ 'error' ]))
{
$mes -> addError ( $status [ 0 ][ 'message' ]);
return ;
}
$mes -> addSuccess ( $status [ 0 ][ 'message' ]);
return $fl -> unzipArchive ( $status [ 0 ][ 'name' ], 'theme' );
// else
/*
2008-11-17 07:17:23 +00:00
{
2013-06-15 15:02:45 +02:00
// FIXME - temporary fixes to upload process, check required.
2013-06-15 15:08:03 +02:00
// Probably in need of a rewrite to use process_uploaded_files();
2009-10-28 23:45:46 +00:00
require_once ( e_HANDLER . " upload_handler.php " );
2013-06-15 15:02:45 +02:00
$fileName = $_FILES [ 'file_userfile' ][ 'name' ][ 0 ];
$fileSize = $_FILES [ 'file_userfile' ][ 'size' ][ 0 ];
$fileType = $_FILES [ 'file_userfile' ][ 'type' ][ 0 ]; // type is returned as mime type (application/octet-stream) not as zip/rar
// There may be a better way to do this.. MIME may not be secure enough
2013-06-15 15:08:03 +02:00
// process_uploaded_files() ?
2013-06-15 15:02:45 +02:00
$mime_zip = array ( " application/octet-stream " , " application/zip " , " multipart/x-zip " );
$mime_gzip = array ( " application/x-gzip " , " multipart/x-gzip " );
// rar?
2009-10-28 23:45:46 +00:00
2013-06-15 15:02:45 +02:00
if ( in_array ( $fileType , $mime_zip ))
2009-10-28 23:45:46 +00:00
{
2013-06-15 15:02:45 +02:00
$fileType = " zip " ;
2009-10-28 23:45:46 +00:00
}
2013-06-15 15:02:45 +02:00
elseif ( in_array ( $fileType , $mime_gzip ))
2009-10-28 23:45:46 +00:00
{
2013-06-15 15:02:45 +02:00
$fileType = " gzip " ;
2009-10-28 23:45:46 +00:00
}
else
{
2013-06-15 15:02:45 +02:00
$mes -> addError ( TPVLAN_17 );
2009-07-18 03:41:49 +00:00
return FALSE ;
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
if ( $fileSize )
{
2009-10-28 23:52:56 +00:00
2013-06-15 15:02:45 +02:00
$uploaded = file_upload ( e_THEME );
2006-12-02 04:36:16 +00:00
$archiveName = $uploaded [ 0 ][ 'name' ];
2009-10-28 23:45:46 +00:00
if ( $fileType == " zip " )
{
require_once ( e_HANDLER . " pclzip.lib.php " );
2006-12-02 04:36:16 +00:00
$archive = new PclZip ( e_THEME . $archiveName );
2013-06-15 15:02:45 +02:00
$unarc = ( $fileList = $archive -> extract ( PCLZIP_OPT_PATH , e_THEME , PCLZIP_OPT_SET_CHMOD , 0666 )); // FIXME - detect folder structure similar to 'Find themes'
2009-10-28 23:45:46 +00:00
}
else
{
require_once ( e_HANDLER . " pcltar.lib.php " );
2013-06-15 15:02:45 +02:00
$unarc = ( $fileList = PclTarExtract ( $archiveName , e_THEME )); // FIXME - detect folder structure similar to 'Find themes'
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2009-07-18 03:41:49 +00:00
if ( ! $unarc )
{
if ( $fileType == " zip " )
{
2009-10-28 23:45:46 +00:00
$error = TPVLAN_46 . " ' " . $archive -> errorName ( TRUE ) . " ' " ;
2009-07-18 03:41:49 +00:00
}
else
{
$error = TPVLAN_47 . PclErrorString () . " , " . TPVLAN_48 . intval ( PclErrorCode ());
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2013-06-15 15:02:45 +02:00
$mes -> addError ( TPVLAN_18 . " " . $archiveName . " " . $error );
2009-07-18 03:41:49 +00:00
return FALSE ;
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
$folderName = substr ( $fileList [ 0 ][ 'stored_filename' ], 0 , ( strpos ( $fileList [ 0 ][ 'stored_filename' ], " / " )));
2013-06-15 15:02:45 +02:00
$mes -> addSuccess ( TPVLAN_19 );
2009-10-28 23:45:46 +00:00
2009-07-18 03:41:49 +00:00
if ( varset ( $_POST [ 'setUploadTheme' ]))
{
$themeArray = $this -> getThemes ();
$this -> id = $themeArray [ $folderName ][ 'id' ];
2013-03-28 00:41:29 -07:00
if ( $this -> setTheme ())
{
$mes -> addSuccess ( TPVLAN_3 );
}
else
{
2013-06-15 15:02:45 +02:00
$mes -> addError ( " Could not change site theme. " ); // TODO LAN
2013-03-28 00:41:29 -07:00
}
2009-10-28 23:52:56 +00:00
2009-07-18 03:41:49 +00:00
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
@ unlink ( e_THEME . $archiveName );
}
}
2015-02-10 23:13:53 -08:00
*
*/
2006-12-02 04:36:16 +00:00
}
2013-05-07 03:47:32 -07:00
2022-04-04 10:54:24 -07:00
/**
* @ param $name
* @ param $searchVal
* @ param $submitName
* @ param $filterName
* @ param $filterArray
* @ param $filterVal
* @ return string
*/
2013-05-07 03:47:32 -07:00
private function search ( $name , $searchVal , $submitName , $filterName = '' , $filterArray = false , $filterVal = false )
{
$frm = e107 :: getForm ();
2015-02-04 04:01:08 -08:00
return $frm -> search ( $name , $searchVal , $submitName , $filterName , $filterArray , $filterVal );
2019-01-31 14:35:57 -08:00
/*
2013-05-07 03:47:32 -07:00
$text = ' < span class = " input-append e-search " >< i class = " icon-search " ></ i >
'.$frm->text($name, $searchVal,20,' class = search - query ').'
< button class = " btn btn-primary " name = " '. $submitName .' " type = " submit " > '.LAN_GO.' </ button >
</ span > ' ;
// $text .= $this->admin_button($submitName,LAN_SEARCH,'search');
return $text ;
2019-01-31 14:35:57 -08:00
*/
2013-05-07 03:47:32 -07:00
}
2013-05-17 16:24:50 +03:00
/**
* Temporary , e107 :: getMarketplace () coming soon
* @ return e_marketplace
*/
public function getMarketplace ()
{
if ( null === $this -> mp )
{
require_once ( e_HANDLER . 'e_marketplace.php' );
2013-05-19 18:58:17 +03:00
$this -> mp = new e_marketplace (); // autodetect the best method
2013-05-17 16:24:50 +03:00
}
return $this -> mp ;
}
2013-01-25 19:30:26 -08:00
2021-01-27 08:45:34 -08:00
/*
2013-05-07 03:47:32 -07:00
function renderOnline ( $ajax = false )
2013-05-06 20:47:46 -07:00
{
2013-05-17 16:24:50 +03:00
global $e107SiteUsername , $e107SiteUserpass ;
2013-05-06 20:47:46 -07:00
$xml = e107 :: getXml ();
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
2013-05-17 16:24:50 +03:00
$mp = $this -> getMarketplace ();
2013-05-06 20:47:46 -07:00
$from = intval ( varset ( $_GET [ 'frm' ]));
2013-05-17 16:24:50 +03:00
$limit = 96 ; // FIXME - ajax pages load
2020-12-20 11:50:10 -08:00
$srch = preg_replace ( '/[\W]/' , '' , vartrue ( $_GET [ 'srch' ]));
2013-03-04 00:47:56 -08:00
2013-05-14 22:42:06 +02:00
// check for cURL
2017-01-06 13:50:15 -08:00
if ( ! function_exists ( 'curl_init' ))
2013-05-14 22:42:06 +02:00
{
2016-11-02 11:12:09 +01:00
$mes -> addWarning ( TPVLAN_79 );
2013-05-14 22:42:06 +02:00
}
2013-05-17 16:24:50 +03:00
// auth
2020-12-22 14:48:28 -08:00
// $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
2013-05-17 16:24:50 +03:00
// do the request, retrieve and parse data
$xdata = $mp -> call ( 'getList' , array (
'type' => 'theme' ,
'params' => array ( 'limit' => $limit , 'search' => $srch , 'from' => $from )
));
$total = $xdata [ 'params' ][ 'count' ];
2021-01-27 08:45:34 -08:00
2013-03-17 02:57:09 -07:00
$amount = $limit ;
2021-01-27 08:45:34 -08:00
2013-01-25 19:30:26 -08:00
$c = 1 ;
2017-11-20 14:45:37 -08:00
$filterName = '' ;
$filterArray = array ();
$filterVal = '' ;
2013-03-04 00:47:56 -08:00
2013-05-07 03:47:32 -07:00
$text = " <form class='form-search' action=' " . e_SELF . " ? " . e_QUERY . " ' id='core-plugin-list-form' method='get'> " ;
$text .= '<div id="myCarousel" class="carousel slide" data-interval="false">' ;
$text .= " <div class='form-inline clearfix row-fluid'> " ;
$text .= $this -> search ( 'srch' , $srch , 'go' , $filterName , $filterArray , $filterVal ) . $frm -> hidden ( 'mode' , 'online' );
$text .= '<div class="btn-group" style="margin-left:10px"><a class="btn btn-primary" href="#myCarousel" data-slide="prev">‹</a><a class="btn btn-primary" href="#myCarousel" data-slide="next">›</a></div>' ;
$text .= " { CAROUSEL_INDICATORS} " ;
$text .= " </div> " ;
$text .= '<div id="shop" style="margin-top:10px;min-height:585px" class=" carousel-inner">' ;
2013-05-19 18:58:17 +03:00
2013-05-17 16:24:50 +03:00
if ( is_array ( $xdata [ 'data' ] ))
2013-01-25 19:30:26 -08:00
{
2013-05-06 20:47:46 -07:00
2013-05-07 03:47:32 -07:00
$text .= '<div class="active item">' ;
2013-05-06 20:47:46 -07:00
$slides = array ();
2013-05-17 16:24:50 +03:00
foreach ( $xdata [ 'data' ] as $r )
2013-03-03 16:53:17 -08:00
{
2013-03-04 03:39:27 -08:00
if ( E107_DBG_PATH )
{
$mes -> addDebug ( print_a ( $r , true ));
}
$theme = array (
2013-05-19 12:16:10 +03:00
'id' => $r [ 'params' ][ 'id' ],
'type' => 'theme' ,
'mode' => $r [ 'params' ][ 'mode' ],
2013-05-17 16:24:50 +03:00
'name' => stripslashes ( $r [ 'name' ]),
2013-03-04 03:39:27 -08:00
'category' => $r [ 'category' ],
2013-05-18 12:07:59 +03:00
'preview' => varset ( $r [ 'screenshots' ][ 'image' ]),
2013-05-17 16:24:50 +03:00
'date' => $r [ 'date' ],
'version' => $r [ 'version' ],
'thumbnail' => $r [ 'thumbnail' ],
2014-05-12 18:52:57 -07:00
'url' => $r [ 'urlView' ],
2013-05-17 16:24:50 +03:00
'author' => $r [ 'author' ],
'website' => $r [ 'authorUrl' ],
'compatibility' => $r [ 'compatibility' ],
'description' => $r [ 'description' ],
'price' => $r [ 'price' ],
'livedemo' => $r [ 'livedemo' ],
2013-03-04 03:39:27 -08:00
);
2015-07-17 23:09:36 -07:00
2013-03-04 03:39:27 -08:00
$text .= $this -> renderTheme ( FALSE , $theme );
2013-05-06 20:47:46 -07:00
$c ++ ;
if ( $c == 19 )
{
$text .= '</div><div class="item">' ;
$slides [] = 1 ;
$c = 1 ;
}
2021-01-27 08:45:34 -08:00
2013-03-04 03:39:27 -08:00
}
2013-05-06 20:47:46 -07:00
2013-03-04 03:39:27 -08:00
$text .= " <div class='clear'> </div> " ;
2013-05-06 20:47:46 -07:00
$text .= " </div> " ;
$text .= " </div> " ;
2013-03-04 03:39:27 -08:00
}
else
{
2016-11-02 11:12:09 +01:00
$mes -> addInfo ( TPVLAN_80 );
2013-01-25 19:30:26 -08:00
}
2013-03-17 02:57:09 -07:00
2015-07-14 12:13:46 -07:00
$indicators = ' < ol class = " carousel-indicators col-md-6 span6 " >
2013-05-06 20:47:46 -07:00
< li data - target = " #myCarousel " data - slide - to = " 0 " class = " active " ></ li > ' ;
2013-03-04 03:39:27 -08:00
2013-05-06 20:47:46 -07:00
foreach ( $slides as $key => $v )
{
$id = $key + 1 ;
2021-01-01 09:33:51 -08:00
$indicators .= '<li data-target="#myCarousel" data-slide-to="' . $id . '" data-bs-slide-to="' . $id . '"></li>' ;
2013-05-06 20:47:46 -07:00
}
2013-03-04 03:39:27 -08:00
2013-05-06 20:47:46 -07:00
$indicators .= '</ol>' ;
$text = str_replace ( " { CAROUSEL_INDICATORS} " , $indicators , $text );
$text .= " </form> " ;
2016-01-30 16:58:58 +01:00
$ns -> tablerender ( TPVLAN_26 . SEP . TPVLAN_69 , $mes -> render () . $text );
2013-05-06 20:47:46 -07:00
}
2021-01-27 08:45:34 -08:00
*/
2013-05-06 20:47:46 -07:00
2021-01-27 08:45:34 -08:00
/*
2013-05-06 20:47:46 -07:00
function showThemes ( $mode = 'main' )
{
global $pref ;
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$tp = e107 :: getParser ();
$frm = e107 :: getForm ();
2013-05-06 21:28:05 -07:00
2013-05-06 20:47:46 -07:00
echo " <div> " ;
if ( $mode == " main " || ! $mode ) // Show Main Configuration
{
foreach ( $this -> themeArray as $key => $theme )
{
if ( $key == $pref [ 'sitetheme' ])
{
$text = $this -> renderTheme ( 1 , $theme );
}
}
2016-11-11 10:10:04 +01:00
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ?mode= " . $mode . " '> \n " ;
2013-05-06 20:47:46 -07:00
$ns -> tablerender ( TPVLAN_26 . SEP . TPVLAN_33 , $mes -> render () . $text );
echo " </form> " ;
}
// Show Admin Configuration
if ( $mode == " admin " )
{
2013-01-25 19:30:26 -08:00
2013-05-06 20:47:46 -07:00
foreach ( $this -> themeArray as $key => $theme )
{
if ( $key == $pref [ 'admintheme' ])
{
$text = $this -> renderTheme ( 2 , $theme );
}
}
2016-11-11 10:10:04 +01:00
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ?mode= " . $mode . " '> \n " ;
2013-05-06 20:47:46 -07:00
$ns -> tablerender ( TPVLAN_26 . SEP . TPVLAN_34 , $mes -> render () . $text );
echo " </form> " ;
}
2013-01-25 19:30:26 -08:00
2013-05-06 20:47:46 -07:00
// Show Upload Form
if ( $mode == " upload " )
{
$this -> renderUploadForm ();
2013-03-04 03:39:27 -08:00
}
2013-01-25 19:30:26 -08:00
2013-05-06 20:47:46 -07:00
// Show All Themes
if ( $mode == " choose " )
{
$text = " " ;
foreach ( $this -> themeArray as $key => $theme )
{
$text .= $this -> renderTheme ( FALSE , $theme );
// print_a($theme);
}
$text .= " <div class='clear'> </div> " ;
2016-11-11 10:10:04 +01:00
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ?mode= " . $mode . " '> \n " ;
2013-05-06 20:47:46 -07:00
$ns -> tablerender ( TPVLAN_26 . SEP . TPVLAN_39 , $mes -> render () . $text );
$text .= " </form> " ;
}
2012-11-28 04:32:05 -08:00
2013-05-06 20:47:46 -07:00
if ( $mode == " online " )
{
$this -> renderOnline ();
}
echo " </div> \n " ;
2009-07-10 14:25:23 +00:00
}
2021-01-27 08:45:34 -08:00
*/
2009-07-10 14:25:23 +00:00
2012-11-28 04:32:05 -08:00
2021-01-27 08:45:34 -08:00
/*
2013-06-13 16:03:45 +02:00
function renderUploadForm ()
2009-07-10 14:25:23 +00:00
{
2012-11-28 02:22:23 -08:00
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
2013-06-13 16:03:45 +02:00
$frm = e107 :: getForm ();
2009-10-28 23:45:46 +00:00
if ( ! is_writable ( e_THEME ))
{
$ns -> tablerender ( TPVLAN_16 , TPVLAN_15 );
$text = " " ;
}
else
{
2013-06-13 16:03:45 +02:00
require_once ( e_HANDLER . 'upload_handler.php' );
2009-10-28 23:45:46 +00:00
$max_file_size = get_user_max_upload ();
$text = "
2013-06-13 16:03:45 +02:00
< form enctype = 'multipart/form-data' action = '".e_SELF."' method = 'post' >
2012-11-26 03:23:20 -08:00
< table class = 'table adminform' >
2012-05-17 05:09:59 +00:00
< colgroup >
2009-07-10 14:25:23 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2009-07-06 05:59:42 +00:00
< tr >
2013-06-13 16:03:45 +02:00
< td > " .TPVLAN_13. " </ td >
< td >
< input type = 'hidden' name = 'MAX_FILE_SIZE' value = '{$max_file_size}' />
< input type = 'hidden' name = 'ac' value = '".md5(ADMINPWCHANGE)."' />
< input class = 'tbox' type = 'file' name = 'file_userfile[]' size = '50' />
</ td >
2009-07-18 03:41:49 +00:00
</ tr >
< tr >
2013-06-13 16:03:45 +02:00
< td > " .TPVLAN_10. " </ td >
< td >< input type = 'checkbox' name = 'setUploadTheme' value = '1' /></ td >
2009-07-06 05:59:42 +00:00
</ tr >
</ table >
2009-10-28 23:45:46 +00:00
2015-02-10 23:13:53 -08:00
< div class = 'buttons-bar center' > " . $frm->admin_button ('upload', 1, 'submit', LAN_UPLOAD). " </ div >
2013-06-13 16:03:45 +02:00
</ form >
" ;
2009-10-28 23:45:46 +00:00
}
2017-04-05 12:42:42 -07:00
2013-02-22 21:34:06 -08:00
$ns -> tablerender ( TPVLAN_26 . SEP . TPVLAN_38 , $mes -> render () . $text );
2009-07-10 14:25:23 +00:00
}
2021-01-27 08:45:34 -08:00
*/
2022-04-04 10:54:24 -07:00
/**
* @ param $theme
* @ return string | null
*/
2009-10-28 23:45:46 +00:00
function renderThemeInfo ( $theme )
2006-12-02 04:36:16 +00:00
{
2016-12-21 08:13:23 -08:00
2017-01-06 13:27:48 -08:00
if ( empty ( $theme ))
{
return null ;
}
if ( ! empty ( $theme [ 'compatibility' ]) && $theme [ 'compatibility' ] == 2 )
{
$theme [ 'compatibility' ] = '2.0' ;
}
2020-07-01 13:00:34 -07:00
$version = e107 :: getParser () -> filter ( e_VERSION , 'version' );
$compatLabel = TPVLAN_77 ;
$compatLabelType = 'warning' ;
if ( version_compare ( $theme [ 'compatibility' ], $version , '<=' ) === false )
{
$compatLabelType = 'danger' ;
$compatLabel = defset ( 'TPVLAN_97' , " This theme requires a newer version of e107. " );
}
2017-01-06 13:27:48 -08:00
2009-10-28 23:45:46 +00:00
global $pref ;
2017-01-06 13:27:48 -08:00
$author = ! empty ( $theme [ 'email' ]) ? " <a href='mailto: " . $theme [ 'email' ] . " ' title=' " . $theme [ 'email' ] . " '> " . $theme [ 'author' ] . " </a> " : $theme [ 'author' ];
$website = ! empty ( $theme [ 'website' ]) ? " <a href=' " . $theme [ 'website' ] . " ' rel='external'> " . $theme [ 'website' ] . " </a> " : " " ;
2016-12-21 08:13:23 -08:00
// $preview = "<a href='".SITEURL."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >".($theme['preview'] ? "<img src='".$theme['preview']."' style='border: 1px solid #000;width:200px' alt='' />" : "<img src='".e_IMAGE_ABS."admin_images/nopreview.png' title='".TPVLAN_12."' alt='' />")."</a>";
2021-01-27 08:45:34 -08:00
$description = vartrue ( $theme [ 'description' ]);
2020-07-01 13:00:34 -07:00
$compat = ( version_compare ( 1.9 , $theme [ 'compatibility' ], '<' )) ? " <span class='label label- " . $compatLabelType . " '> " . $theme [ 'compatibility' ] . " </span><span class='text- " . $compatLabelType . " '> " . $compatLabel . " </span> " : vartrue ( $theme [ 'compatibility' ], '1.0' );
2021-01-30 19:21:23 -08:00
$price = ( ! empty ( $theme [ 'price' ])) ? " <span class='label label-primary'><i class='fa fa-shopping-cart icon-white'></i> " . $theme [ 'price' ] . " </span> " : " <span class='label label-success'> " . TPVLAN_76 . " </span> " ;
2017-01-06 13:27:48 -08:00
2017-10-15 11:55:46 -07:00
$text = e107 :: getForm () -> open ( 'theme-info' , 'post' );
$text .= " <table class='table table-striped'> " ;
2017-01-06 13:27:48 -08:00
2013-03-03 16:53:17 -08:00
// $text .= "<tr><th colspan='2'><h3>".$theme['name']." ".$theme['version']."</h3></th></tr>";
2017-01-06 13:27:48 -08:00
$text .= " <tr><td style='vertical-align:top; width:24%'><b> " . TPVLAN_75 . " </b>:</td><td style='vertical-align:top'> " . $price . " </td></tr> " ;
2013-03-03 17:50:30 -08:00
2017-01-06 13:27:48 -08:00
$text .= ( $author ) ? " <tr><td style='vertical-align:top; width:24%'><b> " . LAN_AUTHOR . " </b>:</td><td style='vertical-align:top'> " . $author . " </td></tr> " : " " ;
$text .= ( $website ) ? " <tr><td style='vertical-align:top; width:24%'><b> " . TPVLAN_5 . " </b>:</td><td style='vertical-align:top'> " . $website . " </td></tr> " : " " ;
$text .= ! empty ( $theme [ 'date' ]) ? " <tr><td style='vertical-align:top; width:24%'><b> " . TPVLAN_6 . " </b>:</td><td style='vertical-align:top'> " . $theme [ 'date' ] . " </td></tr> " : " " ;
2013-03-03 17:50:30 -08:00
$text .= $compat ? " <tr><td style='vertical-align:top; width:24%'><b> " . TPVLAN_57 . " </b>:</td><td style='vertical-align:top'> " . $compat . " </td></tr> " : " " ;
2017-01-06 13:27:48 -08:00
$text .= ! empty ( $description ) ? " <tr><td style='vertical-align:top; width:24%'><b> " . LAN_DESCRIPTION . " </b>:</td><td style='vertical-align:top'> " . $description . " </td></tr> " : " " ;
2013-01-31 01:49:00 -08:00
// $text .= "<tr><td style='vertical-align:top; width:24%'><b>".TPVLAN_49."</b>:</td>
// <td style='vertical-align:top'>XHTML ";
// $text .= ($theme['xhtmlcompliant']) ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON;
// $text .= " CSS ";
// $text .= ($theme['csscompliant']) ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON;
// $text .= "</td></tr>";
2017-01-06 13:27:48 -08:00
if ( ! empty ( $theme [ 'category' ]))
2013-01-31 01:49:00 -08:00
{
2016-11-02 11:12:09 +01:00
$text .= " <tr><td><b> " . LAN_CATEGORY . " </b></td><td> " . $theme [ 'category' ] . " </td></tr> " ;
2013-01-31 01:49:00 -08:00
}
2017-10-15 11:55:46 -07:00
if ( is_dir ( e_THEME . $theme [ 'path' ] . " /.git " ))
{
$text .= " <tr><td><b>Developer</b></td>
< td > " . $this->frm ->admin_button('git_pull', $theme['path'] , 'primary', e107::getParser()->toGlyph('fa-refresh'). " Git Sync " ). " </ td ></ tr > " ;
}
2013-03-03 16:53:17 -08:00
2016-05-24 11:08:22 -07:00
$itext = '' ;
2017-01-06 13:27:48 -08:00
if ( ! empty ( $theme [ 'layouts' ]))
2008-11-17 07:17:23 +00:00
{
2009-10-28 23:45:46 +00:00
$itext .= " <tr>
2009-10-31 00:36:09 +00:00
< td style = 'vertical-align:top; width:24%' >< b > " .TPVLAN_50. " </ b >:</ td >
2013-03-15 23:35:16 -07:00
< td class = 'well' style = 'vertical-align:top' >
2015-02-06 01:03:09 -08:00
< table class = 'table table-striped table-bordered' style = 'margin-left:0px;margin-right:auto' >
2008-11-17 07:17:23 +00:00
< tr > " ;
2017-01-06 13:27:48 -08:00
// $itext .= ($mode == 1) ? "<td class='fcaption' style='text-align:center;vertical-align:top;'>".TPVLAN_55."</td>" : "";
2009-10-28 23:45:46 +00:00
$itext .= "
2016-11-02 17:46:24 +01:00
< th class = 'fcaption' > " .LAN_TITLE. " </ th >
2016-11-02 11:12:09 +01:00
< th class = 'fcaption' > " .TPVLAN_78. " </ th >
< th class = 'fcaption' style = 'text-align:center;width:100px' > " .TPVLAN_54. " </ th >
2008-11-17 07:17:23 +00:00
</ tr > \n " ;
2009-10-28 23:52:56 +00:00
2009-10-28 23:45:46 +00:00
foreach ( $theme [ 'layouts' ] as $key => $val )
{
$itext .= "
2008-11-17 07:17:23 +00:00
< tr > " ;
2017-01-06 13:27:48 -08:00
/* if ( $mode == 1 )
2008-11-17 07:17:23 +00:00
{
2009-07-05 11:57:40 +00:00
if ( ! $pref [ 'sitetheme_deflayout' ])
2008-11-17 07:17:23 +00:00
{
2009-10-28 23:45:46 +00:00
$pref [ 'sitetheme_deflayout' ] = ( $val [ '@attributes' ][ 'default' ] == 'true' ) ? $key : " " ;
// echo "------------- NODEFAULT";
2008-11-17 07:17:23 +00:00
}
$itext .= "
2009-10-31 00:36:09 +00:00
< td style = 'vertical-align:top width:auto;text-align:center' >
2009-10-28 23:45:46 +00:00
< input type = 'radio' name = 'layout_default' value = '{$key}' " .( $pref['sitetheme_deflayout'] == $key ? " checked = 'checked' " : " " ). " />
2008-11-17 07:17:23 +00:00
</ td > " ;
2017-01-06 13:27:48 -08:00
} */
2009-10-28 23:45:46 +00:00
2009-10-31 00:36:09 +00:00
$itext .= " <td style='vertical-align:top'> " ;
2017-01-06 13:27:48 -08:00
$itext .= ! empty ( $val [ '@attributes' ][ 'previewFull' ]) ? " <a href=' " . e_THEME_ABS . $theme [ 'path' ] . " / " . $val [ '@attributes' ][ 'previewFull' ] . " ' > " : " " ;
2008-11-17 07:17:23 +00:00
$itext .= $val [ '@attributes' ][ 'title' ];
2017-01-06 13:27:48 -08:00
$itext .= ! empty ( $val [ '@attributes' ][ 'previewFull' ]) ? " </a> " : " " ;
2009-10-28 23:45:46 +00:00
$itext .= ( $pref [ 'sitetheme_deflayout' ] == $key ) ? " (default) " : " " ;
2008-11-17 07:17:23 +00:00
$itext .= " </td>
2017-01-06 13:27:48 -08:00
< td style = 'vertical-align:top' > " .varset( $val['@attributes'] ['plugins']). " & nbsp ; </ td >
2009-10-31 00:36:09 +00:00
< td style = 'vertical-align:top;text-align:center' > " ;
2017-01-06 13:27:48 -08:00
$itext .= ! empty ( $val [ 'menuPresets' ]) ? ADMIN_TRUE_ICON : " " ;
2009-10-28 23:45:46 +00:00
$itext .= " </td>
2008-11-17 07:17:23 +00:00
</ tr > " ;
}
2013-03-03 16:53:17 -08:00
2009-10-28 23:45:46 +00:00
2008-11-17 07:17:23 +00:00
$itext .= " </table></td></tr> " ;
}
2009-10-28 23:45:46 +00:00
2013-03-03 16:53:17 -08:00
2013-01-31 01:49:00 -08:00
// $text .= "<tr><td><b>".TPVLAN_22.": </b></td><td colspan='2'>";
// foreach ($theme['css'] as $val)
// {
// $text .= $val['name']."<br />";
// }
// $text .= "</td></tr>";
2009-10-28 23:45:46 +00:00
$text .= $itext . " </table> " ;
2017-10-15 11:55:46 -07:00
$text .= e107 :: getForm () -> close ();
2013-03-03 16:53:17 -08:00
if ( count ( $theme [ 'preview' ]))
{
2015-07-17 23:09:36 -07:00
$text .= " <div class='clearfix'> " ;
2013-03-03 16:53:17 -08:00
foreach ( $theme [ 'preview' ] as $pic )
{
2021-01-24 17:00:02 -08:00
$picFull = ( strpos ( $pic , 'http' ) === 0 ) ? $pic : e_THEME . $theme [ 'path' ] . " / " . $pic ;
2013-03-03 16:53:17 -08:00
2015-07-17 23:09:36 -07:00
$text .= " <div class='col-md-6'>
2017-01-20 10:40:05 -08:00
< img class = 'img-responsive img-fluid' src = '".$picFull."' alt = \ " " . $theme [ 'name' ] . " \" />
2013-03-03 16:53:17 -08:00
</ div > " ;
}
2015-07-17 23:09:36 -07:00
$text .= " </div> " ;
2013-03-03 16:53:17 -08:00
// $text .= "</td>
// </tr>";
}
2012-11-28 04:32:05 -08:00
// $text .= "<div class='right'><a href='#themeInfo_".$theme['id']."' class='e-expandit'>Close</a></div>";
2017-10-15 11:55:46 -07:00
2020-12-18 19:55:12 -08:00
//if(E107_DEBUG_LEVEL > 0)
// {
2017-01-06 13:27:48 -08:00
// $text .= print_a($theme, true);
2020-12-18 19:55:12 -08:00
// }
2013-03-03 16:53:17 -08:00
2009-10-28 23:45:46 +00:00
return $text ;
2009-07-06 05:59:42 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2009-10-28 23:45:46 +00:00
function loadThemeConfig ()
2009-07-09 11:37:36 +00:00
{
2012-11-29 22:03:36 -08:00
$mes = e107 :: getMessage ();
2009-10-28 23:45:46 +00:00
2013-06-19 22:50:51 -07:00
$newConfile = e_THEME . $this -> id . " /theme_config.php " ;
2017-01-01 16:27:48 -08:00
$legacyConfile = e_THEME . $this -> id . " / " . $this -> id . " _config.php " ; // @Deprecated
2013-06-19 22:50:51 -07:00
if ( is_readable ( $newConfile ))
{
2017-01-01 16:27:48 -08:00
$confile = $newConfile ;
2013-06-19 22:50:51 -07:00
}
elseif ( is_readable ( $legacyConfile )) // TODO Eventually remove it.
{
// NOTE: this is debug info.. do not translate.
e107 :: getMessage () -> addDebug ( " Deprecated Theme Config File found! Rename <b> " . $this -> id . " _config.php.</b> to <b>theme_config.php</b> to correct this issue. . " );
$confile = $legacyConfile ;
}
else
{
return ;
}
if (( $this -> themeConfigObj === null ) )
2009-07-09 11:37:36 +00:00
{
2017-02-02 08:41:09 -08:00
e107 :: getDebug () -> log ( " Loading : " . $confile );
2009-10-28 23:45:46 +00:00
include ( $confile );
2017-01-01 16:54:57 -08:00
$className = 'theme_' . $this -> id ;
if ( class_exists ( 'theme_config' )) // new v2.1.4 theme_config is the class name.
{
$this -> themeConfigObj = new theme_config ();
2017-11-02 14:30:19 -07:00
2020-04-28 14:00:19 -07:00
if ( ! $this -> themeConfigObj instanceof e_theme_config )
{
// debug - no need to translate.
e107 :: getMessage () -> addWarning ( " class <b>theme_config</b> is missing 'implements e_theme_config' " );
}
2017-11-02 14:30:19 -07:00
if ( class_exists ( 'theme_config_form' )) // new v2.1.7
{
$this -> themeConfigFormObj = new theme_config_form ();
}
2017-01-01 16:54:57 -08:00
}
elseif ( class_exists ( $className )) // old way.
2009-08-17 11:25:01 +00:00
{
$this -> themeConfigObj = new $className ();
}
else
{
2017-01-01 16:54:57 -08:00
$this -> themeConfigObj = false ;
2009-08-17 11:25:01 +00:00
}
2009-10-28 23:45:46 +00:00
}
2009-10-28 23:52:56 +00:00
2009-07-09 11:37:36 +00:00
}
2009-10-28 23:45:46 +00:00
2009-10-28 23:52:56 +00:00
// TODO process custom theme configuration - .
2022-04-04 10:54:24 -07:00
/**
* @ return string | void
*/
2009-10-28 23:52:56 +00:00
function renderThemeConfig ()
2009-07-06 05:59:42 +00:00
{
2012-11-29 22:03:36 -08:00
$mes = e107 :: getMessage ();
2017-11-02 14:30:19 -07:00
$frm = ( $this -> themeConfigFormObj !== null ) ? $this -> themeConfigFormObj : e107 :: getForm ();
2017-01-29 13:47:20 -08:00
$pref = e107 :: getConfig () -> getPref ();
2017-04-12 09:50:07 -07:00
e107 :: getDebug () -> log ( " Rendering Theme Config " );
2009-10-28 23:45:46 +00:00
$this -> loadThemeConfig ();
2017-01-01 16:27:48 -08:00
2017-01-03 07:48:52 -08:00
$value = e107 :: getThemeConfig ( $this -> id ) -> getPref ();
2017-01-01 16:27:48 -08:00
2017-01-29 13:47:20 -08:00
if ( empty ( $value ) && ! empty ( $pref [ 'sitetheme_pref' ]))
{
$value = $pref [ 'sitetheme_pref' ];
}
2009-10-28 23:45:46 +00:00
if ( $this -> themeConfigObj )
{
$var = call_user_func ( array ( & $this -> themeConfigObj , 'config' ));
2017-01-01 16:27:48 -08:00
$text = '' ; // avoid notice
2017-11-02 14:30:19 -07:00
2017-01-01 16:27:48 -08:00
foreach ( $var as $field => $val )
2009-07-09 11:37:36 +00:00
{
2017-01-01 16:27:48 -08:00
if ( is_numeric ( $field ))
{
2017-11-02 14:30:19 -07:00
$text .= " <tr><td><b> " . $val [ 'caption' ] . " </b>:</td><td colspan='2'> " . $val [ 'html' ] . " <div class='field-help'> " . $val [ 'help' ] . " </div></td></tr> " ;
2017-01-01 16:27:48 -08:00
}
else
{
2017-01-03 07:48:52 -08:00
if ( ! empty ( $val [ 'multilan' ]) && isset ( $value [ $field ][ e_LANGUAGE ]))
2017-01-01 16:27:48 -08:00
{
2021-01-27 08:45:34 -08:00
$value [ $field ] = varset ( $value [ $field ][ e_LANGUAGE ]);
2017-01-01 16:27:48 -08:00
}
2017-01-29 13:47:20 -08:00
$tdClass = ! empty ( $val [ 'writeParms' ][ 'post' ]) ? 'form-inline' : '' ;
2021-01-16 13:32:35 -08:00
$text .= " <tr><td><b> " . $val [ 'title' ] . " </b>:</td><td class=' " . $tdClass . " ' colspan='2'> " . $frm -> renderElement ( $field , varset ( $value [ $field ]), $val ) . " <div class='field-help'> " . varset ( $val [ 'help' ]) . " </div></td></tr> " ;
2017-01-01 16:27:48 -08:00
}
2009-07-09 11:37:36 +00:00
}
2014-06-13 12:02:54 +02:00
2009-10-28 23:45:46 +00:00
return $text ;
}
2009-10-28 23:52:56 +00:00
2009-07-09 11:37:36 +00:00
}
2017-01-01 16:27:48 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed | void
*/
2009-07-09 11:37:36 +00:00
function renderThemeHelp ()
{
2009-08-17 11:25:01 +00:00
if ( $this -> themeConfigObj )
2009-10-28 23:45:46 +00:00
{
2009-08-27 12:58:29 +00:00
return call_user_func ( array ( & $this -> themeConfigObj , 'help' ));
2009-07-09 11:37:36 +00:00
}
2009-07-06 05:59:42 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return bool | mixed | void
*/
2009-07-06 05:59:42 +00:00
function setThemeConfig ()
{
2009-10-28 23:45:46 +00:00
$this -> loadThemeConfig ();
2017-01-01 16:54:57 -08:00
2009-10-28 23:45:46 +00:00
if ( $this -> themeConfigObj )
{
2017-01-01 16:54:57 -08:00
$name = get_class ( $this -> themeConfigObj );
if ( $name === 'theme_config' ) // v2.1.4 - don't use process() method.
{
$pref = e107 :: getThemeConfig ();
2021-03-19 12:14:16 +02:00
$values = e107 :: getThemeConfig ( $this -> id ) -> getPref ();
2017-01-01 16:54:57 -08:00
$fields = call_user_func ( array ( & $this -> themeConfigObj , 'config' ));
foreach ( $fields as $field => $data )
{
2021-03-19 12:14:16 +02:00
if ( ! empty ( $data [ 'multilan' ]))
{
$values [ $field ][ e_LANGUAGE ] = $_POST [ $field ][ e_LANGUAGE ];
} else {
$values [ $field ] = $_POST [ $field ];
}
2017-01-01 16:54:57 -08:00
}
2021-03-19 12:14:16 +02:00
if ( $pref -> setPref ( $values ) -> save ( true , true , false ))
2017-01-29 13:47:20 -08:00
{
$siteThemePref = e107 :: getConfig () -> get ( 'sitetheme_pref' );
if ( ! empty ( $siteThemePref ))
{
2021-01-27 08:45:34 -08:00
e107 :: getConfig () -> set ( 'sitetheme_pref' ) -> save ( false , true , false ); // remove old theme pref
2017-01-29 13:47:20 -08:00
}
}
2017-01-29 15:10:32 -08:00
// if($pref->dataHasChanged())
2017-01-29 13:47:20 -08:00
{
2017-01-29 15:10:32 -08:00
e107 :: getCache () -> clearAll ( 'library' ); // Need to clear cache in order to refresh library information.
2017-01-29 13:47:20 -08:00
}
return true ;
2017-01-01 16:54:57 -08:00
}
2017-01-29 15:10:32 -08:00
e107 :: getCache () -> clearAll ( 'library' );
2017-01-01 16:54:57 -08:00
return call_user_func ( array ( & $this -> themeConfigObj , 'process' )); //pre v2.1.4
2009-08-17 11:25:01 +00:00
}
2009-07-06 05:59:42 +00:00
}
2009-10-28 23:45:46 +00:00
2013-01-30 16:51:06 -08:00
/**
mode = 0 :: normal
mode = 1 :: selected site theme
mode = 2 :: selected admin theme
*/
2020-11-27 17:00:32 +01:00
function renderTheme ( $mode = 0 , $theme = array ())
2009-07-06 05:59:42 +00:00
{
2012-12-11 00:34:08 -08:00
$ns = e107 :: getRender ();
$pref = e107 :: getPref ();
$frm = e107 :: getForm ();
2014-01-22 06:10:44 -08:00
$tp = e107 :: getParser ();
2019-05-27 10:45:35 -07:00
2013-01-30 16:51:06 -08:00
$author = ( $theme [ 'email' ] ? " <a href='mailto: " . $theme [ 'email' ] . " ' title=' " . $theme [ 'email' ] . " '> " . $theme [ 'author' ] . " </a> " : $theme [ 'author' ]);
$website = ( $theme [ 'website' ] ? " <a href=' " . $theme [ 'website' ] . " ' rel='external'> " . $theme [ 'website' ] . " </a> " : " " );
2013-05-06 20:47:46 -07:00
// $preview = "<a href='".e_BASE."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >".($theme['preview'] ? "<img src='".$theme['preview']."' style='border: 1px solid #000;width:200px' alt='' />" : "<img src='".e_IMAGE_ABS."admin_images/nopreview.png' title='".TPVLAN_12."' alt='' />")."</a>";
2021-01-27 08:45:34 -08:00
// $main_icon = ($pref['sitetheme'] != $theme['path']) ? "<button class='btn btn-default btn-secondary btn-small btn-sm btn-inverse' type='submit' name='selectmain[".$theme['id']."]' alt=\"".TPVLAN_10."\" title=\"".TPVLAN_10."\" >".$tp->toGlyph('fa-home',array('size'=>'2x'))."</button>" : "<button class='btn btn-small btn-default btn-secondary btn-sm btn-inverse' type='button'>".$tp->toGlyph('fa-check',array('size'=>'2x'))."</button>";
2021-01-26 15:08:58 -08:00
// $info_icon = "<a data-toggle='modal' data-bs-toggle='modal' data-target='".e_SELF."' href='#themeInfo_".$theme['id']."' class='e-tip' title='".TPVLAN_7."'><img src='".e_IMAGE_ABS."admin_images/info_32.png' alt='' class='icon S32' /></a>";
2021-01-27 08:45:34 -08:00
// $info_icon = "<a class='btn btn-default btn-secondary btn-small btn-sm btn-inverse e-modal' data-modal-caption=\"".$theme['name']." ".$theme['version']."\" href='".e_SELF."?mode=".varset($_GET['mode'])."&id=".$theme['path']."&action=info' title='".TPVLAN_7."'>".$tp->toGlyph('fa-info-circle',array('size'=>'2x'))."</a>";
2013-05-06 20:47:46 -07:00
// $preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-dialog' href='".e_BASE."index.php?themepreview.".$theme['id']."'>".E_32_SEARCH."</a>";
2021-01-27 08:45:34 -08:00
// $admin_icon = ($pref['admintheme'] != $theme['path'] ) ? "<button class='btn btn-default btn-secondary btn-small btn-sm btn-inverse' type='submit' name='selectadmin[".$theme['id']."]' alt=\"".TPVLAN_32."\" title=\"".TPVLAN_32."\" >".$tp->toGlyph('fa-gears',array('size'=>'2x'))."</button>" : "<button class='btn btn-small btn-default btn-secondary btn-sm btn-inverse' type='button'>".$tp->toGlyph('fa-check',array('size'=>'2x'))."</button>";
2017-04-05 12:42:42 -07:00
2021-02-04 16:22:25 -08:00
$theme [ 'css' ] = $this -> filterStylesheets ( $mode , $theme );
2013-05-06 21:30:58 -07:00
$price = '' ;
2017-02-01 08:54:28 -08:00
2020-12-20 11:50:10 -08:00
if ( strpos ( $theme [ 'thumbnail' ], 'http' ) === 0 )
2013-05-06 20:47:46 -07:00
{
$thumbPath = $theme [ 'thumbnail' ];
$previewPath = $theme [ 'preview' ][ 0 ];
}
2017-02-01 08:54:28 -08:00
elseif ( ! empty ( $theme [ 'thumbnail' ]))
2013-05-06 20:47:46 -07:00
{
2017-02-01 08:54:28 -08:00
$thumbPath = e_THEME . $theme [ 'path' ] . " / " . $theme [ 'thumbnail' ];
$previewPath = e_THEME . $theme [ 'path' ] . " / " . $theme [ 'thumbnail' ];
2017-02-01 14:14:02 -08:00
$class = 'admin-theme-preview' ;
2013-05-06 20:47:46 -07:00
}
else
{
$thumbPath = e_IMAGE_ABS . " admin_images/nopreview.png " ;
$previewPath = e_BASE . " index.php?themepreview. " . $theme [ 'id' ];
2017-02-01 14:14:02 -08:00
$class = 'admin-theme-nopreview' ;
2013-05-06 20:47:46 -07:00
}
2021-02-04 16:22:25 -08:00
if ( $mode === self :: RENDER_ADMINPREFS )
{
foreach ( $theme [ 'css' ] as $val )
{
if (( $pref [ 'admincss' ] === $val [ 'name' ]) && ! empty ( $val [ 'thumbnail' ]) )
{
$thumbPath = e_THEME . $theme [ 'path' ] . " / " . $val [ 'thumbnail' ];
$previewPath = $thumbPath ;
2021-02-05 06:24:54 -08:00
$class = 'admin-theme-preview' ;
2021-02-04 16:22:25 -08:00
break ;
}
}
}
2012-11-28 04:32:05 -08:00
2017-02-01 14:14:02 -08:00
$thumbnail = " <img class=' " . $class . " ' src=' " . $thumbPath . " ' style='max-width:100%' alt='' /> " ;
2013-05-06 20:47:46 -07:00
2021-02-04 16:22:25 -08:00
2018-01-10 15:06:40 -08:00
$preview_icon = " <a class='e-modal btn btn-default btn-secondary btn-sm btn-small btn-inverse' title=' " . TPVLAN_70 . " " . $theme [ 'name' ] . " ' data-modal-caption= \" " . $theme [ 'name' ] . " " . $theme [ 'version' ] . " \" rel='external' href=' " . $previewPath . " '> " . $tp -> toGlyph ( 'fa-search' , array ( 'size' => '2x' )) . " </a> " ;
2013-01-30 18:37:42 -08:00
2021-01-27 08:45:34 -08:00
2009-10-28 23:52:56 +00:00
// Choose a Theme to Install.
2017-02-01 08:54:28 -08:00
2009-10-28 23:45:46 +00:00
$this -> id = $theme [ 'path' ];
2009-10-28 23:52:56 +00:00
// load customn theme configuration fields.
$this -> loadThemeConfig ();
2017-04-05 12:42:42 -07:00
2021-02-04 16:22:25 -08:00
$text = '<div style="padding-bottom:100px">' ;
2017-04-05 12:42:42 -07:00
$text .= "
2013-02-25 02:47:23 -08:00
< ul class = 'nav nav-tabs' >
2025-01-13 11:41:57 -08:00
< li class = 'nav-item active' >< a class = 'nav-link active' data - toggle = 'tab' data - bs - toggle = 'tab' href = '#core-thememanager-configure' > " .LAN_CONFIGURE. " </ a ></ li > " ;
2009-10-28 23:52:56 +00:00
2014-06-14 21:50:13 +02:00
2017-02-01 08:54:28 -08:00
if ( $this -> themeConfigObj && call_user_func ( array ( & $this -> themeConfigObj , 'config' )) && $mode == self :: RENDER_SITEPREFS )
2014-06-14 21:50:13 +02:00
{
2025-01-13 11:41:57 -08:00
$text .= " <li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-customconfig'> " . LAN_PREFS . " </a></li> \n " ;
2014-06-14 21:50:13 +02:00
}
2014-08-10 14:16:25 +02:00
if ( $this -> themeConfigObj && call_user_func ( array ( & $this -> themeConfigObj , 'help' )))
{
2025-01-13 11:41:57 -08:00
$text .= " <li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-help'> " . LAN_HELP . " </a></li> \n " ;
2014-08-10 14:16:25 +02:00
}
2009-10-28 23:45:46 +00:00
2012-11-29 22:03:36 -08:00
$text .= " </ul>
2013-02-25 02:47:23 -08:00
< div class = 'tab-content' >
< div class = 'tab-pane active' id = 'core-thememanager-configure' >
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
< col class = 'col-control' />
</ colgroup >
2016-11-11 10:10:04 +01:00
< tr >
< td >< b > " .TPVLAN_11. " </ b ></ td >
< td > " . $theme['version'] . " </ td >
< td class = 'well center middle' rowspan = '9' style = 'text-align:center; vertical-align:middle;width:25%' > " . $thumbnail . " </ td >
2013-02-25 02:47:23 -08:00
</ tr > " ;
2015-07-02 14:33:04 +01:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . LAN_AUTHOR . " </b>:</td><td style='vertical-align:top'> " . $author . " </td></tr> " ;
2013-02-25 02:47:23 -08:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_5 . " </b>:</td><td style='vertical-align:top'> " . $website . " </td></tr> " ;
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_6 . " </b>:</td><td style='vertical-align:top'> " . $theme [ 'date' ] . " </td></tr> " ;
2009-10-28 23:45:46 +00:00
2013-03-03 17:50:30 -08:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_7 . " </b>:</td><td style='vertical-align:top'> " . strip_tags ( $theme [ 'info' ], 'b' ) . " </td></tr> " ;
2013-02-25 02:47:23 -08:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . LAN_CATEGORY . " </b>:</td><td style='vertical-align:top'> " . $theme [ 'category' ] . " </td></tr> " ;
2016-04-14 14:45:10 -07:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . LAN_FOLDER . " </b>:</td><td style='vertical-align:top'> " . $theme [ 'path' ] . " </td></tr> " ;
// $text .= "<tr><td style='vertical-align:top; width:25%'><b>Price</b>:</td><td style='vertical-align:top'>".$price."</td></tr>";
2016-11-11 10:10:04 +01:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_49 . " </b>:</td><td style='vertical-align:top'> " ;
2016-01-30 16:58:58 +01:00
$text .= ( $theme [ 'xhtmlcompliant' ]) ? " W3C XHTML " . $theme [ 'xhtmlcompliant' ] : TPVLAN_71 ;
2013-02-25 02:47:23 -08:00
$text .= ( $theme [ 'csscompliant' ]) ? " & CSS " . $theme [ 'csscompliant' ] : " " ;
$text .= " </td></tr> " ;
2016-06-02 19:20:58 -07:00
2017-10-15 11:55:46 -07:00
if ( is_dir ( e_THEME . $this -> id . " /.git " ))
{
$text .= " <tr><td><b>Developer</b></td>
< td > " . $this->frm ->admin_button('git_pull', $this->id , 'primary', $tp->toGlyph ('fa-refresh'). " Git Sync " ). " </ td ></ tr > " ;
}
2016-06-02 19:20:58 -07:00
2013-02-25 02:47:23 -08:00
// site theme..
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_SITEPREFS )
2009-10-28 23:45:46 +00:00
{
2013-02-25 02:47:23 -08:00
$text .= "
< tr >
< td style = 'vertical-align:top; width:24%;' >< b > " .TPVLAN_53. " </ b ></ td >
2016-11-11 10:10:04 +01:00
< td style = 'vertical-align:top width:auto;' > " ;
2017-01-06 13:50:15 -08:00
if ( ! empty ( $theme [ 'plugins' ][ 'plugin' ]))
2013-02-25 02:47:23 -08:00
{
2017-01-06 13:50:15 -08:00
$text .= $this -> renderPlugins ( $theme [ 'plugins' ][ 'plugin' ]);
2013-02-25 02:47:23 -08:00
}
$text .= " </td>
2009-07-06 05:59:42 +00:00
</ tr > " ;
2013-02-25 02:47:23 -08:00
2016-02-09 15:57:07 -08:00
/* $text .= "
2013-02-25 02:47:23 -08:00
< tr >
< td style = 'vertical-align:top; width:24%;' >< b > " .TPVLAN_30. " </ b ></ td >
< td colspan = '2' style = 'vertical-align:top width:auto;' >
< input type = 'radio' name = 'image_preload' value = '1' " .( $pref['image_preload'] ? " checked = 'checked' " : " " ). " /> " .TPVLAN_28. " & nbsp ; & nbsp ;
< input type = 'radio' name = 'image_preload' value = '0' " .(! $pref['image_preload'] ? " checked = 'checked' " : " " ). " /> " .TPVLAN_29. "
</ td >
2016-02-09 15:57:07 -08:00
</ tr > " ;*/
2017-02-01 08:54:28 -08:00
2013-02-25 02:47:23 -08:00
$itext = " <tr>
< td style = 'vertical-align:top; width:24%' >< b > " .TPVLAN_50. " </ b >:</ td >
< td colspan = '2' style = 'vertical-align:top' >
2015-02-06 01:03:09 -08:00
< table class = 'table table-bordered table-striped' >
2013-02-25 02:47:23 -08:00
< colgroup >
< col class = 'col-tm-layout-default' style = 'width:10%' />
2014-01-07 08:21:45 -08:00
< col class = 'col-tm-layout-name' style = 'width:40%' />
< col class = 'col-tm-layout-visibility' style = 'width:30%' />
< col class = 'col-tm-layout-preset' style = 'width:20%' />
2013-02-25 02:47:23 -08:00
</ colgroup >
< tr > " ;
2021-01-27 08:45:34 -08:00
$itext .= " <th class='center top'> " . TPVLAN_55 . " </th> " ;
2013-02-25 02:47:23 -08:00
$itext .= "
2014-01-07 08:21:45 -08:00
< th > " .TPVLAN_52. " </ th >
2019-04-06 12:11:05 -07:00
< th > " .TPVLAN_56. " & nbsp ; < a href = '#' class = 'e-tip' title = \ " " . TPVLAN_96 . " \" > " . ADMIN_INFO_ICON . " </a></th>
2014-01-07 08:21:45 -08:00
< th class = 'text-right' style = 'text-align:right' > " .TPVLAN_54. " </ th >
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
</ tr > \n " ;
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
foreach ( $theme [ 'layouts' ] as $key => $val )
{
$itext .= "
< tr > " ;
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_SITEPREFS )
2013-02-25 02:47:23 -08:00
{
if ( ! $pref [ 'sitetheme_deflayout' ])
{
$pref [ 'sitetheme_deflayout' ] = ( $val [ '@attributes' ][ 'default' ] == 'true' ) ? $key : " " ;
}
$itext .= " <td class='center'> \n " ;
2013-06-17 16:45:03 -07:00
$itext .= " <input id=' " . $frm -> name2id ( $key ) . " ' type='radio' name='layout_default' value=' { $key } ' " . ( $pref [ 'sitetheme_deflayout' ] == $key ? " checked='checked' " : " " ) . " />
2013-02-25 02:47:23 -08:00
</ td > " ;
}
2013-06-17 16:45:03 -07:00
$itext .= " <td style='vertical-align:top'><label for=' " . $frm -> name2id ( $key ) . " '> " ;
2013-02-25 02:47:23 -08:00
// $itext .= ($val['@attributes']['previewFull']) ? "<a href='".e_THEME_ABS.$theme['path']."/".$val['@attributes']['previewFull']."' >" : "";
2014-07-26 18:08:10 +02:00
$itext .= $val [ '@attributes' ][ 'title' ] . " </label><div class='field-help'> " . $key . " </div> " ;
2013-02-25 02:47:23 -08:00
// $itext .= ($val['@attributes']['previewFull']) ? "</a>" : "";
$custompage_count = ( isset ( $pref [ 'sitetheme_custompages' ][ $key ])) ? " [ " . count ( $pref [ 'sitetheme_custompages' ][ $key ]) . " ] " : " " ;
$custompage_diz = " " ;
$count = 1 ;
if ( isset ( $pref [ 'sitetheme_custompages' ][ $key ]) && count ( $pref [ 'sitetheme_custompages' ][ $key ]) > 0 )
{
foreach ( $pref [ 'sitetheme_custompages' ][ $key ] as $cp )
{
2019-04-06 12:11:05 -07:00
$custompage_diz .= " <a href='#element-to-be-shown- { $key } ' class='btn btn-default btn-secondary btn-xs btn-mini e-expandit'> " . trim ( $cp ) . " </a> " ;
2013-02-25 02:47:23 -08:00
if ( $count > 4 )
{
$custompage_diz .= " ... " ;
break ;
}
$count ++ ;
}
}
else
{
2019-04-06 12:11:05 -07:00
$custompage_diz = " <a href='#element-to-be-shown- { $key } ' class='e-tip btn btn-xs btn-default btn-secondary btn-mini e-expandit'> " . LAN_NONE . " </a> " ;
2013-02-25 02:47:23 -08:00
}
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
2014-07-26 18:08:10 +02:00
$itext .= " </td>
2013-02-25 02:47:23 -08:00
< td style = 'vertical-align:top' > " ;
// Default
2016-05-24 11:08:22 -07:00
2019-02-03 17:51:34 +01:00
// issue #3663: 1. custompages are "deleted" for the current selected layout
// issue #3663: 2. custompages of the selected layout are not editable
//if($pref['sitetheme_deflayout'] != $key)
//if(isset($pref['sitetheme_custompages'][$key]))
//{
2016-05-24 11:08:22 -07:00
$itext .= $custompage_diz . " <div class='e-hideme' id='element-to-be-shown- { $key } '>
2021-02-17 14:33:35 -08:00
< textarea class = 'input-custompages' style = 'width:97%' rows = '6' placeholder = 'usersettings.php' cols = '20' name = 'custompages[".$key."]' > " .(isset( $pref['sitetheme_custompages'] [ $key ]) ? implode( " \n " , $pref['sitetheme_custompages'] [ $key ]) : " " ). " </ textarea > " ;
2016-05-24 11:08:22 -07:00
2019-04-06 12:11:05 -07:00
2016-05-24 11:08:22 -07:00
//TODO Later.
2016-05-25 15:10:00 -07:00
if ( e_DEBUG === true )
{
$itext .= " <small>(Not functional yet)</small> " ;
$itext .= e107 :: getForm () -> userclass ( 'layoutUserclass[' . $key . ']' , null , null , array ( 'options' => 'public,member,admin,classes,no-excludes' , 'size' => 'xxlarge' ));
}
2016-05-24 11:08:22 -07:00
$itext .= "
</ div > \n " ;
2019-02-03 17:51:34 +01:00
//}
//else
//{
// $itext .= TPVLAN_55;
//}
2016-05-24 11:08:22 -07:00
2013-02-25 02:47:23 -08:00
$itext .= " </td> " ;
2016-05-24 11:08:22 -07:00
2013-02-25 02:47:23 -08:00
$itext .= " <td> " ;
2013-12-30 06:23:12 -08:00
if ( varset ( $val [ 'menuPresets' ]))
{
2013-12-31 00:59:30 -08:00
$itext .= $this -> renderPresets ( $key );
2013-12-30 06:23:12 -08:00
}
2013-02-25 02:47:23 -08:00
$itext .= " </td>
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
</ tr > " ;
}
2016-06-02 19:20:58 -07:00
2013-02-25 02:47:23 -08:00
$itext .= " </table></td></tr> " ;
}
2009-10-24 07:53:30 +00:00
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
// $itext .= !$mode ? "<tr><td style='vertical-align:top;width:24%'><b>".TPVLAN_8."</b>:</td><td style='vertical-align:top'>".$previewbutton.$selectmainbutton.$selectadminbutton."</td></tr>" : "";
2009-10-28 23:45:46 +00:00
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_ADMINPREFS )
2013-02-25 02:47:23 -08:00
{
$astext = " " ;
$file = e107 :: getFile ();
$adminstyles = $file -> get_files ( e_ADMIN . " includes " );
2017-01-31 16:39:00 -08:00
$astext = " \n <select id='mode2' name='adminstyle' class='form-control input-medium'> \n " ;
2013-02-25 02:47:23 -08:00
foreach ( $adminstyles as $as )
{
$style = str_replace ( " .php " , " " , $as [ 'fname' ]);
2020-12-22 09:29:12 -08:00
$astext .= " <option value=' { $style } ' " . ( $pref [ 'adminstyle' ] == $style ? " selected='selected' " : " " ) . " > " . $style . " </option> \n " ;
2013-02-25 02:47:23 -08:00
}
$astext .= " </select> " ;
$text .= "
< tr >
< td >< b > " .TPVLAN_41. " :</ b ></ td >
2016-11-11 10:10:04 +01:00
< td > " . $astext . " </ td >
</ tr >
\n " ;
$text .= "
< tr >
< td >< b > " . TPVLAN_89 . " </ b ></ td >
< td colspan = '2' >
2017-01-31 16:39:00 -08:00
< div class = 'checkbox' >
2016-11-11 10:10:04 +01:00
< label class = 'checkbox' >
" . $frm->checkbox ('adminpref', 1, (varset( $pref['adminpref'] , 0) == 1)) . "
</ label >
2017-01-31 16:39:00 -08:00
</ div >
2016-11-11 10:10:04 +01:00
</ td >
2013-02-25 02:47:23 -08:00
</ tr >
\n " ;
}
2009-08-06 22:27:47 +00:00
2013-02-25 02:47:23 -08:00
2021-01-27 08:45:34 -08:00
$text .= varset ( $itext );
2015-04-09 20:15:20 -07:00
2021-02-04 16:22:25 -08:00
// Render skin previews.
2022-04-05 19:49:08 -07:00
if ( $skinText = self :: renderSkin ( $theme , $mode , $pref ))
2012-12-16 21:10:42 -08:00
{
2022-04-05 19:49:08 -07:00
$text .= $skinText ;
2021-02-04 16:22:25 -08:00
}
2022-04-05 19:49:08 -07:00
elseif ( ! empty ( $theme [ 'multipleStylesheets' ]) && $mode && ! empty ( $theme [ 'css' ]) && self :: RENDER_SITEPREFS === $mode )
2021-02-04 16:22:25 -08:00
{
$pLabel = TPVLAN_22 ;
2017-11-20 10:16:37 -08:00
2013-02-25 02:47:23 -08:00
$text .= "
2017-11-20 10:16:37 -08:00
< tr >< td style = 'vertical-align:top;' >< b > " . $pLabel . " :</ b ></ td >
2013-02-25 02:47:23 -08:00
< td colspan = '2' style = 'vertical-align:top' >
2015-02-06 01:03:09 -08:00
< table class = 'table table-bordered table-striped' >
2013-02-25 02:47:23 -08:00
< tr >
2017-04-03 10:18:05 -07:00
< td class = 'center' style = 'width:10%' > " .TPVLAN_93. " </ td >
2013-02-25 02:47:23 -08:00
< td style = 'width:20%' > " .TPVLAN_52. " </ td >
< td class = 'left' > " .TPVLAN_7. " </ td >
</ tr > " ;
foreach ( $theme [ 'css' ] as $css )
{
$text2 = " " ;
2015-07-18 13:16:11 -07:00
2021-02-04 16:22:25 -08:00
$text2 = "
< td class = 'center' >
< input id = '".$frm->name2id($css[' name '])."' type = 'radio' name = 'themecss' value = '".$css[' name ']."' " .( $pref['themecss'] == $css['name'] || (! $pref['themecss'] && $css['name'] == " style . css " ) ? " checked = 'checked' " : " " ). " />
</ td >
< td >< label for = '".$frm->name2id($css[' name '])."' > " . $css['name'] . " </ lable ></ td >
< td > " .( $css['info'] ? $css['info'] : ( $css['name'] == " style . css " ? TPVLAN_23 : TPVLAN_24)). " </ td > \n " ;
2015-07-18 13:16:11 -07:00
2013-02-25 02:47:23 -08:00
$text .= ( $text2 ) ? " <tr> " . $text2 . " </tr> " : " " ;
}
$text .= " </table></td></tr> " ;
2012-12-16 21:10:42 -08:00
}
2013-02-25 02:47:23 -08:00
2015-07-18 13:16:11 -07:00
2013-02-25 02:47:23 -08:00
$text .= " </table>
< div class = 'center buttons-bar' > " ;
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_ADMINPREFS ) // admin
2013-02-25 02:47:23 -08:00
{
$mainid = " selectmain[ " . $theme [ 'id' ] . " ] " ;
$text .= $this -> frm -> admin_button ( 'submit_adminstyle' , TPVLAN_35 , 'update' );
2013-02-28 16:12:35 +02:00
//$text .= $this->frm->admin_button($mainid, TPVLAN_10, 'other');
2013-02-25 02:47:23 -08:00
}
else // main
2012-12-16 21:10:42 -08:00
{
2013-02-25 02:47:23 -08:00
$adminid = " selectadmin[ " . $theme [ 'id' ] . " ] " ;
$text .= $this -> frm -> admin_button ( 'submit_style' , TPVLAN_35 , 'update' );
2013-02-28 16:12:35 +02:00
//$text .= $this->frm->admin_button($adminid, TPVLAN_32, 'other');
2012-12-16 21:10:42 -08:00
}
2009-10-28 23:52:56 +00:00
2013-02-25 02:47:23 -08:00
$text .= " <input type='hidden' name='curTheme' value=' " . $theme [ 'path' ] . " ' /> " ;
2009-10-28 23:52:56 +00:00
2013-02-25 02:47:23 -08:00
$text .= " </div>
</ div >
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
< div class = 'tab-pane' id = 'core-thememanager-help' > " . $this->renderThemeHelp (). " </ div >
2014-06-14 21:50:13 +02:00
< div class = 'tab-pane' id = 'core-thememanager-customconfig' >
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
< col class = 'col-control' />
</ colgroup >
" . $this->renderThemeConfig (). "
</ table >
2014-08-10 14:16:25 +02:00
< div class = 'center buttons-bar' > " ;
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_ADMINPREFS ) // admin
2014-08-10 14:16:25 +02:00
{
$mainid = " selectmain[ " . $theme [ 'id' ] . " ] " ;
$text .= $this -> frm -> admin_button ( 'submit_adminstyle' , TPVLAN_35 , 'update' );
//$text .= $this->frm->admin_button($mainid, TPVLAN_10, 'other');
}
else // main
{
$adminid = " selectadmin[ " . $theme [ 'id' ] . " ] " ;
$text .= $this -> frm -> admin_button ( 'submit_style' , TPVLAN_35 , 'update' );
//$text .= $this->frm->admin_button($adminid, TPVLAN_32, 'other');
}
$text .= " <input type='hidden' name='curTheme' value=' " . $theme [ 'path' ] . " ' /> " ;
$text .= " </div>
2014-06-14 21:50:13 +02:00
</ div >
2021-02-04 16:22:25 -08:00
</ div >
2009-07-09 11:37:36 +00:00
</ div >
\n " ;
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
return $text ;
}
2013-12-31 00:59:30 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $mode
* @ param $theme
* @ return array | false
*/
2015-07-18 13:16:11 -07:00
private function filterStylesheets ( $mode , $theme )
{
$detected = array ();
2017-02-01 08:54:28 -08:00
if ( $mode == self :: RENDER_SITEPREFS )
2015-07-18 13:16:11 -07:00
{
2021-02-13 17:56:53 -08:00
$detected = e107 :: getTheme () -> getScope ( 'css' , 'front' );
2021-02-14 06:31:06 -08:00
$all = e107 :: getTheme () -> getScope ( 'css' , 'all' );
2021-02-13 17:56:53 -08:00
2015-07-18 13:16:11 -07:00
foreach ( $theme [ 'css' ] as $k => $v ) // check if wildcard is present.
{
if ( $v [ 'name' ] == '*' )
{
foreach ( $theme [ 'files' ] as $val ) // get wildcard list of css files.
{
2021-02-14 06:31:06 -08:00
if ( isset ( $detected [ $val ]) || isset ( $all [ $val ]))
2021-02-13 17:56:53 -08:00
{
continue ;
}
if ( substr ( $val , - 4 ) === '.css' && strpos ( $val , " admin_ " ) !== 0 )
2015-07-18 13:16:11 -07:00
{
$detected [ $val ] = array ( 'name' => $val , 'info' => 'User-added Stylesheet' , 'nonadmin' => 1 );
}
}
break ;
}
}
}
2021-02-13 17:56:53 -08:00
elseif ( $mode === self :: RENDER_ADMINPREFS )
2015-07-18 13:16:11 -07:00
{
2021-02-13 17:56:53 -08:00
$detected = e107 :: getTheme ( 'admin' ) -> getScope ( 'css' , 'admin' );
2015-07-18 13:16:11 -07:00
}
2021-02-13 17:56:53 -08:00
return $detected ;
2015-07-18 13:16:11 -07:00
}
2013-12-31 00:59:30 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $key
* @ return string
*/
2013-12-31 00:59:30 -08:00
function renderPresets ( $key )
{
require_once ( e_HANDLER . " menumanager_class.php " );
$frm = e107 :: getForm ();
$men = new e_menuManager ();
$men -> curLayout = $key ;
2015-07-16 14:40:25 -07:00
$preset = $men -> getMenuPreset ();
2015-02-06 01:03:09 -08:00
// print_a($preset);
2015-07-16 14:40:25 -07:00
//TODO LAN
2016-01-30 16:58:58 +01:00
$text = " <div class='btn-group pull-right'> " . $frm -> admin_button ( " setMenuPreset[ " . $key . " ] " , TPVLAN_73 , 'other' );
2021-01-26 15:08:58 -08:00
$text .= ' < button class = " btn btn-primary dropdown-toggle " data - toggle = " dropdown " data - bs - toggle = " dropdown " >
2013-12-31 00:59:30 -08:00
< span class = " caret " ></ span >
</ button >
< ul class = " dropdown-menu col-selection " >
<!-- dropdown menu links -->
2016-01-30 16:58:58 +01:00
< li class = " dropdown-header " > '.TPVLAN_74.' </ li >
2013-12-31 00:59:30 -08:00
' ;
foreach ( $preset as $val )
{
$text .= " <li><a title=' " . $val [ 'menu_name' ] . " '> " . str_replace ( " _menu " , " " , $val [ 'menu_name' ]) . " </a></li> " ;
}
2015-07-16 14:44:25 -07:00
2013-12-31 00:59:30 -08:00
$text .= " </ul></div> " ;
return $text ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $pluginOpts
* @ return string
*/
2009-10-28 23:45:46 +00:00
function renderPlugins ( $pluginOpts )
2009-07-06 08:45:19 +00:00
{
2021-01-16 14:32:55 -08:00
2009-10-28 23:52:56 +00:00
// if there is 1 entry, then it's not the same array.
2017-01-06 13:50:15 -08:00
// $tmp = (varset($pluginOpts['plugin'][1])) ? $pluginOpts['plugin'] : $pluginOpts;
2009-10-28 23:45:46 +00:00
$text = " " ;
2021-01-16 14:32:55 -08:00
$frm = e107 :: getForm ();
$sql = e107 :: getDb ();
2009-10-28 23:45:46 +00:00
2017-01-06 13:50:15 -08:00
foreach ( $pluginOpts as $p )
2009-07-06 08:45:19 +00:00
{
2009-07-14 03:18:17 +00:00
$plug = trim ( $p [ '@attributes' ][ 'name' ]);
2009-10-28 23:45:46 +00:00
2015-02-07 13:38:29 -08:00
if ( e107 :: isInstalled ( $plug ))
2009-07-06 08:45:19 +00:00
{
2009-10-28 23:45:46 +00:00
$text .= $plug . " " . ADMIN_TRUE_ICON ;
2009-07-06 08:45:19 +00:00
}
else
{
2009-10-28 23:45:46 +00:00
// echo $plug;
2020-12-14 16:21:48 -08:00
if ( $sql -> select ( " plugin " , " plugin_id " , " plugin_path = ' " . $plug . " ' LIMIT 1 " ))
2009-10-28 23:45:46 +00:00
{
2020-12-14 16:21:48 -08:00
$row = $sql -> fetch ();
2009-07-14 03:18:17 +00:00
$name = " installplugin[ " . $row [ 'plugin_id' ] . " ] " ;
2009-10-28 23:45:46 +00:00
$text .= $this -> frm -> admin_button ( $name , ADLAN_121 . " " . $plug . " " , 'delete' );
2009-07-14 03:18:17 +00:00
}
else
{
2009-10-28 23:45:46 +00:00
$text .= ( varset ( $p [ '@attributes' ][ 'url' ]) && ( $p [ '@attributes' ][ 'url' ] != 'core' )) ? " <a rel='external' href=' " . $p [ '@attributes' ][ 'url' ] . " '> " . $plug . " </a> " : " <i> " . $plug . " </i> " ;
2009-07-14 03:18:17 +00:00
$text .= ADMIN_FALSE_ICON ;
}
2009-10-28 23:52:56 +00:00
2009-07-06 08:45:19 +00:00
}
2009-10-28 23:45:46 +00:00
$text .= " " ;
2009-07-06 08:45:19 +00:00
}
2009-10-28 23:45:46 +00:00
return $text ;
2009-07-06 08:45:19 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $page
* @ return void
*/
2009-10-28 23:45:46 +00:00
function refreshPage ( $page = e_QUERY )
2009-07-07 02:25:05 +00:00
{
2009-10-28 23:45:46 +00:00
header ( " Location: " . e_SELF . " ? " . $page );
exit ;
2009-07-07 02:25:05 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2006-12-02 04:36:16 +00:00
function themePreview ()
{
2022-03-31 08:24:34 -07:00
echo " <script>document.location.href=' " . e_BASE . " index.php?themepreview. " . $this -> id . " '</script> \n " ;
2006-12-02 04:36:16 +00:00
exit ;
}
2019-05-27 10:45:35 -07:00
2009-09-17 00:13:40 +00:00
/**
2009-10-28 23:45:46 +00:00
* Set Theme as Main Theme .
2009-11-17 14:50:37 +00:00
*
* @ param string $name [ optional ] name ( folder ) of the theme to set .
* @ return boolean TRUE on success , FALSE otherwise
2009-09-17 00:13:40 +00:00
*/
2013-04-14 20:18:23 -07:00
function setTheme ( $name = '' , $contentCheck = true )
2006-12-02 04:36:16 +00:00
{
2021-01-27 08:45:34 -08:00
$core = e107 :: getConfig ();
2009-10-28 23:45:46 +00:00
$sql = e107 :: getDb ();
2012-11-28 02:22:23 -08:00
$mes = e107 :: getMessage ();
2009-09-17 00:13:40 +00:00
2020-12-22 09:29:12 -08:00
$themeArray = e107 :: getTheme () -> getList ( " id " );
2009-10-28 23:45:46 +00:00
2022-04-06 08:37:13 -07:00
$name = ( $name ) ? $name : vartrue ( $themeArray [ $this -> id ]);
$layout = $pref [ 'sitetheme_layouts' ] = is_array ( $this -> themeArray [ $name ][ 'layouts' ]) ? $this -> themeArray [ $name ][ 'layouts' ] : array ();
$deflayout = $this -> findDefault ( $name );
2009-10-28 23:45:46 +00:00
$customPages = $this -> themeArray [ $name ][ 'custompages' ];
2022-04-06 08:37:13 -07:00
$version = $this -> themeArray [ $name ][ 'version' ];
$glyphs = $this -> themeArray [ $name ][ 'glyphs' ];
$style = $this -> findDefaultCSS ( $name );
2009-10-28 23:45:46 +00:00
$core -> set ( 'sitetheme' , $name );
2022-04-06 08:37:13 -07:00
$core -> set ( 'themecss' , $style );
2009-10-28 23:45:46 +00:00
$core -> set ( 'sitetheme_layouts' , $layout );
$core -> set ( 'sitetheme_deflayout' , $deflayout );
$core -> set ( 'sitetheme_custompages' , $customPages );
2017-01-01 08:13:42 -08:00
$core -> set ( 'sitetheme_glyphicons' , $glyphs );
2013-04-15 19:46:35 -07:00
2009-10-28 23:45:46 +00:00
$core -> set ( 'sitetheme_version' , $version );
2015-01-28 12:31:14 -08:00
if ( ! empty ( $this -> themeArray [ $name ][ 'preferences' ]))
{
2017-01-29 15:10:32 -08:00
$themePrefs = $this -> themeArray [ $name ][ 'preferences' ];
e107 :: getMessage () -> addDebug ( " ThemePrefs found in theme.xml " );
$this -> id = $name ;
$this -> loadThemeConfig ();
2021-01-21 10:29:29 -08:00
$className = '' ;
if ( ! empty ( $this -> themeConfigObj ))
{
$className = get_class ( $this -> themeConfigObj );
}
2017-01-30 08:52:12 -08:00
if ( $className === 'theme_config' ) // new way. 2.1.4
2017-01-29 15:10:32 -08:00
{
$themeConfig = e107 :: getThemeConfig ( $name );
2017-01-30 08:52:12 -08:00
e107 :: getMessage () -> addDebug ( " Saving theme prefs to their own row: " . print_r ( $themePrefs , true ));
2017-01-29 15:10:32 -08:00
foreach ( $themePrefs as $key => $val )
{
$themeConfig -> add ( $key , $val );
}
$themeConfig -> save ( false , true , false );
}
else // old way.
{
e107 :: getMessage () -> addDebug ( " Saving theme prefs to sitetheme_ref " );
$core -> set ( 'sitetheme_pref' , $this -> themeArray [ $name ][ 'preferences' ]);
}
2015-01-28 12:31:14 -08:00
}
2017-01-29 15:10:32 -08:00
2013-04-15 19:46:35 -07:00
if ( $contentCheck === true )
{
2016-02-10 19:38:03 -08:00
$sql -> delete ( " menus " , " menu_layout !='' " );
2022-04-07 08:15:30 -07:00
$this -> installContentCheck ( $name );
2013-04-15 19:46:35 -07:00
}
2022-04-07 08:15:30 -07:00
2014-01-08 17:23:56 +01:00
e107 :: getCache () -> clear ();
2016-02-10 19:38:03 -08:00
e107 :: getCache () -> clearAll ( 'js' );
e107 :: getCache () -> clearAll ( 'css' );
2017-01-29 15:10:32 -08:00
e107 :: getCache () -> clearAll ( 'library' );
2022-04-06 08:37:13 -07:00
e107 :: getCache () -> clearAll ( 'browser' );
2009-09-17 00:13:40 +00:00
2022-04-07 08:15:30 -07:00
if ( $core -> save ( true , false , false ))
2009-07-14 03:18:17 +00:00
{
2017-01-14 13:38:05 -08:00
$mes -> addDebug ( " Default Layout: " . $deflayout );
$mes -> addDebug ( " Custom Pages: " . print_a ( $customPages , true ));
2009-09-17 00:13:40 +00:00
2012-12-06 21:41:53 -08:00
$med = e107 :: getMedia ();
$med -> import ( '_common_image' , e_THEME . $name , " ^.*?logo.*?( \ .png| \ .jpeg| \ .jpg| \ .JPG| \ .GIF| \ .PNG) $ " );
2017-01-29 15:10:32 -08:00
$med -> import ( '_common_image' , e_THEME . $name , '' , 'min-size=20000' );
2013-03-08 02:19:18 -08:00
2022-04-07 08:15:30 -07:00
2017-01-29 15:10:32 -08:00
2009-10-28 23:45:46 +00:00
$this -> theme_adminlog ( '01' , $name . ', style.css' );
2017-01-29 15:10:32 -08:00
return true ;
2009-07-14 03:18:17 +00:00
}
else
{
2013-03-28 00:41:29 -07:00
// $mes->add(TPVLAN_3." <b>'".$name."'</b>", E_MESSAGE_ERROR);
2017-01-29 15:10:32 -08:00
return true ;
2009-07-14 03:18:17 +00:00
}
2009-10-28 23:52:56 +00:00
2006-12-02 04:36:16 +00:00
}
2013-03-08 04:46:02 -08:00
2015-02-14 23:34:15 -08:00
/**
* @ param $name
2021-12-03 14:58:33 -08:00
* @ return false | void
2015-02-14 23:34:15 -08:00
*/
2013-03-08 04:46:02 -08:00
function installContentCheck ( $name )
{
$file = e_THEME . $name . " /install/install.xml " ;
$frm = e107 :: getForm ();
2015-02-14 23:34:15 -08:00
$tp = e107 :: getParser ();
2015-06-23 10:45:09 +02:00
2013-03-08 04:46:02 -08:00
if ( ! is_readable ( $file ))
{
2015-06-23 10:45:09 +02:00
return false ;
}
2013-03-08 04:46:02 -08:00
$mes = e107 :: getMessage ();
2015-06-23 10:45:09 +02:00
$xmlArray = e107 :: getXml () -> loadXMLfile ( $file , 'advanced' );
2013-03-08 04:46:02 -08:00
$text = "
< form action = '".e_SELF."' method = 'post' >
2015-06-23 10:45:09 +02:00
< div >
< p > " .TPVLAN_58. " < br />
" . $tp->toHTML (TPVLAN_59, true). " :< br />
</ p >
2013-03-08 04:46:02 -08:00
< ul > " ;
2015-06-23 10:45:09 +02:00
2013-03-08 04:46:02 -08:00
$lng = e107 :: getLanguage ();
2015-06-23 10:45:09 +02:00
2013-03-08 04:46:02 -08:00
foreach ( $xmlArray [ 'database' ][ 'dbTable' ] as $key => $val )
{
$count = count ( $val [ 'item' ]);
2015-06-23 10:45:09 +02:00
$data = array ( 'x' => $count , 'y' => $val [ '@attributes' ][ 'name' ]);
$text .= " <li> " . $tp -> lanVars ( TPVLAN_60 , $data ) . " </li> " ;
2013-03-08 04:46:02 -08:00
}
2015-06-23 10:45:09 +02:00
2022-04-07 08:15:30 -07:00
$text .= " </ul> " ;
if ( ! empty ( $xmlArray [ 'prefs' ][ 'core' ]))
{
$text .= " <p> " . LAN_PREFS . " :</p><ul> " ;
foreach ( $xmlArray [ 'prefs' ][ 'core' ] as $key => $val )
{
$text .= " <li> " . $val [ '@attributes' ][ 'name' ] . " </li> " ;
}
$text .= " </ul> " ;
}
2022-04-07 13:11:56 -07:00
2022-04-07 08:15:30 -07:00
$text .= "
2015-06-23 10:45:09 +02:00
< p > " . $tp->toHTML (TPVLAN_61, true). " </ p >
" . $frm->admin_button ('installContent', $name , 'warning', LAN_YES). "
" . $frm->admin_button ('dismiss',0, 'cancel', LAN_NO). "
2013-03-08 04:46:02 -08:00
</ div >
</ form >
" ;
// $text .= print_a($xmlArray, true);
2015-06-23 10:45:09 +02:00
$mes -> addInfo ( $text );
2013-03-08 04:46:02 -08:00
}
2015-06-23 10:45:09 +02:00
2022-04-04 10:54:24 -07:00
/**
* @ param $name
* @ return void
*/
2013-03-08 04:46:02 -08:00
function installContent ( $name )
{
$mes = e107 :: getMessage ();
$file = e_THEME . $name . " /install/install.xml " ;
e107 :: getXml () -> e107Import ( $file , 'replace' , true , false ); // Overwrite specific core pref and tables entries.
$mes -> addSuccess ( LAN_UPDATED );
}
2015-02-14 23:34:15 -08:00
/**
2022-04-06 08:37:13 -07:00
* Find the default layout as marked in theme . xml
2015-02-14 23:34:15 -08:00
* @ param $theme
* @ return int | string
*/
2009-07-05 11:57:40 +00:00
function findDefault ( $theme )
{
2016-12-02 12:04:08 -08:00
if ( ! empty ( $_POST [ 'layout_default' ]))
2009-07-05 11:57:40 +00:00
{
2016-12-02 12:04:08 -08:00
return e107 :: getParser () -> filter ( $_POST [ 'layout_default' ], 'w' );
2009-07-05 11:57:40 +00:00
}
2022-04-06 08:37:13 -07:00
2021-01-01 14:05:51 -08:00
// $l = $this->themeArray[$theme];
2022-04-06 08:37:13 -07:00
2021-01-01 14:05:51 -08:00
// if(!$l)
2009-07-12 14:44:57 +00:00
{
2020-12-22 09:29:12 -08:00
$l = e107 :: getTheme ( $theme ) -> get (); // $this->getThemeInfo($theme);
2009-07-12 14:44:57 +00:00
}
2022-04-06 08:37:13 -07:00
if ( ! empty ( $l [ 'layouts' ]))
2009-07-05 11:57:40 +00:00
{
2009-10-28 23:45:46 +00:00
foreach ( $l [ 'layouts' ] as $key => $val )
2009-07-05 11:57:40 +00:00
{
2009-10-28 23:45:46 +00:00
if ( isset ( $val [ '@attributes' ][ 'default' ]) && ( $val [ '@attributes' ][ 'default' ] == " true " ))
2009-07-08 06:58:00 +00:00
{
2009-10-28 23:45:46 +00:00
return $key ;
2009-07-08 06:58:00 +00:00
}
2009-07-05 11:57:40 +00:00
}
}
2009-07-12 14:44:57 +00:00
else
{
2009-10-28 23:45:46 +00:00
return " " ;
2009-07-12 14:44:57 +00:00
}
2009-07-05 11:57:40 +00:00
}
2022-04-06 08:37:13 -07:00
/**
* Find the default css style as defined in theme . xml . When not found , use 'style.css' .
* @ param string $theme theme - folder name .
* @ return string
*/
function findDefaultCSS ( $theme )
{
$l = e107 :: getTheme ( $theme ) -> get ();
if ( empty ( $l [ 'css' ]))
{
return 'style.css' ;
}
foreach ( $l [ 'css' ] as $item )
{
if ( ! empty ( $item [ 'default' ]) && $item [ 'default' ] === 'true' )
{
return $item [ 'name' ];
}
}
return 'style.css' ;
}
2021-01-29 09:27:38 -08:00
/*
2006-12-02 04:36:16 +00:00
function setAdminTheme ()
{
2012-11-28 02:22:23 -08:00
global $pref , $e107cache ;
2021-01-27 12:20:58 -08:00
2012-11-28 02:22:23 -08:00
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2020-12-22 09:29:12 -08:00
$themeArray = e107 :: getTheme () -> getList ( 'id' ); // $this->getThemes("id");
2009-10-28 23:45:46 +00:00
$pref [ 'admintheme' ] = $themeArray [ $this -> id ];
2013-03-15 23:35:16 -07:00
$pref [ 'admincss' ] = file_exists ( e_THEME . $pref [ 'admintheme' ] . '/admin_dark.css' ) ? 'admin_dark.css' : 'admin_light.css' ;
2008-08-25 10:46:46 +00:00
$e107cache -> clear_sys ();
2014-01-15 02:56:39 -08:00
2009-07-14 03:18:17 +00:00
if ( save_prefs ())
{
2009-10-28 23:52:56 +00:00
// Default Message
2012-11-28 02:22:23 -08:00
$mes -> add ( TPVLAN_40 . " <b>' " . $themeArray [ $this -> id ] . " '</b> " , E_MESSAGE_SUCCESS );
2009-10-28 23:45:46 +00:00
$this -> theme_adminlog ( '02' , $pref [ 'admintheme' ] . ', ' . $pref [ 'admincss' ]);
2009-07-14 03:18:17 +00:00
}
2009-10-28 23:45:46 +00:00
2009-10-31 00:36:09 +00:00
// $ns->tablerender("Admin Message", "<br /><div style='text-align:center;'>".TPVLAN_40." <b>'".$themeArray[$this -> id]."'</b>.</div><br />");
2009-10-28 23:45:46 +00:00
// $this->showThemes('admin');
2021-01-29 09:27:38 -08:00
} */
2017-01-29 12:02:50 -08:00
/**
* @ todo add admin log
*/
2006-12-02 04:36:16 +00:00
function setStyle ()
{
2012-11-28 02:22:23 -08:00
global $pref , $e107cache ;
2017-01-29 12:02:50 -08:00
$sql = e107 :: getDb ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$themeCSS = vartrue ( $_POST [ 'themecss' ], 'style.css' );
$themeLayout = vartrue ( $_POST [ 'layout_default' ], 'default' );
e107 :: getConfig () -> setPosted ( 'themecss' , $themeCSS ) -> setPosted ( 'sitetheme_deflayout' , $themeLayout );
2009-08-17 14:40:23 +00:00
$msg = $this -> setThemeConfig ();
2017-01-29 12:02:50 -08:00
2009-08-17 14:40:23 +00:00
if ( $msg )
2009-07-14 03:18:17 +00:00
{
2012-11-28 02:22:23 -08:00
$mes -> add ( TPVLAN_37 , E_MESSAGE_SUCCESS );
2009-08-17 14:40:23 +00:00
if ( is_array ( $msg ))
2012-11-28 02:22:23 -08:00
$mes -> add ( $msg [ 0 ], $msg [ 1 ]);
2009-07-14 03:18:17 +00:00
}
2017-01-29 12:02:50 -08:00
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2006-12-02 04:36:16 +00:00
function setAdminStyle ()
{
2009-08-17 14:40:23 +00:00
//TODO adminlog
2017-01-31 16:39:00 -08:00
$config = e107 :: getConfig ();
if ( ! empty ( $_POST [ 'admincss' ]))
{
$config -> setPosted ( 'admincss' , $_POST [ 'admincss' ]);
}
2017-02-01 10:39:13 -08:00
$config -> setPosted ( 'adminstyle' , $_POST [ 'adminstyle' ])
2021-01-27 08:45:34 -08:00
-> setPosted ( 'adminpref' , varset ( $_POST [ 'adminpref' ], 0 )) -> save ( true , true );
2017-02-01 10:39:13 -08:00
e107 :: redirect ( e_REQUEST_URI );
2017-01-31 16:39:00 -08:00
/* return ( e107 :: getConfig () -> dataHasChangedFor ( 'admincss' )
2016-11-11 10:10:04 +01:00
|| e107 :: getConfig () -> dataHasChangedFor ( 'adminstyle' )
2017-01-31 16:39:00 -08:00
|| e107 :: getConfig () -> dataHasChangedFor ( 'adminpref' )); */
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $array
* @ return void
*/
2009-10-28 23:45:46 +00:00
function SetCustomPages ( $array )
2009-07-09 08:31:38 +00:00
{
2009-10-28 23:45:46 +00:00
if ( ! is_array ( $array ))
{
return ;
}
2010-01-10 16:24:09 +00:00
$newprefs = array ();
foreach ( $array as $key => $newpref )
{
$newpref = trim ( str_replace ( " \r \n " , " \n " , $newpref ));
$newprefs [ $key ] = array_filter ( explode ( " \n " , $newpref ));
$newprefs [ $key ] = array_unique ( $newprefs [ $key ]);
}
2009-10-28 23:45:46 +00:00
2009-08-17 14:40:23 +00:00
if ( e107 :: getPref ( 'sitetheme_deflayout' ) == 'legacyCustom' )
2009-07-09 08:31:38 +00:00
{
2009-08-17 14:40:23 +00:00
$newprefs [ 'legacyCustom' ] = array ();
2009-07-09 08:31:38 +00:00
}
2010-01-10 16:24:09 +00:00
2009-08-17 14:40:23 +00:00
//setPosted couldn't be used here - sitetheme_custompages structure is not defined
e107 :: getConfig () -> set ( 'sitetheme_custompages' , e107 :: getParser () -> toDB ( $newprefs ));
2009-07-09 08:31:38 +00:00
}
2013-12-19 22:50:01 -08:00
/**
* Set the Theme layouts , as found in theme . xml
*/
2020-12-20 19:42:09 -08:00
function setLayouts ()
2013-12-19 22:50:01 -08:00
{
$name = $this -> id ;
$layout = is_array ( $this -> themeArray [ $name ][ 'layouts' ]) ? $this -> themeArray [ $name ][ 'layouts' ] : array ();
e107 :: getConfig () -> set ( 'sitetheme_layouts' , $layout );
}
2009-10-28 23:45:46 +00:00
2008-11-02 10:28:30 +00:00
// Log event to admin log
2022-04-04 10:54:24 -07:00
/**
* @ param $msg_num
* @ param $woffle
* @ return void
*/
2009-10-28 23:45:46 +00:00
function theme_adminlog ( $msg_num = '00' , $woffle = '' )
2008-11-02 10:28:30 +00:00
{
2009-09-17 00:13:40 +00:00
if ( $this -> noLog )
{
return ;
}
2009-10-31 00:36:09 +00:00
global $pref , $admin_log ;
2008-11-02 10:28:30 +00:00
// if (!varset($pref['admin_log_log']['admin_banlist'],0)) return;
2021-01-27 08:45:34 -08:00
e107 :: getLog () -> add ( 'THEME_' . $msg_num , $woffle );
2008-11-02 10:28:30 +00:00
}
2021-01-27 08:45:34 -08:00
/*
2008-11-17 07:17:23 +00:00
function parse_theme_php ( $path )
{
2017-01-06 13:50:15 -08:00
return e_theme :: parse_theme_php ( $path );
2008-11-17 07:17:23 +00:00
}
2009-10-28 23:45:46 +00:00
function parse_theme_xml ( $path )
2008-11-17 07:17:23 +00:00
{
2017-01-06 13:50:15 -08:00
return e_theme :: parse_theme_xml ( $path );
2017-01-01 08:13:42 -08:00
2008-11-17 07:17:23 +00:00
}
2021-01-27 08:45:34 -08:00
*/
2022-04-05 19:49:08 -07:00
/**
* @ param array $theme
* @ param string $mode
* @ param mixed $value
* @ return array
*/
private static function renderSkin ( $theme , $mode , $pref )
{
$parms = [];
$parms [ 'path' ] = e_THEME . $theme [ 'path' ] . '/' ;
$parms [ 'block-class' ] = 'admin-css-selector col-md-3' ;
foreach ( $theme [ 'css' ] as $val )
{
if ( empty ( $val [ 'thumbnail' ]))
{
continue ;
}
2017-01-01 08:13:42 -08:00
2022-04-05 19:49:08 -07:00
$kid = $val [ 'name' ];
// $val['description'];
$parms [ 'optArray' ][ $kid ] = array (
'thumbnail' => $val [ 'thumbnail' ],
'label' => $val [ 'info' ] . " <br /><small> " . $val [ 'description' ] . " </small> " ,
);
}
if ( empty ( $parms [ 'optArray' ]))
{
return '' ;
}
2017-01-01 08:13:42 -08:00
2022-04-05 19:49:08 -07:00
$text = " <tr><td style='vertical-align:top;'><b> " . TPVLAN_95 . " :</b></td>
< td colspan = '2' style = 'vertical-align:top' >
" ;
$css = ( $mode === self :: RENDER_ADMINPREFS ) ? 'admincss' : 'themecss' ;
$text .= e107 :: getForm () -> radioImage ( $css , vartrue ( $pref [ $css ]), $parms );
$text .= " </td></tr> " ;
return $text ;
}
2017-01-01 08:13:42 -08:00
2009-08-27 12:58:29 +00:00
}
2009-08-17 12:48:52 +00:00
2019-01-31 14:35:57 -08:00
2022-04-04 10:54:24 -07:00
/**
*
*/
2009-08-27 12:58:29 +00:00
interface e_theme_config
{
/**
* Triggered on theme settings submit
* Catch and save theme configuration
*/
2017-01-01 16:54:57 -08:00
// public function process();
2009-10-28 23:45:46 +00:00
2009-08-27 12:58:29 +00:00
/**
* Theme configuration user interface
2009-10-28 23:45:46 +00:00
* Print out config fields
2009-08-27 12:58:29 +00:00
*/
2017-01-01 16:54:57 -08:00
public function config (); // only config() is absolutely required.
2009-08-27 12:58:29 +00:00
/**
* Theme help tab
2009-10-28 23:45:46 +00:00
* Print out theme help content
2009-08-27 12:58:29 +00:00
*/
2017-01-01 16:54:57 -08:00
// public function help();
2007-01-17 20:47:41 +00:00
}
2019-01-31 14:35:57 -08:00
/**
* Interface e_theme_render
2020-04-28 14:00:19 -07:00
* @ see e107_themes / bootstrap3 / theme . php
2019-01-31 14:35:57 -08:00
* @ see e107_themes / bootstrap3 / admin_theme . php
*/
interface e_theme_render
{
2022-04-04 10:54:24 -07:00
/**
* @ return mixed
*/
2021-01-17 07:27:28 -08:00
public function init ();
2022-04-04 10:54:24 -07:00
/**
* @ param $caption
* @ param $text
* @ param $mode
* @ param $data
* @ return mixed
*/
2020-04-28 14:00:19 -07:00
public function tablestyle ( $caption , $text , $mode = '' , $data = array ());
2019-01-31 14:35:57 -08:00
}
/**
* Interface e_theme_library
*//*
interface e_theme_library
{
public function config ();
} */