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() { if(e_AJAX_REQUEST) { $newRoutes = $this->getAllRoutes(); echo json_encode($newRoutes); exit; } } 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; } /** * @return array */ private function getAllRoutes(): array { $legacy = array( 'gallery/index/category', 'gallery/index/list', 'news/list/items', 'news/list/category', 'news/list/all', 'news/list/short', 'news/list/day', 'news/list/month', 'news/list/tag', 'news/list/author', 'news/view/item', 'page/chapter/index', 'page/book/index', 'page/view/index', 'page/view/other', 'page/list/index', 'search/index/index', 'system/error/notfound', 'user/myprofile/view', 'user/myprofile/edit', 'user/profile/list', 'user/profile/view', 'user/login/index', 'user/register/index' ); $newRoutes = e107::getUrlConfig('route'); foreach($legacy as $v) { $newRoutes[$v] = $v; } ksort($newRoutes); $ret = []; foreach($newRoutes as $k => $v) { $ret[] = array('value' => $k, 'label' => $k); } return $ret; } } 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'] = '