本文整理汇总了PHP中Thread::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::model方法的具体用法?PHP Thread::model怎么用?PHP Thread::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::model方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
/**
* This action displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id, $tab = 'Summary', $thread = null)
{
// Load crash report
$model = $this->loadModel($id);
// Check if user is authorized to perform the action
$this->checkAuthorization($model);
// Determine what tab to display
$activeItem = 'Summary';
if ($tab == 'Summary' || $tab == 'CustomProps' || $tab == 'Screenshots' || $tab == 'Videos' || $tab == 'Threads' || $tab == 'Modules' || $tab == 'Files') {
$activeItem = $tab;
}
$threadModel = null;
$stackTraceProvider = null;
if ($thread != null) {
$threadModel = Thread::model()->findByPk((int) $thread);
if ($threadModel == null) {
throw new CHttpException(403, 'Unexpected parameter.');
}
$criteria = new CDbCriteria();
$criteria->compare('thread_id', (int) $thread);
$criteria->order = 'id ASC';
$stackTraceProvider = new CActiveDataProvider('StackFrame', array('criteria' => $criteria, 'pagination' => false));
}
$customProps = $model->searchCustomProps();
$screenshots = $model->searchScreenshots();
$videos = $model->searchVideos();
$modules = $model->searchModules();
$threads = $model->searchThreads();
$this->render('view', array('model' => $model, 'activeItem' => $activeItem, 'thread' => (int) $thread, 'threadModel' => $threadModel, 'stackTrace' => $stackTraceProvider, 'customProps' => $customProps, 'screenshots' => $screenshots, 'videos' => $videos, 'modules' => $modules, 'threads' => $threads));
}
示例2: actionReadTopic
public function actionReadTopic($id)
{
$thread = Thread::model()->getThreadInfoById($id);
$this->forumBreadcrumb = array('Programs' => array('forum/index'), $thread['program_name'] => array('forum/programView', 'programId' => $thread['program_id']), $thread['semester_name'] => array('forum/viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id']), $thread['title'] < Yii::app()->params['forum_max_crumb_length'] ? $thread['title'] : substr($thread['title'], 0, Yii::app()->params['forum_max_crumb_length']) . '...');
$this->areaLarge = $thread['program_name'];
$this->areaSmall = $thread['semester_name'];
$reply = new Reply();
$complaint = new Complaint('postComplaint');
if (isset($_POST['Reply'])) {
$reply->attributes = $_POST['Reply'];
$reply->post_item_id = $id;
if ($reply->save()) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
$reply->unsetAttributes();
} else {
Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
}
}
if (isset($_POST['Complaint'])) {
$complaint->attributes = $_POST['Complaint'];
if ($complaint->save()) {
if ($complaint->post_item_id == $id) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
} else {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
}
$complaint->unsetAttributes();
} else {
Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
}
}
$dataProvider = Thread::model()->getPostsDataInThread($id);
Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
$this->render('view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
}
示例3: actionIndex
/**
* This is basically the "homepage" for the forums
* It'll show a list of root categories which forums in each
*/
public function actionIndex()
{
if (!isset($_GET['id'])) {
$forum = null;
if (!Yii::app()->user->isForumAdmin()) {
$criteria = array('order' => 'lastPost_time DESC', 'condition' => "is_hidden=0", 'distinct' => true, "group" => 't.id');
} else {
$criteria = array('order' => 'lastPost_time DESC', "group" => 't.id');
}
$data = new CActiveDataProvider('Thread', array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->controller->module->threadsPerPage)));
$menuItem = 0;
$breadcrumbs = array('Форум');
} else {
$forum = Forum::model()->findByPk($_GET['id']);
if (null == $forum) {
throw new CHttpException(404, 'The requested page does not exist.');
}
if ($forum->isCat) {
$this->redirect($this->createUrl("index"));
}
if (!Yii::app()->user->isForumAdmin()) {
$hidden = " AND is_hidden=0";
} else {
$hidden = "";
}
$data = new CActiveDataProvider('Thread', array('criteria' => array('condition' => 'forum_id=' . $forum->id . $hidden), 'pagination' => array('pageSize' => Yii::app()->controller->module->threadsPerPage)));
$menuItem = $forum->id;
$breadcrumbs = $forum->getBreadcrumbs();
}
$this->render('index', array('forums' => Thread::model()->findAll(), "data" => $data, "menuItem" => $menuItem, "breadcrumbs" => $breadcrumbs, 'forum' => $forum));
}
示例4: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$dataProvider = Thread::model()->lastNew();
$this->render('index', array('dataProvider' => $dataProvider));
}
示例5: testGetThreadFuncName
public function testGetThreadFuncName()
{
// Find an existing thread
$thread = Thread::model()->findByPk(1);
$funcName = $thread->getThreadFuncName();
$this->assertTrue($funcName == '_WinMainCRTStartup()');
}
示例6: countThread
/**
* @param kategori id
* @return jumlah thread per kategori
*/
public function countThread($id)
{
$cr = new CDbCriteria();
$cr->with = 'kategori';
$cr->condition = 'kategori_id=:id';
$cr->params = array(':id' => $id);
return Thread::model()->count($cr);
}
示例7: actionDeleteThread
public function actionDeleteThread($id)
{
//$thread = new Thread;
$thread = Thread::model()->findByPk($id);
if ($thread->delete()) {
Yii::app()->user->setFlash('success', "Thread {$thread->primaryKey} deleted");
} else {
Yii::app()->user->setFlash('error', "Problem removing thread");
}
$this->redirect(array('myTopics'));
}
示例8: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Thread the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Thread::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例9: getLastPost
/**
* Return the last post in any of the threads in this forum (or null)
*/
public function getLastPost()
{
// There's gotta be an easier, or at least more direct way to do this
$id = Yii::app()->db->createCommand()->select('p.id')->from(Post::model()->tableName() . ' p')->join(Thread::model()->tableName() . ' t', 't.id=p.thread_id')->where('t.forum_id=:id', array(':id' => $this->id))->order('p.created DESC')->limit(1)->queryScalar();
return Post::model()->findByPk($id);
}
示例10: getJudul
public function getJudul()
{
return CHtml::listData(Thread::model()->with('comments')->findAll(), 'id', 'judul');
}
示例11: actionRe
public function actionRe()
{
$threads = Thread::model()->findAll();
foreach ($threads as $item) {
$item->author_id = $item->firstPost->author_id;
$item->created = $item->firstPost->created;
$item->lastPost_user_id = $item->lastPost->author_id;
$item->lastPost_time = $item->lastPost->created;
$item->post_count = $item->postCountInternal;
$item->save();
}
}