public static function get() { $rmFile = preg_replace("/\\/\\*([^x00]*)\\*?\\/?\\*\\//U", "", Filesystem::getFileContent(Config::ROADMAP)); $roadMap = JSON::decode($rmFile, true); $tmpl = self::$_attr; $cnt = 0; $good = is_array($roadMap); //print_r( $roadMap ); die; for ($i = 0; $good && is_array($roadMap) && $i < count($roadMap); $i++) { $el = $roadMap[$i]; foreach ($el as $k => $v) { if (($pos = array_search($k, $tmpl)) !== FALSE) { $tmpl[$pos] = "asnfcjrwpht984fh9prewgf84fds"; $cnt++; } } $good = $cnt == count(self::$_attr); } if ($good) { return $roadMap; } else { self::raiseException(ERR_ROADMAP); return NULL; } }
public static function &buildTree($source, $mode = XMLDocument::BUILD_MODE_FROM_FILE, $ns = NULL) { if ($mode == XMLDocument::BUILD_MODE_FROM_FILE) { if (($content = Filesystem::getFileContent($source)) === NULL) { return NULL; } } else { if ($source == "" || $source == NULL) { return new xmlTree(); } $content = $ns == NULL ? "<ROOT>" . $source . "</ROOT>" : "<ROOT xmlns:{$ns}=\".\">" . $source . "</ROOT>"; } /*$content = ereg_replace( "&", "&", $content ); $content = ereg_replace( "&", "&", $content );*/ //echo $content; $content = preg_replace("/&/", "&", $content); $content = preg_replace("/&/", "&", $content); $content = iconv("windows-1251", "UTF-8", $content); $reader = new XMLReader(); if ($reader->XML($content)) { $_docTree = NULL; $_docTree = new xmlTree(); self::_appendChilds($_docTree->getCurrent(), $reader, 0); $reader = NULL; return $_docTree; } else { self::raiseException(ERR_XML_INVALID_XML, $content); return NULL; } }
public static function getComp($key, $callback_args) { if (self::_exists($key)) { $c = Filesystem::getFileContent(Config::CACHE_DIR . DS . "cache" . DS . $key . ".cache.php"); //echo ( microtime () - self::$_t )."<br/>"; return unserialize($c); } else { $filename = Config::CACHE_DIR . DS . "cache" . DS . $key . ".cache.php"; $content = call_user_func($callback_args); //echo ( microtime () - self::$_t )."<br/>"; Filesystem::saveToFile($filename, serialize($content)); return $content; } }
protected function _compileTemplate($template, $saltAndPepper, $cache = false) { if (isset($this->_templ_cache[$template])) { $template = $this->_templ_cache[$template]; } else { $template_name = $template; $template = Filesystem::getFileContent(__ROOT_PATH . DS . "component" . DS . get_class($this) . DS . $template); if ($cache) { $this->_templ_cache[$template_name] = $template; } } if (!is_array($saltAndPepper) || isset($saltAndPepper[0]) || !is_string($template)) { return NULL; } /* else */ $pattern = array_keys($saltAndPepper); for ($i = 0; $i < count($pattern); $i++) { $pattern[$i] = "/%" . $pattern[$i] . "%/"; } $replacement = array_values($saltAndPepper); return preg_replace($pattern, $replacement, $template); }