本文整理汇总了PHP中Jaws_Utils::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Utils::copy方法的具体用法?PHP Jaws_Utils::copy怎么用?PHP Jaws_Utils::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Utils
的用法示例。
在下文中一共展示了Jaws_Utils::copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copy
/**
* Makes a copy of the source file or directory to dest
*
* @access public
* @param string $source Path to the source file or directory
* @param string $dest The destination path
* @param bool $overwrite Overwrite files if exists
* @param int $mode see php chmod() function
* @return bool True if success, False otherwise
* @see http://www.php.net/copy
*/
static function copy($source, $dest, $overwrite = true, $mode = null)
{
$result = false;
if (file_exists($source)) {
if (is_dir($source)) {
if (false !== ($hDir = @opendir($source))) {
if ($result = Jaws_Utils::mkdir($dest, 0, $mode)) {
while (false !== ($file = @readdir($hDir))) {
if ($file == '.' || $file == '..') {
continue;
}
$result = Jaws_Utils::copy($source . DIRECTORY_SEPARATOR . $file, $dest . DIRECTORY_SEPARATOR . $file, $overwrite, $mode);
if (!$result) {
break;
}
}
}
closedir($hDir);
}
} else {
if (file_exists($dest) && !$overwrite) {
$destinfo = pathinfo($dest);
$dest = $destinfo['dirname'] . DIRECTORY_SEPARATOR . $destinfo['filename'] . '_' . uniqid(floor(microtime() * 1000));
if (isset($destinfo['extension']) && !empty($destinfo['extension'])) {
$dest .= '.' . $destinfo['extension'];
}
}
$result = @copy($source, $dest);
if ($result) {
$result = $dest;
if (!empty($mode)) {
Jaws_Utils::chmod($dest, $mode);
}
}
}
}
return $result;
}
示例2: InstallSampleSite
/**
* Install some gadgets with default data
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function InstallSampleSite()
{
$gadgets = array('Blog', 'Phoo', 'LinkDump', 'Contact', 'Menu', 'Emblems');
$variables = array();
$variables['Blog'] = array('timestamp' => Jaws_DB::getInstance()->date(), 'blog_content1_title' => _t('INSTALL_SAMPLE_BLOG_CONTENT1_TITLE'), 'blog_content1_summary' => _t('INSTALL_SAMPLE_BLOG_CONTENT1_SUMMARY'));
$variables['Phoo'] = array('timestamp' => Jaws_DB::getInstance()->date(), 'folder-path' => gmdate('Y_m_d'), 'siteurl' => Jaws_Utils::getBaseURL('/', false));
$variables['LinkDump'] = array('timestamp' => Jaws_DB::getInstance()->date(), 'linkdump_title1' => _t('INSTALL_SAMPLE_LINKDUMP_TITLE1'), 'linkdump_title2' => _t('INSTALL_SAMPLE_LINKDUMP_TITLE2'), 'linkdump_title3' => _t('INSTALL_SAMPLE_LINKDUMP_TITLE3'));
$variables['Contact'] = array();
$variables['Menu'] = array('timestamp' => Jaws_DB::getInstance()->date(), 'siteurl' => Jaws_Utils::getBaseURL('/', false), 'menu_title1' => _t('INSTALL_SAMPLE_MENU_TITLE1'), 'menu_title2' => _t('INSTALL_SAMPLE_MENU_TITLE2'), 'menu_title3' => _t('INSTALL_SAMPLE_MENU_TITLE3'), 'menu_title4' => _t('INSTALL_SAMPLE_MENU_TITLE4'));
$variables['Emblems'] = array();
// Install gadgets
foreach ($gadgets as $gadget) {
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem while loading sample gadget: {$gadget}");
_log(JAWS_LOG_DEBUG, $objGadget->getMessage());
} else {
$installer = $objGadget->installer->load();
$input_schema = JAWS_PATH . "install/stages/Settings/Sample/{$gadget}/insert.xml";
if (!file_exists($input_schema)) {
$input_schema = '';
}
$res = $installer->InstallGadget($input_schema, $variables[$gadget]);
if (Jaws_Error::IsError($res)) {
_log(JAWS_LOG_DEBUG, "There was a problem while installing sample gadget {$gadget}");
_log(JAWS_LOG_DEBUG, $res->getMessage());
} else {
_log(JAWS_LOG_DEBUG, "Sample gadget {$gadget} installed successfully.");
}
}
}
// Inserts layout sample itemes
$objGadget = Jaws_Gadget::getInstance('Layout');
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem while loading gadget: Layout");
_log(JAWS_LOG_DEBUG, $objGadget->getMessage());
} else {
$base_schema = JAWS_PATH . "gadgets/Layout/Resources/schema/schema.xml";
$input_schema = JAWS_PATH . "install/stages/Settings/Sample/Layout/insert.xml";
$installer = $objGadget->installer->load();
$res = $installer->installSchema($input_schema, '', $base_schema, true);
if (Jaws_Error::IsError($res)) {
_log(JAWS_LOG_DEBUG, "There was a problem while inserting sample itemes into gadget {$gadget}");
_log(JAWS_LOG_DEBUG, $res->getMessage());
} else {
_log(JAWS_LOG_DEBUG, "Sample itemes inserted into gadget {$gadget}.");
}
}
// set Blog as main gadget
$GLOBALS['app']->Registry->update('main_gadget', 'Blog', true, 'Settings');
// Copy Photo Organizer sample data
$source = JAWS_PATH . 'install/stages/Settings/Sample/Phoo/data/';
$destination = JAWS_DATA . 'phoo/' . $variables['Phoo']['folder-path'] . '/';
if (Jaws_Utils::copy($source, $destination)) {
_log(JAWS_LOG_DEBUG, "Sample data of gadget Phoo copied successfully.");
} else {
_log(JAWS_LOG_DEBUG, "There was a problem while copying sample data of gadget Phoo");
}
return true;
}