Ejemplo n.º 1
0
 public function index2Action()
 {
     $searchApi = Engine_Api::_()->getApi('search', 'ynadvsearch');
     $params = $this->_getAllParams();
     // check public settings
     $require_check = Engine_Api::_()->getApi('settings', 'core')->core_general_search;
     if (!$require_check) {
         if (!$this->_helper->requireUser()->isValid()) {
             return;
         }
     }
     $searchModulesTable = new Ynadvsearch_Model_DbTable_Modules();
     $modulesObject = $searchModulesTable->getEnabledModules();
     $modules = $modulesObject->toArray();
     $types = array();
     $page = (int) $this->_getParam('page', 1);
     if (isset($params['submit'])) {
         $mods = $params['moduleynsearch'];
         foreach ($mods as $value => $key) {
             foreach ($modules as $module) {
                 if ($module['name'] == $value) {
                     $module['checked'] = $key;
                     $results[] = $module;
                     break;
                 }
             }
             if ($key == 1) {
                 $types[] = $searchModulesTable->getTypes($value);
             }
         }
         $page = 1;
         $this->view->modules = $results;
     } else {
         if (@$this->_getParam('module_result')) {
             $this->view->modules = $this->_getParam('module_result');
         } else {
             $this->view->modules = $modules;
         }
     }
     $this->view->query = $query = (string) @$params['query'];
     $qty = $this->_getParam('qty');
     if (!is_numeric($qty) || $qty <= 0) {
         $qty = 10;
     }
     $this->view->qty = $qty;
     if (!$types) {
         $types = @$params['type'];
     }
     if (!$types && @$params['is_search']) {
         $this->view->checkAll = 1;
         $types = $searchModulesTable->getAllEnabledTypes($modulesObject);
     }
     $this->view->types = $types;
     if ($query) {
         $this->view->paginator = $paginator = $searchApi->getPaginator($query, $types);
         $this->view->paginator->setCurrentPageNumber($page);
         $this->view->page = $page;
         $paginator->setItemCountPerPage($qty);
     }
     if (@$params['checkall']) {
         $this->view->checkAll = 1;
     }
 }
Ejemplo n.º 2
0
// TO DO HERE
try {
    $coresearchApi = Engine_Api::_()->getApi('search', 'core');
    $searchModulesTable = new Ynadvsearch_Model_DbTable_Modules();
    $values = $_REQUEST;
    $types = array();
    $action = $values['action'];
    if ($action) {
        $type_arr = Engine_Api::_()->ynadvsearch()->getTypesOfAction($action);
        $types = array_merge($types, $type_arr);
    }
    $module_str = $values['modules'];
    if ($module_str) {
        $modules = explode(',', $module_str);
        foreach ($modules as $module) {
            $types = array_merge($types, $searchModulesTable->getTypes($module));
        }
    }
    $query = $values['search'];
    $trimquery = trim($query);
    $showquery = strip_tags($trimquery);
    $item_per_page = $values['maxre'];
    // get types from selected modules in back-end
    $enabled_types = $searchModulesTable->getAllEnabledTypes();
    if (count($types) > 0) {
    } else {
        foreach ($enabled_types as $module_types) {
            foreach ($module_types as $module_type) {
                $types[] = $module_type;
            }
        }