Example #1
0
 protected static function func(&$a)
 {
     if (array_key_exists('a_edited', $a)) {
         $aEdited = end($a['a_edited']);
         $aEdited['edited'] = $a['edited'];
         $a['edits'] = \tplEditedby::parse($aEdited, false);
     }
     if (!empty($a['i_del_ts'])) {
         $a['deleted'] = ' deleted';
     }
     if (!empty($a['a_deleted'])) {
         $a['deletedby'] = \tplDeletedby::parse($a['a_deleted'], false);
     }
     if (!empty($a['a_comments'])) {
         /**
          * Closure function
          * to pass resource_id 
          * and author id of this
          * Answer to the tplComments
          * This way we don't have to store
          * duplicate data in each comment
          * element and still be able to
          * have access to these 2 important
          * fields in the tplComments template
          * We going to need id or resource owner
          * in order to add it to the "reply" link
          * in the form of class uid-$uid
          * 
          */
         $rid = $a['_id'];
         $uid = $a['i_uid'];
         $reply = $a['reply'];
         $reply_t = $a['reply_t'];
         $f = function (&$data) use($rid, $uid, $reply, $reply_t) {
             $data['resource_id'] = $rid;
             $data['owner_id'] = $uid;
             $data['reply'] = $reply;
             $data['reply_t'] = $reply_t;
         };
         $a['comments_html'] = tplComment::loop($a['a_comments'], true, $f);
     }
 }
 protected static function func(&$a)
 {
     if (array_key_exists('a_edited', $a)) {
         /**
          * A way to pass "translated"
          * version of "Edited" word
          * to the tplEditedby template
          */
         $aEdited = end($a['a_edited']);
         $a['edits'] = \tplEditedby::parse($aEdited);
     }
     if (!empty($a['i_sticky'])) {
         $a['sticky'] = ' sticky';
     }
     $a['hts'] = \Lampcms\TimeFormatter::formatTime($_SESSION['locale'], $a['i_ts']);
     if (!empty($a['a_comments'])) {
         /**
          * Closure function
          * to pass resource_id
          * and author id of this
          * Question to the tplComments
          * This way we don't have to store
          * duplicate data in each comment
          * element and still be able to
          * have access to these 2 important
          * fields in the tplComments template
          * We going to need id or resource owner
          * in order to add it to the "reply" link
          * in the form of class uid-$uid
          *
          */
         $rid = $a['_id'];
         $uid = $a['i_uid'];
         $f = function (&$data) use($rid, $uid) {
             $data['resource_id'] = $rid;
             $data['owner_id'] = $uid;
         };
         $a['comments_html'] = tplComment::loop($a['a_comments'], true, $f);
         //
     }
     if (!empty($a['pending'])) {
         $a['moderate'] = '<span class="cb fl pending">@@This question is pending moderator approval@@</span>';
         $a['approve'] = '<span class="ico ttt approve ajax" title="@@Approve this question@@"> </span>';
     }
 }
Example #3
0
 /**
  * Return array of resourceID, type (A or Q)
  * and parsed div with comment
  *
  *
  */
 protected function returnResult()
 {
     $aComment = $this->CommentParser->getArrayCopy();
     /**
      * Add edit and delete tools because
      * Viewer already owns this comment and is
      * allowed to edit or delete it right away.
      * Javascript that usually dynamically adds these tools
      * is not going to be fired, so these tools
      * must alreayd be included in the returned html
      *
      */
     $aComment['edit_delete'] = '  <span class="ico del ajax" title="Delete">delete</span> <span class="ico edit ajax" title="Edit">edit</span>';
     /**
      * Important to add owner_id key
      * because it's not in the comment array
      * It is used when creating the 'reply' link
      * in the tplComment
      * That ID is then used when figuring out if
      * viewer has permission to add comment.
      * Users with low reputation still always have
      * premission to add comments to own resources.
      * 
      */
     $aComment['owner_id'] = $this->Resource->getOwnerId();
     $aRet = array('comment' => array('id' => $aComment['_id'], 'res' => $aComment['i_res'], 'parent' => $aComment['i_prnt'], 'html' => \tplComment::parse($aComment)));
     Responder::sendJSON($aRet);
 }