本文整理汇总了PHP中JFolder::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::delete方法的具体用法?PHP JFolder::delete怎么用?PHP JFolder::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preFlight
/**
* @param string $type
* @param JInstallerAdapterComponent $parent
*
* @return bool
*/
public function preFlight($type, $parent)
{
parent::preFlight($type, $parent);
/* Uninstall the depracated plugin OSCARootCertificates.
* The parent method can't be used because the old plugin
* has a bug that doesn't allow to use the native uninstall method.
*/
jimport('joomla.filesystem.folder');
$success = false;
// Remove the files
$path = JPATH_SITE . '/plugins/system/oscarootcertificates';
if (JFolder::exists($path)) {
$success = JFolder::delete($path);
}
// Remove the database row
$db = JFactory::getDbo();
$queryWhere = array($db->qn('type') . ' = ' . $db->q('plugin'), $db->qn('element') . ' = ' . $db->q('oscarootcertificates'), $db->qn('folder') . ' = ' . $db->q('system'));
$query = $db->getQuery(true)->select('COUNT(*)')->from('#__extensions')->where($queryWhere);
$db->setQuery($query);
if ((int) $db->loadResult() > 0) {
$query = $db->getQuery(true)->delete('#__extensions')->where($queryWhere);
$db->setQuery($query);
$success = $db->execute();
}
// Displays the success message
if ((bool) $success) {
$this->setMessage('Uninstalling system plugin OSCARootCertificates was successful');
}
return true;
}
示例2: doExecute
/**
* doExecute
*
* @return void
*/
protected function doExecute()
{
jimport('joomla.filesystem.folder');
$folder = $this->getArgument(0, '/');
$path = JPATH_BASE . '/cache/' . trim($folder, '/\\');
$path = realpath($path);
if (!$path) {
$this->out('Path: "' . $folder . '" not found.');
return;
}
$this->out('Clearing cache files...');
if ($path != realpath(JPATH_BASE . '/cache')) {
\JFolder::delete($path);
} else {
$files = new \FilesystemIterator($path);
foreach ($files as $file) {
if ($file->getBasename() == 'index.html') {
continue;
}
if ($file->isFile()) {
unlink((string) $file);
} else {
\JFolder::delete((string) $file);
}
}
}
$this->out(sprintf('Path: %s cleaned.', $path));
return;
}
示例3: run
public function run($app)
{
// remove obsolete elements
foreach (array('video', 'gallery', 'facebookilike', 'itempublishup') as $element) {
if ($folder = $app->path->path('media:zoo/elements/' . $element)) {
JFolder::delete($folder);
}
}
// rename _itempublishup to _itempublish_up in config files
foreach ($app->path->files('root:', true, '/positions\\.config/') as $file) {
if (preg_match('#renderer\\/item\\/#', $file)) {
$changed = false;
if (!($path = $app->path->path('root:' . $file))) {
continue;
}
$data = $app->data->create(file_get_contents($path));
if (!empty($data)) {
foreach ($data as $layout => $positions) {
foreach ($positions as $position => $elements) {
foreach ($elements as $index => $element) {
if (isset($element['element']) && $element['element'] == '_itempublishup') {
$data[$layout][$position][$index]['element'] = '_itempublish_up';
$changed = true;
}
}
}
}
}
if ($changed) {
$data = (string) $data;
JFile::write($app->path->path('root:' . $file), $data);
}
}
}
}
示例4: com_install
function com_install()
{
$mainframe = JFactory::getApplication();
jimport('joomla.filesystem.folder');
// Initialize variables
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$language = JFactory::getLanguage();
$language->load('com_jce_imgmanager_ext', JPATH_SITE);
$cache = $mainframe->getCfg('tmp_path');
// Check for tmp folder
if (!JFolder::exists($cache)) {
// Create if does not exist
if (!JFolder::create($cache)) {
$mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error');
}
}
// Check if folder exists and is writable or the FTP layer is enabled
if (JFolder::exists($cache) && (is_writable($cache) || $FTPOptions['enabled'] == 1)) {
$mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_CACHE_DESC'));
} else {
$mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error');
}
// Check for GD
if (!function_exists('gd_info')) {
$mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_GD_DESC'), 'error');
} else {
$info = gd_info();
$mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_GD_DESC') . ' - ' . $info['GD Version']);
}
// remove wideimage folder
if (JFolder::exists(dirname(__FILE) . '/classes/wideimage')) {
@JFolder::delete(dirname(__FILE) . '/classes/wideimage');
}
}
示例5: uninstall
public function uninstall($parent)
{
// Remove all Nucleus files manually as file installer only uninstalls files.
$manifest = $parent->getManifest();
// Loop through all elements and get list of files and folders
foreach ($manifest->fileset->files as $eFiles) {
$target = (string) $eFiles->attributes()->target;
$targetFolder = empty($target) ? JPATH_ROOT : JPATH_ROOT . '/' . $target;
// Check if all children exists
if (count($eFiles->children()) > 0) {
// Loop through all filenames elements
foreach ($eFiles->children() as $eFileName) {
if ($eFileName->getName() == 'folder') {
$folder = $targetFolder . '/' . $eFileName;
$files = JFolder::files($folder, '.', false, true);
foreach ($files as $name) {
JFile::delete($name);
}
$subFolders = JFolder::folders($folder, '.', false, true);
foreach ($subFolders as $name) {
JFolder::delete($name);
}
}
}
}
}
return true;
}
示例6: preflight
function preflight($type, $parent)
{
// Get the extension ID
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('extension_id')->from('#__extensions')->where($db->qn('element') . ' = ' . $db->q('com_eventgallery'));
$db->setQuery($query);
$eid = $db->loadResult();
if ($eid != null) {
// Get the schema version
$query = $db->getQuery(true);
$query->select('version_id')->from('#__schemas')->where('extension_id = ' . $eid);
$db->setQuery($query);
$version = $db->loadResult();
if (version_compare($version, '3.3.2', 'gt')) {
$msg = "<p>Downgrades are not supported. Please install the same or a newer version.</p>";
JError::raiseWarning(100, $msg);
return false;
}
}
$folders = array(JPATH_ROOT . '/administrator/components/com_eventgallery/controllers', JPATH_ROOT . '/administrator/components/com_eventgallery/media', JPATH_ROOT . '/administrator/components/com_eventgallery/models', JPATH_ROOT . '/administrator/components/com_eventgallery/views', JPATH_ROOT . '/administrator/components/com_eventgallery/sql', JPATH_ROOT . '/components/com_eventgallery/controllers', JPATH_ROOT . '/components/com_eventgallery/helpers', JPATH_ROOT . '/components/com_eventgallery/language', JPATH_ROOT . '/components/com_eventgallery/library', JPATH_ROOT . '/components/com_eventgallery/media', JPATH_ROOT . '/components/com_eventgallery/models', JPATH_ROOT . '/components/com_eventgallery/tests', JPATH_ROOT . '/components/com_eventgallery/views');
$files = array(JPATH_ROOT . '/language/en-GB/en-GB.com_eventgallery.ini', JPATH_ROOT . '/language/de-DE/de-DE.com_eventgallery.ini', JPATH_ROOT . '/administrator/language/en-GB/en-GB.com_eventgallery.ini', JPATH_ROOT . '/administrator/language/en-GB/en-GB.com_eventgallery.sys.ini');
foreach ($folders as $folder) {
if (JFolder::exists($folder)) {
JFolder::delete($folder);
}
}
foreach ($files as $file) {
if (JFolder::exists($file)) {
JFolder::delete($file);
}
}
$this->_copyCliFiles($parent);
}
示例7: uninstall
public function uninstall($adapter)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
// Delete plugin files
$folder = JPATH_PLUGINS . '/system/' . $this->_ext;
if (JFolder::exists($folder)) {
JFolder::delete($folder);
}
// Delete plugin language files
$lang_folder = JPATH_ADMINISTRATOR . '/language';
$languages = JFolder::folders($lang_folder);
foreach ($languages as $lang) {
$file = $lang_folder . '/' . $lang . '/' . $lang . '.plg_system_' . $this->_ext . '.ini';
if (JFile::exists($file)) {
JFile::delete($file);
}
$file = $lang_folder . '/' . $lang . '/' . $lang . '.plg_system_' . $this->_ext . '.sys.ini';
if (JFile::exists($file)) {
JFile::delete($file);
}
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)->delete('#__extensions')->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))->where($db->quoteName('element') . ' = ' . $db->quote($this->_ext));
$db->setQuery($query);
$db->execute();
}
示例8: unzip
/**
* unzip the file
* @return bool
*/
public function unzip()
{
JRequest::checkToken() or die('Invalid Token');
$appl = JFactory::getApplication();
// if folder doesn't exist - create it!
if (!JFolder::exists($this->pathUnzipped)) {
JFolder::create($this->pathUnzipped);
} else {
// let us remove all previous unzipped files
$folders = JFolder::folders($this->pathUnzipped);
foreach ($folders as $folder) {
JFolder::delete($this->pathUnzipped . '/' . $folder);
}
}
$file = JFolder::files($this->pathArchive);
$result = JArchive::extract($this->pathArchive . '/' . $file[0], $this->pathUnzipped . '/' . $file[0]);
if ($result) {
// scan unzipped folders if we find zip file -> unzip them as well
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
} else {
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
}
$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
return $result;
}
示例9: cleanupInstall
function cleanupInstall($userfile_name, $resultdir)
{
if (file_exists($resultdir)) {
JFolder::delete($resultdir);
unlink(DOCMAN_Compat::mosPathName(JPATH_ROOT . DS . 'media' . DS . $userfile_name, false));
}
}
示例10: purge
public function purge()
{
$user = JFactory::getUser();
if (!$user->authorise('core.admin', 'com_djmediatools')) {
echo JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
exit(0);
}
$files = JFolder::files(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('index.html', '.svn', 'CVS', '.DS_Store', '__MACOSX'));
$errors = array();
if (count($files) > 0) {
foreach ($files as $file) {
if (!JFile::delete($file)) {
$errors[] = $file;
}
}
}
$folders = JFolder::folders(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('.', '..'));
if (count($folders) > 0) {
$folders = array_reverse($folders);
foreach ($folders as $key => $folder) {
JFolder::delete($folder);
}
}
if (count($errors) > 0) {
echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_NOT_BEEN_DELETED', count($errors));
} else {
echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_BEEN_DELETED', count($files));
}
}
示例11: process
public function process($limitstart = 0)
{
$folders = $this->getFolders();
$target_folder = isset($folders[$limitstart]) ? $folders[$limitstart] : null;
if (!$target_folder) {
return true;
}
$path = str_replace(JPATH_SITE, '', $target_folder);
// Check if the target folder exists
if (!JFolder::exists($target_folder)) {
$this->success = false;
$this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_NOT_FOUND', $path);
return false;
}
// Check if the destination folder exists
if (JFolder::exists($target_folder . '3')) {
if (!JFolder::delete($target_folder . '3')) {
$this->success = false;
$this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_EXISTS', $path . '3');
return false;
}
}
if (!JFolder::move($target_folder, $target_folder . '3')) {
$this->success = false;
$this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_RENAME_FAILED', $path);
return false;
}
$this->log[] = JText::sprintf('COM_PFMIGRATOR_RENAME_FOLDER_SUCCESS', $path, $path . '3');
return true;
}
示例12: _removeObsoleteFilesAndFolders
private function _removeObsoleteFilesAndFolders($icagendaRemoveFiles)
{
// Remove files
jimport('joomla.filesystem.file');
if (!empty($icagendaRemoveFiles['files'])) {
foreach ($icagendaRemoveFiles['files'] as $file) {
$f = JPATH_ROOT . '/' . $file;
if (!JFile::exists($f)) {
continue;
}
JFile::delete($f);
}
}
// Remove folders
jimport('joomla.filesystem.file');
if (!empty($icagendaRemoveFiles['folders'])) {
foreach ($icagendaRemoveFiles['folders'] as $folder) {
$f = JPATH_ROOT . '/' . $folder;
if (!JFolder::exists($f)) {
continue;
}
JFolder::delete($f);
}
}
}
示例13: com_install
function com_install()
{
$db = JFactory::getDBO();
// Install System plugin
$src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_noixacl' . DS . 'plugins' . DS . 'system' . DS;
$dest = JPATH_ROOT . DS . 'plugins' . DS . 'system' . DS;
$res = JFile::copy($src . 'noixacl.php', $dest . 'noixacl.php');
$res = $res && JFile::copy($src . 'noixacl.xml', $dest . 'noixacl.xml');
$db->setQuery("INSERT INTO #__plugins\r\n\t (id, name, element, folder, access, ordering, published, iscore, client_id, checked_out, checked_out_time, params)\r\n\t VALUES ('', 'noixACL - System Plugin 2.0.10', 'noixacl', 'system', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')");
$res = $res && $db->query();
if (!$res) {
JError::raiseWarning(100, JText::_('NoixACL System plugin not installed. Please install it manually from the following folder') . ': ' . $src);
} else {
JFolder::delete($src);
}
// Install User plugin
$src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_noixacl' . DS . 'plugins' . DS . 'user' . DS;
$dest = JPATH_ROOT . DS . 'plugins' . DS . 'user' . DS;
$res = JFile::copy($src . 'noixacl.php', $dest . 'noixacl.php');
$res = $res && JFile::copy($src . 'noixacl.xml', $dest . 'noixacl.xml');
$db->setQuery("INSERT INTO #__plugins\r\n\t (id, name, element, folder, access, ordering, published, iscore, client_id, checked_out, checked_out_time, params)\r\n\t VALUES ('', 'noixACL - User Plugin 2.0.10', 'noixacl', 'user', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')");
$res = $res && $db->query();
if (!$res) {
JError::raiseWarning(100, JText::_('NoixACL User plugin not installed. Please install it manually from the following folder') . ': ' . $src);
} else {
JFolder::delete($src);
}
}
示例14: resetThumbs
public function resetThumbs()
{
$items = self::getItems();
//Get Params
$params = JComponentHelper::getParams('com_spsimpleportfolio');
$square = strtolower($params->get('square', '600x600'));
$rectangle = strtolower($params->get('rectangle', '600x400'));
$tower = strtolower($params->get('tower', '600x800'));
$cropratio = $params->get('cropratio', 4);
if (count($items)) {
//Removing old thumbs
foreach ($items as $item) {
$folder = JPATH_ROOT . '/images/spsimpleportfolio/' . $item->alias;
if (JFolder::exists($folder)) {
JFolder::delete($folder);
}
}
//Creating Thumbs
foreach ($items as $item) {
$image = JPATH_ROOT . '/' . $item->image;
$path = JPATH_ROOT . '/images/spsimpleportfolio/' . $item->alias;
if (!file_exists($path)) {
JFolder::create($path, 0755);
}
$sizes = array($square, $rectangle, $tower);
$image = new JImage($image);
$image->createThumbs($sizes, $cropratio, $path);
}
}
$this->setRedirect('index.php?option=com_config&view=component&component=com_spsimpleportfolio&path=&return=' . base64_encode('index.php?option=com_spsimpleportfolio'), 'Thumbnails generated.');
}
示例15: postflight
/**
* @param (string) $type
* @param (object) $parent
*/
public function postflight($type, $parent)
{
$folder = sprintf('%s/components/com_krizalys_countries', JPATH_SITE);
if (!JFolder::delete($folder)) {
echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $folder) . '<br />';
}
}