Exemplo n.º 1
0
 private function renderRecursive($nod)
 {
     $ret = '';
     for ($n = 0; $n < $nod->childNodes->length; $n++) {
         $cn = $nod->childNodes->item($n);
         if ($cn->namespaceURI == self::NS_LITEMARKUP) {
             $t = explode(':', $cn->nodeName);
             switch ($t[1]) {
                 case 'debug':
                     $ret .= "THIS IS THE DEBUGGING INFO";
                     break;
                 default:
                     Console::warn("Unknown LiteMarkup tag: %s", $cn->nodeName);
             }
         } else {
             switch ($cn->nodeName) {
                 case '#text':
                     $ret .= $cn->nodeValue;
                     break;
                 default:
                     $ret .= '<' . $cn->nodeName . '>' . $this->renderRecursive($cn) . '</' . $cn->nodeName . '>';
                     break;
             }
         }
     }
     return $ret;
 }
Exemplo n.º 2
0
function module($strinfo, $vars = null)
{
    if (count(ModuleManager::$_order) > 0) {
        $mod = ModuleManager::$_order[count(ModuleManager::$_order) - 1];
        ModuleManager::$_modules[$mod]['modinfo'] = $strinfo;
        if ($vars != null) {
            foreach ($vars as $key => $var) {
                ModuleManager::$_modules[$mod][$key] = $var;
            }
            // Load dependencies
            if (isset($vars['depends']) && is_array($vars['depends'])) {
                $deps = (array) $vars['depends'];
                foreach ($vars['depends'] as $dep) {
                    ModuleManager::load($dep);
                }
            }
        }
    } else {
        Console::warn("Module reported modinfo '%s' without being requested?", $string);
    }
}
Exemplo n.º 3
0
 protected function addField($field, $meta)
 {
     // TODO: Verify the meta format
     $md = explode(' ', $meta);
     $mi = 0;
     $mo = array();
     // Console::debugEx(LOG_DEBUG2,__CLASS__,"Parsing quotes in array for %s", $meta);
     // Console::debugEx(LOG_DEBUG2,__CLASS__," \$md = {'%s'}", join("','", $md));
     while ($mi < count($md)) {
         // Console::debugEx(LOG_DEBUG2,__CLASS__,"Current token: %s", $md[$mi]);
         if ($md[$mi][0] == '"') {
             $buf = array();
             while ($mi < count($md)) {
                 $str = $md[$mi];
                 $buf[] = $md[$mi++];
                 // Console::debugEx(LOG_DEBUG2,__CLASS__," -- Quoted token: %s (%s)", $str, $str[strlen($str)-1]);
                 if ($str[strlen($str) - 2] == '"') {
                     break;
                 }
             }
             $bufstr = join(' ', $buf);
             $bufstr = substr($bufstr, 1, strlen($bufstr) - 2);
             $mo[] = $bufstr;
             Console::debugEx(LOG_DEBUG2, __CLASS__, "Joined quoted statement: %s", $bufstr);
         } else {
             $mo[] = $md[$mi++];
         }
     }
     $md = $mo;
     // Console::debugEx(LOG_DEBUG2,__CLASS__," \$md = {'%s'}", join("','", $md));
     $ftype = null;
     $fdef = null;
     $freq = false;
     $fprot = false;
     $mi = 0;
     while ($mi < count($md)) {
         // Console::debugEx(LOG_DEBUG1,__CLASS__,'Parsing abstract model field %s: %s', $field, $md[$mi]);
         switch (strtolower($md[$mi])) {
             case 'string':
                 $ftype = 'STRING';
                 break;
             case 'int':
                 $ftype = 'INT';
                 break;
             case 'bool':
                 $ftype = 'BOOL';
                 break;
             case 'set':
                 $ftype = 'SET';
                 break;
             case 'enum':
                 $ftype = 'STRING';
                 break;
             case 'required':
                 $freq = true;
                 break;
             case 'protected':
                 $fprot = true;
                 break;
             case 'index':
                 $this->_index = $field;
                 break;
             case 'default':
                 $fdef = $md[++$mi];
                 break;
             case 'like':
                 $flike = $md[++$mi];
                 break;
             case 'in':
             case 'of':
                 $fin = $md[++$mi];
                 break;
             case 'format':
                 if ($ftype == 'INT' || $ftype == 'STRING') {
                     // Check format
                 } else {
                     Console::warn('Format declaration for key %s ignored', $field);
                 }
                 break;
             case 'auto':
                 if ($ftype == 'INT') {
                 } else {
                     Console::warn('Only INT can be auto fields');
                 }
                 $fauto = true;
                 break;
         }
         $mi++;
     }
     if ($ftype != null) {
         $this->_fields[$field] = array('type' => $ftype, 'required' => $freq, 'default' => $fdef, 'protected' => $fprot);
         return true;
     } else {
         Console::warn('Bad type specified for field %s in AbstractModel implementation', $field);
         Console::backtrace();
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  *
  */
 static function conflicts($module)
 {
     if (!is_array(ModuleManager::$_modules)) {
         ModuleManager::$_modules = array();
         return false;
     }
     $module = strtolower($module);
     foreach (ModuleManager::$_modules as $mod => $meta) {
         if ($mod == $module) {
             Console::warn("Requested module %s conflicts with the loaded module %s", $module, ModuleManager::$_order[count(ModuleManager::$_order) - 1]);
         }
     }
     return false;
 }
Exemplo n.º 5
0
 function query($sql, $attr = null)
 {
     Console::debugEx(LOG_DEBUG2, __CLASS__, "SQL Query: %s", $sql);
     $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $qt = new Timer(true);
     try {
         $query = $this->conn->query($sql);
     } catch (PDOException $e) {
         throw new DatabaseException($e->getMessage(), intval($e->getCode()), $e);
     }
     $qtt = $qt->stop();
     if (class_exists('OptimizationReport') && $qtt >= config::get(RuntimeOptimization::KEY_DBQUERYTIME)) {
         $msg = sprintf('<p>The following query took %5.1fs to complete:</p><pre>%s</pre>', $qtt, wordwrap($sql));
         if (class_exists('OptimizationReport')) {
             OptimizationReport::addOptimizationHint('Slow SQL Query', 'DB:00001', 'warning', $msg);
         }
     }
     if ($query) {
         if ($query->rowCount() > 0) {
             try {
                 $fetchmode = MYSQLI_BOTH;
                 if ($attr & QueryAttributes::QATTR_GET_ASSOC) {
                     $data = $query->fetchAll(MYSQLI_ASSOC);
                 } elseif ($attr & QueryAttributes::QATTR_GET_NUMERIC) {
                     $data = $query->fetchAll(MYSQLI_NUM);
                 } else {
                     $data = $query->fetchAll();
                 }
                 $ret = array('data' => $data, 'count' => $query->rowCount(), 'columns' => $query->columnCount(), 'error' => false);
             } catch (PDOException $e) {
                 $ret = array('data' => null, 'count' => $query->rowCount(), 'columns' => null, 'error' => false);
             }
         } else {
             $ret = array('data' => null, 'count' => $query->rowCount(), 'columns' => null, 'error' => false);
         }
     } else {
         $ei = $this->conn->errorInfo();
         Console::warn("Database error: %s (%s)", $ei[2], $ei[0]);
         $ret = array('data' => null, 'count' => 0, 'columns' => 0, 'error' => $ei[2]);
     }
     $this->autonumber = $this->conn->lastInsertId();
     return $ret;
 }