Beispiel #1
0
 /**
  * Display permalink anchor for current post.
  *
  * The permalink mode title will use the post title for the 'a' element 'id'
  * attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
  *
  * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
  */
 function permalinkAnchor($mode = 'id')
 {
     switch (strtolower($mode)) {
         case 'title':
             $title = HuradSanitize::title($this->content[self::$model]['title']) . '-' . $this->content[self::$model]['id'];
             echo $this->Html->link(null, null, array('id' => $title));
             break;
         case 'id':
         default:
             echo $this->Html->link(null, null, array('id' => self::$model . '-' . $this->content[self::$model]['id']));
             break;
     }
 }
Beispiel #2
0
    function _dashboard_recent_comments_row($comment)
    {
        $this->Comment->setComment($comment['Comment']);
        ?>

        <div id="comment-<?php 
        $this->Comment->commentID();
        ?>
" <?php 
        $this->Comment->commentClass(array('comment-item', $this->Comment->getCommentStatus($comment['Comment']['status'])));
        ?>
>
            <?php 
        echo $this->Gravatar->image($this->Comment->getCommentAuthorEmail(), array('size' => '50'));
        ?>
            <div class="dashboard-comment-wrap">
                <h4 class="comment-meta">
                    <?php 
        echo __d('hurad', 'From');
        ?>
                    <cite class="comment-author">
                        <?php 
        echo $this->Html->link($this->Comment->getCommentAuthor(), HuradSanitize::url($this->Comment->getCommentAuthorUrl()), array('class' => 'url', 'rel' => 'external nofollow'));
        ?>
                    </cite>
                    <?php 
        echo __d('hurad', 'on');
        ?>
                    <a href="http://localhost/wp3en/wp-admin/post.php?post=1&action=edit"><?php 
        echo $comment['Post']['title'];
        ?>
</a>
                    <a class="comment-link" href="http://localhost/wp3en/?p=1#comment-3">#</a>
                    <span
                        class="approve" <?php 
        echo $comment['Comment']['status'] ? 'style="display: none;"' : 'style=""';
        ?>
><?php 
        echo __('[Pending]');
        ?>
</span>
                </h4>
                <blockquote>
                    <p><?php 
        $this->Comment->commentExcerpt();
        ?>
</p>
                </blockquote>

                <p class="row-actions">
                    <span
                        class="approve" <?php 
        echo $comment['Comment']['status'] ? 'style="display: none;"' : 'style=""';
        ?>
>
                        <?php 
        echo $this->Js->link(__d('hurad', 'Approve'), array('controller' => 'comments', 'action' => 'action', 'approved', $this->Comment->getCommentID()), array('success' => 'cApprove(' . $this->Comment->getCommentID() . ')'));
        ?>
                    </span>
                    <span
                        class="unapprove" <?php 
        echo $comment['Comment']['status'] ? 'style=""' : 'style="display: none;"';
        ?>
>
                        <?php 
        echo $this->Js->link(__d('hurad', 'Unapprove'), array('controller' => 'comments', 'action' => 'action', 'disapproved', $this->Comment->getCommentID()), array('success' => 'cUnapprove(' . $this->Comment->getCommentID() . ')'));
        ?>
                    </span>
                    <!--                    <span class="reply hide-if-no-js">
                                    |
                                    <a class="vim-r hide-if-no-js" href="#" title="Reply to this comment" onclick="commentReply.open('3','1');return false;">Reply</a>
                                </span>-->
                    <span class="edit">
                        |
                        <?php 
        echo $this->Html->link(__d('hurad', 'Edit'), array('admin' => true, 'controller' => 'comments', 'action' => 'edit', $this->Comment->getCommentID()), array('title' => 'Edit comment'));
        ?>
                    </span>
                    <span class="spam">
                        |
                        <?php 
        echo $this->Js->link(__d('hurad', 'Spam'), array('controller' => 'comments', 'action' => 'action', 'spam', $this->Comment->getCommentID()), array('success' => 'cSpam(' . $this->Comment->getCommentID() . ')'));
        ?>
                    </span>
                    <span class="trash">
                        |
                        <?php 
        echo $this->Js->link(__d('hurad', 'Trash'), array('controller' => 'comments', 'action' => 'action', 'trash', $this->Comment->getCommentID()), array('success' => 'cTrash(' . $this->Comment->getCommentID() . ')'));
        ?>
                    </span>
                </p>
            </div>
        </div>
    <?php 
    }
Beispiel #3
0
 /**
  * Returns the classes for the comment div as an array
  *
  * @param string|array $class   One or more classes to add to the class list
  * @param array|string $comment Comment array or comment id
  *
  * @return array Array of classes
  */
 public function getClass($class = '', $comment = null)
 {
     $this->getComment($comment);
     $classes = [];
     $classes[] = 'comment';
     // If the comment author has an id (registered), then print the log in name
     if ($this->comment['Comment']['user_id'] > 0 && ($user = ClassRegistry::init('User')->getUser($this->comment['Comment']['user_id']))) {
         // For all registered users, 'byuser'
         $classes[] = 'byuser';
         $classes[] = 'comment-author-' . HuradSanitize::htmlClass(['comment-author-' . $user['UserMeta']['nickname'], 'comment-author-' . $this->comment['Comment']['user_id']]);
         // For comment authors who are the author of the post
         if ($post = ClassRegistry::init('Post')->getPost($this->comment['Comment']['post_id'])) {
             if ($this->comment['Comment']['user_id'] === $post['Post']['user_id']) {
                 $classes[] = 'by-post-author';
             }
         }
     }
     if (empty($this->commentAlt)) {
         $this->commentAlt = 0;
     }
     if (empty($commentDepth)) {
         $commentDepth = 1;
     }
     if (empty($commentThreadAlt)) {
         $commentThreadAlt = 0;
     }
     if ($this->commentAlt % 2) {
         $classes[] = 'odd';
         $classes[] = 'alt';
     } else {
         $classes[] = 'even';
     }
     $this->commentAlt++;
     // Alt for top-level comments
     if (1 == $commentDepth) {
         if ($commentThreadAlt % 2) {
             $classes[] = 'thread-odd';
             $classes[] = 'thread-alt';
         } else {
             $classes[] = 'thread-even';
         }
         $commentThreadAlt++;
     }
     $classes[] = "depth-{$commentDepth}";
     if (!empty($class)) {
         if (!is_array($class)) {
             $class = preg_split('#\\s+#', $class);
         }
         $classes = Hash::merge($classes, $class);
     }
     $classes = array_map('HuradSanitize::htmlClass', $classes);
     $classesStr = implode(' ', $classes);
     return $this->Hook->applyFilters('Helper.Comment.getClass', $classesStr, $classes, $class);
 }
Beispiel #4
0
 /**
  * Edit page
  *
  * @param null|int $id
  */
 public function admin_edit($id = null)
 {
     $this->set('title_for_layout', __d('hurad', 'Edit Page'));
     if (!empty($this->request->data)) {
         if ($this->request->is('post') || $this->request->is('put')) {
             $this->request->data['Page']['created'] = $this->Hurad->dateParse($this->request->data['Page']['created']);
             $this->request->data['Page']['type'] = 'page';
             $this->request->data['Page']['user_id'] = $this->Auth->user('id');
             if (empty($this->request->data['Page']['slug'])) {
                 $this->request->data['Page']['slug'] = HuradSanitize::title($this->request->data['Page']['title'], 'dash');
             } else {
                 $this->request->data['Page']['slug'] = HuradSanitize::title($this->request->data['Page']['slug'], 'dash');
             }
             // save the data
             $this->Page->create();
             if ($this->Page->save($this->request->data)) {
                 $this->Session->setFlash(__d('hurad', 'The Page has been saved.'), 'flash_message', ['class' => 'success']);
                 $this->redirect(['action' => 'index']);
             } else {
                 $this->Session->setFlash(__d('hurad', 'The Page could not be saved. Please, try again.'), 'flash_message', ['class' => 'danger']);
             }
         }
     } elseif (empty($this->request->data)) {
         $this->request->data = $this->Page->read(null, $id);
     }
     $parentPages = $this->Page->generateTreeList(['Page.type' => 'page', 'Page.id !=' => $id], null, null, '_');
     $this->set(compact('parentPages'));
 }
Beispiel #5
0
 /**
  * Add comment
  */
 public function add()
 {
     if ($this->request->is('post')) {
         $this->Comment->create();
         if ($this->Auth->loggedIn()) {
             $user = $this->Comment->User->getUser($this->Auth->user('id'));
             $this->request->data['Comment']['user_id'] = $user['User']['id'];
             $this->request->data['Comment']['author'] = $user['UserMeta']['display_name'];
             $this->request->data['Comment']['author_email'] = $user['User']['email'];
             $this->request->data['Comment']['author_url'] = $user['User']['url'];
         }
         if ($this->Auth->user('role') == 'administrator') {
             $this->request->data['Comment']['author_url'];
         }
         $request = new CakeRequest();
         $this->request->data['Comment']['author_ip'] = $request->clientIp();
         $this->request->data['Comment']['agent'] = env('HTTP_USER_AGENT');
         $this->request->data['Comment']['author_url'] = HuradSanitize::url($this->request->data['Comment']['author_url']);
         if ($this->Comment->save($this->request->data)) {
             $this->Hurad->sendEmail($this->request->data['Comment']['author_email'], __d('hurad', 'Comment Submit'), 'add_comment', __d('hurad', 'Your comment submit in blog waiting to approve by admin.'));
             $this->Session->setFlash(__d('hurad', 'The comment has been saved'), 'flash_message', ['class' => 'success'], 'comment-flash');
             $this->redirect($this->referer());
         } else {
             $this->Session->setFlash(__d('hurad', 'The comment could not be saved. Please, try again.'), 'flash_message', ['class' => 'danger'], 'comment-flash');
             $this->redirect($this->referer());
         }
     }
 }
Beispiel #6
0
 /**
  * Edit post
  *
  * @param null|int $id
  */
 public function admin_edit($id = null)
 {
     $this->set('title_for_layout', __d('hurad', 'Edit Post'));
     $defaults = array('parent_id' => null, 'user_id' => $this->Auth->user('id'), 'title' => '', 'slug' => '', 'content' => '', 'excerpt' => '', 'status' => Post::STATUS_DRAFT, 'comment_status' => Post::COMMENT_STATUS_OPEN, 'comment_count' => 0, 'type' => 'post');
     if (!empty($this->request->data)) {
         if ($this->request->is('post') || $this->request->is('put')) {
             $this->request->data['Post'] = Hash::merge($defaults, $this->request->data['Post']);
             $this->request->data['Post']['created'] = $this->Hurad->dateParse($this->request->data['Post']['created']);
             if (empty($this->request->data['Post']['tags'])) {
                 $this->loadModel('PostsTag');
                 $this->PostsTag->deleteAll(array('post_id' => $id), false);
             }
         }
         $this->_saveTags();
         if (empty($this->request->data['Post']['slug'])) {
             $this->request->data['Post']['slug'] = HuradSanitize::title($this->request->data['Post']['title'], 'dash');
         } else {
             $this->request->data['Post']['slug'] = HuradSanitize::title($this->request->data['Post']['slug'], 'dash');
         }
         // save the data
         $this->Post->create();
         $this->Post->PostMeta->post_id = $id;
         if ($this->Post->save($this->request->data) && $this->Post->PostMeta->saveData($this->request->data)) {
             $this->Session->setFlash(__d('hurad', 'The Post has been saved.'), 'flash_message', array('class' => 'success'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__d('hurad', 'The Post could not be saved. Please, try again.'), 'flash_message', array('class' => 'danger'));
         }
     }
     if (empty($this->request->data)) {
         $this->request->data = $this->Post->read(null, $id);
         // load the habtm data for the text input.
         $this->_loadTags();
     }
     // get the posts current tags
     $this->Post->PostMeta->post_id = $id;
     $post = Hash::merge($this->Post->read(null, $id), $this->Post->PostMeta->getData());
     $categories = $this->Post->Category->generateTreeList();
     $this->request->data = $post;
     $this->set(compact('post', 'categories'));
 }