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

Last change on this file since 16448 was 16008, checked in by grum, 12 years ago

feature:2635- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 4.8 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{
[15360]23  const SEARCH_SECTION = 'ASearch';
[7318]24  protected $sectionPage;
[7196]25
26  public function __construct($prefixeTable, $filelocation)
27  {
[16008]28    global $template;
29
[7196]30    parent::__construct($prefixeTable, $filelocation);
31    $this->loadConfig();
[7450]32
[7196]33    $this->load_lang();
[7318]34
[7439]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();
[7450]40      $this->initEvents();
[7439]41    }
[7196]42  }
43
44  public function __destruct()
45  {
[7318]46    unset($section_page);
47
[7196]48    parent::__destruct();
49  }
50
51  /*
52    load language file
53  */
54  public function load_lang()
55  {
56    load_language('plugin.lang', ASE_PATH);
[7404]57    load_language('rbuilder.lang', GPC_PATH);
[7196]58  }
59
60  /*
61    initialize events call for the plugin
62  */
63  public function initEvents()
64  {
65    parent::initEvents();
66
[10886]67    add_event_handler('blockmanager_apply', array(&$this, 'blockManagerApply'), 40); // call ASE before AMM
68
[7450]69    if($this->sectionPage->pageIsSection())
70    {
71      GPCRequestBuilder::loadJSandCSS();
[7318]72
[7450]73      add_event_handler('init', array(&$this, 'applyJS'));
74      add_event_handler('user_init', array(&$this, 'load_lang'));
75    }
[7196]76  }
77
[16008]78  public function loadCSS()
79  {
80    GPCCore::addHeaderCSS('ase.css2', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles()."2.css",9);  // have to be loaded before other css file (event level from GPCCore=10)
81  }
[7196]82
83  /* -------------------------------------------------------------------------
84    FUNCTIONS TO MANAGE ASE
85  ------------------------------------------------------------------------- */
86
[7318]87  public function applyJS()
88  {
89    global $template;
[7196]90
[7318]91    $theme=$template->get_themeconf('name');
[7196]92
[15360]93    // css file for piwigo's default themes (provided by ASE)
[7318]94    $file='plugins/ASearchEngine/themes/'.$theme.'/ASE'.$theme.'.css';
95    if(($theme=='Sylvia' or
96        $theme=='clear' or
[15360]97        $theme=='dark' or
98        $theme=='elegant') and
99        file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE0', $file, 35);
[7196]100
[15360]101    // css file for ASE provided by themes
[7318]102    $file='themes/'.$theme.'/css/ASE'.$theme.'.css';
[15360]103    if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE1', $file, 40);
[7318]104
[15360]105    // css file for ASE provided in local directory
[10886]106    $file=PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'local/css/ASE'.$theme.'.css';
[15360]107    if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE2', $file, 45);
[16008]108
109/*
110    $template->set_filename('ASEheader', dirname(__FILE__)."/templates/search_page_header.tpl");
111    $template->block_html_head(null, $template->parse('ASEheader', true), null, null);
112    */
[7318]113  }
114
115  public function managePage()
116  {
117    global $page, $conf, $template;
118
119    /*
120     * make the title bar
121     */
122    $page['title'].=$conf['level_separator'].l10n('ase_search_with_multiple_criteria');
123    $template->assign('TITLE', $page['title']);
124
[16008]125    GPCCore::AddUI('inputTag,categorySelector');
126
[7318]127    $template->clear_assign(array('U_MODE_CREATED', 'U_MODE_POSTED'));
128
129    /*
130     * display empty template
131     * (all content are managed with ajax)
132     */
133
[16008]134    $template->assign(
135      array(
136        'derivative_params' =>trigger_event('get_index_derivative_params', ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ) )
137      )
138    );
139
[15360]140    $template->set_filename('ASEmain', dirname(__FILE__)."/templates/search_page.tpl");
[7318]141
142    $template->assign('ase_search_page', GPCRequestBuilder::displaySearchPage($this->config['ase_publicAccess_allowedPlugins']));
143
[15360]144    $template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEGIN', 'ASEmain');
[7318]145  }
146
147
148  /**
[15360]149   * replace the piwigo search.php url by ?/ASearch url
[7318]150   */
[10886]151  public function blockManagerApply($menu_ref_arr)
[7318]152  {
153    global $user, $page;
154    $menu = & $menu_ref_arr[0];
155
156    if($this->config['ase_publicAccess_active'])
157    {
158      $block=$menu->get_block('mbMenu');
[15360]159      if(!is_null($block)) $block->data['search']['URL']='./?/'.self::SEARCH_SECTION;
[7318]160    }
161  }
162
163
164
165
[7196]166} //class
167
168?>
Note: See TracBrowser for help on using the repository browser.