function template()
 {
     global $html, $action;
     if (!empty($action)) {
         return;
     }
     if (template_match("plugin:TAG_LIST", $html, $null)) {
         $html = template_replace("plugin:TAG_LIST", $this->tagList(), $html);
     }
     if (template_match("plugin:TAG_CLOUD", $html, $null)) {
         $html = template_replace("plugin:TAG_CLOUD", $this->tagCloud(), $html);
     }
 }
Beispiel #2
0
 function template()
 {
     global $CON, $html, $action, $preview, $page, $PG_DIR, $HEAD, $self, $comments_html, $comment_captcha_failed;
     /*
      * Include comments if:
      * - {plugin:COMMENTS} is in template and {NO_COMMENTS} is not in page content
      * - {COMMENTS} is in page content
      */
     if ($action == "" && !$preview && (template_match("plugin:COMMENTS", $html, $null) && strpos($CON, "{NO_COMMENTS}") === false || strpos($CON, "{COMMENTS}") !== false)) {
         $HEAD .= '<script type="text/javascript" src="plugins/Comments/comments.js"></script>';
         $HEAD .= '<style type="text/css" media="all">@import url("plugins/Comments/comments.css");</style>';
         $tmpl = file_get_contents($this->data_dir . $this->template);
         $tmpl = strtr($tmpl, array("{FORM_NAME}" => $this->TP_FORM_NAME, "{FORM_EMAIL}" => $this->TP_FORM_EMAIL, "{FORM_CONTENT}" => $this->TP_FORM_CONTENT, "{FORM_NAME_VALUE}" => $comment_captcha_failed ? h($_POST["name"]) : "", "{FORM_EMAIL_VALUE}" => $comment_captcha_failed ? h($_POST["email"]) : "", "{FORM_CONTENT_VALUE}" => $comment_captcha_failed ? h($_POST["content"]) : "", "{FORM_SUBMIT}" => $this->TP_FORM_SUBMIT, "{FORM_SELF}" => h($self), "{FORM_PAGE}" => h($page), "{COMMENTS}" => $this->TP_COMMENTS));
         $items_str = "";
         if ($dir = @opendir($this->comments_dir . $page)) {
             $item_tmpl = "";
             if (preg_match("/\\{item\\}(.*)\\{\\/item\\}/Us", $tmpl, $m)) {
                 $item_tmpl = $m[1];
             }
             $filenames = array();
             while ($filename = @readdir($dir)) {
                 if (preg_match("/([0-9]{8}-[0-9]{4}-[0-9]{2})\\.txt/", $filename, $m)) {
                     $filenames[] = $filename;
                 }
             }
             if ($this->sorting_order == "asc") {
                 sort($filenames);
             } else {
                 if ($this->sorting_order == "desc") {
                     rsort($filenames);
                 }
             }
             $comment_num = 0;
             foreach ($filenames as $filename) {
                 $comment_num++;
                 $file = file_get_contents($this->comments_dir . $page . "/" . $filename);
                 $delimiter = strpos($file, "\n");
                 $meta = substr($file, 0, $delimiter);
                 $content = substr($file, $delimiter + 1);
                 list($ip, $name, $email) = explode("\t", $meta);
                 $processed_content = $this->processComment($content);
                 $items_str .= strtr($item_tmpl, array("{CONTENT}" => $processed_content, "{NAME}" => h($name), "{EMAIL}" => h($email), "{NAME_TO_EMAIL}" => $email == "" ? $name : "<a href=\"mailto:" . h($email) . "\">" . h($name) . "</a>", "{IP}" => $ip, "{DATE}" => rev_time(basename($filename, ".txt")), "{ID}" => basename($filename, ".txt"), "{NUMBER}" => $comment_num, "{DELETE}" => h($this->TP_DELETE), "{DELETE_LINK}" => "{$self}?action=admin-deletecomment&amp;page=" . u($page) . "&amp;filename=" . u($filename), "{DELETE_CONFIRM}" => h($this->TP_DELETE_CONFIRM)));
             }
         }
         $tmpl = str_replace("{NUMBER_OF_COMMENTS}", count($filenames), $tmpl);
         $comments_html = preg_replace("/\\{item\\}.*\\{\\/item\\}/Us", $items_str, $tmpl);
         plugin("commentsTemplate");
         $html = template_replace("plugin:COMMENTS", $comments_html, $html);
         $CON = str_replace("{COMMENTS}", $comments_html, $CON);
     }
     $CON = str_replace("{NO_COMMENTS}", "", $CON);
     $HEAD .= "\n<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS " . h($this->TP_COMMENTS) . "\" href=\"{$this->rss_file}\" />\n";
 }