}
}
+
+if( !function_exists( 'mb_strpos' ) ) {
+ /**
+ * Fallback implementation of mb_strpos, hardcoded to UTF-8.
+ * @param string $haystack
+ * @param string $needle
+ * @param string $offset optional start position
+ * @param string $encoding optional encoding; ignored
+ * @return int
+ */
+ function mb_strpos( $haystack, $needle, $offset = 0, $encoding="" ) {
+ $needle = preg_quote( $needle, '/' );
+
+ $ar = array();
+ preg_match( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
+
+ if( isset( $ar[0][1] ) ) {
+ return $ar[0][1];
+ } else {
+ return false;
+ }
+ }
+}
+
+if( !function_exists( 'mb_strrpos' ) ) {
+ /**
+ * Fallback implementation of mb_strrpos, hardcoded to UTF-8.
+ * @param string $haystack
+ * @param string $needle
+ * @param string $offset optional start position
+ * @param string $encoding optional encoding; ignored
+ * @return int
+ */
+ function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = "" ) {
+ $needle = preg_quote( $needle, '/' );
+
+ $ar = array();
+ preg_match_all( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
+
+ if( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
+ isset( $ar[0][count($ar[0])-1][1] ) ) {
+ return $ar[0][count($ar[0])-1][1];
+ } else {
+ return false;
+ }
+ }
+}
+
if ( !function_exists( 'array_diff_key' ) ) {
/**
* Exists in PHP 5.1.0+
* @return String: the requested message.
*/
function wfMsgReal( $key, $args, $useDB = true, $forContent=false, $transform = true ) {
- global $wgMessageCache;
wfProfileIn( __METHOD__ );
- $message = wfMsgGetKey( $key, $useDB, $forContent, false );
+ $message = wfMsgGetKey( $key, $useDB, $forContent, $transform );
$message = wfMsgReplaceArgs( $message, $args );
- if( $transform && is_object( $wgMessageCache ) ) {
- $message = $wgMessageCache->transform( $message, !$forContent );
- }
wfProfileOut( __METHOD__ );
return $message;
}
* have query string parameters already. If so, they will be combined.
*
* @param string $url
- * @param string $query
+ * @param mixed $query String or associative array
* @return string
*/
function wfAppendQuery( $url, $query ) {
+ if ( is_array( $query ) ) {
+ $query = wfArrayToCGI( $query );
+ }
if( $query != '' ) {
if( false === strpos( $url, '?' ) ) {
$url .= '?';
* @return string Unified diff of $before and $after
*/
function wfDiff( $before, $after, $params = '-u' ) {
+ if ($before == $after) {
+ return '';
+ }
+
global $wgDiff;
# This check may also protect against code injection in
*
* @param string $dir Full path to directory to create
* @param int $mode Chmod value to use, default is $wgDirectoryMode
+ * @param string $caller Optional caller param for debugging.
* @return bool
*/
-function wfMkdirParents( $dir, $mode = null ) {
+function wfMkdirParents( $dir, $mode = null, $caller = null ) {
global $wgDirectoryMode;
+ if ( !is_null( $caller ) ) {
+ wfDebug( "$caller: called wfMkdirParents($dir)" );
+ }
+
if( strval( $dir ) === '' || file_exists( $dir ) )
return true;