public static function action($plugin_id, $object_name) { $_SERVER['HTTP_REFERER'] = ''; $id = $_GET['id']; $type = $_GET['type']; $select = new q2w3_select_input(); $select->multiple = true; $select->style = 'width: 635px; height: 450px;'; $select->id = 'select_wp_pages'; $select->value_to_select = self::selectable_pages($plugin_id, $type); $select->prepare(); $submit = new q2w3_submit_input(array('value' => __('Apply', $plugin_id), 'class' => 'button-secondary')); $cancel = new q2w3_button_input(array('value' => __('Cancel', $plugin_id), 'class' => 'button-secondary')); $cancel->js = 'onclick="tb_remove()"'; $res = '<form action="" method="get" id="select_wp_pages_form" style="overflow: hidden">' . PHP_EOL; $res .= $select; $res .= '<div style="color: rgb(33,117,155); float: right; margin-top: 3px">' . __('To select multiple pages or deselect page hold CTRL key', $plugin_id) . '</div>'; $res .= $submit . $cancel; $res .= '</form>'; $res .= '<script type="text/javascript">'; $res .= 'var selected_values_str = jQuery("#' . $id . ' input").attr("value"); var selected_values_array = selected_values_str.split(","); jQuery("#select_wp_pages option").each(function () { var opt_val = jQuery(this).attr("value"); if (jQuery.inArray(opt_val, selected_values_array) > -1) jQuery(this).attr("selected", "selected"); });'; $res .= 'jQuery("#select_wp_pages_form").submit(function(){ var str = ""; var values = ""; var comma = ","; var slash = " // "; var i = 0; var num = jQuery("#select_wp_pages option:selected").length; jQuery("#select_wp_pages option:selected").each(function () { i++; if (i == num) { comma = ""; slash = ""; } str += jQuery(this).text() + slash; values += jQuery(this).attr("value") + comma; }); jQuery("#' . $id . ' input").attr("value", values); jQuery("#' . $id . ' .selected_pages").text("' . __('Pages', $plugin_id) . ': " + str); tb_remove(); return false; })'; $res .= '</script>'; echo $res; }
public function html() { $selector = new q2w3_select_input(array('name' => $this->name, 'value_to_select' => self::$months, 'class' => 'month_input', 'value' => $this->value)); return $selector->html(); }