本文整理汇总了PHP中JFolder::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::copy方法的具体用法?PHP JFolder::copy怎么用?PHP JFolder::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doclone
function doclone()
{
$themename = JRequest::getVar('themename');
$newname = JRequest::getString('name');
$newfolder = JRequest::getString('themefolder');
$newdescription = JRequest::getString('description');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
if (is_array($themename)) {
$themename = $themename[0];
}
$themedir = JTheFactoryThemesHelper::getThemeDir();
if (!JTheFactoryThemesHelper::isThemeFile($themedir . DS . $themename . DS . "theme.xml")) {
JError::raiseWarning(420, JText::_("FACTORY_THEME_IS_NOT_VALID"));
$this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes");
return true;
}
if (JFolder::exists($themedir . DS . $newfolder)) {
JError::raiseWarning(420, JText::_("FACTORY_FOLDER_ALREADY_EXISTS") . " " . $newfolder);
$this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes");
return true;
}
JFolder::copy($themedir . DS . $themename, $themedir . DS . $newfolder);
$manifest_file = $themedir . DS . $newfolder . DS . "theme.xml";
$xml = JFactory::getXML($manifest_file);
unset($xml['priority']);
$xml['folder'] = $newfolder;
$xml->name = $newname;
$xml->description = $newdescription;
$xml->creationDate = date('Y-m-d');
$xmlcontent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . $xml->asFormattedXML();
JFile::write($manifest_file, $xmlcontent);
$this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=themes.listthemes", JText::_("FACTORY_THEME_SAVED"));
}
示例2: install
function install()
{
$pkg_path = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR;
if (JFolder::exists($pkg_path . 'nextend')) {
$librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
JFolder::copy($pkg_path . 'nextend', $librariesPath . DIRECTORY_SEPARATOR . 'nextend', '', true);
JFolder::delete($pkg_path . 'nextend');
}
$extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
if (version_compare(JVERSION, '3.0.0', 'ge')) {
foreach ($extensions as $pkg) {
$f = $pkg_path . DIRECTORY_SEPARATOR . $pkg;
$xmlfiles = JFolder::files($f, '.xml$', 1, true);
foreach ($xmlfiles as $xmlf) {
$file = file_get_contents($xmlf);
file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
}
}
}
foreach ($extensions as $pkg) {
$installer = new JInstaller();
$installer->setOverwrite(true);
if ($success = $installer->install($pkg_path . DIRECTORY_SEPARATOR . $pkg)) {
$msgcolor = "#E0FFE0";
$name = version_compare(JVERSION, '1.6.0', 'l') ? $installer->getManifest()->document->name[0]->data() : $installer->getManifest()->name;
$msgtext = $name . " successfully installed.";
} else {
$msgcolor = "#FFD0D0";
$msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://www.nextendweb.com/help/support";
}
?>
<table bgcolor="<?php
echo $msgcolor;
?>
" width ="100%">
<tr style="height:30px">
<td><font size="2"><b><?php
echo $msgtext;
?>
</b></font></td>
</tr>
</table><?php
if ($success && file_exists("{$pkg_path}/{$pkg}/install.php")) {
require_once "{$pkg_path}/{$pkg}/install.php";
$com = new $pkg();
$com->install();
}
}
$db = JFactory::getDBO();
if (version_compare(JVERSION, '1.6.0', 'lt')) {
$db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%nextend%'");
} else {
$db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
}
$db->query();
if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR)) {
JFolder::delete(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
}
}
示例3: preflight
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
public function preflight($type, $parent)
{
// $parent is the class calling this method
//$parent->getParent()->setRedirectURL('index.php?option=com_ckeditor');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
jimport('joomla.installer.installer');
$installer = JInstaller::getInstance();
$source = $installer->getPath('source');
$packages = $source . DS . 'packages';
// Get editor package
if (is_dir($packages)) {
$editor = JFolder::files($packages, 'plg_ckeditor.zip', false, true);
}
if (!empty($editor) && is_file($editor[0])) {
$confObject = JFactory::getApplication();
$packagePath = dirname($editor[0]) . DS . 'ckeditor';
if (!JArchive::extract($editor[0], $packagePath)) {
$editor_result = JText::_('EDITOR EXTRACT ERROR');
} else {
$installer = JInstaller::getInstance();
$c_manifest = $installer->getManifest();
$c_root =& $c_manifest->document;
if (JFolder::copy($packagePath, dirname($installer->getPath('extension_site')) . DS . '..' . DS . 'plugins' . DS . 'editors', '', true)) {
$editor_result = JText::_('Success');
} else {
$editor_result = JText::_('Error');
}
}
} else {
$editor_result = JText::_('Error');
}
echo '<p>' . $editor_result . '</p>';
}
示例4: InstallCBPlugin
function InstallCBPlugin($plugintitle, $tabtitle, $pluginname, $folder, $class)
{
$database = JFactory::getDBO();
$query = "SELECT id FROM #__comprofiler_plugin where element='{$pluginname}'";
$database->setQuery($query);
$plugid = $database->loadResult();
if (!$plugid) {
$query = "INSERT INTO #__comprofiler_plugin SET\r\n `name`='{$plugintitle}',\r\n `element`='{$pluginname}',\r\n `type`='user',\r\n `folder`='{$folder}',\r\n `ordering`=99,\r\n `published`=1,\r\n `iscore`=0\r\n ";
$database->setQuery($query);
$database->query();
$plugid = $database->insertid();
}
$query = "SELECT COUNT(1) FROM #__comprofiler_tabs where pluginid='{$plugid}'";
$database->setQuery($query);
$tabs = $database->loadResult();
if (!$tabs) {
$query = "INSERT INTO #__comprofiler_tabs set\r\n `title`='{$tabtitle}',\r\n `ordering`=999,\r\n `enabled`=1,\r\n `pluginclass`='{$class}',\r\n `pluginid`='{$plugid}',\r\n `fields`=0,\r\n `displaytype`='tab',\r\n `position`='cb_tabmain'\r\n ";
$database->setQuery($query);
$database->query();
}
$sourceFolder = $this->_sourcepath . DS . $folder;
$destinationFolder = JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . $folder;
JFolder::create($destinationFolder);
JFolder::copy($sourceFolder, $destinationFolder, '', true);
return "Installed CB plugin " . $plugintitle;
}
示例5: installPricingPack
function installPricingPack($sourcepath)
{
if (!self::isPackXML($sourcepath . DS . "manifest.xml")) {
JError::raiseWarning(500, JText::_("FACTORY_FILE_IS_NOT_A_VALID_PRICING_MANIFEST") . $sourcepath . DS . "manifest.xml");
return null;
}
$xml = JFactory::getXML($sourcepath . DS . "manifest.xml");
$destfolder = (string) $xml->attributes()->folder;
$destination = JPATH_COMPONENT_ADMINISTRATOR . DS . 'pricing' . DS . $destfolder;
jimport("joomla.filesystem.folder");
JFolder::copy($sourcepath, $destination);
$db = JFactory::getDbo();
$db->setQuery("select max(`ordering`)+1 from #__" . APP_PREFIX . "_pricing");
$maxordering = $db->loadResult();
$paytable = JTable::getInstance('PricingTable', 'JTheFactory');
$paytable->itemname = (string) $xml->attributes()->folder;
$paytable->pricetype = (string) $xml->pricetype;
$paytable->name = (string) $xml->name;
$paytable->price = (string) $xml->price;
$paytable->currency = (string) $xml->currency;
$paytable->enabled = 0;
$paytable->params = null;
$paytable->ordering = $maxordering;
$paytable->store();
self::parseQueries($xml->queries);
}
示例6: installGatewayPack
function installGatewayPack($sourcepath)
{
if (!self::isPackXML($sourcepath . DS . "manifest.xml")) {
JError::raiseWarning(500, JText::_("FACTORY_FILE_IS_NOT_A_VALID_GATEWAY_MANIFEST") . $sourcepath . DS . "manifest.xml");
return null;
}
$xml = JFactory::getXML($sourcepath . DS . "manifest.xml");
$destfolder = (string) $xml->attributes()->folder;
$MyApp = JTheFactoryApplication::getInstance();
$destination = $MyApp->app_path_admin . 'payments' . DS . 'plugins' . DS . 'gateways' . DS . strtolower($destfolder);
jimport("joomla.filesystem.folder");
JFolder::copy($sourcepath, $destination);
$db = JFactory::getDbo();
$db->setQuery("select max(`ordering`)+1 from #__" . APP_PREFIX . "_paysystems");
$maxordering = $db->loadResult();
$gw = JTable::getInstance('GatewaysTable', 'JTheFactory');
$gw->paysystem = (string) $xml->name;
$gw->classname = (string) $xml->attributes()->folder;
$gw->enabled = 0;
$gw->params = null;
$gw->ordering = $maxordering;
$gw->isdefault = 0;
$gw->store();
self::parseQueries($xml->queries);
}
示例7: preflight
/**
* Method to run before an install/update/uninstall method.
*
* @param string $type The type of change (install, update or discover_install)
* @param string $parent The class calling this method
*
* @return boolean
*/
public function preflight($type, $parent)
{
/* @var JInstaller $grandParent */
$grandParent = $parent->getParent();
$PHPMinVersion = '5.3';
if (version_compare(PHP_VERSION, $PHPMinVersion, '<')) {
JFactory::getApplication()->enqueueMessage(sprintf('This script requires at least PHP version %s', $PHPMinVersion), 'error');
return false;
}
//-- This does not work :( - css..
JFactory::getDocument()->addStylesheet(JURI::root(true) . '/media/com_easycreator/admin/css/default.css');
if ('update' == $type) {
$this->extensionPaths = array('admin' => $grandParent->getPath('extension_administrator'), 'site' => $grandParent->getPath('extension_administrator'));
if (false === $this->updateWithMd5File($parent)) {
JFactory::getApplication()->enqueueMessage('Can not update your current EasyCreator version - Please uninstall first - sry ;(', 'error');
return false;
}
$oldFolders = array('builds' => 'data/builds', 'exports' => 'data/exports', 'logs' => 'data/logs', 'results' => 'data/results', 'scripts' => 'data/projects');
$extensionPath = $grandParent->getPath('extension_administrator');
foreach ($oldFolders as $oldName => $newName) {
if (JFolder::exists($extensionPath . '/' . $oldName)) {
if (JFolder::copy($extensionPath . '/' . $oldName, $extensionPath . '/' . $newName)) {
echo sprintf('The folder %s has been copied to %s', $oldName, $newName) . '<br />';
} else {
echo '<strong style="color: red;">' . sprintf('The folder %s could not be copied to %s', $oldName, $newName) . '</strong><br />';
}
}
}
}
return true;
}
示例8: prepareExport
public function prepareExport($id = 0)
{
$config = JFactory::getConfig();
$tmp_path = $config->get('tmp_path');
$tmp_dir = uniqid('cck_');
$path = $tmp_path . '/' . $tmp_dir;
$extension = JCckDatabase::loadObject('SELECT name, type, element, folder FROM #__extensions WHERE extension_id=' . (int) $id);
if (!$extension) {
return;
}
jimport('cck.base.install.export');
$name = $extension->element;
$prefix = CCK_Export::getPrefix($extension->type);
$src = JPATH_SITE . '/plugins/' . $extension->folder . '/' . $extension->element;
$xml = JCckDev::fromXML($src . '/' . $name . '.xml');
$version = isset($xml->version) ? '_' . $xml->version : '';
$filename = $prefix . '_' . $extension->folder . '_' . $name . $version;
$path_zip = $tmp_path . '/' . $filename . '.zip';
if (!$filename) {
return;
}
if ($src && JFolder::exists($src)) {
JFolder::copy($src, $path);
CCK_Export::clean($path);
}
CCK_Export::exportLanguage($src . '/' . $name . '.xml', JPATH_ADMINISTRATOR, $path);
CCK_Export::findFields(array($src . '/tmpl/edit.php', $src . '/tmpl/edit2.php'), $path . '/install');
return CCK_Export::zip($path, $path_zip);
}
示例9: preflight
/**
* Called before any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install)
* @param object $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($type, $parent)
{
// init vars
$db = JFactory::getDBO();
$type = strtolower($type);
$this->_src = $parent->getParent()->getPath('source');
// tmp folder
$this->_target = JPATH_ROOT . '/plugins/system/zlframework';
// install folder
$this->_ext_version = $parent->get("manifest")->version;
// load ZLFW sys language file EXAMPLE
// JFactory::getLanguage()->load('plg_system_zlframework.sys', JPATH_ADMINISTRATOR, 'en-GB', true);
// check dependencies if not uninstalling
if ($type != 'uninstall' && !$this->checkDependencies($parent)) {
Jerror::raiseWarning(null, $this->_error);
return false;
}
// don't overide layouts EXAMPLE
/*
* when updating we don't wont to override renderer/item folder,
* so let's delete the temp folder before install only if it already exists
*/
// if($type == 'update'){
// JFolder::exists($this->_target.'/renderer/item') &&
// JFolder::delete($this->_src.'/renderer/item');
// }
if ($type == 'update') {
/* warn about update requirements only once */
if (!JFile::exists($this->_src . '/warned.txt') && !$this->checkCompatibility($this->_src . '/zlframework/dependencies.config')) {
// rise error
Jerror::raiseWarning(null, $this->_error);
// create a dummy indicational mark file
$some = 'dummy content';
JFile::write($this->_src . '/warned.txt', $some);
// copy the entire install to avoid it delition on cancel
JFolder::copy($this->_src, JPath::clean(JPATH_ROOT . '/tmp/' . basename($this->_src . '_copy')));
// cancel update
return false;
} else {
if (JFile::exists($this->_src . '/warned.txt')) {
JFile::delete($this->_src . '/warned.txt');
}
}
// EXAMPLE make sure the DB schema is set, necesary for SQL updates
// // get extension id
// $db->setQuery("SELECT `extension_id` FROM `#__extensions` WHERE `type` = 'plugin' AND `element` = '{$this->_ext}' AND `folder` = 'system'");
// if ($plg = $db->loadObject()) $this->_ext_id = (int)$plg->extension_id;
// // set schema
// $db->setQuery("SELECT * FROM `#__schemas` WHERE `extension_id` = '{$this->_ext_id}'");
// if (!$db->loadObject()) {
// $query = $db->getQuery(true);
// $query->clear()
// ->insert($db->quoteName('#__schemas'))
// ->columns(array($db->quoteName('extension_id'), $db->quoteName('version_id')))
// ->values($this->_ext_id . ', ' . $db->quote('2013-01-01'));
// $db->setQuery($query)->execute();
// }
}
}
示例10: install
function install(&$plg)
{
$src = dirname(__FILE__) . DS . 'component';
$dest = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping';
$lang =& JFactory::getLanguage();
$inst =& JInstaller::getInstance();
$desc = (string) $inst->getManifest()->description;
$lang->load('plg_jshoppingcheckout_' . $this->_name . '.sys', JPATH_ADMINISTRATOR, null, true);
$inst->set('message', JText::_($desc));
if (!JFolder::exists($dest)) {
return false;
}
if (JFolder::exists($src)) {
foreach (JFolder::folders($src) as $f) {
JFolder::copy($src . DS . $f, $dest . DS . $f, '', true);
}
}
// Конфигурирование JoomShopping (установка дополнений)
$this->jshoppingUpdate();
$res = false;
$path = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping' . DS . 'shippings' . DS . $this->_name . DS;
if (extension_loaded('ionCube Loader')) {
// use ionCube
$res = true;
} else {
// check zend loader/optimizer
$list = get_loaded_extensions();
foreach ($list as &$item) {
if (preg_match("/zend.*(loader|optimizer)/i", $item)) {
$res = true;
break;
}
}
if ($res) {
// Zend was found, detect php version
if (version_compare(phpversion(), "5.3") >= 0) {
// php > 5.3
JFile::move($this->_name . '_5.3.php', $this->_name . '.php', $path);
} else {
JFile::move($this->_name . '_5.2.php', $this->_name . '.php', $path);
}
}
}
if (JFile::exists($path . $this->_name . '_5.2.php')) {
JFile::delete($path . $this->_name . '_5.2.php');
}
if (JFile::exists($path . $this->_name . '_5.3.php')) {
JFile::delete($path . $this->_name . '_5.3.php');
}
if ($res) {
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('PED_INSTALL_NOTIFY'), 'notice');
} else {
JError::raiseNotice('500', JText::_('PED_ZEND_NOT_LOADED'));
}
return true;
}
示例11: copyFiles
protected function copyFiles($parent)
{
$app = JFactory::getApplication();
$installer = $parent->getParent();
$src = $installer->getPath('source') . '/site';
$dest = JPATH_SITE . '/components/com_rsform';
if (!JFolder::copy($src, $dest, '', true)) {
$app->enqueueMessage('Could not copy to ' . str_replace(JPATH_SITE, '', $dest) . ', please make sure destination is writable!', 'error');
}
}
示例12: postflight
public function postflight($type, $parent)
{
if ($type == 'uninstall') {
return true;
}
$installer = $parent->getParent();
$src = $installer->getPath('source') . '/admin';
$dest = JPATH_ADMINISTRATOR . '/components/com_rsform';
JFolder::copy($src, $dest, '', true);
}
示例13: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$path = JPATH_BASE . '/language';
if (is_dir($path)) {
JFolder::delete($path);
}
JFolder::copy(__DIR__ . '/data/language', $path);
$this->object = new JLanguage();
$this->inspector = new JLanguageInspector('', true);
}
示例14: setDestinationData
/**
* Sets the data in the destination database.
*
* @return void
* @since 0.4.
* @throws Exception
*/
protected function setDestinationData()
{
// Get the source data.
$rows = $this->getSourceData();
//$table = empty($this->destination) ? $this->source : $this->destination;
for ($i = 0; $i < count($rows); $i++) {
$src = JPATH_ROOT . DS . 'templates' . DS . $rows[$i]['template'];
$dest = JPATH_SITE . DS . 'templates' . DS . $rows[$i]['template'];
JFolder::copy($src, $dest);
}
}
示例15: __construct
/**
* Constructor.
*
* @param EcrProjectBase $project
*
* @throws DomainException
*/
public function __construct(EcrProjectBase $project)
{
$this->project = $project;
$comParams = JComponentHelper::getComponent('com_easycreator')->params;
$this->localPath = $comParams->get('local_updateserver_dir');
$this->serverUrl = $comParams->get('updateserver_url');
$this->serverTitle = $comParams->get('updateserver_title');
$this->releaseUrl = $comParams->get('updateserver_release_url') ?: $this->serverUrl;
$this->developmentUrl = $comParams->get('updateserver_development_url') ?: $this->serverUrl;
//-- Check the base directory
if (false == JFolder::exists(ECRPATH_UPDATESERVER)) {
if (false == JFolder::copy(JPATH_COMPONENT_ADMINISTRATOR . '/data/updateserver', ECRPATH_UPDATESERVER)) {
throw new DomainException(sprintf('%s - Can not create the update server directory: %s', __METHOD__, ECRPATH_UPDATESERVER));
}
EcrHtml::message(sprintf(jgettext('The update server directory has been created in: %s'), ECRPATH_UPDATESERVER));
}
//-- Check the extension directory
$base = ECRPATH_UPDATESERVER . '/' . $this->project->comName;
if (false == JFolder::exists($base)) {
if (false == JFolder::create($base)) {
throw new DomainException(sprintf('%s - Can not create the extension update server directory: %s', __METHOD__, $base));
}
EcrHtml::message(sprintf(jgettext('The update server extension directory has been created in: %s'), $base));
JFolder::create($base . '/release');
JFolder::create($base . '/development');
JFile::copy(ECRPATH_UPDATESERVER . '/index.html', $base . '/index.html');
JFile::copy(ECRPATH_UPDATESERVER . '/template_extension.html', $base . '/template.html');
JFile::copy(ECRPATH_UPDATESERVER . '/updateserver.css', $base . '/updateserver.css');
JFile::copy(ECRPATH_UPDATESERVER . '/favicon.ico', $base . '/favicon.ico');
/* @var SimpleXMLElement $xml */
$xml = EcrProjectHelper::getXML('<updates/>', false);
$xml->addChild('name', $this->project->name);
$buffer = $xml->asFormattedXML();
//-- @todo: The file name "extension.xml" is the J! default - customize.
JFile::write($base . '/extension.xml', $buffer);
JFile::write($base . '/development.xml', $buffer);
$feed = new EcrProjectFeed();
$feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Release Feed';
$feed->link = $this->releaseUrl . '/release-feed.xml';
$feed->id = $feed->link;
$feed->author = 'XX-Author';
$feed->updated = date(DATE_ATOM);
$buffer = $feed->printPretty();
JFile::write($base . '/release-feed.xml', $buffer);
$feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Development Feed';
$feed->link = $this->developmentUrl . '/development-feed.xml';
$feed->id = $feed->link;
$buffer = $feed->printPretty();
JFile::write($base . '/development-feed.xml', $buffer);
//-- Copy the Joomla! manifest
JFile::copy($this->project->getJoomlaManifestPath() . '/' . $this->project->getJoomlaManifestName(), $base . '/manifest.xml');
$this->update();
}
}