/** * 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; }
/** * 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>'); }
/** * 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; } }