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


PHP AppCore::getSphinx方法代码示例

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


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

示例1: lookupText

 /**
  * Lookup something in the glossary
  * @since Version 3.9.1
  * @return \Railpage\Glossary\Entry
  */
 public function lookupText($text)
 {
     $cachekey = sprintf("railpage:glossary.lookup.text=%s", md5($text));
     if ($id = $this->Redis->fetch($cachekey)) {
         $Sphinx = AppCore::getSphinx();
         $query = $Sphinx->select("*")->from("idx_glossary")->match("short", $text);
         $matches = $query->execute();
         if (count($matches) === 0 && strpos($text, "-") !== false) {
             $query = $Sphinx->select("*")->from("idx_glossary")->match("short", str_replace("-", "", $text));
             $matches = $query->execute();
         }
         if (count($matches) === 1) {
             $id = $matches[0]['entry_id'];
             $this->Redis->save($cachekey, $id, strtotime("+1 year"));
         }
     }
     if (isset($id) && filter_var($id, FILTER_VALIDATE_INT)) {
         return new Entry($id);
     }
     return;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:26,代码来源:Glossary.php

示例2: getContributors

 /**
  * Get contributors of this locomotive
  * @since Version 3.7.5
  * @return array
  */
 public function getContributors()
 {
     $return = array();
     $Sphinx = AppCore::getSphinx();
     $query = $Sphinx->select("user_id", "username")->from("idx_logs")->match("module", "locos")->where("key", "=", "class_id")->where("value", "=", $this->id)->groupBy("user_id");
     $result = $query->execute();
     foreach ($result as $row) {
         $return[$row['user_id']] = $row['username'];
     }
     return $return;
     /*          
     $query = "SELECT DISTINCT l.user_id, u.username FROM log_general AS l LEFT JOIN nuke_users AS u ON u.user_id = l.user_id WHERE l.module = ? AND l.key = ? AND l.value = ?";
     
     foreach ($this->db->fetchAll($query, array("locos", "class_id", $this->id)) as $row) {
         $return[$row['user_id']] = $row['username']; 
     }
     
     return $return;
     */
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:25,代码来源:LocoClass.php

示例3: getContributors

 /**
  * Get contributors of this locomotive
  * @since Version 3.7.5
  * @return array
  */
 public function getContributors()
 {
     $key = sprintf(self::CACHE_KEY, $this->id) . ";contributors";
     if ($contributors = $this->Redis->fetch($key)) {
         return $contributors;
     }
     $return = array();
     $Sphinx = AppCore::getSphinx();
     $query = $Sphinx->select("user_id", "username")->from("idx_logs")->match("module", "locos")->where("key", "=", "loco_id")->where("value", "=", intval($this->id))->groupBy("user_id");
     $result = $query->execute();
     foreach ($result as $row) {
         $return[$row['user_id']] = $row['username'];
     }
     $this->Redis->save($key, $return, strtotime("+2 hours"));
     return $return;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:21,代码来源:Locomotive.php

示例4: GuessCoverPhoto

 /**
  * Find a suitable cover photo
  * @since Version 3.10.0
  * @param string|object $searchQuery
  * @return string
  */
 public static function GuessCoverPhoto($searchQuery)
 {
     $defaultPhoto = "https://static.railpage.com.au/i/logo-fb.jpg";
     $cachekey = sprintf("railpage:coverphoto=%s", md5($searchQuery));
     $Memcached = AppCore::getMemcached();
     #if ($image = $Memcached->fetch($cachekey)) {
     #   return $image;
     #}
     $SphinxQL = AppCore::getSphinx();
     if (!is_string($searchQuery)) {
         return $defaultPhoto;
     }
     preg_match_all('/([a-zA-Z]|\\xC3[\\x80-\\x96\\x98-\\xB6\\xB8-\\xBF]|\\xC5[\\x92\\x93\\xA0\\xA1\\xB8\\xBD\\xBE]){4,}/', $searchQuery, $match_arr);
     $word_arr = $match_arr[0];
     $words = implode(" || ", $word_arr);
     $SphinxQL->select()->from("idx_images")->match(array("title", "description"), $words, true);
     $rs = $SphinxQL->execute();
     if (!count($rs)) {
         return $defaultPhoto;
     }
     $photo = $rs[0];
     $photo['meta'] = json_decode($photo['meta'], true);
     $photo['sizes'] = Images::NormaliseSizes($photo['meta']['sizes']);
     foreach ($photo['sizes'] as $size) {
         if ($size['width'] > 400 && $size['height'] > 300) {
             $Memcached->save($cachekey, $size['source'], 0);
             return $size['source'];
         }
     }
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:36,代码来源:Finder.php


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