Public Member Functions |
| | read_file ($Files, $Path, $File, $Mask= '/.+/', $Recursive=true) |
| | get_files_from_directory ($Path, $Mask= '/.+/', $Recursive=true) |
| | zip_directory ($Directory, $ArchivePath) |
| | pack_into_url ($Params, $Exceptions) |
| | get_package (&$Settings, $File, $Prefix= '') |
| | get_package_path (&$Settings) |
| | get_records (&$Settings) |
| | detect_browser () |
Detailed Description
Utilities.
- Author
- Dodonov A.A.
Definition at line 26 of file utilities.php.
Member Function Documentation
Function detects browser.
- Returns
- Browser name.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Note
- The function will return 'ie' if the browser was not detected.
- Author
- Dodonov A.A.
Definition at line 401 of file utilities.php.
{
try
{
$UserAgent = $_SERVER['HTTP_USER_AGENT'];
if( stristr( $UserAgent , 'Firefox' ) !== false )
{
return( 'firefox' );
}
elseif( stristr( $UserAgent , 'Chrome' ) !== false )
{
return( 'chrome' );
}
elseif( stristr( $UserAgent , 'Safari' ) !== false )
{
return( 'safari' );
}
elseif( stristr( $UserAgent , 'Opera' ) !== false )
{
return( 'opera' );
}
return( 'ie' );
}
catch( Exception $e )
{
}
}
| get_files_from_directory |
( |
|
$Path, |
|
|
|
$Mask = '/.+/', |
|
|
|
$Recursive = true |
|
) |
| |
Function returns all files from the defined directory.
- Parameters
-
| $Path | - Path to the directory. |
| $Mask | - File filtering mask. |
| $Recursive | - Recursive directory parsing. |
- Returns
- Array with file paths.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 125 of file utilities.php.
{
try
{
$Path = rtrim( $Path , '/' ).'/';
$Handle = @opendir( $Path );
$Files = array();
if( $Handle !== false )
{
for( ; false !== ( $File = readdir( $Handle ) ) ; )
{
$Files = $this->
read_file( $Files , $Path , $File , $Mask , $Recursive );
}
closedir( $Handle );
}
return( $Files );
}
catch( Exception $e )
{
}
}
| get_package |
( |
& |
$Settings, |
|
|
|
$File, |
|
|
|
$Prefix = '' |
|
) |
| |
Method returns package.
- Parameters
-
| $Settings | - Fetch parameters. |
| $File | - File path. |
| $Prefix | - Settings names prefix. |
- Returns
- Package.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 275 of file utilities.php.
{
try
{
$PackageName = $Settings->get_setting( $Prefix.'package_name' );
$PackageVersion = $Settings->get_setting( $Prefix.'package_version' , 'last' );
return(
get_package( $PackageName , $PackageVersion , $File ) );
}
catch( Exception $e )
{
}
}
| get_package_path |
( |
& |
$Settings | ) |
|
Method returns path to package.
- Parameters
-
| $Settings | - Fetch parameters. |
- Returns
- Path to package.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 313 of file utilities.php.
{
try
{
$PackageName = $Settings->get_setting( 'package_name' );
$PackageVersion = $Settings->get_setting( 'package_version' , 'last' );
}
catch( Exception $e )
{
}
}
| get_records |
( |
& |
$Settings | ) |
|
Function selects records.
- Parameters
-
- Returns
- Records.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 351 of file utilities.php.
{
try
{
$Query = $this->Settings->get_setting( 'query' , false );
if( $Query )
{
$Records = $this->Database->query( $Query );
return( $this->Database->fetch_results( $Records ) );
}
else
{
$FunctionName = $Settings->get_setting( 'access_function_name' , 'simple_select' );
if( method_exists( $Package , $FunctionName ) )
{
return( call_user_func( array( $Package , $FunctionName ) ) );
}
}
throw( new Exception( "Can't get records" ) );
}
catch( Exception $e )
{
}
}
| pack_into_url |
( |
|
$Params, |
|
|
|
$Exceptions |
|
) |
| |
Function packs parameters into URL.
- Parameters
-
| $Params | - Paramateres for packing. |
| $Exceptions | - List of the excluding parameters. |
- Returns
- URL with parameters.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 223 of file utilities.php.
{
try
{
$Tmp = array();
foreach( $Params as $k => $v )
{
if(
in_array( $k , $Exceptions ) ===
false )
{
$Tmp [] = "$k=$v";
}
}
return( implode( '&' , $Tmp ) );
}
catch( Exception $e )
{
}
}
| read_file |
( |
|
$Files, |
|
|
|
$Path, |
|
|
|
$File, |
|
|
|
$Mask = '/.+/', |
|
|
|
$Recursive = true |
|
) |
| |
Function processes found file.
- Parameters
-
| $Files | - Found files. |
| $Path | - Path to the directory. |
| $File | - Found file. |
| $Mask | - File filtering mask. |
| $Recursive | - Recursive directory parsing. |
- Returns
- Array with file paths.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 66 of file utilities.php.
{
try
{
if( $File != "." && $File != ".." && $File != 'index.html' )
{
$FullPath = $Path.$File;
if( $Recursive && is_dir( $FullPath ) )
{
$Files = array_merge(
$Files ,
);
}
elseif( preg_match( $Mask , $FullPath ) )
{
$Files [] = $FullPath;
}
}
return( $Files );
}
catch( Exception $e )
{
}
}
| zip_directory |
( |
|
$Directory, |
|
|
|
$ArchivePath |
|
) |
| |
Function archives directory.
- Parameters
-
| $Directory | - Directory to be archived. |
| ArchivePath | - Path to the archive. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 174 of file utilities.php.
{
try
{
$Text =
get_package(
'string::text' ,
'last' , __FILE__ );
$Files = $Text->trim_common_prefix( $Files );
$Zip = new ZipArchive;
$Zip->open( "$ArchivePath" , ZIPARCHIVE::CREATE );
foreach( $Files as $i => $File )
{
$Zip->addFile( "$Directory/$File" , $File );
}
$Zip->close();
}
catch( Exception $e )
{
}
}
The documentation for this class was generated from the following file: