1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : Advanced Search Engine |
---|
4 | Author : Grum |
---|
5 | email : grum@piwigo.org |
---|
6 | website : http://photos.grum.fr |
---|
7 | |
---|
8 | << May the Little SpaceFrog be with you ! >> |
---|
9 | ------------------------------------------------------------------------------ |
---|
10 | See main.inc.php for release information |
---|
11 | |
---|
12 | ASE_AIP : classe to manage plugin admin pages |
---|
13 | |
---|
14 | --------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | include_once('ase_root.class.inc.php'); |
---|
17 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); |
---|
19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); |
---|
20 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
21 | |
---|
22 | class ASE_AIP extends ASE_root |
---|
23 | { |
---|
24 | protected $tabsheet; |
---|
25 | |
---|
26 | public function __construct($prefixeTable, $filelocation) |
---|
27 | { |
---|
28 | parent::__construct($prefixeTable, $filelocation); |
---|
29 | |
---|
30 | $this->loadConfig(); |
---|
31 | $this->configForTemplate(); |
---|
32 | |
---|
33 | $this->initRequest(); |
---|
34 | $this->initEvents(); |
---|
35 | |
---|
36 | $this->tabsheet = new tabsheet(); |
---|
37 | |
---|
38 | $this->tabsheet->add('search', |
---|
39 | l10n('ase_search'), |
---|
40 | $this->getAdminLink()."&fASE_tabsheet=search"); |
---|
41 | $this->tabsheet->add('config', |
---|
42 | l10n('ase_config'), |
---|
43 | $this->getAdminLink()."&fASE_tabsheet=config"); |
---|
44 | } |
---|
45 | |
---|
46 | public function __destruct() |
---|
47 | { |
---|
48 | unset($this->tabsheet); |
---|
49 | parent::__destruct(); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * initialize events call for the plugin |
---|
54 | */ |
---|
55 | public function initEvents() |
---|
56 | { |
---|
57 | parent::initEvents(); |
---|
58 | |
---|
59 | if($_REQUEST['fASE_tabsheet']=='search') |
---|
60 | { |
---|
61 | // load request builder JS only on the search page |
---|
62 | GPCRequestBuilder::loadJSandCSS(); |
---|
63 | } |
---|
64 | add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); |
---|
65 | GPCCss::applyGpcCss(); |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | * display the administration page |
---|
70 | */ |
---|
71 | public function manage() |
---|
72 | { |
---|
73 | global $template; |
---|
74 | |
---|
75 | $this->initRequest(); |
---|
76 | |
---|
77 | $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/ase_admin.tpl"); |
---|
78 | |
---|
79 | switch($_REQUEST['fASE_tabsheet']) |
---|
80 | { |
---|
81 | case 'search': |
---|
82 | $this->displaySearch(); |
---|
83 | break; |
---|
84 | case 'config': |
---|
85 | $this->displayConfig(); |
---|
86 | break; |
---|
87 | } |
---|
88 | |
---|
89 | $this->tabsheet->select($_REQUEST['fASE_tabsheet']); |
---|
90 | $this->tabsheet->assign(); |
---|
91 | $selected_tab=$this->tabsheet->get_selected(); |
---|
92 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
93 | |
---|
94 | $template_plugin["ASE_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('ase_release').ASE_VERSION; |
---|
95 | $template_plugin["ASE_PAGE"] = $_REQUEST['fASE_tabsheet']; |
---|
96 | $template_plugin["ASE_TITLE"] = ""; |
---|
97 | |
---|
98 | $template->assign('plugin', $template_plugin); |
---|
99 | |
---|
100 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
101 | |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | /** |
---|
108 | * if empty, initialize the $_REQUEST var |
---|
109 | * |
---|
110 | * if not empty, check validity for the request values |
---|
111 | * |
---|
112 | */ |
---|
113 | private function initRequest() |
---|
114 | { |
---|
115 | //initialise $REQUEST values if not defined |
---|
116 | |
---|
117 | if(!isset($_REQUEST['errcode'])) $_REQUEST['errcode']=''; |
---|
118 | |
---|
119 | if(!isset($_REQUEST['fASE_tabsheet'])) |
---|
120 | { |
---|
121 | $_REQUEST['fASE_tabsheet']="search"; |
---|
122 | } |
---|
123 | |
---|
124 | if(!($_REQUEST['fASE_tabsheet']!="search" or |
---|
125 | $_REQUEST['fASE_tabsheet']!="config" |
---|
126 | )) $_REQUEST['fASE_tabsheet']="search"; |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | /** |
---|
132 | * display the search page |
---|
133 | * |
---|
134 | */ |
---|
135 | protected function displaySearch() |
---|
136 | { |
---|
137 | global $template; |
---|
138 | |
---|
139 | GPCCore::addHeaderCSS('categorySelector', 'plugins/GrumPluginClasses/css/categorySelector_'.$template->get_themeconf('name').'.css'); |
---|
140 | |
---|
141 | |
---|
142 | $template->set_filename('body_page', |
---|
143 | dirname($this->getFileLocation()).'/admin/ase_search.tpl'); |
---|
144 | |
---|
145 | $template->assign('ase_search_page', GPCRequestBuilder::displaySearchPage()); |
---|
146 | |
---|
147 | $template->assign_var_from_handle('ASE_BODY_PAGE', 'body_page'); |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | /** |
---|
152 | * display the config page |
---|
153 | * |
---|
154 | */ |
---|
155 | protected function displayConfig() |
---|
156 | { |
---|
157 | global $template; |
---|
158 | |
---|
159 | /*$template->set_filename('body_page', |
---|
160 | dirname($this->getFileLocation()).'/admin/ase_config.tpl'); |
---|
161 | |
---|
162 | |
---|
163 | $template->assign_var_from_handle('ASE_BODY_PAGE', 'body_page');*/ |
---|
164 | } |
---|
165 | |
---|
166 | |
---|
167 | } //class |
---|
168 | |
---|
169 | |
---|
170 | ?> |
---|