本文整理汇总了PHP中Comment::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::search方法的具体用法?PHP Comment::search怎么用?PHP Comment::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::search方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$type = Param::get('type', self::TYPE_THREAD);
$query = trim_collapse(Param::get('query'));
$page = Param::get('page', 1);
$pagination = new SimplePagination($page, self::RESULTS_PERPAGE);
if (!$query) {
redirect(APP_URL);
}
$results = new stdClass();
switch ($type) {
case self::TYPE_THREAD:
$results = Thread::search($query, $pagination->start_index - 1, $pagination->count + 1);
// Get other info for each thread
foreach ($results->result as $thread) {
$thread->creator = User::getByID($thread->user_id);
$thread->category = Category::getName($thread->category_id);
$thread->replies_count = Comment::countAll($thread->id);
}
break;
case self::TYPE_COMMENT:
$results = Comment::search($query, $pagination->start_index - 1, $pagination->count + 1);
break;
case self::TYPE_USER:
$results = User::search($query, $pagination->start_index - 1, $pagination->count + 1);
break;
default:
throw new PageNotFoundException();
break;
}
$pagination->checkLastPage($results->result);
$pages = ceil($results->total_result / self::RESULTS_PERPAGE);
$title = "Search: '{$query}'";
$this->set(get_defined_vars());
}
示例2: actionIndex
/**
* Display all site comments
*/
public function actionIndex()
{
$model = new Comment('search');
if (!empty($_GET['Comment'])) {
$model->attributes = $_GET['Comment'];
}
$dataProvider = $model->search();
$dataProvider->pagination->pageSize = Yii::app()->settings->get('core', 'productsPerPageAdmin');
$this->render('index', array('model' => $model, 'dataProvider' => $dataProvider));
}
示例3: index
/**
* @file index
* @author ryan <cumt.xiaochi@gmail.com>
* @created Jun 27, 2012 6:24:01 PM
*/
function index()
{
$recentTeachers = Teacher::search()->orderBy('touched DESC')->find();
$recentComments = Comment::search()->OrderBy('id DESC')->find();
$data = compact('recentTeachers', 'recentCourses', 'recentComments');
if ($GLOBALS['has_login']) {
$timelines = Timeline::search()->filterBy('user', $GLOBALS['user'])->find();
$data['timelines'] = $timelines;
}
render_view('master', $data);
}
示例4: teacher_GET
/**
* @author ryan <cumt.xiaochi@gmail.com>
*/
function teacher_GET($id)
{
$teacher = new Teacher($id);
$comments = Comment::search()->filterBy('teacher', $id)->find();
$has_login = $GLOBALS['has_login'];
if ($has_login) {
$teacher->commentedByMe = $teacher->commentedByUser($GLOBALS['user']);
}
$schools = $GLOBALS['config']['school'];
render_view('master', compact('teacher', 'courses', 'comments', 'has_login', 'schools'));
}
示例5: actionIndex
public function actionIndex() {
$model = new Comment('search');
$model->unsetAttributes();
if(!empty($_GET['Comment']))
$model->attributes = $_GET['Comment'];
$criteria = new CDbCriteria;
$criteria->condition = 'id_parent is null';
$dataProvider = $model->search($criteria);
$dataProvider->pagination->pageSize = 25;
$this->render('index', array(
'model'=>$model,
'dataProvider'=>$dataProvider
));
}
示例6: render_main_page_area
function render_main_page_area($user)
{
global $admin_password;
$page_url = PA::$url . "/comment_management.php";
$paging_url = "{$page_url}?";
// url to pass to the pager object
$msg = "";
$path_info = @$_SERVER['PATH_INFO'];
// see if the user is logged in as an admin
if ($path_info == "/login") {
if (@$_REQUEST['admin_password'] == $admin_password) {
$_SESSION['comment_management_is_admin'] = TRUE;
} else {
$msg = "Incorrect password! Try again...";
}
} else {
if ($path_info == "/logout") {
$_SESSION['comment_management_is_admin'] = FALSE;
$msg = "You are now logged out (of admin mode).";
}
}
$is_admin = @$_SESSION['comment_management_is_admin'];
$limit_set = NULL;
// set this to an array with keys 'comment_id' to limit display to those keys
$current_search_terms = NULL;
// current search terms
switch ($path_info) {
case '/analyze_comment':
$comment_id = (int) @$_REQUEST['comment'];
if (!$is_admin) {
$msg = "Sorry, only administrators can analyze comments at the moment :(";
} elseif ($comment_id) {
$cmt = new Comment();
$cmt->load($comment_id);
$cmt->index_spam_domains();
$msg = "<p>Analysis of comment {$comment_id}:</p><hr/><p>" . nl2br(htmlspecialchars($cmt->comment)) . "</p><hr/><ul>";
$hosts = $cmt->get_link_hosts();
foreach ($hosts as $domain => $links) {
$msg .= "<li><b>" . htmlspecialchars($domain) . "</b> (<a href=\"{$page_url}/analyze_domain?domain=" . htmlspecialchars($domain) . "\">analyze</a>): ";
$dom = new SpamDomain($domain);
if ($dom->blacklisted) {
$msg .= " BLACKLISTED";
}
$msg .= "<ul>";
foreach ($links as $link) {
list($url, $linktexts) = $link;
$msg .= "<li>" . htmlspecialchars($url) . " -> " . implode(" | ", array_map("htmlspecialchars", $linktexts)) . "</li>";
}
$msg .= "</ul></li>";
}
$msg .= "</ul><hr/>";
}
break;
case '/search':
$current_search_terms = @$_REQUEST['q'];
if (!$is_admin) {
$msg = "Sorry, only administrators can search comments at the moment :(";
} elseif ($current_search_terms) {
$paging_url = "{$page_url}/search?q=" . urlencode($current_search_terms) . "&";
$limit_set = Comment::search($current_search_terms);
}
break;
case '/stats':
$msg = "<p>Stats:</p>";
list($n) = Dal::query_one("SELECT COUNT(*) FROM {comments}");
list($n_deleted) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0");
$n_active = $n - $n_deleted;
$msg .= "<li>{$n} comments ({$n_active} active / {$n_deleted} deleted)</li>";
list($n_ham) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND spam_state=0");
$n_spam = $n_active - $n_ham;
$msg .= "<li>{$n_spam} active+spam / {$n_ham} active+not spam</li>";
list($n_no_class) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND akismet_spam IS NULL");
$msg .= "<li>{$n_no_class} active comments not (yet?) classified by Akismet</li>";
list($n_akismet_del) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0 AND akismet_spam=1");
$msg .= "<li>{$n_akismet_del} comments flagged as spam by akismet and deleted</li>";
break;
case '/add_spam_term':
$spam_term = @$_REQUEST['term'];
if (!$is_admin) {
$msg = "Sorry, only administrators can add spam terms at the moment.";
} elseif ($spam_term) {
// find the comments
$matches = Comment::search($spam_term);
$n_deleted = count($matches);
// add the term
Comment::add_spam_term($spam_term);
// and delete the comments
$blk_size = 1000;
$F_fetch_ids = create_function('$item', 'return $item["comment_id"];');
for ($i = 0; $i < count($matches); $i += $blk_size) {
Comment::set_spam_state(array_map($F_fetch_ids, array_slice($matches, $i, $blk_size)), SPAM_STATE_SPAM_WORDS);
}
$msg = "Added <b>" . htmlspecialchars($spam_term) . '</b> to the spam term database, and deleted ' . $n_deleted . ' comments containing it.';
}
break;
case '/analyze_domain':
$domain = @$_REQUEST['domain'];
if (!$is_admin) {
$msg = "Sorry, only administrators can analyze domains.";
} else {
//.........这里部分代码省略.........
示例7: Comment
<?php
/**
* Product comments
*
* @var $model StoreProduct
*/
Yii::import('comments.models.Comment');
$module = Yii::app()->getModule('comments');
$comments = new Comment('search');
if (!empty($_GET['Comment'])) {
$comments->attributes = $_GET['Comment'];
}
$comments->class_name = 'application.modules.store.models.StoreProduct';
$comments->object_pk = $model->id;
// Fix sort url
$dataProvider = $comments->search();
$dataProvider->pagination->pageSize = Yii::app()->settings->get('core', 'productsPerPageAdmin');
$dataProvider->sort->route = 'applyCommentsFilter';
$dataProvider->pagination->route = 'applyCommentsFilter';
$this->widget('ext.sgridview.SGridView', array('dataProvider' => $dataProvider, 'id' => 'productCommentsListGrid', 'filter' => $comments, 'ajaxUrl' => Yii::app()->createUrl('/store/admin/products/applyCommentsFilter', array('id' => $model->id)), 'enableHistory' => false, 'columns' => array(array('class' => 'CCheckBoxColumn'), array('class' => 'SGridIdColumn', 'name' => 'id'), array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("/comments/admin/comments/update", "id"=>$data->id))'), array('name' => 'email'), array('name' => 'text', 'value' => 'Comment::truncate($data, 100)'), array('name' => 'status', 'filter' => Comment::getStatuses(), 'value' => '$data->statusTitle'), array('name' => 'created'), array('class' => 'CButtonColumn', 'updateButtonUrl' => 'Yii::app()->createUrl("/comments/admin/comments/update", array("id"=>$data->id))', 'deleteButtonUrl' => 'Yii::app()->createUrl("/comments/admin/comments/delete", array("id"=>$data->id))', 'template' => '{update}{delete}'))));
示例8: user_GET
/**
* @author ryan <cumt.xiaochi@gmail.com>
*/
function user_GET($id)
{
$user = new User($id);
$comments = Comment::search()->filterBy('user', $user)->find();
render_view('master', compact('user', 'comments'));
}
示例9: comments
public function comments()
{
return Comment::search()->filterBy('course', $this)->find();
}
示例10: Comment
<div class="comment-block">
<h2>Comments</h2>
<div class="list">
<?php
$model = new Comment();
$model->pageId = $page->pageId;
$this->widget('zii.widgets.CListView', array('id' => 'comment-list', 'dataProvider' => $model->search(), 'itemView' => 'application.views.comment._view'));
?>
</div>
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'comment-form', 'enableAjaxValidation' => true, 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true)));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php
echo $form->errorSummary($model);
?>
<?php
echo $form->hiddenField($model, 'pageId');
?>
<div class="row">
<?php
echo $form->labelEx($model, 'name');
?>
<?php
echo $form->textField($model, 'name');