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


PHP SearchEngine::IndexBug方法代码示例

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


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

示例1: Fire

 public function Fire()
 {
     if ($this->input->do == 'submit') {
         $bug = new Bug($this->input->bug_id);
         try {
             $bug->FetchInto();
         } catch (phalanx\data\ModelException $e) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('BUG_ID_NOT_FOUND')));
             return;
         }
         $body = trim($this->input->body);
         if (empty($body)) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('COMMENT_MISSING_BODY')));
             return;
         }
         $comment = new Comment();
         $comment->bug_id = $bug_id;
         $comment->post_user_id = Bugdar::$auth->current_user();
         $comment->post_date = time();
         $comment->body = $body;
         $comment->Insert();
         $this->comment_id = $comment->comment_id;
         $search = new SearchEngine();
         $search->IndexBug($bug);
         EventPump::Pump()->PostEvent(new StandardSuccessEvent('view_bug/' . $bug_id, l10n::S('USER_REGISTER_SUCCESS')));
     }
 }
开发者ID:rsesek,项目名称:Bugdar2,代码行数:27,代码来源:comment_new.php

示例2: Fire


//.........这里部分代码省略.........
     $user = Bugdar::$auth->current_user();
     $title = trim($this->input->title);
     if (empty($title) && $do_insert) {
         EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('BUG_MISSING_TITLE')));
         return;
     }
     Bugdar::$db->BeginTransaction();
     $now = time();
     if (!empty($title)) {
         $bug->title = $title;
     }
     if ($do_insert) {
         $bug->reporting_user_id = $user->user_id;
         $bug->reporting_date = $now;
         $bug->Insert();
     } else {
         if ($do_update) {
             $bug->Update();
         }
     }
     // Now set the bug_id output value, which will be set after a call to
     // Insert().  Updated bugs will have this set from FetchInto().
     $this->bug_id = $bug->bug_id;
     // Add a comment if one is present.
     $body = trim($this->input->comment_body);
     if (!empty($body) || $do_insert) {
         if ($do_insert && empty($body)) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('COMMENT_MISSING_BODY')));
             return;
         }
         $comment = new Comment();
         $comment->bug_id = $this->bug_id;
         $comment->post_user_id = $user->user_id;
         $comment->post_date = $now;
         $comment->body = $body;
         $comment->Insert();
         $this->comment_id = $comment->comment_id;
         // Update the bug so it can find that first comment easiliy.
         if ($do_insert) {
             $bug = new Bug($bug->bug_id);
             $bug->first_comment_id = $comment->comment_id;
             $bug->Update();
             $bug->FetchInto();
         }
     }
     // Handle tags.
     if (is_array($this->input->tags_new)) {
         foreach ($this->input->tags_new as $tag) {
             $bug->SetAttribute('', $tag);
         }
     }
     if (is_array($this->input->tags_deleted)) {
         foreach ($this->input->tags_deleted as $tag) {
             $bug->RemoveAttribute($tag, TRUE);
         }
     }
     // Create a map of all the set attributes.
     $set_attributes = array();
     if (is_array($this->input->attributes)) {
         foreach ($this->input->attributes as $attr) {
             // If this is an empty attribute, ignore it.
             if (empty($attr['title']) || empty($attr['value'])) {
                 continue;
             }
             $set_attributes[$attr['title']] = $attr['value'];
         }
         // Get all potential attributes; this includes defined tags.
         $attributes = Attribute::FetchGroup();
         foreach ($attributes as $attr) {
             // If the user is allowed to write to this attribute, update the
             // value.
             if ($attr->is_attribute() && $attr->CheckAccess($user, $bug) & Attribute::ACCESS_WRITE) {
                 // If there is no value for this attribute, then it was removed.
                 if (!isset($set_attributes[$attr->title])) {
                     $bug->RemoveAttribute($attr->title, $attr->is_tag());
                     continue;
                 }
                 // Otherwise, update the value.
                 $validate = $attr->Validate($set_attributes[$attr->title]);
                 if ($validate[0]) {
                     $bug->SetAttribute($attr->title, $validate[1]);
                     unset($set_attributes[$attr->title]);
                 }
             }
         }
         // Any remaining set_attributes are not formally defined.  If the user
         // has permission to set ad-hoc attributes, do so.
         if (TRUE) {
             // TODO: check permission
             foreach ($set_attributes as $title => $value) {
                 $bug->SetAttribute($title, $value);
             }
         }
     }
     Bugdar::$db->Commit();
     $search = new SearchEngine();
     $search->IndexBug($bug);
     $string = $do_insert ? l10n::S('BUG_CREATED_SUCCESSFULLY') : l10n::S('BUG_EDIT_SUCCESS');
     EventPump::Pump()->PostEvent(new StandardSuccessEvent('view_bug/' . $this->bug_id, $string));
 }
开发者ID:rsesek,项目名称:Bugdar2,代码行数:101,代码来源:bug_edit.php

示例3: getcwd

// This program 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
// this program.  If not, see <http://www.gnu.org/licenses/>.
// This script will re-index the search system. It is meant to be run at
// the TOP LEVEL of Bugdar's directory.
define('BUGDAR_ROOT', getcwd());
define('PHALANX_ROOT', BUGDAR_ROOT . '/phalanx');
require_once BUGDAR_ROOT . '/includes/core.php';
require_once BUGDAR_ROOT . '/includes/search_engine.php';
// Load the database.
$config = new phalanx\base\KeyDescender(require BUGDAR_ROOT . '/includes/config.php');
Bugdar::BootstrapDatabase($config);
// This is going to take a while...
set_time_limit(0);
ini_set('max_execution_time', 0);
// Destroy the old index and create a new one.
echo 'Destroying old index for ' . BUGDAR_ROOT . "\n";
exec('rm -rf ' . BUGDAR_ROOT . '/cache/lucene_index');
clearstatcache();
echo 'New index created' . "\n";
$search = new SearchEngine();
$bugs = Bugdar::$db->Query("SELECT * FROM " . TABLE_PREFIX . "bugs");
while ($bug = $bugs->FetchObject()) {
    $search->IndexBug($bug);
    echo ".";
}
echo "\nDone!\n";
开发者ID:rsesek,项目名称:Bugdar2,代码行数:31,代码来源:reindex-search.php


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