예제 #1
0
 /**
  * Check version in info file
  * from $type directory
  *
  * @param array  $directories List of directories
  * @param string $type        Type of directory
  * @param array  &$errors     Insert in this all errors
  *
  * @return void
  */
 protected function checkVersion(array $directories, $type, array &$errors)
 {
     $latestVersion = Version::getLatest();
     foreach ($directories as $directory) {
         if (is_dir($directory)) {
             $filename = $directory . '/' . $type . '.info';
             $info = new Info();
             if ($info->fromFile($filename) === true) {
                 $infos = $info->getInfos();
                 if (!empty($infos['cms_version'])) {
                     preg_match('~(?<operator>[>=]*)(?<version>.+)~', $infos['cms_version'], $matches);
                     if (empty($matches['operator'])) {
                         if (version_compare($latestVersion, $matches['version']) === 1) {
                             $errors[] = basename($directory);
                         }
                     } else {
                         if (!version_compare($latestVersion, $matches['version'], $matches['operator'])) {
                             $errors[] = $directory;
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
파일: Install.php 프로젝트: gotcms/gotcms
 /**
  * Configuration form
  *
  * @return void
  */
 public function configuration()
 {
     $siteName = new Element\Text('site_name');
     $siteName->setLabel('Site name')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('id', 'site_name')->setAttribute('class', 'form-control');
     $siteIsOffline = new Element\Checkbox('site_is_offline');
     $siteIsOffline->setLabel('Is offline')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('class', 'input-checkbox')->setAttribute('id', 'is-offline')->setCheckedValue('1');
     $adminEmail = new Element\Text('admin_email');
     $adminEmail->setAttribute('type', 'text')->setAttribute('class', 'form-control')->setAttribute('id', 'admin_email')->setLabel('Email')->setLabelAttributes(array('class' => 'control-label required col-lg-2'));
     $adminFirstname = new Element\Text('admin_firstname');
     $adminFirstname->setAttribute('type', 'text')->setAttribute('class', 'form-control')->setAttribute('id', 'admin_firstname')->setLabel('Firstname')->setLabelAttributes(array('class' => 'control-label required col-lg-2'));
     $adminLastname = new Element\Text('admin_lastname');
     $adminLastname->setAttribute('type', 'text')->setAttribute('class', 'form-control')->setAttribute('id', 'admin_lastname')->setLabel('Lastname')->setLabelAttributes(array('class' => 'control-label required col-lg-2'));
     $adminLogin = new Element\Text('admin_login');
     $adminLogin->setLabel('Login')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('id', 'admin_login')->setAttribute('class', 'form-control');
     $adminPassword = new Element\Password('admin_password');
     $adminPassword->setLabel('Admin password')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('id', 'admin_password')->setAttribute('class', 'form-control');
     $adminPasswordConfirm = new Element\Password('admin_password_confirm');
     $adminPasswordConfirm->setLabel('Confirm admin password')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('id', 'admin_password_confirm')->setAttribute('class', 'form-control');
     $path = GC_APPLICATION_PATH . '/data/install/design/';
     $listDir = glob($path . '*', GLOB_ONLYDIR);
     $options = array('' => 'Select template');
     $renderOptions = array();
     foreach ($listDir as $dir) {
         $dir = str_replace($path, '', $dir);
         $options[$dir] = $dir;
         $info = new Info();
         $info->fromFile($path . $dir . '/design.info');
         $designInfos = $info->getInfos();
         if (!empty($designInfos)) {
             $renderOptions[$dir] = $info->render();
         }
     }
     $template = new Element\Select('template');
     $template->setLabel('Default template')->setLabelAttributes(array('class' => 'control-label required col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'template')->setAttribute('data', $renderOptions)->setValueOptions($options);
     $copyTranslations = new Element\Checkbox('copy_translations');
     $copyTranslations->setLabel('Copy translations')->setLabelAttributes(array('class' => 'control-label col-lg-2'))->setAttribute('class', 'input-checkbox')->setAttribute('id', 'copy-translations')->setValue('1')->setCheckedValue('1');
     $this->add($siteName);
     $this->add($siteIsOffline);
     $this->add($adminEmail);
     $this->add($adminFirstname);
     $this->add($adminLastname);
     $this->add($adminLogin);
     $this->add($adminPassword);
     $this->add($adminPasswordConfirm);
     $this->add($template);
     $this->add($copyTranslations);
     $inputFilter = $this->getInputFilter();
     $inputFilter->add(array('name' => 'site_name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'site_name');
     $inputFilter->add(array('name' => 'admin_firstname', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'admin_firstname');
     $inputFilter->add(array('name' => 'admin_lastname', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'admin_lastname');
     $inputFilter->add(array('name' => 'admin_email', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'email_address'))), 'admin_email');
     $inputFilter->add(array('name' => 'admin_login', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'admin_login');
     $inputFilter->add(array('name' => 'site_is_offline', 'required' => false), 'site_is_offline');
     $inputFilter->add(array('name' => 'admin_password', 'required' => false), 'admin_password');
     $inputFilter->add(array('name' => 'template', 'required' => true), 'template');
     $inputFilter->add(array('name' => 'copy_translations', 'required' => false), 'copy_translations');
 }
예제 #3
0
 /**
  * Insert data into database
  *
  * @param \Zend\Db\Adapter\Adapter $dbAdapter Database adapter
  * @param string                   $template  Template name
  * @param string                   $sqlType   Sql database type
  *
  * @return \Zend\View\Model\JsonModel|null
  */
 protected function installTemplate($dbAdapter, $template, $sqlType)
 {
     $templatePath = GC_APPLICATION_PATH . sprintf('/data/install/design/%s', $template);
     $info = new Info();
     $info->fromFile($templatePath . '/design.info');
     $filePath = sprintf('%s/sql/%s.sql', $templatePath, $sqlType);
     if (!file_exists($filePath)) {
         return $this->returnJson(array('success' => false, 'message' => sprintf('Could not find data for this template and driver: Driver %s, path %s', $sqlType, $templatePath)));
     }
     $designInfos = $info->getInfos();
     if (!empty($designInfos['modules'])) {
         $modules = $this->getServiceLocator()->get('CustomModules');
         foreach ($designInfos['modules'] as $module) {
             ModuleModel::install($modules, $module);
         }
     }
     $sql = file_get_contents($filePath);
     $dbAdapter->getDriver()->getConnection()->getResource()->exec($sql);
     File::copyDirectory($templatePath . '/frontend', GC_PUBLIC_PATH . '/frontend');
     if (file_exists($templatePath . '/files')) {
         File::copyDirectory($templatePath . '/files', GC_MEDIA_PATH . '/files');
     }
     File::copyDirectory($templatePath . '/templates', GC_APPLICATION_PATH . '/templates');
 }