Ejemplo n.º 1
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  * 
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     if (!empty($atts) and is_array($atts)) {
         if (!isset($atts['border_bottom_width_value_'])) {
             $atts['border_bottom_width_value_'] = '';
             $atts['border_bottom_style'] = '';
             $atts['border_bottom_color'] = '';
         }
         if (!isset($atts['padding_bottom_value_'])) {
             $atts['padding_bottom_value_'] = '';
         }
         if (!isset($attrs['font_size_value_'])) {
             $attrs['font_size_value_'] = '';
         }
     }
     // reload shortcode params: because we get Heading Text from "text" param
     JSNPagebuilderHelpersShortcode::generateShortcodeParams($this->items, NULL, $atts);
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $style = array();
     $exclude_params = array('tag', 'text', 'preview');
     $stylesheet = $font_style = '';
     // Override custom style
     if (!empty($arr_params) and is_array($arr_params)) {
         if ($arr_params['font'] == 'inherit' || $arr_params['font'] == 'Inherit') {
             unset($arr_params['font']);
             unset($arr_params['font_face_type']);
             unset($arr_params['font_face_value']);
             unset($arr_params['font_size_value_']);
             unset($arr_params['font_style']);
             unset($arr_params['color']);
         }
         if (isset($arr_params['font']) && $arr_params['font'] == 'custom') {
             unset($arr_params['font']);
             if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'bold') {
                 $arr_params['font_weight'] = '700';
                 unset($arr_params['font_style']);
             }
             if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'normal') {
                 $arr_params['font_weight'] = 'normal';
                 unset($arr_params['font_style']);
             }
         }
         if (isset($arr_params['font_size_value_']) && $arr_params['font_size_value_'] == '') {
             unset($arr_params['font_size_value_']);
         }
         if ($arr_params['border_bottom_width_value_'] == '') {
             unset($arr_params['border_bottom_width_value_']);
             unset($arr_params['border_bottom_style']);
             unset($arr_params['border_bottom_color']);
         }
         if ($arr_params['padding_bottom_value_'] == '') {
             unset($arr_params['padding_bottom_value_']);
         }
         if ($arr_params['text_align'] == 'inherit' || $arr_params['text_align'] == 'Inherit') {
             unset($arr_params['text_align']);
         }
     }
     foreach ($arr_params as $key => $value) {
         if ($value != '') {
             if ($key == 'font_face_type') {
                 if ($value == JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_FONT_STANDARD') || $value == 'standard fonts') {
                     $font_style = 'font-family:' . $arr_params['font_face_value'];
                 } else {
                     if ($value == JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_FONT_GOOGLE') || $value == 'google fonts') {
                         $document = JFactory::getDocument();
                         $document->addStyleSheet("http://fonts.googleapis.com/css?family={$arr_params['font_face_value']}", 'text/css');
                         $font_style = 'font-family:' . $arr_params['font_face_value'];
                     }
                 }
             } else {
                 if ($key != 'font_face_value') {
                     $key = JSNPagebuilderHelpersShortcode::removeTag($key);
                     if (!in_array($key, $exclude_params)) {
                         switch ($key) {
                             case 'border_bottom_width_value_':
                                 $style[$key] = 'border-bottom-width:' . $value . 'px';
                                 break;
                             case 'text_align':
                                 $style[$key] = 'text-align:' . $value;
                                 break;
                             case 'font_size_value_':
                                 $style[$key] = 'font-size:' . $value . 'px';
                                 break;
                             case 'font_style':
                                 $style[$key] = 'font-style:' . $value;
                                 break;
                             case 'border_bottom_style':
                                 $style[$key] = 'border-bottom-style:' . $value;
                                 break;
                             case 'border_bottom_color':
                                 $style[$key] = 'border-bottom-color:' . $value;
                                 break;
                             case 'padding_bottom_value_':
                                 $style[$key] = 'padding-bottom:' . $value . 'px';
                                 break;
                             case 'font_weight':
                                 $style[$key] = 'font-weight:' . $value;
                                 break;
                             case 'color':
                                 $style[$key] = 'color:' . $value;
                                 break;
                         }
                     }
                 }
             }
         }
     }
     $style = implode(';', $style);
     $style .= ';' . $font_style;
     $style = $style == ';' ? '' : $style;
     $true_element = "<{$arr_params['tag']} style='{$style}'>" . JSNPagebuilderHelpersShortcode::removeAutop($content) . "</{$arr_params['tag']}>";
     $true_element .= '';
     return $this->element_wrapper($true_element, $arr_params);
 }