Ejemplo n.º 1
0
 function getParameter($name, $default = null)
 {
     // {handler}.{method}:{parameters}
     if (preg_match("/^(\\w+(?:\\.\\w+)?):(\\w+)\$/", $name, $aux)) {
         if ($aux[2] == 'handler_file') {
             $res = $this->__h_include("{$aux[1]}.main");
             return $res[0];
         }
         $value = null;
         // load in cascade ...
         $hc = explode('_', $aux[1]);
         $origin = null;
         $ct = count($hc);
         for ($i = $ct; $i > 0; $i--) {
             $hc_c = implode('_', $hc);
             // ... from cache
             if (isset($GLOBALS['tt780'][$this->id]['parameters'][$hc_c]) && isset($GLOBALS['tt780'][$this->id]['parameters'][$hc_c][$aux[2]])) {
                 $value = $GLOBALS['tt780'][$this->id]['parameters'][$hc_c][$aux[2]];
                 break;
             }
             // ... from configuration
             if (isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]) && is_array($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]) && isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters']) && isset($GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters'][$aux[2]])) {
                 $origin = true;
                 $value = $GLOBALS['tt780'][$this->id]['configuration'][$hc_c]['parameters'][$aux[2]];
                 break;
             }
             array_pop($hc);
         }
         if ($value) {
             $pre = array();
             $pre[$aux[2]] = $value;
             $pre2 = new Parameters();
             if ($origin) {
                 $pre2->origin('configuration_file');
             }
             $pre2->concat($GLOBALS['tt780'][$this->id]['globals']);
             // por si necesita valores de contexto
             $pre2->concat($pre);
             $res = $pre2->getParameter($aux[2], $default);
             return $res;
         }
     }
     // ???
     $cursor = count($this->cursor);
     if ($cursor > 0 && isset($this->cursor[$cursor - 1]) && isset($this->cursor[$cursor - 1][$name])) {
         return $this->cursor[$cursor - 1][$name];
     }
     return $GLOBALS['tt780'][$this->id]['globals']->getParameter($name, $default);
 }