Ejemplo n.º 1
0
 /** 更新用户的设备信息 */
 public static function setCurrentDeviceToken($deviceToken = '')
 {
     static::$Devicetoken = $deviceToken;
     HaoUtility::storeCookie('Devicetoken', $deviceToken);
 }
Ejemplo n.º 2
0
 /** 在结果中进行搜索,返回结果是数组(至少也是空数组) */
 public function search($path)
 {
     if ($this->searchIndexString == null) {
         $resultsIndex = HaoUtility::getKeyIndexArray(['results' => $this->results]);
         $extraInfoIndex = HaoUtility::getKeyIndexArray(['extraInfo' => $this->extraInfo]);
         $searchIndex = array_merge($resultsIndex, $extraInfoIndex);
         $this->searchIndexString = implode("\n", $searchIndex);
     }
     $path = trim($path);
     if (strpos($path, 'results>') !== 0 && strpos($path, 'extraInfo>') !== 0) {
         $path = 'results>' . $path;
     }
     $result = array();
     preg_match_all('/(^|\\s)(' . $path . ')($|\\s+)/', $this->searchIndexString, $matches);
     if (is_array($matches) && count($matches) >= 2) {
         foreach ($matches[2] as $pathMatched) {
             $result[] = $this->find($pathMatched);
         }
     }
     return $result;
 }