Inheritance: extends MY_Controller
Example #1
5
 public static function search_query($keyword = '', $category = '')
 {
     if (isset($_GET)) {
         $keyword_clean = mysqli_real_escape_string(db_connect(), $keyword);
         $category_clean = mysqli_real_escape_string(db_connect(), $category);
         if ($category_clean === 'post') {
             $search_results = db_select("SELECT * FROM post WHERE title LIKE '%" . $keyword_clean . "%' OR body LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'category') {
             $search_results = db_select("SELECT * FROM category WHERE title LIKE '%" . $keyword_clean . "%' OR description LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'page') {
             $search_results = db_select("SELECT * FROM page WHERE title LIKE '%" . $keyword_clean . "%' OR body LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'upload') {
             $search_results = db_select("SELECT * FROM upload WHERE filename LIKE '%" . $keyword_clean . "%' OR filetype LIKE '%" . $keyword_clean . "%' OR filepath LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'user') {
             $search_results = db_select("SELECT * FROM user WHERE username LIKE '%" . $keyword_clean . "%'");
         } else {
             // ALL
             $search = new Search();
             $search_results = $search->searchAllDB($keyword_clean);
             //print_r($search_results);
         }
     } else {
         $search_results = '';
         $flash = new Flash();
         $flash->flash('flash_message', 'No keyword entered!', 'danger');
     }
     return $search_results;
 }
Example #2
0
 function index()
 {
     $q = trim(Input::get('q'));
     if (empty($q) || !Input::has('q')) {
         return Redirect::home();
     }
     if (!Input::has('guess') || Input::get('guess') != 'no') {
         $regex = array('pilot' => '[0-9]+', 'airport' => '[A-Z0-9]{4}', 'airline' => '[A-Z0-9]{3}', 'airportIata' => '[A-Z0-9]{3}', 'citypair' => '([A-Z0-9]{3,4})(?:(?:\\s*?[-|>]\\s*?)|\\s+to\\s+|\\s+)([A-Z0-9]{3,4})', 'callsign' => '.*');
         $search = new Search($q);
         foreach ($regex as $type => $pattern) {
             if (preg_match('/^' . $pattern . '$/i', $q, $matches) && ($match = $search->quick($type, $matches))) {
                 Messages::info('You were redirected here by a best guess of the search system. <a href="' . URL::route('search', array('q' => $q, 'guess' => 'no')) . '" class="alert-link">Return to search results.</a>');
                 return $match;
             }
         }
     }
     $pilots = Pilot::where(function ($search) use($q) {
         $search->where('vatsim_id', '=', $q);
         $search->orWhere(function ($name) use($q) {
             $name->where('name', 'LIKE', '%' . $q . '%');
             $name->where('anonymous', '=', false);
         });
     })->where('vatsim_id', '!=', 0)->get();
     $flights = Flight::where('callsign', '=', $q)->orderBy('departure_time', 'desc')->get();
     $airlines = Airline::where('icao', '=', $q)->orWhere('name', 'LIKE', '%' . $q . '%')->get();
     $airports = Airport::where('icao', '=', $q)->orWhere('iata', '=', $q)->orWhere('name', 'LIKE', '%' . $q . '%')->orWhere('city', 'LIKE', '%' . $q . '%')->get();
     $this->autoRender(compact('q', 'flights', 'pilots', 'airlines', 'airports'), 'Search');
 }
Example #3
0
 public function view()
 {
     $dao = DAO::getDAO('SearchDAO');
     if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
         // ex: requesting: /search/delete/2
         $id = trim(sanitizeString($this->params[1]));
         $dao->removeById($id);
     } else {
         if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
             $randNum = mt_rand(0, 99999);
             $newSearch = new Search(array('username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'created' => dbDateTime()));
             // #TODO: implement UserDao.create($newUser) instead.
             if ($dao->countAll() > 30) {
                 // Demo mode: clean up if too many searchs
                 $dao->execute("DELETE FROM searchs");
                 $dao->execute("vacuum");
             }
             $dao->insertInto("username, email, created", $newSearch->getFields());
         }
     }
     $search = $dao->getAll();
     $v = $this->smarty;
     $v->assign('title', 'Search List');
     $v->assign('inc_content', v('search.html'));
     $v->assign('search', $search);
     $v->assign('totalSearch', $dao->countAll());
     $this->display($v, v('index.html'));
 }
 public function testShouldGenerateSearchStringArray()
 {
     $params = array('CISOROOT' => 'all', 'CISOOP1' => 'any', 'CISOFIELD1' => 'creato', 'CISOBOX1' => 'michigan lake', 'CISOOP2' => 'all', 'CISOFIELD2' => 'title', 'CISOBOX2' => 'general grant', 'media-types' => array('image', 'audio', 'map', 'docs'), 'search-button.x' => '61', 'search-button.y' => '19', 'search-button' => '');
     $search = new Search();
     $search->set_search_string($params);
     $this->assertEquals('creato', $search->search_string[0]['field']);
 }
Example #5
0
 public function indexAction()
 {
     $key = $this->getRequest()->get('kw');
     $orderby = $this->getRequest()->get('od');
     $page = $this->getRequest()->get('page', 1);
     // $router = \Yaf\Dispatcher::getInstance()->getRouter();
     // $config = \Yaf\Application::app()->getConfig();
     $search = new Search();
     $search->setQ($key);
     $search->setPage($page);
     if (!empty($orderby)) {
         $search->setSortby($orderby);
     }
     $res = $search->query();
     $pages = 1;
     $films = null;
     if ($res) {
         $pages = empty($res['pages']) ? 1 : $res['pages'];
         if (isset($res['matches'])) {
             foreach ($res['matches'] as $match) {
                 $ids[] = $match['id'];
             }
             $conn = new MyPDO();
             $films = $conn->table('film')->select('*')->where('id in (' . implode(',', $ids) . ')')->orderBy('order by find_in_set (id, \'' . implode(',', $ids) . '\')')->execute();
         }
     }
     $this->_view->assign('films', $films);
     $this->_view->assign('kw', $key);
     $this->_view->assign('orderby', $orderby);
     $this->_view->assign('page', $page);
     $this->_view->assign('pages', $pages);
 }
Example #6
0
 private function show($q)
 {
     include 'lib/search.php';
     $search = new Search();
     $items = $search->do_search($q);
     foreach ($items as $item) {
         $item->content = process_content($item->content);
         foreach ($item->comments as $comment) {
             $comment->content = process_content($comment->content);
         }
         foreach ($item->likes as $like) {
             if (isset($_SESSION['user_id']) && $like->user_id == $_SESSION['user_id']) {
                 $item->i_like = true;
             } else {
                 $item->i_like = false;
             }
         }
     }
     if (isset($this->plugins->log)) {
         $result_count = count($items);
         $this->plugins->log->add($_SESSION['user_id'], 'search', NULL, 'new', "Term = {$q}\nResult_count = {$result_count}");
     }
     if ($this->json) {
         $this->render_json($items);
     } else {
         $this->loadView('search/index', array('items' => $items));
     }
 }
Example #7
0
 public function getBookSearchResults()
 {
     $search = new Search();
     $books = $search->searchBook($_POST['searchstring']);
     include 'view/libro/search_menu.php';
     include 'view/libro/libros.php';
 }
Example #8
0
 public function get_top_recommendations($query_name, $number)
 {
     $auth = Clarifai::get_auth($this->client_id, $this->client_secret);
     $matches = $this->get_initial_recommendations($query_name, $number);
     // Get initial recommended movies
     $number = count($matches);
     if ($number <= 0) {
         return NULL;
     }
     $query = new Search($query_name);
     $query_links = $query->get_links();
     // Get links to query stills using Google Images API
     $links = array();
     $links[$query_name] = $query_links;
     // Array containing links
     foreach ($matches as $match) {
         // Get stills to each of the initial recommended movies
         $match_search = new Search($match);
         $links[$match] = $match_search->get_links();
         // Add links to array
     }
     $tags_array = Clarifai::get_unique_tags($links, $auth);
     // Get tags using Clarifai API
     $results = array();
     foreach (array_slice($tags_array, 1, $number) as $key => $tags) {
         $results[$key] = count(array_intersect($tags, $tags_array[$query_name]));
     }
     arsort($results);
     return array_keys($results);
 }
Example #9
0
 public function testAnnotations()
 {
     $s = new Search('reddress');
     $s->setUid('b1cb66795dfb0ff41fff56c841c0dea8');
     $s->setTqid('D9XmaeqdjAxrkDPX');
     $this->assertEquals('q=reddress&tqid=D9XmaeqdjAxrkDPX&uid=b1cb66795dfb0ff41fff56c841c0dea8', $s->getUrlString());
 }
Example #10
0
 /**
  * getUserLabels Helper
  *
  * @param     array $data
  * @param     function $callback
  * @return    mixed
  */
 static function getUserLabels(array $data, $callback = false)
 {
     // validate data parameters
     if (!isset($data['website'])) {
         throw new \InvalidArgumentException('website is required.');
     }
     // validate data parameters
     if (!isset($data['search'])) {
         throw new \InvalidArgumentException('search is required.');
     }
     $woopra_labels = Woopra::getAllLabels($data);
     $search = new Search($data);
     $rsp = $search->search(array('website' => $data['website'], 'search' => $data['search']));
     $labels = array();
     foreach ($rsp->visitors as $visitor) {
         foreach ($visitor->labels as $label) {
             if (array_key_exists($label, $woopra_labels)) {
                 $labels[$label] = $woopra_labels[$label];
             }
         }
     }
     // run callback or return the label data
     if (is_callable($callback)) {
         $callback($labels);
     } else {
         return $labels;
     }
 }
Example #11
0
 public function searchPostAction($search)
 {
     $admin = new Search();
     $searchResult = $admin->setSearchItem($_GET['search'], 'posts');
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/header.php';
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/search.php';
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/footer.php';
 }
Example #12
0
 public function testFiter()
 {
     $s = new Search('');
     $s->addFilter((new Filter('tags', '=', 'Women'))->addOr('tags', '=', 'dress pants'));
     $r = $this->engine->search($s);
     $this->assertEquals($r->results->hits[0]->id, 'f346904e7dcd43c521bff2e6dcfae21a');
     $this->assertEquals($r->results->hits[1]->id, 'c05ef333b5dbd9f31123a65221762395');
 }
Example #13
0
 /**
  * Search with solr & prepare data for output
  *
  * @param $p options
  * @param $prepare bool
  */
 private function solrSearch($p, $prepare = false)
 {
     // skip grid params
     unset($p->grid);
     $p->fl = 'id, pid, path, name, template_type, system, ' . 'size, date, date_end, oid, cid, cdate, uid, udate, case_id, acl_count, ' . 'case, template_id, task_u_assignee, status, task_d_closed, versions, ' . 'case_violation_resolved, case_violation_unresolved, cfg, type, nid, ' . 'search_hash, case_hash';
     $s = new Search();
     return $s->query($p);
 }
 public function Search($param)
 {
     //echo "hello";
     import('SC.Search.Search');
     $searchInfo = new Search($param);
     $result = $searchInfo->run();
     echo $result;
 }
 public function before_render(&$template, &$content)
 {
     parent::before_render($template, $content);
     /*
      * Create the browser title.
      */
     if (strlen($content->get('browser_title')) === 0) {
         if (strlen($content->get('page_title')) > 0) {
             $content->set('browser_title', $content->get('page_title'));
             $content->append('browser_title', ' - ' . SITE_TITLE);
         } else {
             $content->set('browser_title', SITE_TITLE);
         }
     } else {
         $content->append('browser_title', '&#8202;-&#8202;' . SITE_TITLE);
     }
     /*
      * Include the place name (e.g., "Washington," "Texas," "United States").
      */
     $content->set('place_name', PLACE_NAME);
     /*
      * Get the edition data
      */
     $search = new Search();
     // Since we don't have any conditions in our template, we have to build
     // html here.
     if (!$content->is_set('current_edition') && defined('EDITION_ID')) {
         $content->set('current_edition', EDITION_ID);
     }
     $content->set('edition_select', $search->build_edition($content->get('current_edition')));
     /*
      * Set our search terms.
      */
     $query = '';
     if (isset($_GET['q'])) {
         $query = $_GET['q'];
     }
     $content->set('search_terms', $query);
     /*
      * If a Google Analytics Web Property ID has been provided, insert the tracking code.
      */
     if (defined('GOOGLE_ANALYTICS_ID')) {
         $content->prepend('javascript', "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\t\t\t\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\t\t\t\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\t\t\t\t})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n\t\t\t\tga('create', '" . GOOGLE_ANALYTICS_ID . "', 'auto');\n\t\t\t\tga('send', 'pageview');");
     }
     /*
      * If a Typekit ID has been provided, insert the JavaScript.
      */
     if (defined('TYPEKIT_ID')) {
         $this->add_asset('typekit_js', array('path' => '//use.typekit.net/' . TYPEKIT_ID . '.js', 'type' => 'javascript'));
         $content->append('javascript', 'try{Typekit.load();}catch(e){};');
     }
     $content->append('javascript', 'var zclip_swf_file = "' . THEME_WEB_PATH . 'static/js/vendor/ZeroClipboard.swf";');
     /*
      * Setup assets
      */
     $this->render_assets($template, $content);
 }
 public function testShouldCreateSearchTerms()
 {
     $search = new Search();
     $search->media_types = array('image', 'audio', 'video', 'docs');
     $search->generate_content_type_search_string();
     $this->assertEquals('format', $search->search_string[0]['field']);
     $this->assertEquals('image audio video Document ', $search->search_string[0]['string']);
     $this->assertEquals('all', $search->search_string[0]['mode']);
 }
Example #17
0
 public function testResultsShouldReturnListOfItems()
 {
     $search = new Search();
     $list = $search->results();
     $this->assertEquals(3, count($list));
     foreach ($list as $item) {
         $this->assertEquals('Item', get_class($item));
     }
 }
Example #18
0
 public function save($key_id)
 {
     $db = new PHPWS_DB('ps_text');
     $result = $db->saveObject($this);
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     $search = new Search($key_id);
     $search->addKeywords($this->content);
     return $search->save();
 }
Example #19
0
 function get()
 {
     $profile_uid = intval($_GET['p']);
     if (!$profile_uid) {
         $profile_uid = -1;
     }
     $load = argc() > 1 && argv(1) == 'load' ? 1 : 0;
     header("Content-type: text/html");
     echo "<!DOCTYPE html><html><body>\r\n";
     /**
      * We can remove this hack once Internet Explorer recognises HTML5 natively
      */
     echo $_GET['msie'] == 1 ? '<div>' : '<section>';
     /**
      *
      * Grab the page inner contents by calling the content function from the profile module directly, 
      * but move any image src attributes to another attribute name. This is because 
      * some browsers will prefetch all the images for the page even if we don't need them.
      * The only ones we need to fetch are those for new page additions, which we'll discover
      * on the client side and then swap the image back.
      *
      */
     $mod = new Search();
     $text = $mod->get($profile_uid, $load);
     $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
     $replace = "<img\${1} dst=\"\${2}\"";
     //	$text = preg_replace($pattern, $replace, $text);
     /*
     	if(! $load) {
     		$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
     		$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
     		$text = preg_replace($pattern, $replace, $text);
     		$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
     		$text = preg_replace($pattern, $replace, $text);
     		$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
     		$text = preg_replace($pattern, $replace, $text);
         	$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
         	$text = preg_replace($pattern, $replace, $text);
     	}
     */
     /**
      * reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
      */
     echo str_replace("\t", '       ', $text);
     echo $_GET['msie'] == 1 ? '</div>' : '</section>';
     echo "</body></html>\r\n";
     killme();
 }
Example #20
0
 private function on_get()
 {
     $response = [];
     foreach (['langs', 'options', 'types'] as $name) {
         if ($this->request->query_boolean($name, false)) {
             $methodname = 'get_' . $name;
             $response[$name] = $this->context->{$methodname}();
         }
     }
     if ($this->request->query_boolean('setup', false)) {
         $response['setup'] = $this->setup->to_jsono($this->context->is_admin());
     }
     if ($this->request->query_boolean('theme', false)) {
         $theme = new Theme($this->context);
         $response['theme'] = $theme->get_icons();
     }
     if ($this->request->query('items', false)) {
         $href = $this->request->query('items.href');
         $what = $this->request->query_numeric('items.what');
         $response['items'] = $this->context->get_items($href, $what);
     }
     if ($this->request->query('custom', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'custom disabled', !$this->context->query_option('custom.enabled', false));
         $href = $this->request->query('custom');
         $custom = new Custom($this->context);
         $response['custom'] = $custom->get_customizations($href);
     }
     if ($this->request->query('l10n', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'l10n disabled', !$this->context->query_option('l10n.enabled', false));
         $iso_codes = $this->request->query_array('l10n');
         $iso_codes = array_filter($iso_codes);
         $response['l10n'] = $this->context->get_l10n($iso_codes);
     }
     if ($this->request->query('search', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'search disabled', !$this->context->query_option('search.enabled', false));
         $href = $this->request->query('search.href');
         $pattern = $this->request->query('search.pattern');
         $search = new Search($this->context);
         $response['search'] = $search->get_items($href, $pattern);
     }
     if ($this->request->query('thumbs', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'thumbnails disabled', !$this->context->query_option('thumbnails.enabled', false));
         Util::json_fail(Util::ERR_UNSUPPORTED, 'thumbnails not supported', !$this->setup->get('HAS_PHP_JPEG'));
         $thumbs = $this->request->query_array('thumbs');
         $response['thumbs'] = $this->context->get_thumbs($thumbs);
     }
     Util::json_exit($response);
 }
Example #21
0
 function getTerms($types, $terms)
 {
     $ret = array();
     foreach ($terms as $t) {
         assert('$t[0] == "group"');
         $t = $t[1];
         foreach (array('type', 'text', 'exact') as $n) {
             if ($t[$n]) {
                 assert('$t[$n][0] == "string"');
                 $t[$n] = $t[$n][1];
             }
         }
         list($type, $text, $exact) = $t;
         if (!array_key_exists($t['type'], $types)) {
             continue;
         }
         if ($types[$t['type']]['method'] == 'words' and !$t['exact']) {
             $words = Search::explodeQuoted($t['text']);
             // Optimize the query a bit by eliminating duplicates and looking for longer
             // words first.  This should help cut down the number of records that have
             // to be scanned for subsequent words.
             usort($words, array('Search', 'lencmp'));
             foreach (array_unique($words) as $word) {
                 if ($word == "") {
                     continue;
                 }
                 array_push($ret, array($t['type'], $word, $t['exact']));
             }
         } else {
             array_push($ret, array($t['type'], $t['text'], $t['exact']));
         }
     }
     return $ret;
 }
Example #22
0
File: lib.php Project: lursu/morgue
 static function perform($terms)
 {
     $terms = Search::split_terms($terms);
     $terms_db = Search::db_escape_terms($terms);
     $terms_rx = Search::rx_escape_terms($terms);
     $parts = array();
     foreach ($terms_db as $term_db) {
         array_push($parts, "(summary RLIKE '{$term_db}' OR title RLIKE '{$term_db}')");
     }
     $parts = implode(' AND ', $parts);
     $conn = Persistence::get_database_object();
     $sql = "SELECT id, title, summary, created  FROM postmortems WHERE {$parts}";
     $rows = array();
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $timezone = getUserTimezone();
     $tz = new DateTimeZone($timezone);
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $row['score'] = 0;
         $row['created'] = new DateTime("@{$row['created']}");
         $row['created']->setTimezone($tz);
         $row['created'] = $row['created']->format('m/d/Y G:ia');
         foreach ($terms_rx as $term_rx) {
             $row['score'] += preg_match_all("/{$term_rx}/i", $row['summary'], $null);
             $row['score'] += preg_match_all("/{$term_rx}/i", $row['title'], $null);
         }
         $rows[] = $row;
     }
     uasort($rows, 'Search::sort_results');
     $conn = null;
     return $rows;
 }
Example #23
0
 public static function run($scope, $query)
 {
     self::$enterprise = 'enterprise' === $scope;
     if (' ' !== $query[0]) {
         return '';
     }
     $query = ltrim($query);
     self::$query = $query;
     self::$parts = $parts = explode(' ', $query);
     Workflow::init(self::$enterprise, $query);
     if (Workflow::checkUpdate()) {
         self::addUpdateCommands();
         return Workflow::getItemsAsXml();
     }
     if (self::$enterprise && !Workflow::getBaseUrl()) {
         self::addEnterpriseUrlCommand();
         return Workflow::getItemsAsXml();
     }
     if (!Workflow::getAccessToken() || !(self::$user = Workflow::requestApi('/user'))) {
         self::addLoginCommands();
         return Workflow::getItemsAsXml();
     }
     Workflow::stopServer();
     $isSystem = isset($query[0]) && $query[0] == '>';
     $isMy = 'my' == $parts[0] && isset($parts[1]);
     $isUser = isset($query[0]) && $query[0] == '@';
     $isRepo = false;
     $queryUser = null;
     if ($isUser) {
         $queryUser = ltrim($parts[0], '@');
     } elseif (($pos = strpos($parts[0], '/')) !== false) {
         $queryUser = substr($parts[0], 0, $pos);
         $isRepo = true;
     }
     if ($isSystem) {
         self::addSystemCommands();
         Workflow::sortItems();
     } else {
         if ($isMy) {
             self::addMyCommands();
         } elseif ($isUser && isset($parts[1])) {
             self::addUserSubCommands($queryUser);
         } elseif (!$isUser && $isRepo && isset($parts[1])) {
             self::addRepoSubCommands();
         } else {
             self::addDefaultCommands($isUser, $isRepo, $queryUser);
         }
         Workflow::sortItems();
         if ($query) {
             if (!$isUser && $isRepo && isset($parts[1])) {
                 $repoQuery = substr($query, strlen($parts[0]) + 1);
                 Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
             }
             $path = $isUser ? $queryUser : '******' . urlencode($query);
             $name = self::$enterprise ? 'GitHub Enterprise' : 'GitHub';
             Workflow::addItem(Item::create()->title("Search {$name} for '{$query}'")->icon('search')->arg('/' . $path)->autocomplete(false), false);
         }
     }
     return Workflow::getItemsAsXml();
 }
Example #24
0
 function do_url()
 {
     $page = $this->getcurrentPage();
     if ($page->isexist()) {
         $html = convert_Page($page);
         if (keys_exists(Vars::$get, 'word', 'type')) {
             $list = mb_split('[\\s ]', Vars::$get['word']);
             $smarty = $this->getSmarty();
             $smarty->assign('word', $list);
             $smarty->assign('type', Vars::$get['type']);
             $smarty->assign('body', Search::getinstance()->mark($html, $list, Vars::$get['type']));
             $html = $smarty->fetch('highlight.tpl.htm');
         }
         $ret['body'] = $html;
         $ret['title'] = $page->getpagename();
         $ret['pagename'] = $page->getpagename();
         $ret['lastmodified'] = $page->gettimestamp();
     } else {
         $smarty = $this->getSmarty();
         $smarty->assign('pagename', $page->getpagename());
         $ret['body'] = $smarty->fetch('notexist.tpl.htm');
         $ret['title'] = $page->getpagename() . ' は存在しません';
         $ret['pagename'] = $page->getpagename();
     }
     return $ret;
 }
Example #25
0
 public function __construct(array $config)
 {
     parent::__construct($config);
     Kohana::load(Kohana::find_file('vendors', 'sphinxapi'));
     $this->_client = new SphinxClient();
     $this->_client->SetServer($this->config('host'), $this->config('port'));
 }
Example #26
0
 public static function newInstance($expired = false)
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self($expired);
     }
     return self::$instance;
 }
Example #27
0
 /**
  * Rewrite construct to init some debug parameters.
  */
 protected function __construct($profile)
 {
     $sphinx_config = parent::__construct($profile);
     // Init Debug:
     $this->query_debug['current_query'] = 0;
     $this->query_debug = array_merge($this->query_debug, $sphinx_config);
 }
Example #28
0
 /**
  * Return the current object instance (Singleton)
  * @return object
  */
 public static function getInstance()
 {
     if (!is_object(self::$objInstance)) {
         self::$objInstance = new Search();
     }
     return self::$objInstance;
 }
Example #29
0
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #30
0
 public function _index()
 {
     // Deny access if not logged in
     new Protect('ajax');
     $post = Input::post();
     $token = Token::ajaxCheck($post['token']);
     // TODO: Add Token Support
     $token = TRUE;
     $data['errors'] = NULL;
     if (!empty($post['username'] && $token === TRUE)) {
         $t = Search::publicUsername($post['username']);
         foreach ($t as $key => $value) {
             $t[$key]['profile_pic'] = User::getProfilePic($value['profile_pic']);
         }
         return $t;
     } else {
         if (!$token) {
             $data['errors'][] = 'Security Token Missing';
         } else {
             $data['errors'][] = 'Username Required';
         }
     }
     if (!empty($data)) {
         return $data;
     } else {
         return FALSE;
     }
 }