public function start() { $renderView = new RenderView(); $resultView = new ResultView(); $addView = new AddView(); $connectionDAL = new ConnectionDAL(); $artistDAL = new ArtistDAL($connectionDAL); $songDAL = new SongDAL($connectionDAL, $artistDAL); $addModel = new AddModel($artistDAL, $songDAL); $loginModel = new LoginModel(); $deleteModel = new DeleteModel($songDAL, $artistDAL); $searchModel = new SearchModel($deleteModel, $connectionDAL); $searchView = new SearchView($searchModel, $loginModel); $searchController = new SearchController($renderView, $searchView, $searchModel, $loginModel, $deleteModel, $resultView); $addController = new AddController($renderView, $addView, $addModel); $loginView = new LoginView(); $loginController = new LoginController($renderView, $loginView, $loginModel); $navigationView = new NavigationView(); $page = $navigationView->checkPage(); if ($page == "/" || $page == "/index.php" || $page == "/project/") { $searchController->Start(); } else { if ($page == "login") { $loginController->Start(); } else { if ($page == "add") { $addController->Start(); } else { $searchController->Chords($page); } } } }
public function testControllerWithXmlHttpRequest() { $request = new Request(); $request->set('q', 'Hello'); $request->setRequestFormat('XmlHttpRequest'); $ctrl = new SearchController(); $response = $ctrl->searchAction($request); $this->assertEquals('ProductBundle:Search:list.html.twig{"products":{"0":{"name":"foo","description":"A foo product","price":42},"1":{"name":"bar","description":"A bar product","price":23}},"noLayout":true}', $response->getContent()); }
public function testSearchFollowers() { $this->simulateLogin('*****@*****.**', true, true); $_GET['c'] = "followers"; $_GET['u'] = 'ev'; $_GET['n'] = 'twitter'; $_GET['q'] = "name:Apple"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No followers found/', $results); }
public function actionPrintArrayByField() { $listOfField = Input::get('listoffields'); $listDienbien = Input::get('listDienbien'); $listOfField = substr($listOfField, 0, strlen($listOfField) - 1); $listOfField = explode(',', $listOfField); $searchController = new SearchController(); $listDangvien = $searchController->querySearchSimpleToPrint($listOfField); $data = []; foreach ($listDangvien['all'] as $key => $value) { $data[$key] = (array) $value; } $this->exportData->xuatDulieuDangvien($data, $listDienbien); }
public function testSearchFollowersLessThan20Results() { $builders = self::buildData(); $builders[] = FixtureBuilder::build('users', array('user_id' => '15', 'user_name' => 'jonyive', 'full_name' => 'Jony Ive', 'description' => 'design things at Apple')); $builders[] = FixtureBuilder::build('follows', array('follower_id' => '15', 'user_id' => '13', 'network' => 'twitter')); $this->simulateLogin('*****@*****.**', true, true); $_GET['q'] = "Apple"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern("/Results seem incomplete\\? ThinkUp may not have captured your latest data./", $results); $this->assertNoPattern("/Aw, no \"Apple\" here\\!/", $results); $this->assertNoPattern("/Seems like none of @ev's Twitter followers has \"Apple\" in their bio./", $results); $this->assertPattern("/1 of @ev's Twitter followers has \"Apple\" in their bio/", $results); $this->debug($results); }
public function render() { $this->view->addJS(JS_ANNONCE); $this->view->addJS(JS_MODAL); $this->view->new = true; parent::render(); }
/** * Method for executing all the pre-display activities */ private function prepareDisplay() { $searchSuggestions = Session::get(Session::SESS_SEARCH_SUGGESTIONS); if (empty($searchSuggestions)) { $search = new SearchController(); $searchSuggestions = $search->getSearchSuggestions(); Session::set(Session::SESS_SEARCH_SUGGESTIONS, $searchSuggestions); } $this->smarty->assign('APP_NAME', Constants::APP_NAME); $this->smarty->assign('APP_LOGO', Constants::APP_LOGO); $this->smarty->assign('APP_VERSION', Constants::APP_VERSION); $this->smarty->assign('CSRF_TOKEN_NAME', Constants::CSRF_TOKEN_NAME); $this->smarty->assign('CSRF_TOKEN_VALUE', RequestManager::getCsrfToken()); $this->smarty->assign('SEARCH_SUGGESTIONS', $searchSuggestions); $this->smarty->assign('CHPWD_ACTION_VALUE', AuthController::CHPWD_ACTION_VALUE); }
/** * getting songs list in json format * @param array $input * @return json */ public function searchAlbum($input) { $albums = parent::searchAlbum(json_decode($input, true)); if ($albums) { return $this->buildAnswer(true, 'Ok', array($albums)); } else { return $this->buildAnswer(false, 'Cannot fetch albums at this time'); } }
public function index() { self::$keyword = $_GET['keyword']; if (!isset($this->params[0])) { $this->params[0] = 0; } $page = (int) $this->params[0]; return $this->model->get(self::$keyword, $page); }
function search_on_search_result(&$api) { if (!$_GET['q'] || trim($_GET['q']) == '') { return search_on_search_form($api); } $forum_id = $api->forum() ? $api->forum()->get_id() : NULL; $url = new FreechURL('', _('Find')); $url->set_var('action', 'search'); $url->set_var('forum_id', $forum_id); $api->breadcrumbs()->add_link($url); $api->breadcrumbs()->add_text($_GET['q']); // Search for postings or users. $controller = new SearchController($api); if ($_GET['user_search']) { $controller->show_users($_GET['q'], $_GET['hs']); } else { $controller->show_postings($forum_id, $_GET['q'], $_GET['hs']); } }
private function search_row_query($controller, $params) { if (isset($params['query'])) { $tables = 'content'; $columns = 'content.*'; $where = 'match (content.contenttext) against (? in boolean mode) order by content.contentid'; $fields = array($params['query']); //build query from BuildQuery class $db_results = BuildQuery::all_field_query($tables, $columns, $where, $fields); //print_r($db_results); self::$db_content_rows = $db_results; } }
public function search_violation() { $user = Sentry::getUser(); // 普通用户每天只能查询两次 if ($user->is_common_user()) { $account_to_render = ['remain_search' => SearchController::get_search_count_remain($user->user_id, 'violation')]; } else { if ($user->is_business_user()) { $account = BusinessController::accountInfo($user->user_id); $account_to_render = ['unit' => $account['violationUnit'], 'balance' => $account['balance']]; } else { return View::make('Unkown error'); } } return View::make('pages.serve-center.business.vio', ['account' => $account_to_render]); }
/** * Import movies */ public function actionImport() { if ($movies = CHttpRequest::getPost('movies', false)) { foreach (explode("\n", $movies) as $key => $movie) { if (!ImportLog::model()->find('import_name=:movie', array(':movie' => $movie))) { if (substr($movie, -2) == 02) { continue; } // 2nd part $search = SearchController::search(str_replace(array('-', '01'), ' ', $movie)); $log = new ImportLog(); $log->import_name = $movie; $log->search_id = $search->id; $log->save(); } } } $this->render('import', array('imported_movies' => ImportLog::model()->findAll())); }
<?php /** * * ThinkUp/webapp/search.php * * Copyright (c) 2013 Gina Trapani * * LICENSE: * * This file is part of ThinkUp (http://thinkup.com). * * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any * later version. * * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see * <http://www.gnu.org/licenses/>. * * * @author Gina Trapani <ginatrapani[at]gmail[dot]com> * @license http://www.gnu.org/licenses/gpl.html * @copyright 2013 Gina Trapani */ require_once 'init.php'; $controller = new SearchController(); echo $controller->go();
{ $view_page = "requirements"; include_once ROOT_PATH . "search/view/container.php"; } public function fundraisers() { $view_page = "fundraisers"; include_once ROOT_PATH . "search/view/container.php"; } public function projects() { $view_page = "projects"; include_once ROOT_PATH . "search/view/container.php"; } } $searchcontroller = new SearchController(); if (isset($_GET['m'])) { $method = $_GET['m']; } else { $method = "index"; } switch ($method) { case "index": $searchcontroller->index(); break; case "fundraisers": $searchcontroller->fundraisers(); break; case "projects": $searchcontroller->projects(); break;
<?php /** * @version $Id: search.php 10381 2008-06-01 03:35:53Z pasamio $ * @package Joomla * @subpackage Search * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); // Require the com_content helper library require_once JPATH_COMPONENT . DS . 'controller.php'; // Create the controller $controller = new SearchController(); // Perform the Request task $controller->execute(JRequest::getCmd('task')); // Redirect if set by the controller $controller->redirect();
public function testSearchSearches() { //Before building data No posts $this->simulateLogin('*****@*****.**', true, true); $_GET['c'] = "searches"; $_GET['n'] = "twitter"; $_GET['u'] = "ecucurella"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. #totssomtv3 is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); $this->assertPattern('/Uh-oh. Your search terms are missing. Please try again./', $results); $_GET['q'] = ""; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. #totssomtv3 is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); $this->assertPattern('/Uh-oh. Your search term is missing. Please try again./', $results); $_GET['q'] = "totssomtv3"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. #totssomtv3 is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); $_GET['u'] = "vetcastellnou"; $_GET['q'] = "CCMA"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. CCMA is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Buil data $builder = $this->buildSearchData1(); //Hashtag NOT being searched $_GET['u'] = "ecucurella"; $_GET['k'] = "#nohashtag"; $_GET['q'] = "#nohashtag"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->debug($results); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertPattern('/Uh-oh. #nohashtag is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Keyword NOT being searched $_GET['u'] = 'vetcastellnou'; $_GET['q'] = "nokeyword"; $_GET['k'] = "nokeyword"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertPattern('/Uh-oh. nokeyword is not a saved search. Please try again./', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Hashtag being searched $_GET['u'] = "ecucurella"; $_GET['q'] = "#totssomtv3"; $_GET['k'] = "#totssomtv3"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->debug($results); $this->assertNoPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. #totssomtv3 is not a saved search. Please try again./', $results); $this->assertPattern('/Dem treballadors de TV3 donarem sang #lasangdelatele #totssomtv3/', $results); $this->assertNoPattern('/El comit dempresa de TV3 acusa la direcci de la CCMA de populista/', $results); $this->assertNoPattern('/El Chelsea quiere a Mourinho YA #efectivament/', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Keyword being searched $_GET['u'] = 'vetcastellnou'; $_GET['q'] = "CCMA"; $_GET['k'] = "CCMA"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->debug($results); $this->assertNoPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. Keyword CCMA is not being searched. Please try again./', $results); $this->assertNoPattern('/Dem treballadors de TV3 donarem sang #lasangdelatele #totssomtv3/', $results); $this->assertPattern('/El comit dempresa de TV3 acusa la direcci de la CCMA de populista/', $results); $this->assertNoPattern('/El Chelsea quiere a Mourinho YA #efectivament/', $results); $this->assertNoPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Another owner with no permission $this->simulateLogin('*****@*****.**', true, true); //Hashtag being searched $_GET['u'] = "ecucurella"; $_GET['q'] = "totssomtv3"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. Hashtag #totssomtv3 is not being searched. Please try again./', $results); $this->assertPattern('/Whoops! You don't have access to that user. Please try again./', $results); //Keyword being searched $_GET['u'] = 'vetcastellnou'; $_GET['q'] = "CCMA"; $controller = new SearchController(true); $this->assertTrue(isset($controller)); $results = $controller->go(); $this->assertPattern('/No posts found/', $results); $this->assertNoPattern('/Whoops! That user doesn't exist. Please try again./', $results); $this->assertNoPattern('/Uh-oh. Keyword CCMA is not being searched. Please try again./', $results); $this->assertPattern('/Whoops! You don't have access to that user. Please try again./', $results); }
// $ctrlSearch->GetSearchResult((object) array( // 'type' => 'common', // 'pattern' => $pattern // )); // }); /** * (GET) * Suche über den gesamten Datenbestand anhand eines Typs und Suchbegriffen * * Parameter * @type - (string) Type (z.B. common, bands, cds) * @pattern - (string) Suchbegriff(e) */ $app->get('/search/:type/:pattern', function ($type, $pattern) use($app) { // Statistics-Controller instanziieren $ctrlSearch = new SearchController(); // Searchinfo aus Datenbank holen // Mögliche Typen (type): // - common // - bands // - cds $ctrlSearch->GetSearchResult((object) array('type' => $type, 'pattern' => $pattern)); }); // ENDE - Suche // --- Authentication ---- /** * (POST) * Authentifiziert den Benutzer am System * * Requestparameter als JSON ({"username":"******","password":"******"}) * Aufruf siehe: app/js/services/login-service.js -> Methode: AuthenticationService.Login
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ require_once "Libs/autoload.php"; $config = new Config(); $webPage = new PJSWebPage($config->getTitle() . ' - Delete Search'); $act = Tools::Param('act'); if ("Delete Search" === $act) { $searchModel = new SearchModel(); $searchModel->populateFromForm(); if (!$searchModel->validateForDelete()) { $searchView = new SearchFormView('Delete Search', $searchModel); $body = "<h2>Invalid data</h2>\n" . $searchView->getForm(); } else { $searchController = new SearchController(); $searchController->delete($searchModel); $body = "Deleted search # " . $searchModel->getId() . "<br />\n"; } } else { $searchController = new SearchController(); $searchModel = $searchController->get(Tools::param('id')); $searchView = new SearchFormView('Delete Search', $searchModel); $body = $searchView->getForm(); } $webPage->setBody($body); $webPage->displayPage();
$controller = new MailController(); $controller->create(); }); $app->delete('/inbox/:id', function ($id) { fAuthorization::requireLoggedIn(); $controller = new MailController(); $controller->delete($id); }); $app->post('/msgs', function () { fAuthorization::requireLoggedIn(); $controller = new MsgController(); $controller->create(); }); $app->post('/search', function () { fAuthorization::requireLoggedIn(); $controller = new SearchController(); $controller->show(); }); $app->delete('/msgs/:id', function ($id) { fAuthorization::requireLoggedIn(); $controller = new MsgController(); $controller->delete($id); }); $app->get('/tweets', function () { UserHelper::requireProfile(); $controller = new TweetController(); $controller->index(); }); $app->post('/tweets', function () { fAuthorization::requireLoggedIn(); $controller = new TweetController();
public function index() { ClassLoader::import('application.model.presentation.CategoryPresentation'); $this->getAppliedFilters(); // presentation if ($theme = CategoryPresentation::getThemeByCategory($this->getCategory())) { if ($theme->getTheme()) { $this->application->setTheme($theme->getTheme()); } if ($layout = $theme->listStyle->get()) { $this->request->set('layout', strtolower($layout)); $this->config->set('LIST_LAYOUT', $layout); $this->config->set('ALLOW_SWITCH_LAYOUT', false); } } // pagination $currentPage = $this->request->get('page', 1); $listLayout = $this->getListLayout(); $perPage = $this->getProductLimitCount($listLayout); $offsetStart = ($currentPage - 1) * $perPage + 1; $offsetEnd = $currentPage * $perPage; $selectFilter = new ARSelectFilter(); $selectFilter->setLimit($perPage, $offsetStart - 1); $this->application->processInstancePlugins('productFilter', $selectFilter); // create new search filter $query = $this->request->get('q'); if ($query) { $searchFilter = new SearchFilter($query); $this->filters[] = $searchFilter; // search by category names $f = new ARSelectFilter(); foreach (array($this->locale->getLocaleCode(), $this->application->getDefaultLanguageCode()) as $handle) { $langHandle = MultiLingualObject::getLangSearchHandle(new ARFieldHandle('Category', 'name'), $handle); $f->mergeCondition(new LikeCond($langHandle, '%' . $query . '%')); } $foundCategories = ActiveRecordModel::getRecordSet('Category', $f, Category::LOAD_REFERENCES); foreach ($foundCategories as $category) { $category->getPathNodeSet(); } $cleanedQuery = $searchFilter->getCleanedQuery($query); $this->logSearchQuery($cleanedQuery); } // root category? if ($this->getCategory()->isRoot() && !$this->filters && !$this instanceof IndexController && !$this->request->get('includeSub') && $currentPage > 1) { return new ActionRedirectResponse('index', 'index'); } // sorting $sort = array(); $opts = $this->config->get('ALLOWED_SORT_ORDER'); if ($opts) { foreach ($opts as $opt => $status) { $sort[strtolower($opt)] = $this->translate($opt); } } foreach ($this->getCategory()->getSpecificationFieldArray() as $field) { if ($field['isSortable']) { $sortName = $field['dataType'] == SpecField::DATATYPE_NUMBERS ? '_sort_num' : '_sort_text'; $sort[$field['ID'] . '-' . $field['handle'] . '_asc'] = $this->maketext($sortName . '_asc', $field['name_lang']); $sort[$field['ID'] . '-' . $field['handle'] . '_desc'] = $this->maketext($sortName . '_desc', $field['name_lang']); } } $order = $this->request->get('sort'); $defOrder = strtolower($this->config->get('SORT_ORDER')); if (!$order) { $order = $defOrder; } $this->applySortOrder($selectFilter, $order); // setup ProductFilter $productFilter = new ProductFilter($this->getCategory(), $selectFilter); if ($this->config->get('INCLUDE_SUBCATEGORY_PRODUCTS')) { $productFilter->includeSubcategories(); } $this->productFilter = $productFilter; foreach ($this->filters as $filter) { $productFilter->applyFilter($filter); if ($filter instanceof SearchFilter) { $productFilter->includeSubcategories(); $searchQuery = $filter->getKeywords(); } } if ($this->getCategory()->isRoot() && $this->filters || $this->filters || $this->request->get('includeSub')) { $productFilter->includeSubcategories(); } $products = $this->getProductsArray($productFilter); $this->hasProducts = count($products) > 0; // pagination $count = new ProductCount($this->productFilter, $this->application); $totalCount = $count->getCategoryProductCount($productFilter); $offsetEnd = min($totalCount, $offsetEnd); $this->totalCount = $totalCount; // narrow by subcategories $subCategories = $this->getCategory()->getSubCategoryArray(Category::LOAD_REFERENCES); $categoryNarrow = array(); if ((!empty($searchQuery) || $this->getCategory()->isRoot() || $this->filters) && $products) { $categoryNarrow = $this->getSubCategoriesBySearchQuery($productFilter->getSelectFilter(), $subCategories); } $categoryArray = $this->getCategory()->toArray(); if (!$this->getCategory()->isRoot()) { $this->redirect301($this->request->get('cathandle'), createHandleString($categoryArray['name_lang'])); } // if all the results come from one category, redirect to this category if (count($categoryNarrow) == 1 && count($this->filters) == 1 && empty($foundCategories)) { $canNarrow = true; foreach ($products as $product) { if ($product['Category']['ID'] == $this->getCategoryId()) { $canNarrow = false; } } if ($canNarrow) { while (count($categoryNarrow) == 1) { if ($categoryNarrow[0]['searchCount'] != $totalCount) { break; } $this->category = Category::getInstanceByID($categoryNarrow[0]['ID'], Category::LOAD_DATA); $subCategories = $this->getCategory()->getSubCategoryArray(Category::LOAD_REFERENCES); if ($subCategories) { $subCategories[] = $categoryArray; } $categoryNarrow = $this->getSubCategoriesBySearchQuery($selectFilter, $subCategories); } include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php'; if (!$this->getCategory()->isRoot()) { return new RedirectResponse(createCategoryUrl(array('data' => $this->getCategory()->toArray(), 'filters' => $this->filters), $this->application)); } } } // get subcategory-subcategories if ($subCategories && $this->config->get('CAT_MENU_SUBS')) { $this->getSubSubCategories($subCategories); } // get subcategory featured products $subCatFeatured = array(); if ($subCategories && !$products || $this instanceof IndexController) { $subCatFeatured = $this->getSubCatFeaturedProducts(); } // if there were no products found, include subcategories in filter counts... except home page if (!$products || $this->getCategory()->isRoot()) { $selectFilter->removeCondition(new EqualsCond(new ARFieldHandle('Product', 'categoryID'), $this->getCategory()->getID())); $this->productFilter->includeSubcategories(); } // search redirects // no products found, but found one category name - redirect to this category if (isset($foundCategories) && 1 == $foundCategories->size() && !$products) { include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php'; return new RedirectResponse(createCategoryUrl(array('data' => $foundCategories->get(0)->toArray()), $this->application)); } $filterArray = array(); foreach ($this->filters as $filter) { $filterArray[] = $filter->toArray(); } if ($this->config->get('DISPLAY_CATEGORY_FEATURED')) { $this->getFeaturedMainCategoryProducts($subCategories); $this->getFeaturedMainCategoryProducts($categoryNarrow); } $response = new ActionResponse(); $response->set('id', $this->getCategoryId()); $response->set('products', $products); $response->set('count', $totalCount); $response->set('offsetStart', $offsetStart); $response->set('offsetEnd', $offsetEnd); $response->set('perPage', $perPage); $response->set('currentPage', $currentPage); $response->set('category', $categoryArray); $response->set('subCategories', $subCategories); $response->set('currency', $this->getRequestCurrency()); $response->set('sortOptions', $sort); $response->set('sortForm', $this->buildSortForm($order)); $response->set('sortField', $order); $response->set('categoryNarrow', $categoryNarrow); $response->set('subCatFeatured', $subCatFeatured); //$response->set('allFilters', $filters); //$response->set('showAll', $showAll); $response->set('appliedFilters', $filterArray); $response->set('layout', $listLayout); $response->set('listAttributes', $this->getListAttributes()); $filterChainHandle = $this->setUpBreadCrumbAndReturnFilterChainHandle($currentPage); $response->set('url', $this->getCategoryPageUrl(array('page' => '_000_', 'filters' => $filterChainHandle))); $response->set('layoutUrl', $this->getCategoryPageUrl(array('filters' => $filterChainHandle, 'query' => array('layout' => '')))); $response->set('filterChainHandle', $filterChainHandle); if (isset($searchQuery)) { $response->set('searchQuery', $searchQuery); } if (isset($foundCategories)) { $response->set('foundCategories', $foundCategories->toArray()); } // look for manufacturer filter foreach ($this->filters as $filter) { if ($filter instanceof ManufacturerFilter) { $response->set('manufacturerFilter', $filter->toArray()); } } if (1 == $currentPage && $query) { $searchCon = new SearchController($this->application); $response->set('modelSearch', $searchCon->searchAll($cleanedQuery)); } return $response; }
public function search($what) { if (isset($_POST['searchstring'])) { $this->loadTemplate(); $controller = new SearchController(); switch ($what) { case 'autor': $controller->getAutorSearchResults(); break; case 'book': $controller->getBookSearchResults(); break; } } }
if ($_GET[KEY_PATH] == "manager") { include CONTROLLER_PATH . "manager.php"; // path = manager if ($_GET[KEY_TARGET] == "noticeboard") { ManagerController::noticeboard(); } else { if ($_GET[KEY_TARGET] == "loginrecord") { ManagerController::loginrecord(); } else { if ($_GET[KEY_TARGET] == "permission") { ManagerController::permission(); } else { if ($_GET[KEY_TARGET] == "googleanalytics") { ManagerController::googleAnalytics(); } } } } } else { if ($_GET[KEY_PATH] == "help") { include CONTROLLER_PATH . "help.php"; HelpController::show(); } else { if ($_GET[KEY_PATH] == "search") { include CONTROLLER_PATH . "search.php"; SearchController::index(); } } } } }
/** * Runs the QueryTool on the supplied command line arguments */ function start() { global $argv, $INDEXING_PLUGINS; if (!isset($argv[1])) { $this->usageMessageAndExit(); } $query = $argv[1]; $results_per_page = isset($argv[2]) ? $argv[2] : 10; $limit = isset($argv[3]) ? $argv[3] : 0; setLocaleObject(getLocaleTag()); $start_time = microtime(); $controller = new SearchController($INDEXING_PLUGINS); $data = $controller->queryRequest($query, $results_per_page, $limit); if (!isset($data['PAGES'])) { $data['PAGES'] = array(); } foreach ($data['PAGES'] as $page) { echo "============\n"; echo "TITLE: " . trim($page[self::TITLE]) . "\n"; echo "URL: " . trim($page[self::URL]) . "\n"; echo "IPs: "; if (isset($page[self::IP_ADDRESSES])) { foreach ($page[self::IP_ADDRESSES] as $address) { echo $address . " "; } } echo "\n"; echo "DESCRIPTION: " . wordwrap(trim($page[self::DESCRIPTION])) . "\n"; echo "Rank: " . $page[self::DOC_RANK] . "\n"; echo "Relevance: " . $page[self::RELEVANCE] . "\n"; echo "Proximity: " . $page[self::PROXIMITY] . "\n"; echo "Score: " . $page[self::SCORE] . "\n"; echo "============\n\n"; } $data['ELAPSED_TIME'] = changeInMicrotime($start_time); echo "QUERY STATISTICS\n"; echo "============\n"; echo "ELAPSED TIME: " . $data['ELAPSED_TIME'] . "\n"; if (isset($data['LIMIT'])) { echo "LOW: " . $data['LIMIT'] . "\n"; } if (isset($data['HIGH'])) { echo "HIGH: " . min($data['TOTAL_ROWS'], $data['LIMIT'] + $data['RESULTS_PER_PAGE']) . "\n"; } if (isset($data['TOTAL_ROWS'])) { echo "TOTAL ROWS: " . $data['TOTAL_ROWS'] . "\n"; } if (isset($data['ERROR'])) { echo $data['ERROR'] . "\n"; } }
public function renderMore() { echo "\n <script>\n \$('.popup').magnificPopup({\n type: 'ajax',\n alignTop: true,\n overflowY: 'scroll'\n });\n </script>\n "; parent::renderMore(); }
/** * Implements post processing of recipes. recipes are extracted * ingredients are scrubbed and recipes are clustered. The clustered * recipes are added back to the index. * * @param string $index_name index name of the current crawl. */ function postProcessing($index_name) { global $INDEXING_PLUGINS; if (!class_exists("SplHeap")) { crawlLog("...Recipe Plugin Requires SPLHeap for clustering!"); crawlLog("...Aborting plugin"); return; } $locale_tag = guessLocale(); setLocaleObject($locale_tag); $search_controller = new SearchController($INDEXING_PLUGINS); $query = "recipe:all i:{$index_name}"; crawlLog("...Running Recipe Plugin!"); crawlLog("...Finding docs tagged as recipes."); $more_docs = true; $raw_recipes = array(); $limit = 0; $num = 100; while ($more_docs) { $results = @$search_controller->queryRequest($query, $num, $limit, 1, $index_name); if (isset($results["PAGES"]) && ($num_results = count($results["PAGES"])) > 0) { $raw_recipes = array_merge($raw_recipes, $results["PAGES"]); } crawlLog("Scanning recipes {$limit} through " . ($limit + $num_results) . "."); $limit += $num_results; if (isset($results["SAVE_POINT"])) { $end = true; foreach ($results["SAVE_POINT"] as $save_point) { if ($save_point != -1) { $end = false; } } if ($end) { $more_docs = false; } } else { $more_docs = false; } } crawlLog("...Clustering."); // only cluster if would make more than one cluster if (count($raw_recipes) * CLUSTER_RATIO > 1) { $recipes = array(); $i = 0; foreach ($raw_recipes as $raw_recipe) { $description = $raw_recipe[self::DESCRIPTION]; $ingredients = explode("||", $description); if (is_array($ingredients) && count($ingredients) > 1) { $recipes[$i][0] = $raw_recipe[self::TITLE]; $recipes[$i][1] = $ingredients; $recipes[$i][2] = crawlHash($raw_recipe[self::URL]); $recipes[$i][3] = $raw_recipe; $i++; } } $recipes_ingredients = array(); $count = count($recipes); foreach ($recipes as $key => $recipe) { foreach ($recipe[1] as $index => $ingredient) { if (strlen($ingredient) != 0 && substr($ingredient, strlen($ingredient) - 1) != ":") { $mainIngredient = $this->getIngredientName((string) $ingredient); if (strlen($mainIngredient) != 0) { $recipe[1][$index] = $mainIngredient; } else { unset($recipe[1][$index]); } } else { unset($recipe[1][$index]); } } $recipes[$key] = $recipe; } $count = count($recipes); $k = 0; $basic_ingredients = array('onion', 'oil', 'cheese', 'pepper', 'sauce', 'salt', 'milk', 'butter', 'flour', 'cake', 'garlic', 'cream', 'soda', 'honey', 'powder', 'sauce', 'water', 'vanilla', 'pepper', 'bread', 'sugar', 'vanillaextract', 'celery', 'seasoning', 'syrup', 'skewers', 'egg', 'muffin', 'ginger', 'basil', 'oregano', 'cinammon', 'cumin', 'mayonnaise', 'mayo', 'chillipowder', 'lemon', 'greens', 'yogurt', 'margarine', 'asparagus', 'halfhalf', 'pancakemix', 'coffee', 'cookies', 'lime', 'chillies', 'cilantro', 'rosemary', 'vanillaextract', 'vinegar', 'shallots', 'wine', 'cornmeal', 'nonstickspray'); for ($i = 0; $i < $count; $i++) { $recipe1_main_ingredient = ""; $recipe1 = $recipes[$i][1]; $recipe_name = $recipes[$i][0]; $recipe1_title = strtolower($recipes[$i][0]); $distinct_ingredients[$recipe_name] = $recipes[$i][1]; $doc_keys[$recipe_name] = $recipes[$i][2]; $recipes_summary[$recipe_name] = $recipes[$i][3]; for ($j = $i + 1; $j < $count; $j++) { $recipe2_main_ingredient = ""; $recipe2 = $recipes[$j][1]; $recipe2_title = strtolower($recipes[$j][0]); $weights[$k][0] = $recipes[$i][0]; $weights[$k][1] = $recipes[$j][0]; $merge_array = array_merge($recipe1, $recipe2); $vector_array = array_unique($merge_array); sort($vector_array); $recipe1_vector = array_fill_keys($vector_array, 0); $recipe2_vector = array_fill_keys($vector_array, 0); foreach ($recipe1 as $ingredient) { if ($ingredient != "" && !in_array($ingredient, $basic_ingredients)) { if (strstr($recipe1_title, $ingredient)) { $recipe1_main_ingredient = $ingredient; } } $recipe1_vector[$ingredient] = 1; } foreach ($recipe2 as $ingredient) { if ($ingredient != "" && !in_array($ingredient, $basic_ingredients)) { if (strstr($recipe2_title, $ingredient)) { $recipe2_main_ingredient = $ingredient; } } $recipe2_vector[$ingredient] = 1; } $edge_weight = 0; $matches = 1; foreach ($vector_array as $vector) { $diff = $recipe1_vector[$vector] - $recipe2_vector[$vector]; $vector_diff[$vector] = pow($diff, 2); if (abs($diff) == 1) { $matches += 1; } $edge_weight += $vector_diff[$vector]; } $main_ingredient_match = 1; if ($recipe1_main_ingredient != $recipe2_main_ingredient) { $main_ingredient_match = 1000; } $edge_weight = sqrt($edge_weight) * $matches * $main_ingredient_match; $weights[$k][2] = $edge_weight; $k++; } } crawlLog("...Making new shard with clustered recipes as docs."); $clusters = kruskalClustering($weights, $count, $distinct_ingredients); $index_shard = new IndexShard("cluster_shard"); $word_lists = array(); $recipe_sites = array(); foreach ($clusters as $cluster) { $count = count($cluster); for ($i = 0; $i < $count - 1; $i++) { $meta_ids = array(); $summary = array(); $recipe = $cluster[$i]; $summary[self::URL] = $recipes_summary[$recipe][self::URL]; $summary[self::TITLE] = $recipes_summary[$recipe][self::TITLE]; $summary[self::DESCRIPTION] = $recipes_summary[$recipe][self::DESCRIPTION]; $summary[self::TIMESTAMP] = $recipes_summary[$recipe][self::TIMESTAMP]; $summary[self::ENCODING] = $recipes_summary[$recipe][self::ENCODING]; $summary[self::HASH] = $recipes_summary[$recipe][self::HASH]; $doc_keys[$recipe] = crawlHash($summary[self::URL], true); $hash_rhost = "r" . substr(crawlHash(UrlParser::getHost($summary[self::URL]) . "/", true), 1); $doc_keys[$recipe] .= $summary[self::HASH] . $hash_rhost; $summary[self::TYPE] = $recipes_summary[$recipe][self::TYPE]; $summary[self::HTTP_CODE] = $recipes_summary[$recipe][self::HTTP_CODE]; $recipe_sites[] = $summary; $meta_ids[] = "ingredient:" . trim($cluster["ingredient"]); crawlLog("ingredient:" . $cluster["ingredient"]); if (!$index_shard->addDocumentWords($doc_keys[$recipe], self::NEEDS_OFFSET_FLAG, $word_lists, $meta_ids, true, false)) { crawlLog("Problem inserting recipe: " . $summary[self::TITLE]); } } } $shard_string = $index_shard->save(true); $index_shard = IndexShard::load("cluster_shard", $shard_string); unset($shard_string); crawlLog("...Adding recipe shard to index archive bundle"); $dir = CRAWL_DIR . "/cache/" . self::index_data_base_name . $index_name; $index_archive = new IndexArchiveBundle($dir, false); if ($index_shard->word_docs_packed) { $index_shard->unpackWordDocs(); } $generation = $index_archive->initGenerationToAdd($index_shard); if (isset($recipe_sites)) { crawlLog("... Adding " . count($recipe_sites) . " recipe docs."); $index_archive->addPages($generation, self::SUMMARY_OFFSET, $recipe_sites, 0); } $k = 0; foreach ($recipe_sites as $site) { $recipe = $site[self::TITLE]; $hash = crawlHash($site[self::URL], true) . $site[self::HASH] . "r" . substr(crawlHash(UrlParser::getHost($site[self::URL]) . "/", true), 1); $summary_offsets[$hash] = $site[self::SUMMARY_OFFSET]; } $index_shard->changeDocumentOffsets($summary_offsets); $index_archive->addIndexData($index_shard); $index_archive->saveAndAddCurrentShardDictionary(); $index_archive->dictionary->mergeAllTiers(); $this->db->setWorldPermissionsRecursive(CRAWL_DIR . '/cache/' . self::index_data_base_name . $index_name); crawlLog("...Recipe plugin finished."); } }
public function build_filter_field($filter, $key, $section) { // set up the faceting params if ($section->facet) { $sf = $section->filter; $facet = $filter->facet->{$sf}; $facet->field_ext = $filter->facet_search_ext; $facet->filter_name = $sf; //$section->filter; foreach ($section->facet as $attr => $value) { $facet->{$attr} = $value; } // automatically populate facet limit if show_max is sepecified if ($section->facet->show_max && !$facet->limit) { $facet->limit = $section->facet->show_max + 1; } // Handle count reducing tag/exclude for multi-choice filter fields if ($section->facet->select == "multiple") { $facet->multi = true; } } parent::build_filter_field($filter, $key, $section); }
if (file_exists($file->path)) { $app->render('pictureView.phtml', array('title' => $file->name, 'file' => $file, 'path' => $file->path)); } }); $app->post('/modify/:id', function ($id) use($app) { session_start(); $description = $app->request->post('description'); if (isset($_SESSION['fileId']) && array_key_exists("{$id}", $_SESSION['fileId'])) { $app->FileGateway->changeDescription($id, $description); $app->flash('success', 'Описание файла успешно обновлено'); } $app->response->redirect("/f/{$id}", 303); }); $app->get('/search(/:page)', function ($page = 1) use($app) { $queryString = $app->request->get('string'); $searchHandler = new SearchController($app->SearchGateway, $app->config('filesPerPage')); $totalFilesNum = $searchHandler->countResults($queryString); $files = $searchHandler->find($queryString, $page); $last = $searchHandler->countPages(); $message = $searchHandler->getHeaderString($queryString); $app->render('searchResults.phtml', array('files' => $files, 'title' => "Результаты поиска", 'message' => $message, 'query' => $queryString, 'curPage' => $page, 'last' => $last, 'query' => $queryString)); }); $app->post('/comment/async', function () use($app) { $commentHandler = new CommentsController($app->CommentGateway, $app->request->post()); $result = $commentHandler->addComment(true); if (is_array($result)) { list($comment, $relativesNum) = $result; } else { $comment = $result; $relativesNum = null; }
public static function search($params) { $searchController = new SearchController(); $results = $searchController->search($params); return $results; }
}); $routes->get('/institution/:id/update', function ($id) { InstitutionController::edit($id); }); $routes->post('/institution/:id/update', function ($id) { InstitutionController::update($id); }); $routes->post('/institution/:id/delete', function ($id) { InstitutionController::delete($id); }); $routes->get('/suggestions', function () { SuggestionController::index(); }); $routes->get('/suggestion/new', function () { SuggestionController::create(); }); $routes->post('/suggestion/new', function () { SuggestionController::store(); }); $routes->post('/suggestion/:id/update', function ($id) { SuggestionController::toggleProcessed($id); }); $routes->post('/suggestion/:id/delete', function ($id) { SuggestionController::delete($id); }); $routes->get('/search', function () { SearchController::index(); }); $routes->post('/search', function () { SearchController::search(); });