当前位置: 首页>>代码示例>>PHP>>正文


PHP JArchive::extract方法代码示例

本文整理汇总了PHP中JArchive::extract方法的典型用法代码示例。如果您正苦于以下问题:PHP JArchive::extract方法的具体用法?PHP JArchive::extract怎么用?PHP JArchive::extract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JArchive的用法示例。


在下文中一共展示了JArchive::extract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getbackup

 function getbackup()
 {
     global $mainframe;
     if (!JFile::exists(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php')) {
         JError::raiseWarning(304, 'Backup file doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     $version = JRequest::getCmd('version');
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php';
     if (!JFile::exists($urlbackup)) {
         JError::raiseWarning(400, 'File backup doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     // do the unpacking of the archive
     $extractdir = JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . uniqid($version . '_');
     $archivename = $urlbackup;
     JFolder::create($extractdir);
     $result = JArchive::extract($archivename, $extractdir);
     // Get Instance
     $autoupdate = new AutoupdateHelper($extractdir . DS . 'update.xml', false, true, false, $extractdir);
     $autoupdate->upgradeFile();
     $autoupdate->cleanFileUpdate();
     $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version', $autoupdate->getReport());
 }
开发者ID:laiello,项目名称:yrm,代码行数:26,代码来源:upgrade.php

示例2: 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>';
 }
开发者ID:neoandrew1000,项目名称:crao_journal,代码行数:39,代码来源:install_ckeditor.php

示例3: installApplicationFromUserfile

 /**
  * Installs an Application from a user upload.
  *
  * @param array $userfile The userfile to install from
  * @return int 2 = update, 1 = install
  *
  * @throws InstallHelperException
  * @since 2.0
  */
 public function installApplicationFromUserfile($userfile)
 {
     // Make sure that file uploads are enabled in php
     if (!(bool) ini_get('file_uploads')) {
         throw new InstallHelperException('Fileuploads are not enabled in php.');
     }
     // If there is no uploaded file, we have a problem...
     if (!is_array($userfile)) {
         throw new InstallHelperException('No file selected.');
     }
     // Check if there was a problem uploading the file.
     if ($userfile['error'] || $userfile['size'] < 1) {
         throw new InstallHelperException('Upload error occured.');
     }
     // Temporary folder to extract the archive into
     $tmp_directory = $this->app->path->path('tmp:') . '/';
     $archivename = $tmp_directory . $userfile['name'];
     if (!JFile::upload($userfile['tmp_name'], $archivename)) {
         throw new InstallHelperException("Could not move uploaded file to ({$archivename})");
     }
     // Clean the paths to use for archive extraction
     $extractdir = $tmp_directory . uniqid('install_');
     jimport('joomla.filesystem.archive');
     // do the unpacking of the archive
     if (!JArchive::extract($archivename, $extractdir)) {
         throw new InstallHelperException("Could not extract zip file to ({$tmp_directory})");
     }
     return $this->installApplicationFromFolder($extractdir);
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:38,代码来源:install.php

示例4: civicrm_setup

function civicrm_setup()
{
    global $adminPath, $compileDir;
    $adminPath = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm';
    $jConfig = JFactory::getConfig();
    set_time_limit(4000);
    // Path to the archive
    $archivename = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.zip';
    // a bit of support for the non-alternaive joomla install
    if (file_exists($archivename)) {
        // ensure that the site has native zip, else abort
        if (!function_exists('zip_open') || !function_exists('zip_read')) {
            echo "Your PHP version is missing  zip functionality. Please ask your system administrator / hosting provider to recompile PHP with zip support.<p>";
            echo "If this is a new install, you will need to uninstall CiviCRM from the Joomla Extension Manager.<p>";
            exit;
        }
        $extractdir = $adminPath;
        JArchive::extract($archivename, $extractdir);
    }
    $scratchDir = JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'civicrm';
    if (!is_dir($scratchDir)) {
        JFolder::create($scratchDir, 0777);
    }
    $compileDir = $scratchDir . DIRECTORY_SEPARATOR . 'templates_c';
    if (!is_dir($compileDir)) {
        JFolder::create($compileDir, 0777);
    }
    $db = JFactory::getDBO();
    $db->setQuery(' SELECT count( * )
FROM information_schema.tables
WHERE table_name LIKE "civicrm_domain"
AND table_schema = "' . $jConfig->getValue('config.db') . '" ');
    global $civicrmUpgrade;
    $civicrmUpgrade = $db->loadResult() == 0 ? FALSE : TRUE;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:configure.php

示例5: 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();
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:60,代码来源:rules.php

示例6: upload

 /**
  * Support Zip files for image galleries 
  * @see TiendaFile::upload()
  */
 function upload()
 {
     if ($result = parent::upload()) {
         // Check if it's a supported archive
         $allowed_archives = array('zip', 'tar', 'tgz', 'gz', 'gzip', 'tbz2', 'bz2', 'bzip2');
         if (in_array(strtolower($this->getExtension()), $allowed_archives)) {
             $dir = $this->getDirectory();
             jimport('joomla.filesystem.archive');
             JArchive::extract($this->full_path, $dir);
             JFile::delete($this->full_path);
             $this->is_archive = true;
             $files = JFolder::files($dir);
             // Thumbnails support
             if (count($files)) {
                 // Name correction
                 foreach ($files as &$file) {
                     $file = new TiendaImage($dir . '/' . $file);
                 }
                 $this->archive_files = $files;
                 $this->physicalname = $files[0]->getPhysicalname();
             }
         }
     }
     return $result;
 }
开发者ID:annggeel,项目名称:tienda,代码行数:29,代码来源:image.php

示例7: extract

 public function extract()
 {
     $session = JFactory::getSession();
     $target = $session->get('target', '', 'liveupdate');
     $tempdir = $session->get('tempdir', '', 'liveupdate');
     jimport('joomla.filesystem.archive');
     return JArchive::extract($target, $tempdir);
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:8,代码来源:model.php

示例8: install

 function install()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.archive');
     $tmp = JPATH_ROOT . '/tmp/kinstall/';
     $dest = KPATH_SITE . '/template/';
     $file = JRequest::getVar('install_package', NULL, 'FILES', 'array');
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     if (!$file || !is_uploaded_file($file['tmp_name'])) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_MISSING', $file['name']), 'notice');
     } else {
         $success = JFile::upload($file['tmp_name'], $tmp . $file['name']);
         $success = JArchive::extract($tmp . $file['name'], $tmp);
         if (!$success) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_FAILED', $file['name']), 'notice');
         }
         // Delete the tmp install directory
         if (JFolder::exists($tmp)) {
             $templates = KunenaTemplateHelper::parseXmlFiles($tmp);
             if (!empty($templates)) {
                 foreach ($templates as $template) {
                     // Never overwrite default template
                     if ($template->directory == 'default') {
                         continue;
                     }
                     if (is_dir($dest . $template->directory)) {
                         if (is_file($dest . $template->directory . '/params.ini')) {
                             if (is_file($tmp . $template->directory . '/params.ini')) {
                                 JFile::delete($tmp . $template->directory . '/params.ini');
                             }
                             JFile::move($dest . $template->directory . '/params.ini', $tmp . $template->directory . '/params.ini');
                         }
                         JFolder::delete($dest . $template->directory);
                     }
                     $error = JFolder::move($tmp . $template->directory, $dest . $template->directory);
                     if ($error !== true) {
                         $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ': ' . $error, 'notice');
                     }
                 }
                 $retval = JFolder::delete($tmp);
                 $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_INSTALL_EXTRACT_SUCCESS', $file['name']));
             } else {
                 JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_MISSING_FILE'));
                 $retval = false;
             }
         } else {
             JError::raiseWarning(100, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE') . ' ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_UNINSTALL') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_DIR_NOT_EXIST'));
             $retval = false;
         }
     }
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:56,代码来源:templates.php

示例9: extract

 public function extract($archive)
 {
     $destination = JPath::clean(dirname($archive) . '/' . uniqid('social_install_'));
     $archive = JPath::clean($archive);
     jimport('joomla.filesystem.archive');
     if (JArchive::extract($archive, $destination)) {
         return $destination;
     }
     return false;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:10,代码来源:joomla.php

示例10: _install

 function _install($file)
 {
     $AG_resourceType = JRequest::getVar('AG_resourceType');
     // Current resource type
     $config = JFactory::getConfig();
     $tmp_dest = $config->get('tmp_path');
     $resourceType = substr($AG_resourceType, 0, strlen($AG_resourceType) - 1);
     $file_type = "zip";
     if (isset($file) && !empty($file['name'])) {
         //Clean up filename to get rid of strange characters like spaces etc
         $filename = JFile::makeSafe($file['name']);
         $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
         $src = $file['tmp_name'];
         $dest = $tmp_dest . DIRECTORY_SEPARATOR . $filename;
         //First check if the file has the right extension
         if ($ext == $file_type) {
             if (JFile::upload($src, $dest)) {
                 if (JArchive::extract($tmp_dest . DIRECTORY_SEPARATOR . $filename, $tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType)) {
                     JFile::delete($tmp_dest . DIRECTORY_SEPARATOR . $filename);
                 }
                 // TEMPLATE DETAILS PARSING
                 if (JFIle::exists($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml')) {
                     $ag_resourceManager_xml =& JFactory::getXML($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename) . DIRECTORY_SEPARATOR . 'details.xml');
                     if (isset($ag_resourceManager_xml->type)) {
                         $ag_resourceManager_type = $ag_resourceManager_xml->type;
                     } else {
                         JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                         return;
                     }
                 } else {
                     JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                     JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                     return;
                 }
                 if ($ag_resourceManager_type && $ag_resourceManager_type == $resourceType) {
                     $result = JFolder::move($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename), JPATH_SITE . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . 'admirorgallery' . DIRECTORY_SEPARATOR . $AG_resourceType . DIRECTORY_SEPARATOR . JFile::stripExt($filename));
                     if ($result) {
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_INSTALLED') . "&nbsp;" . $filename, 'message');
                     } else {
                         JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_MOVED_ITEM') . "&nbsp;" . $result, 'message');
                     }
                 } else {
                     JFolder::delete($tmp_dest . DIRECTORY_SEPARATOR . $AG_resourceType);
                     JFactory::getApplication()->enqueueMessage(JText::_('AG_ZIP_PACKAGE_IS_NOT_VALID_RESOURCE_TYPE') . "&nbsp;" . $filename, 'error');
                 }
             } else {
                 JFactory::getApplication()->enqueueMessage(JText::_('AG_CANNOT_UPLOAD_FILE_TO_TEMP_FOLDER_PLEASE_CHECK_PERMISSIONS'), 'error');
             }
         } else {
             JFactory::getApplication()->enqueueMessage(JText::_('AG_ONLY_ZIP_ARCHIVES_CAN_BE_INSTALLED'), 'error');
         }
     }
 }
开发者ID:elhui2,项目名称:admirorgallery,代码行数:54,代码来源:resourcemanager.php

示例11: installLanguage

 function installLanguage($parent, $tag, $name)
 {
     $exists = false;
     $success = true;
     $source = $parent->getParent()->getPath('source') . '/language';
     $destinations = array('site' => JPATH_SITE . '/components/com_kunena', 'admin' => JPATH_ADMINISTRATOR . '/components/com_kunena');
     $version = Kunena::version();
     $file = "com_kunena.en-GB.site_v{$version}";
     if (file_exists("{$source}/{$file}.zip")) {
         $ext = "zip";
     } elseif (file_exists("{$source}/{$file}.tar")) {
         $ext = "tar";
     } elseif (file_exists("{$source}/{$file}.tar.gz")) {
         $ext = "tar.gz";
     } elseif (file_exists("{$source}/{$file}.tar.bz2")) {
         $ext = "tar.bz2";
     }
     foreach ($destinations as $key => $dest) {
         if ($success != true) {
             continue;
         }
         // If we are installing Kunena from archive, we need to unzip language file
         $file = "{$source}/com_kunena.{$tag}.{$key}_v{$version}.{$ext}";
         $installdir = "{$dest}/language/{$tag}";
         if (file_exists($file)) {
             if (!JFolder::exists($installdir)) {
                 $success = JFolder::create($installdir);
             }
             if ($success) {
                 $success = JArchive::extract($file, $installdir);
             }
         }
         // Install language from dest/language/xx-XX
         if ($success == true && is_dir($installdir)) {
             $exists = true;
             // Older versions installed language files into main folders
             // Those files need to be removed to bring language up to date!
             jimport('joomla.filesystem.folder');
             $files = JFolder::files($installdir, '\\.ini$');
             foreach ($files as $filename) {
                 if (file_exists(JPATH_SITE . "/language/{$tag}/{$filename}")) {
                     JFile::delete(JPATH_SITE . "/language/{$tag}/{$filename}");
                 }
                 if (file_exists(JPATH_ADMINISTRATOR . "/language/{$tag}/{$filename}")) {
                     JFile::delete(JPATH_ADMINISTRATOR . "/language/{$tag}/{$filename}");
                 }
             }
         }
     }
     if ($exists && $name) {
         return sprintf('Installing %s - %s ... ', $tag, $name) . ($success ? sprintf('%s DONE %s', '<span style="color:darkgreen">', '</span>') : sprintf('%s FAILED %s', '<span style="color:darkred">', '</span>')) . '<br />';
     }
 }
开发者ID:redigy,项目名称:Kunena-1.6,代码行数:53,代码来源:install.script.php

示例12: testExtractTar

 /**
  * Tests extracting TAR.
  *
  * @group	JArchive
  * @covers	JArchive::extract
  * @return void
  */
 public function testExtractTar()
 {
     if (!is_dir(self::$outputPath)) {
         $this->markTestSkipped("Couldn't create folder.");
         return;
     }
     if (!JArchiveTar::isSupported()) {
         $this->markTestSkipped('Tar files can not be extracted.');
         return;
     }
     JArchive::extract(__DIR__ . '/archive/logo.tar', self::$outputPath);
     $this->assertTrue(is_file(self::$outputPath . '/logo-tar.png'));
     if (is_file(self::$outputPath . '/logo-tar.png')) {
         unlink(self::$outputPath . '/logo-tar.png');
     }
 }
开发者ID:raquelsa,项目名称:Joomla,代码行数:23,代码来源:JArchiveTest.php

示例13: unZip

 /**
  * Uncompress zip file using pclzip library
  *
  * @param $zipFile  string path to zip file
  * @param $extractPath  string path to location which will be extract to
  *
  * @return  boolean true if success, false if failure
  */
 public static function unZip($zipFile, $extractPath)
 {
     jimport('joomla.filesystem.archive');
     $result = JArchive::extract($zipFile, $extractPath);
     if ($result === false) {
         return false;
     }
     return true;
     /*$pcl = new PclZip($zipFile);
     	 if(empty($pcl)) {
     		return false;
     		}
     		$retVal = $pcl->extract(PCLZIP_OPT_PATH, $extractPath);
     		$pcl->privCloseFd();
     		return $retVal;*/
 }
开发者ID:ForAEdesWeb,项目名称:AEW10,代码行数:24,代码来源:ArchiveHelper.php

示例14: execute

 /**
  * Perform installation of SQL queries
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     // Get the temporary path from the server.
     $tmpPath = $this->input->get('path', '', 'default');
     // There should be a queries.zip archive in the archive.
     $tmpQueriesPath = $tmpPath . '/queries.zip';
     // Extract the queries
     $path = $tmpPath . '/queries';
     // If on development mode, skip this
     if ($this->isDevelopment()) {
         return $this->output($this->getResultObj('COM_EASYBLOG_INSTALLATION_DEVELOPER_MODE', true));
     }
     // Check if this folder exists.
     if (JFolder::exists($path)) {
         JFolder::delete($path);
     }
     // Extract the archive now
     $state = JArchive::extract($tmpQueriesPath, $path);
     if (!$state) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_UNABLE_EXTRACT_QUERIES', false);
         return $this->output();
     }
     // Get the list of files in the folder.
     $queryFiles = JFolder::files($path, '.', true, true);
     // When there are no queries file, we should just display a proper warning instead of exit
     if (!$queryFiles) {
         $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_EMPTY_QUERIES_FOLDER', false);
         return $this->output();
     }
     $db = JFactory::getDBO();
     $total = 0;
     foreach ($queryFiles as $file) {
         // Get the contents of the file
         $contents = JFile::read($file);
         $queries = JInstallerHelper::splitSql($contents);
         foreach ($queries as $query) {
             $query = trim($query);
             if (!empty($query)) {
                 $db->setQuery($query);
                 $state = $db->execute();
             }
         }
         $total += 1;
     }
     $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_SQL_EXECUTED_SUCCESS', $total), true);
     return $this->output();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:55,代码来源:install.sql.php

示例15: _actionDisplay

 /**
  * Display the view
  *
  * @return void
  */
 public function _actionDisplay(KCommandContext $context)
 {
     if (!JFolder::exists(JPATH_COMPONENT_ADMINISTRATOR . '/packages/')) {
         return;
     }
     $model = $this->getModel();
     $data = array();
     if (KRequest::has('get.folder', 'cmd')) {
         $package = JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . KRequest::get('get.folder', 'cmd') . '/';
         $installer = JInstaller::getInstance();
         $installer->install($package);
         $data['html'] = $installer->get('extension.message');
         JFolder::delete($package);
     } elseif (KRequest::has('get.file', 'filename')) {
         $package = JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . KRequest::get('get.file', 'filename');
         $data['package'] = JFile::stripExt(basename($package));
         JArchive::extract($package, JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . $data['package']);
         JFile::delete($package);
         $files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . $data['package'], '\\.xml$', 1, true);
         $xml = is_array($files) ? end($files) : $files;
         $xml = simplexml_load_file($xml);
         $attribs = $xml->attributes();
         $data['package_name'] = (string) $xml->name . ': ' . ucfirst($attribs['type']);
         $data['package_version'] = (string) '<strong>' . JText::_('OK') . '</strong> - ' . $xml->version . @$xml->version['status'];
         ob_start();
         echo KFactory::get('admin::com.extensions.view.packages.html')->set('i', KRequest::get('get.i', 'int', 0))->set('package', $xml->name . ' ' . $xml->version . @$xml->version['status'])->setLayout('installing')->display();
         $data['html'] = ob_get_clean();
     } else {
         ob_start();
         echo KFactory::get('admin::com.extensions.view.packages.html')->setLayout('default')->display();
         $data['html'] = ob_get_clean();
         $packages = $model->getList();
         sort($packages);
         foreach ($packages as $i => $package) {
             $data['packages'][] = $package;
             ob_start();
             echo KFactory::get('admin::com.extensions.view.packages.html')->set('i', ++$i)->set('package', $package)->setLayout('unpacking')->display();
             $data['layouts'][] = ob_get_clean();
         }
         if ($model->getTotal() < 1) {
             $data['html'] = null;
         }
     }
     return json_encode($data);
 }
开发者ID:ravenlife,项目名称:Ninja-Framework,代码行数:50,代码来源:package.php


注:本文中的JArchive::extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。