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


PHP JArchive::getAdapter方法代码示例

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


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

示例1: doExecute

    /**
     * Entry point for CLI script
     *
     * @return  void
     *
     * @since   3.0
     */
    public function doExecute()
    {
        ini_set("max_execution_time", 300);
        jimport('joomla.filesystem.archive');
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        $config = JFactory::getConfig();
        $username = $config->get('user');
        $password = $config->get('password');
        $database = $config->get('db');
        echo 'Exporting database...
';
        exec("mysqldump --user={$username} --password={$password} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$database} > " . JPATH_SITE . "/database-backup.sql");
        $zipFilesArray = array();
        $dirs = JFolder::folders(JPATH_SITE, '.', true, true);
        array_push($dirs, JPATH_SITE);
        echo 'Collecting files...
';
        foreach ($dirs as $dir) {
            $files = JFolder::files($dir, '.', false, true);
            foreach ($files as $file) {
                $data = JFile::read($file);
                $zipFilesArray[] = array('name' => str_replace(JPATH_SITE . '/', '', $file), 'data' => $data);
            }
        }
        $zip = JArchive::getAdapter('zip');
        echo 'Creating zip...
';
        $archive = JPATH_SITE . '/backups/' . date('Ymd') . '-backup.zip';
        $zip->create($archive, $zipFilesArray);
        echo 'Backup created ' . $archive . '
';
    }
开发者ID:joomlla,项目名称:jacs,代码行数:40,代码来源:BackupSite.php

示例2: readContentElementFile

 /**
  * Read content files
  *
  * @return void
  *
  * @throws Exception
  */
 public function readContentElementFile()
 {
     NenoLog::log('Method readContentElementFile of NenoControllerGroupsElements called', 3);
     jimport('joomla.filesystem.file');
     NenoLog::log('Trying to move content element files', 3);
     $input = JFactory::getApplication()->input;
     $fileData = $input->files->get('content_element');
     $destFile = JFactory::getConfig()->get('tmp_path') . '/' . $fileData['name'];
     $extractPath = JFactory::getConfig()->get('tmp_path') . '/' . JFile::stripExt($fileData['name']);
     // If the file has been moved successfully, let's work with it.
     if (JFile::move($fileData['tmp_name'], $destFile) === true) {
         NenoLog::log('Content element files moved successfully', 2);
         // If the file is a zip file, let's extract it
         if ($fileData['type'] == 'application/zip') {
             NenoLog::log('Extracting zip content element files', 3);
             $adapter = JArchive::getAdapter('zip');
             $adapter->extract($destFile, $extractPath);
             $contentElementFiles = JFolder::files($extractPath);
         } else {
             $contentElementFiles = array($destFile);
         }
         // Add to each content file the path of the extraction location.
         NenoHelper::concatenateStringToStringArray($extractPath . '/', $contentElementFiles);
         NenoLog::log('Parsing element files for readContentElementFile', 3);
         // Parse element file(s)
         NenoHelperBackend::parseContentElementFile(JFile::stripExt($fileData['name']), $contentElementFiles);
         NenoLog::log('Cleaning temporal folder for readContentElementFile', 3);
         // Clean temporal folder
         NenoHelperBackend::cleanFolder(JFactory::getConfig()->get('tmp_path'));
     }
     NenoLog::log('Redirecting to groupselements view', 3);
     $this->setRedirect('index.php?option=com_neno&view=groupselements')->redirect();
 }
开发者ID:andresmaeso,项目名称:neno,代码行数:40,代码来源:groupselements.php

示例3: packageUnzip

 function packageUnzip($file, $target)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $extract1 =& JArchive::getAdapter('zip');
     $result = @$extract1->extract($file, $target);
     if ($result != true) {
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $extract2 = new PclZip($file);
         $result = @$extract2->extract(PCLZIP_OPT_PATH, $target);
     }
     unset($extract1, $extract2);
     return $result;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:26,代码来源:joomla15.php

示例4: _extract

 function _extract($package, $target)
 {
     // First extract files
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if (!is_dir($target)) {
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         $extract = new PclZip($package);
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $result = $extract->extract(PCLZIP_OPT_PATH, $target);
     }
     return $result;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:26,代码来源:admin_geomaps_install_controller.php

示例5: download

 public function download()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $type = $this->input->get->getCmd('type');
     $model = $this->getModel();
     try {
         switch ($type) {
             case 'locations':
                 $output = $model->getLocations();
                 $fileName = 'locations.xml';
                 break;
             case 'countries':
                 $output = $model->getCountries();
                 $fileName = 'countries.xml';
                 break;
             case 'states':
                 $output = $model->getStates();
                 $fileName = 'states.xml';
                 break;
             default:
                 // Error
                 $output = '';
                 $fileName = 'error.xml';
                 break;
         }
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.archive');
     $tmpFolder = JPath::clean($app->get('tmp_path'));
     $date = new JDate();
     $date = $date->format('d_m_Y_H_i_s');
     $archiveName = JFile::stripExt(basename($fileName)) . '_' . $date;
     $archiveFile = $archiveName . '.zip';
     $destination = $tmpFolder . DIRECTORY_SEPARATOR . $archiveFile;
     // compression type
     $zipAdapter = JArchive::getAdapter('zip');
     $filesToZip[] = array('name' => $fileName, 'data' => $output);
     $zipAdapter->create($destination, $filesToZip, array());
     $filesize = filesize($destination);
     JFactory::getApplication()->setHeader('Content-Type', 'application/octet-stream', true);
     JFactory::getApplication()->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
     JFactory::getApplication()->setHeader('Content-Transfer-Encoding', 'binary', true);
     JFactory::getApplication()->setHeader('Pragma', 'no-cache', true);
     JFactory::getApplication()->setHeader('Expires', '0', true);
     JFactory::getApplication()->setHeader('Content-Disposition', 'attachment; filename=' . $archiveFile, true);
     JFactory::getApplication()->setHeader('Content-Length', $filesize, true);
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('application/octet-stream');
     $app->sendHeaders();
     echo file_get_contents($destination);
     $app->close();
 }
开发者ID:ITPrism,项目名称:SocialCommunityDistribution,代码行数:58,代码来源:export.raw.php

示例6: process

 function process()
 {
     $this->installDir = JPATH_SITE . '/media/' . uniqid('rsinstall_');
     $adapter = JArchive::getAdapter('zip');
     if (!$adapter->extract($this->archive, $this->installDir)) {
         return false;
     }
     return true;
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:9,代码来源:restore.php

示例7: extract

 /**
  * Extract ZIP-file
  *
  * @param	string	$path	The ZIP-file
  * @param	string	$dest	The destination
  *
  * @return	boolean		True on success, false otherwise
  */
 public static function extract($path, $dest = '')
 {
     if (!JFile::exists($path) || JFile::getExt($path) != "zip") {
         return false;
     }
     if ($dest = '') {
         $dest = JFile::stripExt($files);
     }
     return JArchive::getAdapter('zip')->extract($path, $dest);
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:18,代码来源:archive.php

示例8: extractFile

 public function extractFile($file, $destFolder)
 {
     $filePath = "";
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     foreach ($dir as $fileinfo) {
         $fileExtension = JFile::getExt($fileinfo->getFilename());
         if (!$fileinfo->isDot() and strcmp('xml', $fileExtension) === 0) {
             $filePath = JPath::clean($destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename()));
             break;
         }
     }
     return $filePath;
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:16,代码来源:import.php

示例9: extractFile

 public function extractFile($file, $destFolder)
 {
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     $filePath = '';
     foreach ($dir as $fileinfo) {
         $currentFileName = JString::strtolower($fileinfo->getFilename());
         if (!$fileinfo->isDot() and !in_array($currentFileName, $this->ignoredFiles, true)) {
             $filePath = JPath::clean($destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename()));
             break;
         }
     }
     return $filePath;
 }
开发者ID:sis-direct,项目名称:CrowdFunding,代码行数:16,代码来源:import.php

示例10: extractFile

 public function extractFile($file, $destFolder)
 {
     // extract type
     $zipAdapter = JArchive::getAdapter('zip');
     $zipAdapter->extract($file, $destFolder);
     $dir = new DirectoryIterator($destFolder);
     $fileName = JFile::stripExt(basename($file));
     foreach ($dir as $fileinfo) {
         $currentFileName = JFile::stripExt($fileinfo->getFilename());
         if (!$fileinfo->isDot() and strcmp($fileName, $currentFileName) == 0) {
             $filePath = $destFolder . DIRECTORY_SEPARATOR . JFile::makeSafe($fileinfo->getFilename());
             break;
         }
     }
     return $filePath;
 }
开发者ID:phpsource,项目名称:CrowdFunding,代码行数:16,代码来源:import.php

示例11: install

 /**
  * Install component
  *
  * @param	string	$file		Path to extension archive
  * @param	boolean	$update		True if extension should be updated, false if it is new
  */
 public static function install($file, $update = false)
 {
     $installer = JInstaller::getInstance();
     $tmp = JDeveloperINSTALL . "/" . JFile::stripExt(JFile::getName($file));
     JArchive::getAdapter('zip')->extract($file, $tmp);
     if ($update) {
         if (!$installer->update($tmp)) {
             return false;
         }
     } else {
         if (!$installer->install($tmp)) {
             return false;
         }
     }
     self::cleanInstallDir();
     return true;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:23,代码来源:install.php

示例12: export

 /**
  * Method to export features tables as CSV
  */
 public function export()
 {
     $features = JRequest::getVar('cid', array(), 'post', 'array');
     if (!empty($features)) {
         $config = JFactory::getConfig();
         $exportPath = $config->get('tmp_path') . DS . 'jea_export';
         if (JFolder::create($exportPath) === false) {
             $msg = JText::_('JLIB_FILESYSTEM_ERROR_FOLDER_CREATE') . ' : ' . $exportPath;
             $this->setRedirect('index.php?option=com_jea&view=features', $msg, 'warning');
         } else {
             $xmlPath = JPATH_COMPONENT . '/models/forms/features/';
             $xmlFiles = JFolder::files($xmlPath);
             $model = $this->getModel();
             $files = array();
             foreach ($xmlFiles as $filename) {
                 if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename, $matches)) {
                     $feature = $matches[1];
                     if (in_array($feature, $features)) {
                         $form = simplexml_load_file($xmlPath . DS . $filename);
                         $table = (string) $form['table'];
                         $files[] = array('data' => $model->getCSVData($table), 'name' => $table . '.csv');
                     }
                 }
             }
             $zipFile = $exportPath . DS . 'jea_export_' . uniqid() . '.zip';
             $zip = JArchive::getAdapter('zip');
             $zip->create($zipFile, $files);
             JResponse::setHeader('Content-Type', 'application/zip');
             JResponse::setHeader('Content-Disposition', 'attachment; filename="jea_features.zip"');
             JResponse::setHeader('Content-Transfer-Encoding', 'binary');
             JResponse::setBody(readfile($zipFile));
             echo JResponse::toString();
             // clean tmp files
             JFile::delete($zipFile);
             JFolder::delete($exportPath);
             Jexit();
         }
     } else {
         $msg = JText::_('JERROR_NO_ITEMS_SELECTED');
         $this->setRedirect('index.php?option=com_jea&view=features', $msg);
     }
 }
开发者ID:Cloudum,项目名称:com_jea,代码行数:45,代码来源:features.php

示例13: com_install

function com_install()
{
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    $path_root = dirname(dirname(dirname(dirname(__FILE__))));
    $path_app_admin = $path_root . DS . 'administrator' . DS . 'components' . DS . 'com_s2framework' . DS;
    $package = $path_app_admin . 's2framework.s2';
    $target = $path_root . DS . 'components' . DS . 'com_s2framework' . DS;
    jimport('joomla.filesystem.file');
    jimport('joomla.filesystem.folder');
    jimport('joomla.filesystem.archive');
    jimport('joomla.filesystem.path');
    $adapter =& JArchive::getAdapter('zip');
    $result = $adapter->extract($package, $target);
    if ($result) {
        $version = new JVersion();
        if ($version->RELEASE == 1.6) {
            ?>
            <script type="text/javascript">                        
            window.addEvent('domready', function() { 
                var req = new Request({ 
                  method: 'get', 
                  url: '<?php 
            echo JURI::base();
            ?>
index.php?option=com_s2framework&tmpl=component&format=raw&install=1', 
                }).send();
            });
            </script>
            <?php 
        }
        echo "The S2 Framework has been successfully installed.";
    } else {
        echo "There was a problem installing the framework. You need to extract and rename the s2framework.s2 file inside the component zip you just tried to install to s2framework.zip. Then extract it locally and upload via ftp to the /components/com_s2framework/ directory.";
    }
}
开发者ID:bizanto,项目名称:Hooked,代码行数:37,代码来源:install.s2framework.php

示例14: upload

 function upload()
 {
     $app = JFactory::getApplication();
     // Check that the zlib is available
     if (!extension_loaded('zlib')) {
         $app->redirect("index.php?option=com_adsmanager&c=plugins", "The installer can't continue before zlib is installed", 'message');
     }
     $userfile = JRequest::getVar('userfile', null, "FILES");
     //$_FILES
     $name = substr($userfile['name'], 0, strpos($userfile['name'], '.'));
     if (eregi('.zip$', $userfile['name'])) {
         // Extract functions
         jimport('joomla.filesystem.archive');
         $zip = JArchive::getAdapter('zip');
         $ret = $zip->extract($userfile['tmp_name'], JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name);
         if ($ret != true) {
             JError::raiseError(500, 'Extract Error');
             return false;
         }
     } else {
         JError::raiseError(500, 'Extract Error');
         return false;
     }
     if (file_exists(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name . "/plug.php")) {
         require_once JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name . "/plug.php";
         foreach ($plugins as $plug) {
             $plug->install();
         }
     } else {
         if (is_file(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name)) {
             JFolder::delete(JPATH_ROOT . "/images/com_adsmanager/plugins/" . $name);
         }
         JError::raiseError(500, 'This is not an adsmanager plugin');
         return false;
     }
     $app->redirect("index.php?option=com_adsmanager&c=plugins", JText::_('ADSMANAGER_PLUGIN_SAVED'), 'message');
 }
开发者ID:politik86,项目名称:test2,代码行数:37,代码来源:plugins.php

示例15: _installPlugin

 /**
  * Installs the JReviews Content Plugin
  * 
  */
 function _installPlugin()
 {
     $package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
     if ($this->cmsVersion == CMS_JOOMLA16) {
         @mkdir(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews');
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews';
     } else {
         $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
     }
     $target_file = $target . DS . 'jreviews.php';
     $first_pass = false;
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if (!file_exists($target_file)) {
         $plugin_install = false;
     } else {
         $plugin_install = true;
         if ($this->cmsVersion == CMS_JOOMLA16) {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        extension_id, enabled\n                    FROM \n                        #__extensions \n                    WHERE \n                        type = 'plugin' AND element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadAssoc();
             if (empty($result) || !$result['extension_id']) {
                 $query = "\n                        INSERT INTO \n                            #__extensions \n                                (`name`, `type`,`element`, `folder`, `access`, `ordering`, `enabled`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                            VALUES \n                                ('JReviews Plugin', 'plugin', 'jreviews', 'content', 1, 0, 1, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             } elseif (!empty($result) && $result['extension_id'] && !$result['enabled']) {
                 $query = "UPDATE #__extensions SET enabled = 1 WHERE extension_id = " . $result['extension_id'];
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             }
         } else {
             // Add/create plugin db entry
             $query = "\n                    SELECT \n                        id, published \n                    FROM \n                        #__plugins \n                    WHERE \n                        element = 'jreviews' AND folder = 'content'\n                ";
             $this->_db->setQuery($query);
             $result = $this->_db->loadAssoc();
             if (empty($result) || !$result['id']) {
                 $query = "\n                        INSERT INTO #__plugins \n                            (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`)\n                        VALUES \n                            ('JReviews Plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');\n                    ";
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             } elseif (!empty($result) && $result['id'] && !$result['published']) {
                 $query = "UPDATE #__plugins SET published = 1 WHERE id = " . $result['id'];
                 $this->_db->setQuery($query);
                 $plugin_install = $this->_db->query();
             }
         }
     }
     return $plugin_install;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:57,代码来源:install_controller.php


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