public function outputMetaContent($resp) { $bp = jApp::urlBasePath(); $confDate =& jApp::config()->datepickers; $datepicker_default_config = jApp::config()->forms['datepicker']; $config = isset($ctrl->datepickerConfig) ? $ctrl->datepickerConfig : $datepicker_default_config; $resp->addJSLink($bp . $confDate[$config]); }
/** * Load the configuration of authentification, stored in the auth plugin config * @return array * @since 1.2.10 */ public static function loadConfig($newconfig = null) { if (self::$config === null || $newconfig) { if (!$newconfig) { $plugin = jApp::coord()->getPlugin('auth'); if ($plugin === null) { throw new jException('jelix~auth.error.plugin.missing'); } $config =& $plugin->config; } else { $config = $newconfig; } if (!isset($config['session_name']) || $config['session_name'] == '') { $config['session_name'] = 'JELIX_USER'; } if (!isset($config['persistant_cookie_path']) || $config['persistant_cookie_path'] == '') { if (jApp::config()) { $config['persistant_cookie_path'] = jApp::urlBasePath(); } else { $config['persistant_cookie_path'] = '/'; } } if (!isset($config['persistant_encryption_key'])) { if (isset(jApp::config()->coordplugin_auth) && isset(jApp::config()->coordplugin_auth['persistant_encryption_key'])) { $config['persistant_encryption_key'] = trim(jApp::config()->coordplugin_auth['persistant_encryption_key']); } else { $config['persistant_encryption_key'] = ''; } } if (!isset($config['persistant_cookie_name'])) { $config['persistant_cookie_name'] = 'jauthSession'; } // Read hash method configuration. If not empty, cryptPassword will use // the new API of PHP 5.5 (password_verify and so on...) $password_hash_method = isset($config['password_hash_method']) ? $config['password_hash_method'] : 0; if ($password_hash_method === '' || !is_numeric($password_hash_method)) { $password_hash_method = 0; } else { $password_hash_method = intval($password_hash_method); } $password_hash_options = isset($config['password_hash_options']) ? $config['password_hash_options'] : ''; if ($password_hash_options != '') { $list = '{"' . str_replace(array('=', ';'), array('":"', '","'), $config['password_hash_options']) . '"}'; $password_hash_options = @json_decode($list, true); if (!$password_hash_options) { $password_hash_options = array(); } } else { $password_hash_options = array(); } $config['password_hash_method'] = $password_hash_method; $config['password_hash_options'] = $password_hash_options; $config[$config['driver']]['password_hash_method'] = $password_hash_method; $config[$config['driver']]['password_hash_options'] = $password_hash_options; self::$config = $config; } return self::$config; }
/** * Load the configuration of authentification, stored in the auth plugin config * @return array * @since 1.2.10 */ public static function loadConfig($newconfig = null) { if (self::$config === null || $newconfig) { if (!$newconfig) { $plugin = jApp::coord()->getPlugin('auth'); if ($plugin === null) { throw new jException('jelix~auth.error.plugin.missing'); } $config =& $plugin->config; } else { $config = $newconfig; } if (!isset($config['session_name']) || $config['session_name'] == '') { $config['session_name'] = 'JELIX_USER'; } if (!isset($config['persistant_cookie_path']) || $config['persistant_cookie_path'] == '') { if (jApp::config()) { $config['persistant_cookie_path'] = jApp::urlBasePath(); } else { $config['persistant_cookie_path'] = '/'; } } // Read hash method configuration. If not empty, cryptPassword will use // the new API of PHP 5.5 (password_verify and so on...) $password_hash_method = isset($config['password_hash_method']) ? $config['password_hash_method'] : 0; if ($password_hash_method === '' || !is_numeric($password_hash_method)) { $password_hash_method = 0; } else { $password_hash_method = intval($password_hash_method); } if ($password_hash_method > 0) { require_once __DIR__ . '/password.php'; if (!can_use_password_API()) { $password_hash_method = 0; } } else { require_once __DIR__ . '/hash_equals.php'; } $password_hash_options = isset($config['password_hash_options']) ? $config['password_hash_options'] : ''; if ($password_hash_options != '') { $list = '{"' . str_replace(array('=', ';'), array('":"', '","'), $config['password_hash_options']) . '"}'; $json = new jJson(SERVICES_JSON_LOOSE_TYPE); $password_hash_options = @$json->decode($list); if (!$password_hash_options) { $password_hash_options = array(); } } else { $password_hash_options = array(); } $config['password_hash_method'] = $password_hash_method; $config['password_hash_options'] = $password_hash_options; $config[$config['driver']]['password_hash_method'] = $password_hash_method; $config[$config['driver']]['password_hash_options'] = $password_hash_options; self::$config = $config; } return self::$config; }
public function __construct() { $config = jApp::config(); $basePath = jApp::urlBasePath(); $this->_vars['j_basepath'] = $basePath; $this->_vars['j_jelixwww'] = $config->urlengine['jelixWWWPath']; $this->_vars['j_jquerypath'] = $config->urlengine['jqueryPath']; $this->_vars['j_themepath'] = $basePath . 'themes/' . $config->theme . '/'; $this->_vars['j_locale'] = $config->locale; parent::__construct(); }
public function outputHeader($builder) { $conf = jApp::config()->urlengine; // no scope into an anonymous js function, because jFormsJQ.tForm is used by other generated source code echo '<script type="text/javascript"> //<![CDATA[ jFormsJQ.selectFillUrl=\'' . jUrl::get('jelix~jforms:getListData') . '\'; jFormsJQ.config = {locale:' . $builder->escJsStr(jApp::config()->locale) . ',basePath:' . $builder->escJsStr(jApp::urlBasePath()) . ',jqueryPath:' . $builder->escJsStr($conf['jqueryPath']) . ',jelixWWWPath:' . $builder->escJsStr($conf['jelixWWWPath']) . '}; jFormsJQ.tForm = new jFormsJQForm(\'' . $builder->getName() . '\',\'' . $builder->getForm()->getSelector() . '\',\'' . $builder->getForm()->getContainer()->formId . '\'); jFormsJQ.tForm.setErrorDecorator(new ' . $builder->getOption('errorDecorator') . '()); jFormsJQ.declareForm(jFormsJQ.tForm); //]]> </script>'; }
public function outputMetaContent($resp) { $bp = jApp::urlBasePath(); $confWikiEditor =& jApp::config()->wikieditors; if (isset($confWikiEditor[$this->ctrl->config . '.engine.file'])) { $resp->addJSLink($bp . $confWikiEditor[$this->ctrl->config . '.engine.file']); } if (isset($confWikiEditor[$this->ctrl->config . '.config.path'])) { $p = $bp . $confWikiEditor[$this->ctrl->config . '.config.path']; $resp->addJSLink($p . jApp::config()->locale . '.js'); $resp->addCSSLink($p . 'style.css'); } if (isset($confWikiEditor[$this->ctrl->config . '.skin'])) { $resp->addCSSLink($bp . $confWikiEditor[$this->ctrl->config . '.skin']); } }
/** * start a session */ public static function start() { $params =& jApp::config()->sessions; // do not start the session if the request is made from the command line or if sessions are disabled in configuration if (jApp::coord()->request instanceof jCmdLineRequest || !$params['start']) { return false; } //make sure that the session cookie is only for the current application if (!$params['shared_session']) { session_set_cookie_params(0, jApp::urlBasePath()); } if ($params['storage'] != '') { /* on debian/ubuntu (maybe others), garbage collector launch probability is set to 0 and replaced by a simple cron job which is not enough for jSession (different path, db storage, ...), so we set it to 1 as PHP's default value */ if (!ini_get('session.gc_probability')) { ini_set('session.gc_probability', '1'); } switch ($params['storage']) { case 'dao': session_set_save_handler(array(__CLASS__, 'daoOpen'), array(__CLASS__, 'daoClose'), array(__CLASS__, 'daoRead'), array(__CLASS__, 'daoWrite'), array(__CLASS__, 'daoDestroy'), array(__CLASS__, 'daoGarbageCollector')); self::$_params = $params; break; case 'files': session_save_path($params['files_path']); break; } } if ($params['name'] != '') { #ifnot ENABLE_OPTIMIZED_SOURCE if (!preg_match('#^[a-zA-Z0-9]+$#', $params['name'])) { // regexp check because session name can only be alpha numeric according to the php documentation throw new jException('jelix~errors.jsession.name.invalid'); } #endif session_name($params['name']); } if (isset($params['_class_to_load'])) { foreach ($params['_class_to_load'] as $file) { require_once $file; } } session_start(); return true; }
/** * meta plugin : modify an xml response object * * @see jResponseXml * @param jTpl $tpl template engine * @param string $method indicates what you want to specify (possible values : xsl,css,csstheme) * @param mixed $param parameter (a css style sheet url for "css" for example) */ function jtpl_meta_xml_xml($tpl, $method, $param) { $resp = jApp::coord()->response; if ($resp->getFormatType() != 'xml') { return; } switch ($method) { case 'xsl': $resp->addXSLStyleSheet($param); break; case 'css': $resp->addCSSLink($param); break; case 'csstheme': $resp->addCSSLink(jApp::urlBasePath() . 'themes/' . jApp::config()->theme . '/' . $param); break; } }
public function outputMetaContent($resp) { $bp = jApp::urlBasePath(); $confHtmlEditor =& jApp::config()->htmleditors; if (isset($confHtmlEditor[$this->ctrl->config . '.engine.file'])) { if (is_array($confHtmlEditor[$this->ctrl->config . '.engine.file'])) { foreach ($confHtmlEditor[$this->ctrl->config . '.engine.file'] as $url) { $resp->addJSLink($bp . $url); } } else { $resp->addJSLink($bp . $confHtmlEditor[$this->ctrl->config . '.engine.file']); } } if (isset($confHtmlEditor[$this->ctrl->config . '.config'])) { $resp->addJSLink($bp . $confHtmlEditor[$this->ctrl->config . '.config']); } $skin = $this->ctrl->config . '.skin.' . $this->ctrl->skin; if (isset($confHtmlEditor[$skin]) && $confHtmlEditor[$skin] != '') { $resp->addCSSLink($bp . $confHtmlEditor[$skin]); } }
public function outputMetaContent($t) { $resp = jApp::coord()->response; if ($resp === null || $resp->getType() != 'html') { return; } $config = jApp::config(); $www = $config->urlengine['jelixWWWPath']; $bp = jApp::urlBasePath(); $resp->addJSLink($www . 'js/jforms_light.js'); $resp->addCSSLink($www . 'design/jform.css'); $heConf =& $config->htmleditors; foreach ($t->_vars as $k => $v) { if ($v instanceof jFormsBase && count($edlist = $v->getHtmlEditors())) { foreach ($edlist as $ed) { if (isset($heConf[$ed->config . '.engine.file'])) { $file = $heConf[$ed->config . '.engine.file']; if (is_array($file)) { foreach ($file as $url) { $resp->addJSLink($bp . $url); } } else { $resp->addJSLink($bp . $file); } } if (isset($heConf[$ed->config . '.config'])) { $resp->addJSLink($bp . $heConf[$ed->config . '.config']); } $skin = $ed->config . '.skin.' . $ed->skin; if (isset($heConf[$skin]) && $heConf[$skin] != '') { $resp->addCSSLink($bp . $heConf[$skin]); } } } } }
/** * Create a jurl object with the given action data * @param jUrlAction $url information about the action * @return jUrl the url correspondant to the action * @author Laurent Jouanneau * @copyright 2005 CopixTeam, 2005-2006 Laurent Jouanneau * very few lines of code are copyrighted by CopixTeam, written by Laurent Jouanneau * and released under GNU Lesser General Public Licence, * in an experimental version of Copix Framework v2.3dev20050901, * http://www.copix.org. */ public function create($urlact) { if ($this->dataCreateUrl == null) { $sel = new jSelectorUrlCfgSig(jApp::config()->urlengine['significantFile']); jIncluder::inc($sel); $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; } $url = new jUrl('', $urlact->params, ''); $module = $url->getParam('module', jApp::getCurrentModule()); $action = $url->getParam('action'); // let's try to retrieve informations corresponding // to the given action. this informations will allow us to build // the url $id = $module . '~' . $action . '@' . $urlact->requestType; $urlinfo = null; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } else { $id = $module . '~*@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; if ($urlinfo[0] != 3 || $urlinfo[3] === true) { $url->delParam('module'); } } else { $id = '@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; } else { throw new Exception("Significant url engine doesn't find corresponding url to this action :" . $module . '~' . $action . '@' . $urlact->requestType); } } } /* urlinfo = or array(0,'entrypoint', https true/false, 'handler selector', 'basepathinfo') or array(1,'entrypoint', https true/false, array('year','month',), // list of dynamic values included in the url array(true, false..), // list of integers which indicates for each // dynamic value: 0: urlencode, 1:urlencode except '/', 2:escape "/news/%1/%2/", // the url true/false, // false : this is a secondary action array('bla'=>'whatIWant' ) // list of static values ) or array(2,'entrypoint', https true/false), // for the patterns "@request" or array(3,'entrypoint', https true/false), // for the patterns "module~@request" or array(4, array(1,...), array(1,...)...) */ if ($urlinfo[0] == 4) { // an action is mapped to several urls // so it isn't finished. Let's find building information // into the array $l = count($urlinfo); $urlinfofound = null; for ($i = 1; $i < $l; $i++) { $ok = true; // verify that given static parameters of the action correspond // to those defined for this url foreach ($urlinfo[$i][7] as $n => $v) { // specialStatic are static values for which the url engine // can compare not only with a given url parameter value, but // also with a value stored some where (typically, a configuration value) $specialStatic = !empty($v) && $v[0] == '$'; $paramStatic = $url->getParam($n, null); if ($specialStatic) { // special statique value $typePS = $v[1]; $v = substr($v, 2); if ($typePS == 'l') { if ($paramStatic === null) { $paramStatic = jLocale::getCurrentLang(); } else { if (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $paramStatic, $m)) { // if the value is a locale instead of lang, translate it $paramStatic = $m[1]; } } } elseif ($typePS == 'L') { if ($paramStatic === null) { $paramStatic = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $paramStatic, $m)) { // if the value is a lang instead of locale, translate it $paramStatic = jLocale::langToLocale($paramStatic); } } } } if ($paramStatic != $v) { $ok = false; break; } } if ($ok) { // static parameters correspond: we found our informations $urlinfofound = $urlinfo[$i]; break; } } if ($urlinfofound !== null) { $urlinfo = $urlinfofound; } else { $urlinfo = $urlinfo[1]; } } // at this step, we have informations to build the url $url->scriptName = jApp::urlBasePath() . $urlinfo[1]; if ($urlinfo[2]) { $url->scriptName = jApp::coord()->request->getServerURI(true) . $url->scriptName; } if ($urlinfo[1] && !jApp::config()->urlengine['multiview']) { $url->scriptName .= '.php'; } // for some request types, parameters aren't in the url // so we remove them // it's a bit dirty to do that hardcoded here, but it would be a pain // to load the request class to check whether we can remove or not if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) { $url->clearParam(); return $url; } if ($urlinfo[0] == 0) { $s = new jSelectorUrlHandler($urlinfo[3]); $c = $s->resource . 'UrlsHandler'; $handler = new $c(); $handler->create($urlact, $url); if ($urlinfo[4] != '') { $url->pathInfo = $urlinfo[4] . $url->pathInfo; } } elseif ($urlinfo[0] == 1) { $pi = $urlinfo[5]; foreach ($urlinfo[3] as $k => $param) { $typeParam = $urlinfo[4][$k]; $value = $url->getParam($param, ''); if ($typeParam & 2) { $value = jUrl::escape($value, true); } else { if ($typeParam & 1) { $value = str_replace('%2F', '/', urlencode($value)); } else { if ($typeParam & 4) { if ($value == '') { $value = jLocale::getCurrentLang(); } else { if (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $value, $m)) { $value = $m[1]; } } } else { if ($typeParam & 8) { if ($value == '') { $value = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $value, $m)) { $value = jLocale::langToLocale($value); } } } else { $value = urlencode($value); } } } } $pi = str_replace(':' . $param, $value, $pi); $url->delParam($param); } $url->pathInfo = $pi; if ($urlinfo[6]) { $url->setParam('action', $action); } // removed parameters corresponding to static values foreach ($urlinfo[7] as $name => $value) { $url->delParam($name); } } elseif ($urlinfo[0] == 3) { if ($urlinfo[3]) { $url->delParam('module'); } } return $url; }
protected function generateMinifyUrl($urlsList) { $url = jApp::urlBasePath() . jApp::config()->jResponseHtml['minifyEntryPoint'] . '?f='; $url .= implode(',', $urlsList); return $url; }
static function handleError($type, $code, $message, $file, $line, $trace) { $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); // for non fatal error appeared during init, let's just store it for loggers later if ($type != 'error') { self::$initErrorMessages[] = $errorLog; return; } else { if (jServer::isCLI()) { // fatal error appeared during init, in a CLI context while (ob_get_level() && @ob_end_clean()) { } // log into file and output message in the console echo 'Error during initialization: \\n'; foreach (self::$initErrorMessages as $err) { @error_log($err->getFormatedMessage() . "\n", 3, jApp::logPath('errors.log')); echo '* ' . $err->getMessage() . ' (' . $err->getFile() . ' ' . $err->getLine() . ")\n"; } @error_log($errorLog->getFormatedMessage() . "\n", 3, jApp::logPath('errors.log')); echo '* ' . $message . ' (' . $file . ' ' . $line . ")\n"; } else { // fatal error appeared during init, let's display an HTML page // since we don't know the request, we cannot return a response // corresponding to the expected protocol while (ob_get_level() && @ob_end_clean()) { } // log into file foreach (self::$initErrorMessages as $err) { @error_log($err->getFormatedMessage() . "\n", 3, jApp::logPath('errors.log')); } @error_log($errorLog->getFormatedMessage() . "\n", 3, jApp::logPath('errors.log')); $msg = $errorLog->getMessage(); if (strpos($msg, '--') !== false) { list($msg, $bin) = explode('--', $msg, 2); // remove confidential data } // if accept text/html if (isset($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'text/html')) { if (file_exists(jApp::appPath('responses/error.en_US.php'))) { $file = jApp::appPath('responses/error.en_US.php'); } else { $file = JELIX_LIB_CORE_PATH . 'response/error.en_US.php'; } $HEADTOP = ''; $HEADBOTTOM = ''; $BODYTOP = ''; $BODYBOTTOM = htmlspecialchars($msg); $BASEPATH = jApp::urlBasePath(); if ($BASEPATH == '') { $BASEPATH = '/'; } header("HTTP/1.1 500 Internal jelix error"); header('Content-type: text/html'); include $file; } else { // output text response header("HTTP/1.1 500 Internal jelix error"); header('Content-type: text/plain'); echo 'Error during initialization. ' . $msg; } } } exit(1); }
protected function generateMinifyUrl($urlsList) { $entrypoint = 'minify.php'; if (isset(jApp::config()->jResponseHtml['minifyEntryPoint']) && jApp::config()->jResponseHtml['minifyEntryPoint']) { $entrypoint = jApp::config()->jResponseHtml['minifyEntryPoint']; } $url = jApp::urlBasePath() . $entrypoint . '?f='; $url .= implode(',', $urlsList); return $url; }
/** * Generate the WSDL content */ private function _compile() { $url = jUrl::get($this->module . '~' . $this->controller . ':index@soap', array(), jUrl::JURL); $url->clearParam(); $url->setParam('service', $this->module . '~' . $this->controller); $serverUri = jUrl::getRootUrlRessourceValue('soap'); if ($serverUri === null) { $serverUri = jUrl::getRootUrlRessourceValue('soap-' . $this->module); } if ($serverUri === null) { $serverUri = jUrl::getRootUrlRessourceValue('soap-' . $this->module . '-' . $this->controller); } if ($serverUri === null) { $serverUri = jApp::coord()->request->getServerURI(); } $serviceURL = $serverUri . $url->toString(); $serviceNameSpace = $serverUri . jApp::urlBasePath(); $wsdl = new WSDLStruct($serviceNameSpace, $serviceURL, SOAP_RPC, SOAP_ENCODED); $wsdl->setService(new IPReflectionClass($this->controllerClassName)); try { $gendoc = $wsdl->generateDocument(); } catch (WSDLException $exception) { throw new JException('jsoap~errors.wsdl.generation', $exception->msg); } return $gendoc; }
/** * get the root url for a given ressource type. Root URLs are stored in config file. * @param string $ressourceType Name of the ressource * @return string the root URL corresponding to this ressource, or basePath if unknown */ public static function getRootUrl($ressourceType) { $rootUrl = jUrl::getRootUrlRessourceValue($ressourceType); if ($rootUrl !== null) { if (substr($rootUrl, 0, 7) !== 'http://' && substr($rootUrl, 0, 8) !== 'https://' && substr($rootUrl, 0, 1) !== '/') { //and is not relative to root // so let's prepend basePath : $rootUrl = jApp::urlBasePath() . $rootUrl; } } else { // basePath by default : $rootUrl = jApp::urlBasePath(); } return $rootUrl; }
/** * meta plugin : modify an html response object * * @see jResponseHtml * @param jTpl $tpl template engine * @param string $method indicates what you want to specify * (possible values : js, css, jsie, jsie7, jsltie7, cssie, cssie7, cssltie7, * csstheme, cssthemeie, cssthemeie7, cssthemeltie7, bodyattr, keywords, * description, others) * @param mixed $param parameter (a css style sheet for "css" for example) * @params array $params additionnal parameters (a media attribute for stylesheet for example) */ function jtpl_meta_html_html($tpl, $method, $param = null, $params = array()) { $resp = jApp::coord()->response; if ($resp->getType() != 'html') { return; } switch ($method) { case 'title': $resp->setTitle($param); break; case 'js': $resp->addJSLink($param, $params); break; case 'css': $resp->addCSSLink($param, $params); break; case 'jsie': $resp->addJSLink($param, $params, true); break; case 'jsie7': $resp->addJSLink($param, $params, 'IE 7'); break; case 'jsltie7': $resp->addJSLink($param, $params, 'lt IE 7'); break; case 'cssie': $resp->addCSSLink($param, $params, true); break; case 'cssie7': case 'cssie8': case 'cssie9': $resp->addCSSLink($param, $params, 'IE ' . substr($method, -1, 1)); break; case 'cssltie7': case 'cssltie8': case 'cssltie9': $resp->addCSSLink($param, $params, 'lt IE ' . substr($method, -1, 1)); break; case 'csstheme': $resp->addCSSLink(jApp::urlBasePath() . 'themes/' . jApp::config()->theme . '/' . $param, $params); break; case 'cssthemeie': $resp->addCSSLink(jApp::urlBasePath() . 'themes/' . jApp::config()->theme . '/' . $param, $params, true); break; case 'cssthemeie7': case 'cssthemeie8': case 'cssthemeie9': $resp->addCSSLink(jApp::urlBasePath() . 'themes/' . jApp::config()->theme . '/' . $param, $params, 'IE ' . substr($method, -1, 1)); break; case 'cssthemeltie7': case 'cssthemeltie8': case 'cssthemeltie9': $resp->addCSSLink(jApp::urlBasePath() . 'themes/' . jApp::config()->theme . '/' . $param, $params, 'lt IE ' . substr($method, -1, 1)); break; case 'style': if (is_array($param)) { foreach ($param as $p1 => $p2) { $resp->addStyle($p1, $p2); } } break; case 'bodyattr': if (is_array($param)) { $resp->setBodyAttributes($param); } break; case 'keywords': $resp->addMetaKeywords($param); break; case 'description': $resp->addMetaDescription($param); break; case 'others': $resp->addHeadContent($param); break; case 'author': $resp->addMetaAuthor($param); break; case 'generator': $resp->addMetaGenerator($param); break; case 'jquery': $resp->addJSLink(jApp::config()->urlengine['jqueryPath'] . 'jquery.js'); break; case 'jquery_ui': $base = jApp::config()->urlengine['jqueryPath']; switch ($param) { case 'components': $resp->addJSLink($base . 'jquery.js'); $resp->addJSLink($base . 'ui/jquery.ui.core.min.js'); foreach ($params as $f) { $resp->addJSLink($base . 'ui/jquery.ui.' . $f . '.min.js'); } break; case 'effects': $resp->addJSLink($base . 'jquery.js'); $resp->addJSLink($base . 'ui/jquery.ui.core.min.js'); $resp->addJSLink($base . 'ui/jquery.ui.effect.min.js'); foreach ($params as $f) { $resp->addJSLink($base . 'ui/jquery.ui.effect-' . $f . '.min.js'); } break; case 'theme': $resp->addCSSLink($base . 'themes/base/jquery.ui.all.css'); break; } break; } }
/** * compute path from the configuration or from * the given array. These paths will be used to read images and to save them * into a cache directory. * @return array. keys are * src_url, src_path, cache_path, cache_url */ public static function computeUrlFilePath($config = null) { // paths & uri $basePath = jApp::urlBasePath(); if (!$config) { $config =& jApp::config()->imagemodifier; } // compute URL and file path of the source image if ($config['src_url'] && $config['src_path']) { $srcUri = $config['src_url']; if ($srcUri[0] != '/' && strpos($srcUri, 'http:') !== 0) { $srcUri = $basePath . $srcUri; } $srcPath = jFile::parseJelixPath($config['src_path']); } else { $srcUri = jApp::coord()->request->getServerURI() . $basePath; $srcPath = jApp::wwwPath(); } if ($config['cache_path'] && $config['cache_url']) { $cacheUri = $config['cache_url']; if ($cacheUri[0] != '/' && strpos($cacheUri, 'http:') !== 0) { $cacheUri = $basePath . $cacheUri; } $cachePath = jFile::parseJelixPath($config['cache_path']); } else { $cachePath = jApp::wwwPath('cache/images/'); $cacheUri = jApp::coord()->request->getServerURI() . $basePath . 'cache/images/'; } return array($srcPath, $srcUri, $cachePath, $cacheUri); }
/** * Read the configuration and return an url part according of the * of the https configuration * @param string $requestType * @param string $module * @param string $action */ protected function getBasePath($requestType, $module = null, $action = null) { if ($this->urlhttps == null) { $this->urlhttps = array(); $selectors = preg_split("/[\\s,]+/", jApp::config()->urlengine['simple_urlengine_https']); foreach ($selectors as $sel2) { $this->urlhttps[$sel2] = true; } } $usehttps = false; if (count($this->urlhttps)) { if ($action && isset($this->urlhttps[$module . '~' . $action . '@' . $requestType])) { $usehttps = true; } elseif ($module && isset($this->urlhttps[$module . '~*@' . $requestType])) { $usehttps = true; } elseif (isset($this->urlhttps['@' . $requestType])) { $usehttps = true; } } if ($usehttps) { return jApp::coord()->request->getServerURI(true) . jApp::urlBasePath(); } else { return jApp::urlBasePath(); } }
protected function _prepareResponse() { $rep = $this->getResponse('html', true); $rep->bodyTpl = 'junittests~main'; $rep->body->assign('page_title', 'Unit Tests'); $rep->body->assign('versionphp', phpversion()); $rep->body->assign('versionjelix', JELIX_VERSION); $rep->body->assign('basepath', jApp::urlBasePath()); $rep->body->assign('isurlsig', jApp::config()->urlengine['engine'] == 'significant'); $runnerPreparer = jClasses::create('junittests~jrunnerpreparer'); $this->allTestsList = $runnerPreparer->getTestsList('html'); $this->category = $this->param('categ', false); $this->testsList = $runnerPreparer->filterTestsByCategory($this->category, $this->allTestsList); $rep->body->assign('modules', $this->allTestsList); return $rep; }
/** * output errors */ public function outputErrors() { if (file_exists(jApp::appPath('app/responses/error.en_US.php'))) { $file = jApp::appPath('app/responses/error.en_US.php'); } else { $file = JELIX_LIB_CORE_PATH . 'response/error.en_US.php'; } // we erase already generated content $this->_headTop = array(); $this->_headBottom = array(); $this->_bodyBottom = array(); $this->_bodyTop = array(); jLog::outputLog($this); foreach ($this->plugins as $name => $plugin) { $plugin->beforeOutputError(); } $HEADTOP = implode("\n", $this->_headTop); $HEADBOTTOM = implode("\n", $this->_headBottom); $BODYTOP = implode("\n", $this->_bodyTop); $BODYBOTTOM = implode("\n", $this->_bodyBottom); $BASEPATH = jApp::urlBasePath(); header("HTTP/{$this->httpVersion} 500 Internal jelix error"); header('Content-Type: text/html;charset=' . $this->_charset); include $file; }
<?php /** * @package jelix * @subpackage jtcpdf module * @author Julien Issler * @contributor Laurent Jouanneau * @copyright 2007-2009 Julien Issler, 2007-2015 Laurent Jouanneau * @link http://www.jelix.org * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html * @since 1.0 */ define('K_TCPDF_EXTERNAL_CONFIG', true); define('K_TCPDF_THROW_EXCEPTION_ERROR', true); define('K_PATH_URL', jApp::coord()->request->getServerURI() . jApp::urlBasePath()); define('K_PATH_CACHE', jApp::tempPath()); define('K_PATH_IMAGES', jApp::appPath()); define('K_BLANK_IMAGE', K_PATH_MAIN . 'images/_blank.png'); define('K_CELL_HEIGHT_RATIO', 1.25); define('K_SMALL_RATIO', 2 / 3); /** * sub-class of TCPDF, for better Jelix integration and easy save to disk feature. * @package jelix * @subpackage utils * @since 1.0 */ class jTcpdf extends TCPDF { public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa = false) { if (is_string($unicode)) {