コード例 #1
0
 /**
  * Gets the form value for the available locales options
  * @param \ride\library\cms\node\Node $node
  * @return array
  */
 protected function getLocalesValueFromNode(Node $node)
 {
     $value = array();
     $availableLocales = $node->get(Node::PROPERTY_LOCALES, '', false);
     if ($availableLocales == Node::LOCALES_ALL || !$availableLocales && !$node->hasParent()) {
         $value[Node::LOCALES_ALL] = Node::LOCALES_ALL;
     } elseif ($availableLocales && $availableLocales != Node::LOCALES_ALL) {
         $locales = explode(NodeProperty::LIST_SEPARATOR, $availableLocales);
         $value = array();
         foreach ($locales as $locale) {
             $locale = trim($locale);
             $value[$locale] = $locale;
         }
     } else {
         $value[self::OPTION_INHERITED] = self::OPTION_INHERITED;
     }
     return $value;
 }
コード例 #2
0
ファイル: Node.php プロジェクト: janhenckens/ride-lib-cms
 /**
  * Parses the widget from the provided section string
  * @param string $section String to define the widgets in a section
  * eg. [12,4,87],[43,2]
  * @return array Array with the block id as key and as value an array with the
  * widget instance id as key and the widget id as value
  */
 public function parseSectionString(Node $site, $sectionString)
 {
     $blocks = array();
     $blocksWidgetIds = explode(self::BLOCK_CLOSE . NodeProperty::LIST_SEPARATOR . self::BLOCK_OPEN, $sectionString);
     foreach ($blocksWidgetIds as $block => $blockWidgetIds) {
         $block++;
         // start from 1 instead of 0
         $blocks[$block] = array();
         $blockWidgetIds = trim($blockWidgetIds, self::BLOCK_OPEN . self::BLOCK_CLOSE . ' ');
         if (!$blockWidgetIds) {
             continue;
         }
         $widgetIds = explode(NodeProperty::LIST_SEPARATOR, $blockWidgetIds);
         foreach ($widgetIds as $widgetId) {
             $widgetId = trim($widgetId);
             $blocks[$block][$widgetId] = $site->get(self::PROPERTY_WIDGET . '.' . $widgetId);
         }
     }
     return $blocks;
 }
コード例 #3
0
 /**
  * Get a suffix for the security inherit label based on the inherited settings
  * @param \ride\library\cms\node\Node $node
  * @param \ride\library\i18n\translator\Translator $translator
  * @return string if a publish setting is found the suffix will be " (Yes)" or " (No)"
  */
 protected function getSecurityInheritSuffix(Node $node, Translator $translator)
 {
     $security = $node->get(Node::PROPERTY_SECURITY, Node::AUTHENTICATION_STATUS_EVERYBODY, true, true);
     $suffix = ' (';
     switch ($security) {
         case Node::AUTHENTICATION_STATUS_EVERYBODY:
             $suffix .= $translator->translate('label.allow.everybody');
             break;
         case Node::AUTHENTICATION_STATUS_ANONYMOUS:
             $suffix .= $translator->translate('label.allow.anonymous');
             break;
         case Node::AUTHENTICATION_STATUS_AUTHENTICATED:
             $suffix .= $translator->translate('label.allow.authenticated');
             break;
         default:
             $suffix .= $security;
             break;
     }
     $suffix .= ')';
     return strtolower($suffix);
 }
コード例 #4
0
 /**
  * Gets the inherited cache options
  * @param \ride\library\cms\node\Node $parentNode
  * @param \ride\library\i18n\translator\Translator $translator
  * @param $locale
  *
  * @return string
  */
 protected function getInheritedCacheOption(Node $parentNode, Translator $translator, $locale)
 {
     $value = $parentNode->get('cache.target', null, true, true);
     $maxAge = $parentNode->getHeader($locale, 'max-age');
     $sharedMaxAge = $parentNode->getHeader($locale, 's-maxage');
     if (empty($value)) {
         return "";
     }
     $suffix = ' (';
     $suffix .= $translator->translate('label.cache.target.' . $value);
     $suffix .= in_array($value, array('inherit', 'all')) ? ', ' . $translator->translate('label.header.maxage') . ': ' . $translator->translate('label.cache.time.' . $maxAge) : null;
     $suffix .= in_array($value, array('inherit', 'intermediate', 'all')) ? ', ' . $translator->translate('label.header.smaxage') . ': ' . $translator->translate('label.cache.time.' . $sharedMaxAge) : null;
     $suffix .= ')';
     return $suffix;
 }
コード例 #5
0
 /**
  * Validates the publication dates
  * @param \ride\library\cms\node\Node $node Node to be validated
  * @param \ride\library\validation\exception\ValidationException $exception
  * @return null
  */
 protected function validatePublicationDate(Node $node, ValidationException $exception)
 {
     $publishStart = $node->get(Node::PROPERTY_PUBLISH_START, null, false);
     $publishStop = $node->get(Node::PROPERTY_PUBLISH_STOP, null, false);
     $isPublishStartEmpty = empty($publishStart);
     $isPublishStopEmpty = empty($publishStop);
     if (!$isPublishStartEmpty) {
         $this->validateDate($publishStart, $exception, Node::PROPERTY_PUBLISH_START);
     }
     if (!$isPublishStopEmpty) {
         $this->validateDate($publishStop, $exception, Node::PROPERTY_PUBLISH_STOP);
     }
     if (!$isPublishStartEmpty && !$isPublishStopEmpty && $publishStart >= $publishStop) {
         $error = new ValidationError('error.date.publish.negative', 'Publish stop date cannot be before the publish start date');
         $exception->addErrors(Node::PROPERTY_PUBLISH_STOP, array($error));
     }
 }
コード例 #6
0
 /**
  * Get a setting value for the widget
  * @param string $key key of the setting
  * @param mixed $default default value for when the setting is not set
  * @return mixed setting value of $default if the setting was not set
  */
 public function getWidgetProperty($key, $default = null)
 {
     return $this->node->get($this->widgetPropertyPrefix . $key, $default);
 }