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

Last change on this file since 7450 was 7450, checked in by grum, 13 years ago

implement feature:1970

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