Example #1
0
 protected function managementForm($widgetData = array())
 {
     $form = new \Ip\Form();
     $form->setEnvironment('admin');
     $form->addField(new \Ip\Form\Field\Hidden(array('name' => 'aa', 'value' => 'Block.checkForm', 'validator' => array("Required"))));
     $fieldset = new \Ip\Form\Fieldset();
     $fieldset->addField(new \Ip\Form\Field\Color(array('label' => __('Text Color', 'Block'), 'name' => 'color', 'validator' => array("Required"), 'value' => isset($widgetData['color']) ? $widgetData['color'] : ipGetThemeOption('ipTextColor', '000000'))));
     $form->addFieldset($fieldset);
     $fieldset = new \Ip\Form\Fieldset("Background");
     $fieldset->addField(new \Ip\Form\Field\Color(array('label' => __('Background color', 'Block'), 'name' => 'background_color', 'validator' => array("Required"), 'value' => isset($widgetData['background_color']) ? $widgetData['background_color'] : 'dedede')));
     $fieldset->addField(new \Ip\Form\Field\Number(array('label' => __('Background color transparency in percent', 'Block'), 'name' => 'transparency', 'validator' => array("Required"), 'value' => isset($widgetData['transparency']) ? $widgetData['transparency'] : 0)));
     $fieldset->addField(new \Ip\Form\Field\Checkbox(array('label' => __('Background image', 'Block'), 'name' => 'show_background_image', 'validator' => array("Required"), 'value' => isset($widgetData['show_background_image']) ? $widgetData['show_background_image'] : false)));
     $fieldset->addField(new \Ip\Form\Field\Hidden(array('name' => 'background_image', 'value' => isset($widgetData['background_image']) ? $widgetData['background_image'] : null)));
     $fieldset->addField(new \Ip\Form\Field\Info(array('html' => ' <div class="ipsEditScreen"></div>')));
     $form->addFieldset($fieldset);
     $fieldset = new \Ip\Form\Fieldset("Advanced");
     $fieldset->addField(new \Ip\Form\Field\Checkbox(array('label' => __('Fixed background', 'Block'), 'name' => 'fixed_background', 'validator' => array("Required"), 'value' => isset($widgetData['fixed_background']) ? $widgetData['fixed_background'] : false, 'hint' => __('Fixed background image will be fixed to viewport causing parallax effect.', 'Block'))));
     $fieldset->addField(new \Ip\Form\Field\Checkbox(array('label' => __('Blur background image', 'Block'), 'name' => 'blur_background_image', 'validator' => array("Required"), 'value' => isset($widgetData['blur_background_image']) ? $widgetData['blur_background_image'] : false)));
     $fieldset->addField(new \Ip\Form\Field\Number(array('label' => __('Blur radius(pixels)', 'Block'), 'name' => 'blur_radius', 'validator' => array("Required"), 'value' => isset($widgetData['blur_radius']) ? $widgetData['blur_radius'] : 5)));
     $fieldset->addField(new \Ip\Form\Field\Checkbox(array('label' => __('Text shadow', 'Block'), 'name' => 'text_shadow', 'validator' => array("Required"), 'value' => isset($widgetData['text_shadow']) ? $widgetData['text_shadow'] : false)));
     $values = array(array('cover', 'Cover'), array('contain', 'Contain'), array('auto', 'Auto'), array('100% auto', 'Fit width'), array('auto 100%', 'Fit height'));
     $fieldset->addField(new \Ip\Form\Field\Select(array('label' => __('Background size', 'Block'), 'name' => 'background_size', 'values' => $values, 'value' => isset($widgetData['background_size']) ? $widgetData['background_size'] : 'cover', 'hint' => __('Cover: Scale the background image to be as large as possible so that the background area is completely covered by the background image. Some parts of the background image may not be in view within the background positioning area. Contain: Scale the image to the largest size such that both its width and its height can fit inside the content area. Auto: The background-image contains its width and height. Fit width: will scale image to match width. Fit height: will scale image to match height.', 'Block'))));
     $fieldset->addField(new \Ip\Form\Field\Checkbox(array('label' => __('Background repeat', 'Block'), 'name' => 'background_repeat', 'validator' => array("Required"), 'value' => isset($widgetData['background_repeat']) ? $widgetData['background_repeat'] : true)));
     $fieldset->addField(new \Ip\Form\Field\Number(array('label' => __('Image width', 'Block'), 'hint' => __('If you want to optimize background image you can change the size of it. Beware that big images slows down page load speed, but small images will look bad if background is big. You can try to change size, repeat and blur to improve quality of lower resolution images.', 'Block'), 'name' => 'width', 'validator' => array("Required"), 'value' => isset($widgetData['width']) ? $widgetData['width'] : 960)));
     $fieldset->addField(new \Ip\Form\Field\Number(array('label' => __('Image height', 'Block'), 'name' => 'height', 'validator' => array("Required"), 'value' => isset($widgetData['height']) ? $widgetData['height'] : 640)));
     $form->addFieldset($fieldset);
     return $form;
 }
Example #2
0
 public static function ipPagePropertiesForm($form, $data)
 {
     $fieldset = new \Ip\Form\Fieldset(__('Glori options', 'Glori'));
     $fieldset->addField(new Field\BreadCrumb(array('name' => 'magellan_original_page', 'label' => __('Original page', 'Glori'), 'value' => ipPageStorage($data['pageId'])->get('magellan_original_page', null), 'note' => __('Target page with content.', 'Glori'))));
     $fieldset->addField(new \Ip\Form\Field\Text(array('name' => 'magellan_anchor', 'label' => __('Anchor', 'Glori'), 'value' => ipPageStorage($data['pageId'])->get('magellan_anchor', ''), 'note' => __('Anchor marking the start of content in page. Add exact anchor to heading widget(in options) or in background widget(options) in Original page marking start of the content', 'Glori'))));
     $form->addFieldset($fieldset);
     return $form;
 }
Example #3
0
 /**
  * @param $options
  * @return Form\Fieldset
  */
 protected function getFieldset($themeName, $options)
 {
     $fieldset = new \Ip\Form\Fieldset();
     foreach ($options as $option) {
         if (empty($option['type']) || empty($option['name'])) {
             continue;
         }
         switch ($option['type']) {
             case 'select':
             case 'Select':
                 $newField = new Form\Field\Select();
                 $values = array();
                 if (!empty($option['values']) && is_array($option['values'])) {
                     foreach ($option['values'] as $value) {
                         $values[] = array($value, $value);
                     }
                 }
                 $newField->setValues($values);
                 break;
             case 'text':
             case 'Text':
                 $newField = new Form\Field\Text();
                 break;
             case 'textarea':
             case 'Textarea':
                 $newField = new Form\Field\Textarea();
                 break;
             case 'color':
             case 'Color':
                 $newField = new Form\Field\Color();
                 break;
             case 'range':
             case 'Range':
                 $newField = new Form\Field\Range();
                 break;
             case 'checkbox':
             case 'Checkbox':
                 $newField = new Form\Field\Checkbox();
                 break;
             default:
                 $class = 'Ip\\Form\\Field\\' . $option['type'];
                 if (!class_exists($class)) {
                     $class = $option['type'];
                 }
                 if (class_exists($class)) {
                     $newField = new $class();
                     if ($option['type'] == 'RepositoryFile') {
                         $newField->setFileLimit(1);
                     }
                     if (method_exists($newField, 'setValues') && isset($option['values'])) {
                         $newField->setValues($option['values']);
                     }
                 } else {
                     $newField = new Form\Field\Text();
                 }
         }
         if (!isset($newField)) {
             //field type is not recognised
             continue;
         }
         if (!empty($option['note'])) {
             $newField->setNote($option['note']);
         }
         $newField->setName($option['name']);
         $newField->setLabel(empty($option['label']) ? '' : $option['label']);
         $default = isset($option['default']) ? $option['default'] : null;
         $newField->setValue($this->getConfigValue($themeName, $option['name'], $default));
         $fieldset->addfield($newField);
     }
     return $fieldset;
 }