public function controls() { $res = '<div id="poststuff" class="metabox-holder">' . PHP_EOL; $res .= '<div id="q2w3_table_search" class="postbox" style="width: 100%; margin-bottom: 0px;">' . PHP_EOL; $res .= '<h3 class="hndle" style="cursor: normal;"><span>Поиск</span></h3>' . PHP_EOL; if (!empty($_SESSION['search'])) { $show_form = 'style="display: block"'; } else { $show_form = 'style="display: none"'; } $res .= '<div class="inside" ' . $show_form . '>' . PHP_EOL; $res .= '<form method="post" action="' . q2w3_table_func::folder_url() . '/q2w3_post.php' . '" id="q2w3_table_search_form">' . PHP_EOL; $search = new q2w3_table_search($this->plugin_id); $res .= $search->html(); $res .= new q2w3_hidden_input(array('name' => 'wp_nonce', 'value' => wp_create_nonce('q2w3_table_post'))); $res .= '<table>' . PHP_EOL; foreach ($this->obj as $pname => $propertie) { if ($propertie->search == true) { $propertie->input->value = $_SESSION['search'][$propertie->col_name]; $res .= '<tr>' . PHP_EOL; $res .= '<td>' . $propertie->name . '</td>' . PHP_EOL; $res .= '<td>' . $propertie->input . '</td>' . PHP_EOL; $res .= '</tr>' . PHP_EOL; } } $res .= '<tr>' . PHP_EOL; $res .= '<td><input type="button" value="Сброс" class="button-secondary"/></td>' . PHP_EOL; $res .= '<td><input type="submit" value="Поиск" class="button-primary"/></td>' . PHP_EOL; $res .= '</tr>' . PHP_EOL; $res .= '</table>' . PHP_EOL; $res .= '</form>' . PHP_EOL; $res .= '</div>' . PHP_EOL . '</div>' . PHP_EOL . '</div>' . PHP_EOL; //'</div>'.PHP_EOL; $res .= '<script type="text/javascript">jQuery("#q2w3_table_search .hndle").click(function(){jQuery("#q2w3_table_search .inside").toggle()});'; $res .= 'jQuery("#q2w3_table_search_form .button-secondary").click(function(){jQuery(":input","#q2w3_table_search_form").not(":button, :submit, :reset, :hidden").val("").removeAttr("checked").removeAttr("selected");jQuery("#q2w3_table_search_form").submit();});'; $res .= '</script>'; return $res; }
/** * Returns javascript needed for include edit form * */ public function js() { $this->widget_title->input->value = $this->widget_title->val; $this->code_align->input->value = $this->code_align->val; $zcbpath = q2w3_table_func::folder_url() . '_js/zeroclipboard/'; $zcbptext = __('Copy to clipboard', self::$plugin_id); $manual_inc_code = '<?php if ( method_exists(\'q2w3_inc_manager\', \'manual_inc\') ) q2w3_inc_manager::manual_inc(' . $_GET['id'] . '); ?>'; $shortcode_inc_code = '[include id="' . $_GET['id'] . '" title="" + get_inc_title() + ""]'; $js = '<script src="' . $zcbpath . 'ZeroClipboard.js"></script> <script type="text/javascript"> jQuery("#select_location").parent("td").append(\'<span id="manual_include_code"></span>\'); jQuery("#inc_code").parent("td").prepend(\'<span id="code_align"></span>\'); jQuery("#select_location").change(function() { var location = jQuery(this).attr("value"); if (location == ' . self::LOC_WIDGET . ' || location == ' . self::LOC_MANUAL . ') { jQuery(this).parent("td").parent("tr").next("tr").hide(); } else { jQuery(this).parent("td").parent("tr").next("tr").show(); } if (location == ' . self::LOC_MANUAL . ') { jQuery("#manual_include_code").text(""); jQuery("#manual_include_code").append("<span id=\\"text_to_copy\\">' . $manual_inc_code . '</span> <input data-clipboard-text=\\"' . $manual_inc_code . '\\" type=\\"button\\" value=\\"' . $zcbptext . '\\" id=\\"copy-button-manual\\" class=\\"button-secondary\\" />"); var clip = new ZeroClipboard( document.getElementById("copy-button-manual"), { moviePath: "' . $zcbpath . 'ZeroClipboard.swf" } ); } else if (location == ' . self::LOC_WIDGET . ') { jQuery("#manual_include_code").text(""); jQuery("#manual_include_code").append(\'' . $this->widget_title->name . ': ' . trim($this->widget_title->input) . '\'); } else if (location == ' . self::LOC_SHORTCODE . ') { jQuery("#manual_include_code").text(""); jQuery("#manual_include_code").append("<span id=\\"text_to_copy\\">' . $shortcode_inc_code . '</span> <input data-clipboard-text=\\"' . $shortcode_inc_code . '\\" type=\\"button\\" value=\\"' . $zcbptext . '\\" id=\\"copy-button-shortcode\\" class=\\"button-secondary\\" />"); var clip = new ZeroClipboard( document.getElementById("copy-button-shortcode"), { moviePath: "' . $zcbpath . 'ZeroClipboard.swf" } ); } else { jQuery("#manual_include_code").text(""); } if (location != ' . self::LOC_HEADER . ') { jQuery("#code_align").text(""); jQuery("#code_align").append(\'' . str_replace(PHP_EOL, '', $this->code_align->input) . '\'); } else { jQuery("#code_align").text(""); } }).trigger("change"); function get_inc_title() { return jQuery("input[name=\'propertie[description]\']").attr("value"); } function htmlDecode(value){ return jQuery(\'<div/>\').html(value).text(); } </script>'; return $js; }