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
*
2013-06-13 16:03:45 +02:00
* Copyright ( C ) 2008 - 2013 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
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 ;
2009-09-17 00:13:40 +00:00
var $noLog = FALSE ;
2012-11-29 22:03:36 -08:00
2015-02-27 14:35:07 -08:00
private $approvedAdminThemes = array ( 'bootstrap' );
2012-11-29 22:03:36 -08:00
2009-10-28 23:45:46 +00:00
public $allowedCategories = array ( 'generic' ,
'adult' ,
'blog' ,
'clan' ,
'children' ,
'corporate' ,
'forum' ,
'gaming' ,
'gallery' ,
'news' ,
'social' ,
'video' ,
'multimedia' );
2013-05-17 16:24:50 +03:00
/**
* Marketplace handler instance
* @ var e_marketplace
*/
protected $mp ;
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
if ( isset ( $_SERVER [ 'E_B3_ADMIN' ]) && $_SERVER [ 'E_B3_ADMIN' ] === 'true' )
{
$this -> approvedAdminThemes [] = 'bootstrap3' ;
}
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
$this -> frm = new e_form ();
2009-10-28 23:45:46 +00:00
$this -> fl = e107 :: getFile ();
2015-02-10 23:13:53 -08:00
if ( ! empty ( $_POST [ 'upload' ]))
{
$unzippedTheme = $this -> themeUpload ();
}
if ( ! empty ( $_POST [ 'setUploadTheme' ]) && ! empty ( $unzippedTheme ))
2009-07-18 03:41:49 +00:00
{
2015-02-10 23:13:53 -08:00
$themeArray = $this -> getThemes ();
$this -> id = $themeArray [ $unzippedTheme ][ 'id' ];
if ( $this -> setTheme ())
{
$mes -> addSuccess ( TPVLAN_3 );
}
else
{
$mes -> addError ( " Could not change site theme. " ); // TODO LAN
}
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2015-02-10 23:13:53 -08:00
if ( ! empty ( $_POST [ 'installContent' ]))
2013-03-08 04:46:02 -08:00
{
$this -> installContent ( $_POST [ 'installContent' ]);
}
2009-10-28 23:45:46 +00:00
$this -> themeArray = ( defined ( 'E107_INSTALL' )) ? $this -> getThemes ( 'xml' ) : $this -> getThemes ();
// print_a($this -> themeArray);
foreach ( $_POST as $key => $post )
2006-12-02 04:36:16 +00:00
{
2009-10-28 23:45:46 +00:00
if ( strstr ( $key , " preview " ))
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
}
2009-10-28 23:45:46 +00: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 );
}
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
if ( strstr ( $key , " selectadmin " ))
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' );
2006-12-02 04:36:16 +00:00
}
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
if ( isset ( $_POST [ 'submit_adminstyle' ]))
{
2009-10-28 23:45:46 +00:00
$this -> id = $_POST [ 'curTheme' ];
if ( $this -> setAdminStyle ())
2009-08-17 14:40:23 +00:00
{
eMessage :: getInstance () -> add ( TPVLAN_43 , E_MESSAGE_SUCCESS );
}
e107 :: getConfig () -> save ( true );
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
if ( isset ( $_POST [ 'submit_style' ]))
{
2009-10-28 23:45:46 +00:00
$this -> id = $_POST [ 'curTheme' ];
2013-12-19 22:50:01 -08: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 ();
e107 :: getConfig () -> save ( true );
2009-10-28 23:52:56 +00:00
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2009-07-14 03:18:17 +00:00
if ( isset ( $_POST [ 'installplugin' ]))
{
$key = key ( $_POST [ 'installplugin' ]);
2009-10-28 23:45:46 +00:00
2009-07-14 03:18:17 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_plugin.php " );
2009-10-28 23:45:46 +00:00
require_once ( e_HANDLER . " plugin_class.php " );
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
}
2009-10-28 23:45:46 +00: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' ]);
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_menus.php " );
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 : " " ;
2009-10-28 23:45:46 +00:00
2009-07-16 02:55:19 +00:00
if ( $areas = $men -> menuSetPreset ())
{
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
}
2009-10-28 23:45:46 +00: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
}
2009-10-28 23:52:56 +00:00
2009-07-16 02:55:19 +00:00
}
2009-10-28 23:52:56 +00:00
2009-10-28 23:45:46 +00:00
}
2006-12-02 04:36:16 +00:00
2009-10-28 23:45:46 +00:00
function getThemes ( $mode = FALSE )
2006-12-02 04:36:16 +00:00
{
$themeArray = array ();
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
$tloop = 1 ;
2012-11-29 23:12:20 -08:00
$fl = e107 :: getFile ();
$array = $fl -> get_dirs ( e_THEME );
2009-10-28 23:45:46 +00:00
2012-11-29 23:12:20 -08:00
foreach ( $array as $file )
2008-04-08 21:24:32 +00:00
{
2012-11-29 23:12:20 -08:00
2009-09-17 00:13:40 +00:00
if (( $mode == 'xml' ) && ! is_readable ( e_THEME . $file . " /theme.xml " ))
{
continue ;
}
2009-10-28 23:45:46 +00:00
if ( $file != " . " && $file != " .. " && $file != " CVS " && $file != " templates " && is_dir ( e_THEME . $file ) && is_readable ( e_THEME . $file . " /theme.php " ))
{
2008-11-17 07:17:23 +00:00
if ( $mode == " id " )
2008-04-08 21:24:32 +00:00
{
2008-11-17 07:17:23 +00:00
$themeArray [ $tloop ] = $file ;
2006-12-02 04:36:16 +00:00
}
2008-11-17 07:17:23 +00:00
else
2008-04-08 21:24:32 +00:00
{
2009-07-12 14:44:57 +00:00
$themeArray [ $file ] = $this -> getThemeInfo ( $file );
2008-11-17 07:17:23 +00:00
$themeArray [ $file ][ 'id' ] = $tloop ;
2006-12-02 04:36:16 +00:00
}
2008-11-17 07:17:23 +00:00
$tloop ++ ;
2009-10-28 23:45:46 +00:00
}
2009-07-12 14:44:57 +00:00
}
2012-11-29 23:12:20 -08:00
// echo "<pre>";
// print_r($themeArray);
// echo "</pre>";
2009-07-12 14:44:57 +00:00
2009-10-28 23:45:46 +00:00
2009-07-12 14:44:57 +00:00
return $themeArray ;
}
2009-10-28 23:45:46 +00:00
function getThemeInfo ( $file )
2009-07-12 14:44:57 +00:00
{
2013-03-31 00:06:21 -07:00
2013-06-21 01:25:47 -07:00
$mes = e107 :: getMessage ();
2013-03-31 00:06:21 -07:00
$reject = array ( 'e_.*' );
2013-06-21 01:25:47 -07:00
$handle2 = e107 :: getFile () -> get_files ( e_THEME . $file . " / " , " \ .php| \ .css| \ .xml|preview \ .jpg|preview \ .png " , $reject , 1 );
2013-03-31 00:06:21 -07:00
2009-10-28 23:45:46 +00:00
foreach ( $handle2 as $fln )
{
$file2 = str_replace ( e_THEME . $file . " / " , " " , $fln [ 'path' ]) . $fln [ 'fname' ];
$themeArray [ $file ][ 'files' ][] = $file2 ;
2013-06-21 01:25:47 -07:00
2009-10-28 23:45:46 +00:00
if ( strstr ( $file2 , " preview. " ))
{
$themeArray [ $file ][ 'preview' ] = e_THEME . $file . " / " . $file2 ;
}
2009-07-12 14:44:57 +00:00
2013-06-21 01:25:47 -07:00
// ---------------- get information string for css file - Legacy mode (no theme.xml)
2008-11-17 07:17:23 +00:00
2013-06-21 01:25:47 -07:00
if ( strstr ( $file2 , " .css " ) && ! strstr ( $file2 , " menu.css " ) && strpos ( $file2 , " e_ " ) !== 0 )
2009-10-28 23:45:46 +00:00
{
2013-03-31 00:06:21 -07:00
if ( $cssContents = file_get_contents ( e_THEME . $file . " / " . $file2 ))
2009-10-28 23:45:46 +00:00
{
$nonadmin = preg_match ( '/\* Non-Admin(.*?)\*\//' , $cssContents ) ? true : false ;
preg_match ( '/\* info:(.*?)\*\//' , $cssContents , $match );
$match [ 1 ] = varset ( $match [ 1 ], '' );
2013-06-21 01:25:47 -07:00
$themeArray [ $file ][ 'css' ][] = array ( " name " => $file2 , " info " => $match [ 1 ], " nonadmin " => $nonadmin );
2009-10-28 23:45:46 +00:00
}
2013-03-31 00:06:21 -07:00
else
{
2013-06-21 01:25:47 -07:00
// $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2);
2013-03-31 00:06:21 -07:00
}
2009-10-28 23:45:46 +00:00
}
2009-07-12 14:44:57 +00:00
2009-10-28 23:52:56 +00:00
2009-10-28 23:45:46 +00:00
} // end while..
2013-06-21 01:25:47 -07:00
// Load Theme information and merge with existing array. theme.xml (v2.x theme) is given priority over theme.php (v1.x).
2009-10-28 23:45:46 +00:00
if ( in_array ( " theme.xml " , $themeArray [ $file ][ 'files' ]))
{
$themeArray [ $file ] = array_merge ( $themeArray [ $file ], $this -> parse_theme_xml ( $file ));
}
elseif ( in_array ( " theme.php " , $themeArray [ $file ][ 'files' ]))
{
$themeArray [ $file ] = array_merge ( $themeArray [ $file ], $this -> parse_theme_php ( $file ));
}
2009-07-12 14:44:57 +00:00
2015-04-29 10:22:46 -07:00
if ( ! empty ( $themeArray [ $file ][ 'css' ]) && count ( $themeArray [ $file ][ 'css' ]) > 1 )
2013-06-21 01:25:47 -07:00
{
$themeArray [ $file ][ 'multipleStylesheets' ] = TRUE ;
}
2009-10-28 23:45:46 +00:00
return $themeArray [ $file ];
2009-07-12 14:44:57 +00:00
2009-10-28 23:52:56 +00:00
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
*/
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
2009-10-28 23:45:46 +00: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
}
2009-10-28 23:45:46 +00:00
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 );
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 ;
}
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
2013-05-06 20:47:46 -07: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
2013-05-06 21:28:05 -07: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
if ( ! function_exists ( curl_init ))
{
$mes -> addWarning ( " cURL is currently required to use this feature. Contact your webhosting provider to enable cURL " ); // TODO LAN?
}
2013-05-17 16:24:50 +03:00
// auth
$mp -> generateAuthKey ( $e107SiteUsername , $e107SiteUserpass );
// 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' ];
// OLD BIT OF CODE ------------------------------->
/* $file = " http://e107.org/feed?type=theme&frm= " . $from . " &srch= " . $srch . " &limit= " . $limit ;
2013-03-04 03:39:27 -08:00
$mes -> addDebug ( " File = " . $file );
2013-01-25 19:30:26 -08:00
2013-01-30 16:51:06 -08:00
$xml -> setOptArrayTags ( 'theme,screenshots/image' ); // make sure 'theme' tag always returns an array
// $xdata = $xml->loadXMLfile($file,'advanced',true);
$xdata = $xml -> loadXMLfile ( $file , true , false );
2013-05-17 16:24:50 +03:00
$total = $xdata [ '@attributes' ][ 'total' ]; */
// OLD BIT OF CODE ------------------------------->
2013-03-04 00:47:56 -08:00
2013-03-17 02:57:09 -07:00
$amount = $limit ;
2013-05-06 20:47:46 -07:00
/*
2013-03-17 02:57:09 -07:00
if ( $total > $amount )
{
//$parms = $total.",".$amount.",".$from.",".e_SELF.'?mode='.$_GET['mode'].'&frm=[FROM]';
$url = rawurlencode ( e_SELF . '?mode=' . $_GET [ 'mode' ] . '&frm=[FROM]' );
$parms = " total= " . $total . " &amount= " . $amount . " ¤t= " . $from . " &url= " . $url . " &caption=off&tmpl=basic&navcount=4&glyphs=1 " ;
$text .= " <div class='span5' style='margin-left: 100px;margin-top:10px'> " . $tp -> parseTemplate ( " { NEXTPREV= $parms } " , TRUE ) . " </div> " ;
}
2013-05-06 20:47:46 -07:00
*/
2013-03-17 02:57:09 -07:00
2013-01-25 19:30:26 -08:00
// print_a($xdata);
$c = 1 ;
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
);
$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 ;
}
2013-03-04 03:39:27 -08:00
/*
[ author ] => e107 Inc
[ summary ] => Bootstrap e107 admin theme
[ category ] => generic
[ keywords ] => Array
(
[ word ] => Array
(
[ 0 ] => bootstrap
[ 1 ] => clean
)
2013-01-25 19:30:26 -08:00
2013-03-04 03:39:27 -08:00
)
[ name ] => bootstrap
[ version ] => 1.0
[ date ] => 2012 - 12 - 01
[ compatibility ] => 2.0
[ releaseUrl ] =>
[ email ] => e107inc @ something . com
[ website ] => http :// e107 . org
[ info ] => Bootstrap e107 admin theme
[ compliance ] => Array
(
[ @ attributes ] => Array
(
[ xhtml ] =>
[ css ] =>
)
2013-01-25 19:30:26 -08:00
2013-03-04 03:39:27 -08:00
)
2013-01-25 19:30:26 -08:00
2013-03-04 03:39:27 -08:00
[ xhtmlcompliant ] =>
[ csscompliant ] =>
[ path ] => bootstrap
*/
}
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
{
$mes -> addInfo ( " No Themes found which match your search criteria " );
2013-01-25 19:30:26 -08:00
}
2013-03-17 02:57:09 -07:00
2013-05-06 20:47:46 -07:00
$indicators = ' < ol class = " carousel-indicators span6 " >
< 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 ;
$indicators .= '<li data-target="#myCarousel" data-slide-to="' . $id . '"></li>' ;
}
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> " ;
2013-05-14 22:42:06 +02:00
$ns -> tablerender ( TPVLAN_26 . SEP . " Available for Download " , $mes -> render () . $text );
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 );
}
}
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ? " . $mode . " '> \n " ;
$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 );
}
}
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ? " . $mode . " '> \n " ;
$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> " ;
echo " <form enctype='multipart/form-data' method='post' action=' " . e_SELF . " ? " . $mode . " '> \n " ;
$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
}
2012-11-28 04:32:05 -08:00
2009-10-28 23:45:46 +00: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
}
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
}
2009-10-28 23:45:46 +00:00
function renderThemeInfo ( $theme )
2006-12-02 04:36:16 +00:00
{
2012-12-11 00:34:08 -08:00
2009-10-28 23:45:46 +00:00
global $pref ;
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-18 12:07:59 +03: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> " ;
2013-01-31 01:49:00 -08:00
$description = vartrue ( $theme [ 'description' ], '' );
2013-03-03 17:50:30 -08:00
$compat = ( intval ( $theme [ 'compatibility' ]) == 2 ) ? " <span class='label label-warning'> " . number_format ( $theme [ 'compatibility' ], 1 , '.' , '' ) . " </span><span class='text-warning'> Recommended!</span> " : vartrue ( number_format ( $theme [ 'compatibility' ], 1 , '.' , '' ), '1.0' );
2013-05-06 20:47:46 -07:00
$price = ( $theme [ 'price' ] > 0 ) ? " <span class='label label-info'><i class='icon-shopping-cart icon-white'></i> " . $theme [ 'price' ] . " </span> " : " <span class='label label-success'> " . Free . " </span> " ;
2013-03-03 17:50:30 -08:00
2013-03-03 16:53:17 -08:00
$text = " <table class='table table-striped'> " ;
// $text .= "<tr><th colspan='2'><h3>".$theme['name']." ".$theme['version']."</h3></th></tr>";
2013-03-03 17:50:30 -08:00
2009-10-31 00:36:09 +00:00
$text .= $author ? " <tr><td style='vertical-align:top; width:24%'><b> " . TPVLAN_4 . " </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 .= $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> " : " " ;
2013-05-06 20:47:46 -07:00
$text .= " <tr><td style='vertical-align:top; width:24%'><b>Price</b>:</td><td style='vertical-align:top'> " . $price . " </td></tr> " ;
2013-01-31 01:49:00 -08:00
$text .= $description ? " <tr><td style='vertical-align:top; width:24%'><b>Description</b>:</td><td style='vertical-align:top'> " . $description . " </td></tr> " : " " ;
// $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>";
if ( vartrue ( $theme [ 'category' ]))
{
$text .= " <tr><td><b>Category</b></td><td> " . $theme [ 'category' ] . " </td></tr> " ;
}
2013-03-03 16:53:17 -08:00
2013-01-31 01:49:00 -08:00
2009-10-28 23:45:46 +00:00
2009-10-28 23:52:56 +00:00
// New in 0.8 WORK IN PROGRESS ----
if ( $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 > " ;
2009-10-31 00:36:09 +00:00
$itext .= ( $mode == 1 ) ? " <td class='fcaption' style='text-align:center;vertical-align:top;'>Default</td> " : " " ;
2009-10-28 23:45:46 +00:00
$itext .= "
2013-03-15 23:35:16 -07:00
< th class = 'fcaption' > Title </ th >
< th class = 'fcaption' > Requirements </ th >
< th class = 'fcaption' style = 'text-align:center;width:100px' > Menu Preset </ 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 > " ;
if ( $mode == 1 )
{
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 > " ;
}
2009-10-28 23:45:46 +00:00
2009-10-31 00:36:09 +00:00
$itext .= " <td style='vertical-align:top'> " ;
2008-11-17 07:17:23 +00:00
$itext .= ( $val [ '@attributes' ][ 'previewFull' ]) ? " <a href=' " . e_THEME_ABS . $theme [ 'path' ] . " / " . $val [ '@attributes' ][ 'previewFull' ] . " ' > " : " " ;
$itext .= $val [ '@attributes' ][ 'title' ];
$itext .= ( $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>
2009-10-31 00:36:09 +00:00
< td style = 'vertical-align:top' > " . $val['@attributes'] ['plugins']. " & nbsp ; </ td >
< td style = 'vertical-align:top;text-align:center' > " ;
2009-10-28 23:45:46 +00:00
$itext .= ( $val [ 'menuPresets' ]) ? ADMIN_TRUE_ICON : " " ;
$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> " ;
2013-03-03 16:53:17 -08:00
if ( count ( $theme [ 'preview' ]))
{
$text .= " <tr><td colspan='2'> " ;
foreach ( $theme [ 'preview' ] as $pic )
{
$picFull = ( substr ( $pic , 0 , 4 ) == 'http' ) ? $pic : e_THEME . $theme [ 'path' ] . " / " . $pic ;
$text .= " <div style='padding:5px;width:700px'>
< img src = '".$picFull."' alt = \ " " . $theme [ 'name' ] . " \" />
</ div > " ;
}
// $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>";
2013-03-03 16:53:17 -08:00
if ( E107_DEBUG_LEVEL > 0 )
{
$text .= print_a ( $theme , true );
}
2009-10-28 23:45:46 +00:00
return $text ;
2009-07-06 05:59:42 +00:00
}
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 " ;
$legacyConfile = e_THEME . $this -> id . " / " . $this -> id . " _config.php " ; // @Deprecated
if ( is_readable ( $newConfile ))
{
$confile = $newConfile ;
}
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
{
2012-11-29 22:03:36 -08:00
$mes -> addDebug ( " Loading : " . $confile );
2009-10-28 23:45:46 +00:00
include ( $confile );
$className = 'theme_' . $this -> id ;
2009-08-17 11:25:01 +00:00
if ( class_exists ( $className ))
{
$this -> themeConfigObj = new $className ();
}
else
{
2009-10-28 23:45:46 +00: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 - .
function renderThemeConfig ()
2009-07-06 05:59:42 +00:00
{
2012-11-29 22:03:36 -08:00
$mes = e107 :: getMessage ();
$mes -> addDebug ( " Rendering Theme Config " );
2009-10-28 23:45:46 +00:00
$this -> loadThemeConfig ();
if ( $this -> themeConfigObj )
{
$var = call_user_func ( array ( & $this -> themeConfigObj , 'config' ));
2014-06-13 12:02:54 +02:00
vartrue ( $text ); // avoid notice
2009-10-28 23:45:46 +00:00
foreach ( $var as $val )
2009-07-09 11:37:36 +00:00
{
2014-08-10 16:02:32 +02:00
$text .= " <tr><td><b> " . $val [ 'caption' ] . " </b>:</td><td colspan='2'> " . $val [ 'html' ] . " <div class='field-help'> " . $val [ 'help' ] . " </div>
</ td ></ tr > " ;
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
}
2009-10-28 23:45:46 +00:00
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
}
2009-10-28 23:45:46 +00:00
2009-07-06 05:59:42 +00:00
function setThemeConfig ()
{
2009-10-28 23:45:46 +00:00
$this -> loadThemeConfig ();
if ( $this -> themeConfigObj )
{
2009-08-27 12:58:29 +00:00
return call_user_func ( array ( & $this -> themeConfigObj , 'process' ));
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
*/
2009-10-28 23:45:46 +00:00
function renderTheme ( $mode = FALSE , $theme )
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 ();
2009-10-28 23:45:46 +00: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>";
2014-06-12 14:47:34 -07:00
$main_icon = ( $pref [ 'sitetheme' ] != $theme [ 'path' ]) ? " <button class='btn 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-sm btn-inverse' type='button'> " . $tp -> toGlyph ( 'fa-check' , array ( 'size' => '2x' )) . " </button> " ;
2013-01-30 16:51:06 -08:00
// $info_icon = "<a data-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>";
2014-06-12 14:47:34 -07:00
$info_icon = " <a class='btn btn-small btn-sm btn-inverse' data-toggle='modal' data-modal-caption= \" " . $theme [ 'name' ] . " " . $theme [ 'version' ] . " \" href=' " . e_SELF . " ?id= " . $theme [ 'path' ] . " ' data-target='#uiModal' 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>";
2014-06-12 14:47:34 -07:00
$admin_icon = ( $pref [ 'admintheme' ] != $theme [ 'path' ] ) ? " <button class='btn 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> \n " : " <button class='btn btn-small btn-sm btn-inverse' type='button'> " . $tp -> toGlyph ( 'fa-check' , array ( 'size' => '2x' )) . " </button> " ;
2013-05-06 21:30:58 -07:00
$price = '' ;
2013-05-06 20:47:46 -07:00
if ( substr ( $theme [ 'thumbnail' ], 0 , 4 ) == 'http' )
{
$thumbPath = $theme [ 'thumbnail' ];
$previewPath = $theme [ 'preview' ][ 0 ];
}
elseif ( vartrue ( $theme [ 'preview' ][ 0 ]))
{
$thumbPath = e_THEME . $theme [ 'path' ] . " / " . $theme [ 'preview' ][ 0 ];
$previewPath = e_THEME . $theme [ 'path' ] . " / " . $theme [ 'preview' ][ 0 ];
}
else
{
$thumbPath = e_IMAGE_ABS . " admin_images/nopreview.png " ;
$previewPath = e_BASE . " index.php?themepreview. " . $theme [ 'id' ];
}
2012-11-28 04:32:05 -08:00
2013-05-06 20:47:46 -07:00
$thumbnail = " <img src=' " . $thumbPath . " ' style='width:200px; height:130px;' alt='' /> " ;
2013-01-30 18:37:42 -08:00
2013-05-06 20:47:46 -07:00
2013-01-30 18:37:42 -08:00
if ( $_GET [ 'mode' ] == 'online' )
{
$d = http_build_query ( $theme , false , '&' );
$url = e_SELF . " ?src= " . base64_encode ( $d );
$id = $frm -> name2id ( $theme [ 'name' ]);
2013-05-06 20:47:46 -07:00
$LAN_DOWNLOAD = ( $theme [ 'price' ] > 0 ) ? " Buy/Download " : " Download " ;
2014-05-12 18:52:57 -07:00
/*
2013-05-19 15:02:05 -07:00
if ( $this -> mp -> hasAuthKey ())
{
$action = 'download' ;
$caption = " Downloading " . $theme [ 'name' ] . " " . $theme [ 'version' ];
}
else
{
$action = 'login' ;
$caption = " Please login to your e107.org account to proceed.. " ;
}
2014-05-12 18:52:57 -07:00
*/
2013-05-19 15:02:05 -07:00
2015-02-10 12:57:38 -08:00
$downloadUrl = e_SELF . '?mode=download&action=' . $action . '&src=' . base64_encode ( $d ); //$url.'&action=download';
2013-05-19 12:16:10 +03:00
$infoUrl = $url . '&action=info' ;
2014-05-12 18:52:57 -07:00
$viewUrl = $theme [ 'url' ];
2013-05-19 17:28:43 +03:00
//$main_icon = "<a data-src='".$downloadUrl."' href='{$downloadUrl}' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='-e-ajax' title='".$LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
2014-05-12 18:52:57 -07:00
// $main_icon = "<a data-toggle='modal' data-modal-caption=\"".$caption."\" href='{$downloadUrl}' data-cache='false' data-target='#uiModal' title='".$LAN_DOWNLOAD."' >".$tp->toGlyph('download',array('size'=>'2x'))."</a> ";
2015-02-10 12:57:38 -08:00
$main_icon = " <a class='e-modal btn btn-small btn-inverse' data-modal-caption= \" " . $theme [ 'name' ] . " " . $theme [ 'version' ] . " \" rel='external' href=' { $downloadUrl } ' data-cache='false' title=' " . $LAN_DOWNLOAD . " ' > " . $tp -> toGlyph ( 'download' , array ( 'size' => '2x' )) . " </a> " ;
2014-05-12 18:52:57 -07:00
// Temporary Pop-up version.
2015-02-10 12:57:38 -08:00
// $main_icon = "<a class='e-modal btn btn-small btn-inverse' data-modal-caption=\"".$theme['name']." ".$theme['version']."\" rel='external' href='{$viewUrl}' data-cache='false' title='".$LAN_DOWNLOAD."' >".$tp->toGlyph('download',array('size'=>'2x'))."</a> ";
2014-05-12 18:52:57 -07:00
2014-06-12 14:47:34 -07:00
$info_icon = " <a class='btn btn-small btn-inverse' data-toggle='modal' data-modal-caption= \" " . $theme [ 'name' ] . " " . $theme [ 'version' ] . " \" href=' " . $infoUrl . " ' data-cache='false' data-target='#uiModal' title=' " . TPVLAN_7 . " '> " . $tp -> toGlyph ( 'fa-info-circle' , array ( 'size' => '2x' )) . " </a> " ;
2013-01-31 01:49:00 -08:00
2013-05-06 20:47:46 -07:00
if ( $theme [ 'livedemo' ])
{
$previewPath = $theme [ 'livedemo' ];
}
2013-01-31 01:49:00 -08:00
//XXX modal-Cache is currently enabled by default. Awaiting inclusion of data-cache feature.
// See here: https://github.com/twitter/bootstrap/pull/4224
2013-05-06 21:30:58 -07:00
$price = ( $theme [ 'price' ] > 0 ) ? " <span class='label label-info pull-right'><i class='icon-shopping-cart icon-white'></i> " . $theme [ 'price' ] . " </span> " : " <span class='label label-success pull-right'> " . Free . " </span> " ;
2013-01-30 18:37:42 -08:00
}
2014-06-12 14:47:34 -07:00
$preview_icon = " <a class='e-modal btn btn-small btn-inverse' title='Preview/Live-Demo : " . $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
2012-11-29 22:03:36 -08:00
if ( ! in_array ( $theme [ 'path' ], $this -> approvedAdminThemes ))
{
$admin_icon = " " ;
}
2012-11-28 04:32:05 -08:00
2013-01-30 16:51:06 -08:00
if ( $theme [ 'name' ] == 'bootstrap' )
2012-12-11 00:34:08 -08:00
{
2013-01-30 16:51:06 -08:00
// print_a($theme);
2012-12-11 00:34:08 -08:00
}
//
2013-01-30 16:51:06 -08:00
// $thumbPath = (substr($theme['thumbnail'],0,4) == 'http') ? $theme['thumbnail'] : e_THEME.$theme['path'] ."/".$theme['preview'][0];
// $thumbnail = "<a href='".e_BASE."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >";
2013-05-06 20:47:46 -07:00
2013-01-30 16:51:06 -08:00
// $thumbnail .= "</a>";
2009-10-28 23:45:46 +00:00
2009-10-28 23:52:56 +00:00
// Choose a Theme to Install.
2013-05-06 20:47:46 -07:00
2013-05-06 21:30:58 -07:00
2013-05-06 20:47:46 -07:00
2009-10-28 23:52:56 +00:00
if ( ! $mode )
2009-07-06 05:59:42 +00:00
{
// styles NEED to be put into style.css
2012-06-03 09:45:20 +00:00
2012-11-29 22:03:36 -08:00
if ( $pref [ 'sitetheme' ] == $theme [ 'path' ])
{
$borderStyle = " admin-theme-cell-site " ;
}
elseif ( $pref [ 'admintheme' ] == $theme [ 'path' ])
{
$borderStyle = " admin-theme-cell-admin " ;
}
else
{
$borderStyle = " admin-theme-cell-default " ;
}
2013-03-15 03:54:34 -07:00
$borderStyle = 'well' ;
2013-05-06 20:47:46 -07:00
2012-11-29 22:03:36 -08:00
$text = "
< div class = 'f-left block-text admin-theme-cell ".$borderStyle."' >
2013-03-15 23:35:16 -07:00
< div class = 'well admin-theme-thumb' > " . $thumbnail . " </ div >
2014-06-12 14:47:34 -07:00
< div id = '".$frm->name2id($theme[' name '])."' class = 'btn-group admin-theme-options' > " . $main_icon . $admin_icon . $info_icon . $preview_icon . " </ div >
2013-05-06 20:47:46 -07:00
< div class = 'admin-theme-title' >< small style = 'white-space:nowrap;display:inline-block;width:160px;overflow:hidden' > " . $theme['name'] . " " . $theme['version'] . " </ small >
" . $price . "
</ div >
2012-11-29 22:03:36 -08:00
</ div > " ;
2009-10-28 23:45:46 +00:00
return $text ;
2006-12-02 04:36:16 +00: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 ();
2009-10-28 23:45:46 +00:00
2009-07-09 11:37:36 +00:00
$text = "
2009-07-09 02:47:17 +00:00
< h2 class = 'caption' > " . $theme['name'] . " </ h2 >
2013-02-25 02:47:23 -08:00
< ul class = 'nav nav-tabs' >
< li class = 'active' >< a data - 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
if ( $this -> themeConfigObj && call_user_func ( array ( & $this -> themeConfigObj , 'config' )) && $mode == 1 )
{
2015-03-29 20:25:33 -07:00
$text .= " <li><a data-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' )))
{
$text .= " <li><a data-toggle='tab' href='#core-thememanager-help'> " . LAN_HELP . " </a></li> \n " ;
}
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 >
2009-07-06 05:59:42 +00:00
< tr >
2013-02-25 02:47:23 -08:00
< td >< b > " .TPVLAN_11. " </ b ></ td >
< td > " . $theme['version'] . " </ td >
2013-03-15 03:54:34 -07:00
< td class = 'well center middle' rowspan = '6' style = 'text-align:center; vertical-align:middle;width:25%' > " . $thumbnail . " </ td >
2013-02-25 02:47:23 -08:00
</ tr > " ;
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_4 . " </b>:</td><td style='vertical-align:top'> " . $author . " </td></tr> " ;
$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> " ;
2013-05-06 20:47:46 -07:00
// $text .= "<tr><td style='vertical-align:top; width:25%'><b>Price</b>:</td><td style='vertical-align:top'>".$price."</td></tr>";
2013-02-25 02:47:23 -08:00
$text .= " <tr><td style='vertical-align:top; width:25%'><b> " . TPVLAN_49 . " </b>:</td>
< td style = 'vertical-align:top' colspan = '2' > " ;
$text .= ( $theme [ 'xhtmlcompliant' ]) ? " W3C XHTML " . $theme [ 'xhtmlcompliant' ] : " Not Specified " ;
$text .= ( $theme [ 'csscompliant' ]) ? " & CSS " . $theme [ 'csscompliant' ] : " " ;
$text .= " </td></tr> " ;
// site theme..
if ( $mode == 1 )
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 >
< td colspan = '2' style = 'vertical-align:top width:auto;' > " ;
if ( varset ( $theme [ 'plugins' ]))
2009-10-28 23:45:46 +00:00
{
2013-02-25 02:47:23 -08:00
foreach ( $theme [ 'plugins' ] as $key => $val )
{
$text .= $this -> renderPlugins ( $theme [ 'plugins' ]);
$text .= " " ;
}
2009-10-28 23:45:46 +00:00
}
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
$text .= "
< 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 >
</ tr > " ;
}
2009-10-28 23:45:46 +00:00
2013-02-25 02:47:23 -08:00
// New in 0.8 ---- site theme.
if ( $mode == 1 )
{
$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 > " ;
2014-01-07 08:21:45 -08:00
$itext .= ( $mode == 1 ) ? " <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 >
< th > " .TPVLAN_56. " </ th >
< 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 > " ;
if ( $mode == 1 )
{
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 )
{
2014-07-26 17:39:59 +02:00
$custompage_diz .= " <a href='#element-to-be-shown- { $key } ' title='Set pages which should automatically use this layout. One per line.' class='e-tip btn btn-mini e-expandit'> " . trim ( $cp ) . " </a> " ;
2013-02-25 02:47:23 -08:00
if ( $count > 4 )
{
$custompage_diz .= " ... " ;
break ;
}
$count ++ ;
}
}
else
{
$custompage_diz = " <a href='#element-to-be-shown- { $key } ' title='Set pages which should automatically use this layout. One per line.' class='e-tip btn btn-mini e-expandit'>None</a> " ;
}
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
$itext .= ( $pref [ 'sitetheme_deflayout' ] != $key ) ? $custompage_diz . " <div class='e-hideme' id='element-to-be-shown- { $key } '><textarea 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></div> \n " : TPVLAN_55 ;
$itext .= " </td> " ;
$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 > " ;
}
$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
2013-02-25 02:47:23 -08:00
if ( $mode == 2 )
{
$astext = " " ;
$file = e107 :: getFile ();
$adminstyles = $file -> get_files ( e_ADMIN . " includes " );
$astext = " \n <select id='mode2' name='adminstyle' class='tbox'> \n " ;
foreach ( $adminstyles as $as )
{
$style = str_replace ( " .php " , " " , $as [ 'fname' ]);
$astext .= " <option value=' { $style } ' " . ( $pref [ 'adminstyle' ] == $style ? " selected='selected' " : " " ) . " > " . $style . " </option> \n " ;
}
$astext .= " </select> " ;
$text .= "
< tr >
< td >< b > " .TPVLAN_41. " :</ b ></ td >
< td colspan = '2' > " . $astext . " </ td >
</ tr >
\n " ;
}
2009-08-06 22:27:47 +00:00
2013-02-25 02:47:23 -08:00
$text .= $itext ;
2015-04-09 20:15:20 -07:00
$wildcard = false ;
$curCss = array ();
foreach ( $theme [ 'css' ] as $k => $vl )
{
if ( $vl [ 'name' ] == '*' )
{
unset ( $theme [ 'css' ][ $k ]);
$wildcard = true ;
}
else
{
$curCss [] = $vl [ 'name' ];
}
}
if ( $wildcard == true )
{
foreach ( $theme [ 'files' ] as $val )
{
if ( substr ( $val , - 4 ) == '.css' && substr ( $val , 0 , 5 ) != 'admin_' && ! in_array ( $val , $curCss ))
{
$theme [ 'css' ][] = array ( 'name' => $val , 'info' => 'User-added Stylesheet' , 'nonadmin' => 1 );
}
}
}
2012-12-16 21:10:42 -08:00
2013-02-25 02:47:23 -08:00
if ( array_key_exists ( " multipleStylesheets " , $theme ) && $mode )
2012-12-16 21:10:42 -08:00
{
2013-02-25 02:47:23 -08:00
$text .= "
< tr >< td style = 'vertical-align:top;' >< b > " .TPVLAN_22. " :</ 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
< tr >
< td class = 'center' style = 'width:10%' > " .TPVLAN_55. " </ td >
< td style = 'width:20%' > " .TPVLAN_52. " </ td >
< td class = 'left' > " .TPVLAN_7. " </ td >
</ tr > " ;
foreach ( $theme [ 'css' ] as $css )
{
$text2 = " " ;
if ( $mode == 2 ) // ADMIN MODE
{
if ( $css [ 'name' ] == " style.css " || ! vartrue ( $css [ 'info' ])) // Hide the admin css unless it has a header. eg. /* info: Default stylesheet */
{
continue ;
}
if ( ! $css [ 'nonadmin' ])
{
2013-03-15 23:35:16 -07:00
$for = $frm -> name2id ( " admincss- " . $css [ 'name' ]);
2013-02-25 02:47:23 -08:00
$text2 = "
< td class = 'center' > " .
2013-03-15 03:54:34 -07:00
$frm -> radio ( 'admincss' , $css [ 'name' ], vartrue ( $pref [ 'admincss' ]) == $css [ 'name' ]) . "
2013-02-25 02:47:23 -08:00
</ td >
2013-03-15 23:35:16 -07:00
< td >< label for = '".$for."' > " . $css['info'] . " </ label ></ td > " ;
$text2 .= " <td> " . ( $css [ 'info' ] ? $css [ 'info' ] : ( $css [ 'name' ] == " admin_style.css " ? TPVLAN_23 : TPVLAN_24 )) . " </td> \n " ;
2013-02-25 02:47:23 -08:00
}
}
if ( $mode == 1 ) // SITE-THEME Mode
{
2013-06-17 15:40:39 -07:00
if ( substr ( $css [ 'name' ], 0 , 6 ) == " admin_ " )
2013-02-25 02:47:23 -08:00
{
continue ;
}
$text2 = "
< td class = 'center' >
2013-06-17 16:45:03 -07:00
< 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' " : " " ). " />
2013-02-25 02:47:23 -08:00
</ td >
2013-06-17 16:45:03 -07:00
< td >< label for = '".$frm->name2id($css[' name '])."' > " . $css['name'] . " </ lable ></ td >
2013-02-25 02:47:23 -08:00
< td > " .( $css['info'] ? $css['info'] : ( $css['name'] == " style . css " ? TPVLAN_23 : TPVLAN_24)). " </ td > \n " ;
}
$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
2014-06-14 21:50:13 +02:00
/*
2013-02-25 02:47:23 -08:00
if ( $mode == 1 )
2006-12-02 04:36:16 +00:00
{
2013-02-25 02:47:23 -08:00
$text .= $this -> renderThemeConfig ();
2006-12-02 04:36:16 +00:00
}
2014-06-14 21:50:13 +02:00
*/
2013-02-25 02:47:23 -08:00
$text .= " </table>
< div class = 'center buttons-bar' > " ;
if ( $mode == 2 ) // admin
{
$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' > " ;
if ( $mode == 2 ) // admin
{
$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 >
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
function renderPresets ( $key )
{
require_once ( e_HANDLER . " menumanager_class.php " );
$frm = e107 :: getForm ();
$men = new e_menuManager ();
$men -> curLayout = $key ;
2015-02-06 01:03:09 -08:00
$preset = $men -> getMenuPreset (); //FIXME Broken XML format.
// print_a($preset);
2013-12-31 00:59:30 -08:00
2014-01-07 08:21:45 -08:00
$text .= " <div class='btn-group pull-right'> " . $frm -> admin_button ( " setMenuPreset[ " . $key . " ] " , " Activate Menus " , 'other' );
2013-12-31 00:59:30 -08:00
$text .= ' < button class = " btn btn-primary dropdown-toggle " data - toggle = " dropdown " >
< span class = " caret " ></ span >
</ button >
< ul class = " dropdown-menu col-selection " >
<!-- dropdown menu links -->
< li >< strong > Activate the following :</ strong ></ li >
' ;
foreach ( $preset as $val )
{
$text .= " <li><a title=' " . $val [ 'menu_name' ] . " '> " . str_replace ( " _menu " , " " , $val [ 'menu_name' ]) . " </a></li> " ;
}
// $itext .= "<div class='field-help'>".print_a($preset ,true)."</div>";
$text .= " </ul></div> " ;
return $text ;
}
2009-10-28 23:45:46 +00:00
function renderPlugins ( $pluginOpts )
2009-07-06 08:45:19 +00:00
{
2009-10-31 00:36:09 +00:00
global $frm , $sql ;
2009-10-28 23:45:46 +00:00
2009-10-28 23:52:56 +00:00
// if there is 1 entry, then it's not the same array.
$tmp = ( varset ( $pluginOpts [ 'plugin' ][ 1 ])) ? $pluginOpts [ 'plugin' ] : $pluginOpts ;
2009-10-28 23:45:46 +00:00
$text = " " ;
foreach ( $tmp 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;
if ( $sql -> db_Select ( " plugin " , " plugin_id " , " plugin_path = ' " . $plug . " ' LIMIT 1 " ))
{
$row = $sql -> db_Fetch ( MYSQL_ASSOC );
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
}
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
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
function themePreview ()
{
2009-10-28 23:45:46 +00:00
echo " <script type='text/javascript'>document.location.href=' " . e_BASE . " index.php?themepreview. " . $this -> id . " '</script> \n " ;
2006-12-02 04:36:16 +00:00
exit ;
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
function showPreview ()
{
2008-04-10 19:23:51 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_theme.php " );
2006-12-02 04:36:16 +00:00
$text = " <br /><div class='indent'> " . TPVLAN_1 . " .</div><br /> " ;
global $ns ;
$ns -> tablerender ( TPVLAN_2 , $text );
}
2009-10-28 23:45:46 +00: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
{
2009-09-17 00:13:40 +00:00
$core = e107 :: getConfig ( 'core' );
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
2009-10-28 23:45:46 +00:00
$themeArray = $this -> getThemes ( " id " );
2012-11-29 23:12:20 -08:00
$name = ( $name ) ? $name : vartrue ( $themeArray [ $this -> id ]);
2009-10-28 23:45:46 +00:00
$layout = $pref [ 'sitetheme_layouts' ] = is_array ( $this -> themeArray [ $name ][ 'layouts' ]) ? $this -> themeArray [ $name ][ 'layouts' ] : array ();
$deflayout = $this -> findDefault ( $name );
$customPages = $this -> themeArray [ $name ][ 'custompages' ];
$version = $this -> themeArray [ $name ][ 'version' ];
$core -> set ( 'sitetheme' , $name );
$core -> set ( 'themecss' , 'style.css' );
$core -> set ( 'sitetheme_layouts' , $layout );
$core -> set ( 'sitetheme_deflayout' , $deflayout );
$core -> set ( 'sitetheme_custompages' , $customPages );
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' ]))
{
$core -> set ( 'sitetheme_pref' , $this -> themeArray [ $name ][ 'preferences' ]);
}
2013-03-08 02:19:18 -08:00
// $core->set('sitetheme_releaseUrl', $this->themeArray[$name]['releaseUrl']);
2009-10-28 23:45:46 +00:00
2013-04-15 19:46:35 -07:00
if ( $contentCheck === true )
{
$sql -> db_Delete ( " menus " , " menu_layout !='' " );
}
2009-10-28 23:45:46 +00:00
2014-01-08 17:23:56 +01:00
e107 :: getCache () -> clear ();
2009-09-17 00:13:40 +00:00
2009-10-28 23:45:46 +00:00
if ( $core -> save ())
2009-07-14 03:18:17 +00:00
{
2009-09-17 00:13:40 +00:00
//TODO LANs
2013-03-28 00:41:29 -07:00
$mes -> addDebug ( " Default Layout: " . $deflayout );
2012-12-17 13:22:17 -08:00
$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) $ " );
2013-03-08 02:19:18 -08:00
$med -> import ( '_common_image' , e_THEME . $name , '' , 'min-size=20000' );
2013-04-14 20:18:23 -07:00
if ( $contentCheck === true )
{
$this -> installContentCheck ( $name );
}
2013-03-08 02:19:18 -08:00
2012-12-06 21:41:53 -08:00
2009-10-28 23:45:46 +00:00
$this -> theme_adminlog ( '01' , $name . ', style.css' );
2013-03-08 04:46:02 -08:00
2009-09-17 00:13:40 +00: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);
2009-09-17 00:13:40 +00:00
return FALSE ;
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
*/
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
2013-03-08 04:46:02 -08:00
$text .= " </ul>
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
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
/**
* @ param $theme
* @ return int | string
*/
2009-07-05 11:57:40 +00:00
function findDefault ( $theme )
{
if ( varset ( $_POST [ 'layout_default' ]))
{
2009-10-28 23:45:46 +00:00
return $_POST [ 'layout_default' ];
2009-07-05 11:57:40 +00:00
}
2009-10-28 23:45:46 +00:00
$l = $this -> themeArray [ $theme ];
2009-07-12 14:44:57 +00:00
if ( ! $l )
{
2009-10-28 23:45:46 +00:00
$l = $this -> getThemeInfo ( $theme );
2009-07-12 14:44:57 +00:00
}
2009-10-28 23:45:46 +00:00
2009-07-08 06:58:00 +00:00
if ( $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
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
function setAdminTheme ()
{
2012-11-28 02:22:23 -08:00
global $pref , $e107cache ;
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2009-10-28 23:45:46 +00:00
$themeArray = $this -> getThemes ( " id " );
$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');
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
function setStyle ()
{
2012-11-28 02:22:23 -08:00
global $pref , $e107cache ;
$sql = e107 :: getDb ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2009-08-17 14:40:23 +00:00
//TODO adminlog
2009-10-28 23:45:46 +00:00
e107 :: getConfig () -> setPosted ( 'themecss' , $_POST [ 'themecss' ]) -> setPosted ( 'image_preload' , $_POST [ 'image_preload' ]) -> setPosted ( 'sitetheme_deflayout' ,
$_POST [ 'layout_default' ]);
2009-08-17 14:40:23 +00:00
$msg = $this -> setThemeConfig ();
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
}
2006-12-02 04:36:16 +00:00
}
2009-10-28 23:45:46 +00:00
2006-12-02 04:36:16 +00:00
function setAdminStyle ()
{
2012-11-28 02:22:23 -08:00
global $pref , $e107cache ;
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2009-08-17 14:40:23 +00:00
/* $pref [ 'admincss' ] = $_POST [ 'admincss' ];
2009-10-28 23:45:46 +00:00
$pref [ 'adminstyle' ] = $_POST [ 'adminstyle' ];
$e107cache -> clear_sys ();
if ( save_prefs ())
{
2012-11-28 02:22:23 -08:00
$mes -> add ( TPVLAN_43 , E_MESSAGE_SUCCESS );
2009-10-31 00:36:09 +00:00
$this -> theme_adminlog ( '04' , $pref [ 'adminstyle' ] . ', ' . $pref [ 'admincss' ]);
2009-10-28 23:45:46 +00:00
}
else
{
2012-11-28 02:22:23 -08:00
$mes -> add ( TPVLAN_43 , E_MESSAGE_ERROR );
2009-10-28 23:45:46 +00:00
} */
2009-07-06 09:17:27 +00:00
2009-10-28 23:45:46 +00:00
2009-08-17 14:40:23 +00:00
//TODO adminlog
2009-10-28 23:45:46 +00:00
e107 :: getConfig () -> setPosted ( 'admincss' , $_POST [ 'admincss' ]) -> setPosted ( 'adminstyle' , $_POST [ 'adminstyle' ]);
2009-08-17 14:40:23 +00:00
return ( e107 :: getConfig () -> dataHasChangedFor ( 'admincss' ) || e107 :: getConfig () -> dataHasChangedFor ( 'adminstyle' ));
2006-12-02 04:36:16 +00:00
}
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
*/
function setLayouts ( $name = '' )
{
$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
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;
2014-10-23 11:12:13 -07:00
e107 :: getLog () -> add ( 'THEME_' . $msg_num , $woffle , E_LOG_INFORMATIVE , '' );
2008-11-02 10:28:30 +00:00
}
2009-10-28 23:45:46 +00:00
2008-11-17 07:17:23 +00:00
function parse_theme_php ( $path )
{
2009-10-28 23:45:46 +00:00
$CUSTOMPAGES = " " ;
2013-05-02 10:17:54 +02:00
$tp = e107 :: getParser ();
2009-10-28 23:45:46 +00:00
$fp = fopen ( e_THEME . $path . " /theme.php " , " r " );
$themeContents = fread ( $fp , filesize ( e_THEME . $path . " /theme.php " ));
2008-11-17 07:17:23 +00:00
fclose ( $fp );
2009-10-28 23:45:46 +00:00
2008-11-17 07:17:23 +00:00
preg_match ( '/themename(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'name' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themeversion(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'version' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themeauthor(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'author' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themeemail(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'email' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themewebsite(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'website' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themedate(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'date' ] = varset ( $match [ 3 ], '' );
2008-11-17 07:17:23 +00:00
preg_match ( '/themeinfo(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-28 23:45:46 +00:00
$themeArray [ 'info' ] = varset ( $match [ 3 ], '' );
preg_match ( '/xhtmlcompliant(\s*?=\s*?)(\S*?);/si' , $themeContents , $match );
2008-11-17 07:17:23 +00:00
$xhtml = strtolower ( $match [ 2 ]);
2009-07-24 12:54:39 +00:00
$themeArray [ 'xhtmlcompliant' ] = ( $xhtml == " true " ? " 1.1 " : false );
2009-10-28 23:45:46 +00:00
2008-11-17 07:17:23 +00:00
preg_match ( '/csscompliant(\s*?=\s*?)(\S*?);/si' , $themeContents , $match );
$css = strtolower ( $match [ 2 ]);
2009-07-24 12:54:39 +00:00
$themeArray [ 'csscompliant' ] = ( $css == " true " ? " 2.1 " : false );
2009-10-28 23:45:46 +00:00
/* preg_match ( '/CUSTOMPAGES(\s*?=\s*?)("|\')(.*?)("|\');/si' , $themeContents , $match );
2009-10-31 00:36:09 +00:00
$themeArray [ 'custompages' ] = array_filter ( explode ( " " , $match [ 3 ])); */
2009-10-28 23:45:46 +00:00
$themeContentsArray = explode ( " \n " , $themeContents );
2009-11-09 00:13:59 +00:00
preg_match_all ( " # \\ $ " . " CUSTOMHEADER \ [( \" |')(.*?)('| \" ) \ ].*?# " , $themeContents , $match );
$customHeaderArray = $match [ 2 ];
preg_match_all ( " # \\ $ " . " CUSTOMFOOTER \ [( \" |')(.*?)('| \" ) \ ].*?# " , $themeContents , $match );
2009-11-09 00:27:43 +00:00
$customFooterArray = $match [ 2 ];
2009-10-28 23:45:46 +00:00
if ( ! $themeArray [ 'name' ])
2008-11-17 07:17:23 +00:00
{
2008-12-03 18:09:00 +00:00
unset ( $themeArray );
}
2009-07-12 14:44:57 +00:00
2009-10-28 23:45:46 +00:00
$lays [ 'legacyDefault' ][ '@attributes' ] = array ( 'title' => 'Default' ,
'plugins' => '' ,
'default' => 'true' );
2009-10-28 23:52:56 +00:00
// load custompages from theme.php only when theme.xml doesn't exist.
if ( ! file_exists ( e_THEME . $path . " theme.xml " ))
2009-07-07 16:04:51 +00:00
{
2009-11-09 00:27:43 +00:00
foreach ( $themeContentsArray as $line )
{
if ( strstr ( $line , " CUSTOMPAGES " ))
{
eval ( str_replace ( " $ " , " \$ " , $line )); // detect arrays also.
}
}
2009-11-09 00:13:59 +00:00
2009-10-28 23:45:46 +00:00
if ( is_array ( $CUSTOMPAGES ))
2009-07-12 14:44:57 +00:00
{
2009-10-28 23:45:46 +00:00
foreach ( $CUSTOMPAGES as $key => $val )
{
$themeArray [ 'custompages' ][ $key ] = explode ( " " , $val );
}
2009-07-12 14:44:57 +00:00
}
elseif ( $CUSTOMPAGES )
{
2009-10-28 23:45:46 +00:00
$themeArray [ 'custompages' ][ 'legacyCustom' ] = explode ( " " , $CUSTOMPAGES );
$lays [ 'legacyCustom' ][ '@attributes' ] = array ( 'title' => 'Custom' ,
'plugins' => '' );
2009-07-07 16:04:51 +00:00
}
2009-11-09 00:13:59 +00:00
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' => '' );
}
2009-07-07 16:04:51 +00:00
}
2009-11-09 00:13:59 +00:00
2009-07-06 05:59:42 +00:00
$themeArray [ 'path' ] = $path ;
2009-07-09 08:31:38 +00:00
$themeArray [ 'layouts' ] = $lays ;
2012-12-11 00:34:08 -08:00
if ( file_exists ( e_THEME . $path . " /preview.jpg " ))
{
$themeArray [ 'preview' ] = array ( " preview.jpg " );
2013-01-30 16:51:06 -08:00
$themeArray [ 'thumbnail' ] = " preview.jpg " ;
2012-12-11 00:34:08 -08:00
}
if ( file_exists ( e_THEME . $path . " /preview.png " ))
{
$themeArray [ 'preview' ] = array ( " preview.png " );
2013-01-30 16:51:06 -08:00
$themeArray [ 'thumbnail' ] = " preview.png " ;
2012-12-11 00:34:08 -08:00
}
2009-11-09 00:13:59 +00:00
// echo "<h2>".$themeArray['name']."</h2>";
// print_a($lays);
2009-10-28 23:45:46 +00:00
return $themeArray ;
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
{
2009-11-05 09:15:19 +00:00
$tp = e107 :: getParser ();
$xml = e107 :: getXml ();
// loadLanFiles($path, 'admin'); // Look for LAN files on default paths
2009-10-28 23:52:56 +00:00
// layout should always be an array.
2012-12-11 00:34:08 -08:00
$xml -> setOptArrayTags ( 'layout,screenshots/image' );
2015-01-28 12:31:14 -08:00
$xml -> setOptStringTags ( 'menuPresets,customPages,custompages' );
2012-12-11 00:34:08 -08:00
2015-01-28 12:31:14 -08:00
// $vars = $xml->loadXMLfile(e_THEME.$path.'/theme.xml', true, true);
2015-02-11 11:05:33 -08:00
// $oldvars =
2015-01-28 12:31:14 -08:00
$vars = $xml -> loadXMLfile ( e_THEME . $path . '/theme.xml' , 'advanced' , true ); // must be 'advanced'
2015-02-11 11:05:33 -08:00
if ( $path == " bootstrap3 " )
2015-01-28 12:31:14 -08:00
{
2015-02-11 11:05:33 -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>";
2015-01-28 12:31:14 -08:00
}
2009-10-28 23:45:46 +00:00
2013-01-30 16:51:06 -08:00
$vars [ 'name' ] = varset ( $vars [ '@attributes' ][ 'name' ]);
$vars [ 'version' ] = varset ( $vars [ '@attributes' ][ 'version' ]);
$vars [ 'date' ] = varset ( $vars [ '@attributes' ][ 'date' ]);
$vars [ 'compatibility' ] = varset ( $vars [ '@attributes' ][ 'compatibility' ]);
$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' ]);
$vars [ 'info' ] = varset ( $vars [ 'description' ]);
$vars [ 'category' ] = $this -> getThemeCategory ( varset ( $vars [ 'category' ]));
2009-10-28 23:45:46 +00:00
$vars [ 'xhtmlcompliant' ] = varset ( $vars [ 'compliance' ][ '@attributes' ][ 'xhtml' ]);
2013-01-30 16:51:06 -08:00
$vars [ 'csscompliant' ] = varset ( $vars [ 'compliance' ][ '@attributes' ][ 'css' ]);
$vars [ 'path' ] = $path ;
2009-09-17 00:13:40 +00:00
$vars [ '@attributes' ][ 'default' ] = ( varset ( $vars [ '@attributes' ][ 'default' ]) && strtolower ( $vars [ '@attributes' ][ 'default' ]) == 'true' ) ? 1 : 0 ;
2013-01-30 16:51:06 -08:00
$vars [ 'preview' ] = varset ( $vars [ 'screenshots' ][ 'image' ]);
2013-03-21 02:36:55 -07:00
$vars [ 'thumbnail' ] = varset ( $vars [ 'preview' ][ 0 ]);
2009-09-17 00:13:40 +00:00
2015-01-28 12:31:14 -08:00
if ( ! empty ( $vars [ 'themePrefs' ]))
{
foreach ( $vars [ 'themePrefs' ][ 'pref' ] as $k => $val )
{
$name = $val [ '@attributes' ][ 'name' ];
$vars [ 'preferences' ][ $name ] = $val [ '@value' ];
}
}
2012-12-11 00:34:08 -08:00
unset ( $vars [ 'authorEmail' ], $vars [ 'authorUrl' ], $vars [ 'xhtmlCompliant' ], $vars [ 'cssCompliant' ], $vars [ 'description' ], $vars [ 'screenshots' ]);
2009-09-17 00:13:40 +00:00
2009-10-28 23:45:46 +00:00
// Compile layout information into a more usable format.
2009-09-17 00:13:40 +00:00
2009-10-28 23:45:46 +00:00
$custom = array ();
2013-03-15 05:28:27 -07:00
/*
2009-10-28 23:45:46 +00:00
foreach ( $vars [ 'layouts' ] as $layout )
2008-11-17 07:17:23 +00:00
{
2009-10-28 23:45:46 +00:00
foreach ( $layout as $key => $val )
2008-11-17 07:17:23 +00:00
{
2009-09-17 00:13:40 +00:00
$name = $val [ '@attributes' ][ 'name' ];
unset ( $val [ '@attributes' ][ 'name' ]);
$lays [ $name ] = $val ;
2013-03-15 05:28:27 -07:00
2012-12-16 21:10:42 -08:00
2009-09-17 00:13:40 +00:00
if ( isset ( $val [ 'customPages' ]))
2009-07-06 08:45:19 +00:00
{
2013-03-15 05:28:27 -07:00
$cusArray = explode ( " " , $val [ 'customPages' ]);
$custom [ $name ] = array_filter ( $cusArray );
2009-07-07 16:04:51 +00:00
}
2012-12-16 21:10:42 -08:00
if ( isset ( $val [ 'custompages' ]))
{
2013-03-15 05:28:27 -07:00
$cusArray = explode ( " " , $val [ 'custompages' ]);
2012-12-16 21:10:42 -08:00
$custom [ $name ] = array_filter ( explode ( " " , $val [ 'custompages' ]));
}
2009-07-06 08:45:19 +00:00
}
2009-10-28 23:45:46 +00:00
}
2013-03-15 05:28:27 -07:00
*/
foreach ( $vars [ 'layouts' ][ 'layout' ] as $k => $val )
{
$name = $val [ '@attributes' ][ 'name' ];
unset ( $val [ '@attributes' ][ 'name' ]);
$lays [ $name ] = $val ;
2013-03-21 02:36:55 -07:00
if ( isset ( $val [ 'custompages' ]))
2013-03-17 02:57:09 -07:00
{
2013-03-21 02:36:55 -07:00
if ( is_string ( $val [ 'custompages' ]))
{
$custom [ $name ] = array_filter ( explode ( " " , $val [ 'custompages' ]));
}
elseif ( is_array ( $val [ 'custompages' ]))
{
$custom [ $name ] = $val [ 'custompages' ];
}
2013-03-15 05:28:27 -07:00
}
}
2009-10-28 23:45:46 +00:00
2012-12-16 21:10:42 -08:00
$vars [ 'layouts' ] = $lays ;
$vars [ 'path' ] = $path ;
$vars [ 'custompages' ] = $custom ;
2013-06-21 01:25:47 -07:00
if ( vartrue ( $vars [ 'stylesheets' ][ 'css' ]))
{
$vars [ 'css' ] = array ();
foreach ( $vars [ 'stylesheets' ][ 'css' ] as $val )
{
$notadmin = vartrue ( $val [ '@attributes' ][ 'admin' ]) ? false : true ;
$vars [ 'css' ][] = array ( " name " => $val [ '@attributes' ][ 'file' ], " info " => $val [ '@attributes' ][ 'name' ], " nonadmin " => $notadmin );
}
unset ( $vars [ 'stylesheets' ]);
}
//
2013-01-30 16:51:06 -08:00
2012-12-16 21:10:42 -08:00
$mes = e107 :: getMessage (); // DEBUG
2013-03-15 05:28:27 -07:00
2013-03-17 02:57:09 -07:00
if ( $path == " leasure " )
2012-11-26 03:23:20 -08:00
{
2013-03-15 05:28:27 -07:00
2013-03-17 02:57:09 -07:00
// $mes->addDebug("<h2>".$path."</h2>");
// $mes->addDebug(print_a($vars,true));
// $mes->addDebug("<hr />");
2012-11-26 03:23:20 -08:00
}
2013-03-15 05:28:27 -07:00
2015-02-11 11:05:33 -08:00
if ( $path == " bootstrap3 " )
2015-01-28 12:31:14 -08:00
{
2015-02-11 11:05:33 -08:00
// print_a($vars);
2015-01-28 12:31:14 -08:00
// echo "<table class='table'><tr><td>".print_a($vars,true)."</td><td>".print_a($adv,true)."</td></tr></table>";
}
2012-12-11 00:34:08 -08:00
2009-10-28 23:45:46 +00:00
return $vars ;
2008-11-17 07:17:23 +00:00
}
2009-10-28 23:52:56 +00:00
2009-08-27 12:58:29 +00:00
}
2009-08-17 12:48:52 +00:00
2009-08-27 12:58:29 +00:00
interface e_theme_config
{
/**
* Triggered on theme settings submit
* Catch and save theme configuration
*/
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
*/
public function config ();
/**
* Theme help tab
2009-10-28 23:45:46 +00:00
* Print out theme help content
2009-08-27 12:58:29 +00:00
*/
public function help ();
2007-01-17 20:47:41 +00:00
}