本文整理汇总了PHP中JFile::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::copy方法的具体用法?PHP JFile::copy怎么用?PHP JFile::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: com_install
function com_install()
{
$file = new JFile();
$basePath = 'libraries' . DS . 'solr' . DS;
$basePathClient = $basePath . 'client.php';
$basePathQuery = $basePath . 'query.php';
$dest = JPATH_LIBRARIES . DS . 'solr' . DS;
$file->copy($basePathClient, $dest);
$file->copy($basePathQuery, $dest);
}
示例2: 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);
}
}
示例3: defaultTpl
function defaultTpl($tpl = null)
{
JToolBarHelper::title(JText::_('STOP WORDS'), 'tag.png');
$canDo = UsersHelper::getActions();
if ($canDo->get('core.create')) {
JToolBarHelper::apply();
JToolBarHelper::spacer();
JToolBarHelper::save();
JToolBarHelper::spacer();
JToolBarHelper::custom('restore', 'default', '', JText::_('RESTORE DEFAULT'), false);
JToolBarHelper::spacer();
}
JToolBarHelper::back(JText::_('CEDTAG_CONTROL_PANEL'), 'index.php?option=com_cedtag');
$lang = strval(JFactory::getLanguage()->getDefault());
$file = JPATH_ADMINISTRATOR . '/components/com_cedtag/stopwords/stopwords_' . $lang . '.php';
if (!is_file($file)) {
JFile::copy(JPATH_ADMINISTRATOR . '/components/com_cedtag/stopwords/stopwords_en-GB-default.php', $file);
}
$isWritable = is_writable($file);
$FileContent = trim(file_get_contents($file));
$this->assign('isWritable', $isWritable);
$this->assignRef('FileName', $file);
$this->assignRef('FileContent', $FileContent);
parent::display($tpl);
}
示例4: install
public function install()
{
// Request forgeries check
JRequest::checkToken() or die('Invalid Token');
$file = JRequest::getVar('rule', '', 'FILES');
$app = JFactory::getApplication();
$files = array();
// @task: If there's no tmp_name in the $file, we assume that the data sent is corrupted.
if (!isset($file['tmp_name'])) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
// There are various MIME type for compressed file. So let's check the file extension instead.
if ($file['name'] && JFile::getExt($file['name']) == 'xml') {
$files = array($file['tmp_name']);
} else {
$jConfig = DiscussHelper::getJConfig();
$path = rtrim($jConfig->get('tmp_path'), '/') . '/' . $file['name'];
// @rule: Copy zip file to temporary location
if (!JFile::copy($file['tmp_name'], $path)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
jimport('joomla.filesystem.archive');
$tmp = md5(DiscussHelper::getDate()->toMysQL());
$dest = rtrim($jConfig->get('tmp_path'), '/') . '/' . $tmp;
if (!JArchive::extract($path, $dest)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
$files = JFolder::files($dest, '.', true, true);
if (empty($files)) {
// Try to do a level deeper in case the zip is on the outer.
$folder = JFolder::folders($dest);
if (!empty($folder)) {
$files = JFolder::files($dest . '/' . $folder[0], true);
$dest = $dest . '/' . $folder[0];
}
}
if (empty($files)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
}
if (empty($files)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_FAILED'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
foreach ($files as $file) {
$this->installXML($file);
}
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_SUCCESS'), DISCUSS_QUEUE_SUCCESS);
$app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install');
$app->close();
}
示例5: install
/**
* Function to install an AUP rule
*
* @param object $parent - the parent installer object
* @param string $pluginName - the plugin name
*
* @return boolean
*/
public static function install($parent, $pluginName)
{
$status = false;
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/library/cb/cb.installer.php')) {
global $_CB_framework;
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.class.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/comprofiler.class.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/library/cb/cb.installer.php';
$cbInstaller = new cbInstallerPlugin();
if ($cbInstaller->install($parent->getParent()->getPath('source') . '/components/com_comprofiler/plugin/user/' . $pluginName . '/')) {
$path = $parent->getParent()->getPath('source') . '/components/com_comprofiler/plugin/user/' . $pluginName . '/administrator/language';
if (JFolder::exists($path)) {
$languages = JFolder::folders($path);
foreach ($languages as $language) {
if (JFolder::exists(JPATH_ROOT . '/administrator/language/' . $language)) {
if (file_exists($path . '/' . $language . '/' . $language . '.plg_' . $pluginName . '.ini')) {
JFile::copy($path . '/' . $language . '/' . $language . '.plg_' . $pluginName . '.ini', JPATH_ROOT . '/administrator/language/' . $language . '/' . $language . '.plg_' . $pluginName . '.ini');
} elseif (file_exists($path . '/' . $language . '/' . $language . '.plg_' . str_replace('plug_', '', $pluginName) . '.ini')) {
JFile::copy($path . '/' . $language . '/' . $language . '.plg_' . str_replace('plug_', '', $pluginName) . '.ini', JPATH_ROOT . '/administrator/language/' . $language . '/' . $language . '.plg_' . str_replace('plug_', '', $pluginName) . '.ini');
}
}
}
}
$status = true;
}
}
return $status;
}
示例6: postflight
/**
* Method to run after installing the component
*/
function postflight($type, $parent)
{
//Restore the modified language strings by merging to language files
$registry = new JRegistry();
foreach (self::$languageFiles as $languageFile) {
$backupFile = JPATH_ROOT . '/language/en-GB/bak.' . $languageFile;
$currentFile = JPATH_ROOT . '/language/en-GB/' . $languageFile;
if (JFile::exists($currentFile) && JFile::exists($backupFile)) {
$registry->loadFile($currentFile, 'INI');
$currentItems = $registry->toArray();
$registry->loadFile($backupFile, 'INI');
$backupItems = $registry->toArray();
$items = array_merge($currentItems, $backupItems);
$content = "";
foreach ($items as $key => $value) {
$content .= "{$key}=\"{$value}\"\n";
}
JFile::write($currentFile, $content);
}
}
// Restore custom modified css file
if (JFile::exists(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css')) {
JFile::copy(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css', JPATH_ROOT . '/components/com_osmembership/assets/css/custom.css');
JFile::delete(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css');
}
}
示例7: initFile
protected function initFile()
{
$logFilenameBase = str_replace('.php', '', $this->path);
$logFile = $logFilenameBase . '.php';
if (JFile::exists($logFile)) {
if (@filesize($logFile) > 1048756) {
$altLog = $logFilenameBase . '-' . time() . '.php';
JFile::copy($logFile, $altLog);
JFile::delete($logFile);
}
}
// If the file doesn't already exist we need to create it and generate the file header.
if (!is_file($this->path)) {
// Make sure the folder exists in which to create the log file.
JFolder::create(dirname($this->path));
// Build the log file header.
$head = $this->generateFileHeader();
} else {
$head = false;
}
// Open the file for writing (append mode).
if (!($this->file = fopen($this->path, 'a'))) {
throw new RuntimeException('Cannot open file for writing log');
}
if ($head) {
if (!fwrite($this->file, $head)) {
throw new RuntimeException('Cannot fput file for log');
}
}
}
示例8: installPlugin
/**
* Helper task for installing CB plugin later
*
* @throws Exception - if CB not found
*
* @return void
*/
public function installPlugin()
{
JLoader::import("joomla.filesystem.file");
JLoader::import("joomla.filesystem.folder");
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/library/cb/cb.installer.php')) {
global $_CB_framework;
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.class.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/comprofiler.class.php';
require_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/library/cb/cb.installer.php';
$plugin = "plug_cmc";
$cbInstaller = new cbInstallerPlugin();
if ($cbInstaller->install(JPATH_ROOT . '/components/com_comprofiler/plugin/user/' . $plugin . '/')) {
$langPath = JPATH_ROOT . '/components/com_comprofiler/plugin/user/' . $plugin . '/administrator/language';
$cbNames = explode('_', $plugin);
if (JFolder::exists($langPath)) {
$languages = JFolder::folders($langPath);
foreach ($languages as $language) {
if (JFolder::exists(JPATH_ROOT . '/administrator/language/' . $language)) {
JFile::copy($langPath . '/' . $language . '/' . $language . '.plg_' . $cbNames[1] . '.ini', JPATH_ROOT . '/administrator/language/' . $language . '/' . $language . '.plg_' . $cbNames[1] . '.ini');
}
}
}
} else {
throw new Exception("CB plugin installation failed");
}
} else {
throw new Exception("CB Framework not found", 404);
}
$msg = JText::_('COM_CMC_CB_PLUGIN_INSTALLED_SUCCESSFULLY');
$this->setRedirect('index.php?option=com_cmc&view=lists', $msg);
}
示例9: runningcopy
/**
* Performs the copy procedure of each file without of the install pachages
*
* @return void
*
* @since 0.10.1
*/
public function runningcopy()
{
$temp_unpack_path = JFactory::getApplication()->getUserState('com_playjoomupdate.unpackage.name', null);
$options['format'] = '{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}';
$options['text_file'] = 'playjoom_update.php';
JLog::addLogger($options, JLog::INFO, array('Update', 'databasequery', 'jerror'));
// Send the appropriate error code response.
JResponse::clearHeaders();
JResponse::setHeader('Content-Type', 'application/json; charset=utf-8');
JResponse::sendHeaders();
$total = $_GET['total'];
$one_procent = 1 / ($total / 100);
$curr_index = number_format($_GET['total'] * $_GET['status'] / 100, 0, '', '');
$filespath_from_cache = explode('*|*', JFactory::getApplication()->getUserState('com_playjoomupdate.filespaths.array'));
$php_array['status'] = $_GET['status'] + $one_procent;
if (isset($filespath_from_cache[$curr_index])) {
//Copy file
$src = $filespath_from_cache[$curr_index];
$dest = str_replace($temp_unpack_path, JPATH_ROOT, $filespath_from_cache[$curr_index]);
JFile::copy($src, $dest);
}
// Bei 100% ist Schluss ;)
if ($php_array['status'] > 100) {
$php_array['status'] = 100;
}
if ($php_array['status'] != 100 && isset($filespath_from_cache[$curr_index])) {
$php_array['message'] = JText::_('COM_PLAYJOOMUPDATE_INSTALLING_EXTENSIONS_CURRENT_STATUS') . ' ' . ($curr_index + 1) . ' / ' . $total . ' - ' . round($php_array['status'], 1) . '%';
$php_array['message_path'] = JText::_('COM_PLAYJOOMUPDATE_COPY_FILE_TO_PATH_STATUS') . ' ' . $dest;
} else {
$php_array['message'] = JText::_('COM_PLAYJOOMUPDATE_COPY_FILES_DONE');
}
// Output as PHP arrays as JSON Objekt
echo json_encode($php_array);
}
示例10: _InstallCBPlugin
function _InstallCBPlugin($plugintitle, $tabtitle, $pluginname, $folder, $class)
{
$database = JFactory::getDBO();
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$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 \t\t\t`name`='{$plugintitle}',\r\n \t\t\t`element`='{$pluginname}',\r\n \t\t\t`type`='user',\r\n \t\t\t`folder`='{$folder}',\r\n \t\t\t`ordering`=99,\r\n \t\t\t`published`=1,\r\n \t\t\t`iscore`=0\r\n \t\t";
$database->setQuery($query);
$database->query();
$plugid = $database->insertid();
}
$query = "SELECT count(*) FROM #__comprofiler_tabs where pluginid='{$plugid}'";
$database->setQuery($query);
$tabs = $database->loadResult();
if (!$tabs) {
$query = "INSERT INTO #__comprofiler_tabs set\r\n \t\t`title`='{$tabtitle}',\r\n \t\t`ordering`=999,\r\n \t\t`enabled`=1,\r\n \t\t`pluginclass`='{$class}',\r\n \t\t`pluginid`='{$plugid}',\r\n \t\t`fields`=0,\r\n \t\t`displaytype`='tab',\r\n \t\t`position`='cb_tabmain'\r\n\r\n \t";
$database->setQuery($query);
$database->query();
}
$pluginfolder = JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . $folder;
$pluginfile_source = JPATH_ROOT . DS . "components" . DS . APP_EXTENSION . DS . "installer" . DS . "cb_plug" . DS . "{$pluginname}";
if (!JFolder::exists($pluginfolder)) {
JFolder::create($pluginfolder);
}
JFile::copy($pluginfile_source . '.php', $pluginfolder . DS . "{$pluginname}.php");
JFile::copy($pluginfile_source . '.xml', $pluginfolder . DS . "{$pluginname}.xml");
return $plugintitle;
}
示例11: run
/**
* Perform the action.
*
* @param EcrProjectZiper $ziper
*
* @return \EcrProjectAction
*/
public function run(EcrProjectZiper $ziper)
{
$project = EcrProjectHelper::getProject();
$updateserver = new EcrProjectUpdateserver($project);
$fileList = $ziper->getCreatedFiles();
if (0 == count($fileList)) {
return $this->abort('ERROR: No files to transfer', $ziper);
}
$path = ECRPATH_UPDATESERVER . '/' . $project->comName . '/' . $this->releaseState;
$urlPath = ECRPATH_UPDATESERVER_URL . '/' . $project->comName . '/' . $this->releaseState;
$urls = array();
/* @ var EcrProjectZiperCreatedfile $f */
foreach ($fileList as $f) {
$dest = $path . '/' . $f->name;
if (false == JFile::copy($f->path, $dest)) {
return $this->abort(sprintf('ERROR: Can not copy the file %s to %s', $f->path, $dest), $ziper);
}
$ziper->logger->log(sprintf('The file<br />%s<br />has been copied to<br />%s', $f->path, $dest));
$alternate = $f->alternateDownload;
$urls[] = $alternate ?: $urlPath . '/' . $f->name;
}
$release = new EcrProjectUpdateserverRelease();
$release->state = $this->releaseState;
$release->downloads = $urls;
$release->description = 'Bescreibung...';
$updateserver->addRelease($release);
return $this;
}
示例12: upload
/**
* Uploads the given file to a temporary location on the site.
*
* @since 1.0
* @access public
* @param string
* @return string The path to the uploaded item.
*/
public function upload($file, $hash, $userId)
{
// Check if file exists on the server
if (!isset($file['tmp_name']) || empty($file)) {
$this->setError(JText::_('COM_EASYSOCIAL_UPLOADER_FILE_NOT_FOUND'));
return false;
}
// Lets figure out the storage path.
$config = FD::config();
// Test if the folder exists for this upload type.
$path = JPATH_ROOT . '/' . FD::cleanPath($config->get('uploader.storage.container'));
if (!FD::makeFolder($path)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_CREATE_DESTINATION_FOLDER', $path));
return false;
}
// Let's finalize the storage path.
$storage = $path . '/' . $userId;
if (!FD::makeFolder($storage)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_CREATE_DESTINATION_FOLDER', $storage));
return false;
}
// Once the script reaches here, we assume everything is good now.
// Copy the files over.
jimport('joomla.filesystem.file');
$absolutePath = $storage . '/' . $hash;
if (!JFile::copy($file['tmp_name'], $absolutePath)) {
$this->setError(JText::sprintf('COM_EASYSOCIAL_UPLOADER_UNABLE_TO_COPY_TO_DESTINATION_FOLDER', $absolutePath));
return false;
}
return $absolutePath;
}
示例13: installCustomMail
/**
* method to install custom mail scripts
*
* @return void
*/
private function installCustomMail($parent)
{
foreach ($this->mailScripts as $mailScript) {
$source = 'html/emails/' . $mailScript . '.modified.php';
$src = __DIR__ . '/' . $source;
if (!JFile::exists($src)) {
echo '<span style="color:red;"><hr />';
echo 'Customised email file not available: ' . $source . '<br />';
echo 'Check customisation instructions in: plugins/hikashop/html/emails<br />';
echo '</span>';
continue;
}
$target = 'media/com_hikashop/mail/' . $mailScript . '.modified.php';
$dest = JPATH_ROOT . '/' . $target;
if (JFile::exists($dest)) {
if ($this->compareCustomMail($dest, $src)) {
continue;
}
echo '<span style="color:red;"><hr />';
echo 'Modified email file already exists: ' . $target . '<br />';
echo 'Check customisation instructions in: plugins/hikashop/bf_item_delivery_date/html/emails<br />';
echo '</span>';
continue;
}
JFile::copy($src, $dest);
}
}
示例14: display
/**
* Wordbridge entry view display method
* @return void
**/
function display($tpl = null)
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
if (!$item) {
$item = $menu->getItem(JRequest::getInt('Itemid'));
}
$params = $item->params;
$this->assignRef('params', $params);
$postid = JRequest::getInt('p', 0);
$blogInfo = WordbridgeHelper::getBlogByName($params->get('wordbridge_blog_name'));
$this->assignRef('blogTitle', $blogInfo['description']);
$model = $this->getModel();
$entry = $model->getEntry($postid, $blogInfo['uuid']);
$baseUrl = $item->link . '&Itemid=' . $item->id;
$this->assignRef('blogLink', $baseUrl);
// Determine if we'll convert links
$convertLinks = $params->get('wordbridge_convert_links', 'no') == 'yes' ? true : false;
$this->assignRef('convertLinks', $convertLinks);
$this->assignRef('content', $entry['content']);
$this->assignRef('title', $entry['title']);
$this->assignRef('slug', $entry['slug']);
$this->assignRef('categories', $entry['categories']);
$this->assignRef('postid', $entry['postid']);
$this->assignRef('date', $entry['date']);
// Allow JComments to be added to blog entries
$jcomments = false;
$jcommentsPath = JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS;
$jcommentFile = $jcommentsPath . 'jcomments.php';
if ($params->get('wordbridge_show_jcomments') == 'yes' && file_exists($jcommentFile)) {
$jbase = JPATH_SITE . DS . 'components' . DS;
$jPlgSrc = $jbase . 'com_wordbridge' . DS . 'assets' . DS . 'com_wordbridge.plugin.php';
$jPlgDst = $jbase . 'com_jcomments' . DS . 'plugins' . DS . 'com_wordbridge.plugin.php';
// Check to see if the integration is installed
$copyRes = true;
if (!file_exists($jPlgDst) || filemtime($jPlgSrc) > filemtime($jPlgDst)) {
// Copy the wordbridge plugin over to jcomments
$copyRes = JFile::copy($jPlgSrc, $jPlgDst);
}
// Only set up JComments if the wordbridge plugin is
// installed OK
if ($copyRes) {
require_once $jcommentFile;
$jid = $item->id * 10000000 + $entry['postid'];
$jcomments = JComments::showComments($jid, 'com_wordbridge', $entry['title']);
}
}
$this->assignRef('jcomments', $jcomments);
$document = JFactory::getDocument();
// Set the title to place above the blog
$blog_title = $params->get('page_heading');
if (!$blog_title) {
$blog_title = $document->getTitle();
}
$this->assignRef('blog_title', $blog_title);
// Set the page title
$document->setTitle($document->getTitle() . ' - ' . $entry['title']);
parent::display($tpl);
}
示例15: createFolder
/**
* Method is responsible to create a folder in the site.
*
* @access public
* @param null
*/
public function createFolder()
{
$ajax = EasyBlogHelper::getHelper('Ajax');
// This is the relative path to the items that needs to be deleted.
$path = JRequest::getVar('path');
// This let's us know the type of folder we should lookup to
$place = JRequest::getString('place');
// @task: Create the media object.
$media = new EasyBlogMediaManager();
$absolutePath = EasyBlogMediaManager::getAbsolutePath($path, $place);
if (JFolder::exists($absolutePath)) {
return $ajax->fail(JText::_('COM_EASYBLOG_FOLDER_EXISTS'));
}
// @task: Let's create the folder
JFolder::create($absolutePath);
// @task: Let's copy a standard index.html to prevent any directory browsing here.
$source = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'index.html';
$destination = $absolutePath . DIRECTORY_SEPARATOR . 'index.html';
JFile::copy($source, $destination);
// @task: Get the absolute URI to the destination item.
$uri = EasyBlogMediaManager::getAbsoluteURI($path, $place);
// @task: Try to get the relative path of the "path" . Since the last fragment is always the folder that we're trying to create.
$relative = dirname($path);
$obj = $media->getItem($absolutePath, $uri, $relative, false, $place)->toArray();
$ajax->success($obj);
}