示例#1
0
 /**
  * @param string $text
  * @param mixed $args
  * @return string
  */
 function format($text, $args = array())
 {
     $formatter =& VoodooFormatter::getInstance();
     return $formatter->parse($text, $args);
 }
示例#2
0
 /**
  * @param int $id
  * @param string $content
  * @param bool $actions
  * @param bool|int $revision 
  */
 function execute($id = null, $content = '', $actions = true, $revision = false)
 {
     $handle = '';
     if ($id) {
         $w = new Wiki($this->db);
         $w->set($id, $revision);
         $content = $w->revision->content;
         $handle = $w->handle;
         $this->dispatcher->controller->dispatcherObject = $w;
     }
     // We dont have rights to view wiki's (or this individual page)
     // @see VoodooPrivileges
     if (!$this->hasRights($_SESSION['access'], 'view', $handle)) {
         return array($handle . ' - WikiView', 'No Permission');
     }
     $wf =& VoodooFormatter::getInstance();
     $wf->setWikiPotions($this->dispatcher->conf['potions']);
     // this assumes stuff
     if (isset($this->dispatcher->conf['templates']) && isset($this->dispatcher->conf['templates']['template.' . $handle])) {
         $this->dispatcher->controller->site_template = $this->dispatcher->conf['templates']['template.' . $handle];
     }
     $content = $wf->parse($content, array('handler' => 'wiki', 'action' => $handle));
     // Add simple template in case the rights are to modify/delete
     // We were told to show actions, so lets verify the rights
     $buttons = '';
     $attachments = (bool) (isset($this->dispatcher->conf['attachment']) && $this->dispatcher->conf['attachment'] && defined('ATTACHMENT_CLASSES'));
     // We can modify the wiki page, show the button to do so
     if ($actions && $this->hasRights($_SESSION['access'], 'modify', $handle)) {
         $args = $this->defaultArgs;
         $args['button_action'] = '/wiki/' . $handle . '?action=edit';
         $args['button'] = 'Edit this page';
         $args['class'] = 'buttonmargin';
         $buttons .= $this->template->parse('button', $args);
         // We can add attachments
         // TODO: we dont want the wiki to know anything about attachments
         if ($attachments) {
             $args = $this->defaultArgs;
             $args['button_action'] = '/attachment/wiki/' . $handle . '?action=create';
             $args['button'] = 'Attach file';
             $args['class'] = 'buttonmargin';
             $buttons .= $this->template->parse('button', $args);
         }
     }
     $buttons .= '<span class="spacer"></span>';
     // We can view the history of the wiki page, show the button
     if ($actions && $this->hasRights($_SESSION['access'], 'history', $handle)) {
         $args = $this->defaultArgs;
         $args['button_action'] = '/wiki/' . $handle . '?action=history';
         $args['button'] = 'View page history';
         $args['class'] = 'buttonlargemargin';
         $buttons .= $this->template->parse('button', $args);
     }
     // We can delete the wiki page, show the button
     if ($actions && $this->hasRights($_SESSION['access'], 'delete', $handle)) {
         $args = $this->defaultArgs;
         $args['button_action'] = '/wiki/' . $handle . '?action=delete';
         $args['button'] = 'Delete page';
         $args['class'] = 'buttonmargin';
         $buttons .= $this->template->parse('button', $args);
     }
     $this->siteArgs['view']['active'] = 'active';
     $this->addSiteArgs();
     return array($handle . ' - WikiView', $this->template->parse('view', array('content' => $content, 'buttons' => $buttons)));
 }