static function make($data) { $page = array(); $moduleMix = so_package::make()['-mix']->dir; $page[] = array('?xml-stylesheet' => array('href' => (string) $moduleMix[static::$mode . '.xsl']->uriVersioned, 'type' => 'text/xsl')); $page[] = array('so_page' => array('@so_page_styles' => (string) $moduleMix[static::$mode . '.css']->uriVersioned, '@so_page_script' => (string) $moduleMix[static::$mode . '.js']->uriVersioned, '@so_page_icon' => (string) so_file::make('icon.png')->uriVersioned, $data)); return so_dom::make($page)->doc; }
function list_store($list) { $list = (array) $list; foreach ($list as $key => $package) { if (!is_numeric($key)) { continue; } unset($list[$key]); $package = so_package::make($package); $list += $package->packages->list; } return $list; }
static function start($package, $mode = 'dev') { register_shutdown_function(array(get_class(), 'finalize')); ob_start(); so_error::monitor(); foreach (parse_ini_file(so_file::make('php.ini')) as $key => $value) { ini_set($key, $value); } so_page::$mode = $mode; so_package::$defaultName = $package; so_query::$resourcePrefix = $package; $front = so_front::make(); $query = $front->uri->query; $resource = $query->resource; $uriStandard = $resource->uri; if ($query->uri != $uriStandard) { return static::$response = so_output::moved((string) $uriStandard); } static::$response = $resource->execute($front->method, $front->data); }
function send($response) { $content = $response->content; $mime = $content->mime; $cache = $response->cache; $private = $response->private; if ($mime === 'application/xml') { $accept = preg_split('~[,;] ?~', strtolower(so_value::make($_SERVER['HTTP_ACCEPT']) ?: '')); if (!in_array('application/xhtml+xml', $accept)) { $xs = new so_xstyle(); $xs->pathXSL = (string) so_package::make()['-mix']['release.xsl']->file; $xsl = $xs->docXSL; foreach ($xsl->childs['xsl:include'] as $dom) { $dom['@href'] = preg_replace('!\\?[^?]*$!', '', $dom['@href']); } $content = (string) $xs->process((string) $content); $content = preg_replace('~^<\\?xml .+?\\?>\\n?~', '', $content); $mime = 'text/html'; } } $encoding = $response->encoding; $code = static::$codeMap[$response->status]; header("Content-Type: {$mime}", true, $code); if (!$private) { header("Access-Control-Allow-Origin: *", true); } if ($cache) { header("Cache-Control: " . ($private ? 'private' : 'public'), true); } else { header("Cache-Control: no-cache", true); } if ($location = $response->location) { header("Location: {$location}", true); } echo str_pad($content, 512, ' ', STR_PAD_RIGHT); return $this; }
function offsetGet($name) { return so_package::make($this->dir->go($name)); }
function package_store($data) { return so_package::make($data); }
function package_make() { return so_package::make($this->dir->parent); }