Ejemplo n.º 1
0
 protected function _doInsert(\Application\Entity\Entity $model)
 {
     $data = array("tax_free_allowance" => $model->taxFreeAllowance, "tax_percent" => $model->taxPercent, "incaso_parts" => $model->incasoParts, "storno_interval" => $model->stornoInterval, "storno_first_part_percent" => $model->stornoFirstPartPercent, "storno_second_part_percent" => $model->stornoSecondPartPercent);
     $filename = APPLICATION_PATH . "/configs/configuration.ini";
     $configWriter = new \Zend_Config_Writer_Ini();
     $configWriter->write($filename, new \Zend_Config($data));
 }
Ejemplo n.º 2
0
 private function configure()
 {
     $zend_console = new Zend_Console_Getopt(array('create|c' => 'Create database configureation', 'adapter|a=w' => 'Database adapter (mysql)', 'host|h=w' => 'Default to localhost', 'username|u=w' => 'Username to connect to database', 'password|p=w' => 'Password to connect to database', 'database|d=w' => 'Database Name', 'port|o-i' => '(optional) Port for connecting to database', 'socket|s-w' => '(optional) Location for database socket'), $this->argv);
     try {
         echo $a = $zend_console->getOption('a');
         echo $h = $zend_console->getOption('h');
         // Load all sections from an existing config file, while skipping the extends.
         $config = new Zend_Config_Ini(SMCONFIG_DIRECTORY . DIRECTORY_SEPARATOR . 'database.ini', null, array('skipExtends' => true, 'allowModifications' => true));
         // Modify values
         $config->database->doctrine_adapter = $zend_console->getOption('a');
         $config->database->params->host = $zend_console->getOption('h');
         $config->database->params->username = $zend_console->getOption('u');
         $config->database->params->password = $zend_console->getOption('p');
         $config->database->params->dbname = $zend_console->getOption('d');
         $config->database->params->port = $zend_console->getOption('h');
         $config->database->params->socket = $zend_console->getOption('h');
         // Write the config file
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => 'config.ini'));
         $writer->write();
         //*/
     } catch (Zend_Console_Getopt_Exception $e) {
         fwrite(STDOUT, "Connection Failed\n");
         echo $e->getUsageMessage();
         exit;
     }
 }
Ejemplo n.º 3
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, $config->get('dcmj2pnm', DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, $config->get('dcmftest', DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, $config->get('dcmdictpath', DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->dcmj2pnm);
         unset($config->global->dcmftest);
         unset($config->global->dcmdictpath);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 4
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     $securityKey = $randomComponent->generateString(32);
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $config->get('securitykey', $securityKey), $this->moduleName);
         $showButton = $config->get('showbutton');
         if ($showButton === 'true') {
             $showButton = 1;
         } elseif ($showButton === 'false') {
             $showButton = 0;
         } else {
             $showButton = MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE;
         }
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, $showButton, $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->securitykey->securitykey);
         unset($config->showbutton->showbutton);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $securityKey, $this->moduleName);
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 5
0
 public function indexAction()
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/manager.ini', null, true);
     $validationErrors = array();
     if ($this->getRequest()->isPost()) {
         $c = $this->_getParam('config');
         if (empty($c['manager_host'])) {
             $validationErrors['manager_host'] = $translate->translate("Manager host is required");
         }
         if (empty($c['gateway_host'])) {
             $validationErrors['gateway_host'] = $translate->translate("Gateway host is required");
         }
         if (empty($validationErrors)) {
             $config->manager_host = $c['manager_host'];
             $config->gateway_host = $c['gateway_host'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => APPLICATION_PATH . '/configs/manager.ini'));
             $writer->write();
             $this->view->flashMessage = $translate->translate("Preferences Updated");
         }
     }
     $this->view->config = $config;
     $this->view->validationErrors = $validationErrors;
 }
Ejemplo n.º 6
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $piwikUrl = isset($config->piwik->url) ? $config->piwik->url : STATISTICS_PIWIK_URL_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, $piwikUrl, $this->moduleName);
         $piwikId = isset($config->piwik->id) ? $config->piwik->id : STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, $piwikId, $this->moduleName);
         $piwikApiKey = isset($config->piwik->apikey) ? $config->piwik->apikey : STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, $piwikApiKey, $this->moduleName);
         $ipInfoDbApiKey = isset($config->ipinfodb->apikey) ? $config->ipinfodb->apikey : STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, $ipInfoDbApiKey, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, $config->get('report', STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->piwik->url);
         unset($config->global->piwik->id);
         unset($config->global->piwik->pikey);
         unset($config->global->ipinfodb->apikey);
         unset($config->global->report);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, STATISTICS_PIWIK_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 7
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_PHMAGICK, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_JPG, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, $config->get('imagemagick', MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, $config->get('useThumbnailer', MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, $config->get('thumbnailer', MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->imageFormats);
         unset($config->global->imagemagick);
         unset($config->global->thumbnailer);
         unset($config->global->useThumbnailer);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
     }
 }
 public function indexAction()
 {
     $config = Zend_Registry::get('config');
     /* @var $config Zend_Config */
     if ($config->gandi->api->key) {
         return $this->_helper->redirector('index', 'index');
     }
     $configFile = APPLICATION_PATH . '/configs/application.ini';
     $config = new Zend_Config_Ini($configFile, null, array('skipExtends' => true, 'allowModifications' => true));
     $request = $this->getRequest();
     $form = new Application_Form_Install();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $formValues = $form->getValues();
             // DEBUG
             //Zend_Debug::dump($formValues); die();
             $apiKey = $formValues['apikey'];
             try {
                 if (!$apiKey) {
                     throw new Exception('Gandi API key can\'t be empty!');
                 }
                 if (!is_writable($configFile)) {
                     throw new Exception(sprintf('Config file is not writeable! Please check write right to %s file!', $configFile));
                 }
                 $config->development->gandi = array('api' => array('key' => $apiKey), 'account' => array('showdetails' => '0'), 'vm' => array('showdetails' => '0'));
                 $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile));
                 $writer->write();
                 return $this->_helper->redirector('index', 'index');
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 9
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, 'global');
     $settingModel->setConfig('address_verification', $config->get('verifyemail', 0), 'mail');
     if ($config->get('smtpfromaddress')) {
         $fromAddress = $config->get('smtpfromaddress');
     } elseif (ini_get('sendmail_from')) {
         $fromAddress = ini_get('sendmail_from');
     } else {
         $fromAddress = '*****@*****.**';
         // RFC2606
     }
     $settingModel->setConfig('from_address', $fromAddress, 'mail');
     if ($config->get('smtpserver')) {
         $components = parse_url($config->get('smtpserver'));
         if (isset($components['host'])) {
             $settingModel->setConfig('smtp_host', $components['host'], 'mail');
         }
         if (isset($components['port'])) {
             $settingModel->setConfig('smtp_port', $components['port'], 'mail');
             if ($components['port'] === 587) {
                 $settingModel->setConfig('smtp_use_ssl', 1, 'mail');
             }
         }
         if (isset($components['user'])) {
             $settingModel->setConfig('smtp_username', $components['user'], 'mail');
         }
         if (isset($components['pass'])) {
             $settingModel->setConfig('smtp_password', $components['pass'], 'mail');
         }
     }
     if ($config->get('smtpuser')) {
         $settingModel->setConfig('smtp_username', $config->get('smtpuser'), 'mail');
     }
     if ($config->get('smtppassword')) {
         $settingModel->setConfig('smtp_password', $config->get('smtppassword'), 'mail');
     }
     if ($settingModel->getValueByName('smtp_host', 'mail')) {
         $provider = 'smtp';
     } else {
         $provider = 'mail';
     }
     $settingModel->setConfig('provider', $provider, 'mail');
     /** @var UtilityComponent $utilityComponent */
     $utilityComponent = MidasLoader::loadComponent('Utility');
     $utilityComponent->installModule('mail');
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, null, true);
     unset($config->global->smtpfromaddress);
     unset($config->global->smtpserver);
     unset($config->global->smtpuser);
     unset($config->global->smtppassword);
     unset($config->global->verifyemail);
     $writer = new Zend_Config_Writer_Ini();
     $writer->setConfig($config);
     $writer->setFilename(APPLICATION_CONFIG);
     $writer->write();
 }
Ejemplo n.º 10
0
 public function saveConfig()
 {
     if (!is_dir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/")) {
         mkdir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/");
     }
     if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini")) {
         unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini");
     }
     $config = new Zend_Config($this->config, true);
     $writer = new Zend_Config_Writer_Ini(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini"));
     $writer->write();
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD']) {
         $form = new VF_Import_Settings();
         $form->populate($_POST);
         $config = $form->getConfig();
         $config->importer->allowMissingFields = $form->getValue('allowMissingFields');
         $config->importer->Y2KMode = $form->getValue('Y2KMode');
         $config->importer->Y2KThreshold = $form->getValue('Y2KThreshold');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $form = new Elite_Vaf_Model_Settings_Category();
         $form->populate($_POST);
         $config = $form->getConfig();
         $config->category->disable = $form->getValue('disable');
         $config->category->mode = $form->getValue('mode');
         $config->category->whitelist = $form->getValue('whitelist');
         $config->category->blacklist = $form->getValue('blacklist');
         $config->category->requireVehicle = $form->getValue('requireVehicle');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 13
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', MIDAS_DICOMSERVER_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_COMMAND_KEY, $config->get('storescp', MIDAS_DICOMSERVER_STORESCP_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_PORT_KEY, $config->get('storescp_port', MIDAS_DICOMSERVER_STORESCP_PORT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_KEY, $config->get('storescp_study_timeout', MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_KEY, $config->get('receptiondir', MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DESTINATION_FOLDER_KEY, $config->get('pydas_dest_folder', MIDAS_DICOMSERVER_DESTINATION_FOLDER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_KEY, $config->get('dcmqrscp', MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_PORT_KEY, $config->get('dcmqrscp_port', MIDAS_DICOMSERVER_DCMQRSCP_PORT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_KEY, $config->get('dcmqridx', MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_SERVER_AE_TITLE_KEY, $config->get('server_ae_title', MIDAS_DICOMSERVER_SERVER_AE_TITLE_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_PEER_AES_KEY, $config->get('peer_aes', MIDAS_DICOMSERVER_PEER_AES_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->storescp);
         unset($config->global->storescp_port);
         unset($config->global->storescp_study_timeout);
         unset($config->global->receptiondir);
         unset($config->global->pydas_dest_folder);
         unset($config->global->dcmqrscp);
         unset($config->global->dcmqrscp_port);
         unset($config->global->dcmqridx);
         unset($config->global->server_ae_title);
         unset($config->global->peer_aes);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCM2XML_COMMAND_KEY, MIDAS_DICOMSERVER_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_COMMAND_KEY, MIDAS_DICOMSERVER_STORESCP_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_PORT_KEY, MIDAS_DICOMSERVER_STORESCP_PORT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_KEY, MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_KEY, MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DESTINATION_FOLDER_KEY, MIDAS_DICOMSERVER_DESTINATION_FOLDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_KEY, MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_PORT_KEY, MIDAS_DICOMSERVER_DCMQRSCP_PORT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_KEY, MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_SERVER_AE_TITLE_KEY, MIDAS_DICOMSERVER_SERVER_AE_TITLE_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_PEER_AES_KEY, MIDAS_DICOMSERVER_PEER_AES_DEFAULT_VALUE, $this->moduleName);
     }
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $form = new Elite_Vaf_Model_Settings_Garage();
         $form->populate($_POST);
         $config = $form->getConfig();
         foreach ($form->getElements() as $name => $element) {
             if ($name == 'save') {
                 continue;
             }
             $config->mygarage->{$name} = $element->getValue();
         }
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 15
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, $config->get('hachoir', METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->hachoir);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 16
0
Archivo: Config.php Proyecto: hjr3/zf2
 /**
  * @param string $type
  */
 public function create()
 {
     /* @var $userConfig Zend_Tool_Framework_Client_Config */
     $userConfig = $this->_registry->getConfig();
     $resp = $this->_registry->getResponse();
     if ($userConfig->exists()) {
         throw new Zend_Tool_Framework_Exception("A configuration already exists, cannot create a new one.");
     }
     $homeDirectory = $this->_detectHomeDirectory();
     $writer = new Zend_Config_Writer_Ini();
     $writer->setRenderWithoutSections();
     $filename = $homeDirectory . "/.zf.ini";
     $config = array('php' => array('includepath' => get_include_path()));
     $writer->write($filename, new Zend_Config($config));
     $resp = $this->_registry->getResponse();
     $resp->appendContent("Successfully written Zend Tool config.");
     $resp->appendContent("It is located at: " . $filename);
 }
Ejemplo n.º 17
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(API_METHOD_PREFIX_KEY, $config->get('methodprefix', API_METHOD_PREFIX_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->methodprefix);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(API_METHOD_PREFIX_KEY, API_METHOD_PREFIX_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 18
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_KEY, $config->get('days', CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->days);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_KEY, CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_DEFAULT_VALUE, $this->moduleName);
     }
 }
 function doIndexAction()
 {
     $config = $this->getConfig();
     $this->block->setTemplate('vf/vaf/vfdata.phtml');
     $form = $this->form();
     $this->block->form = $form;
     if ($this->getRequest()->getParam('download')) {
         $download_url = 'http://data.vehiclefits.com/api/download?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $download_stream = fopen($download_url, 'r');
         while (!feof($download_stream)) {
             $buffer = fread($download_stream, 512);
             // use a buffer of 512 bytes
             fwrite($local_stream, $buffer);
         }
         fclose($download_stream);
         fclose($local_stream);
         $importer = new VF_Import_VehiclesList_CSV_Import($local_file);
         $importer->import();
         $this->block->downloaded = true;
         return;
     }
     if ($this->getRequest()->getParam('upload')) {
         $upload_url = 'http://data.vehiclefits.com/api/upload?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $exporter = new VF_Import_VehiclesList_CSV_Export();
         $exporter->export($local_stream);
         $ch = curl_init($upload_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($local_file));
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $response = curl_exec($ch);
         $this->block->uploaded = $response;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
         $config->vfdata->api_token = $form->getValue('api_token');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 20
0
 private function writeModulesIni()
 {
     // Load all sections from an existing config file, while skipping the extends.
     $filename = ZfApplication::$_data_path . '/etc/modules.ini';
     $config = new Zend_Config_Ini($filename, null, array('skipExtends' => true, 'allowModifications' => true));
     $config->production = array();
     $config->setExtend('staging', 'production');
     $config->setExtend('cli', 'production');
     // Modify a value
     $directory = new DirectoryIterator(ZfApplication::$_base_path . "/app");
     $config->production->modules = array();
     foreach ($directory as $dir) {
         $name = strtolower($dir->getFilename());
         if (!$dir->isDot() && $dir->isDir() && !in_array($name[0], array(".", "_"))) {
             $config->production->modules->{$name} = '/app/' . $dir->getFilename() . '/Controllers';
         }
     }
     // Write the config file
     $writer = new Zend_Config_Writer_Ini();
     $writer->write($filename, $config);
 }
Ejemplo n.º 21
0
 /**
  * Create configs for project
  *
  * Configs will be created by asking user to answer some questions
  * and saved in the config file (~/.mtool.ini)
  *
  * @param  string $configFileName config file name, basically it's ~/.mtool.ini
  * @return null
  */
 protected function _createConfig($configFileName)
 {
     // id of the last project
     $maxProjectId = 0;
     // create config file if it's not exists
     if (!file_exists($configFileName)) {
         if (!($configFileHandle = fopen($configFileName, 'a+'))) {
             throw new Mtool_Codegen_Exception_Filesystem("Cannot create config file {$configFileName}.  Maybe permissions problem?");
         } else {
             fclose($configFileHandle);
         }
     }
     // if file already exists, try to find other projects configs
     $iniConfig = new Zend_Config_Ini($configFileName, null, array('skipExtends' => true, 'allowModifications' => true));
     if (!is_null($iniConfig->projects)) {
         $projects = $iniConfig->projects->toArray();
         $maxProjectId = max(array_keys($projects));
     }
     // access to _ask()/_anwer() methods
     $author = $this->_ask("Please, enter data for the @author string\n" . "For example, Dan Kocherga <*****@*****.**>");
     $copyright = $this->_ask("Please, enter data for the copyright owner\n" . "For example, Oggetto Web ltd (http://oggettoweb.com/)");
     $licensePath = $this->_ask("Please, enter path to the license file\n" . "For example, /home/user/project/license.lic\n" . "Or press Enter to use the same as in the Magento");
     $moduleOwner = $this->_ask("Please, enter module owner\n" . "For example, Oggetto Web\n" . "It will be used to generate a short file description string");
     $projectId = $maxProjectId + 1;
     $newProject = array($projectId => array('copyright_company' => $copyright, 'path' => Mtool_Magento::getRoot(), 'author' => $author, 'module_owner' => $moduleOwner));
     if ($licensePath) {
         $newProject[$projectId]['license_path'] = $licensePath;
     }
     if (!isset($projects) || !is_array($projects)) {
         $projects = array();
     }
     $iniConfig->projects = array_merge($projects, $newProject);
     // save configurations to the config file
     $options = array('config' => $iniConfig, 'filename' => $configFileName);
     $writer = new Zend_Config_Writer_Ini($options);
     $writer->write();
     return $iniConfig;
 }
Ejemplo n.º 22
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(VISUALIZE_TEMPORARY_DIRECTORY_KEY, $config->get('customtmp', VISUALIZE_TEMPORARY_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_PARAVIEW_WEB_KEY, $config->get('useparaview', VISUALIZE_USE_PARAVIEW_WEB_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_WEB_GL_KEY, $config->get('userwebgl', VISUALIZE_USE_WEB_GL_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_SYMLINKS_KEY, $config->get('usesymlinks', VISUALIZE_USE_SYMLINKS_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_TOMCAT_ROOT_URL_KEY, $config->get('pwapp', VISUALIZE_TOMCAT_ROOT_URL_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PVBATCH_COMMAND_KEY, $config->get('pvbatch', VISUALIZE_PVBATCH_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_KEY, $config->get('paraviewworkdir', VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->customtmp);
         unset($config->global->useparaview);
         unset($config->global->userwebgl);
         unset($config->global->usesymlinks);
         unset($config->global->pwapp);
         unset($config->global->pvbatch);
         unset($config->global->paraviewworkdir);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(VISUALIZE_TEMPORARY_DIRECTORY_KEY, VISUALIZE_TEMPORARY_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_PARAVIEW_WEB_KEY, VISUALIZE_USE_PARAVIEW_WEB_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_WEB_GL_KEY, VISUALIZE_USE_WEB_GL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_SYMLINKS_KEY, VISUALIZE_USE_SYMLINKS_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_TOMCAT_ROOT_URL_KEY, VISUALIZE_TOMCAT_ROOT_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PVBATCH_COMMAND_KEY, VISUALIZE_PVBATCH_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_KEY, VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 23
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(OAI_REPOSITORY_IDENTIFIER_KEY, $config->get('repositoryidentifier', OAI_REPOSITORY_IDENTIFIER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(OAI_REPOSITORY_NAME_KEY, $config->get('repositoryname', OAI_REPOSITORY_NAME_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(OAI_ADMIN_EMAIL_KEY, $config->get('adminemail', OAI_ADMIN_EMAIL_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->repositoryidentifier);
         unset($config->global->repositoryname);
         unset($config->global->adminemail);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(OAI_REPOSITORY_IDENTIFIER_KEY, OAI_REPOSITORY_IDENTIFIER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(OAI_REPOSITORY_NAME_KEY, OAI_REPOSITORY_NAME_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(OAI_ADMIN_EMAIL_KEY, OAI_ADMIN_EMAIL_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 24
0
 /**
  * The public method that would be exposed into ZF tool
  */
 public function generate()
 {
     $currentWorkingDirectory = getcwd();
     // replace the slash just to print a beautiful message :D
     $configDir = str_replace('/', DIRECTORY_SEPARATOR, $currentWorkingDirectory . '/application/configs/');
     $configFilePath = $configDir . 'application.ini';
     $backupName = 'application.ini';
     $backupCount = 1;
     // create a backup
     while (file_exists($configDir . "{$backupName}.{$backupCount}")) {
         ++$backupCount;
     }
     copy($configFilePath, $configDir . "{$backupName}.{$backupCount}");
     if (!file_exists($configFilePath)) {
         throw new Zodeken_ZfTool_Exception('Application config file not found: ' . $configFilePath);
     }
     $this->_cwd = $currentWorkingDirectory;
     $configs = new Zend_Config_Ini($configFilePath, null, array('skipExtends' => true, 'allowModifications' => true));
     // find db configs in development section
     $dbConfig = $configs->development->resources->db;
     // if not found, find it in production section
     if (null === $dbConfig) {
         $dbConfig = $configs->production->resources->db;
     }
     if (null === $dbConfig) {
         throw new Zodeken_ZfTool_Exception("Db configs not found in your application.ini");
     }
     // get the app namespace
     if ($configs->production->appnamespace) {
         $this->_appnamespace = $configs->production->appnamespace;
         if ($this->_appnamespace[strlen($this->_appnamespace) - 1] !== '_') {
             $this->_appnamespace .= '_';
         }
     }
     $this->_dbName = $dbConfig->params->dbname;
     $this->_packageName = $this->_getCamelCase($this->_dbName);
     $this->_db = Zend_Db::factory($dbConfig);
     // modify the config file
     if (!$configs->zodeken) {
         $configs->zodeken = array();
     }
     // get package name from config
     if ($configs->zodeken->packageName) {
         $this->_packageName = $configs->zodeken->packageName;
     }
     // get form base class from config
     if ($configs->zodeken->formBaseClass) {
         $this->_formBaseClass = $configs->zodeken->formBaseClass;
     }
     $eol = PHP_EOL;
     $question = "Which component do you want to generate?{$eol}{$eol}" . "1. DbTables{$eol}2. Mappers{$eol}3. Forms{$eol}4. All{$eol}{$eol}";
     $question .= "Your choice (4): ";
     $mode = (int) $this->_readInput($question);
     if (!$mode) {
         $mode = 4;
     }
     $packageName = $this->_readInput("Your package name ({$this->_packageName}): ");
     $formBaseClass = $this->_readInput("Form's parent class ({$this->_formBaseClass}): ");
     if (!empty($packageName)) {
         $this->_packageName = $packageName;
     }
     if (!empty($formBaseClass)) {
         $this->_formBaseClass = $formBaseClass;
     }
     // auto-add "Zodeken_" to the autoloadernamespaces directive
     $autoloaderNamespaces = $configs->production->autoloadernamespaces;
     if (!$autoloaderNamespaces) {
         $autoloaderNamespaces = array('Zodeken_');
     } else {
         $autoloaderNamespaces = $autoloaderNamespaces->toArray();
         if (false === array_search('Zodeken_', $autoloaderNamespaces)) {
             $autoloaderNamespaces[] = 'Zodeken_';
         }
     }
     // modify configs
     $configs->zodeken->packageName = $this->_packageName;
     $configs->zodeken->formBaseClass = $this->_formBaseClass;
     $configs->production->autoloadernamespaces = $autoloaderNamespaces;
     $configWriter = new Zend_Config_Writer_Ini(array('config' => $configs, 'filename' => $configFilePath));
     $configWriter->write();
     // some constants like APPLICATION_PATH is replaced with "APPLICATION_PATH"
     // we need to remove the double quotes...
     $this->_preserveIniConfigs($configFilePath);
     echo 'Configs have been written to application.ini';
     // end of modifying configs
     $this->_analyzeTableDefinitions();
     $modelsDir = $currentWorkingDirectory . '/application/models';
     $formsDir = $currentWorkingDirectory . '/application/forms';
     foreach ($this->_tables as $tableName => $tableDefinition) {
         $tableBaseClassName = $tableDefinition['baseClassName'];
         if (1 === $mode || 4 === $mode) {
             $tableCode = $this->_getDbTableCode($tableDefinition);
             $rowCode = $this->_getRowCode($tableDefinition);
             $rowsetCode = $this->_getRowsetCode($tableDefinition);
             $this->_createFile("{$modelsDir}/DbTable", $tableBaseClassName . '.php', $tableCode, true);
             $this->_createFile("{$modelsDir}/DbTable/Row", $tableBaseClassName . '.php', $rowCode, true);
             $this->_createFile("{$modelsDir}/DbTable/Rowset", $tableBaseClassName . '.php', $rowsetCode, true);
         }
         if (!$tableDefinition['isMap']) {
             if (2 === $mode || 4 === $mode) {
                 $this->_createFile($modelsDir, $tableBaseClassName . 'Mapper.php', $this->_getMapperCode($tableDefinition), false);
             }
             if (3 === $mode || 4 === $mode) {
                 $this->_createFile($formsDir, $tableBaseClassName . '.php', $this->_getFormCode($tableDefinition), false);
             }
         }
     }
 }
Ejemplo n.º 25
0
 public function indexAction()
 {
     // Title
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Parameters")));
     // Get configuration properties from Zend_Registry
     $config = Zend_Registry::get('config');
     // Include Inpector class, for permission test
     include_once $config->system->path->base . "/inspectors/Permissions.php";
     $test = new Permissions();
     $response = $test->getTests();
     // Verify if there's any error, and if it's related to the setup.conf file
     if ($response['error'] && strpos($response['message'], "setup.conf") > 0) {
         // seta variavel verificada no template
         $this->view->error = $this->view->translate("The File includes/setup.conf does not have permission to be modified.");
     }
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/parameters/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/setup.conf.xml');
     // Section General
     $general = new Snep_Form_SubForm($this->view->translate("General Configuration"), $form_xml->general);
     // Setting propoertie values
     $empName = $general->getElement('emp_nome');
     $empName->setValue($config->ambiente->emp_nome);
     $debug = $general->getElement('debug');
     $debug->setValue($config->system->debug);
     $ipSock = $general->getElement('ip_sock');
     $ipSock->setValue($config->ambiente->ip_sock);
     $userSock = $general->getElement('user_sock');
     $userSock->setValue($config->ambiente->user_sock);
     $passSock = $general->getElement('pass_sock');
     $passSock->setValue($config->ambiente->pass_sock);
     $email = $general->getElement('mail');
     $email->setValue($config->system->mail);
     $lineLimit = $general->getElement('linelimit');
     $lineLimit->setValue($config->ambiente->linelimit);
     $dstExceptions = $general->getElement('dst_exceptions');
     $dstExceptions->setValue($config->ambiente->dst_exceptions);
     $conferenceApp = $general->getElement('conference_app');
     $conferenceApp->setValue($config->ambiente->conference_app);
     $form->addSubForm($general, "general");
     $locale_form = new Snep_Form_SubForm($this->view->translate("Locale Configuration"), $form_xml->locale);
     $locale = Snep_Locale::getInstance()->getZendLocale();
     $locales = array();
     foreach ($locale->getTranslationList("territory", Snep_Locale::getInstance()->getLanguage(), 2) as $ccode => $country) {
         $locales[$country] = $locale->getLocaleToTerritory($ccode);
     }
     ksort($locales, SORT_LOCALE_STRING);
     foreach ($locales as $country => $ccode) {
         $locale_form->getElement("locale")->addMultiOption($ccode, $country);
     }
     $locale_form->getElement("locale")->setValue(Snep_Locale::getInstance()->getLocale());
     foreach ($locale->getTranslationList("territorytotimezone", Snep_Locale::getInstance()->getLanguage()) as $timezone => $territory) {
         $locale_form->getElement("timezone")->addMultiOption($timezone, $timezone);
     }
     $locale_form->getElement("timezone")->setValue(Snep_Locale::getInstance()->getTimezone());
     $languages = array();
     $languageElement = $locale_form->getElement("language");
     $available_languages = Snep_Locale::getInstance()->getAvailableLanguages();
     foreach ($locale->getTranslationList("language", Snep_Locale::getInstance()->getLanguage()) as $lcode => $language) {
         if (in_array($lcode, $available_languages)) {
             $languageElement->addMultiOption($lcode, ucfirst($language));
         }
     }
     $languageElement->setValue(Snep_Locale::getInstance()->getLanguage());
     $form->addSubForm($locale_form, "locale");
     // Section Recording
     $recording = new Snep_Form_SubForm($this->view->translate("Call Recording Configuration"), $form_xml->recording);
     // Setting propoertie values
     $application = $recording->getElement('application');
     $application->setValue($config->general->record->application);
     $flag = $recording->getElement('flag');
     $flag->setValue($config->general->record->flag);
     $recordMp3 = $recording->getElement('record_mp3');
     $recordMp3->setValue($config->general->record_mp3);
     $pathVoice = $recording->getElement('path_voz');
     $pathVoice->setValue($config->ambiente->path_voz);
     $pathVoiceBkp = $recording->getElement('path_voz_bkp');
     $pathVoiceBkp->setValue($config->ambiente->path_voz_bkp);
     $form->addSubForm($recording, "gravacao");
     // Section Trunks
     $trunks = new Snep_Form_SubForm($this->view->translate("Trunks Configuration"), $form_xml->trunks);
     // Setting propoertie values
     $qualControlValue = $trunks->getElement('valor_controle_qualidade');
     $qualControlValue->setValue($config->ambiente->valor_controle_qualidade);
     $form->addSubForm($trunks, "troncos");
     // Verify if the request is a post
     if ($this->_request->getPost()) {
         $formIsValid = $form->isValid($_POST);
         $formData = $this->getRequest()->getParams();
         // Specific verification for propertie path_voice
         if (!file_exists($formData['gravacao']['path_voz'])) {
             $recording->getElement('path_voz')->addError($this->view->translate("Invalid path"));
             $formIsValid = false;
         }
         //Validates form, then sets propertie values and records it on the configuration file
         if ($formIsValid) {
             $configFile = APPLICATION_PATH . "/includes/setup.conf";
             $config = new Zend_Config_Ini($configFile, null, true);
             $config->ambiente->emp_nome = $formData['general']['emp_nome'];
             $config->system->debug = $formData['general']['debug'];
             $config->system->language = $formData['locale']['language'];
             $config->system->locale = $formData['locale']['locale'];
             $config->system->timezone = $formData['locale']['timezone'];
             $config->ambiente->ip_sock = $formData['general']['ip_sock'];
             $config->ambiente->user_sock = $formData['general']['user_sock'];
             $config->ambiente->pass_sock = $formData['general']['pass_sock'];
             $config->system->mail = $formData['general']['mail'];
             $config->ambiente->linelimit = $formData['general']['linelimit'];
             $config->ambiente->dst_exceptions = $formData['general']['dst_exceptions'];
             $config->ambiente->conference_app = $formData['general']['conference_app'];
             $config->general->record->application = $formData['gravacao']['application'];
             $config->general->record->flag = $formData['gravacao']['flag'];
             $config->general->record_mp3 = $formData['gravacao']['record_mp3'];
             $config->ambiente->path_voz = $formData['gravacao']['path_voz'];
             $config->ambiente->path_voz_bkp = $formData['gravacao']['path_voz_bkp'];
             $config->ambiente->valor_controle_qualidade = $formData['troncos']['valor_controle_qualidade'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile));
             // Write file
             $writer->write();
             $this->_redirect('parameters');
         }
     }
     $this->view->form = $form;
 }
 /**
  * Set the upgrade level for the given $context to a certain level
  *
  * Will only update when the $level is higher than the achieved level, unless
  * when $force = true when it will always update.
  *
  * @param string $context
  * @param int $level
  * @param boolean $force
  */
 protected function setLevel($context, $level = null, $force = false)
 {
     if (!is_null($level) && $this->_info->{$context} != $level && ($force || $this->_info->{$context} < $level)) {
         $this->_info->{$context} = $level;
         $writer = new \Zend_Config_Writer_Ini();
         $writer->write($this->upgradeFile, $this->_info);
     }
 }
Ejemplo n.º 27
0
 /**
  * Method exports zipped theme
  * @param string $themeName Theme name
  * @param bool   $full      Set true to dump data and media files
  */
 protected function _exportTheme($themeName = '', $full = false, $noZip = false)
 {
     if (!$themeName) {
         $themeName = $this->_configHelper->getConfig('currentTheme');
     }
     $themePath = $this->_websiteHelper->getPath() . $this->_themesConfig['path'] . $themeName . DIRECTORY_SEPARATOR;
     $websitePath = $this->_websiteHelper->getPath();
     if ($full) {
         /**
          * @var $dbAdapter Zend_Db_Adapter_Abstract
          */
         $dbAdapter = Zend_Registry::get('dbAdapter');
         // exporting themes data for the full theme
         // init empty array for export data
         $data = array('page' => array());
         // and for media files
         $mediaFiles = array();
         // fetching index page and main menu pages
         $pagesSqlWhere = "SELECT * FROM `page` WHERE system = '0' AND draft = '0' AND (\n\t\t\turl = 'index.html' OR (parent_id = '0' AND show_in_menu = '1') OR (parent_id = '-1' AND show_in_menu = '2')\n\t\t    OR (parent_id = '0' OR parent_id IN (SELECT DISTINCT `page`.`id` FROM `page` WHERE (parent_id = '0') AND (system = '0') AND (show_in_menu = '1')) )\n\t\t    OR id IN ( SELECT DISTINCT `page_id` FROM `page_fa` )\n\t\t    OR id IN ( SELECT DISTINCT `page_id` FROM `page_has_option` )\n\t\t    ) ORDER BY `order` ASC";
         $pages = $dbAdapter->fetchAll($pagesSqlWhere);
         if (is_array($pages) && !empty($pages)) {
             $data['page'] = $pages;
             unset($pages);
         }
         // combining list of queries for export others tables content
         $queryList = array();
         $enabledPlugins = Tools_Plugins_Tools::getEnabledPlugins(true);
         foreach ($enabledPlugins as $plugin) {
             $pluginsData = Tools_Plugins_Tools::runStatic(self::PLUGIN_EXPORT_METHOD, $plugin);
             if (!$pluginsData) {
                 continue;
             }
             if (isset($pluginsData['pages']) && is_array($pluginsData['pages']) && !empty($pluginsData['pages'])) {
                 $data['page'] = array_merge($data['page'], $pluginsData['pages']);
             }
             if (isset($pluginsData['tables']) && is_array($pluginsData['tables']) && !empty($pluginsData['tables'])) {
                 foreach ($pluginsData['tables'] as $table => $query) {
                     if (array_key_exists($table, $this->_fullThemesSqlMap)) {
                         continue;
                     }
                     $queryList[$table] = $query;
                     unset($table, $query);
                 }
             }
             if (isset($pluginsData['media']) && is_array($pluginsData['media']) && !empty($pluginsData['media'])) {
                 $mediaFiles = array_unique(array_merge($mediaFiles, $pluginsData['media']));
             }
         }
         unset($enabledPlugins);
         // getting list of pages ids for export
         $pagesIDs = array_map(function ($page) {
             return $page['id'];
         }, $data['page']);
         // building list of dump queries and executing it with page IDS substitution
         $queryList = array_merge($this->_fullThemesSqlMap, $queryList);
         foreach ($queryList as $table => $query) {
             $data[$table] = $dbAdapter->fetchAll($dbAdapter->quoteInto($query, $pagesIDs));
         }
         unset($queryList, $pagesIDs);
         if (!empty($data)) {
             $exportData = new Zend_Config($data);
             $themeDataFile = new Zend_Config_Writer_Json(array('config' => $exportData, 'filename' => $themePath . self::THEME_DATA_FILE));
             $themeDataFile->write();
         }
         // exporting list of media files
         $totalFileSize = 0;
         // initializing files size counter
         $previewFolder = $this->_websiteHelper->getPreview();
         $pagePreviews = array_filter(array_map(function ($page) use($previewFolder) {
             return !empty($page['preview_image']) ? $previewFolder . $page['preview_image'] : false;
         }, $data['page']));
         $contentImages = array();
         // list of images from containers
         if (!empty($data['container'])) {
             foreach ($data['container'] as $container) {
                 preg_match_all('~media[^"\']*\\.(?:jpe?g|gif|png)~iu', $container['content'], $matches);
                 if (!empty($matches[0])) {
                     $contentImages = array_merge($contentImages, array_map(function ($file) {
                         $file = explode(DIRECTORY_SEPARATOR, $file);
                         if ($file[2] !== 'original') {
                             $file[2] = 'original';
                         }
                         return implode(DIRECTORY_SEPARATOR, $file);
                     }, $matches[0]));
                 }
                 unset($matches, $container);
             }
         }
         $mediaFiles = array_merge($pagePreviews, $contentImages, $mediaFiles);
         $mediaFiles = array_unique(array_filter($mediaFiles));
         if (!empty($mediaFiles)) {
             clearstatcache();
             foreach ($mediaFiles as $key => $file) {
                 if (!is_file($websitePath . $file)) {
                     $mediaFiles[$key] = null;
                     continue;
                 }
                 $totalFileSize += filesize($websitePath . $file);
             }
         }
         if ($totalFileSize > self::THEME_FULL_MAX_FILESIZE) {
             $this->_error('Too many images');
         } else {
             $mediaFiles = array_filter($mediaFiles);
         }
     }
     // if requested name is current one we create system file with template types
     if ($themeName === $this->_configHelper->getConfig('currentTheme')) {
         // saving template types into theme.ini. @see Tools_Template_Tools::THEME_CONFIGURATION_FILE
         $themeIniConfig = new Zend_Config(array(), true);
         foreach (Application_Model_Mappers_TemplateMapper::getInstance()->fetchAll() as $template) {
             $themeIniConfig->{$template->getName()} = $template->getType();
         }
         if (!empty($themeIniConfig)) {
             try {
                 $iniWriter = new Zend_Config_Writer_Ini(array('config' => $themeIniConfig, 'filename' => $themePath . Tools_Template_Tools::THEME_CONFIGURATION_FILE));
                 $iniWriter->write();
             } catch (Exception $e) {
                 Tools_System_Tools::debugMode() && error_log($e->getMessage());
             }
         }
         unset($themeIniConfig, $iniWriter);
     }
     //defining list files that needs to be excluded
     $excludeFiles = array();
     if (!$full) {
         array_push($excludeFiles, self::THEME_DATA_FILE);
     }
     if ($noZip === true) {
         // backup media files to theme subfolder
         if (!empty($mediaFiles)) {
             if (!is_dir($themePath . 'previews')) {
                 Tools_Filesystem_Tools::mkDir($themePath . 'previews');
             }
             if (!is_dir($themePath . 'media')) {
                 Tools_Filesystem_Tools::mkDir($themePath . 'media');
             }
             foreach ($mediaFiles as $file) {
                 if (!is_file($websitePath . $file)) {
                     continue;
                 }
                 $path = explode(DIRECTORY_SEPARATOR, $file);
                 if (!is_array($path) || empty($path)) {
                     continue;
                 }
                 switch ($path[0]) {
                     case 'previews':
                         list($folder, $filename) = $path;
                         break;
                     case 'media':
                         $folder = 'media' . DIRECTORY_SEPARATOR . $path[1];
                         if (!is_dir($themePath . $folder)) {
                             Tools_Filesystem_Tools::mkDir($themePath . $folder);
                         }
                         $filename = end($path);
                         break;
                     default:
                         continue;
                         break;
                 }
                 $destination = $themePath . $folder . DIRECTORY_SEPARATOR . $filename;
                 try {
                     $r = Tools_Filesystem_Tools::copy($websitePath . $file, $destination);
                 } catch (Exception $e) {
                     Tools_System_Tools::debugMode() && error_log($e->getMessage());
                 }
             }
         }
         return true;
     } else {
         //create theme zip archive
         $themeArchive = Tools_Theme_Tools::zip($themeName, isset($mediaFiles) ? $mediaFiles : false, $excludeFiles);
         if ($themeArchive) {
             $body = file_get_contents($themeArchive);
             if (false !== $body) {
                 Tools_Filesystem_Tools::deleteFile($themeArchive);
             } else {
                 $this->_error('Unable to read website archive file');
             }
         } else {
             $this->_error('Can\'t create website archive');
         }
         //outputting theme zip
         $this->_response->clearAllHeaders()->clearBody();
         $this->_response->setHeader('Content-Disposition', 'attachment; filename=' . $themeName . '.zip')->setHeader('Content-Type', 'application/zip', true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Expires', date(DATE_RFC1123), true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Pragma', 'public', true)->setBody($body)->sendResponse();
         exit;
     }
 }
Ejemplo n.º 28
0
 /** index */
 public function indexAction()
 {
     $this->requireAdminPrivileges();
     $this->view->header = 'Administration';
     $options = array('allowModifications' => true);
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, null, $options);
     $configForm = $this->Form->Admin->createConfigForm();
     $formArray = $this->getFormAsArray($configForm);
     $formArray['description']->setValue($config->global->application->description);
     $formArray['lang']->setValue($config->global->application->lang);
     $formArray['name']->setValue($config->global->application->name);
     $formArray['timezone']->setValue($config->global->default->timezone);
     if (isset($config->global->allow_password_reset)) {
         $formArray['allow_password_reset']->setValue($config->global->allow_password_reset);
     }
     if (isset($config->global->closeregistration)) {
         $formArray['closeregistration']->setValue($config->global->closeregistration);
     }
     if (isset($config->global->dynamichelp)) {
         $formArray['dynamichelp']->setValue($config->global->dynamichelp);
     }
     if (isset($config->global->gravatar)) {
         $formArray['gravatar']->setValue($config->global->gravatar);
     }
     if (isset($config->global->httpproxy)) {
         $formArray['httpProxy']->setValue($config->global->httpproxy);
     }
     $this->view->configForm = $formArray;
     $this->view->selectedLicense = $config->global->defaultlicense;
     try {
         $this->view->allLicenses = $this->License->getAll();
     } catch (Exception $e) {
         $this->view->allLicenses = array();
     }
     $allModules = $this->Component->Utility->getAllModules();
     $this->view->extraTabs = Zend_Registry::get('notifier')->callback('CALLBACK_CORE_ADMIN_TABS');
     if ($this->_request->isPost()) {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $submitConfig = $this->getParam('submitConfig');
         $submitModule = $this->getParam('submitModule');
         if (isset($submitConfig)) {
             $config->global->application->name = $this->getParam('name');
             $config->global->application->description = $this->getParam('description');
             $config->global->application->lang = $this->getParam('lang');
             $config->global->default->timezone = $this->getParam('timezone');
             $config->global->defaultlicense = $this->getParam('licenseSelect');
             $config->global->allow_password_reset = $this->getParam('allow_password_reset');
             $config->global->closeregistration = $this->getParam('closeregistration');
             $config->global->dynamichelp = $this->getParam('dynamichelp');
             $config->global->gravatar = $this->getParam('gravatar');
             $config->global->httpproxy = $this->getParam('httpProxy');
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             echo JsonComponent::encode(array(true, 'Changes saved'));
         }
         if (isset($submitModule)) {
             $moduleName = $this->getParam('modulename');
             $modulevalue = $this->getParam('modulevalue');
             $moduleConfigLocalFile = LOCAL_CONFIGS_PATH . '/' . $moduleName . '.local.ini';
             $moduleConfigFile = BASE_PATH . '/modules/' . $moduleName . '/configs/module.ini';
             $moduleConfigPrivateFile = BASE_PATH . '/privateModules/' . $moduleName . '/configs/module.ini';
             if (!file_exists($moduleConfigLocalFile) && file_exists($moduleConfigFile)) {
                 copy($moduleConfigFile, $moduleConfigLocalFile);
                 $this->Component->Utility->installModule($moduleName);
             } elseif (!file_exists($moduleConfigLocalFile) && file_exists($moduleConfigPrivateFile)) {
                 copy($moduleConfigPrivateFile, $moduleConfigLocalFile);
                 $this->Component->Utility->installModule($moduleName);
             } elseif (!file_exists($moduleConfigLocalFile)) {
                 throw new Zend_Exception('Unable to find config file');
             }
             $config->module->{$moduleName} = $modulevalue;
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             echo JsonComponent::encode(array(true, 'Changes saved'));
         }
     }
     $defaultAssetStoreId = $this->Assetstore->getDefault()->getKey();
     // get assetstore data
     $assetstores = $this->Assetstore->getAll();
     $defaultSet = false;
     foreach ($assetstores as $key => $assetstore) {
         if ($assetstore->getKey() == $defaultAssetStoreId) {
             $assetstores[$key]->default = true;
             $defaultSet = true;
         } else {
             $assetstores[$key]->default = false;
         }
         // Check if we can access the path
         if (file_exists($assetstore->getPath())) {
             $assetstores[$key]->totalSpace = UtilityComponent::diskTotalSpace($assetstore->getPath());
             $assetstores[$key]->totalSpaceText = $this->Component->Utility->formatSize($assetstores[$key]->totalSpace);
             $assetstores[$key]->freeSpace = UtilityComponent::diskFreeSpace($assetstore->getPath());
             $assetstores[$key]->freeSpaceText = $this->Component->Utility->formatSize($assetstores[$key]->freeSpace);
         } else {
             $assetstores[$key]->totalSpaceText = false;
         }
     }
     if (!$defaultSet) {
         foreach ($assetstores as $key => $assetstore) {
             $assetstores[$key]->default = true;
             $this->Setting->setConfig('default_assetstore', $assetstores[$key]->getKey());
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             break;
         }
     }
     $this->view->assetstores = $assetstores;
     $this->view->assetstoreForm = $this->Form->Assetstore->createAssetstoreForm();
     // get modules
     $enabledModules = Zend_Registry::get('modulesEnable');
     $adapter = Zend_Registry::get('configDatabase')->database->adapter;
     foreach ($allModules as $key => $module) {
         if (file_exists(BASE_PATH . '/modules/' . $key . '/controllers/ConfigController.php')) {
             $allModules[$key]->configPage = 'config';
         } elseif (file_exists(BASE_PATH . '/privateModules/' . $key . '/controllers/ConfigController.php')) {
             $allModules[$key]->configPage = 'config';
         } elseif (file_exists(BASE_PATH . '/modules/' . $key . '/controllers/AdminController.php')) {
             $allModules[$key]->configPage = 'admin';
         } elseif (file_exists(BASE_PATH . '/privateModules/' . $key . '/controllers/AdminController.php')) {
             $allModules[$key]->configPage = 'admin';
         } else {
             $allModules[$key]->configPage = false;
         }
         if (isset($module->db->{$adapter})) {
             $allModules[$key]->dbOk = true;
         } else {
             $allModules[$key]->dbOk = false;
         }
         $allModules[$key]->dependenciesArray = array();
         $allModules[$key]->dependenciesExist = true;
         // check if dependencies exit
         if (isset($allModules[$key]->dependencies) && !empty($allModules[$key]->dependencies)) {
             $allModules[$key]->dependenciesArray = explode(',', trim($allModules[$key]->dependencies));
             foreach ($allModules[$key]->dependenciesArray as $dependency) {
                 if (!isset($allModules[$dependency])) {
                     $allModules[$key]->dependenciesExist = false;
                 }
             }
         }
     }
     $modulesList = array();
     $countModules = array();
     foreach ($allModules as $k => $module) {
         if (!isset($module->category) || empty($module->category)) {
             $category = 'Misc';
         } else {
             $category = ucfirst($module->category);
         }
         if (!isset($modulesList[$category])) {
             $modulesList[$category] = array();
             $countModules[$category] = array('visible' => 0, 'hidden' => 0);
         }
         $modulesList[$category][$k] = $module;
         if ($module->dbOk && $module->dependenciesExist) {
             ++$countModules[$category]['visible'];
         } else {
             ++$countModules[$category]['hidden'];
         }
     }
     foreach ($modulesList as $k => $l) {
         ksort($modulesList[$k]);
     }
     ksort($modulesList);
     $this->view->countModules = $countModules;
     $this->view->modulesList = $modulesList;
     $this->view->modulesEnable = $enabledModules;
     $this->view->databaseType = Zend_Registry::get('configDatabase')->database->adapter;
 }
Ejemplo n.º 29
0
 /**
  * The public method that would be exposed into ZF tool
  */
 public function generate($force = 0)
 {
     $currentWorkingDirectory = getcwd();
     $forceOverriding = $force ? true : false;
     // replace the slash just to print a beautiful message :D
     $configDir = str_replace('/', DIRECTORY_SEPARATOR, $currentWorkingDirectory . '/application/configs/');
     $configFilePath = $configDir . 'application.ini';
     if (!file_exists($configFilePath)) {
         throw new Zodeken_ZfTool_Exception('Application config file not found: ' . $configFilePath);
     }
     $backupName = 'application.ini';
     $backupCount = 1;
     // create a backup
     while (file_exists($configDir . "{$backupName}.{$backupCount}")) {
         ++$backupCount;
     }
     copy($configFilePath, $configDir . "{$backupName}.{$backupCount}");
     $this->_cwd = $currentWorkingDirectory;
     // used to get db configs
     $configs = new Zend_Config_Ini($configFilePath);
     // find db configs in development section
     $dbConfig = $configs->development->resources->db;
     // if not found, find it in production section
     if (null === $dbConfig) {
         $dbConfig = $configs->production->resources->db;
     }
     if (null === $dbConfig) {
         throw new Zodeken_ZfTool_Exception("Db configs not found in your application.ini");
     }
     // used to modify the file
     $writableConfigs = new Zend_Config_Ini($configFilePath, null, array('skipExtends' => true, 'allowModifications' => true));
     // get the app namespace
     if ($writableConfigs->production->appnamespace) {
         $this->_appnamespace = $writableConfigs->production->appnamespace;
         if ($this->_appnamespace[strlen($this->_appnamespace) - 1] !== '_') {
             $this->_appnamespace .= '_';
         }
     }
     $this->_dbName = $dbConfig->params->dbname;
     $this->_packageName = $this->_getCamelCase($this->_dbName);
     $this->_db = Zend_Db::factory($dbConfig);
     // modify the config file
     if (!$writableConfigs->zodeken) {
         $writableConfigs->zodeken = array();
     }
     // get package name from config
     if ($writableConfigs->zodeken->packageName) {
         $this->_packageName = $writableConfigs->zodeken->packageName;
     }
     $eol = PHP_EOL;
     // load the output files config
     $zodekenDir = dirname(__FILE__);
     $xdoc = new DOMDocument();
     $xdoc->load($zodekenDir . '/output-config.xml');
     $outputs = array();
     $asciiChar = 97;
     $allKeys = array();
     if ($forceOverriding) {
         echo "ATTENTION! Zodeken will override all existing files!";
     }
     $question = array("{$eol}Which files do you want to generate?{$eol}- Enter 1 to generate all{$eol}- Enter a comma-separated list of generated files, e.g. a,b,c,d{$eol}    ");
     foreach ($xdoc->getElementsByTagName('output') as $outputElement) {
         $output = array('key' => strtolower(chr($asciiChar++)), 'templateName' => $outputElement->getAttribute('templateName'), 'templateFile' => $zodekenDir . '/templates/' . $outputElement->getAttribute('templateName'), 'canOverride' => (int) $outputElement->getAttribute('canOverride'), 'outputPath' => $outputElement->getAttribute('outputPath'), 'acceptMapTable' => $outputElement->getAttribute('acceptMapTable'));
         $outputs[] = $output;
         $allKeys[] = strtolower($output['key']);
         $question[] = $output['key'] . '. ' . $output['templateName'];
     }
     $question = implode($eol . '    ', $question) . "{$eol}{$eol}Your choice: ";
     $input = strtolower(trim($this->_readInput($question)));
     if ('1' == $input) {
         $keys = $allKeys;
     } elseif ($input) {
         $keys = explode(',', $input);
     } else {
         $keys = array();
     }
     $packageName = $this->_readInput("Your package name ({$this->_packageName}): ");
     if (!empty($packageName)) {
         $this->_packageName = $packageName;
     }
     // module support has been suggested by Brian Gerrity (bgerrity73@gmail.com)
     $moduleName = $this->_readInput("Module name (leave empty for default): ");
     if (!empty($moduleName)) {
         $this->_moduleName = $moduleName;
         $this->_controllerNamePrefix = $this->_getCamelCase($moduleName) . '_';
     }
     // auto-add "resources.frontController.moduleDirectory" if module is specified
     if (!empty($this->_moduleName)) {
         if (!$writableConfigs->production->resources->frontController->moduleDirectory) {
             $writableConfigs->production->resources->frontController->moduleDirectory = 'APPLICATION_PATH/modules';
         }
         if (!$writableConfigs->production->resources->modules) {
             $writableConfigs->production->resources->modules = '';
         }
     }
     // auto-add "Zodeken_" to the autoloadernamespaces directive
     $autoloaderNamespaces = $writableConfigs->production->autoloadernamespaces;
     if (!$autoloaderNamespaces) {
         $autoloaderNamespaces = array('Zodeken_');
     } else {
         $autoloaderNamespaces = $autoloaderNamespaces->toArray();
         if (false === array_search('Zodeken_', $autoloaderNamespaces)) {
             $autoloaderNamespaces[] = 'Zodeken_';
         }
     }
     // modify configs
     $writableConfigs->zodeken->packageName = $this->_packageName;
     $writableConfigs->production->autoloadernamespaces = $autoloaderNamespaces;
     $configWriter = new Zend_Config_Writer_Ini(array('config' => $writableConfigs, 'filename' => $configFilePath));
     $configWriter->write();
     // some constants like APPLICATION_PATH is replaced with "APPLICATION_PATH"
     // we need to remove the double quotes...
     $this->_preserveIniConfigs($configFilePath);
     echo 'Configs have been written to application.ini', PHP_EOL;
     // end of modifying configs
     $this->_analyzeTableDefinitions();
     $moduleBaseDirectory = $currentWorkingDirectory . '/application';
     if (!empty($this->_moduleName)) {
         $moduleBaseDirectory .= '/modules/' . $this->_moduleName;
     }
     foreach ($this->_tables as $tableName => $tableDefinition) {
         $tableBaseClassName = $tableDefinition['baseClassName'];
         foreach ($outputs as $output) {
             if (!in_array($output['key'], $keys) || $tableDefinition['isMap'] && !$output['acceptMapTable']) {
                 continue;
             }
             $fileName = $output['outputPath'];
             $canOverride = $output['canOverride'];
             $templateFile = $output['templateFile'];
             $code = (require $templateFile);
             $fileName = str_replace('{MODULE_BASE_DIR}', $moduleBaseDirectory, $fileName);
             $fileName = str_replace('{APPLICATION_DIR}', $moduleBaseDirectory, $fileName);
             $fileName = str_replace('{TABLE_CAMEL_NAME}', $tableDefinition['baseClassName'], $fileName);
             $fileName = str_replace('{TABLE_CONTROLLER_NAME}', $tableDefinition['controllerName'], $fileName);
             $this->_createFile($fileName, $code, $forceOverriding ? true : $canOverride);
         }
     }
 }
Ejemplo n.º 30
0
 public function testZF6521_NoDoubleQuoutesInValue()
 {
     $config = new Zend_Config(array('default' => array('test' => 'fo"o')));
     try {
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $this->_tempName));
         $writer->write();
         $this->fail('An expected Zend_Config_Exception has not been raised');
     } catch (Zend_Config_Exception $expected) {
         $this->assertContains('Value can not contain double quotes "', $expected->getMessage());
     }
 }