/** * Init Module form * * @return void */ public function init() { $this->setAttribute('class', 'relative'); $fileInfo = new Info(); $modulesInfos = array(); $options = array('' => 'Select an option'); foreach ($this->getServiceLocator()->get('ModulesList') as $path => $dir) { $options[$dir] = $dir; $configFile = $path . '/module.info'; if ($fileInfo->fromFile($configFile) === true) { $modulesInfos[$dir] = $fileInfo->render(); } } $collection = new ModuleCollection(); $modules = $collection->getModules(); foreach ($modules as $module) { if (in_array($module->getName(), $options)) { unset($options[$module->getName()]); unset($modulesInfos[$module->getName()]); } } $module = new Element\Select('module'); $module->setLabel('Module')->setLabelAttributes(array('class' => 'required')); $module->setAttribute('id', 'module')->setAttribute('class', 'form-control')->setAttribute('modules_info', $modulesInfos)->setValueOptions($options); $this->add($module); $inputFilterFactory = new InputFilterFactory(); $inputFilter = $inputFilterFactory->createInputFilter(array('module' => array('name' => 'module', 'required' => true, 'validators' => array(array('name' => 'not_empty'))))); $this->setInputFilter($inputFilter); }
/** * 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'); }
/** * Return datatype informations * * @return false|string */ public function getInfos() { $object = new ReflectionObject($this); $directory = dirname($object->getFileName()); $filename = $directory . '/datatype.info'; $info = new Info(); if ($info->fromFile($filename) !== true) { return false; } return $info->render(); }