Пример #1
0
    function generate_index()
    {
        $this->generate_header();
        $url = $this->main_object->admin_url;
        $name = $this->main_object->plugin_name;
        $new_url = $url . '&action=new';
        echo '<h2 class="all_around_status">' . $name . '<a href="' . $new_url . '">Create new</a></h2> <span class="all_around_small_buton" id="all_around_update_notification" style="display: none;"></span>';
        echo $this->main_object->mvc->get_index_table();
        echo all_around_visual_elements::generate_button('all_around_new', 'Create new', 'blue', NULL, array('width' => '150px', 'float' => 'right'), TRUE, $new_url);
        if (!isset($this->main_object->settings_in_db['use_separated_jquery'])) {
            $this->main_object->settings_in_db['use_separated_jquery'] = 0;
        }
        $use_separated_jquery = $this->main_object->settings_in_db['use_separated_jquery'];
        $separated = all_around_visual_elements::generate_checkbox('Use separated jQuery only for this plugin in order to skip possible conflicts (activate this option only if slider fails to open)', 'use_separated_jquery', $use_separated_jquery, array('empty_wrapper' => 1), array('auto_width' => FALSE));
        $skip_head_section = $this->main_object->settings['skip_head_section'];
        $skipheadsection = all_around_visual_elements::generate_checkbox('Put CSS &amp; JS near HTML block, not in &lt;head&gt; section (this can help if your template or some other plugin screws up &lt;head&gt; section)', 'skip_head_section', $skip_head_section, array('empty_wrapper' => 1), array('auto_width' => FALSE));
        //$settings=print_r(, TRUE);
        //<div style="background-color: white;"><pre>$settings</pre></div>
        //echo '<span style="color: #E0E0E0;">prefix='.$this->wrapper->get_db_prefix().'<br />table='.$this->main_object->get_plugin_table_name().'</span><br />';
        echo <<<eof
\t\t<script>
\t\t(function(\$){
\t\t\tall_around_add_event('use_separated_jquery', function(name, value) {
\t\t\t\tall_around_send_ajax('all_around_set_settings_1val', 'var1=use_separated_jquery&val1='+value, function(response) {
\t\t\t\t\t\$('#all_around_save_status').fadeIn('slow', function(){
\t\t\t\t\t\t\$(this).fadeOut('slow');
\t\t\t\t\t});

\t\t\t\t});
\t\t\t});
\t\t\tall_around_add_event('skip_head_section', function(name, value) {
\t\t\t\tall_around_send_ajax('all_around_set_settings_1val', 'var1=skip_head_section&val1='+value, function(response) {
\t\t\t\t\t\$('#all_around_save_status').fadeIn('slow', function(){
\t\t\t\t\t\t\$(this).fadeOut('slow');
\t\t\t\t\t});

\t\t\t\t});
\t\t\t});
\t\t})(jQuery);
\t\t</script>
\t\t<br /><span style="padding: 2px 0 0 0; font-size: 12px; display: block; float: left; font-weight: bold; position: relative; color: #E0E0E0;">Troubleshooting?</span>&nbsp;&nbsp;&nbsp;<a class="all_around_small_buton" style="top: 3px; display: none;" id="all_around_save_status">Saved</a><br /><br />
\t\t{$separated}
\t\t{$skipheadsection}
\t\t<br /><br /><br />
\t\t<h2 class="all_around_status">Step by step:</h2>
<ol class="all_around_steps">
\t<li>
\t\t<h3>Click on "Create New" button</h3>
\t</li>
\t<li>
\t\t<h3>Setup your slider, save it, and come back here</h3>
\t</li>
\t<li>
\t\t<h3>Copy "shortcode" from the table above and paste it in your post or page.<br />(for adding slider into .php parts of template use it like this "&lt;?php echo do_shortcode('[all_around id="X"]'); ?&gt;" where X is id of your slider)</h3>
\t</li>
</ol>
eof;
        $this->close_header();
    }
Пример #2
0
 function generate_html_fields(&$form)
 {
     $html = '';
     foreach ($form as $id => $field) {
         $wrapper = array();
         $style = NULL;
         $class = '';
         $style['auto_width'] = FALSE;
         $generated_html = '';
         if (isset($field['wrapper'])) {
             $wrapper = $field['wrapper'];
         }
         if (isset($field['class'])) {
             $class = $field['class'];
         }
         if (isset($field['if_other_fields'])) {
             foreach ($field['if_other_fields'] as $arr) {
                 //$tarr=explode('_', $field['name']);
                 //$prefix=$tarr[0].'_'.$tarr[1];
                 //$item_number=$tarr[1];
                 $item_number = $this->model->determine_item_number($field['name']);
                 foreach ($arr as $condition => $action) {
                     $condition = explode('=', $condition);
                     $target = $condition[0];
                     $target_value = $condition[1];
                     $action = explode(' ', $action);
                     //if (substr($target,0,7)=='item_*_') $target=$prefix.'_'.substr($target,7);
                     $target_arr =& $this->model->find_target($target, $field['name']);
                     //$this->model->get_field_from_custom_scheme($form, $target);
                     if ($target_arr['value'] == $target_value) {
                         if ($action[0] == 'show_form') {
                             if (substr($action[1], 0, 12) == 'custom_form_') {
                                 $custom_form = intval(substr($action[1], 12));
                                 $generated_html = $this->generate_html_fields($this->model->item_loaded_custom_forms[$item_number][$custom_form]);
                             }
                         }
                     }
                 }
             }
         }
         if (isset($field['not_visible_if'])) {
             foreach ($field['not_visible_if'] as $not_visible_if_array) {
                 //echo '========= '.$not_visible_if_array."<br />";
                 $looking_for_arr = explode('=', $not_visible_if_array);
                 $looking_for = $looking_for_arr[0];
                 $looked_val = $looking_for_arr[1];
                 //echo 'looking_for: '.$looking_for.'<br />'; echo 'looked_val: '.$looked_val.'<br />';
                 if (substr($looking_for, 0, 5) == 'item_') {
                     $looked_arr =& $this->model->find_target($looking_for, $field['name']);
                     if ($looked_arr != NULL) {
                         if ($looked_arr['value'] == $looked_val) {
                             $wrapper['display'] = 'none';
                         }
                     }
                 }
                 if (substr($looking_for, 0, 9) == 'settings_') {
                     //echo 'explain: '.$looking_for." = ".$looked_val."  => ".$this->model->loaded_settings[$looking_for]['value']."<br />";
                     //print_r()
                     if ($this->model->loaded_settings[$looking_for]['value'] == $looked_val) {
                         $wrapper['display'] = 'none';
                     }
                 }
             }
         }
         if (isset($field['if_value'])) {
             $arr = $field['if_value'];
             $events = array();
             foreach ($arr as $value => $expr) {
                 $expr = explode(' ', $expr);
                 $action = $expr[0];
                 $target = $expr[1];
                 $param1 = '';
                 $param2 = '';
                 $tarr = explode('_', $field['name']);
                 $prefix = $tarr[0] . '_' . $tarr[1];
                 if (isset($expr[2])) {
                     $param1 = $expr[2];
                 }
                 if ($action == 'ajax_load_form' && $tarr[0] == 'item') {
                     $param2 = $tarr[1];
                 }
                 if ($tarr[0] == 'item' && substr($target, 0, 7) == 'item_*_') {
                     $target = $prefix . '_' . substr($target, 7);
                 }
                 if ($tarr[0] == 'item' && substr($target, 0, 8) == '.item_*_') {
                     $target = '.' . $prefix . '_' . substr($target, 8);
                 }
                 if ($tarr[0] == 'item' && substr($target, 0, 8) == '#item_*_') {
                     $target = '#' . $prefix . '_' . substr($target, 8);
                 }
                 $target_arr = array('target' => $target, 'param1' => $param1, 'param2' => $param2);
                 $events[$value] = array($action => $target_arr);
             }
             $this->javascript_events[] = array('object' => $field['name'], 'if_value' => $events);
         }
         if (isset($field['style'])) {
             $style = $field['style'];
         }
         if (isset($field['label'])) {
             $wrapper['span'] = $field['label'];
         }
         if (isset($field['group'])) {
             $wrapper['group'] = $field['group'];
             $tarr = explode('_', $field['name']);
             $prefix = $tarr[0] . '_' . $tarr[1];
             if ($tarr[0] == 'item' && substr($field['group'], 0, 7) == 'item_*_') {
                 $wrapper['group'] = $prefix . '_' . substr($wrapper['group'], 7);
             }
         }
         if (isset($field['html_before'])) {
             $html .= $field['html_before'];
         }
         if ($field['type'] == 'image_upload') {
             $default = $this->main_object->url . 'images/no_image.jpg';
             if (isset($field['empty_image'])) {
                 $default = $field['empty_image'];
             }
             $html .= all_around_visual_elements::generate_image($field['name'], $field['value'], $wrapper, $style, $default);
         }
         if ($field['type'] == 'listbox') {
             $html .= all_around_visual_elements::generate_listbox($field['name'], $field['value'], $field['list'], $wrapper, $style);
         }
         if ($field['type'] == 'text') {
             $html .= all_around_visual_elements::generate_textarea($field['name'], $field['value'], $wrapper, $style);
         }
         if ($field['type'] == 'input') {
             $html .= all_around_visual_elements::generate_input($field['name'], $field['value'], $wrapper, $style);
         }
         if ($field['type'] == 'hidden') {
             $html .= all_around_visual_elements::generate_hidden($field['name'], $field['value'], $class);
         }
         if ($field['type'] == 'font') {
             $wrapper2 = $wrapper;
             if ($this->main_object->backend_style == 1) {
                 $wrapper2['margin-bottom'] = '50px';
             }
             if ($this->main_object->backend_style == 2) {
                 $wrapper2['margin-bottom'] = '71px';
             }
             $html .= all_around_visual_elements::generate_button($field['name'] . '_button', $this->convert_font_data_to_label($field['value']), 'black_clear', $wrapper2, $style, FALSE, '', 'all_around_font_button', $field['name']) . all_around_visual_elements::generate_hidden($field['name'], $field['value']);
         }
         if ($field['type'] == 'button') {
             $wrapper2 = $wrapper;
             if ($this->main_object->backend_style == 1) {
                 $wrapper2['margin-bottom'] = '50px';
             }
             if ($this->main_object->backend_style == 2) {
                 $wrapper2['margin-bottom'] = '71px';
             }
             if (isset($field['wrapper'])) {
                 $wrapper2 = $field['wrapper'];
             }
             $html .= all_around_visual_elements::generate_button($field['name'] . '_button', $field['value'], 'black_clear', $wrapper2, $style, TRUE);
         }
         if ($field['type'] == 'color') {
             $html .= all_around_visual_elements::generate_color($field['name'], $field['value'], $wrapper, $style);
         }
         if ($field['type'] == 'checkbox') {
             if (isset($field['without_wrapper_label']) && $field['without_wrapper_label'] == 1 && isset($wrapper['span'])) {
                 unset($wrapper['span']);
                 $wrapper['empty_wrapper'] = 1;
             }
             $html .= all_around_visual_elements::generate_checkbox($field['label'], $field['name'], $field['value'], $wrapper, $style);
         }
         if ($field['type'] == 'number') {
             if (!isset($field['step'])) {
                 $field['step'] = 1;
             }
             $html .= all_around_visual_elements::generate_number($field['name'], $field['value'], $field['min'], $field['max'], $field['unit'], $wrapper, $style, $field['step']);
         }
         if ($field['type'] == 'attached_form') {
             $html .= all_around_visual_elements::generate_div($field['name'], $generated_html, $style);
         }
         if (isset($field['html_after'])) {
             $html .= $field['html_after'];
         }
     }
     return $html;
 }