public function data(array $data = null) { if (null === $this->data) { if (!isset($this->data)) { $this->data = array(); } $this->data['DIR'] = getcwd() . DIRECTORY_SEPARATOR; $this->data['CONFIGFILE'] = $this->data['DIR'] . 'config.frdl.php'; $this->data['o'] = new \stdclass(); $this->data['data_out'] = new \stdclass(); $this->data['config'] = array(); $this->data['settings'] = new \stdclass(); $this->data['settings']->cli = array('frdl' => array('cli.cmd.cli' => 'frdl', 'cli.class' => '\\frdl\\ApplicationComposer\\Console', 'cli.class.required.parent' => '\\frdl\\aSQL\\Engines\\Terminal\\CLI')); $this->data['tpl_data'] = array('FILE' => htmlentities(__FILE__), 'URI_DIR_API' => self::URI_DIR_API, 'LOCATION' => 'http://' . $_SERVER['SERVER_NAME'] . implode('/', \webdof\wURI::getInstance()->getU()->dirs) . '/' . \webdof\wURI::getInstance()->getU()->file, 'URL' => '', 'EXTRA_PMX_URL' => ''); $h = parse_url($this->data['tpl_data']['LOCATION']); $pu = \webdof\wURI::parse_uri($h['scheme'], $h['host'], $h['path']); $path = '/'; foreach ($pu->dirs as $num => $dir) { $path .= $dir . '/'; } $this->data['installed'] = false; $this->data['index'] = 'Main Template'; if (is_array($data) || is_object($data)) { foreach ($data as $k => $v) { if (isset($this->data[$k])) { $this->data[$k] = $v; } } } \webfan\App::God()->{'?session_started'}(true); // $sessionKey = __CLASS__. sha1( $h['host'] ); $sessionKey = __CLASS__; if (!isset($_SESSION[$sessionKey])) { $_SESSION[$sessionKey] = array(); } $this->aSess =& $_SESSION[$sessionKey]; $this->data['config_new'] = $this->readFile('config.json'); $this->data['config'] = $this->data['config_new']; if (file_exists($this->data['CONFIGFILE'])) { require $this->data['CONFIGFILE']; $this->data['installed'] = "1"; } else { $this->data['installed'] = "0"; } $this->data['config_new'] = (array) $this->data['config_new']; $this->data['config'] = array_merge($this->data['config_new'], (array) $this->data['config']); $this->data['config']['INSTALLED'] = $this->data['installed']; if (base64_decode('eyRfX0xPQ0FUSU9OX19ffQ==') === $this->data['config']['URL']) { $this->data['config']['URL'] = $this->data['tpl_data']['LOCATION']; if (true === $this->debug) { trigger_error(self::HINT_NOTINSTALLED, E_USER_WARNING); } } $this->data['tpl_data']['URL'] =& $this->data['config']['URL']; $this->data['tpl_data']['URL'] = str_replace('setup.phpsetup.php', 'setup.php', $this->data['tpl_data']['URL']); $this->data['tpl_data']['URI_DIR_API'] = $this->data['tpl_data']['URL'] . 'api.php'; $this->data['config']['URL_API_ORIGINAL'] = $this->data['tpl_data']['URI_DIR_API']; $this->data['config']['URL_API_ORIGINAL'] = str_replace('setup.phpapi.php', 'api.php', $this->data['config']['URL_API_ORIGINAL']); $this->data['tpl_data']['URI_DIR_API'] = str_replace('setup.phpapi.php', 'api.php', $this->data['tpl_data']['URI_DIR_API']); /* $this->data['tpl_data']['PACKAGE'] = function(){ return $this->data['config']['PACKAGE']; }; $this->data['tpl_data']['VERSION'] = function(){ return $this->data['config']['VERSION']; }; $this->data['tpl_data']['INSTALLED'] = function(){ return $this->data['config']['INSTALLED']; }; $this->data['tpl_data']['REGISTERED'] = function(){ return $this->data['config']['REGISTERED']; }; $this->data['tpl_data']['UNAME'] = function(){ return $this->data['config']['UNAME']; }; $this->data['tpl_data']['UID'] = function(){ return $this->data['config']['UID']; }; */ $this->data['INSTALLER_PHAR_AVAILABLE'] = '0'; $this->data['tpl_data']['EXTRA_PHAR_URL'] = ''; $this->data['tpl_data']['INSTALLER'] = ''; if (function_exists('frdl_install_rewrite_function') || file_exists($this->data['DIR'] . 'install.phar') || file_exists($this->data['DIR'] . 'install.php')) { $this->_installFromPhar(\webdof\wURI::getInstance()); } /* $this->data['tpl_data']['INSTALLER_PHAR_AVAILABLE'] = function(){ return $this->data['INSTALLER_PHAR_AVAILABLE']; }; */ } else { if (is_array($data)) { foreach ($data as $k => $v) { $this->data[$k] = $v; } } } if (!isset($path)) { $h = parse_url($this->data['tpl_data']['LOCATION']); $pu = \webdof\wURI::parse_uri($h['scheme'], $h['host'], $h['path']); $path = '/'; foreach ($pu->dirs as $num => $dir) { $path .= $dir . '/'; } } $this->data['config']['EXTRA'] = $this->_extra($this->data); $this->data['tpl_data']['EXTRA_IS_PMX'] = true === $this->data['config']['EXTRA']['extra']['pragmamx']['main'] ? 'yes' : 'no'; $this->data['tpl_data']['EXTRA_IS_WP'] = true === $this->data['config']['EXTRA']['extra']['wordpress']['main'] ? 'yes' : 'no'; $this->data['template_main_options'] = array('Title' => 'Webfan - Application Composer', 'css' => array(), 'meta' => array(array('http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8'), array('http-equiv' => 'content-style-type', 'content' => 'text/css'), array('http-equiv' => 'content-script-type', 'content' => 'text/javascript'), array('http-equiv' => 'content-script-type', 'content' => 'text/javascript'), array('name' => 'mobile-web-app-capable', 'content' => 'yes'), array('name' => 'apple-mobile-web-app-capable', 'content' => 'yes'), array('name' => 'apple-mobile-web-app-status-bar-style', 'content' => 'lightblue'), array('name' => 'HandheldFriendly', 'content' => 'true'), array('name' => 'MobileOptimized', 'content' => '320'), array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0, user-scalable=yes'), array('name' => 'flow.component.frdl.webfan.api.url', 'content' => $this->data['tpl_data']['URI_DIR_API']), array('name' => 'flow.component.frdl.webfan.api.url.initial', 'content' => $this->data['tpl_data']['URI_DIR_API']), array('name' => 'webfan-registration-key', 'content' => isset($this->data['config']['REGISTRATIONKEY']) ? $this->data['config']['REGISTRATIONKEY'] : isset($this->data['config_new']['REGISTRATIONKEY']) ? $this->data['config_new']['REGISTRATIONKEY'] : '')), 'link' => array(array('rel' => 'package', 'type' => 'application/package', 'href' => 'https://github.com/frdl/webfan/archive/master.zip'), array('rel' => 'manifest', 'type' => 'application/manifest+json', 'href' => str_replace('setup.php', '', $this->data['config']['URL']) . 'manifest.webapp'), array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => str_replace('setup.php', '', $this->data['config']['URL']) . '/favicon.ico')), 'js' => array('phar' !== $this->data['tpl_data']['INSTALLER'] && file_Exists($this->data['CONFIGFILE']) && file_exists($this->data['DIR'] . 'js' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'flow.js') ? 'js/lib/flow.js' : 'http://api.webfan.de/api-d/4/js-api/library.js')); if (isset($_GET['intents'])) { $this->data['template_main_options']['js'][] = 'http://webfan.de/cdn/frdl/flow/components/webfan/webfat/js/intents.js'; } return $this->data; }
public function j() { return \webfan\App::God(); }
/** * todo... * */ protected function apply_fm_flow() { $args = func_get_args(); $THIS =& $this; $SELF =& $this; \webfan\App::God()->{'$'}('?session_started', function ($startIf = true) use($THIS, $SELF) { $r = false; if (php_sapi_name() !== 'cli') { if (version_compare(phpversion(), '5.4.0', '>=')) { $r = session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; } else { $r = '' === session_id() ? FALSE : TRUE; } } if (true === $startIf && false === $r) { if (!session_start()) { if (isset($THIS) && isset($THIS->debug) && true === $THIS->debug) { trigger_error('Cannot start session in ' . basename(__FILE__) . ' ' . __LINE__, E_USER_WARNING); } } } return $r; }); $func_jsonP = function ($str) use($THIS, $SELF) { $r = isset($THIS) && isset($THIS->data['data_out']) ? $THIS->data['data_out'] : new \stdclass(); $r->type = 'print'; $r->out = $str; $fnregex = "/^[A-Za-z0-9\$\\.-_\\({1}\\){1}]+\$/"; $callback = isset($_REQUEST['callback']) && preg_match($fnregex, $_REQUEST['callback']) ? strip_tags($_REQUEST['callback']) : ''; if ($callback === '') { $o = json_encode($r); } else { $r->callback = $callback; $o = $callback . '(' . json_encode($r) . ')'; } return $o; }; /** * http://php.net/manual/en/function.apache-request-headers.php#116645 */ \webfan\App::God()->{'$'}('?request_headers', function () { if (function_exists('apache_request_headers')) { return apache_request_headers(); } foreach ($_SERVER as $K => $V) { $a = explode('_', $K); if (array_shift($a) === 'HTTP') { array_walk($a, function (&$v) { $v = ucfirst(strtolower($v)); }); $retval[join('-', $a)] = $V; } } return $retval; }); \webfan\App::God()->{'$'}('$.sem.parse', function ($sem) use($THIS, $SELF) { $str = $SELF::TPL_SERVER_ROUTE; foreach ($sem as $k => $v) { $s = is_array($v) ? implode(',', $v) : $v; $str = str_replace('{$' . $k . '}', $s, $str); } return $str; })->{'$'}('$.sem.unparse', function (&$sem, $route) use($THIS, $SELF) { $seg = explode('.', $route); $sem['cmd'] = array_shift($seg); $sem['responseformat'] = array_shift($seg); $sem['modul'] = array_shift($seg); $sem['responsebuffers'] = explode(',', array_shift($seg)); $sem['.nodes'] = $seg; return $THIS; })->{'$'}('$.sem->getFomatterMethod', function ($format) { if ('jsonp' !== $format && 'json' !== $format) { return false; } return '$.sem.format->' . $format; })->{'$'}('$.sem.format->json', $func_jsonP)->{'$'}('$.sem.format->jsonp', $func_jsonP)->{'$'}('$.sem.get->mime', function ($format = null, $file = null, $apply = true, $default = '') use($THIS, $SELF) { $file = null === $file || !is_string($file) ? \webdof\wURI::getInstance()->getU()->file : $file; if (true === $apply) { $THIS->format = $default; } $mime_types = array('' => array('text/html'), 'frdl' => array('application/frdl-bin'), 'jpg' => array('image/jpeg'), 'jpeg' => array('image/jpeg'), 'jpe' => array('image/jpeg'), 'gif' => array('image/gif'), 'png' => array('image/png'), 'bmp' => array('image/bmp'), 'flv' => array('video/x-flv'), 'js' => array('application/x-javascript'), 'json' => array('application/json'), 'jsonp' => array('application/x-javascript'), 'tiff' => array('image/tiff'), 'css' => array('text/css'), 'xml' => array('application/xml'), 'doc' => array('application/msword'), 'docx' => array('application/msword'), 'xls' => array('application/vnd.ms-excel'), 'xlm' => array('application/vnd.ms-excel'), 'xld' => array('application/vnd.ms-excel'), 'xla' => array('application/vnd.ms-excel'), 'xlc' => array('application/vnd.ms-excel'), 'xlw' => array('application/vnd.ms-excel'), 'xll' => array('application/vnd.ms-excel'), 'ppt' => array('application/vnd.ms-powerpoint'), 'pps' => array('application/vnd.ms-powerpoint'), 'rtf' => array('application/rtf'), 'pdf' => array('application/pdf'), 'html' => array('text/html'), 'htm' => array('text/html'), 'php' => array('text/html'), 'txt' => array('text/plain'), 'mpeg' => array('video/mpeg'), 'mpg' => array('video/mpeg'), 'mpe' => array('video/mpeg'), 'mp3' => array('audio/mpeg3'), 'wav' => array('audio/wav'), 'aiff' => array('audio/aiff'), 'aif' => array('audio/aiff'), 'avi' => array('video/msvideo'), 'wmv' => array('video/x-ms-wmv'), 'mov' => array('video/quicktime'), 'zip' => array('application/zip'), 'tar' => array('application/x-tar'), 'swf' => array('application/x-shockwave-flash'), 'odt' => array('application/vnd.oasis.opendocument.text'), 'ott' => array('application/vnd.oasis.opendocument.text-template'), 'oth' => array('application/vnd.oasis.opendocument.text-web'), 'odm' => array('application/vnd.oasis.opendocument.text-master'), 'odg' => array('application/vnd.oasis.opendocument.graphics'), 'otg' => array('application/vnd.oasis.opendocument.graphics-template'), 'odp' => array('application/vnd.oasis.opendocument.presentation'), 'otp' => array('application/vnd.oasis.opendocument.presentation-template'), 'ods' => array('application/vnd.oasis.opendocument.spreadsheet'), 'ots' => array('application/vnd.oasis.opendocument.spreadsheet-template'), 'odc' => array('application/vnd.oasis.opendocument.chart'), 'odf' => array('application/vnd.oasis.opendocument.formula'), 'odb' => array('application/vnd.oasis.opendocument.database'), 'odi' => array('application/vnd.oasis.opendocument.image'), 'oxt' => array('application/vnd.openofficeorg.extension'), 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), 'docm' => array('application/vnd.ms-word.document.macroEnabled.12'), 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.template'), 'dotm' => array('application/vnd.ms-word.template.macroEnabled.12'), 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), 'xlsm' => array('application/vnd.ms-excel.sheet.macroEnabled.12'), 'xltx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.template'), 'xltm' => array('application/vnd.ms-excel.template.macroEnabled.12'), 'xlsb' => array('application/vnd.ms-excel.sheet.binary.macroEnabled.12'), 'xlam' => array('application/vnd.ms-excel.addin.macroEnabled.12'), 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation'), 'pptm' => array('application/vnd.ms-powerpoint.presentation.macroEnabled.12'), 'ppsx' => array('application/vnd.openxmlformats-officedocument.presentationml.slideshow'), 'ppsm' => array('application/vnd.ms-powerpoint.slideshow.macroEnabled.12'), 'potx' => array('application/vnd.openxmlformats-officedocument.presentationml.template'), 'potm' => array('application/vnd.ms-powerpoint.template.macroEnabled.12'), 'ppam' => array('application/vnd.ms-powerpoint.addin.macroEnabled.12'), 'sldx' => array('application/vnd.openxmlformats-officedocument.presentationml.slide'), 'sldm' => array('application/vnd.ms-powerpoint.slide.macroEnabled.12'), 'thmx' => array('application/vnd.ms-officetheme'), 'onetoc' => array('application/onenote'), 'onetoc2' => array('application/onenote'), 'onetmp' => array('application/onenote'), 'onepkg' => array('application/onenote'), 'po' => array("Content-Type: text/plain; charset=UTF-8;", "Content-Transfer-Encoding: 8bit\n"), 'key' => array('application/pkcs8'), 'crt' => array('application/x-x509-ca-cert'), 'cer' => array('pkix-cert'), 'crl' => array('application/x-pkcs7-crl'), 'pfx' => array('application/x-pkcs12'), 'bin' => array("Content-Type: application/octet-stream", "Content-Transfer-Encoding: binary\n"), 'dat' => array("Content-Type: application/octet-stream", "Content-Transfer-Encoding: binary\n", 'Content-Disposition:attachment; filename="' . $file . '"')); $fnFromatFromHeaders = function () use($mime_types) { /** * * @todo * */ return false; $headers = \webfan\App::God()->{'?request_headers'}(); if (isset($headers['Accept'])) { $accepts = explode(',', $headers['Accept']); if (count($accepts) === 1) { $_ = explode('/', $accepts[0]); $_ = explode(';', $_[1]); $_ = explode('+', $_[0]); if ('*' !== $_s[0]) { return isset($mime_types[$_s[0]]) ? $_s[0] : false; } } } return false; }; if (null === $format || false === $format || !isset($mime_types[$format])) { $fromHeaders = $fnFromatFromHeaders(); $_e = explode('.', $file); $_e = array_reverse($_e); $extension = count($_e) > 1 ? $_e[0] : ''; if ('?' === $format) { $format = $extension; if (!isset($mime_types[$format]) && false !== $fromHeaders) { $format = $fromHeaders; } } elseif ('?:extension' === $format) { $format = $extension; } elseif ('?:headers' === $format) { $format = $fromHeaders; } } if (null !== $format && false !== $format) { if (true === $apply) { $THIS->format = $format; } return isset($mime_types[$format]) ? $mime_types[$format] : false; } else { return $mime_types; } }); return $this; }
protected final function default_boot() { \webfan\App::God()->addStreamWrapper('webfan', 'fexe', $this, true); return $this; }