Exemplo n.º 1
0
 public function listAction()
 {
     $console = $this->getServiceLocator()->get('console');
     $sm = $this->getServiceLocator();
     $isLocal = $this->params()->fromRoute('local');
     if ($isLocal) {
         $appdir = getcwd();
         echo $appdir;
         if (file_exists($appdir . '/config/autoload/local.php')) {
             $config = (include $appdir . '/config/autoload/local.php');
         } else {
             echo 'FILE NO EXIST' . PHP_EOL;
             $config = array();
         }
     } else {
         $config = $sm->get('Configuration');
     }
     if (!is_array($config)) {
         $config = ArrayUtils::iteratorToArray($config, true);
     }
     $console->writeLine('Configuration:', Color::GREEN);
     // print_r($config);
     $ini = new IniWriter();
     echo $ini->toString($config);
 }
Exemplo n.º 2
0
 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getParam("application");
     //Este fragmento de código se usa cuando hay instalador
     $reader = new Ini();
     $data = $reader->fromFile(__DIR__ . '/config/config.ini');
     $appInstalada = false;
     if ($data['production']['configuracion']['instalado'] == "0") {
         $app->getEventManager()->attach('dispatch', array($this, 'initInstalacion'), 20000);
         $config = new Config(array(), true);
         $config->production = array();
         $config->production->configuracion = array();
         $config->production->configuracion->instalado = "-1";
         $config->production->configuracion->confirmado = "0";
         $writer = new Ini2();
         $writer->toFile(__DIR__ . '/config/config.ini', $config);
     } elseif ($data['production']['configuracion']['instalado'] == "-1") {
         return;
     } else {
         $appInstalada = true;
     }
     if ($appInstalada) {
         $app->getEventManager()->attach('dispatch', array($this, 'initAuth'), 200);
     }
     $moduleRouteListener = new ModuleRouteListener();
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener->attach($eventManager);
 }
Exemplo n.º 3
0
 /**
  * Write data to label file
  *
  * @param    String        $network
  * @param    String        $locale
  * @param    Array[]        $data
  * @return    String        Path to file
  */
 public function write($network, $locale, array $data)
 {
     $data = $this->convertData($data);
     $config = new Config($data, false);
     $writer = new IniWriter();
     $pathFile = $this->buildPath($network, $locale);
     $writer->toFile($pathFile, $config);
     return $pathFile;
 }
Exemplo n.º 4
0
 /**
  * (non-PHPdoc)
  * 
  * @see \Zend\Stdlib\Hydrator\Strategy\StrategyInterface::extract()
  */
 public function extract($value)
 {
     if (true === isset($value['params']) && true === is_array($value['params'])) {
         $config = new IniWriter();
         $config->setRenderWithoutSectionsFlags(true);
         $value['params'] = $config->toString($value['params']);
     } else {
         $value['params'] = '';
     }
     return $value;
 }
Exemplo n.º 5
0
 /**
  * Save configuration file
  *
  * @param    Array    $data
  * @param    String    $filename
  * @return    String
  * @throws    \Exception
  */
 public function saveConfigFile(array $data, $filename)
 {
     $pathFile = $this->basePath . '/' . $filename . '.ini';
     $pathDir = dirname($pathFile);
     $dirStatus = is_dir($pathDir) || mkdir($pathDir, 0777, true);
     if (!$dirStatus) {
         throw new \Exception('Cannot create config folder ' . $filename);
     }
     $data = $this->cleanData($data);
     $config = new Config($data, false);
     $writer = new IniWriter();
     $writer->toFile($pathFile, $config);
     return $pathFile;
 }
Exemplo n.º 6
0
 /**
  * @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 Exception\RuntimeException('A configuration already exists; cannot create a new one');
     }
     $homeDirectory = $this->_detectHomeDirectory();
     $writer = new IniConfigWriter();
     $writer->setRenderWithoutSections();
     $filename = $homeDirectory . '/.zf.ini';
     $config = array('php' => array('include_path' => get_include_path()));
     $writer->write($filename, new Configuration($config));
     $resp = $this->_registry->getResponse();
     $resp->appendContent("Successfully written Zend Tool config.");
     $resp->appendContent("It is located at: " . $filename);
 }
Exemplo n.º 7
0
 /**
  * @param int $id
  * @return int
  * @throws UthandoException
  */
 public function sendMessage($id)
 {
     $message = $this->getById($id);
     if ($message->isSent()) {
         throw new UthandoException('Cannot send message out again.');
     }
     // we need to set the server url before add to mail queue
     $serverUrlHelper = $this->getService('ViewHelperManager')->get('ServerUrl');
     $basePathUrlHelper = $this->getService('ViewHelperManager')->get('BasePath');
     $serverUrl = $serverUrlHelper() . $basePathUrlHelper();
     $iniReader = new IniReader();
     $iniWriter = new IniWriter();
     $params = $iniReader->fromString($message->getParams());
     $params['server_url'] = $serverUrl;
     $message->setParams($iniWriter->toString($params));
     $viewModel = new NewsletterModel();
     $viewModel->setTemplate('message/' . $message->getMessageId());
     /* @var $subscriptionMapper SubscriptionMapper */
     $subscriptionMapper = $this->getService('UthandoNewsletterSubscription')->getMapper();
     $subscriptions = $subscriptionMapper->getSubscriptionsByNewsletterId($message->getNewsletterId());
     $subscriberIds = [];
     /* @var $subscription SubscriptionModel */
     foreach ($subscriptions as $subscription) {
         $subscriberIds[] = $subscription->getSubscriberId();
     }
     /* @var $subscriberMapper SubscriberMapper */
     $subscriberMapper = $this->getService('UthandoNewsletterSubscriber')->getMapper();
     $subscribers = $subscriberMapper->getSubscribersById($subscriberIds);
     $count = 0;
     /* @var $subscriber SubscriberModel */
     foreach ($subscribers as $subscriber) {
         $this->getEventManager()->trigger('mail.queue', $this, ['recipient' => ['name' => $subscriber->getName(), 'address' => $subscriber->getEmail()], 'layout' => $viewModel, 'body' => null, 'subject' => $message->getSubject(), 'renderer' => 'ViewNewsletterRenderer', 'transport' => 'default']);
         $count++;
     }
     // set message as sent and save to database.
     $message->setDateSent(null)->setSent(true);
     $this->save($message);
     return $count;
 }
Exemplo n.º 8
0
 /**
  * Save a setting into translation.ini
  * @param $section
  * @param $subsection
  * @param $value
  */
 public function setConfig($section, $subsection, $value)
 {
     $cfg = $this->getConfig();
     if (!isset($cfg->{$section})) {
         $cfg->{$section} = [];
     }
     if ($subsection) {
         $cfg->{$section}->{$subsection} = $value;
     } else {
         $cfg->{$section} = $value;
     }
     $config = $this->getServiceLocator()->get('config');
     $config = $config['circlical']['translation_editor'];
     $cache_dir = $config['cache_dir'];
     $translator_config = $cache_dir . '/translator.ini';
     if (!file_exists($translator_config)) {
         @mkdir(dirname($translator_config), 0755, true);
         @touch($translator_config);
     }
     $writer = new ConfigWriter();
     $writer->toFile($translator_config, $cfg, false);
 }
Exemplo n.º 9
0
 /**
  * Saves all target data
  * @param array $data associative array with all targets.
  *               - key - name of the the target
  *               - value - target properties
  *
  * @throws ConfigException
  */
 public function save(array $data)
 {
     $config = new ConfigWriter();
     return $config->toFile($this->configFile, $data);
 }
Exemplo n.º 10
0
    /**
     * @group ZF-6289
     */
    public function testZF6289_NonSectionElementsAndSectionJumbling()
    {
        $config = new \Zend\Config\Config(array(
            'one'   => 'element',
            'two'   => array('type' => 'section'),
            'three' => 'element',
            'four'  => array('type' => 'section'),
            'five'  => 'element'
        ));
        
        $writer = new \Zend\Config\Writer\Ini;
        $iniString = $writer->setConfig($config)->render($config);
        
        $expected = <<<ECS
one = "element"
three = "element"
five = "element"
[two]
type = "section"

[four]
type = "section"


ECS;
        
        $this->assertEquals(
            $expected,
            $iniString
        );
    }
Exemplo n.º 11
0
    /**
     * @group ZF-6521
     */
    public function testNoDoubleQuoutesInValue()
    {
        $config = new Config(array('default' => array('test' => 'fo"o')));

        $this->setExpectedException('Zend\Config\Exception\RuntimeException', 'Value can not contain double quotes');
        $writer = new Ini(array('config' => $config, 'filename' => $this->_tempName));
        $writer->write();
    }
Exemplo n.º 12
0
 /**
  * Get configuration by key
  */
 public function getAction()
 {
     // check for help mode
     if ($this->requestOptions->getFlagHelp()) {
         return $this->getHelp();
     }
     // output header
     $this->consoleHeader('Fetching requested configuration');
     // get needed options to shorten code
     $path = realpath($this->requestOptions->getPath());
     $configName = $this->requestOptions->getConfigName();
     $flagLocal = $this->requestOptions->getFlagLocal();
     // check for config name
     if (!$configName) {
         return $this->sendError('config get <configName> was not provided');
     }
     // check for local file
     if ($flagLocal) {
         $configFile = $path . '/config/autoload/local.php';
         // check if local config file exists
         if (!file_exists($configFile)) {
             return $this->sendError('Local config file ' . $configFile . ' does not exist.');
         }
     } else {
         $configFile = $path . '/config/application.config.php';
     }
     // fetch config data
     $configData = (include $configFile);
     // check if local config file exists
     if (empty($configData)) {
         return $this->sendError('Config file ' . $configFile . ' is empty.');
     }
     // start output
     $this->console->write('       => Reading configuration file ');
     $this->console->writeLine($configFile, Color::GREEN);
     $this->console->writeLine();
     // find value in array
     $configValue = ModuleConfig::findValueInArray($configName, $configData);
     // start output
     $this->console->write(' Done ', Color::NORMAL, Color::CYAN);
     $this->console->write(' ');
     $this->console->write('Configuration data for key ');
     $this->console->writeLine($configName, Color::GREEN);
     $this->console->writeLine();
     // check config value
     if (is_array($configValue)) {
         $iniWriter = new IniWriter();
         $this->console->writeLine(str_pad('', $this->console->getWidth() - 1, '=', STR_PAD_RIGHT));
         $this->console->writeLine(trim($iniWriter->toString($configValue)));
         $this->console->writeLine(str_pad('', $this->console->getWidth() - 1, '=', STR_PAD_RIGHT));
     } elseif (is_null($configValue)) {
         $this->console->writeLine('       => NULL');
     } else {
         $this->console->writeLine('       => ' . $configValue);
     }
     // output footer
     $this->consoleFooter('requested configuration was successfully displayed');
 }
Exemplo n.º 13
0
 public function instalaAction()
 {
     // [TODO] probar este bloque if de redireccion
     if (!$this->request->isPost()) {
         return $this->redirect()->toRoute('login');
     }
     $form = new CreaEsquemaForm();
     $data = $this->request->getPost();
     $form->setData($data);
     if (!$form->isValid()) {
         echo 'fail';
         exit;
     }
     $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $instalacionBO = new InstalacionBO($adapter);
     $resultado = $instalacionBO->guardar($form->getData());
     // echo"<pre>";var_dump($resultado);exit();
     if ($resultado == 1) {
         $config = new Config(array(), true);
         $config->production = array();
         $config->production->configuracion = array();
         $config->production->configuracion->instalado = "1";
         $config->production->configuracion->confirmado = "1";
         $writer = new Ini2();
         $dir = str_replace("Instalacion\\src\\Instalacion\\Controller", "", __DIR__);
         $dir = str_replace("Instalacion/src/Instalacion/Controller", "", $dir);
         $writer->toFile($dir . 'Application/config/config.ini', $config);
         return $this->redirect()->toRoute('home');
     } else {
         echo 'laca';
         exit;
     }
 }
Exemplo n.º 14
0
 /**
  * Get the config writer that corresponds to the current config file type.
  *
  * @return ConfigWriter\AbstractFileWriter
  */
 protected function getConfigWriter()
 {
     $suffix = substr($this->getConfigFilepath(), -4);
     switch ($suffix) {
         case '.ini':
             $writer = new ConfigWriter\Ini();
             $writer->setRenderWithoutSections();
             break;
         case '.xml':
             $writer = new ConfigWriter\Xml();
             break;
         case '.php':
             $writer = new ConfigWriter\ArrayWriter();
             break;
         default:
             throw new Exception\RuntimeException(sprintf('Unknown config file type "%s" at location "%s"', $suffix, $this->getConfigFilepath()));
     }
     return $writer;
 }
Exemplo n.º 15
0
 /**
  * @param mixed  $data
  * @param string $format
  * @param array  $context
  *
  * @return string
  */
 public function encode($data, $format, array $context = array())
 {
     return $this->encoder->toString($data);
 }