コード例 #1
0
ファイル: ContentsTest.php プロジェクト: TN03/forum_xh
 /**
  * Tests creating and deleting a comment.
  *
  * @return void
  */
 public function testCreateAndDeleteComment()
 {
     $tid = $this->contents->getId();
     $title = 'hallo';
     $cid = $this->contents->getId();
     $user = '******';
     $comment = array('user' => $user, 'time' => time(), 'comment' => 'foo bar baz');
     $this->contents->createComment($this->forum, $tid, $title, $cid, $comment);
     $actual = $this->getComment($this->forum, $tid, $cid);
     $this->assertEquals($comment, $actual);
     $this->contents->deleteComment($this->forum, $tid, $cid, $user);
     $actual = $this->getComment($this->forum, $tid, $cid);
     $this->assertEmpty($actual);
 }
コード例 #2
0
 /**
  * Append header comments to the DOM document
  */
 protected function do_header_comments()
 {
     /* Array of translated comment lines */
     $lines = array(__('This is a code snippets export file generated by the Code Snippets WordPress plugin.', 'code-snippets'), __('http://wordpress.org/plugins/code-snippets', 'code-snippets'), __('To import these snippets a WordPress site follow these steps:', 'code-snippets'), __('1. Log in to that site as an administrator.', 'code-snippets'), __('2. Install the Code Snippets plugin using the directions provided at the above link.', 'code-snippets'), __("3. Go to 'Tools: Import' in the WordPress admin panel.", 'code-snippets'), __('4. Click on the "Code Snippets" importer in the list', 'code-snippets'), __('5. Upload this file using the form provided on that page.', 'code-snippets'), __('6. Code Snippets will then import all of the snippets and associated information contained in this file into your site.', 'code-snippets'), __("7. You will then have to visit the 'Snippets: Manage' admin menu and activate desired snippets.", 'code-snippets'));
     /* Add each line as a comment element */
     foreach ($lines as $line) {
         $comment = $this->dom->createComment(" {$line} ");
         $this->dom->appendChild($comment);
     }
     /* Build a generator line, like the WordPress export files */
     $gen = sprintf('generator="Code Snippets/%s" created="%s"', CODE_SNIPPETS_VERSION, date('Y-m-d H:i'));
     /* Run the generator line through the standard WordPress filter */
     $type = 'code_snippets_export';
     $gen = apply_filters("get_the_generator_{$type}", $gen, $type);
     /* Add it to the file as a comment */
     $gen = $this->dom->createComment(" {$gen} ");
     $this->dom->appendChild($gen);
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: TN03/forum_xh
 /**
  * Processes a posted comment.
  *
  * Returns the topic ID, if the comment could be posted,
  * <var>false</var> otherwise.
  *
  * @param string $forum A forum name.
  * @param string $tid   A topic ID (<var>null</var> means new topic).
  * @param string $cid   A comment ID.
  *
  * @return string
  */
 protected function postComment($forum, $tid = null, $cid = null)
 {
     if (!isset($tid) && empty($_POST['forum_title']) || $this->user() === false || empty($_POST['forum_text'])) {
         return false;
     }
     $tid = isset($tid) ? $this->contents->cleanId($tid) : $this->contents->getId();
     if ($tid === false) {
         return false;
     }
     $comment = array('user' => $this->user(), 'time' => time(), 'comment' => stsl($_POST['forum_text']));
     if (!isset($cid)) {
         $cid = $this->contents->getId();
         $title = isset($_POST['forum_title']) ? stsl($_POST['forum_title']) : null;
         $this->contents->createComment($forum, $tid, $title, $cid, $comment);
     } else {
         $this->contents->updateComment($forum, $tid, $cid, $comment);
     }
     return $tid;
 }