source: extensions/ASearchEngine/ase_root.class.inc.php @ 7318

Last change on this file since 7318 was 7318, checked in by grum, 14 years ago

fix some bugs and implement public interface

  • Property svn:executable set to *
File size: 5.5 KB
Line 
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_root : common classe for admin and public classes
13
14  --------------------------------------------------------------------------- */
15  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
16  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
17
18  class ASE_root extends CommonPlugin
19  {
20    protected $css;
21
22    public function __construct($prefixeTable, $filelocation)
23    {
24      $this->setPluginName('Advanced Search Engine');
25      $this->setPluginNameFiles("ase");
26      parent::__construct($prefixeTable, $filelocation);
27      $this->section_name=$this->getPluginNameFiles();
28
29      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
30    }
31
32    public function __destruct()
33    {
34      parent::__destruct();
35    }
36
37    public function initEvents()
38    {
39    }
40
41
42    /*
43      surchage of CommonPlugin->saveConfig function
44    */
45    public function saveConfig()
46    {
47      if(parent::saveConfig())
48      {
49        return(true);
50      }
51      return(false);
52    }
53
54    /*
55      surchage of CommonPlugin->saveConfig function
56    */
57    public function loadConfig()
58    {
59      parent::loadConfig();
60    }
61
62    /*
63      initialize default values
64    */
65    public function initConfig()
66    {
67      //global $user;
68      $this->config=array(
69        'ase_keyword_minLength' => 3,
70        'ase_publicAccess_active' => false,
71        'ase_publicAccess_applyLimits' => true,
72        'ase_publicAccess_limits' => 1000,
73        'ase_publicAccess_allowedPlugins' => array()
74      );
75    }
76
77
78    /**
79     *
80     */
81    protected function configForTemplate()
82    {
83      global $template;
84
85      $template->assign('aseConfig', $this->config);
86    }
87
88
89    public function getAdminLink($mode='')
90    {
91      if($mode=='ajax')
92      {
93        return('plugins/'.basename(dirname($this->getFileLocation())).'/ase_ajax.php');
94      }
95      else
96      {
97        return(parent::getAdminLink());
98      }
99    }
100
101    protected function displayResult($action_msg, $result)
102    {
103      global $page;
104
105      if($result)
106      {
107        array_push($page['infos'], $action_msg);
108      }
109      else
110      {
111        array_push($page['errors'], $action_msg);
112      }
113    }
114
115
116    /* ---------------------------------------------------------------------------
117
118    --------------------------------------------------------------------------- */
119
120
121
122  } //class
123
124
125
126class ASE_functions
127  {
128    static private $tables = Array();
129    static private $config = Array();
130
131    /**
132     * initialise the class
133     *
134     * @param String $prefixeTable : the piwigo prefixe used on tables name
135     * @param String $pluginNameFile : the plugin name used for tables name
136     */
137    static public function init($prefixeTable)
138    {
139      // no tables for this plugin
140    }
141
142
143    /**
144     *  return all HTML&JS code necessary to display a dialogbox to choose
145     *  tags
146     */
147    static public function dialogBoxASETags()
148    {
149      global $template;
150
151      $template->set_filename('ase_tag_choose',
152                    dirname(__FILE__).'/templates/ase_dialog_tag_choose.tpl');
153
154      return($template->parse('ase_tag_choose', true));
155    }
156
157
158    /**
159     *  return all HTML&JS code necessary to display a dialogbox to choose
160     *  categories
161     */
162    static public function dialogBoxASECategory()
163    {
164      global $template;
165
166      $template->set_filename('ase_category_choose',
167                    dirname(__FILE__).'/templates/ase_dialog_category_choose.tpl');
168
169      return($template->parse('ase_category_choose', true));
170    }
171
172    /**
173     *  return all HTML&JS code necessary to display a dialogbox to choose
174     *  dates
175     */
176    static public function dialogBoxASEDate()
177    {
178      global $template;
179
180      $template->set_filename('ase_date_choose',
181                    dirname(__FILE__).'/templates/ase_dialog_date_choose.tpl');
182
183      return($template->parse('ase_date_choose', true));
184    }
185
186    /**
187     *  return all HTML&JS code necessary to display a dialogbox to choose
188     *  keywords
189     */
190    static public function dialogBoxASEKeyword()
191    {
192      global $template;
193
194      $template->set_filename('ase_keyword_choose',
195                    dirname(__FILE__).'/templates/ase_dialog_keyword_choose.tpl');
196
197      $config=array();
198      GPCCore::loadConfig('ase', $config);
199      $template->assign('aseConfig', $config);
200
201      return($template->parse('ase_keyword_choose', true));
202    }
203
204    /**
205     *  return all HTML&JS code necessary to display a dialogbox to choose
206     *  HD picture
207     */
208    static public function dialogBoxASEHD()
209    {
210      global $template;
211
212      $template->set_filename('ase_hd_choose',
213                    dirname(__FILE__).'/templates/ase_dialog_hd_choose.tpl');
214
215      return($template->parse('ase_hd_choose', true));
216    }
217
218    /**
219     *  return all HTML&JS code necessary to display a dialogbox to choose
220     *  rate on picture
221     */
222    static public function dialogBoxASERate()
223    {
224      global $template;
225
226      $template->set_filename('ase_rate_choose',
227                    dirname(__FILE__).'/templates/ase_dialog_rate_choose.tpl');
228
229      return($template->parse('ase_rate_choose', true));
230    }
231
232  } //ASE_functions
233
234
235
236?>
Note: See TracBrowser for help on using the repository browser.