source: extensions/ASearchEngine/ase_pip.class.inc.php @ 7404

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

Fix load language bug + update en_UK lang file

  • Property svn:executable set to *
File size: 4.6 KB
RevLine 
[7196]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_PIP : classe to manage plugin public pages
13
14  --------------------------------------------------------------------------- */
15
16include_once('ase_root.class.inc.php');
[7318]17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
[7196]19
[7318]20
[7196]21class ASE_PIP extends ASE_root
22{
[7318]23  const SEARCH_SECTION = 'Search';
24  protected $sectionPage;
[7196]25  protected $css2;
26
27  public function __construct($prefixeTable, $filelocation)
28  {
29    parent::__construct($prefixeTable, $filelocation);
30    $this->css2 = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."2.css");
31    $this->loadConfig();
32    $this->initEvents();
33    $this->load_lang();
[7318]34
35    $this->sectionPage=new GPCPublicIntegration(self::SEARCH_SECTION);
36    $this->sectionPage->setCallbackPageFunction(array(&$this, 'managePage'));
37    $this->sectionPage->initEvents();
[7196]38  }
39
40  public function __destruct()
41  {
[7318]42    unset($section_page);
43
[7196]44    parent::__destruct();
45  }
46
47  /*
48    load language file
49  */
50  public function load_lang()
51  {
[7404]52    global $template;
[7196]53
54    load_language('plugin.lang', ASE_PATH);
[7404]55    load_language('rbuilder.lang', GPC_PATH);
[7196]56  }
57
58  /*
59    initialize events call for the plugin
60  */
61  public function initEvents()
62  {
63    parent::initEvents();
64
[7318]65    GPCRequestBuilder::loadJSandCSS();
66
67    add_event_handler('init', array(&$this, 'applyJS'));
68    add_event_handler('loc_begin_page_header', array(&$this->css2, 'applyCSS'), 9); // have to be loaded before other css file (event level from GPCCore=10)
69    add_event_handler('blockmanager_apply', array(&$this, 'blockmanagerApply'), 55);
[7404]70    add_event_handler('user_init', array(&$this, 'load_lang'));
[7196]71  }
72
73
74
75  /* -------------------------------------------------------------------------
76    FUNCTIONS TO MANAGE ASE
77  ------------------------------------------------------------------------- */
78
[7318]79  public function applyJS()
80  {
81    global $template;
[7196]82
[7318]83    GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.packed.js');
[7196]84
[7318]85    $theme=$template->get_themeconf('name');
[7196]86
[7318]87    $file='plugins/ASearchEngine/themes/'.$theme.'/ASE'.$theme.'.css';
88    if(($theme=='Sylvia' or
89        $theme=='clear' or
90        $theme=='dark') and
91        file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE0', $file);
[7196]92
[7318]93    $file='themes/'.$theme.'/css/ASE'.$theme.'.css';
94    if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE1', $file);
95
96    $file='local/css/ASE'.$theme.'.css';
97    if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE2', $file);
98  }
99
100  public function managePage()
101  {
102    global $page, $conf, $template;
103
104    /*
105     * make the title bar
106     */
107    $page['title'].=$conf['level_separator'].l10n('ase_search_with_multiple_criteria');
108    $template->assign('TITLE', $page['title']);
109
[7328]110    if($template->get_themeconf('parent')=='gally-default')
111    {
112      $template->assign('PLUGIN_INDEX_ACTIONS' ,
113      '<li><a rel="nofollow" title="'.l10n('return to homepage').'" href="'.make_index_url().'" class="button" id="icon_home"></a></li>');
114    }
115    else
116    {
117      $template->assign('PLUGIN_INDEX_ACTIONS' ,
118      '<li><a href="'.make_index_url().'" title="'.l10n('return to homepage').'"><img src="'.$template->get_themeconf('icon_dir').'/home.png" class="button" alt="'.l10n('home').'"/></a></li>');
119    }
120
121
[7318]122    $template->clear_assign(array('U_MODE_CREATED', 'U_MODE_POSTED'));
123
124    /*
125     * display empty template
126     * (all content are managed with ajax)
127     */
128
129    $template->set_filename('main', dirname(__FILE__)."/templates/search_page.tpl");
130
131    $template->assign('ase_search_page', GPCRequestBuilder::displaySearchPage($this->config['ase_publicAccess_allowedPlugins']));
132
133    $template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEGIN', 'main');
134  }
135
136
137  /**
138   * replace the piwigo search.php url by ?/aSearch url
139   */
140  public function blockmanagerApply($menu_ref_arr)
141  {
142    global $user, $page;
143    $menu = & $menu_ref_arr[0];
144
145    if($this->config['ase_publicAccess_active'])
146    {
147      $block=$menu->get_block('mbMenu');
148      $block->data['search']['URL']=get_root_url().'?/'.self::SEARCH_SECTION;
149    }
150  }
151
152
153
154
[7196]155} //class
156
157?>
Note: See TracBrowser for help on using the repository browser.