Ejemplo n.º 1
0
 function route($a_route = null, $a_method = null)
 {
     $method = Zoombi_String::normalize(!$a_method ? $_SERVER['REQUEST_METHOD'] : '');
     $router = isset($this->router->{$method}) ? $this->router->{$method} : null;
     if ($router) {
         return $router->route(!$a_route ? $_SERVER['REQUEST_URI'] : '');
     }
     return false;
 }
Ejemplo n.º 2
0
     echo $t['class'] . $t['type'];
 }
 $args = array();
 foreach ($t['args'] as $a) {
     switch (gettype($a)) {
         default:
             $args[] = $a;
             break;
         case null:
             $args[] = 'NULL';
             break;
         case 'string':
             if (file_exists($a) && is_file($a)) {
                 $args[] = '"' . str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', $a) . '"';
             } else {
                 $args[] = '"' . (strlen($a) > 40 ? Zoombi_String::truncate($a, 40) : $a) . '"';
             }
             break;
         case 'array':
             if (is_callable($a)) {
                 list($obj, $act) = $a;
                 if (is_object($obj)) {
                     $args[] = get_class($obj) . '->' . $act;
                 } else {
                     $args[] = $obj . '->' . $act;
                 }
             } else {
                 $args[] = 'Array(' . count($a) . ')';
             }
             break;
         case 'object':
Ejemplo n.º 3
0
 private function _decorateController(Zoombi_Controller &$a_controller)
 {
     if (isset($a_controller->action)) {
         $a_controller->addAction($a_controller->action);
         unset($a_controller->action);
     }
     if (isset($a_controller->model)) {
         if (is_string($a_controller->model)) {
             $a_controller->setModels(explode(' ', $a_controller->model));
         }
         if (is_array($a_controller->model)) {
             $a_controller->setModels($a_controller->model);
         }
         unset($a_controller->model);
     }
     if (isset($a_controller->helper)) {
         $helpers = array();
         switch (gettype($a_controller->helper)) {
             default:
                 $this->triggerError("Controller '{$a_controller->getName()}':  has wrong helper type.", Zoombi_Exception_Controller::EXC_MODEL);
                 break;
             case 'string':
                 $helpers = explode(' ', trim($a_controller->helper));
                 break;
             case 'array':
                 $helpers =& $a_controller->helper;
                 break;
         }
         foreach ($helpers as $h) {
             $name = Zoombi_String::normalize($h);
             if (empty($name)) {
                 continue;
             }
             $loader =& $this;
             if (substr($name, 0, 1) == Zoombi::SS) {
                 $loader =& Zoombi::getApplication()->getLoader();
                 $name = substr($name, 1);
             }
             if (!$loader) {
                 if ($this->getModule()->isMode(Zoombi_Module::MODE_DEBUG)) {
                     $this->triggerError('Bad loader');
                 }
             }
             try {
                 $loader->helper($name);
             } catch (Zoombi_Exception_Helper $e) {
                 if ($this->getModule()->isMode(Zoombi_Module::MODE_DEBUG)) {
                     $this->triggerError($e);
                 }
             }
         }
         unset($a_controller->helper);
     }
     if (isset($a_controller->map)) {
         if (is_array($a_controller->map)) {
             $a_controller->setMaps($a_controller->map);
         }
         if (is_object($a_controller->map)) {
             $a_controller->setMaps(get_object_vars($a_controller->map));
         }
         unset($a_controller->map);
     }
 }
Ejemplo n.º 4
0
 /**
  * Check if controller has a action
  * @param string $a_action
  * @return bool
  */
 public function hasAction($a_action)
 {
     switch (gettype($a_action)) {
         default:
             $name = $this->_actionMin(Zoombi_String::normalize($a_action));
             return method_exists($this, $this->_actiomMax($name)) or array_key_exists($name, $this->m_actions);
         case 'array':
             if (count($a_action) == 2) {
                 if ($a_action[0] == $this or is_a($a_action[0], get_class($this))) {
                     return $this->hasAction($a_action[1]);
                 }
             }
             break;
         case 'object':
             foreach ($this->m_actions as &$a) {
                 if ($a === $a_action) {
                     return true;
                 }
             }
             break;
     }
     return false;
 }