<?php
-class Fluidbook_Form_CMS_Sub_Features_Feature extends CubeIT_Form_SubForm {
-
- public function init() {
- parent::init();
-
- $title = new CubeIT_Form_Element_Text('title');
- $title->setLabel('Titre du bloc');
- $this->addElement($title);
-
- $content = new CubeIT_Form_Element_Markitup('content');
- $content->setLabel('Contenus');
- $this->addElement($content);
-
- $icon = new Fluidbook_Form_Element_Picto('icon');
- $icon->setLabel('Pictogramme reference (CSS class)');
- $this->addElement($icon);
-
- $bg_gradient = new Fluidbook_Form_CMS_Sub_Gradient();
- $bg_gradient->setLegend('Background Gradient');
- $this->addSubForm($bg_gradient, 'background_gradient');
-
- $bg_image = new CubeIT_Form_Element_File_Image('background_image');
- $bg_image->setLabel('Background Image');
- $this->addElement($bg_image);
-
- $layout = new Zend_Form_Element_Select('layout');
- $layout->setLabel('Layout');
- $layout->setMultiOptions(array(
- 'square-top' => 'Square block with image top',
- 'square-bottom' => 'Square block with image bottom',
- 'rectangle-right' => 'Large rectangle with image right',
- 'rectangle-bottom' => 'Large rectangle with image bottom',
- 'small-rectangle-tall' => 'Small rectangle (tall)',
- 'small-rectangle-wide' => 'Small rectangle (wide)',
- ));
- $this->addElement($layout);
-
- $link = new CubeIT_Form_Element_Link('link');
- $link->setLabel('Lien');
- $this->addSubForm($link, 'link');
- }
+class Fluidbook_Form_CMS_Sub_Features_Feature extends CubeIT_Form_SubForm
+{
+
+ public function init()
+ {
+ parent::init();
+
+ $title = new CubeIT_Form_Element_Text('title');
+ $title->setLabel('Titre du bloc');
+ $this->addElement($title);
+
+ $content = new CubeIT_Form_Element_Markitup('content');
+ $content->setLabel('Contenus');
+ $this->addElement($content);
+
+ $icon = new Fluidbook_Form_Element_Picto('icon');
+ $icon->setLabel('Pictogramme reference (CSS class)');
+ $this->addElement($icon);
+
+ $bg_gradient = new Fluidbook_Form_CMS_Sub_Gradient();
+ $bg_gradient->setLegend('Background Gradient');
+ $this->addSubForm($bg_gradient, 'background_gradient');
+
+ $textColor = new Zend_Form_Element_Select('text_color');
+ $textColor->setLabel('Text color');
+ $textColor->setMultiOptions(['auto' => 'Automatic',
+ 'light' => 'Light', 'dark' => 'Dark']);
+ $this->addElement($textColor);
+
+ $bg_image = new CubeIT_Form_Element_File_Image('background_image');
+ $bg_image->setLabel('Background Image');
+ $this->addElement($bg_image);
+
+ $layout = new Zend_Form_Element_Select('layout');
+ $layout->setLabel('Layout');
+ $layout->setMultiOptions(array(
+ 'square-top' => 'Square block with image top',
+ 'square-bottom' => 'Square block with image bottom',
+ 'rectangle-right' => 'Large rectangle with image right',
+ 'rectangle-bottom' => 'Large rectangle with image bottom',
+ 'small-rectangle-tall' => 'Small rectangle (tall)',
+ 'small-rectangle-wide' => 'Small rectangle (wide)',
+ ));
+ $this->addElement($layout);
+
+ $link = new CubeIT_Form_Element_Link('link');
+ $link->setLabel('Lien');
+ $this->addSubForm($link, 'link');
+ }
}
\ No newline at end of file
<?php
-class Fluidbook_View_Helper_FeaturesSection extends CubeIT_View_Helper_Abstract {
-
- public function featuresSection($title, $blocks, $heading_element = 'h2') {
-
- $this->headScript()->addMasonry()->addJQueryTransform();
-
- $res = '<div class="content-wrapper grid wrap">';
- $res .= $this->title($title, $heading_element, array('class' => 'col-6'));
- $res .= '<div class="feature-blocks">';
-
- foreach ($blocks as $block) {
-
- // Generate ID for CSS
- $id = 'block-' . strtolower(CubeIT_Util_Text::str2URL($block['title']));
-
- // Text colour is based on whether block has a gradient or not
- $text_colour = $this->hasGradient($block) ? 'light' : 'dark';
-
- $res .= '<div class="feature-block text-' . $text_colour . ' ' . $block['layout'] . '" id="' . $id . '">';
- $link = $this->linkCMS($block['link'], ['class' => 'button']);
- if ($link) {
- $res .= $this->htmlElement($link, 'div', ['class' => 'more']);
- }
-
- $res .= $this->_CSS($id, $block);
-
- $res .= '<div class="feature-inner">';
-
- if (!empty($block['icon'])) {
- $res .= '<div class="feature-icon fb-' . $block['icon'] . '"></div>';
- }
-
- $res .= '<div class="feature-text">';
- $res .= '<h4 class="feature-title">' . $block['title'] . '</h4>';
- $res .= $this->markupDotclear($block['content']);
- $res .= '</div>'; // .feature-text
-
- $res .= '</div>'; // .feature-inner
- $res .= '</div>'; // .feature-block
- }
-
- $res .= '</div>'; // .feature-blocks
- $res .= '</div>'; // .content-wrapper
-
- return $res;
- }
-
- protected function hasGradient($block) {
- $gradient = $block['background_gradient'];
- return !(empty($gradient['color1']) || empty($gradient['color2']));
- }
-
- protected function hasBGImage($block) {
- return is_array($block['background_image']);
- }
-
- protected function _layoutData($layout) {
-
- switch ($layout) {
- case 'square-top':
- case 'square-bottom':
- $w = 2;
- $h = 2;
- break;
- case 'rectangle-right':
- case 'rectangle-bottom':
- $w = 3;
- $h = 2;
- break;
- case 'small-rectangle-tall':
- $w = 1;
- $h = 2;
- break;
- case 'small-rectangle-wide':
- $w = 2;
- $h = 1;
- }
-
- if (!$w || !$h)
- return '';
-
- return 'data-w="' . $w . '" data-h="' . $h . '"';
- }
-
- protected function _CSS($id, $block) {
- $res = '<style type="text/css">';
-
- $res .= "#$id {";
- $res .= $this->_backgroundColour($block);
-
- // Main CSS - block can have a bg image, a gradient, both or neither.
- if ($this->hasBGImage($block)) {
- $res .= $this->_backgroundImage($block);
- } elseif ($this->hasGradient($block)) {
- $res .= $this->_gradient($block);
- }
-
- $res .= '}';
-
- // 1 column version - swap background images for a gradient / solid colour
- $res .= '[data-cols="1"] #' . $id . ' {';
-
- if ($this->hasGradient($block)) {
- $res .= $this->_gradient($block);
- } else {
- $res .= 'background-image: none;';
- }
-
- $res .= '}';
- $res .= '</style>';
-
- return $res;
- }
-
- protected function _backgroundColour($block) {
- if (empty($block['background_gradient']['color1'])) {
- return '';
- }
-
- return 'background-color: ' . $block['background_gradient']['color1'] . ';';
- }
-
- protected function _backgroundImage($block) {
- if (!is_array($block['background_image']))
- return '';
-
- $path = CubeIT_View_Helper_ImageCms::getPath($block['background_image']);
-
- return "background-image: url('$path');";
- }
-
- protected function _gradient($block) {
-
- $gradient = $block['background_gradient'];
-
- if (empty($gradient['color1']) || empty($gradient['color2'])) {
- return '';
- }
-
- $angle = '45deg';
- $c1 = $gradient['color1'];
- $c2 = $gradient['color2'];
-
- return "background-image: -moz-linear-gradient($angle, $c1 0%, $c2 100%);
+class Fluidbook_View_Helper_FeaturesSection extends CubeIT_View_Helper_Abstract
+{
+
+ public function featuresSection($title, $blocks, $heading_element = 'h2')
+ {
+
+ $this->headScript()->addMasonry()->addJQueryTransform();
+
+ $res = '<div class="content-wrapper grid wrap">';
+ $res .= $this->title($title, $heading_element, array('class' => 'col-6'));
+ $res .= '<div class="feature-blocks">';
+
+ foreach ($blocks as $block) {
+
+ // Generate ID for CSS
+ $id = 'block-' . strtolower(CubeIT_Util_Text::str2URL($block['title']));
+
+ // Text colour is based on whether block has a gradient or not
+ $text_colour = (!isset($block['text_color']) || $block['text_color'] === 'auto') ? ($this->hasGradient($block) ? 'light' : 'dark') : $block['text_color'];
+
+ $res .= '<div class="feature-block text-' . $text_colour . ' ' . $block['layout'] . '" id="' . $id . '">';
+ $link = $this->linkCMS($block['link'], ['class' => 'button']);
+ if ($link) {
+ $res .= $this->htmlElement($link, 'div', ['class' => 'more']);
+ }
+
+ $res .= $this->_CSS($id, $block);
+
+ $res .= '<div class="feature-inner">';
+
+ if (!empty($block['icon'])) {
+ $res .= '<div class="feature-icon fb-' . $block['icon'] . '"></div>';
+ }
+
+ $res .= '<div class="feature-text">';
+ $res .= '<h4 class="feature-title">' . $block['title'] . '</h4>';
+ $res .= $this->markupDotclear($block['content']);
+ $res .= '</div>'; // .feature-text
+
+ $res .= '</div>'; // .feature-inner
+ $res .= '</div>'; // .feature-block
+ }
+
+ $res .= '</div>'; // .feature-blocks
+ $res .= '</div>'; // .content-wrapper
+
+ return $res;
+ }
+
+ protected function hasGradient($block)
+ {
+ $gradient = $block['background_gradient'];
+ if (empty($gradient['color1']) && empty($gradient['color2'])) {
+ return false;
+ }
+ $c1 = mb_strtolower($gradient['color1']);
+ $c2 = mb_strtolower($gradient['color2']);
+ if ($c1 === $c2) {
+ return false;
+ }
+ return true;
+ }
+
+ protected function hasBGImage($block)
+ {
+ return is_array($block['background_image']);
+ }
+
+ protected function _layoutData($layout)
+ {
+
+ switch ($layout) {
+ case 'square-top':
+ case 'square-bottom':
+ $w = 2;
+ $h = 2;
+ break;
+ case 'rectangle-right':
+ case 'rectangle-bottom':
+ $w = 3;
+ $h = 2;
+ break;
+ case 'small-rectangle-tall':
+ $w = 1;
+ $h = 2;
+ break;
+ case 'small-rectangle-wide':
+ $w = 2;
+ $h = 1;
+ }
+
+ if (!$w || !$h)
+ return '';
+
+ return 'data-w="' . $w . '" data-h="' . $h . '"';
+ }
+
+ protected function _CSS($id, $block)
+ {
+ $res = '<style type="text/css">';
+
+ $res .= "#$id {";
+ $res .= $this->_backgroundColour($block);
+
+ // Main CSS - block can have a bg image, a gradient, both or neither.
+ if ($this->hasBGImage($block)) {
+ $res .= $this->_backgroundImage($block);
+ } elseif ($this->hasGradient($block)) {
+ $res .= $this->_gradient($block);
+ }
+
+ $res .= '}';
+
+ // 1 column version - swap background images for a gradient / solid colour
+ $res .= '[data-cols="1"] #' . $id . ' {';
+
+ if ($this->hasGradient($block)) {
+ $res .= $this->_gradient($block);
+ } else {
+ $res .= 'background-image: none;';
+ }
+
+ $res .= '}';
+ $res .= '</style>';
+
+ return $res;
+ }
+
+ protected function _backgroundColour($block)
+ {
+ if (empty($block['background_gradient']['color1'])) {
+ return '';
+ }
+
+ return 'background-color: ' . $block['background_gradient']['color1'] . ';';
+ }
+
+ protected function _backgroundImage($block)
+ {
+ if (!is_array($block['background_image']))
+ return '';
+
+ $path = CubeIT_View_Helper_ImageCms::getPath($block['background_image']);
+
+ return "background-image: url('$path');";
+ }
+
+ protected function _gradient($block)
+ {
+
+ $gradient = $block['background_gradient'];
+
+ if (empty($gradient['color1']) || empty($gradient['color2'])) {
+ return '';
+ }
+
+ $angle = '45deg';
+ $c1 = $gradient['color1'];
+ $c2 = $gradient['color2'];
+
+ return "background-image: -moz-linear-gradient($angle, $c1 0%, $c2 100%);
background-image: -webkit-linear-gradient($angle, $c1 0%, $c2 100%);
background-image: linear-gradient($angle, $c1 0%, $c2 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='$c1', endColorstr='$c2',GradientType=1);";
- }
+ }
}