function processRequest() { $this->assign('__action', 'livesearch'); $this->assign('searchText', $this->searchtext); $searchin = $this->expand ? array($this->expandTable) : $this->getGlobalOption('searchInTables', 'frontendhome'); if (!is_array($searchin) || count($searchin) == 0) { return array('message' => __('No search domain')); } $out = array(); foreach ($searchin as $table) { $obj = M_Office_Util::doForTable($table); if (method_exists($obj, 'livesearch')) { $obj->livesearch($this->searchtext); $out[$table] = $obj; } } foreach ($out as $table => $obj) { $cnt = 0; foreach ($obj as $rec) { $result = $rec->liveSearchText(); if (!is_array($result)) { $result = array('text' => $result); } $ret[$table][] = array_merge($result, array('url' => M_Office_Util::doURL($rec, $table, array(), array('livesearch', 'format')))); $cnt++; if ($cnt > 10) { break; } } if ($cnt == 0) { $ret[$table] = array(); } } $this->assign('output', $this->format($ret, $_GET['format'])); }
/** * Returns a DB_DataObjects collection, containing the tuples on which to apply the action * @param bool (default true) wether to query or just prepare the query (giving the possibility to add further clause) */ public function getSelected($doQuery = true) { if ($this->type == 'single') { return $this->do; } if (!$this->_selected || !$doQuery) { switch ($this->scope) { case 'all': $selected = clone $this->do; $selected->selectAdd(); $selected->selectAdd($this->do->tableName() . '.*'); break; case 'selected': $db = $this->do->getDatabaseConnection(); $ids = $this->getSelectedIds(); array_walk($ids, array('M_Office_Util', 'arrayquote'), $db); $selected = M_Office_Util::doForTable($this->do->tableName()); $selected->whereAdd($db->quoteIdentifier($this->do->pkName()) . ' IN (' . implode(',', $ids) . ')'); break; } if ($doQuery && !$selected->N) { $selected->find(); } } if ($doQuery) { $this->_selected = $selected; } else { return $selected; } return $this->_selected; }
function &getObject($recordId = null) { $do = M_Office_Util::doForTable($this->table); $do->{$this->field} = $this->value; if (!is_null($recordId)) { $do->get($recordId); } return $do; }