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


PHP Kronolith::addSearchEvents方法代码示例

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


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

示例1: searchEvents

 /**
  * TODO
  */
 public function searchEvents()
 {
     $query = Horde_Serialize::unserialize($this->vars->query, Horde_Serialize::JSON);
     if (!isset($query->start)) {
         $query->start = new Horde_Date($_SERVER['REQUEST_TIME']);
     }
     if (!isset($query->end)) {
         $query->end = null;
     }
     switch ($this->vars->time) {
         case 'all':
             $query->start = null;
             $query->end = null;
             break;
         case 'future':
             $query->start = new Horde_Date($_SERVER['REQUEST_TIME']);
             $query->end = null;
             break;
         case 'past':
             $query->start = null;
             $query->end = new Horde_Date($_SERVER['REQUEST_TIME']);
             break;
     }
     $tagger = new Kronolith_Tagger();
     $cals = Horde_Serialize::unserialize($this->vars->cals, Horde_Serialize::JSON);
     $events = array();
     foreach ($cals as $cal) {
         if (!($kronolith_driver = $this->_getDriver($cal))) {
             continue;
         }
         try {
             $result = $kronolith_driver->search($query, true);
             if ($result) {
                 $events[$cal] = $result;
             }
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e, 'horde.error');
         }
         $split = explode('|', $cal);
         if ($split[0] == 'internal') {
             $result = $tagger->search($query->title, array('type' => 'event', 'calendar' => $split[1]));
             foreach ($result['events'] as $uid) {
                 Kronolith::addSearchEvents($events[$cal], $kronolith_driver->getByUID($uid), $query, true);
             }
         }
     }
     $result = new stdClass();
     $result->view = 'search';
     $result->query = $this->vars->query;
     if ($events) {
         $result->events = $events;
     }
     return $result;
 }
开发者ID:kossamums,项目名称:horde,代码行数:57,代码来源:Handler.php

示例2: search

 /**
  * Searches a calendar.
  *
  * @param object $query  An object with the criteria to search for.
  * @param boolean $json  Store the results of the events' toJson() method?
  *
  * @return mixed  An array of Kronolith_Events.
  * @throws Kronolith_Exception
  */
 public function search($query, $json = false)
 {
     /* Build SQL conditions based on the query string. */
     $cond = '((';
     $values = array();
     foreach (array('title', 'location', 'url', 'description') as $field) {
         if (!empty($query->{$field})) {
             $binds = $this->_db->buildClause('event_' . $field, 'LIKE', $this->convertToDriver($query->{$field}), true);
             if (is_array($binds)) {
                 $cond .= $binds[0] . ' AND ';
                 $values = array_merge($values, $binds[1]);
             } else {
                 $cond .= $binds;
             }
         }
     }
     if (!empty($query->baseid)) {
         $binds = $this->_db->buildClause('event_baseid', '=', $query->baseid, true);
         if (is_array($binds)) {
             $cond .= $binds[0] . ' AND ';
             $values = array_merge($values, $binds[1]);
         } else {
             $cond .= $binds;
         }
     }
     if (isset($query->status)) {
         $binds = $this->_db->buildClause('event_status', '=', $query->status, true);
         if (is_array($binds)) {
             $cond .= $binds[0] . ' AND ';
             $values = array_merge($values, $binds[1]);
         } else {
             $cond .= $binds;
         }
     }
     if (!empty($query->creator)) {
         $binds = $this->_db->buildClause('event_creator_id', '=', $query->creator, true);
         if (is_array($binds)) {
             $cond .= $binds[0] . ' AND ';
             $values = array_merge($values, $binds[1]);
         } else {
             $cond .= $binds;
         }
     }
     if ($cond == '((') {
         $cond = '';
     } else {
         $cond = substr($cond, 0, strlen($cond) - 5) . '))';
     }
     $eventIds = $this->_listEventsConditional(empty($query->start) ? null : $query->start, empty($query->end) ? null : $query->end, $cond, $values);
     $events = array();
     foreach ($eventIds as $eventId) {
         Kronolith::addSearchEvents($events, $this->getEvent($eventId), $query, $json);
     }
     return $events;
 }
开发者ID:horde,项目名称:horde,代码行数:64,代码来源:Sql.php


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