| 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 | |
|---|
| 16 | include_once('ase_root.class.inc.php'); |
|---|
| 17 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php'); |
|---|
| 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | class 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 | $this->initEvents(); |
|---|
| 33 | $this->load_lang(); |
|---|
| 34 | |
|---|
| 35 | $this->sectionPage=new GPCPublicIntegration(self::SEARCH_SECTION); |
|---|
| 36 | $this->sectionPage->setCallbackPageFunction(array(&$this, 'managePage')); |
|---|
| 37 | $this->sectionPage->initEvents(); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | public function __destruct() |
|---|
| 41 | { |
|---|
| 42 | unset($section_page); |
|---|
| 43 | |
|---|
| 44 | parent::__destruct(); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | /* |
|---|
| 48 | load language file |
|---|
| 49 | */ |
|---|
| 50 | public function load_lang() |
|---|
| 51 | { |
|---|
| 52 | global $lang; |
|---|
| 53 | |
|---|
| 54 | load_language('plugin.lang', ASE_PATH); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | /* |
|---|
| 58 | initialize events call for the plugin |
|---|
| 59 | */ |
|---|
| 60 | public function initEvents() |
|---|
| 61 | { |
|---|
| 62 | parent::initEvents(); |
|---|
| 63 | |
|---|
| 64 | GPCRequestBuilder::loadJSandCSS(); |
|---|
| 65 | |
|---|
| 66 | add_event_handler('init', array(&$this, 'applyJS')); |
|---|
| 67 | 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) |
|---|
| 68 | add_event_handler('blockmanager_apply', array(&$this, 'blockmanagerApply'), 55); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | /* ------------------------------------------------------------------------- |
|---|
| 74 | FUNCTIONS TO MANAGE ASE |
|---|
| 75 | ------------------------------------------------------------------------- */ |
|---|
| 76 | |
|---|
| 77 | public function applyJS() |
|---|
| 78 | { |
|---|
| 79 | global $template; |
|---|
| 80 | |
|---|
| 81 | GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.packed.js'); |
|---|
| 82 | |
|---|
| 83 | $theme=$template->get_themeconf('name'); |
|---|
| 84 | |
|---|
| 85 | $file='plugins/ASearchEngine/themes/'.$theme.'/ASE'.$theme.'.css'; |
|---|
| 86 | if(($theme=='Sylvia' or |
|---|
| 87 | $theme=='clear' or |
|---|
| 88 | $theme=='dark') and |
|---|
| 89 | file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE0', $file); |
|---|
| 90 | |
|---|
| 91 | $file='themes/'.$theme.'/css/ASE'.$theme.'.css'; |
|---|
| 92 | if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE1', $file); |
|---|
| 93 | |
|---|
| 94 | $file='local/css/ASE'.$theme.'.css'; |
|---|
| 95 | if(file_exists(GPCCore::getPiwigoSystemPath().'/'.$file)) GPCCore::addHeaderCSS('ASE2', $file); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | public function managePage() |
|---|
| 99 | { |
|---|
| 100 | global $page, $conf, $template; |
|---|
| 101 | |
|---|
| 102 | /* |
|---|
| 103 | * make the title bar |
|---|
| 104 | */ |
|---|
| 105 | $page['title'].=$conf['level_separator'].l10n('ase_search_with_multiple_criteria'); |
|---|
| 106 | $template->assign('TITLE', $page['title']); |
|---|
| 107 | |
|---|
| 108 | $template->clear_assign(array('U_MODE_CREATED', 'U_MODE_POSTED')); |
|---|
| 109 | |
|---|
| 110 | /* |
|---|
| 111 | * display empty template |
|---|
| 112 | * (all content are managed with ajax) |
|---|
| 113 | */ |
|---|
| 114 | |
|---|
| 115 | $template->set_filename('main', dirname(__FILE__)."/templates/search_page.tpl"); |
|---|
| 116 | |
|---|
| 117 | $template->assign('ase_search_page', GPCRequestBuilder::displaySearchPage($this->config['ase_publicAccess_allowedPlugins'])); |
|---|
| 118 | |
|---|
| 119 | $template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEGIN', 'main'); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | /** |
|---|
| 124 | * replace the piwigo search.php url by ?/aSearch url |
|---|
| 125 | */ |
|---|
| 126 | public function blockmanagerApply($menu_ref_arr) |
|---|
| 127 | { |
|---|
| 128 | global $user, $page; |
|---|
| 129 | $menu = & $menu_ref_arr[0]; |
|---|
| 130 | |
|---|
| 131 | if($this->config['ase_publicAccess_active']) |
|---|
| 132 | { |
|---|
| 133 | $block=$menu->get_block('mbMenu'); |
|---|
| 134 | $block->data['search']['URL']=get_root_url().'?/'.self::SEARCH_SECTION; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | } //class |
|---|
| 142 | |
|---|
| 143 | ?> |
|---|