/**
  * Returns a normalized array of the controller's helper names and configuration.
  * @return array
  */
 protected function getNormalizedHelpers()
 {
     if (isset($this->controller->helpers)) {
         return Hash::normalize((array) $this->controller->helpers);
     }
     return array();
 }
 private function replaceDefaultTaxonomySlug($url, $taxonomyDetails)
 {
     $localeCode = $this->currentLocale->getCode();
     if (Hash::check((array) $taxonomyDetails->i18n, "{$localeCode}.rewrite.slug")) {
         return Utility::replaceFirstOccurence(Hash::get($taxonomyDetails->i18n, "{$localeCode}.rewrite.slug"), $taxonomyDetails->rewrite['slug'], $url);
     }
     return $url;
 }
 /**
  * Overrides the default i18n function in order to use
  * our custom Locale object and have our own set of functions.
  * @return array
  */
 protected function rebuildLocaleList()
 {
     $app = Strata::app();
     $original = Hash::normalize($app->getConfig("i18n.locales"));
     $newLocales = array();
     foreach ($original as $key => $config) {
         $newLocales[$key] = new Locale($key, $config);
     }
     return $newLocales;
 }
 protected function removeLocalizedRoutedSlugs($route, $model)
 {
     if (!$this->currentLocale->isDefault() && is_array($model->routed)) {
         $key = "i18n." . $this->currentLocale->getCode() . ".rewrite";
         if (Hash::check($model->routed, $key)) {
             foreach (Hash::get($model->routed, $key) as $rewriteKey => $rewriteUrl) {
                 if (Hash::check($model->routed, "rewrite.{$rewriteKey}")) {
                     $defaultValue = Hash::get($model->routed, "rewrite.{$rewriteKey}");
                     $route = Utility::replaceFirstOccurence($rewriteUrl, $defaultValue, $route);
                 }
             }
         }
     }
     return $route;
 }
 protected function extractLocalizedInformation()
 {
     foreach ($this->getLocales() as $locale) {
         $localeCode = $locale->getCode();
         foreach ($this->model->routed['rewrite'] as $routeKey => $routeUrl) {
             $localizedUrl = $routeUrl;
             $localizedPath = "i18n.{$localeCode}.rewrite.{$routeKey}";
             if (Hash::check($this->model->routed, $localizedPath)) {
                 $localizedUrl = Hash::get($this->model->routed, $localizedPath);
             }
             $route = $this->createRouteFor($routeKey, $localizedUrl, array($localizedUrl, $routeUrl));
             $this->addRoute($route);
             $this->queueRewrite($localizedUrl, $this->defaultSlug, $locale);
         }
     }
 }
 protected function extractLocalizedInformation()
 {
     if ($this->modelSupportsRewrites()) {
         foreach ($this->getLocales() as $locale) {
             $localeCode = $locale->getCode();
             $localizedSlug = $this->model->hasConfig("i18n.{$localeCode}.rewrite.slug") ? $this->model->getConfig("i18n.{$localeCode}.rewrite.slug") : $this->defaultSlug;
             foreach ($this->model->routed['rewrite'] as $routeKey => $routeUrl) {
                 $localizedUrl = $routeUrl;
                 $localizedPath = "i18n.{$localeCode}.rewrite.{$routeKey}";
                 if (Hash::check($this->model->routed, $localizedPath)) {
                     $localizedUrl = Hash::get($this->model->routed, $localizedPath);
                 }
                 $this->addRoute($this->createRouteFor($localizedUrl, $localizedSlug));
                 $this->queueRewrite($localizedUrl, $localizedSlug, $locale);
             }
         }
     }
 }
Exemple #7
0
 /**
  * Returns whether the request contains uploaded files
  * @return boolean
  */
 public function hasFiles()
 {
     return Hash::check($this->_FILES, "data.name") && count($this->_FILES["data"]["name"]);
 }
 /**
  * Gets the associated taxonomy objects.
  * @return array
  */
 public function getTaxonomies()
 {
     $tax = array();
     foreach (Hash::normalize($this->belongs_to) as $taxonomyName => $taxonomyConfig) {
         if (class_exists($taxonomyName)) {
             $tax[] = new $taxonomyName();
         } else {
             $tax[] = Taxonomy::factory($taxonomyName);
         }
     }
     return $tax;
 }
 /**
  * Normalized the full list of attribute. This is not performed 'deep'.
  */
 private function normalizeAttributes()
 {
     $this->attributes = Hash::normalize($this->attributes);
 }
Exemple #10
0
 protected function getMergedHeaders()
 {
     $defaults = array('Content-Type' => 'text/html; charset=UTF-8', 'X-Mailer' => "PHP " . phpversion());
     return Hash::merge((array) $this->getConfig('headers'), $defaults);
 }
Exemple #11
0
 /**
  * Goes through the list of localization configurations values in Strata's
  * configuration file.
  * @return array A list of instantiated Locale object.
  */
 protected function parseLocalesFromConfig()
 {
     $localeInfos = Hash::normalize((array) Strata::config("i18n.locales"));
     $locales = array();
     foreach ($localeInfos as $key => $config) {
         $locales[$key] = new Locale($key, $config);
     }
     return $locales;
 }
 /**
  * Normalizes the configuration cache. This will only run once
  * on the object. It is mainly a safegard against a badly configured
  * value cache.
  * @return null
  */
 protected function normalizeConfiguration()
 {
     if (!$this->isConfigurableNormalized) {
         $this->configuration = Hash::normalize($this->configuration);
     }
 }
 /**
  * Loads ~/config/strata.php, cleans up the data and saves it as
  * the active configuration of the current instance of the Strata object.
  * @return  array Configuration array
  */
 public static function parseProjectConfigFile()
 {
     $configFile = self::getProjectConfigurationFilePath();
     if (file_exists($configFile)) {
         $strata = (include $configFile);
         if (isset($strata) && count($strata)) {
             return Hash::normalize($strata);
         }
     }
 }