Example #1
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  */
 public function element_shortcode_full($atts = null, $content = null)
 {
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content);
     $custom_style = WR_Pb_Utils_Placeholder::get_placeholder('custom_style');
     return "{$heading}<!--heading-->{$icon}<!--icon--><div id='pane{index}' class='tab-pane {active} {fade_effect}' {$custom_style}>\n\t\t\t{$inner_content}\n\t\t\t\t</div><!--seperate-->";
 }
Example #2
0
        /**
         *
         * @param type $content		: inner shortcode elements of this row
         * @param type $shortcode_data : not used
         * @return string
         */
        public function element_in_pgbldr($content = '', $shortcode_data = '')
        {
            if (empty($content)) {
                $column = new WR_Column();
                $column_html = $column->element_in_pgbldr();
                $column_html = $column_html[0];
            } else {
                $column_html = WR_Pb_Helper_Shortcode::do_shortcode_admin($content);
            }
            if (empty($shortcode_data)) {
                $shortcode_data = $this->config['shortcode_structure'];
            }
            // remove [/wr_row][wr_column...] from $shortcode_data
            $shortcode_data = explode('][', $shortcode_data);
            $shortcode_data = $shortcode_data[0] . ']';
            // Remove empty value attributes of shortcode tag.
            $shortcode_data = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*"")/', '', $shortcode_data);
            $custom_style = WR_Pb_Utils_Placeholder::get_placeholder('custom_style');
            $row[] = '<div class="jsn-row-container ui-sortable row-fluid shortcode-container" ' . $custom_style . '>
						<textarea class="hidden" data-sc-info="shortcode_content" name="shortcode_content[]" >' . $shortcode_data . '</textarea>
						<div class="jsn-iconbar left">
							<a href="javascript:void(0);" title="' . __('Move Up', WR_PBL) . '" class="jsn-move-up disabled"><i class="icon-chevron-up"></i></a>
							<a href="javascript:void(0);" title="' . __('Move Down', WR_PBL) . '" class="jsn-move-down disabled"><i class=" icon-chevron-down"></i></a>
						</div>
						<div class="wr-row-content">
						' . $column_html . '
						</div>
						<div class="jsn-iconbar jsn-vertical">
							<a href="javascript:void(0);" class="add-container" title="' . __('Add column', WR_PBL) . '"><i class="wr-icon-add-col"></i></a>
							<a href="javascript:void(0);" title="Edit row" data-shortcode="' . $this->config['shortcode'] . '" class="element-edit row" data-use-ajax="' . ($this->config['edit_using_ajax'] ? 1 : 0) . '"><i class="icon-pencil"></i></a>
							<a href="javascript:void(0);" class="item-delete row" title="' . __('Delete row', WR_PBL) . '"><i class="icon-trash"></i></a>
						</div>
						<textarea class="hidden" name="shortcode_content[]" >[/' . $this->config['shortcode'] . ']</textarea>
					</div>';
            return $row;
        }
Example #3
0
 /**
  * Handle empty icon & heading for Carousel, ,Tab, Accordion, List item
  *
  * @param type $heading
  * @param type $icon
  */
 static function heading_icon(&$heading, &$icon, $heading_empty = false)
 {
     if (strpos($heading, WR_Pb_Utils_Placeholder::get_placeholder('index')) !== false) {
         $heading = '';
     }
     if (empty($icon) && empty($heading)) {
         $heading = !$heading_empty ? __('(Untitled)', WR_PBL) : '';
     }
 }
Example #4
0
 /**
  * Generate options list of shortcode (from $this->items array) OR get value of a option
  *
  * @param array       $arr             ($this->items)
  * @param string|null $paramID         (get std of a option by ID)
  * @param array       $new_values      (set std for some options ( "pram id" => "new std value" ))
  * @param bool        $assign_content  (set $option['std'] = $new_values['_shortcode_content'] of option which has role = 'content')
  * @param bool        $extract_content (get $option['std'] of option which has role = 'content')
  * @param string      $extract_title   (get $option['std'] of option which has role|role_2 = 'title')
  *
  * @return array
  */
 static function generate_shortcode_params(&$arr, $paramID = NULL, $new_values = NULL, $assign_content = FALSE, $extract_content = FALSE, $extract_title = '', &$has_preview = false)
 {
     $params = array();
     if ($arr) {
         foreach ($arr as $tab => &$options) {
             foreach ($options as &$option) {
                 $type = isset($option['type']) ? $option['type'] : '';
                 $option['std'] = !isset($option['std']) ? '' : $option['std'];
                 // option has role = 'content'
                 if (isset($option['role']) && $option['role'] == 'content') {
                     // set std of this option
                     if ($assign_content) {
                         if (!empty($new_values) && isset($new_values['_shortcode_content'])) {
                             $option['std'] = $new_values['_shortcode_content'];
                         }
                     }
                     // get std of this option
                     if ($extract_content) {
                         $params['extract_shortcode_content'][$option['id']] = $option['std'];
                     } else {
                         // remove option which role = content from shortcode structure ( except option which has another role: title )
                         if (!(isset($option['role']) && $option['role'] == 'title' || isset($option['role_2']) && $option['role_2'] == 'title' || isset($option['role']) && $option['role'] == 'title_prepend')) {
                             unset($option);
                             continue;
                         }
                     }
                 }
                 if ($type != 'preview') {
                     // single option : $option['type'] => string
                     if (!is_array($type)) {
                         // if is not parent/nested shortcode
                         if (!in_array($type, self::$group_shortcodes)) {
                             // default content
                             if (empty($new_values)) {
                                 if (!empty($paramID)) {
                                     if ($option['id'] == $paramID) {
                                         return $option['std'];
                                     }
                                 } else {
                                     if (isset($option['id'])) {
                                         $params[$option['id']] = $option['std'];
                                     }
                                 }
                             } else {
                                 if (isset($option['id']) && array_key_exists($option['id'], $new_values)) {
                                     $option['std'] = $new_values[$option['id']];
                                 }
                                 if (isset($option['role']) && $option['role'] == 'title' && empty($new_values[$option['id']])) {
                                     $option['std'] = '';
                                 }
                             }
                             // extract title for element like Table
                             if (!empty($extract_title)) {
                                 // default std
                                 if (strpos($option['std'], WR_Pb_Utils_Placeholder::get_placeholder('index')) !== false) {
                                     $option['std'] = $extract_title;
                                     $params['extract_title'] = $extract_title;
                                 } else {
                                     if (isset($option['role']) && $option['role'] == 'title' || isset($option['role_2']) && $option['role_2'] == 'title') {
                                         if ($option['role'] == 'title') {
                                             $params['extract_title'] = $option['std'];
                                         } else {
                                             $params['extract_title'] = WR_Pb_Utils_Common::slice_content($option['std']);
                                         }
                                     } else {
                                         if (isset($option['role']) && $option['role'] == 'title_prepend' && !empty($option['title_prepend_type']) && !empty($option['std'])) {
                                             $params['extract_title'] = WR_Pb_Utils_Placeholder::remove_placeholder(self::$item_html_template[$option['title_prepend_type']], 'standard_value', $option['std']) . $params['extract_title'];
                                         }
                                     }
                                 }
                             }
                         } else {
                             // default content
                             if (empty($new_values)) {
                                 foreach ($option['sub_items'] as &$sub_items) {
                                     $sub_items['std'] = !isset($sub_items['std']) ? '' : $sub_items['std'];
                                     if (!empty($paramID)) {
                                         if ($sub_items['id'] == $paramID) {
                                             return $sub_items['std'];
                                         }
                                     } else {
                                         $params['sub_items_content'][$option['sub_item_type']][] = $sub_items;
                                     }
                                 }
                             } else {
                                 $count_default = count($option['sub_items']);
                                 $count_real = isset($new_values['sub_items_content'][$option['sub_item_type']]) ? count($new_values['sub_items_content'][$option['sub_item_type']]) : 0;
                                 if ($count_real > 0) {
                                     // there are new sub items
                                     if ($count_default < $count_real) {
                                         for ($index = $count_default; $index < $count_real; $index++) {
                                             $option['sub_items'][$index] = array('std' => '');
                                         }
                                     } else {
                                         if ($count_default > $count_real) {
                                             for ($index = $count_real; $index < $count_default; $index++) {
                                                 unset($option['sub_items'][$index]);
                                             }
                                         }
                                     }
                                     // update content for sub items
                                     array_walk($option['sub_items'], array('WR_Pb_Helper_Functions', 'wr_arr_walk_subsc'), $new_values['sub_items_content'][$option['sub_item_type']]);
                                 }
                             }
                         }
                     } else {
                         // default content
                         if (empty($new_values)) {
                             foreach ($option['type'] as &$sub_options) {
                                 $sub_options['std'] = !isset($sub_options['std']) ? '' : $sub_options['std'];
                                 if (!empty($paramID)) {
                                     if ($sub_options['id'] == $paramID) {
                                         return $sub_options['std'];
                                     }
                                 } else {
                                     $params[$sub_options['id']] = $sub_options['std'];
                                 }
                             }
                         } else {
                             array_walk($option['type'], array('WR_Pb_Helper_Functions', 'wr_arr_walk'), $new_values);
                         }
                     }
                     if (isset($option['extended_ids'])) {
                         foreach ($option['extended_ids'] as $_id) {
                             $params[$_id] = isset($option[$_id]['std']) ? $option[$_id]['std'] : '';
                         }
                     }
                 } else {
                     $has_preview = true;
                 }
             }
         }
     }
     return $params;
 }