Beispiel #1
0
    function generate_form($id)
    {
        //$this->main_object->init_google_fonts();
        $this->generate_header();
        $message = 'Add slider';
        $admin_url = $this->main_object->admin_url;
        $plugin_url = $this->main_object->url;
        $style2 = array('width' => '140px');
        $style3 = array('width' => '140px', 'margin-left' => '5px !important');
        $new = all_around_visual_elements::generate_button('all_around_add_new_item', 'Add new item', 'black_clear', FALSE, $style2, FALSE);
        $new .= all_around_visual_elements::generate_button('all_around_add_new_from_post', 'Add new from post', 'black_clear', FALSE, $style3, FALSE);
        $new .= all_around_visual_elements::generate_button('all_around_add_new_from_category', 'Add new from category', 'black_clear', FALSE, $style3, TRUE);
        if ($id != 'new') {
            $this->main_object->mvc->load($id);
            $this->main_object->mvc->pre_process_form('all');
            $loaded_items = $this->main_object->mvc->generate_all_sub_items();
            $title_value = $this->main_object->mvc->get_loaded_name();
            $message = 'Edit slider';
        } else {
            $this->main_object->mvc->pre_process_form('all');
            $loaded_items = array();
            $title_value = 'New item';
            //$elements=$this->main_object->mvc->generate_html_form_part('empty_item', 0);
        }
        $status = '<h2 class="all_around_status">' . $message . '<a href="' . $admin_url . '">Cancel</a></h2> <span class="all_around_small_buton" id="all_around_update_notification" style="display: none;"></span>';
        $title = all_around_visual_elements::generate_input('element_name', $title_value, NULL, array('auto_width' => FALSE));
        $ul = all_around_visual_elements::generate_sortable('all_around_sortable', $loaded_items, NULL, 'all_around_primary_sortable');
        $style2 = array('width' => '70px');
        $style_collapsible = array('width' => '280px');
        $buttons = all_around_visual_elements::generate_button('all_around_save_button', 'Save', 'blue', FALSE, $style2, FALSE) . all_around_visual_elements::generate_button('all_around_preview_button', 'Preview', '', FALSE, $style2, TRUE);
        $loader = '<img src="' . $plugin_url . 'images/ajax-loader2.gif" id="all_around_save_loader" style="float: right; margin-right:38px; display: none;">';
        $saved = '<a class="all_around_small_buton" style="float: right; margin-right: 38px; display: none;" id="all_around_save_status">Saved</a>';
        $save = all_around_visual_elements::generate_collapsible('Save' . $saved . $loader, $buttons, $style_collapsible, TRUE);
        $settings_form = $this->main_object->mvc->generate_html_form_part('settings');
        $steps = <<<eod
<h2 class="all_around_status">Step by step:</h2>
<ol class="all_around_steps">
\t<li>
\t\t<h3>Enter some name for this slider, something associative (name will not be shown on page)</h3>
\t</li>
\t<li>
\t\t<h3>Add items</h3>
\t</li>
\t<li>
\t\t<h3>Save it</h3>
\t</li>
\t<li>
\t\t<h3>And go to <a href="{$admin_url}">All Around plugin main page</a></h3>
\t</li>
</ol>
eod;
        $settings_side = $save . $settings_form;
        $element_side = $status . $title . '<br />' . $new . '<br />' . $ul . '<br />' . $steps;
        $view = all_around_visual_elements::generate_form_layout($element_side, $settings_side);
        $hidden = all_around_visual_elements::generate_hidden('element_id', $id);
        $view = all_around_visual_elements::generate_form($hidden . $view, 'form1');
        echo $view;
        $this->close_header();
    }
 function generate_html_form_part($for, $id = 0, $closed = 0)
 {
     $html = '';
     $form = array();
     $current_item_title = '';
     $this->pre_generate_html_form_part($for, $id);
     if ($for == 'item' || $for == 'empty_item') {
         $form =& $this->model->loaded_items[$id];
         if (isset($form['title']['value'])) {
             $current_item_title = $form['title']['value'];
         }
     }
     if ($for == 'settings') {
         $form =& $this->model->loaded_settings;
     }
     // main task
     $html = $this->generate_html_fields($form);
     // finalizing
     if ($for == 'item') {
         $current_item_title .= '&nbsp;&nbsp;&nbsp;<a class="all_around_delete_subitem">[Delete]</a>&nbsp;&nbsp;&nbsp;<a class="all_around_duplicate_subitem">[Duplicate]</a>';
         if (isset($form['group']['value']) && intval($form['group']['value']) > -1) {
             $current_item_title .= '&nbsp;&nbsp;&nbsp;<a class="all_around_group_move_out_subitem" style="display: none;">[Move out from group]</a><a class="all_around_group_move_in_subitem" style="display: none;">[Move in group]</a>';
         } else {
             $current_item_title .= '&nbsp;&nbsp;&nbsp;<a class="all_around_group_move_out_subitem" style="display: none;">[Move out from group]</a><a class="all_around_group_move_in_subitem" style="display: none;">[Move in group]</a>';
         }
         $open = FALSE;
         $display = '';
         $additional_classes = '';
         if ($this->main_object->ajax_call == 1) {
             if ($closed == 0) {
                 $open = TRUE;
                 $display = ' display: none;';
                 $additional_classes = 'all_around_new_subitem';
             }
         }
         $html .= $this->generate_backend_javascript(1);
         $this->javascript_events = array();
         $html = all_around_visual_elements::generate_collapsible($current_item_title, $html, NULL, $open, all_around_visual_elements::$style_collapsible_content_style . $display, $additional_classes);
     }
     if ($for == 'settings') {
         $style_collapsible = array('width' => '280px');
         $html = all_around_visual_elements::generate_collapsible('Settings', $html, $style_collapsible, TRUE, all_around_visual_elements::$style_settings_collapsible_content_style);
     }
     return $html;
 }
    function generate_form($id)
    {
        //$this->main_object->init_google_fonts();
        $this->generate_header();
        //echo '<pre>'; print_r ($this->wrapper->get_tags()); echo '</pre>';exit;
        //echo '<pre>'; print_r ($this->wrapper->get_tag_posts(3)); echo '</pre>';exit;
        //echo '<pre>'; print_r($this->wrapper->get_tag_info(3)); echo '</pre>'; exit;
        $message = 'Add slider';
        if (defined('ALL_AROUND_DEMO')) {
            $message = 'Create a slider';
        }
        $admin_url = $this->main_object->admin_url;
        $plugin_url = $this->main_object->url;
        $style3 = array('margin-right' => '5px !important', 'margin-top' => '5px !important');
        $new = all_around_visual_elements::generate_button('all_around_add_new_item', 'Add new item', 'black_clear', FALSE, $style3, FALSE, '', '', '', 0, FALSE);
        $new .= all_around_visual_elements::generate_button('all_around_add_new_from_post', 'Add new from post', 'black_clear', FALSE, $style3, FALSE, '', '', '', 0, FALSE);
        $new .= all_around_visual_elements::generate_button('all_around_add_new_from_category', 'Add new from category', 'black_clear', FALSE, $style3, FALSE, '', '', '', 0, FALSE);
        $new .= all_around_visual_elements::generate_button('all_around_add_new_from_tag', 'Add new from tag', 'black_clear', FALSE, $style3, TRUE, '', '', '', 0, FALSE);
        if ($id != 'new') {
            $this->main_object->mvc->load($id);
            $this->main_object->mvc->pre_process_form('all');
            //echo '<pre>'; print_r($this->main_object->mvc->model->loaded_items[0]['main_link']); echo '</pre>'; exit;
            $loaded_items = $this->main_object->mvc->generate_all_sub_items();
            $title_value = $this->main_object->mvc->get_loaded_name();
            $message = 'Edit slider';
        } else {
            $this->main_object->mvc->pre_process_form('all');
            $loaded_items = array();
            $loaded_items['items'] = array();
            $loaded_items['style'] = array();
            $title_value = 'New slider';
            //$elements=$this->main_object->mvc->generate_html_form_part('empty_item', 0);
        }
        $cancel_url = $admin_url;
        if (defined('ALL_AROUND_DEMO')) {
            $cancel_url = '#';
        }
        $status = '<h2 class="all_around_status">' . $message . '<a href="' . $cancel_url . '">Cancel</a></h2> <span class="all_around_small_buton" id="all_around_update_notification" style="display: none;"></span>';
        $title = all_around_visual_elements::generate_input('element_name', $title_value, NULL, array('auto_width' => FALSE, 'margin-bottom' => '5px'));
        $ul = '';
        $ul = all_around_visual_elements::generate_sortable('all_around_sortable', $loaded_items['items'], NULL, 'all_around_primary_sortable', $loaded_items['style']);
        $style_collapsible = array('width' => '280px');
        $buttons = '';
        if (!defined('ALL_AROUND_DEMO')) {
            $style2 = array('width' => '70px');
            $buttons = all_around_visual_elements::generate_button('all_around_save_button', 'Save', 'blue', FALSE, $style2, FALSE);
            $buttons .= all_around_visual_elements::generate_button('all_around_preview_button', 'Preview', 'center_label', FALSE, $style2, TRUE);
        } else {
            $style2 = array('width' => '120px', 'margin-left' => '55px !important');
            $buttons .= all_around_visual_elements::generate_button('all_around_preview_button', 'Preview', 'blue', FALSE, $style2, TRUE);
        }
        $loader = '<img src="' . $plugin_url . 'images/ajax-loader2.gif" id="all_around_save_loader" style="float: right; margin-right:38px; display: none;">';
        $saved = '<a class="all_around_small_buton" style="float: right; margin-right: 38px; display: none;" id="all_around_save_status">Saved</a>';
        $save_title = 'Save';
        if (defined('ALL_AROUND_DEMO')) {
            $save_title = 'Preview';
        }
        $save = all_around_visual_elements::generate_collapsible($save_title . $saved . $loader, $buttons, $style_collapsible, TRUE);
        $settings_form = $this->main_object->mvc->generate_html_form_part('settings');
        if (!defined('ALL_AROUND_DEMO')) {
            $steps = <<<eod
<h2 class="all_around_status">Step by step:</h2>
<ol class="all_around_steps">
\t<li>
\t\t<h3>Enter some name for this slider, something associative (name will not be shown on page)</h3>
\t</li>
\t<li>
\t\t<h3>Add items</h3>
\t</li>
\t<li>
\t\t<h3>Save it</h3>
\t</li>
\t<li>
\t\t<h3>And go to <a href="{$admin_url}">All Around plugin main page</a></h3>
\t</li>
</ol>
eod;
        } else {
            $steps = <<<eod
<h2 class="all_around_status">Step by step:</h2>
<ol class="all_around_steps">
\t<li>
\t\t<h3>Click on "Add new item" button</h3>
\t</li>
\t<li>
\t\t<h3>Optionally: customize it, or add more items</h3>
\t</li>
\t<li>
\t\t<h3>Click on "Preview" button (in right sidebar)</h3>
\t</li>
</ol>
eod;
        }
        $settings_side = $save . $settings_form;
        $element_side = $status . $title . '<br />' . $new . '<br />' . $ul . '<br />' . $steps;
        $view = all_around_visual_elements::generate_form_layout($element_side, $settings_side);
        $hidden = all_around_visual_elements::generate_hidden('element_id', $id);
        if (defined('ALL_AROUND_DEMO')) {
            $hidden .= all_around_visual_elements::generate_hidden('all_around_demo', 1);
        }
        $view = all_around_visual_elements::generate_form($hidden . $view, 'form1');
        echo $view;
        $this->close_header();
    }
Beispiel #4
0
 function generate_html_form_part($for, $id = 0)
 {
     $html = '';
     $form = array();
     $current_item_title = '';
     $this->pre_generate_html_form_part($for, $id);
     if ($for == 'item' || $for == 'empty_item') {
         $form = $this->model->loaded_items[$id];
         foreach ($form as $aid => $arr) {
             if ($arr['base_name'] == 'title') {
                 $current_item_title = $arr['value'];
             }
         }
     }
     if ($for == 'settings') {
         $form = $this->model->loaded_settings;
     }
     // main task
     $html = $this->generate_html_fields($form);
     // finalizing
     if ($for == 'item') {
         $current_item_title .= '&nbsp;&nbsp;&nbsp;<a class="all_around_delete_subitem">[Delete]</a>';
         $open = FALSE;
         if ($this->main_object->ajax_call == 1) {
             $open = TRUE;
             $html .= $this->generate_backend_javascript(1);
             $this->javascript_events = array();
         }
         $html = all_around_visual_elements::generate_collapsible($current_item_title, $html, NULL, $open, 'padding-left: 0px; padding-right: 15px;');
     }
     if ($for == 'settings') {
         $style_collapsible = array('width' => '280px');
         $html = all_around_visual_elements::generate_collapsible('Settings', $html, $style_collapsible, TRUE);
     }
     return $html;
 }