本文整理汇总了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')));
}
}
示例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));
}
示例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";