📄 functions.php
字号:
*
* @deprecated As of version 1.5
*/
function mosPathWay() {
mosLoadModule('breadcrumb', -1);
}
/**
* Legacy function, use {@link JBrowser::getInstance()} instead
*
* @deprecated As of version 1.5
*/
function mosGetBrowser( $agent ) {
jimport('joomla.environment.browser');
$instance =& JBrowser::getInstance();
return $instance;
}
/**
* Legacy function, use {@link JApplication::getBrowser()} instead
*
* @deprecated As of version 1.5
*/
function mosGetOS( $agent ) {
jimport('joomla.environment.browser');
$instance =& JBrowser::getInstance();
return $instance->getPlatform();
}
/**
* Legacy function, use {@link JArrayHelper::getValue()} instead
*
* @deprecated As of version 1.5
*/
function mosGetParam( &$arr, $name, $def=null, $mask=0 )
{
// Static input filters for specific settings
static $noHtmlFilter = null;
static $safeHtmlFilter = null;
$var = JArrayHelper::getValue( $arr, $name, $def, '' );
// If the no trim flag is not set, trim the variable
if (!($mask & 1) && is_string($var)) {
$var = trim($var);
}
// Now we handle input filtering
if ($mask & 2) {
// If the allow html flag is set, apply a safe html filter to the variable
if (is_null($safeHtmlFilter)) {
$safeHtmlFilter = & JFilterInput::getInstance(null, null, 1, 1);
}
$var = $safeHtmlFilter->clean($var, 'none');
} elseif ($mask & 4) {
// If the allow raw flag is set, do not modify the variable
$var = $var;
} else {
// Since no allow flags were set, we will apply the most strict filter to the variable
if (is_null($noHtmlFilter)) {
$noHtmlFilter = & JFilterInput::getInstance(/* $tags, $attr, $tag_method, $attr_method, $xss_auto */);
}
$var = $noHtmlFilter->clean($var, 'none');
}
return $var;
}
/**
* Legacy function, use {@link JHTML::_('list.genericordering', )} instead
*
* @deprecated As of version 1.5
*/
function mosGetOrderingList( $sql, $chop='30' )
{
return JHTML::_('list.genericordering', $sql, $chop);
}
/**
* Legacy function, use {@link JRegistry} instead
*
* @deprecated As of version 1.5
*/
function mosParseParams( $txt ) {
$registry = new JRegistry();
$registry->loadINI($txt);
return $registry->toObject( );
}
/**
* Legacy function, removed
*
* @deprecated As of version 1.5
*/
function mosLoadComponent( $name )
{
// set up some global variables for use by the frontend component
global $mainframe, $database;
$name = JFilterInput::clean($name, 'cmd');
$path = JPATH_SITE.DS.'components'.DS.'com_'.$name.DS.$name.'.php';
if (file_exists($path)) {
include $path;
}
}
/**
* Legacy function, use {@link JEditor::init()} instead
*
* @deprecated As of version 1.5
*/
function initEditor()
{
$editor =& JFactory::getEditor();
echo $editor->initialise();
}
/**
* Legacy function, use {@link JEditor::save()} or {@link JEditor::getContent()} instead
*
* @deprecated As of version 1.5
*/
function getEditorContents($editorArea, $hiddenField)
{
jimport( 'joomla.html.editor' );
$editor =& JFactory::getEditor();
echo $editor->save( $hiddenField );
}
/**
* Legacy function, use {@link JEditor::display()} instead
*
* @deprecated As of version 1.5
*/
function editorArea($name, $content, $hiddenField, $width, $height, $col, $row)
{
jimport( 'joomla.html.editor' );
$editor =& JFactory::getEditor();
echo $editor->display($hiddenField, $content, $width, $height, $col, $row);
}
/**
* Legacy function, use {@link JMenu::authorize()} instead
*
* @deprecated As of version 1.5
*/
function mosMenuCheck( $Itemid, $menu_option, $task, $gid )
{
$user =& JFactory::getUser();
$menus =& JSite::getMenu();
$menus->authorize($Itemid, $user->get('aid'));
}
/**
* Legacy function, use {@link JArrayHelper::fromObject()} instead
*
* @deprecated As of version 1.5
*/
function mosObjectToArray( $p_obj, $recurse = true, $regex = null )
{
$result = JArrayHelper::fromObject( $p_obj, $recurse, $regex );
return $result;
}
/**
* Legacy function, use {@link JHTML::_('date', )} instead
*
* @deprecated As of version 1.5
*/
function mosFormatDate( $date = 'now', $format = null, $offset = null ) {
if ( ! $format )
{
$format = JText::_('DATE_FORMAT_LC1');
}
return JHTML::_('date', $date, $format, $offset);
}
/**
* Legacy function, use {@link JHTML::_('date', )} instead
*
* @deprecated As of version 1.5
*/
function mosCurrentDate( $format="" )
{
if ($format=="") {
$format = JText::_( 'DATE_FORMAT_LC1' );
}
return JHTML::_('date', 'now', $format);
}
/**
* Legacy function, use {@link JFilterOutput::objectHTMLSafe()} instead
*
* @deprecated As of version 1.5
*/
function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) {
JFilterOutput::objectHTMLSafe( $mixed, $quote_style, $exclude_keys );
}
/**
* Legacy function, handled by {@link JDocument} Zlib outputfilter
*
* @deprecated As of version 1.5
*/
function initGzip()
{
global $mainframe, $do_gzip_compress;
// attempt to disable session.use_trans_sid
ini_set('session.use_trans_sid', false);
$do_gzip_compress = FALSE;
if ($mainframe->getCfg('gzip') == 1) {
$phpver = phpversion();
$useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' );
$canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' );
if ( $phpver >= '4.0.4pl1' &&
( strpos($useragent,'compatible') !== false ||
strpos($useragent,'Gecko') !== false
)
) {
// Check for gzip header or northon internet securities
if ( isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
$encodings = explode(',', strtolower($_SERVER['HTTP_ACCEPT_ENCODING']));
}
if ( (in_array('gzip', $encodings) || isset( $_SERVER['---------------']) ) && extension_loaded('zlib') && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && !ini_get('session.use_trans_sid') ) {
// You cannot specify additional output handlers if
// zlib.output_compression is activated here
ob_start( 'ob_gzhandler' );
return;
}
} else if ( $phpver > '4.0' ) {
if ( strpos($canZip,'gzip') !== false ) {
if (extension_loaded( 'zlib' )) {
$do_gzip_compress = TRUE;
ob_start();
ob_implicit_flush(0);
header( 'Content-Encoding: gzip' );
return;
}
}
}
}
ob_start();
}
/**
* Legacy function, use JFolder::delete($path)
*
* @deprecated As of version 1.5
*/
function deldir( $dir )
{
$current_dir = opendir( $dir );
$old_umask = umask(0);
while ($entryname = readdir( $current_dir )) {
if ($entryname != '.' and $entryname != '..') {
if (is_dir( $dir . $entryname )) {
deldir( mosPathName( $dir . $entryname ) );
} else {
@chmod($dir . $entryname, 0777);
unlink( $dir . $entryname );
}
}
}
umask($old_umask);
closedir( $current_dir );
return rmdir( $dir );
}
/**
* Legacy function, handled by {@link JDocument} Zlib outputfilter
*
* @deprecated As of version 1.5
*/
function doGzip()
{
global $do_gzip_compress;
if ( $do_gzip_compress )
{
$gzip_contents = ob_get_contents();
ob_end_clean();
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
} else {
ob_end_flush();
}
}
/**
* Legacy function, use {@link JArrayHelper::sortObjects()} instead
*
* @deprecated As of version 1.5
*/
function SortArrayObjects( &$a, $k, $sort_direction=1 )
{
JArrayHelper::sortObjects($a, $k, $sort_direction);
}
/**
* Legacy function, {@link JRequest::getVar()}
*
* @deprecated As of version 1.5
*/
function josGetArrayInts( $name, $type=NULL ) {
$array = JRequest::getVar($name, array(), 'default', 'array' );
return $array;
}
/**
* Legacy function, {@link JSession} transparently checks for spoofing attacks
*
* @deprecated As of version 1.5
*/
function josSpoofCheck( $header=false, $alternate=false )
{
// Lets make sure they saw the html form
$check = true;
$hash = josSpoofValue();
$valid = JRequest::getBool( $hash, 0, 'post' );
if (!$valid) {
$check = false;
}
// Make sure request came from a client with a user agent string.
if (!isset( $_SERVER['HTTP_USER_AGENT'] )) {
$check = false;
}
// Check to make sure that the request was posted as well.
$requestMethod = JArrayHelper::getValue( $_SERVER, 'REQUEST_METHOD' );
if ($requestMethod != 'POST') {
$check = false;
}
if (!$check)
{
header( 'HTTP/1.0 403 Forbidden' );
jexit( JText::_('E_SESSION_TIMEOUT') );
}
}
/**
* Legacy function, use {@link JUtility::getToken()} instead
*
* @deprecated As of version 1.5
*/
function josSpoofValue($alt = NULL)
{
global $mainframe;
if ($alt) {
if ( $alt == 1 ) {
$random = date( 'Ymd' );
} else {
$random = $alt . date( 'Ymd' );
}
} else {
$random = date( 'dmY' );
}
// the prefix ensures that the hash is non-numeric
// otherwise it will be intercepted by globals.php
$validate = 'j' . mosHash( $mainframe->getCfg( 'db' ) . $random );
return $validate;
}
/**
* Legacy function to load the tooltip library.
*
* @deprecated As of version 1.5
*/
function loadOverlib() {
JHTML::_('behavior.tooltip');
}
/**
* Legacy utility function to provide ToolTips
*
* @deprecated As of version 1.5
*/
function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='', $link=1 )
{
// Initialize the toolips if required
static $init;
if ( ! $init )
{
JHTML::_('behavior.tooltip');
$init = true;
}
return JHTML::_('tooltip', $tooltip, $title, $image, $text, $href, $link);
}
/**
* Legacy function to convert an internal Joomla URL to a humanly readible URL.
*
* @deprecated As of version 1.5
*/
function sefRelToAbs($value)
{
// Replace all & with & as the router doesn't understand &
$url = str_replace('&', '&', $value);
if(substr(strtolower($url),0,9) != "index.php") return $url;
$uri = JURI::getInstance();
$prefix = $uri->toString(array('scheme', 'host', 'port'));
return $prefix.JRoute::_($url);
}
/**
* Legacy function to replaces & with & for xhtml compliance
*
* @deprecated As of version 1.5
*/
function ampReplace( $text ) {
return JFilterOutput::ampReplace($text);
}
/**
* Legacy function to replaces & with & for xhtml compliance
*
* @deprecated As of version 1.5
*/
function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 )
{
jimport('joomla.html.html');
return JHTML::_('menu.treerecurse', $id, $indent, $list, $children, $maxlevel, $level, $type);
}
/**
* Legacy function, use {@link JHTML::tooltip()} instead
*
* @deprecated As of version 1.5
*/
function mosWarning($warning, $title='Joomla! Warning') {
return JHTML::tooltip($warning, $title, 'warning.png', null, null, null);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -