コード例 #1
0
 /**
  * @return bool|array
  * {
  *     False on failure, or array with these keys:
  *
  *     @type Workflow $boardWorkflow
  *     @type Workflow $topicWorkflow
  *     @type PostRevision $post
  *     @type PostRevision $topic
  *     @type User $user
  *     @type User $agent
  *     @type NotificationController $notificationController
  * }
  */
 protected function getTestData()
 {
     $user = User::newFromName('Flow Test User');
     $user->addToDatabase();
     $agent = User::newFromName('Flow Test Agent');
     $agent->addToDatabase();
     $tuple = UserTuple::newFromUser($agent);
     $topicTitle = $this->generateObject(array('rev_user_wiki' => $tuple->wiki, 'rev_user_id' => $tuple->id, 'rev_user_ip' => $tuple->ip, 'rev_flags' => 'wikitext', 'rev_content' => 'some content'));
     /*
      * We don't really *have* to store everything for this test. We could
      * just work off of the object we have here.
      * However, our current CI setup forces us to not use Parsoid & write
      * wikitext instead.
      * Notifications need to convert the content to HTML & in order to do so
      * have to know the title of the board the post is on (to resolve links
      * & stuff).
      * For those combined reasons, we'll store everything.
      */
     $this->store($topicTitle);
     $boardWorkflow = $topicTitle->getCollection()->getBoardWorkflow();
     $topicWorkflow = $topicTitle->getCollection()->getWorkflow();
     $firstPost = $topicTitle->reply($topicWorkflow, $agent, 'ffuts dna ylper', 'wikitext');
     $this->store($firstPost);
     return array('boardWorkflow' => $boardWorkflow, 'topicWorkflow' => $topicWorkflow, 'post' => $firstPost, 'topic' => $topicTitle, 'user' => $user, 'agent' => $agent, 'notificationController' => Container::get('controller.notification'));
 }
コード例 #2
0
 /**
  * @param Title $title
  * @param PostRevision $post
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param string $changeType
  * @return PostSummary
  */
 public static function create(Title $title, PostRevision $post, User $user, $content, $format, $changeType)
 {
     $obj = new self();
     $obj->revId = UUID::create();
     $obj->user = UserTuple::newFromUser($user);
     $obj->prevRevision = null;
     $obj->changeType = $changeType;
     $obj->summaryTargetId = $post->getPostId();
     $obj->setContent($content, $format, $title);
     return $obj;
 }
コード例 #3
0
 /**
  * @param Workflow $workflow
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param string[optional] $changeType
  * @return Header
  */
 public static function create(Workflow $workflow, User $user, $content, $format, $changeType = 'create-header')
 {
     $obj = new self();
     $obj->revId = UUID::create();
     $obj->workflowId = $workflow->getId();
     $obj->user = UserTuple::newFromUser($user);
     $obj->prevRevision = null;
     // no prior revision
     $obj->setContent($content, $format, $workflow->getArticleTitle());
     $obj->changeType = $changeType;
     return $obj;
 }
コード例 #4
0
 /**
  * Returns an array, representing flow_revision & flow_tree_revision db
  * columns.
  *
  * You can pass in arguments to override default data.
  * With no arguments tossed in, default data (resembling a newly-created
  * topic title) will be returned.
  *
  * @param array[optional] $row DB row data (only specify override columns)
  * @return array
  */
 protected function generateRow(array $row = array())
 {
     $workflow = $this->generateWorkflow(array('workflow_type' => 'topic'));
     $uuidRevision = UUID::create();
     $user = User::newFromName('UTSysop');
     $tuple = UserTuple::newFromUser($user);
     return $row + array('rev_id' => $uuidRevision->getBinary(), 'rev_type' => 'post', 'rev_type_id' => $workflow->getId()->getBinary(), 'rev_user_wiki' => $tuple->wiki, 'rev_user_id' => $tuple->id, 'rev_user_ip' => $tuple->ip, 'rev_parent_id' => null, 'rev_flags' => 'html', 'rev_content' => 'test content', 'rev_change_type' => 'new-topic', 'rev_mod_state' => AbstractRevision::MODERATED_NONE, 'rev_mod_user_wiki' => null, 'rev_mod_user_id' => null, 'rev_mod_user_ip' => null, 'rev_mod_timestamp' => null, 'rev_mod_reason' => null, 'rev_last_edit_id' => null, 'rev_edit_user_wiki' => null, 'rev_edit_user_id' => null, 'rev_edit_user_ip' => null, 'rev_content_length' => 0, 'rev_previous_content_length' => 0, 'tree_rev_descendant_id' => $workflow->getId()->getBinary(), 'tree_rev_id' => $uuidRevision->getBinary(), 'tree_orig_user_wiki' => $tuple->wiki, 'tree_orig_user_id' => $tuple->id, 'tree_orig_user_ip' => $tuple->ip, 'tree_parent_id' => null);
 }
コード例 #5
0
 /**
  * @param Workflow $workflow
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param string[optional] $changeType
  * @return PostRevision
  */
 public function reply(Workflow $workflow, User $user, $content, $format, $changeType = 'reply')
 {
     $reply = new self();
     // UUIDs should not be reused for different entities/entity types in the future.
     // (It is also inconsistent with newFromId, which uses separate ones.)
     // This may be changed here in the future.
     $reply->revId = $reply->postId = UUID::create();
     $reply->user = UserTuple::newFromUser($user);
     $reply->origUser = $reply->user;
     $reply->replyToId = $this->postId;
     $reply->setContent($content, $format, $workflow->getArticleTitle());
     $reply->changeType = $changeType;
     $reply->setChildren(array());
     $reply->setDepth($this->getDepth() + 1);
     $reply->rootPost = $this->rootPost;
     return $reply;
 }
コード例 #6
0
 /**
  * Apply new content to a revision.
  *
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param Title|null $title When null the related workflow will be lazy-loaded to locate the title
  * @throws DataModelException
  */
 protected function setNextContent(User $user, $content, $format, Title $title = null)
 {
     if ($this->moderationState !== self::MODERATED_NONE) {
         throw new DataModelException('Cannot change content of restricted revision', 'process-data');
     }
     if ($content !== $this->getContent()) {
         $this->content = null;
         $this->setContent($content, $format, $title);
         $this->lastEditId = $this->getRevisionId();
         $this->lastEditUser = UserTuple::newFromUser($user);
     }
 }