本文整理汇总了PHP中Maged_Controller::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Maged_Controller::model方法的具体用法?PHP Maged_Controller::model怎么用?PHP Maged_Controller::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maged_Controller
的用法示例。
在下文中一共展示了Maged_Controller::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _installFile2
//.........这里部分代码省略.........
$task =& new $task($this->config, $this, PEAR_TASK_INSTALL);
if (!$task->isScript()) {
// scripts are only handled after installation
$task->init($raw, $attribs, $pkg->getLastInstalledVersion());
$res = $task->startSession($pkg, $contents, $final_dest_file);
if ($res === false) {
continue;
// skip this file
}
if (PEAR::isError($res)) {
return $res;
}
$contents = $res;
// save changes
}
$wp = @fopen($dest_file, "wb");
if (!is_resource($wp)) {
return $this->raiseError("failed to create {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
}
if (fwrite($wp, $contents) === false) {
return $this->raiseError("failed writing to {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
}
fclose($wp);
}
}
// {{{ check the md5
if (isset($md5sum)) {
if (strtolower($md5sum) === strtolower($attribs['md5sum'])) {
$this->log(2, "md5sum ok: {$final_dest_file}");
} else {
if (empty($options['force'])) {
// delete the file
if (file_exists($dest_file)) {
unlink($dest_file);
}
if (!isset($options['ignore-errors'])) {
return $this->raiseError("bad md5sum for file {$final_dest_file}", PEAR_INSTALLER_FAILED);
} else {
if (!isset($options['soft'])) {
$this->log(0, "warning : bad md5sum for file {$final_dest_file}");
}
}
} else {
if (!isset($options['soft'])) {
$this->log(0, "warning : bad md5sum for file {$final_dest_file}");
}
}
}
}
// }}}
// {{{ set file permissions
if (!OS_WINDOWS) {
if ($role->isExecutable()) {
$mode = 0777 & ~(int) octdec($this->config->get('umask'));
$this->log(3, "+ chmod +x {$dest_file}");
} else {
$mode = 0666 & ~(int) octdec($this->config->get('umask'));
}
/*
* Magento fix for custom set permissions in config.ini
*/
if (class_exists('Maged_Controller', false)) {
$magedConfig = Maged_Controller::model('Config', true)->load();
if ($magedConfig->get('use_custom_permissions_mode') == '1') {
if ($role->isExecutable() && ($configMode = $magedConfig->get('chmod_file_mode_executable'))) {
$mode = $magedConfig;
}
if (!$role->isExecutable() && ($configMode = $magedConfig->get('chmod_file_mode'))) {
$mode = $magedConfig;
}
}
}
/*
* End fix
*/
if ($attribs['role'] != 'src') {
$this->addFileOperation("chmod", array($mode, $dest_file));
if (!@chmod($dest_file, $mode)) {
if (!isset($options['soft'])) {
$this->log(0, "failed to change mode of {$dest_file}: {$php_errormsg}");
}
}
}
}
// }}}
if ($attribs['role'] == 'src') {
rename($dest_file, $final_dest_file);
$this->log(2, "renamed source file {$dest_file} to {$final_dest_file}");
} else {
$this->addFileOperation("rename", array($dest_file, $final_dest_file, $role->isExtension()));
}
}
// Store the full path where the file was installed for easy uninstall
if ($attribs['role'] != 'src') {
$loc = $this->config->get($role->getLocationConfig(), null, $channel);
$this->addFileOperation("installed_as", array($file, $installed_as, $loc, dirname(substr($installed_as, strlen($loc)))));
}
//$this->log(2, "installed: $dest_file");
return PEAR_INSTALLER_OK;
}
示例2: mkDirHier
/**
* Wrapper to System::mkDir(), creates a directory as well as
* any necessary parent directories.
*
* @param string $dir directory name
*
* @return bool TRUE on success, or a PEAR error
*
* @access public
*/
function mkDirHier($dir)
{
$this->log(2, "+ create dir {$dir}");
if (!class_exists('System')) {
require_once 'System.php';
}
/*
* Magento fix for custom set permissions in config.ini
*/
if (class_exists('Maged_Controller', false)) {
$magedConfig = Maged_Controller::model('Config', true)->load();
if ($magedConfig->get('use_custom_permissions_mode') == '1' && ($mode = $magedConfig->get('mkdir_mode'))) {
return System::mkDir(array('-m' . $mode, $dir));
}
}
/*
* End fix
*/
return System::mkDir(array('-p', $dir));
}
示例3: tmpdir
/**
* Get the path of the temporal directory set in the system
* by looking in its environments variables.
* Note: php.ini-recommended removes the "E" from the variables_order setting,
* making unavaible the $_ENV array, that s why we do tests with _ENV
*
* @static
* @return string The temporary directory on the system
*/
function tmpdir()
{
/*
* Magento fix for set tmp dir in config.ini
*/
if (class_exists('Maged_Controller', false)) {
$magedConfig = Maged_Controller::model('Config', true)->load();
if (!is_null($tmpDir = $magedConfig->get('tmp_dir'))) {
return $tmpDir;
}
}
/*
* End fix
*/
if (OS_WINDOWS) {
if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
return $var;
}
if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
return $var;
}
if ($var = isset($_ENV['USERPROFILE']) ? $_ENV['USERPROFILE'] : getenv('USERPROFILE')) {
return $var;
}
if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
return $var;
}
return getenv('SystemRoot') . '\\temp';
}
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}