本文整理汇总了PHP中Thread::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::create方法的具体用法?PHP Thread::create怎么用?PHP Thread::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create new Thread and should be with Comment/s
* $username is not same with session username
*/
public function create()
{
$thread = new Thread();
$comment = new Comment();
$page = Param::get('page_next', 'create');
switch ($page) {
case 'create':
break;
case 'create_end':
try {
$thread->id = Param::get('thread_id');
$thread->user_id = User::getId($_SESSION['username']);
$thread->title = Param::get('title');
$comment->username = Param::get('username');
$comment->body = Param::get('body');
$thread->create($comment);
} catch (ValidationException $e) {
$page = 'create';
}
break;
default:
throw new PageNotFoundException("{$page} is not found");
break;
}
$this->set(get_defined_vars());
$this->render($page);
}
示例2: post_create
public function post_create()
{
$posts = Input::all();
$title = $posts['thread_name'];
$contentRaw = $posts['inputarea'];
if ($title != '' && strlen($contentRaw) > 10) {
$alias = Str::slug($title, '-');
$exist = Thread::where('alias', '=', $alias)->first();
if ($exist != null) {
return Redirect::to($exist->id);
}
$threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
$thread = Thread::create($threadData);
if ($thread != null) {
$content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
$postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
$pst = Post::create($postData);
if ($pst != null) {
return Redirect::to($thread->id);
}
}
} else {
return Redirect::to(URL::full());
}
}
示例3: create
public function create()
{
$thread = new Thread();
$comment = new Comment();
$page = Param::get('page_next', 'create');
$user_id = get_authenticated_user_id($_SESSION['userid']);
switch ($page) {
case self::CREATE_PAGE:
break;
case self::PAGE_AFTER_CREATE:
$thread->title = Param::get('title');
$thread->user_id = $user_id;
$thread->category = Param::get('category');
$comment->user_id = $user_id;
$comment->body = Param::get('body');
try {
$thread->create($comment);
} catch (ValidationException $e) {
$page = self::CREATE_PAGE;
}
break;
default:
throw new RecordNotFoundException("{$page} is not found");
}
if ($page === self::PAGE_AFTER_CREATE) {
redirect(VIEW_COMMENT_PAGE, array('thread_id' => $comment->id));
}
$this->set(get_defined_vars());
$this->render($page);
}
示例4: create
public function create()
{
redirect_guest_user(LOGIN_URL);
$thread = new Thread();
$comment = new Comment();
$page = Param::get('page_next', 'create');
$auth_user = User::getAuthenticated();
$categories = Category::getAll();
switch ($page) {
case 'create':
break;
case 'create_end':
$thread->title = trim_collapse(Param::get('title'));
$thread->category_id = Param::get('category');
$thread->user_id = $auth_user->id;
$comment->user_id = $auth_user->id;
$comment->body = trim(Param::get('body'));
$db = DB::conn();
try {
$db->begin();
$thread->create($comment);
$follow = new Follow();
$follow->thread_id = $thread->id;
$follow->user_id = $auth_user->id;
$follow->last_comment = Comment::getFirstInThread($thread)->id;
$follow->create();
$db->commit();
redirect(VIEW_THREAD_URL, array('id' => $thread->id));
} catch (ValidationException $e) {
$page = 'create';
$db->rollback();
} catch (CategoryException $e) {
$thread->validation_errors['category']['exists'] = true;
$page = 'create';
$db->rollback();
}
break;
default:
throw new PageNotFoundException("{$page} is not found");
break;
}
$title = 'Create Thread';
$this->set(get_defined_vars());
$this->render($page);
}
示例5: createRSS
public static function createRSS()
{
// begin
if ($_SESSION[KEY_SESSION][Account::KEY_USERNAME] == "guest") {
Utils::showNoPermissionPage();
die;
}
// end
$error_message = "";
$title = "";
$url = "";
if (!empty($_POST)) {
$title = $_POST["title"];
$url = $_POST["url"];
if (empty($title)) {
$error_message .= "<li>タイトルを空白にしないでください。</li>";
}
if (empty($url)) {
$error_message .= "<li>URLを空白にしないでください。</li>";
} else {
if (!preg_match("/^https?:\\/\\//", $url)) {
$error_message .= "<li>URLは正しくありません。</li>";
}
}
// if not error, there should be no error_message
if (strlen($error_message) == 0) {
$json = json_encode(array("title" => $title, "url" => $url, "version" => 1));
$host_id = $_SESSION[KEY_SESSION][Account::KEY_ID];
$update_time = Utils::getCurrentTime();
$update_date = Utils::getCurrentDate();
$latest_update = time();
$content = "<script>{$json}</script>";
$permission = $_POST["permission"];
$last_created_id = Thread::create($host_id, $title, $update_time, $update_date, $latest_update, $content, "rss", $permission);
header("Location: /thread/" . $last_created_id);
die;
}
}
$content = "create-rss.php";
Utils::output_view(["private-nav.php", "thread/thread.php"], ["content" => $content]);
}
示例6: newPostMetadataUpdates
static function newPostMetadataUpdates($data)
{
$requiredFields = array('talkpage', 'root', 'text', 'subject');
foreach ($requiredFields as $f) {
if (!isset($data[$f])) {
throw new Exception("Missing required field {$f}");
}
}
if (isset($data['signature'])) {
$signature = $data['signature'];
} else {
global $wgUser;
$signature = LqtView::getUserSignature($wgUser);
}
$summary = isset($data['summary']) ? $data['summary'] : '';
$talkpage = $data['talkpage'];
$root = $data['root'];
$subject = $data['subject'];
$thread = Thread::create($root, $talkpage, null, Threads::TYPE_NORMAL, $subject, $summary, null, $signature);
Hooks::run('LiquidThreadsAfterNewPostMetadataUpdates', array(&$thread));
return $thread;
}
示例7: leaveTrace
function leaveTrace($reason, $oldTitle, $newTitle)
{
$this->dieIfHistorical();
// Create redirect text
$mwRedir = MagicWord::get('redirect');
$redirectText = $mwRedir->getSynonym(0) . ' [[' . $this->title()->getPrefixedText() . "]]\n";
// Make the article edit.
$traceTitle = Threads::newThreadTitle($this->subject(), new Article($oldTitle));
$redirectArticle = new Article($traceTitle);
$redirectArticle->doEdit($redirectText, $reason, EDIT_NEW | EDIT_SUPPRESS_RC);
// Add the trace thread to the tracking table.
$thread = Thread::create($redirectArticle, new Article($oldTitle), null, Threads::TYPE_MOVED, $this->subject());
$thread->setSortkey($this->sortkey());
$thread->save();
}
示例8: afterImportPage
/**
* Processes discussion threading data in XML dumps (extracted in handlePageXMLTag).
*
* @param $title Title
* @param $origTitle Title
* @param $revCount
* @param $sRevCount
* @param $pageInfo
* @return bool
*/
public static function afterImportPage($title, $origTitle, $revCount, $sRevCount, $pageInfo)
{
// in-process cache of pending thread relationships
static $pendingRelationships = null;
if ($pendingRelationships === null) {
$pendingRelationships = self::loadPendingRelationships();
}
$titlePendingRelationships = array();
if (isset($pendingRelationships[$title->getPrefixedText()])) {
$titlePendingRelationships = $pendingRelationships[$title->getPrefixedText()];
foreach ($titlePendingRelationships as $k => $v) {
if ($v['type'] == 'article') {
self::applyPendingArticleRelationship($v, $title);
unset($titlePendingRelationships[$k]);
}
}
}
if (!isset($pageInfo['DiscussionThreading'])) {
return true;
}
$statusValues = array_flip(self::$editedStati);
$typeValues = array_flip(self::$threadTypes);
$info = $pageInfo['DiscussionThreading'];
$root = new Article($title, 0);
$article = new Article(Title::newFromText($info['ThreadPage']), 0);
$type = $typeValues[$info['ThreadType']];
$subject = $info['ThreadSubject'];
$summary = wfMessage('lqt-imported')->inContentLanguage()->text();
$signature = null;
if (isset($info['ThreadSignature'])) {
$signature = $info['ThreadSignature'];
}
$thread = Thread::create($root, $article, null, $type, $subject, $summary, null, $signature);
if (isset($info['ThreadSummaryPage'])) {
$summaryPageName = $info['ThreadSummaryPage'];
$summaryPage = new Article(Title::newFromText($summaryPageName), 0);
if ($summaryPage->exists()) {
$thread->setSummaryPage($summaryPage);
} else {
self::addPendingRelationship($thread->id(), 'thread_summary_page', $summaryPageName, 'article', $pendingRelationships);
}
}
if (isset($info['ThreadParent'])) {
$threadPageName = $info['ThreadParent'];
$parentArticle = new Article(Title::newFromText($threadPageName), 0);
$superthread = Threads::withRoot($parentArticle);
if ($superthread) {
$thread->setSuperthread($superthread);
} else {
self::addPendingRelationship($thread->id(), 'thread_parent', $threadPageName, 'thread', $pendingRelationships);
}
}
$thread->save();
foreach ($titlePendingRelationships as $k => $v) {
if ($v['type'] == 'thread') {
self::applyPendingThreadRelationship($v, $thread);
unset($titlePendingRelationships[$k]);
}
}
return true;
}
示例9: __construct
function __construct($commands)
{
$this->commands = $commands;
foreach ($this->commands as $key => $command) {
$this->thread[$key] = Thread::create($command);
}
}