当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchForm::getSearchQuery方法代码示例

本文整理汇总了PHP中SearchForm::getSearchQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::getSearchQuery方法的具体用法?PHP SearchForm::getSearchQuery怎么用?PHP SearchForm::getSearchQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchForm的用法示例。


在下文中一共展示了SearchForm::getSearchQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modulesearchformresults

 /**
  * Process and render search results.
  *
  * @param array $data The raw request data submitted by user
  * @param SearchForm $form The form instance that was submitted
  * @param SS_HTTPRequest $request Request generated for this action
  */
 function modulesearchformresults($data, $form, $request)
 {
     $data = array('Results' => $form->getResults(), 'Query' => $form->getSearchQuery(), 'Title' => _t('SearchForm.SearchResults', 'Search Results'));
     //search tags
     //search authors
     if ($data["Results"]) {
         foreach ($data["Results"] as $key => $resultItem) {
             if (!$resultItem instanceof ModuleProduct) {
                 $data["Results"]->remove($resultItem);
             }
         }
     } else {
         $data["Results"] = new ArrayList();
     }
     $search = Convert::raw2sql($data["Query"]);
     if (strlen($search) > 2) {
         $additionalProducts = ModuleProduct::get()->filterAny(array("Code:PartialMatch" => $search, "MenuTitle:PartialMatch" => $search));
         if ($additionalProducts) {
             foreach ($additionalProducts as $moduleProduct) {
                 $data["Results"]->push($moduleProduct);
             }
         }
         $tags = EcommerceProductTag::get()->filterAny(array("Title:PartialMatch" => $search, "Synonyms:PartialMatch" => $search, "Explanation:PartialMatch" => $search));
         if ($tags->count()) {
             foreach ($tags as $tag) {
                 $rows = DB::query("SELECT ProductID FROM EcommerceProductTag_Products WHERE EcommerceProductTagID = " . $tag->ID);
                 if ($rows) {
                     foreach ($rows as $row) {
                         $item = ModuleProduct::get()->byID($row["ProductID"]);
                         if ($item) {
                             $data["Results"]->push($item);
                         }
                     }
                 }
             }
         }
         $authors = Member::get()->filterAny(array("ScreenName:PartialMatch" => $search, "FirstName:PartialMatch" => $search, "Surname:PartialMatch" => $search));
         if ($authors->count()) {
             foreach ($authors as $author) {
                 $rows = DB::query("SELECT \"ModuleProductID\" FROM \"ModuleProduct_Authors\" WHERE \"MemberID\" = " . $author->ID);
                 if ($rows) {
                     foreach ($rows as $row) {
                         $item = ModuleProduct::get()->byID($row["ModuleProductID"]);
                         if ($item) {
                             $data["Results"]->push($item);
                         }
                     }
                 }
             }
         }
     }
     if ($data["Results"] && $data["Results"] instanceof DataObjectSet) {
         $data["Results"]->removeDuplicates();
     }
     if (Director::is_ajax()) {
         return Convert::array2json(array("ModuleProducts" => $data["Results"]->column("ID")));
     }
     return $this->customise(array("Products" => $data["Results"]));
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-software,代码行数:66,代码来源:ModuleProductGroup.php

示例2: results

 /**
  * Process and render search results. This has been hacked a bit to load
  * products into the list (if they exists). Will need to come up with a more
  * elegant solution to dealing with complex searches of objects though.
  *
  * @param array $data The raw request data submitted by user
  * @param SearchForm $form The form instance that was submitted
  * @param SS_HTTPRequest $request Request generated for this action
  */
 public function results($data, $form, $request)
 {
     $results = $form->getResults();
     // For the moment this will also need to be added to your
     // Page_Controller::results() method (until a more elegant solution can
     // be found
     if (class_exists("Product")) {
         $products = Product::get()->filterAny(array("Title:PartialMatch" => $data["Search"], "StockID" => $data["Search"], "Content:PartialMatch" => $data["Search"]));
         $results->merge($products);
     }
     $results = $results->sort("Title", "ASC");
     $data = array('Results' => PaginatedList::create($results, $this->request), 'Query' => $form->getSearchQuery(), 'Title' => _t('SearchForm.SearchResults', 'Search Results'));
     return $this->owner->customise($data)->renderWith(array('Page_results', 'SearchResults', 'Page'));
 }
开发者ID:i-lateral,项目名称:silverstripe-catalogue,代码行数:23,代码来源:CatalogueController.php

示例3: results

 /**
  * Gets the results from the given query.
  *
  * Appends to the usual results the matches on the GtkdocSection
  * instances on the following order:
  *
  * 1. GtkdocSections with matches in 'Title'
  * 2. GtkdocSections with matches in 'MetaDescription'
  * 3. GtkdocSections with matches in 'Content'
  *
  * Eventual duplicates are dropped from the list.
  *
  * @param array          $data    The raw data submitted by user
  * @param SearchForm     $form    The form instance
  * @param SS_HTTPRequest $request Request for this action
  */
 public function results($data, $form, $request)
 {
     $keywords = $data['Search'];
     // Populate the first matches in the usual way
     $matches = $form->getResults()->toArray();
     // Get the list of GtkdocSection with matching title...
     $context = singleton('GtkdocSection')->getDefaultSearchContext();
     $gtkdoc_matches = $context->getResults(array('Title' => $keywords))->toArray();
     // ...and add to them the list of GtkdocSection with matching
     // description and matching content, skipping the duplicates...
     self::merge($gtkdoc_matches, $context->getResults(array('MetaDescription' => $keywords))->toArray());
     self::merge($gtkdoc_matches, $context->getResults(array('Content' => $keywords))->toArray());
     // Append the GtkdocSection matches to the original ones
     $matches = array_merge($matches, $gtkdoc_matches);
     $results = new PaginatedList(new ArrayList($matches));
     $results->setPageLength(10);
     $results->setLimitItems(true);
     $results->setPageStart($request->getVar('start'));
     $data = array('Results' => $results, 'Query' => $form->getSearchQuery(), 'Title' => _t('SearchForm.SearchResults', 'Search Results'));
     return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
 }
开发者ID:helpfulrobot,项目名称:entidi-silverstripe-gtkdoc,代码行数:37,代码来源:Gtkdoc.php

示例4: results

 /**
  * Process and render search results.
  *
  * @param array $data The raw request data submitted by user
  * @param SearchForm $form The form instance that was submitted
  * @param SS_HTTPRequest $request Request generated for this action
  */
 public function results($data, $form, $request)
 {
     $data = array('Results' => $form->getResults(), 'Query' => $form->getSearchQuery(), 'Title' => _t('SearchForm.SearchResults', 'Search Results'));
     return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:12,代码来源:ContentControllerSearchExtension.php

示例5: results

 /**
  * Overrides the ContentControllerSearchExtension and adds snippets to results.
  *
  * @param array $data
  * @param SearchForm $form
  * @param SS_HTTPRequest $request
  * @return HTMLText
  */
 function results($data, $form, $request)
 {
     $result = null;
     $results = $form->getResults();
     $query = $form->getSearchQuery();
     // Add context summaries based on the queries.
     foreach ($results as $result) {
         $contextualTitle = new Text();
         $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
         $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);
         if (!$result->Content && $result->ClassName == 'File') {
             // Fake some content for the files.
             $result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size}).";
         } else {
             // /(.?)\[embed(.*?)\](.+?)\[\/\s*embed\s*\](.?)/gi
             $valueField = $result->obj('Content');
             $valueField->setValue(ShortcodeParser::get_active()->parse($valueField->getValue()));
             $result->ContextualContent = $valueField->ContextSummary(300, $query);
         }
     }
     $rssLink = HTTP::setGetVar('rss', '1');
     // Render the result.
     $context = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink);
     // Choose the delivery method - rss or html.
     if (!$this->owner->request->getVar('rss')) {
         // Add RSS feed to normal search.
         RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\".");
         $result = $this->owner->customise($context)->renderWith(array('Page_results', 'Page'));
     } else {
         // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
         $fullList = $results->getList()->sort('LastEdited', 'DESC');
         // Get some descriptive strings
         $siteName = SiteConfig::current_site_config()->Title;
         $siteTagline = SiteConfig::current_site_config()->Tagline;
         if ($siteName) {
             $title = "{$siteName} search results for query \"{$query}\".";
         } else {
             $title = "Search results for query \"{$query}\".";
         }
         // Generate the feed content.
         $rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
         $rss->setTemplate('Page_results_rss');
         $result = $rss->outputToBrowser();
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-extensions,代码行数:54,代码来源:SSGuru_ContentController.php


注:本文中的SearchForm::getSearchQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。