> ------------------------------------------------------------------------------ See main.inc.php for release information GMaps_AIP : classe to manage plugin admin pages --------------------------------------------------------------------------- */ include_once('gmaps_root.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); class GMaps_AIP extends GMaps_root { protected $tabsheet; protected $amdState; public function __construct($prefixeTable, $filelocation) { parent::__construct($prefixeTable, $filelocation); $this->loadConfig(); $this->configForTemplate(); $this->amdState=GMaps_root::checkAMDActivated(); $this->initRequest(); $this->initEvents(); $this->tabsheet = new tabsheet(); if($this->amdState!='advanced') { $this->tabsheet->add('amd_warning', l10n('gmaps_warning'), $this->getAdminLink()."&fGMaps_tabsheet=amd_warning"); } $this->tabsheet->add('maps', l10n('gmaps_maps'), $this->getAdminLink()."&fGMaps_tabsheet=maps"); $this->tabsheet->add('category_maps', l10n('gmaps_associate_category_maps'), $this->getAdminLink()."&fGMaps_tabsheet=category_maps"); /* $this->tabsheet->add('kml_files', l10n('gmaps_kml_files_management'), $this->getAdminLink()."&fGMaps_tabsheet=kml_files"); $this->tabsheet->add('search', l10n('gmaps_search'), $this->getAdminLink()."&fGMaps_tabsheet=search"); $this->tabsheet->add('help', l10n('gmaps_help'), $this->getAdminLink()."&fGMaps_tabsheet=help"); */ } public function __destruct() { unset($this->tabsheet); parent::__destruct(); } /** * initialize events call for the plugin */ public function initEvents() { add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); GPCCss::applyGpcCss(); parent::initEvents(); } /** * display the administration page */ public function manage() { global $template; $this->initRequest(); $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/gmaps_admin.tpl"); switch($_REQUEST['fGMaps_tabsheet']) { case 'amd_warning': $this->displayAmdWarning(); break; case 'maps': $this->displayMaps(); break; case 'category_maps': $this->displayCategoryMaps(); break; case 'kml_files': $this->displayKmlFiles(); break; case 'search': $this->displaySearch(); break; case 'help': $this->displayHelp(); break; } $this->tabsheet->select($_REQUEST['fGMaps_tabsheet']); $this->tabsheet->assign(); $selected_tab=$this->tabsheet->get_selected(); $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); $template_plugin["GMAPS_VERSION"] = "".$this->getPluginName()." ".l10n('gmaps_release').GMAPS_VERSION; $template_plugin["GMAPS_PAGE"] = $_REQUEST['fGMaps_tabsheet']; $template_plugin["GMAPS_TITLE"] = ""; $template->assign('plugin', $template_plugin); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); } /** * if empty, initialize the $_REQUEST var * * if not empty, check validity for the request values * */ private function initRequest() { //initialise $REQUEST values if not defined if(!isset($_REQUEST['fGMaps_tabsheet'])) { $_REQUEST['fGMaps_tabsheet']="maps"; } if(!($_REQUEST['fGMaps_tabsheet']!="maps" or $_REQUEST['fGMaps_tabsheet']!="category_maps" or $_REQUEST['fGMaps_tabsheet']!="amd_warning" //$_REQUEST['fGMaps_tabsheet']!="kml_files" or //$_REQUEST['fGMaps_tabsheet']!="search" or //$_REQUEST['fGMaps_tabsheet']!="help" )) $_REQUEST['fGMaps_tabsheet']="maps"; if($_REQUEST['fGMaps_tabsheet']=="amd_warning" and $this->amdState=='advanced') $_REQUEST['fGMaps_tabsheet']="maps"; } /** * display de maps page * */ protected function displayMaps() { global $template; $template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/gmaps_maps.tpl'); $mapTabsheet = new GPCTabSheet('mapTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2'); $mapTabsheet->add('general', l10n('gmaps_properties_general'), '', true, "udm.displayTab('general');"); $mapTabsheet->add('dimensions', l10n('gmaps_dimensions'), '', false, "udm.displayTab('dimensions');"); $mapTabsheet->add('mapType', l10n('gmaps_properties_mapType'), '', false, "udm.displayTab('mapType');"); $mapTabsheet->add('zoomLevel', l10n('gmaps_properties_zoomLevel'), '', false, "udm.displayTab('zoomLevel');"); $mapTabsheet->assign(); $datas=Array( 'urlRequest' => $this->getAdminLink('ajax') ); $template->assign('datas', $datas); $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page'); } /** * display the category_maps page * */ protected function displayCategoryMaps() { global $template; $template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/gmaps_category_maps.tpl'); $mapTabsheet = new GPCTabSheet('mapTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2'); $mapTabsheet->add('assoc', l10n('gmaps_map_assoc'), '', false, "am.displayTab('assoc');"); $mapTabsheet->add('integration', l10n('gmaps_map_integration'), '', true, "am.displayTab('integration');"); $mapTabsheet->assign(); $datas=Array( 'urlRequest' => $this->getAdminLink('ajax'), 'cats' => $this->makeCategoriesTree(), 'maps' => $this->makeMapsList(), 'icons' => $this->makeIconsList(), ); $template->assign('datas', $datas); $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page'); } /** * display the kml file management page * */ protected function displayKmlFiles() { global $template; /*$template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl'); $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/ } /** * display the search page * */ protected function displaySearch() { global $template; /*$template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl'); $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/ } /** * display the help page * */ protected function displayHelp() { global $template; /*$template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl'); $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/ } /** * display a warning page if AMD is not installed * */ protected function displayAmdWarning() { global $template; $template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/gmaps_amd_warning.tpl'); switch(GMaps_root::checkAMDActivated()) { case 'none': case 'inactive': $template->assign('gmaps_amd_warning_inactive', sprintf(l10n('gmaps_amd_warning_inactive'), GMAPS_AMD_NEEDED)); break; case 'basic': $template->assign('gmaps_amd_warning_basic', l10n('gmaps_amd_warning_basic')); break; } $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page'); } /** * build the categories tree * @return Array : an array, ready to use in the template */ private function makeCategoriesTree() { $returned=array( array( 'id' => 0, 'name' => '-- '.l10n('gmaps_applyForAllTheGallery').' --' ) ); $sql="SELECT id, name, global_rank FROM ".CATEGORIES_TABLE." ORDER BY global_rank"; $result = pwg_query($sql); if($result) { while ($row = pwg_db_fetch_assoc($result)) { $returned[]=array( 'id' => $row['id'], 'name' => str_repeat('  ', substr_count($row['global_rank'], '.')).$row['name'] ); } } return($returned); } //makeCategoriesTree /** * build a maps list * @return Array : an array, ready to use in the template */ private function makeMapsList() { $returned=array( 'IC' => array(), 'IP' => array(), 'MP' => array() ); $sql="SELECT id, name, displayType FROM ".$this->tables['maps']." ORDER BY displayType, name"; $result = pwg_query($sql); if($result) { while($row = pwg_db_fetch_assoc($result)) { $returned[$row['displayType']][]=array( 'id' => $row['id'], 'name' => $row['name'] ); } } return($returned); } //makeCategoriesTree /** * build THE ICON LIST * @return Array : an array, ready to use in the template */ private function makeIconsList() { $returned=array(); $directory=scandir(GMAPS_PATH.'img/'); foreach($directory as $file) { $ext=(pathinfo($file, PATHINFO_EXTENSION)); if(preg_match('/^i.*(?:jpg|jpeg|png|gif)$/i', $file)) { $returned[]=array( 'type' => (strtolower(substr($file,0,1))=='i')?'img':'other', 'file' => $file ); } } return($returned); } //makeCategoriesTree } //class ?>