Esempio n. 1
0
 /**
  * Returns the value of the cache config attribute or throws an exception,
  * in case the attribute is not given within the attributes array.
  *
  * @param string $name The name of the desired attribute.
  *
  * @return string Value of the attribute.
  * @throws InvalidArgumentException In case the desired attribute is not defined.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 24.11.2008<br />
  */
 protected function getConfigAttribute($name)
 {
     $value = $this->configuration->getValue($name);
     if ($value == null) {
         $env = Registry::retrieve('APF\\core', 'Environment');
         throw new InvalidArgumentException('[' . get_class($this) . '::getConfigAttribute()] The configuration directive "' . $name . '" is not present or empty. ' . 'Please check your cache configuration ("' . $env . '_cacheconfig.ini") for namespace ' . '"APF\\tools\\cache" and context "' . $this->getContext() . '" or consult the documentation!', E_USER_ERROR);
     }
     return $value;
 }
Esempio n. 2
0
 /**
  * Implements the init() method used by the service manager. Initializes the cache
  * manager with the corresponding cache configuration section.
  *
  * @param Configuration $initParam The desired cache config section.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 21.11.2008<br />
  * Version 0.2, 22.11.2008 (Refactored due to fabric introduction.)<br />
  * Version 0.3, 24.11.2008 (Refactoring due to discussions on the fusion of writers and readers)<br />
  * Version 0.4, 24.06.2014 (ID#207: Refactoring due to separation of attribute handling from APFObject)<br />
  */
 public function init($initParam)
 {
     $class = $initParam->getValue('Provider');
     /* @var $provider CacheProvider */
     $provider = $this->getServiceObject($class, [], APFService::SERVICE_TYPE_NORMAL);
     // inject configuration
     $provider->setConfiguration($initParam);
     $this->provider = $provider;
     // map the active configuration key
     $active = $initParam->getValue('Active');
     if ($active == 'true') {
         $this->active = true;
     }
 }
Esempio n. 3
0
 /**
  * Erzeugt den JS Code zum Prüfen des MimeType
  *
  * @return string
  *
  * @author dave
  * @version 1.0, 14.07.2012
  */
 private function createMimeTypeCheck()
 {
     return '
      var regexp = ' . $this->createFileExtensionForJS($this->manager->getMimeTypes()) . ';
      if (!regexp.test(files[index].name)) {
         $(".filetype_dialog").dialog({
            modal: true,height:220,width:300,
            buttons: {
               "' . $this->languageConfig->getValue('filetype.ok') . '": function() {
                  $(this).dialog("close");
               }
            }
         });
      handler.uploadRow.remove();
      return;
      }';
 }
Esempio n. 4
0
 /**
  * Generates a package from it's single files.
  * Will Shrink output, if enabled.
  *
  * @param Configuration $cfgPack The package configuration
  * @param string $name The package name
  *
  * @return string All files put together to one string.
  *
  * @author Ralf Schubert
  * @version
  * Version 1.0, 18.03.2010<br />
  * Version 1.1, 05.11.2010 (Fixed Bug, caused by incompatible use of new configuration methods)<br />
  */
 protected function generatePackage(Configuration $cfgPack, $name)
 {
     $output = '';
     $files = $cfgPack->getSection('Files');
     foreach ($files->getSectionNames() as $fileSectionName) {
         $file = $files->getSection($fileSectionName);
         $output .= $this->loadSingleFile($file->getValue('Namespace'), $file->getValue('Filename'), $cfgPack->getValue('PackageType'), $name);
     }
     if ($cfgPack->getValue('EnableShrinking') === 'true') {
         switch ($cfgPack->getValue('PackageType')) {
             case 'js':
                 $output = $this->shrinkJs($output);
                 break;
             case 'css':
                 $output = $this->shrinkCSS($output);
                 break;
         }
     }
     $this->initFilterChain($cfgPack->getValue('PackageType'));
     $output = JsCssInclusionFilterChain::getInstance()->filter($output);
     return $output;
 }
 private function generateComplexConfigValue(Configuration $config, $currentName)
 {
     $buffer = '';
     // append simple values
     foreach ($config->getValueNames() as $name) {
         $value = $config->getValue($name);
         if (is_array($value)) {
             foreach ($value as $element) {
                 $buffer .= $currentName . '.' . $name . '[] = "' . $element . '"' . PHP_EOL;
             }
         } else {
             $buffer .= $currentName . '.' . $name . ' = "' . $value . '"' . PHP_EOL;
         }
     }
     // append sections
     foreach ($config->getSectionNames() as $name) {
         $buffer .= $this->generateComplexConfigValue($config->getSection($name), $currentName . '.' . $name);
     }
     return $buffer;
 }
 protected function processValues(&$output, Configuration $config, $indention)
 {
     $valueNames = $config->getValueNames();
     $valuesCount = count($valueNames);
     $i = 1;
     foreach ($valueNames as $valueName) {
         $this->processValue($output, $valueName, $config->getValue($valueName), $indention, $valuesCount == $i);
         $i++;
     }
 }
 /**
  * Resolves the configuration abstraction to the array meta format concerning one section.
  *
  * @param Configuration $config The config to resolve.
  *
  * @return array The meta structure of the given configuration representation.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 07.11.2010<br />
  */
 private function resolveSection(Configuration $config)
 {
     $rawConfig = [];
     foreach ($config->getValueNames() as $name) {
         $rawConfig[$name] = $config->getValue($name);
     }
     foreach ($config->getSectionNames() as $name) {
         $rawConfig[$name] = $this->resolveSection($config->getSection($name));
     }
     return $rawConfig;
 }
 /**
  * Transforms a given config section into the applied xml structure.
  *
  * @param SimpleXMLElement $xml The parent XML node.
  * @param Configuration $config The current section to translate.
  * @param string $name The name of the section to add.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 28.10.2010<br />
  */
 private function processSection(SimpleXMLElement &$xml, Configuration $config, $name)
 {
     // create current section and append it to the parent node structure.
     $section = $xml->addChild('section');
     $section->addAttribute('name', $name);
     // add values
     foreach ($config->getValueNames() as $valueName) {
         $property = $section->addChild('property', $config->getValue($valueName));
         $property->addAttribute('name', $valueName);
     }
     // add sections recursively
     foreach ($config->getSectionNames() as $sectionName) {
         $this->processSection($section, $config->getSection($sectionName), $sectionName);
     }
 }