1<?php 2/** 3 * Allow searching of address books from the portal. 4 * 5 * Copyright 2011-2017 Horde LLC (http://www.horde.org/) 6 * 7 * See the enclosed file LICENSE for license information (ASL). If you 8 * did not receive this file, see http://www.horde.org/licenses/apache. 9 */ 10class Turba_Block_Minisearch extends Horde_Core_Block 11{ 12 /** 13 * The available options for address book selection 14 * 15 * @var array 16 */ 17 protected $_options = array(); 18 19 /** 20 */ 21 public function __construct($app, $params = array()) 22 { 23 parent::__construct($app, $params); 24 foreach (Turba::getAddressBooks(Horde_Perms::READ) as $key => $addressbook) { 25 $this->_options[$key] = $addressbook['title']; 26 } 27 $this->_name = _("Contact Search"); 28 } 29 30 /** 31 */ 32 protected function _title() 33 { 34 return Horde::url($GLOBALS['registry']->getInitialPage(), true)->link() 35 . $this->getName() . '</a>'; 36 } 37 38 /** 39 */ 40 protected function _params() 41 { 42 return array( 43 'addressbooks' => array( 44 'type' => 'multienum', 45 'name' => _("Address Books"), 46 'values' => $this->_options 47 ) 48 ); 49 } 50 /** 51 */ 52 protected function _content() 53 { 54 global $page_output, $registry; 55 56 $abooks = empty($this->_params['addressbooks']) 57 ? array_keys($this->_options) 58 : $this->_params['addressbooks']; 59 60 $page_output->addInlineJsVars(array( 61 'TurbaMinisearch.abooks' => $abooks, 62 'TurbaMinisearch.URI_AJAX' => $registry->getServiceLink('ajax', 'turba')->url 63 )); 64 $page_output->addScriptFile('minisearch.js'); 65 66 Horde::startBuffer(); 67 include TURBA_TEMPLATES . '/block/minisearch.inc'; 68 return Horde::endBuffer(); 69 } 70 71} 72