Go to the source code of this file.
Packages | |
package | Mage_Core |
Functions | |
if(get_magic_quotes_gpc()) | __autoload ($class) |
destruct ($object) | |
__ () | |
uc_words ($str, $destSep='_', $srcSep='_') | |
now ($dayOnly=false) | |
is_empty_date ($date) | |
mageFindClassFile ($class) | |
mageCoreErrorHandler ($errno, $errstr, $errfile, $errline) | |
mageDebugBacktrace ($return=false, $html=true, $showFirst=false) | |
mageSendErrorHeader () | |
mageSendErrorFooter () | |
mageDelTree ($path) | |
mageParseCsv ($string, $delimiter=",", $enclosure='"', $escape='\\') | |
is_dir_writeable ($dir) |
__ | ( | ) |
Translator function
string | $text the text to translate | |
mixed | optional parameters to use in sprintf |
Definition at line 93 of file functions.php.
00094 { 00095 return Mage::app()->getTranslator()->translate(func_get_args()); 00096 }
if (get_magic_quotes_gpc()) __autoload | ( | $ | class | ) |
Disable magic quotes in runtime if needed
Class autoload todo 16. deprecated 24. string $class
Definition at line 60 of file functions.php.
00061 { 00062 if (defined('COMPILER_INCLUDE_PATH')) { 00063 $classFile = $class.'.php'; 00064 } else { 00065 $classFile = uc_words($class, DIRECTORY_SEPARATOR).'.php'; 00066 } 00067 00068 include($classFile); 00069 }
destruct | ( | $ | object | ) |
Object destructor
mixed | $object |
Definition at line 76 of file functions.php.
00077 { 00078 if (is_array($object)) { 00079 foreach ($object as $obj) { 00080 destruct($obj); 00081 } 00082 } 00083 unset($object); 00084 }
is_dir_writeable | ( | $ | dir | ) |
Definition at line 322 of file functions.php.
00323 { 00324 if (is_dir($dir) && is_writable($dir)) { 00325 if (stripos(PHP_OS, 'win') === 0) { 00326 $dir = ltrim($dir, DIRECTORY_SEPARATOR); 00327 $file = $dir . DIRECTORY_SEPARATOR . uniqid(mt_rand()).'.tmp'; 00328 $exist = file_exists($file); 00329 $fp = @fopen($file, 'a'); 00330 if ($fp === false) { 00331 return false; 00332 } 00333 fclose($fp); 00334 if (!$exist) { 00335 unlink($file); 00336 } 00337 } 00338 return true; 00339 } 00340 return false; 00341 } 00342 00343 if ( !function_exists('sys_get_temp_dir') ) { 00344 // Based on http://www.phpit.net/ 00345 // article/creating-zip-tar-archives-dynamically-php/2/ 00346 function sys_get_temp_dir() 00347 { 00348 // Try to get from environment variable 00349 if ( !empty($_ENV['TMP']) ) { 00350 return realpath( $_ENV['TMP'] ); 00351 } else if ( !empty($_ENV['TMPDIR']) ) { 00352 return realpath( $_ENV['TMPDIR'] ); 00353 } else if ( !empty($_ENV['TEMP']) ) { 00354 return realpath( $_ENV['TEMP'] ); 00355 } else { 00356 // Try to use system's temporary directory 00357 // as random name shouldn't exist 00358 $temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); 00359 if ( $temp_file ) { 00360 $temp_dir = realpath( dirname($temp_file) ); 00361 unlink( $temp_file ); 00362 return $temp_dir; 00363 } else { 00364 return FALSE; 00365 } 00366 } 00367 } 00368 }
is_empty_date | ( | $ | date | ) |
Check whether sql date is empty
string | $date |
Definition at line 130 of file functions.php.
mageCoreErrorHandler | ( | $ | errno, | |
$ | errstr, | |||
$ | errfile, | |||
$ | errline | |||
) |
Custom error handler
integer | $errno | |
string | $errstr | |
string | $errfile | |
integer | $errline |
Definition at line 161 of file functions.php.
00161 { 00162 if (strpos($errstr, 'DateTimeZone::__construct')!==false) { 00163 // there's no way to distinguish between caught system exceptions and warnings 00164 return false; 00165 } 00166 00167 $errno = $errno & error_reporting(); 00168 if ($errno == 0) { 00169 return false; 00170 } 00171 if (!defined('E_STRICT')) { 00172 define('E_STRICT', 2048); 00173 } 00174 if (!defined('E_RECOVERABLE_ERROR')) { 00175 define('E_RECOVERABLE_ERROR', 4096); 00176 } 00177 00178 // PEAR specific message handling 00179 if (stripos($errfile.$errstr, 'pear') !== false) { 00180 // ignore strict notices 00181 if ($errno == E_STRICT) { 00182 return false; 00183 } 00184 // ignore attempts to read system files when open_basedir is set 00185 if ($errno == E_WARNING && stripos($errstr, 'open_basedir') !== false) { 00186 return false; 00187 } 00188 } 00189 00190 $errorMessage = ''; 00191 00192 switch($errno){ 00193 case E_ERROR: 00194 $errorMessage .= "Error"; 00195 break; 00196 case E_WARNING: 00197 $errorMessage .= "Warning"; 00198 break; 00199 case E_PARSE: 00200 $errorMessage .= "Parse Error"; 00201 break; 00202 case E_NOTICE: 00203 $errorMessage .= "Notice"; 00204 break; 00205 case E_CORE_ERROR: 00206 $errorMessage .= "Core Error"; 00207 break; 00208 case E_CORE_WARNING: 00209 $errorMessage .= "Core Warning"; 00210 break; 00211 case E_COMPILE_ERROR: 00212 $errorMessage .= "Compile Error"; 00213 break; 00214 case E_COMPILE_WARNING: 00215 $errorMessage .= "Compile Warning"; 00216 break; 00217 case E_USER_ERROR: 00218 $errorMessage .= "User Error"; 00219 break; 00220 case E_USER_WARNING: 00221 $errorMessage .= "User Warning"; 00222 break; 00223 case E_USER_NOTICE: 00224 $errorMessage .= "User Notice"; 00225 break; 00226 case E_STRICT: 00227 $errorMessage .= "Strict Notice"; 00228 break; 00229 case E_RECOVERABLE_ERROR: 00230 $errorMessage .= "Recoverable Error"; 00231 break; 00232 default: 00233 $errorMessage .= "Unknown error ($errno)"; 00234 break; 00235 } 00236 00237 $errorMessage .= ": {$errstr} in {$errfile} on line {$errline}"; 00238 00239 throw new Exception($errorMessage); 00240 }
mageDebugBacktrace | ( | $ | return = false , |
|
$ | html = true , |
|||
$ | showFirst = false | |||
) |
Definition at line 242 of file functions.php.
00243 { 00244 $d = debug_backtrace(); 00245 $out = ''; 00246 if ($html) $out .= "<pre>"; 00247 foreach ($d as $i=>$r) { 00248 if (!$showFirst && $i==0) { 00249 continue; 00250 } 00251 // sometimes there is undefined index 'file' 00252 @$out .= "[$i] {$r['file']}:{$r['line']}\n"; 00253 } 00254 if ($html) $out .= "</pre>"; 00255 if ($return) { 00256 return $out; 00257 } else { 00258 echo $out; 00259 } 00260 }
mageDelTree | ( | $ | path | ) |
Definition at line 282 of file functions.php.
00282 { 00283 if (is_dir($path)) { 00284 $entries = scandir($path); 00285 foreach ($entries as $entry) { 00286 if ($entry != '.' && $entry != '..') { 00287 mageDelTree($path.DS.$entry); 00288 } 00289 } 00290 @rmdir($path); 00291 } else { 00292 @unlink($path); 00293 } 00294 }
mageFindClassFile | ( | $ | class | ) |
Definition at line 135 of file functions.php.
00136 { 00137 if (defined('COMPILER_INCLUDE_PATH')) { 00138 $classFile = $class.'.php'; 00139 } else { 00140 $classFile = uc_words($class, DIRECTORY_SEPARATOR).'.php'; 00141 } 00142 $found = false; 00143 foreach (explode(PS, get_include_path()) as $path) { 00144 $fileName = $path.DS.$classFile; 00145 if (file_exists($fileName)) { 00146 $found = $fileName; 00147 break; 00148 } 00149 } 00150 return $found; 00151 }
mageParseCsv | ( | $ | string, | |
$ | delimiter = "," , |
|||
$ | enclosure = '"' , |
|||
$ | escape = '\\' | |||
) |
Definition at line 296 of file functions.php.
00297 { 00298 $elements = explode($delimiter, $string); 00299 for ($i = 0; $i < count($elements); $i++) { 00300 $nquotes = substr_count($elements[$i], $enclosure); 00301 if ($nquotes %2 == 1) { 00302 for ($j = $i+1; $j < count($elements); $j++) { 00303 if (substr_count($elements[$j], $enclosure) > 0) { 00304 // Put the quoted string's pieces back together again 00305 array_splice($elements, $i, $j-$i+1, 00306 implode($delimiter, array_slice($elements, $i, $j-$i+1))); 00307 break; 00308 } 00309 } 00310 } 00311 if ($nquotes > 0) { 00312 // Remove first and last quotes, then merge pairs of quotes 00313 $qstr =& $elements[$i]; 00314 $qstr = substr_replace($qstr, '', strpos($qstr, $enclosure), 1); 00315 $qstr = substr_replace($qstr, '', strrpos($qstr, $enclosure), 1); 00316 $qstr = str_replace($enclosure.$enclosure, $enclosure, $qstr); 00317 } 00318 } 00319 return $elements; 00320 }
mageSendErrorFooter | ( | ) |
Definition at line 272 of file functions.php.
00273 { 00274 return; 00275 if (!isset($_SERVER['SCRIPT_NAME'])) { 00276 return; 00277 } 00278 echo '</textarea></form><script type="text/javascript">document.getElementById("error_report").submit()</script>'; 00279 exit; 00280 }
mageSendErrorHeader | ( | ) |
Definition at line 262 of file functions.php.
00263 { 00264 return; 00265 if (!isset($_SERVER['SCRIPT_NAME'])) { 00266 return; 00267 } 00268 $action = Mage::app()->getRequest()->getBasePath()."bugreport.php"; 00269 echo '<form id="error_report" method="post" style="display:none" action="'.$action.'"><textarea name="error">'; 00270 }
now | ( | $ | dayOnly = false |
) |
Simple sql format date
string | $format |
Definition at line 119 of file functions.php.
uc_words | ( | $ | str, | |
$ | destSep = '_' , |
|||
$ | srcSep = '_' | |||
) |
Tiny function to enhance functionality of ucwords
Will capitalize first letters and convert separators if needed
string | $str | |
string | $destSep | |
string | $srcSep |
Definition at line 108 of file functions.php.