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


PHP PharData::hasMetadata方法代码示例

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


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

示例1: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $dialog = $this->getHelperSet()->get('dialog');
     $_configuration = $this->getHelper('configuration')->getConfiguration();
     $file = $input->getArgument('file');
     $connection = $this->getHelper('configuration')->getConnection();
     if (is_file($file) && is_readable($file)) {
         $phar = new \PharData($file);
         if ($phar->hasMetadata()) {
             $langInfo = $phar->getMetadata();
             $connection = $this->getHelper('configuration')->getConnection();
             if ($connection) {
                 $q = mysql_query("SELECT * FROM language WHERE dokeos_folder = '{$langInfo['dokeos_folder']}' ");
                 $langInfoFromDB = mysql_fetch_array($q, MYSQL_ASSOC);
                 $langFolderPath = $_configuration['root_sys'] . 'main/lang/' . $langInfoFromDB['dokeos_folder'];
                 if ($langInfoFromDB && $langFolderPath) {
                     //Overwrite lang files
                     if (!$dialog->askConfirmation($output, '<question>The ' . $langInfo['original_name'] . ' language already exists in Chamilo. Did you want to overwrite the contents? (y/N)</question>', false)) {
                         return;
                     }
                     if (is_writable($langFolderPath)) {
                         $output->writeln("Trying to save files here: {$langFolderPath}");
                         $phar->extractTo($langFolderPath, null, true);
                         // extract all files
                         $output->writeln("Files were copied.");
                     } else {
                         $output->writeln("<error>Make sure that this folder {$langFolderPath} has writable permissions or execute the script with sudo </error>");
                     }
                 } else {
                     //Check if parent_id exists
                     $parentId = '';
                     if (!empty($langInfo['parent_id'])) {
                         $sql = "select selected_value from settings_current where variable = 'allow_use_sub_language'";
                         $result = mysql_query($sql);
                         $subLanguageSetting = mysql_fetch_array($result, MYSQL_ASSOC);
                         $subLanguageSetting = $subLanguageSetting['selected_value'];
                         if ($subLanguageSetting == 'true') {
                             $q = mysql_query("SELECT * FROM language WHERE id = '{$langInfo['parent_id']}' ");
                             $parentLangInfoFromDB = mysql_fetch_array($q, MYSQL_ASSOC);
                             if ($parentLangInfoFromDB) {
                                 $output->writeln("Setting parent language: " . $parentLangInfoFromDB['original_name']);
                                 $parentId = $langInfo['parent_id'];
                             } else {
                                 $output->writeln("The lang parent_id = {$langInfo['parent_id']} does not exist in Chamilo. Try to import first the parent language.");
                                 exit;
                             }
                         } else {
                             $output->writeln("<comment>Please turn ON the sublanguage feature in this portal</comment>");
                             exit;
                         }
                     } else {
                         $output->writeln("Parent language was not provided");
                     }
                     $q = mysql_query("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available, parent_id) VALUES (\n                                '" . $langInfo['original_name'] . "',\n                                '" . $langInfo['english_name'] . "',\n                                '" . $langInfo['isocode'] . "',\n                                '" . $langInfo['dokeos_folder'] . "',\n                                '1',\n                                '" . $parentId . "')");
                     if ($q) {
                         $output->writeln("Language inserted in the DB");
                         $langFolderPath = $_configuration['root_sys'] . 'main/lang/' . $langInfo['dokeos_folder'];
                         $phar->extractTo($langFolderPath, null, true);
                         // extract all files
                         $output->writeln("<comment>Files were copied here {$langFolderPath} </comment>");
                     } else {
                         $output->writeln("An error ocurred while tring to create the language");
                     }
                 }
             }
         } else {
             $output->writeln("<comment>The file is not a valid Chamilo language package<comment>");
         }
     } else {
         $output->writeln("<comment>The file located in '{$file}' is not accessible<comment>");
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:78,代码来源:ImportLanguageCommand.php


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