array('controller' =>'CONTROLLER_CLASS'[, 'index' => 'list', 'path' => 'CONTROLLER SCRIPT PATH', 'ui' => 'UI CLASS NAME child of e_admin_ui', 'uipath' => 'UI SCRIPT PATH']); * Note - default mode/action is autodetected in this order: * - $defaultMode/$defaultAction (owned by dispatcher - see below) * - $adminMenu (first key if admin menu array is not empty) * - $modes (first key == mode, corresponding 'index' key == action) * @var array */ protected $modes = array( 'main' => array( 'controller' => 'theme_admin_ui', 'path' => null, 'ui' => 'theme_admin_form_ui', 'uipath' => null ), 'convert' => array( 'controller' => 'theme_builder', 'path' => null, 'ui' => 'theme_admin_form_ui', 'uipath' => null ), ); protected $adminMenu = array( 'main/main' => array('caption'=> TPVLAN_33, 'perm' => '0|1|TMP', 'icon'=>'fas-home'), 'main/admin' => array('caption'=> TPVLAN_34, 'perm' => '0', 'icon'=>'fas-tachometer-alt'), 'main/choose' => array('caption'=> TPVLAN_51, 'perm' => '0', 'icon'=>'fas-exchange-alt'), 'main/online' => array('caption'=> TPVLAN_62, 'perm' => '0', 'icon'=>'fas-search'), 'main/upload' => array('caption'=> TPVLAN_38, 'perm' => '0'), 'convert/main' => array('caption'=> ADLAN_CL_6, 'perm' => '0', 'icon'=>'fas-toolbox') ); protected $adminMenuAliases = array( 'main/edit' => 'main/list' ); protected $adminMenuIcon = 'e-themes-24'; protected $menuTitle = TPVLAN_26; function init() { } function handleAjax() { if(empty($_GET['action'])) { return null; } require_once(e_HANDLER."theme_handler.php"); $themec = new themeHandler; switch ($_GET['action']) { case 'login': $mp = $themec->getMarketplace(); echo $mp->renderLoginForm(); exit; break; /* case 'download': $string = base64_decode($_GET['src']); parse_str($string, $p); $mp = $themec->getMarketplace(); $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) echo "
Connecting...\n"; flush();
					// download and flush
					$mp->download($p['id'], $p['mode'], $p['type']);
					echo "
"; flush(); exit; break; */ case 'info': if(!empty($_GET['src'])) { $string = base64_decode($_GET['src']); parse_str($string,$p); $themeInfo = e107::getSession()->get('thememanager/online/'.intval($p['id'])); echo $themec->renderThemeInfo($themeInfo); } break; case 'preview': // Theme Info Ajax $tm = (string) $_GET['id']; $data = e107::getTheme($tm)->get(); // $themec->getThemeInfo($tm); echo $themec->renderThemeInfo($data); // exit; break; } /* if(vartrue($_GET['src'])) // Process Theme Download. { $string = base64_decode($_GET['src']); parse_str($string,$p); if(vartrue($_GET['info'])) { echo $themec->renderThemeInfo($p); // print_a($p); exit; } $remotefile = $p['url']; e107::getFile()->download($remotefile,'theme'); exit; } */ // Theme Info Ajax // FIXME addd action=preview to the url, remove this block if(!empty($_GET['id'])) { $tm = (string) $_GET['id']; $data = e107::getTheme($tm)->get(); // $themec->getThemeInfo($tm); echo $themec->renderThemeInfo($data); } require_once(e_ADMIN."footer.php"); exit; } } class theme_admin_ui extends e_admin_ui { // required protected $pluginTitle = TPVLAN_26; protected $pluginName = 'core'; protected $table = false; protected $listQry = false; protected $pid = "id"; protected $perPage = 10; protected $batchDelete = false; // protected \$sortField = 'somefield_order'; // protected \$sortParent = 'somefield_parent'; // protected \$treePrefix = 'somefield_title'; protected $grid = array('price'=>'price', 'version'=>'version','title'=>'name', 'image'=>'thumbnail', 'body'=>'', 'class'=>'col-md-2 col-sm-3', 'perPage'=>12, 'carousel'=>true, 'toggleButton'=>false); protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'), 'id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'class'=>'center', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable 'name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable 'thumbnail' => array('title'=> LAN_IMAGE, 'type' => 'image', 'readParms'=>array('thumb'=>1,'w'=>300,'h'=>169,'crop'=>1, 'link'=>false, 'fallback'=>'{e_IMAGE}admin_images/nopreview.png'), 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE), 'folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''), 'category' => array('title'=> LAN_CATEGORY, 'type' => 'dropdown', 'data' => 'str', 'filter'=>true, 'width' => 'auto', 'thclass' => '', 'writeParms'=>array()), 'version' => array('title'=> 'Version', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''), 'price' => array('title'=> LAN_AUTHOR, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'), // 'blank_authorURL' => array('title'=> "Url", 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'), // 'blank_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => 'type=datetime'), // 'blank_compatibility' => array('title'=> 'Compatible', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ), // 'blank_url' => array('title'=> LAN_URL, 'type' => 'file', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => false, 'help' => 'Enter blank URL here', 'error' => 'please, ener valid URL'), // 'test_list_1' => array('title'=> 'test 1', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'noedit' => true), 'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE) ); //required - default column user prefs // protected $fieldpref = array('checkboxes', 'blank_id', 'blank_type', 'blank_url', 'blank_compatibility', 'options'); // optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName); protected $prefs = array(); protected $themeObj; public function __construct($request,$response,$params=array()) { require_once(e_HANDLER."theme_handler.php"); $this->themeObj = new themeHandler; // handles POSTed data. $this->fields['category']['writeParms']['optArray'] = e107::getTheme()->getCategoryList(); // array('plugin_category_0','plugin_category_1', 'plugin_category_2'); // Example Drop-down array. parent::__construct($request,$response,$params); } // optional public function init() { e107::css('inline', ' .admin-ui-grid .price { position: absolute; /* bottom: 68px;*/ top:0; right: 18px; } .overlay-title { padding-bottom:7px } '); $this->themeObj ->postObserver(); $this->grid['template'] = '
{IMAGE}
{TITLE} v{VERSION}
{OPTIONS}
'; } public function _setTreeModel() { if($this->getAction() === 'online') { $this->_tree_model = new theme_admin_online_tree_model; } else { $this->_tree_model = new theme_admin_tree_model;// new theme_model_admin_tree(); } return $this; } public function ChooseObserver() // action = choose { $mes = e107::getMessage(); $tp = e107::getParser(); if(!empty($_POST['selectmain'])) { $id = key($_POST['selectmain']); $message = $tp->lanVars(TPVLAN_94,$id); if($this->themeObj->setTheme($id)) { $mes->addSuccess($message); // clear infopanel in admin dashboard. e107::getCache()->clear('Infopanel_theme', true); e107::getSession()->clear('addons-update-status'); e107::getSession()->set('addons-update-checked',false); // set to recheck it. } else { $mes->addError($message); } } if(!empty($_POST['selectadmin'])) { $id = key($_POST['selectadmin']); $this->setAdminTheme($id); } $param = array(); $this->perPage = 0; $param['limitFrom'] = (int) $this->getQuery('from', 0); $param['limitTo'] = 0 ; // (int) $this->getPerPage(); $param['searchqry'] = $this->getQuery('searchquery', ''); $this->getTreeModel()->setParams($param)->loadBatch(); // load the tree model above from the class below. } private function setAdminTheme($folder) { $adminCSS = file_exists(e_THEME.$pref['admintheme'].'/admin_dark.css') ? 'admin_dark.css' : 'admin_light.css'; e107::getConfig()->set('admintheme',$folder)->set('admincss',$adminCSS)->save(true,true,true); e107::getCache()->clear_sys(); /* if(save_prefs()) { // Default Message $mes->add(TPVLAN_40." '".$themeArray[$this->id]."'", E_MESSAGE_SUCCESS); $this->theme_adminlog('02', $pref['admintheme'].', '.$pref['admincss']); }*/ // $ns->tablerender("Admin Message", "
".TPVLAN_40." '".$themeArray[$this -> id]."'.

"); // $this->showThemes('admin'); } public function OnlineObserver() { unset($this->fields['checkboxes']); $this->perPage = 500; } public function ChooseAjaxObserver() { $this->ChooseObserver(); } public function MainPage() { if(empty($_POST) && deftrue('e_DEVELOPER') || deftrue('e_DEBUG')) // check for new theme media and import. { $name = e107::getPref('sitetheme'); e107::getMedia()->import('_common_image', e_THEME.$name, '', 'min-size=10000'); e107::getMessage()->addInfo('Developer/Debug Mode: Scanning theme images folder for new media to import.'); } $message = e107::getMessage()->render(); return $message.$this->renderThemeConfig('front'); } public function AdminPage() { return $this->renderThemeConfig('admin'); } private function search($name, $searchVal, $submitName, $filterName='', $filterArray=false, $filterVal=false) { $frm = e107::getForm(); return $frm->search($name, $searchVal, $submitName, $filterName, $filterArray, $filterVal); } /* public function OnlinePageOld() { global $e107SiteUsername, $e107SiteUserpass; $xml = e107::getXml(); $mes = e107::getMessage(); $frm = e107::getForm(); require_once(e_HANDLER.'e_marketplace.php'); $mp = new e_marketplace(); // autodetect the best method $from = intval(varset($_GET['frm'])); $limit = 96; // FIXME - ajax pages load $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch'])); // check for cURL if(!function_exists('curl_init')) { $mes->addWarning(TPVLAN_79); } // 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']; $amount =$limit; $c = 1;*/ /* $text = "