private function ParseHeaderFooter($str, $uid = null) { $str = preg_replace_callback('/%sort_?link:([a-z0-9_]+)%/i', array(__CLASS__, 'GenSortlink'), $str); if (strpos($str, '%search_form%') !== false) { wpfb_loadclass('Output'); $str = str_replace('%search_form%', WPFB_Output::GetSearchForm("", $_GET), $str); } $str = preg_replace_callback('/%print_?(script|style):([a-z0-9_-]+)%/i', array(__CLASS__, 'PrintScriptCallback'), $str); if (empty($uid)) { $uid = uniqid(); } $str = str_replace('%uid%', $uid, $str); $count = 0; $str = preg_replace("/jQuery\\((.+?)\\)\\.dataTable\\s*\\((.*?)\\)(\\.?.*?)\\s*;/", 'jQuery($1).dataTable((function(options){/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/})($2))$3;', $str, -1, $count); if ($count > 0) { $dataTableOptions = array(); list($sort_field, $sort_dir) = wpfb_call('Output', 'ParseSorting', $this->current_list->file_order); $file_tpl = WPFB_Core::GetTpls('file', $this->file_tpl_tag); if (($p = strpos($file_tpl, "%{$sort_field}%")) > 0) { // get the column index of field to sort $col_index = substr_count($file_tpl, "</t", 0, $p); $dataTableOptions["aaSorting"] = array(array($col_index, strtolower($sort_dir))); } if ($this->current_list->page_limit > 0) { $dataTableOptions["iDisplayLength"] = $this->current_list->page_limit; } $str = str_replace('/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/', " var wpfbOptions = " . json_encode($dataTableOptions) . "; " . " if('object' == typeof(options)) { for (var v in options) { wpfbOptions[v] = options[v]; } }" . " return wpfbOptions; ", $str); } return $str; }
function widget($args, $instance) { wpfb_loadclass('File', 'Category', 'Output'); extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget, $before_title . (empty($title) ? __('Search Files', WPFB) : $title) . $after_title; $prefix = "wpfb-search-widget-" . $this->id_base; $fbp_id = WPFB_Core::$settings->file_browser_post_id; $action = WPFB_Core::GetPostUrl($fbp_id); $p_in_query = strpos($action, '?') !== false; // no permalinks? $action = $p_in_query ? remove_query_arg(array('p', 'post_id', 'page_id', 'wpfb_s')) : $action; echo WPFB_Output::GetSearchForm($action, $p_in_query ? array('p' => $fbp_id) : null, ""); echo $after_widget; }