SystemUpdateInstaller Class Reference
[SystemUpdate]
Class to help installing stuff. More...
Static Public Member Functions |
|
static | copy_file_to_app ($source_file, $target_file, $policy=self::COPY_OVERWRITE) |
Copy a file to app. |
|
static | copy_to_app ($target_dir, $source_dir, $files, $policy=self::COPY_OVERWRITE) |
Copy given files to the given directory
benath /app. |
|
static | copy_to_webroot ($dir, $files, $policy=self::COPY_OVERWRITE) |
Copy given files to the web root directory.
|
|
static | modify_htaccess ($module, $section, $content) |
Inserts $content in .htaccess. |
|
Public Attributes |
|
const | COPY_NO_REPLACE = 'no_replace' |
const | COPY_OVERWRITE = 'overwrite' |
const | HTACCESS_OPTIONS = 'OPTIONS' |
const | HTACCESS_REWRITE = 'REWRITE' |
Detailed Description
Class to help installing stuff.
Definition at line 8 of file systemupdateinstaller.cls.php.
Member Function Documentation
static SystemUpdateInstaller::copy_file_to_app | ( | $ | source_file, | |
$ | target_file, | |||
$ | policy =
self::COPY_OVERWRITE |
|||
) | [static] |
Copy a file to app.
For example this copies the file test.php.example to the www subdirectory
SystemUpdateInstaller::copy_file_to_app('/var/backup/test.php.example', 'www/test.php');
- Parameters:
-
string $source_file Absolute path to source file string $target_file path to target file, relative to /app string $policy Either SystemUpdateInstaller::COPY_NO_REPLACE or SystemUpdateInstaller::COPY_OVERWRITE
- Returns:
- Status
Definition at line 63 of file systemupdateinstaller.cls.php.
00063 { 00064 $ret = new Status(); 00065 $target = APP_INCLUDE_ABSPATH . ltrim($target_file, '/'); 00066 if ($policy == self::COPY_OVERWRITE || !file_exists($target)) { 00067 if (!copy($source_file, $target)) { 00068 $ret->merge(tr( 00069 'Could not create %target from %source. Please do it manually', 00070 'systemupdate', 00071 array('%target' => $target, '%source' => $source_file) 00072 )); 00073 } 00074 } 00075 return $ret; 00076 }
static SystemUpdateInstaller::copy_to_app | ( | $ | target_dir, | |
$ | source_dir, | |||
$ | files, | |||
$ | policy =
self::COPY_OVERWRITE |
|||
) | [static] |
Copy given files to the given directory benath /app.
- Parameters:
-
string $target_dir Target directory (relative to /app) string $source_dir Source directory (absolute path) array $files array of file names relative to $dir string $policy Either SystemUpdateInstaller::COPY_NO_REPLACE or SystemUpdateInstaller::COPY_OVERWRITE
- Returns:
- Status
Definition at line 41 of file systemupdateinstaller.cls.php.
00041 { 00042 $ret = new Status(); 00043 $app = APP_INCLUDE_ABSPATH; 00044 00045 return self::copy_to_dir($app . $target_dir, $source_dir, $files, $policy); 00046 }
static SystemUpdateInstaller::copy_to_webroot | ( | $ | dir, | |
$ | files, | |||
$ | policy =
self::COPY_OVERWRITE |
|||
) | [static] |
Copy given files to the web root directory.
- Parameters:
-
string $dir Source directory array $files array of file names relatice to $dir string $policy Either SystemUpdateInstaller::COPY_NO_REPLACE or SystemUpdateInstaller::COPY_OVERWRITE
- Returns:
- Status
Definition at line 24 of file systemupdateinstaller.cls.php.
00024 { 00025 $ret = new Status(); 00026 $webroot = Config::get_value(Config::URL_ABSPATH); 00027 00028 return self::copy_to_dir($webroot, $dir, $files, $policy); 00029 }
static SystemUpdateInstaller::modify_htaccess | ( | $ | module, | |
$ | section, | |||
$ | content | |||
) | [static] |
Inserts $content in .htaccess.
- Parameters:
-
string $module Module requesting changes string $section Section in .htaccess string|array $content
- Returns:
- Status
Definition at line 130 of file systemupdateinstaller.cls.php.
00130 { 00131 $ret = new Status(); 00132 if (is_array($content)) { 00133 $content = implode("\n", $content); 00134 } 00135 00136 $start = '## start ' . $module . ' ' . $section; 00137 $end = '## end ' . $module . ' ' . $section; 00138 $content = "$start\n$content\n$end"; 00139 00140 $htaccess_path = Config::get_value(Config::URL_ABSPATH) . '.htaccess'; 00141 $htaccess = @file_get_contents($htaccess_path); 00142 // Remove old 00143 $pattern = preg_quote($start) . '.*' . preg_quote($end); 00144 $htaccess = preg_replace('|' . $pattern . '|s', '', $htaccess); 00145 // Insert new 00146 $section_string = "### BEGIN $section ###"; 00147 $section_start = strpos($htaccess, $section_string); 00148 if ($section_start !== false) { 00149 $htaccess = str_replace($section_string, $section_string . "\n\n" . $content, $htaccess); 00150 while(strpos($htaccess, "\n\n\n") !== false) { 00151 $htaccess = str_replace("\n\n\n", "\n\n", $htaccess); 00152 } 00153 if (file_put_contents($htaccess_path, $htaccess) === false) { 00154 $ret->append('Could not write .htaccess'); 00155 } 00156 } 00157 else { 00158 $ret->append("Your .htaccess is not ready to be automatically modified - or it misses the section $section"); 00159 } 00160 return $ret; 00161 }
Member Data Documentation
const SystemUpdateInstaller::COPY_NO_REPLACE = 'no_replace' |
Definition at line 9 of file systemupdateinstaller.cls.php.
const SystemUpdateInstaller::COPY_OVERWRITE = 'overwrite' |
Definition at line 10 of file systemupdateinstaller.cls.php.
const SystemUpdateInstaller::HTACCESS_OPTIONS = 'OPTIONS' |
Definition at line 12 of file systemupdateinstaller.cls.php.
const SystemUpdateInstaller::HTACCESS_REWRITE = 'REWRITE' |
Definition at line 13 of file systemupdateinstaller.cls.php.
The documentation for this class was generated from the following file:
- gyro/modules/systemupdate/lib/components/systemupdateinstaller.cls.php