📄 functions.php
字号:
<?php/** * @version $Id: functions.php 11214 2008-10-26 01:29:04Z ian $ * @package Joomla.Legacy * @subpackage 1.5 * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. *//** * Legacy function, use <jdoc:exists type="modules" condition="{POSITION}" /> instead * * @deprecated As of version 1.5 */function mosCountModules( $position='left' ) { jimport('joomla.application.module.helper'); return count(JModuleHelper::getModules($position));}/** * Legacy function, use <jdoc:include type="component" /> instead * * @deprecated As of version 1.5 */function mosMainBody() { ?><jdoc:include type="component" /><?php}/** * Legacy function, use <jdoc:include type="modules" /> instead * * @deprecated As of version 1.5 */function mosLoadModules( $position='left', $style=0 ){ // Select the module chrome function if (is_numeric($style)) { switch ( $style ) { case -3: $style = 'rounded'; break; case -2: $style = 'xhtml'; break; case -1: $style = 'raw'; break; case 0 : default : $style = 'table'; break; } } ?><jdoc:include type="modules" name="<?php echo $position ?>" style="<?php echo $style ?>"/><?php}/** * Legacy function, use <jdoc:include type="module" /> instead * * @deprecated As of version 1.5 */function mosLoadModule( $name, $style=-1 ) { ?><jdoc:include type="module" name="<?php echo $name ?>" style="<?php echo $style ?>" /><?php}/** * Legacy function, use <jdoc:include type="head" /> instead * * @deprecated As of version 1.5 */function mosShowHead() { ?><jdoc:include type="head" /><?php}/** * Legacy function, using <jdoc:exists> instead * * @deprecated As of version 1.5 */function mosCountAdminModules( $position='left' ) { $document =& JFactory::getDocument(); return count($document->getModules($position));}/** * Legacy function, using <jdoc:include type="component" /> instead * * @deprecated As of version 1.5 */function mosMainBody_Admin() { ?><jdoc:include type="component" /><?php}/** * Legacy function, using <jdoc:include type="modules" /> instead * * @deprecated As of version 1.5 */function mosLoadAdminModules( $position='left', $style=0 ) { // Select the module chrome function if (is_numeric($style)) { switch ( $style ) { case 2: $style = 'xhtml'; break; case 0 : default : $style = 'raw'; break; } } ?><jdoc:include type="modules" name="<?php echo $position ?>" style="<?php echo $style ?>" /><?php}/** * Legacy function, using <jdoc:include type="module" /> instead * * @deprecated As of version 1.5 */function mosLoadAdminModule( $name, $style=0 ) { ?><jdoc:include type="module" name="<?php echo $name ?>" style="<?php echo $style ?>" /><?php}/** * Legacy function, using <jdoc:include type="head" /> instead * * @deprecated As of version 1.5 */function mosShowHead_Admin() { ?><jdoc:include type="head" /><?php}/** * Legacy function, always use {@link JRequest::getVar()} instead * * @deprecated As of version 1.5 */function mosStripslashes( &$value ){ $ret = ''; if (is_string( $value )) { $ret = stripslashes( $value ); } else { if (is_array( $value )) { $ret = array(); foreach ($value as $key => $val) { $ret[$key] = mosStripslashes( $val ); } } else { $ret = $value; } } return $ret;}/** * Legacy function, use {@link JArrayHelper JArrayHelper->toObject()} instead * * @deprecated As of version 1.5 */function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ){ if (!is_array( $array ) || !is_object( $obj )) { return (false); } foreach (get_object_vars($obj) as $k => $v) { if( substr( $k, 0, 1 ) != '_' ) { // internal attributes of an object are ignored if (strpos( $ignore, $k) === false) { if ($prefix) { $ak = $prefix . $k; } else { $ak = $k; } if (isset($array[$ak])) { $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? mosStripslashes( $array[$ak] ) : $array[$ak]; } } } } return true;}/** * Legacy function, use {@link JUtility::getHash()} instead * * @deprecated As of version 1.5 */function mosHash( $seed ) { return JUtility::getHash( $seed );}/*** Legacy function * * @deprecated As of version 1.5*/function mosNotAuth(){ $user =& JFactory::getUser(); echo JText::_('ALERTNOTAUTH'); if ($user->get('id') < 1) { echo "<br />" . JText::_( 'You need to login.' ); }}/** * Legacy function, use (@link JError} or {@link JApplication::redirect()} instead. * * @deprecated As of version 1.5 */function mosErrorAlert( $text, $action='window.history.go(-1);', $mode=1 ){ global $mainframe; $text = nl2br( $text ); $text = addslashes( $text ); $text = strip_tags( $text ); switch ( $mode ) { case 2: echo "<script>$action</script> \n"; break; case 1: default: echo "<script>alert('$text'); $action</script> \n"; echo '<noscript>'; echo "$text\n"; echo '</noscript>'; break; } $mainframe->close();}/** * Legacy function, use {@link JPath::clean()} instead * * @deprecated As of version 1.5 */function mosPathName($p_path, $p_addtrailingslash = true){ jimport('joomla.filesystem.path'); $path = JPath::clean($p_path); if ($p_addtrailingslash) { $path = rtrim($path, DS) . DS; } return $path;}/** * Legacy function, use {@link JFolder::files()} or {@link JFolder::folders()} instead * * @deprecated As of version 1.5 */function mosReadDirectory( $path, $filter='.', $recurse=false, $fullpath=false ){ $arr = array(null); // Get the files and folders jimport('joomla.filesystem.folder'); $files = JFolder::files($path, $filter, $recurse, $fullpath); $folders = JFolder::folders($path, $filter, $recurse, $fullpath); // Merge files and folders into one array $arr = array_merge($files, $folders); // Sort them all asort($arr); return $arr;}/** * Legacy function, use {@link JFactory::getMailer()} instead * * @deprecated As of version 1.5 */function mosCreateMail( $from='', $fromname='', $subject, $body ) { $mail =& JFactory::getMailer(); $mail->From = $from ? $from : $mail->From; $mail->FromName = $fromname ? $fromname : $mail->FromName; $mail->Subject = $subject; $mail->Body = $body; return $mail;}/** * Legacy function, use {@link JUtility::sendMail()} instead * * @deprecated As of version 1.5 */function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { return JUTility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname );}/** * Legacy function, use {@link JUtility::sendAdminMail()} instead * * @deprecated As of version 1.5 */function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { JUtility::sendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author );}/** * Legacy function, use {@link JUserHelper::genRandomPassword()} instead * * @deprecated As of version 1.5 */function mosMakePassword() { jimport('joomla.user.helper'); return JUserHelper::genRandomPassword();}/** * Legacy function, use {@link JApplication::redirect() JApplication->redirect()} instead * * @deprecated As of version 1.5 */function mosRedirect( $url, $msg='' ) { global $mainframe; $mainframe->redirect( $url, $msg );}/** * Legacy function, use {@link JFolder::create()} * * @deprecated As of version 1.5 */function mosMakePath($base, $path='', $mode = NULL) { if ($mode===null) { $mode = 0755; } jimport('joomla.filesystem.folder'); return JFolder::create($base.$path, $mode);}/** * Legacy function, use {@link JArrayHelper::toInteger()} instead * * @deprecated As of version 1.5 */function mosArrayToInts( &$array, $default=null ) { return JArrayHelper::toInteger( $array, $default );}/** * Legacy function, use {@link JException::getTrace() JException->getTrace()} instead * * @deprecated As of version 1.5 */function mosBackTrace( $message='' ) { if (function_exists( 'debug_backtrace' )) { echo '<div align="left">'; if ($message) { echo '<p><strong>' . $message . '</strong></p>'; } foreach( debug_backtrace() as $back) { if (@$back['file']) { echo '<br />' . str_replace( JPATH_ROOT, '', $back['file'] ) . ':' . $back['line']; } } echo '</div>'; }}/** * Legacy function, use {@link JPath::setPermissions()} instead * * @deprecated As of version 1.5 */function mosChmod( $path ) { jimport('joomla.filesystem.path'); return JPath::setPermissions( $path );}/** * Legacy function, use {@link JPath::setPermissions()} instead * * @deprecated As of version 1.5 */function mosChmodRecursive( $path, $filemode=NULL, $dirmode=NULL ) { jimport('joomla.filesystem.path'); return JPath::setPermissions( $path, $filemode, $dirmode );}/** * Legacy function, use {@link JPath::canChmod()} instead * * @deprecated As of version 1.5 */function mosIsChmodable( $file ) { jimport('joomla.filesystem.path'); return JPath::canChmod( $file );}/** * Legacy function, replaced by geshi bot * * @deprecated As of version 1.5 */function mosShowSource( $filename, $withLineNums=false ) { ini_set('highlight.html', '000000'); ini_set('highlight.default', '#800000'); ini_set('highlight.keyword','#0000ff'); ini_set('highlight.string', '#ff00ff'); ini_set('highlight.comment','#008000'); if (!($source = @highlight_file( $filename, true ))) { return JText::_( 'Operation Failed' ); } $source = explode("<br />", $source); $ln = 1; $txt = ''; foreach( $source as $line ) { $txt .= "<code>"; if ($withLineNums) { $txt .= "<font color=\"#aaaaaa\">"; $txt .= str_replace( ' ', ' ', sprintf( "%4d:", $ln ) ); $txt .= "</font>"; } $txt .= "$line<br /><code>"; $ln++; } return $txt;}/** * Legacy function, use mosLoadModule( 'breadcrumb', -1 ); instead
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -