本文整理汇总了PHP中System::getBaseUri方法的典型用法代码示例。如果您正苦于以下问题:PHP System::getBaseUri方法的具体用法?PHP System::getBaseUri怎么用?PHP System::getBaseUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::getBaseUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEFMConfig
public static function getEFMConfig()
{
require_once 'modules/Scribite/plugins/Xinha/vendor/xinha/contrib/php-xinha.php';
$zikulaBaseURI = rtrim(System::getBaseUri(), '/');
$zikulaBaseURI = ltrim($zikulaBaseURI, '/');
// define backend configuration for the plugin
$IMConfig = array();
$IMConfig['images_dir'] = '/files/';
$IMConfig['images_url'] = 'files/';
$IMConfig['files_dir'] = '/files/';
$IMConfig['files_url'] = 'files';
$IMConfig['thumbnail_prefix'] = 't_';
$IMConfig['thumbnail_dir'] = 't';
$IMConfig['resized_prefix'] = 'resized_';
$IMConfig['resized_dir'] = '';
$IMConfig['tmp_prefix'] = '_tmp';
$IMConfig['max_filesize_kb_image'] = 2000;
// maximum size for uploading files in 'insert image' mode (2000 kB here)
$IMConfig['max_filesize_kb_link'] = 5000;
// maximum size for uploading files in 'insert link' mode (5000 kB here)
// Maximum upload folder size in Megabytes.
// Use 0 to disable limit
$IMConfig['max_foldersize_mb'] = 0;
$IMConfig['allowed_image_extensions'] = array("jpg", "gif", "png");
$IMConfig['allowed_link_extensions'] = array("jpg", "gif", "pdf", "ip", "txt", "psd", "png", "html", "swf", "xml", "xls");
xinha_pass_to_php_backend($IMConfig);
return $IMConfig;
}
示例2: smarty_function_getbaseuri
/**
* Zikula_View function to obtain base URL for this site
*
* This function obtains the base URL for the site. The base url is defined as the
* full URL for the site minus any file information i.e. everything before the
* 'index.php' from your start page.
* Unlike the API function System::getBaseUrl, the results of this function are already
* sanitized to display, so it should not be passed to the safetext modifier.
*
* Available parameters:
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Example
* {getbaseurl}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The base URL of the site.
*/
function smarty_function_getbaseuri($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('getbaseuri', '$baseuri')), E_USER_DEPRECATED);
$assign = isset($params['assign']) ? $params['assign'] : null;
$result = htmlspecialchars(System::getBaseUri());
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例3: getJSConfig
/**
* Generate a configuration for javascript and return script tag to embed in HTML HEAD.
*
* @return string HTML code with script tag
*/
public static function getJSConfig()
{
$return = '';
$config = array('entrypoint' => System::getVar('entrypoint', 'index.php'), 'baseURL' => System::getBaseUrl(), 'baseURI' => System::getBaseUri() . '/', 'ajaxtimeout' => (int) System::getVar('ajaxtimeout', 5000), 'lang' => ZLanguage::getLanguageCode(), 'sessionName' => session_name());
$config = DataUtil::formatForDisplay($config);
$return .= "<script type=\"text/javascript\">/* <![CDATA[ */ \n";
if (System::isLegacyMode()) {
$return .= 'document.location.entrypoint="' . $config['entrypoint'] . '";';
$return .= 'document.location.ajaxtimeout=' . $config['ajaxtimeout'] . ";\n";
}
$return .= "if (typeof(Zikula) == 'undefined') {var Zikula = {};}\n";
$return .= "Zikula.Config = " . json_encode($config) . "\n";
$return .= ' /* ]]> */</script>' . "\n";
return $return;
}
示例4: smarty_function_debugenvironment
/**
* Zikula_View function to get all session variables.
*
* This function gets all session vars from the Zikula system assigns the names and
* values to two array. This is being used in pndebug to show them.
*
* Example
* {debugenvironment}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_debugenvironment($params, Zikula_View $view)
{
$view->assign('_ZSession_keys', array_keys($_SESSION));
$view->assign('_ZSession_vals', array_values($_SESSION));
$view->assign('_smartyversion', $view->_version);
$_theme = ModUtil::getInfoFromName('ZikulaThemeModule');
$view->assign('_themeversion', $_theme['version']);
$view->assign('_force_compile', ModUtil::getVar('ZikulaThemeModule', 'force_compile') ? __('On') : __('Off'));
$view->assign('_compile_check', ModUtil::getVar('ZikulaThemeModule', 'compile_check') ? __('On') : __('Off'));
$view->assign('_baseurl', System::getBaseUrl());
$view->assign('_baseuri', System::getBaseUri());
$plugininfo = isset($view->_plugins['function']['zdebug']) ? $view->_plugins['function']['zdebug'] : $view->_plugins['function']['zpopup'];
$view->assign('_template', $plugininfo[1]);
$view->assign('_path', $view->get_template_path($plugininfo[1]));
$view->assign('_line', $plugininfo[2]);
}
示例5: start
public function start()
{
$config = array('gc_probability' => System::getVar('gc_probability'), 'gc_divisor' => 10000, 'gc_maxlifetime' => System::getVar('secinactivemins'));
$path = System::getBaseUri();
if (empty($path)) {
$path = '/';
} elseif (substr($path, -1, 1) != '/') {
$path .= '/';
}
$config['cookie_path'] = $path;
$host = System::serverGetVar('HTTP_HOST');
if (($pos = strpos($host, ':')) !== false) {
$host = substr($host, 0, $pos);
}
// PHP configuration variables
// Set lifetime of session cookie
$seclevel = System::getVar('seclevel');
switch ($seclevel) {
case 'High':
// Session lasts duration of browser
$lifetime = 0;
// Referer check
// ini_set('session.referer_check', $host.$path);
$config['referer_check'] = $host;
break;
case 'Medium':
// Session lasts set number of days
$lifetime = System::getVar('secmeddays') * 86400;
break;
case 'Low':
default:
// (Currently set to 1 year)
$lifetime = 31536000;
break;
}
$config['cookie_lifetime'] = $lifetime;
$this->storage->setOptions($config);
return parent::start();
}
示例6: smarty_function_iwqvuserprintstate
function smarty_function_iwqvuserprintstate($params, &$smarty) {
$dom = ZLanguage::getModuleDomain('IWqv');
if (!isset($params['class'])) {
$params['class'] = 'pn-menuitem-title';
}
$html = "<span class=\"" . $params['class'] . "\">";
if (count($params['states']) > 0) {
if (isset($params['states'][2]) && $params['sections'] == $params['states'][2]) {
// All the sections are revised
$html.="<img src=\"" . System::getBaseUri() . "/modules/IWqv/pnimages/state_corrected.gif\" alt=\"" . __('Corrected', $dom) . "\">";
} else if (isset($params['states'][1]) && $params['states'][1] > 0) {
// There is at least one section to revise
$html.="<img src=\"" . System::getBaseUri() . "/modules/IWqv/pnimages/state_delivered.gif\" alt=\"" . __('Delivered', $dom) . "\">";
} else {
// The qv is started
$html.="<img src=\"" . System::getBaseUri() . "/modules/IWqv/pnimages/state_started.gif\" alt=\"" . __('Started', $dom) . "\">";
}
}
$html.="</span>\n";
return $html;
}
示例7: save
/**
* Save combined pagevars.
*
* @param array $files Files.
* @param string $ext Extention.
* @param string $cache_dir Cache directory.
*
* @return array Array of file with combined pagevars file and remote files
*/
private static function save($files, $ext, $cache_dir)
{
$themevars = ModUtil::getVar('ZikulaThemeModule');
$lifetime = $themevars['cssjscombine_lifetime'];
$hash = md5(serialize($files) . UserUtil::getTheme());
$cachedFile = "{$cache_dir}/{$hash}_{$ext}.php";
$cachedFileUri = "{$hash}_{$ext}.php";
if (is_readable($cachedFile) && ($lifetime == -1 || filemtime($cachedFile) + $lifetime > time())) {
return System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
}
switch ($ext) {
case 'css':
$ctype = 'text/css';
break;
case 'js':
$ctype = 'text/javascript';
break;
default:
$ctype = 'text/plain';
break;
}
$includedFiles = array();
$outputFiles = array();
$contents = array();
$dest = fopen($cachedFile, 'w');
foreach ($files as $file) {
if (!empty($file)) {
// skip remote files from combining
if (is_file($file)) {
self::readfile($contents, $file, $ext);
$includedFiles[] = $file;
} else {
$outputFiles[] = $file;
}
}
}
array_unshift($contents, "/* --- Combined file written: " . DateUtil::getDateTime() . " */\n\n");
array_unshift($contents, "/* --- Combined files:\n" . implode("\n", $includedFiles) . "\n*/\n\n");
$contents = implode('', $contents);
// optional minify
if ($themevars['cssjsminify'] && $ext == 'css') {
// Remove comments.
$contents = trim(preg_replace('/\\/\\*.*?\\*\\//s', '', $contents));
// Compress whitespace.
$contents = preg_replace('/\\s+/', ' ', $contents);
// Additional whitespace optimisation -- spaces around certain tokens is not required by CSS
$contents = preg_replace('/\\s*(;|\\{|\\}|:|,)\\s*/', '\\1', $contents);
}
global $ZConfig;
$signingKey = md5(serialize($ZConfig['DBInfo']['databases']['default']));
$signature = md5($contents . $ctype . $lifetime . $themevars['cssjscompress'] . $signingKey);
$data = array('contents' => $contents, 'ctype' => $ctype, 'lifetime' => $lifetime, 'gz' => $themevars['cssjscompress'], 'signature' => $signature);
fwrite($dest, serialize($data));
fclose($dest);
$combined = System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
array_unshift($outputFiles, $combined);
return $outputFiles;
}
示例8: smarty_function_thumb
/**
* Available params:
* - image (string) Path to source image (required)
* - width (int) Thumbnail width in pixels or 'auto' (optional, default value based on 'default' preset)
* - height (int) Thumbnail width in pixels or 'auto' (optional, default value based on 'default' preset)
* - mode (string) Thumbnail mode; 'inset' or 'outbound' (optional, default 'inset')
* In outbound mode auto width or height gives the same effect as inset
* - extension (string) File extension for thumbnails: jpg, png, gif; null for original file type
* (optional, default value based on 'default' preset)
* - options (array) Options array given to the thumbnail Imagine method call.
* - options[jpeg_quality]
* (int) Thumbnail jpeg quality in % [0-100], where 100% is best quality (optional, default value based on 'default' preset)
* - options[png_compression_level]
* (int) Thumbnail png compression level [0-9], where 0 is no compression (optional, default value based on 'default' preset)
* - objectid (string) Unique signature for object, which owns this thumbnail (optional)
* - preset (string|object) Name of preset defined in Imagine or custom preset passed as instance of
* SystemPlugin_Imagine_Preset; if given inline options ('width', 'heigth', 'mode'
* and 'extension') are ignored (optional)
* - manager (object) Instance of SystemPlugin_Imagine_Manager; if given inline options ('width',
* 'heigth', 'mode' and 'extension') are ignored (optional)
* - fqurl (boolean) If set the thumb path is absolute, if not relative
* - tag (boolean) If set to true - full <img> tag will be generated. Tag attributes should be
* passed with "img_" prefix (for example: "img_class"). Getttext prefix may be
* used for translations (for example: "__img_alt")
*
* Examples
*
* Basic usage with inline options:
* {thumb image='path/to/image.png' width='100' height='100' mode='inset' extension='jpg'}
* {thumb image='path/to/image.png' width='150' height='auto' mode='inset' extension='png'}
* {thumb image='path/to/image.jpg' width='150' 'jpeg_quality'=50}
*
* Using preset define in Imagine plugin
* {thumb image='path/to/image.png' objectid='123' preset='my_preset'}
*
* Using custom preset, defined in module and passed to template
* {thumb image='path/to/image.png' objectid='123' preset=$preset}
*
* Using custom SystemPlugin_Imagine_Manager instance, defined in module and passed to template
* {thumb image='path/to/image.png' objectid='123' manager=$manager}
*
* Generating full img tag
* {thumb image='path/to/image.png' objectid='123' preset=$preset tag=true __img_alt='Alt text, gettext prefix may be used' img_class='image-class'}
* This will generate:
* <img src="thumb/path" widht="100" height="100" alt="Alt text, gettext prefix may be used" class="image-class" />
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string thumb path
*/
function smarty_function_thumb($params, Zikula_View $view)
{
if (!isset($params['image']) || empty($params['image'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_thumb', 'image')));
return false;
}
$image = $params['image'];
$objectId = isset($params['objectid']) ? $params['objectid'] : null;
if (isset($params['manager']) && $params['manager'] instanceof SystemPlugin_Imagine_Manager) {
$manager = $params['manager'];
} else {
$manager = $view->getContainer()->get('systemplugin.imagine.manager');
}
if (isset($params['preset']) && $params['preset'] instanceof SystemPlugin_Imagine_Preset) {
$preset = $params['preset'];
} elseif (isset($params['preset']) && $manager->getPlugin()->hasPreset($params['preset'])) {
$preset = $manager->getPlugin()->getPreset($params['preset']);
} else {
$preset = array();
$preset['width'] = isset($params['width']) ? $params['width'] : 'auto';
$preset['height'] = isset($params['height']) ? $params['height'] : 'auto';
$preset['mode'] = isset($params['mode']) ? $params['mode'] : null;
$preset['extension'] = isset($params['extension']) ? $params['extension'] : null;
$preset['options'] = isset($params['options']) ? $params['options'] : array();
$preset = array_filter($preset);
}
$manager->setPreset($preset);
$thumb = $manager->getThumb($image, $objectId);
$basePath = isset($params['fqurl']) && $params['fqurl'] ? System::getBaseUrl() : System::getBaseUri();
$result = "{$basePath}/{$thumb}";
if (isset($params['tag']) && $params['tag']) {
$thumbSize = @getimagesize($thumb);
$attributes = array();
$attributes[] = "src=\"{$basePath}/{$thumb}\"";
$attributes[] = $thumbSize[3];
// width and height
// get tag params
foreach ($params as $key => $value) {
if (strpos($key, 'img_') === 0) {
$key = str_replace('img_', '', $key);
$attributes[$key] = "{$key}=\"{$value}\"";
}
}
if (!isset($attributes['alt'])) {
$attributes[] = 'alt=""';
}
$attributes = implode(' ', $attributes);
$result = "<img {$attributes} />";
}
//.........这里部分代码省略.........
示例9: getUrl
public function getUrl()
{
return \System::getBaseUri() . '/' . $this->getPath();
}
示例10: create
/**
* Create a comment for a specific item
*
* This is a standard function that is called with the results of the
* form supplied by EZComments_user_view to create a new item
*
* @param $comment the comment (taken from HTTP put)
* @param $mod the name of the module the comment is for (taken from HTTP put)
* @param $objectid ID of the item the comment is for (taken from HTTP put)
* @param $redirect URL to return to (taken from HTTP put)
* @param $subject The subject of the comment (if any) (taken from HTTP put)
* @param $replyto The ID of the comment for which this an anser to (taken from HTTP put)
* @since 0.1
*/
public function create($args)
{
$mod = isset($args['mod']) ? $args['mod'] : FormUtil::getPassedValue('mod', null, 'POST');
$objectid = isset($args['objectid']) ? $args['objectid'] : FormUtil::getPassedValue('objectid', null, 'POST');
$areaid = isset($args['areaid']) ? $args['areaid'] : FormUtil::getPassedValue('areaid', null, 'POST');
$comment = isset($args['comment']) ? $args['comment'] : FormUtil::getPassedValue('comment', null, 'POST');
$subject = isset($args['subject']) ? $args['subject'] : FormUtil::getPassedValue('subject', null, 'POST');
$replyto = isset($args['replyto']) ? $args['replyto'] : FormUtil::getPassedValue('replyto', null, 'POST');
$owneruid = isset($args['owneruid']) ? $args['owneruid'] : FormUtil::getPassedValue('owneruid', null, 'POST');
$redirect = isset($args['redirect']) ? $args['redirect'] : FormUtil::getPassedValue('redirect', null, 'POST');
$useurl = isset($args['useurl']) ? $args['useurl'] : FormUtil::getPassedValue('useurl', null, 'POST');
// check if the user logged in and if we're allowing anon users to
// set a name and email address
if (!UserUtil::isLoggedIn()) {
$anonname = isset($args['anonname']) ? $args['anonname'] : FormUtil::getPassedValue('anonname', null, 'POST');
$anonmail = isset($args['anonmail']) ? $args['anonmail'] : FormUtil::getPassedValue('anonmail', null, 'POST');
$anonwebsite = isset($args['anonwebsite']) ? $args['anonwebsite'] : FormUtil::getPassedValue('anonwebsite', null, 'POST');
} else {
$anonname = '';
$anonmail = '';
$anonwebsite = '';
}
if (!isset($owneruid) || !($owneruid > 1)) {
$owneruid = 0;
}
$redirect = str_replace('&', '&', base64_decode($redirect));
$redirect = !empty($redirect) ? $redirect : System::serverGetVar('HTTP_REFERER');
$useurl = base64_decode($useurl);
// save the submitted data if any error occurs
$ezcomment = unserialize(SessionUtil::getVar('ezcomment', 'a:0:{}'));
if (isset($ezcomment[$mod][$objectid])) {
unset($ezcomment[$mod][$objectid]);
}
if (!empty($subject)) {
$ezcomment[$mod][$objectid]['subject'] = $subject;
}
if (!empty($comment)) {
$ezcomment[$mod][$objectid]['comment'] = $comment;
}
if (!empty($anonname)) {
$ezcomment[$mod][$objectid]['anonname'] = $anonname;
}
if (!empty($anonmail)) {
$ezcomment[$mod][$objectid]['anonmail'] = $anonmail;
}
if (!empty($anonwebsite)) {
$ezcomment[$mod][$objectid]['anonwebsite'] = $anonwebsite;
}
// Confirm authorisation code
// check csrf token
SessionUtil::setVar('ezcomment', serialize($ezcomment));
$this->checkCsrfToken();
SessionUtil::delVar('ezcomment');
// and check we've actually got a comment....
if (empty($comment)) {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
return LogUtil::registerError($this->__('Error! The comment contains no text.'), null, $redirect . "#commentform_{$mod}_{$objectid}");
}
// Check hooked modules for validation
$hookvalidators = $this->notifyHooks(new Zikula_ValidationHook('ezcomments.ui_hooks.comments.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators();
if ($hookvalidators->hasErrors()) {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
return LogUtil::registerError($this->__('Error! The hooked content does not validate. Could it possibly be that a captcha code was entered incorrectly?'), null, $redirect . "#commentform_{$mod}_{$objectid}");
}
// now parse out the hostname+subfolder from the url for storing in the DB
$url = str_replace(System::getBaseUri(), '', $useurl);
$id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => $mod, 'objectid' => $objectid, 'areaid' => $areaid, 'url' => $url, 'comment' => $comment, 'subject' => $subject, 'replyto' => $replyto, 'uid' => UserUtil::getVar('uid'), 'owneruid' => $owneruid, 'useurl' => $useurl, 'redirect' => $redirect, 'anonname' => $anonname, 'anonmail' => $anonmail, 'anonwebsite' => $anonwebsite));
if ($id) {
// clear respective cache
ModUtil::apiFunc('EZComments', 'user', 'clearItemCache', array('id' => $id, 'modname' => $mod, 'objectid' => $objectid, 'url' => $url));
} else {
// redirect if it was not successful
SessionUtil::setVar('ezcomment', $ezcomment);
System::redirect($redirect . "#commentform_{$mod}_{$objectid}");
}
// clean/set the session data
if (isset($ezcomment[$mod][$objectid])) {
unset($ezcomment[$mod][$objectid]);
if (empty($ezcomment[$mod])) {
unset($ezcomment[$mod]);
}
}
if (empty($ezcomment)) {
SessionUtil::delVar('ezcomment');
} else {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
//.........这里部分代码省略.........
示例11: smarty_function_img
//.........这里部分代码省略.........
$modpath = "images";
$paths = array($themepath, $corethemepath, $modpath);
} else {
$osmodname = DataUtil::formatForOS($modname);
$themelangpath = "{$themePath}/{$lang}";
$themelangpathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images/{$lang}";
$themepathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images";
$module = ModUtil::getModule($modinfo['name']);
$moduleBasePath = null === $module ? '' : $module->getRelativePath() . '/Resources/public/images';
$modlangpath = "{$moduleBasePath}/{$lang}";
$modpath = $moduleBasePath;
$modlangpathOld = "{$moduleDir}/{$osmoddir}/images/{$lang}";
$modpathOld = "{$moduleDir}/{$osmoddir}/images";
$modlangpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages/{$lang}";
$modpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages";
// form the array of paths
if (preg_match('/^admin.(png|gif|jpg)$/', $params['src'])) {
// special processing for modules' admin icon
$paths = array($modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
} else {
$paths = array($themelangpath, $themepath, $themelangpathOld, $themepathOld, $corethemepath, $modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
}
}
}
}
$ossrc = DataUtil::formatForOS($params['src']);
// search for the image
$imgsrc = '';
foreach ($paths as $path) {
$fullpath = $path . ($osset ? "/{$osset}/" : '/') . $ossrc;
if (is_readable($fullpath)) {
$imgsrc = $fullpath;
break;
}
}
if ($imgsrc == '' && isset($params['default'])) {
$imgsrc = $params['default'];
}
// default for the optional flag
$optional = isset($params['optional']) ? $params['optional'] : true;
if ($imgsrc == '') {
if ($optional) {
if (!$nostoponerror) {
$view->trigger_error(__f("%s: Image '%s' not found", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src']))));
return;
} else {
return false;
}
}
return;
}
// If neither width nor height is set, get these parameters.
// If one of them is set, we do NOT obtain the real dimensions.
// This way it is easy to scale the image to a certain dimension.
if (!isset($params['width']) && !isset($params['height'])) {
if (!($_image_data = @getimagesize($imgsrc))) {
if (!$nostoponerror) {
$view->trigger_error(__f("%s: Image '%s' is not a valid image file", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src']))));
return;
} else {
return false;
}
}
$params['width'] = $_image_data[0];
$params['height'] = $_image_data[1];
}
$basepath = isset($params['fqurl']) && $params['fqurl'] ? System::getBaseUrl() : System::getBaseUri();
$params['src'] = $basepath . '/' . $imgsrc;
$retval = isset($params['retval']) ? $params['retval'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
unset($params['modname']);
unset($params['retval']);
unset($params['assign']);
if (isset($params['altml'])) {
// legacy
unset($params['altml']);
}
if (isset($params['titleml'])) {
// legacy
unset($params['titleml']);
}
unset($params['optional']);
unset($params['default']);
unset($params['set']);
unset($params['nostoponerror']);
unset($params['fqurl']);
$imgtag = '<img ';
foreach ($params as $key => $value) {
$imgtag .= $key . '="' . $value . '" ';
}
$imgtag .= '/>';
if (!empty($retval) && isset($params[$retval])) {
return $params[$retval];
} elseif (!empty($assign)) {
$params['imgtag'] = $imgtag;
$view->assign($assign, $params);
} else {
return $imgtag;
}
}
示例12: resolveSymfonyAsset
private static function resolveSymfonyAsset($path)
{
if (is_array($path)) {
$return = array();
foreach ($path as $key => $value) {
$return[$key] = self::resolveSymfonyAsset($value);
}
return $return;
}
if (substr($path, 0, 1) != "@") {
return $path;
}
$sm = \ServiceUtil::getManager();
$kernel = $sm->get('kernel');
$root = realpath($kernel->getRootDir() . "/../");
$fullPath = $kernel->locateResource($path);
$path = System::getBaseUri() . str_replace(DIRECTORY_SEPARATOR, '/', substr($fullPath, strlen($root)));
return $path;
}
示例13: bindDomain
/**
* Bind domain.
*
* @param string $domain Gettext domain.
* @param string $path Domain path.
*
* @return boolean
*/
public static function bindDomain($domain, $path)
{
$_this = self::getInstance();
$locale = $_this->getLocale();
if (!$locale) {
// fallback solution to be replaced by proper routing
$defaultLocale = System::getVar('language_i18n', 'en');
if (System::getVar('shorturls')) {
// we need to extract the language code from current url, since it is not ensured
// that System::queryStringDecode() has been executed already
$customentrypoint = System::getVar('entrypoint');
$expectEntrypoint = !System::getVar('shorturlsstripentrypoint');
$root = empty($customentrypoint) ? 'index.php' : $customentrypoint;
// get base path to work out our current url
$parsedURL = parse_url(System::getCurrentUri());
$tobestripped = array(System::getBaseUri(), "{$root}");
$path = str_replace($tobestripped, '', $parsedURL['path']);
$path = trim($path, '/');
// split the path into a set of argument strings
$args = explode('/', rtrim($path, '/'));
// ensure that each argument is properly decoded
foreach ($args as $k => $v) {
$args[$k] = urldecode($v);
}
if (isset($args[0]) && self::isLangParam($args[0]) && in_array($args[0], self::getInstalledLanguages())) {
$defaultLocale = $args[0];
}
}
$_this->setLocale($defaultLocale);
$locale = $_this->getLocale();
}
// exit if the language system hasnt yet fully initialised
if (!$locale) {
return false;
}
// prevent double loading
if (array_key_exists($domain, $_this->domainCache[$locale])) {
return true;
}
ZGettext::getInstance()->bindTextDomain($domain, $path);
ZGettext::getInstance()->bindTextDomainCodeset($domain, $_this->encoding);
$_this->domainCache[$locale][$domain] = true;
return $_this->domainCache[$locale][$domain];
}
示例14: start
/**
* {@inheritdoc}
*/
public function start()
{
$path = System::getBaseUri();
if (empty($path)) {
$path = '/';
} elseif (substr($path, -1, 1) != '/') {
$path .= '/';
}
$host = System::serverGetVar('HTTP_HOST');
if (($pos = strpos($host, ':')) !== false) {
$host = substr($host, 0, $pos);
}
// PHP configuration variables
ini_set('session.use_trans_sid', 0);
// Stop adding SID to URLs
@ini_set('url_rewriter.tags', '');
// some environments dont allow this value to be set causing an error that prevents installation
ini_set('session.serialize_handler', 'php');
// How to store data
ini_set('session.use_cookies', 1);
// Use cookie to store the session ID
ini_set('session.auto_start', 1);
// Auto-start session
ini_set('session.name', SessionUtil::getCookieName());
// Name of our cookie
// Set lifetime of session cookie
$seclevel = System::getVar('seclevel');
switch ($seclevel) {
case 'High':
// Session lasts duration of browser
$lifetime = 0;
// Referer check
// ini_set('session.referer_check', $host.$path);
ini_set('session.referer_check', $host);
break;
case 'Medium':
// Session lasts set number of days
$lifetime = System::getVar('secmeddays') * 86400;
break;
case 'Low':
default:
// Session lasts unlimited number of days (well, lots, anyway)
// (Currently set to 25 years)
$lifetime = 788940000;
break;
}
ini_set('session.cookie_lifetime', $lifetime);
// domain and path settings for session cookie
// if (System::getVar('intranet') == false) {
// Cookie path
ini_set('session.cookie_path', $path);
// Garbage collection
ini_set('session.gc_probability', System::getVar('gc_probability'));
ini_set('session.gc_divisor', 10000);
ini_set('session.gc_maxlifetime', System::getVar('secinactivemins') * 60);
// Inactivity timeout for user sessions
ini_set('session.hash_function', 1);
// Set custom session handlers
ini_set('session.save_handler', 'user');
if (System::getVar('sessionstoretofile')) {
ini_set('session.save_path', System::getVar('sessionsavepath'));
}
session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
// create IP finger print
$current_ipaddr = '';
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
if (System::getVar('sessionipcheck')) {
// feature for future release
}
// create the ip fingerprint
$current_ipaddr = md5($_REMOTE_ADDR . $_HTTP_X_FORWARDED_FOR);
// start session check expiry and ip fingerprint if required
if (session_start() && isset($GLOBALS['_ZSession']['obj']) && $GLOBALS['_ZSession']['obj']) {
// check if session has expired or not
$now = time();
$inactive = $now - (int) (System::getVar('secinactivemins') * 60);
$daysold = $now - (int) (System::getVar('secmeddays') * 86400);
$lastused = strtotime($GLOBALS['_ZSession']['obj']['lastused']);
$rememberme = SessionUtil::getVar('rememberme');
$uid = $GLOBALS['_ZSession']['obj']['uid'];
$ipaddr = $GLOBALS['_ZSession']['obj']['ipaddr'];
// IP check
if (System::getVar('sessionipcheck', false)) {
if ($ipaddr !== $current_ipaddr) {
session_destroy();
return false;
}
}
switch (System::getVar('seclevel')) {
case 'Low':
// Low security - users stay logged in permanently
// no special check necessary
break;
case 'Medium':
// Medium security - delete session info if session cookie has
// expired or user decided not to remember themself and inactivity timeout
//.........这里部分代码省略.........
示例15: getIconThumbnailByFileExtension
protected function getIconThumbnailByFileExtension(AbstractFileEntity $entity, $width, $height, $format = 'html', $mode = 'outbound', $optimize = true, $forceExtension = false)
{
return false;
// @todo Re-enable?
if (!in_array($mode, ['inset', 'outbound'])) {
throw new \InvalidArgumentException('Invalid mode requested.');
}
$mode = 'inset';
$availableSizes = [16, 32, 48, 512];
foreach ($availableSizes as $size) {
if ($width <= $size && $height <= $size) {
break;
}
}
$extension = $forceExtension ? $forceExtension : pathinfo($entity->getFileName(), PATHINFO_EXTENSION);
$icon = '@CmfcmfMediaModule/Resources/public/images/file-icons/' . $size . 'px/' . $extension . '.png';
try {
$path = $this->getPathToFile($icon);
} catch (\InvalidArgumentException $e) {
$icon = '@CmfcmfMediaModule/Resources/public/images/file-icons/' . $size . 'px/_blank.png';
$path = $this->getPathToFile($icon);
}
$this->imagineManager->setPreset($this->getPreset($entity, $path, $width, $height, $mode, $optimize));
$path = $this->imagineManager->getThumb($path, $entity->getImagineId());
$url = \System::getBaseUri() . '/' . $path;
switch ($format) {
case 'url':
return $url;
case 'html':
return '<img src="' . $url . '" />';
case 'path':
return $path;
}
throw new \LogicException();
}