Ejemplo n.º 1
0
 function getArticle($type, $article, $isLink = false)
 {
     if ($type == 'post') {
         if (is_numeric($article) == true) {
             $article = $this->getPost($article);
         }
         $article->title = GetString($article->title, 'replace');
         $article->logo = $article->logo == 0 ? null : $this->IM->getModule('attachment')->getFileInfo($article->logo);
         $article->content = '<div class="wrapContent">' . AntiXSS($this->getArticleContent($article->content)) . '</div>' . PHP_EOL . '<div style="clear:both;"></div>';
         if ($isLink == true) {
             $page = $this->getPostPage($article->idx);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->idx, false, $page->domain, $page->language);
         }
     } else {
         if (is_numeric($article) == true) {
             $article = $this->getMent($article);
         }
         if (empty($this->ments[$article->idx]) == true) {
             $this->ments[$article->idx] = $article;
         }
         if ($isLink == true) {
             $page = $this->getPostPage($article->parent);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->parent, false, $page->domain, $page->language);
         }
     }
     $article->member = $this->IM->getModule('member')->getMember($article->midx);
     $article->name = $this->IM->getModule('member')->getMemberNickname($article->midx);
     $article->ip = $this->getArticleIp($article->ip);
     return $article;
 }
Ejemplo n.º 2
0
 function getMentItem($ment)
 {
     ob_start();
     $answer = $this->getPost($ment->parent);
     $question = $this->getPost($answer->parent);
     $qna = $this->getQna($answer->qid);
     $templetPath = $qna->templetPath;
     $templetDir = $qna->templetDir;
     $attachments = $this->db()->select($this->table->attachment)->where('type', 'MENT')->where('parent', $ment->idx)->get();
     for ($i = 0, $loop = count($attachments); $i < $loop; $i++) {
         $attachments[$i] = $this->IM->getModule('attachment')->getFileInfo($attachments[$i]->idx);
     }
     $ment->member = $this->IM->getModule('member')->getMember($ment->midx);
     $ment->name = $this->IM->getModule('member')->getMemberNickname($ment->midx, true);
     $ment->content = '<div class="wrapContent">' . AntiXSS($this->getArticleContent($ment->content)) . '</div>' . PHP_EOL . '<div style="clear:both;"></div>';
     $ment->ip = $this->getArticleIp($ment->ip);
     if ($ment->is_secret == 'TRUE' && $answer->midx != $this->IM->getModule('member')->getLogged() && $question->midx != $this->IM->getModule('member')->getLogged()) {
         $ment->content = '<i class="fa fa-lock"></i> 질문자 및 답변자에게만 공개된 댓글입니다.';
     }
     echo '<div id="ModuleQnaMentItem-' . $ment->idx . '" class="mentItem">' . PHP_EOL;
     $IM = $this->IM;
     $Module = $this;
     if (file_exists($templetPath . '/ment.item.php') == true) {
         include $templetPath . '/ment.item.php';
     }
     echo '</div>' . PHP_EOL;
     $context = ob_get_contents();
     ob_end_clean();
     return $context;
 }
Ejemplo n.º 3
0
 function getArticle($type, $article, $isLink = false)
 {
     if ($type == 'class') {
         if (is_numeric($article) == true) {
             $article = $this->getClass($article);
         }
         $article->title = GetString($article->title, 'replace');
         $article->cover = $this->IM->getModule('attachment')->getFileInfo($article->cover);
         if ($isLink == true) {
             $page = $this->getPostPage($article->idx);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->idx, false, $page->domain, $page->language);
         }
     } elseif ($type == 'subject') {
         if (is_numeric($article) == true) {
             $article = $this->getSubject($article);
         }
         $attend = $this->getAttend($article->parent);
         $percent = 0;
         $article->posts = $this->db()->select($this->table->post)->where('parent', $article->idx)->orderBy('sort', 'asc')->get();
         for ($i = 0, $loop = count($article->posts); $i < $loop; $i++) {
             $article->posts[$i] = $this->getArticle('post', $article->posts[$i]);
             $percent += $article->posts[$i]->percent;
         }
         $article->percent = $loop > 0 ? $percent / $loop : 0;
     } elseif ($type == 'post') {
         if (is_numeric($article) == true) {
             $article = $this->getPost($article);
         }
         $class = $this->getClass($article->class);
         $attend = $this->getAttend($article->class);
         $article->title = GetString($article->title, 'replace');
         $article->context = json_decode($article->context);
         $article->image = null;
         if ($article->type == 'youtube') {
             $article->image = $article->context->thumbnail ? $article->context->thumbnail : '';
         }
         if ($article->type == 'video') {
             $article->image = isset($article->context->thumbnail) == true ? $article->context->thumbnail : '';
         }
         $article->percent = 0;
         if ($attend != null) {
             if ($attend->mode == 'P') {
                 $trackings = $this->db()->select($this->table->tracking)->where('pidx', $article->idx)->get();
                 $percent = 0;
                 foreach ($trackings as $tracking) {
                     $percent += $tracking->percent;
                 }
                 $article->percent = $class->student > 0 ? round($percent / $class->student) : 0;
             } else {
                 $tracking = $this->db()->select($this->table->tracking)->where('midx', $this->IM->getModule('member')->getLogged())->where('pidx', $article->idx)->getOne();
                 if ($tracking != null) {
                     $article->percent = $tracking->percent;
                 }
             }
         }
         if ($isLink == true) {
             $page = $this->getPostPage($article->idx);
             //				$article->link = $this->IM->getUrl($page->menu,$page->page,'view',$article->idx,false,$page->domain);
         }
     } else {
         if (is_numeric($article) == true) {
             $article = $this->getMent($article);
         }
         if ($isLink == true) {
             $page = $this->getPostPage($article->parent);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->parent, false, $page->domain, $page->language);
         }
     }
     $article->member = $this->IM->getModule('member')->getMember($article->midx);
     $article->name = $this->IM->getModule('member')->getMemberNickname($article->midx, true);
     if ($type != 'subject') {
         $article->content = '<div class="wrapContent">' . AntiXSS($this->getArticleContent($article->content)) . '</div>' . PHP_EOL . '<div style="clear:both;"></div>';
     }
     if ($type != 'subject' && $type != 'post') {
         $article->ip = $this->getArticleIp($article->ip);
     }
     return $article;
 }
Ejemplo n.º 4
0
 /**
  * Get article(post and ment)'s data initialization, this method used iModule core for recently article list
  *
  * @param string $type article type(post or ment)
  * @param int $articleIdx or object $article If this values is numeric, use article idx.
  * @param boolean $isLink find article's url (for recently article list)
  * @param boolean $isApi data initialization for api (included full url, and some data remove for security)
  * @return object $data
  */
 function getArticle($type, $article, $isLink = false, $isApi = false)
 {
     if ($type == 'post') {
         if (is_numeric($article) == true) {
             $article = $this->getPost($article);
         }
         $article->title = GetString($article->title, 'replace');
         $article->is_secret = $article->is_secret == 'TRUE';
         $article->is_image = preg_match('/<img(.*?)>/', $article->content);
         $article->is_file = $this->db()->select($this->table->attachment)->where('parent', $article->idx)->where('type', 'POST')->count() > 0;
         $article->is_link = preg_match('/<a(.*?)href(.*?)>/', $article->content);
         $article->is_video = preg_match('/<iframe(.*?)src=(.*?)(youtube|vimeo|daum|naver)(.*?)>/', $article->content);
         if (preg_match('/<img(.*?)data-idx="([0-9]+)"(.*?)>/', $article->content, $match) == true) {
             $article->image = $this->IM->getModule('attachment')->getFileInfo($match[2]);
         } else {
             $article->image = null;
         }
         if ($isLink == true) {
             $page = $this->getPostPage($article->idx);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->idx, false, $page->domain, $page->language);
         }
     } else {
         if (is_numeric($article) == true) {
             $article = $this->getMent($article);
         }
         if ($isLink == true) {
             $page = $this->getPostPage($article->parent);
             $article->link = $this->IM->getUrl($page->menu, $page->page, 'view', $article->parent, false, $page->domain, $page->language);
         }
     }
     $article->member = $this->IM->getModule('member')->getMember($article->midx);
     $article->name = $this->IM->getModule('member')->getMemberNickname($article->midx, true, $article->name);
     $article->content = '<div class="wrapContent">' . AntiXSS($this->getArticleContent($article->content, $isApi)) . '</div>' . PHP_EOL . '<div style="clear:both;"></div>';
     $article->ip = $this->getArticleIp($article->ip);
     return $article;
 }