示例#1
0
 /**
  * Returns a reference to the tag helper plugin preloaded with
  * the current entry
  */
 public function &getTagHelper()
 {
     if (!$this->taghelper) {
         $this->taghelper = plugin_load('helper', 'blogtng_tags');
         $this->taghelper->load($this->entry['pid']);
     }
     return $this->taghelper;
 }
示例#2
0
 /**
  * Handles the actual output creation.
  *
  * @param string          $mode     output format being rendered
  * @param Doku_Renderer   $renderer the current renderer object
  * @param array           $data     data created by handler()
  * @return  boolean                 rendered correctly? (however, returned value is not used at the moment)
  */
 public function render($mode, Doku_Renderer $renderer, $data)
 {
     if ($mode != 'xhtml') {
         return false;
     }
     $this->loadHelpers();
     // set target if not set yet
     global $ID;
     if (!isset($data['conf']['target'])) {
         $data['conf']['target'] = $ID;
     }
     // add additional data from request parameters
     if ($start = $this->tools->getParam('pagination/start')) {
         // start offset
         $data['conf']['offset'] = (int) $start;
     }
     if ($tags = $this->tools->getParam('post/tags')) {
         // tags
         $data['conf']['tags'] = array_merge($data['conf']['tags'], explode(',', $tags));
     }
     $data['conf']['tags'] = array_map('trim', $data['conf']['tags']);
     $data['conf']['tags'] = array_unique($data['conf']['tags']);
     $data['conf']['tags'] = array_filter($data['conf']['tags']);
     // dispatch to the correct type handler
     $renderer->info['cache'] = (bool) $data['conf']['cache'];
     switch ($data['type']) {
         case 'related':
             $renderer->doc .= $this->entryhelper->xhtml_related($data['conf']);
             break;
         case 'pagination':
             $renderer->doc .= $this->entryhelper->xhtml_pagination($data['conf']);
             break;
         case 'newform':
             $renderer->info['cache'] = false;
             //never cache this
             $renderer->doc .= $this->entryhelper->xhtml_newform($data['conf']);
             break;
         case 'recentcomments':
             // FIXME to cache or not to cache?
             $renderer->doc .= $this->commenthelper->xhtml_recentcomments($data['conf']);
             break;
         case 'tagcloud':
             $renderer->info['cache'] = false;
             // never cache this
             $renderer->doc .= $this->taghelper->xhtml_tagcloud($data['conf']);
             break;
         case 'tagsearch':
             $renderer->doc .= $this->entryhelper->xhtml_tagsearch($data['conf'], $renderer);
             break;
         default:
             $renderer->doc .= $this->entryhelper->xhtml_list($data['conf'], $renderer);
     }
     return true;
 }
示例#3
0
 /**
  * Displays a single entry and related actions
  *
  * @author Michael Klier <*****@*****.**>
  *
  * @param $entry
  * @param $query
  */
 private function xhtml_entry_item($entry, $query)
 {
     global $lang;
     global $ID;
     static $class = 'odd';
     ptln('<tr class="' . $class . '">');
     $class = $class == 'odd' ? 'even' : 'odd';
     ptln('<td class="entry_created">' . dformat($entry['created']) . '</td>');
     ptln('<td class="entry_author">' . hsc($entry['author']) . '</td>');
     ptln('<td class="entry_title">' . html_wikilink(':' . $entry['page'], $entry['title']) . '</td>');
     ptln('<td class="entry_set_blog">' . $this->xhtml_entry_edit_form($entry, $query, 'blog') . '</th>');
     ptln('<td class="entry_set_commentstatus">' . $this->xhtml_entry_edit_form($entry, $query, 'commentstatus') . '</th>');
     $this->commenthelper->setPid($entry['pid']);
     // search comments of this entry link
     ptln('<td class="entry_comments">');
     $count = $this->commenthelper->get_count(null, true);
     if ($count > 0) {
         $params = array('do' => 'admin', 'page' => 'blogtng', 'btng[admin]' => 'search', 'btng[query][filter]' => 'comment', 'btng[query][pid]' => $entry['pid']);
         ptln('<a href="' . wl($ID, $params) . '" title="' . $this->getLang('comments') . '">' . $count . '</a>');
     } else {
         ptln($count);
     }
     ptln('</td>');
     // tags filter links
     ptln('<td class="entry_tags">');
     $this->taghelper->load($entry['pid']);
     $tags = $this->taghelper->getTags();
     $count = count($tags);
     for ($i = 0; $i < $count; $i++) {
         $params = array('do' => 'admin', 'page' => 'blogtng', 'btng[admin]' => 'search', 'btng[query][filter]' => 'tags', 'btng[query][string]' => $tags[$i]);
         $link = '<a href="' . wl($ID, $params) . '" title="' . $tags[$i] . '">' . $tags[$i] . '</a>';
         if ($i < $count - 1) {
             $link .= ', ';
         }
         ptln($link);
     }
     ptln('</td>');
     // edit links
     ptln('<td class="entry_edit">');
     $params = array('id' => $entry['page'], 'do' => 'edit');
     ptln('<a href="' . wl($ID, $params) . '" class="blogtng_btn_edit" title="' . $lang['btn_secedit'] . '">' . $lang['btn_secedit'] . '</a>');
     ptln('</td>');
     ptln('</tr>');
 }
示例#4
0
 /**
  * Save the blog related meta data of a page to the sqlite DB
  *
  * @param Doku_Event $event
  * @param $param
  */
 function handle_action_act_preprocess(Doku_Event $event, $param)
 {
     list($type) = $param;
     switch ($type) {
         case 'before':
             if (is_array($event->data)) {
                 list($this->preact) = array_keys($event->data);
             } else {
                 $this->preact = $event->data;
             }
             break;
         case 'after':
             global $ID;
             if ($this->preact != 'save' || $event->data != 'show') {
                 return;
             }
             // does the page still exist? might be a deletion
             if (!page_exists($ID)) {
                 return;
             }
             $blog = $this->tools->getParam('post/blog');
             $blogs = $this->entryhelper->get_blogs();
             if (!in_array($blog, $blogs)) {
                 $blog = null;
             }
             if ($blog === null) {
                 $this->entryhelper->poke();
             } else {
                 $pid = md5($ID);
                 $this->entryhelper->load_by_pid($pid);
                 $entry = $this->_collectInfoForEntry();
                 $this->entryhelper->set($entry);
                 $this->entryhelper->entry['blog'] = $blog;
                 $this->entryhelper->entry['commentstatus'] = $this->tools->getParam('post/commentstatus');
                 if (empty($this->entryhelper->entry['page'])) {
                     $this->entryhelper->entry['page'] = $ID;
                 }
                 // allow to override created date
                 if ($this->tools->getParam('post/date') && $this->getConf('editform_set_date')) {
                     foreach (array('hh', 'mm', 'MM', 'DD') as $key) {
                         $_REQUEST['btng']['post']['date'][$key] = $_REQUEST['btng']['post']['date'][$key][0] == 0 ? $_REQUEST['btng']['post']['date'][$key][1] : $_REQUEST['btng']['post']['date'][$key];
                     }
                     $time = mktime($this->tools->getParam('post/date/hh'), $this->tools->getParam('post/date/mm'), 0, $this->tools->getParam('post/date/MM'), $this->tools->getParam('post/date/DD'), $this->tools->getParam('post/date/YY'));
                     $this->entryhelper->entry['created'] = $time;
                 }
                 $this->entryhelper->save();
                 $tags = $this->_get_post_tags();
                 if ($tags === false) {
                     $tags = array();
                 }
                 $allowed_tags = $this->_get_allowed_tags();
                 if (count($allowed_tags) > 0) {
                     foreach ($tags as $n => $tag) {
                         if (!in_array($tag, $allowed_tags)) {
                             unset($tags[$n]);
                         }
                     }
                 }
                 $this->taghelper->load($pid);
                 $this->taghelper->setTags($tags);
                 $this->taghelper->save();
             }
             break;
     }
 }