本文整理汇总了PHP中Topic类的典型用法代码示例。如果您正苦于以下问题:PHP Topic类的具体用法?PHP Topic怎么用?PHP Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Topic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave($options = array())
{
//parent::beforeSave($options);
//print_r($this->data);
$loggedInUser = AuthComponent::user();
$found = false;
$userId = $loggedInUser['user_id'];
$this->data['Post']['post_by'] = $userId;
$this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d');
//format('Y-m-d H:i:s')
if (!empty($this->data['Topic']['topic_subject'])) {
$str = $this->data['Topic']['topic_subject'];
$num = $this->data['Post']['post_cat'];
$subject = new Topic();
$found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num)));
if (!$found) {
$subject->create();
//create topic
$subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId));
//see also save associated model method cakephp
$this->data['Post']['post_topic'] = $this->Topic->getLastInsertId();
return true;
}
$this->data['Post']['post_topic'] = $found['Topic']['topic_id'];
return true;
}
//nothing
return true;
}
示例2: run
public function run()
{
$table = $this->getTable();
$title = 'Lorem ipsum dolor sit amet';
$topic = new Topic(['title' => $title]);
$topic->save();
}
示例3: delete_category
function delete_category($params = array(), $param_op = 'AND')
{
$categories = $this->select_record($params, array('id'), $param_op);
$topic = new Topic($this->config);
foreach ($categories as $category) {
$topic->delete_record(array('category' => $category['id']));
}
$this->delete_record($params);
}
示例4: DropTables
function DropTables()
{
$moderator = new Moderator();
$moderator->SetDatabase($this);
$moderator->Drop();
$message = new Message();
$message->SetDatabase($this);
$message->Drop();
$topic = new Topic();
$topic->SetDatabase($this);
$topic->Drop();
$user_info = new UserInfo();
$user_info->SetDatabase($this);
$user_info->Drop();
$session = new Session();
$session->SetDatabase($this);
$session->Drop();
$new = new News();
$new->SetDatabase($this);
$new->Drop();
$shout = new Shout();
$shout->SetDatabase($this);
$shout->Drop();
$paragraph = new Paragraph();
$paragraph->SetDatabase($this);
$paragraph->Drop();
$privilege = new Privilege();
$privilege->SetDatabase($this);
$privilege->Drop();
$role = new Role();
$role->SetDatabase($this);
$role->Drop();
$menu_item = new MenuItem();
$menu_item->SetDatabase($this);
$menu_item->Drop();
$module = new Module();
$module->SetDatabase($this);
$module->Drop();
$page = new Page();
$page->SetDatabase($this);
$page->Drop();
$article = new Article();
$article->SetDatabase($this);
$article->Drop();
$subject = new Subject();
$subject->SetDatabase($this);
$subject->Drop();
$menu = new Menu();
$menu->SetDatabase($this);
$menu->Drop();
$profile = new Profile();
$profile->SetDatabase($this);
$profile->Drop();
$user = new User();
$user->SetDatabase($this);
$user->Drop();
}
示例5: addTopic
function addTopic($topic_ancestor_id, $topic_name)
{
$ancestor_object = TopicQuery::create()->findOneById($topic_ancestor_id);
$topic_object = new Topic();
$topic_object->setName($topic_name)->insertAsLastDescendantOf($ancestor_object)->save();
$topic_synonym_object = new TopicSynonym();
$topic_synonym_object->setName($topic_name)->setTopic($topic_object)->save();
return $topic_object->getId();
}
示例6: addTopicToTest
function addTopicToTest($id = 1)
{
$toc = new Topic();
$toc->get_by_id($id);
$t = new Test();
$t->get_by_id(2);
if ($t->save($toc)) {
echo $toc->to_json();
}
}
示例7: PostTopic
/**
* This will post a new Topic for this forum along with the topic's first / initial message.
*
* @param string $strTitle
* @param string $strMessageText
* @param Person $objPerson
* @param QDateTime $dttPostDate
* @return Topic
*/
public function PostTopic($strTitle, $strFirstMessageText, Person $objPerson, QDateTime $dttPostDate = null)
{
$objTopic = new Topic();
$objTopic->TopicLink = $this->TopicLink;
$objTopic->Name = $strTitle;
$objTopic->Person = $objPerson;
$objTopic->Save();
$objTopic->PostMessage($strFirstMessageText, $objPerson, $dttPostDate);
return $objTopic;
}
示例8: delete
public function delete(Topic $topic)
{
$id = $topic->getId();
$query = "DELETE FROM topic WHERE id='" . $id . "'";
$res = mysqli_query($this->db, $query);
if ($res) {
return true;
} else {
return "Internal Server Error";
}
}
示例9: unfollowtopic
function unfollowtopic(){
$topic = new Topic();
if (!isset($_GET['topicid_unfollowtopic']))
return array("ok"=>false, "error"=>"no id");
$topic->setId($_GET['topicid_unfollowtopic']);
if ($topic->unfollow())
return array("ok"=>true, "error"=>"");
else
return array("ok"=>false, "error"=>"cant unfollow");
}
示例10: create
public function create($titre)
{
$topic = new Topic($this->link);
$topic->setTitre($titre);
$titre = mysqli_real_escape_string($this->link, $titre);
$request = "INSERT INTO topics (titre, id_auteur, id_category) VALUES ('" . $titre . "', '" . $_SESSION['id'] . "', '" . $this->id . "')";
$res = mysqli_query($this->link, $request);
if ($res) {
return $this->select(mysqli_insert_id($this->link));
} else {
throw new Exception("Internal server error");
}
}
示例11: getTopicStartTest
function getTopicStartTest($t_id)
{
// Wertprüfung
$t_id = abs(intval($t_id));
echo '<form action="index.php?site=start_test&action=getQuestions" method="post">';
$button = Function_getTopic_03;
$topic = new Topic();
$topic->getActiveTopic();
$arrayTopic = $topic->getTopicArray();
echo " <div id=\"inner_box_top\">\n";
// In der Mitte der Inhalt
showForm($t_id, $button, $arrayTopic);
}
示例12: CreateTopicAndTopicLink
/**
* Creates the Topic and TopicLink for this Package object.
* @param Person $objPerson person who created this package who will be credited with creating the linked topic
* @return Topic
*/
public function CreateTopicAndTopicLink(Person $objPerson)
{
$objTopicLink = new TopicLink();
$objTopicLink->TopicLinkTypeId = TopicLinkType::Package;
$objTopicLink->Package = $this;
$objTopicLink->Save();
$objTopic = new Topic();
$objTopic->TopicLink = $objTopicLink;
$objTopic->Name = $this->strName;
$objTopic->Person = $objPerson;
$objTopic->Save();
return $objTopic;
}
示例13: create
public function create()
{
foreach ($this->required as $required => $strlen) {
if (!Input::has($required) || strlen(Input::get($required)) < $strlen) {
return Response::make(['error' => 'You must introduce a ' . $required . ' with ' . $strlen . ' of length...'], 404);
}
}
$new = new Topic();
$new->fill(Input::only(['title', 'author', 'message']));
$new->place = $this->place;
$new->save();
return Response::make(['success' => 'You just created a new topic!', 'topic' => $new->toArray()], 404);
}
示例14: idsFromNames
/**
* Given a list of topic names, return the list of topic ids
*/
public static function idsFromNames(array $names)
{
$ids = [];
foreach ($names as $name) {
$topic = static::whereName($name)->first();
if (!$topic) {
$topic = new Topic();
$topic->name = $name;
$topic->save();
}
$ids[] = $topic->id;
}
return $ids;
}
示例15: downVote
public function downVote(Topic $topic)
{
if (Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('downvote')->count()) {
Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('downvote')->delete();
$topic->increment('recommend_add', 1);
} elseif (Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('upvote')->count()) {
Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('upvote')->delete();
Recomment::create(['user_id' => Auth::user()->user_id, 'topic_id' => $topic->topic_id, 'status' => '0', 'types' => 'downvote']);
$topic->decrement('recommend_add', 2);
} else {
Recomment::create(['user_id' => Auth::user()->user_id, 'topic_id' => $topic->topic_id, 'status' => '0', 'types' => 'downvote']);
$topic->decrement('recommend_add', 1);
}
}