Example #1
0
 /**
  * @return string
  */
 function init()
 {
     $r =& VoodooRegistry::getInstance();
     $template =& VoodooTemplate::getInstance();
     $template->setDir(WIKI_TEMPLATES);
     $vc =& $r->registry('VC');
     $temp = 'wiki.login';
     $args = array('prepath' => PATH_TO_DOCROOT, 'loginpath' => $this->formatter->handler . '/' . $this->formatter->action);
     if (isset($_POST['action']) && $_POST['action'] == 'dologin' && !empty($_POST['handle'])) {
         // Check success of the login action
         if ($this->login($this->formatter->db, $_POST['handle'], $_POST['passwd'])) {
             return $this->display = VoodooError::displayError('Succesfully Logged in.');
         } else {
             $args['message'] = VoodooError::displayError('Incorrect Username and/or Password.');
         }
     } elseif (isset($_GET['action']) && $_GET['action'] == 'logout') {
         $this->logout();
     }
     // Hey! We're already logged in
     // TODO: mkpretty
     if (isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) {
         return $this->display = sprintf('You are already logged in. <a href="%s/%s/%s?action=logout">Logout</a>', PATH_TO_DOCROOT, $this->formatter->handler, $this->formatter->action);
     }
     // Parse the login screen from the template
     return $this->display = $template->parse($temp, $args);
 }
Example #2
0
 /**
  * 
  */
 function &load($name)
 {
     $name = strtolower($name);
     $registry =& VoodooRegistry::getInstance();
     if (!($conf = $registry->registry('ini.' . $name))) {
         return VoodooIni::register($registry, $name);
     }
     return $conf;
 }
Example #3
0
 /**
  * 
  */
 function init()
 {
     $r =& VoodooRegistry::getInstance();
     $template =& VoodooTemplate::getInstance();
     $template->setDir(WIKI_TEMPLATES);
     $vc =& $r->registry('VC');
     $temp = 'wiki.register';
     $args = array('prepath' => PATH_TO_DOCROOT, 'loginpath' => $this->formatter->handler . '/' . $this->formatter->action);
     if (isset($_POST['action']) && $_POST['action'] == 'doregister' && !empty($_POST['handle'])) {
         // We do not have a failure! Happy Time!
         if (!($failure = $this->register($this->formatter->db))) {
             return $this->display = VoodooError::displayError('Succesfully Registered `' . $_POST['handle'] . '`.');
         } else {
             $args['message'] = VoodooError::displayError(sprintf('Registration failed: %s', $failure));
         }
     }
     if ($_SESSION['user_id'] > 0) {
         return $this->display = 'You are already registered.';
     }
     return $this->display = $template->parse($temp, $args);
 }
Example #4
0
 /**
  * Execute any hooks that should be completed before display
  * @param array $actionlist
  */
 function executePreDisplayHooks($actionlist)
 {
     $registry =& VoodooRegistry::getInstance();
     $controller = $registry->registry('controller');
     $hooks = $registry->registry('hooks');
     foreach ($hooks as $class => $instance) {
         $instance->setDB($this->DBConnect());
         foreach ($instance->preDisplayHooks() as $hook => $callback) {
             list($obj, $func) = $callback;
             $action = $this->dispatcherObject ? array($this->dispatcherObject) : $actionlist;
             $this->content = $obj->{$func}($controller, $action, $this->content);
         }
     }
 }
Example #5
0
 /**
  * @static
  */
 function requirePotion($potion)
 {
     $path = explode('_', $potion);
     if (count($path) == 1) {
         $path = SPELLBOOK . 'Wiki/Potions/';
     } elseif (count($path) > 2) {
         trigger_error('Incorrect WikiPotion definition', E_USER_ERROR);
         exit;
     } else {
         $registry =& VoodooRegistry::getInstance();
         $vc =& $registry->registry('VC', $this);
         $potion = $path[1];
         $path = $path[0];
         if (!array_key_exists(strtolower($path), $vc->conf['controllers'])) {
             return false;
         }
         if (!$vc->conf['controllers'][strtolower($path)]) {
             return false;
         }
         $path = SPELLBOOK . $path . '/Potions/';
     }
     // Does the potion actually exist?
     if (!is_file($path . $potion . '.php')) {
         return false;
     }
     // Yes it does, lets make a new instance of it
     require_once $path . $potion . '.php';
     return $potion;
 }
Example #6
0
 /**
  * @return VoodooFormatter 
  */
 function &getInstance()
 {
     $registry =& VoodooRegistry::getInstance();
     return $registry->registry('formatter');
 }