diff -r 2f6f6f7551ca -r 32102edaa81b web/wp-content/plugins/xili-language/xili-includes/xili-language-widgets.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/xili-language/xili-includes/xili-language-widgets.php Mon Nov 19 18:26:13 2012 +0100 @@ -0,0 +1,427 @@ += 2.8.0 +# 090606 - xili-language list widget is now multiple and more features + +/* thanks to http://blog.zen-dreams.com/ tutorial + + Copyright 2009-10 dev.xiligroup.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/** + * Recent_Posts widget class + * rewritten from default WP widget to suppress wp_reset_query and add sub-selection by language (current or forced) + * @since 1.4.0 + */ +class xili_Widget_Recent_Posts extends WP_Widget { + + function xili_Widget_Recent_Posts() { + $widget_ops = array('classname' => 'xili_widget_recent_entries', 'description' => __( "The most recent posts on your blog by xili-language",'xili-language-widget').' © v. '.XILILANGUAGE_VER ); + $this->WP_Widget('xili-recent-posts', __('List of recent posts','xili-language-widget'), $widget_ops); + $this->alt_option_name = 'xili_widget_recent_entries'; + + add_action( 'save_post', array(&$this, 'flush_widget_cache') ); + add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); + add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); + } + + function widget($args, $instance) { + $cache = wp_cache_get('xili_widget_recent_posts', 'widget'); + + if ( !is_array($cache) ) + $cache = array(); + + if ( isset($cache[$args['widget_id']]) ) { + echo $cache[$args['widget_id']]; + return; + } + + ob_start(); + extract($args); + + $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title']); + if ( !$number = (int) $instance['number'] ) + $number = 10; + else if ( $number < 1 ) + $number = 1; + else if ( $number > 15 ) + $number = 15; + + $the_lang = $instance['the_lang']; + if ( !isset ( $instance['post_type'] ) || $instance['post_type'] == '' ) { + $post_type_arr = array('post'); + } else { + $post_type_arr = explode (',', $instance['post_type'] ); + } + global $wp_query; + //$tmp_wp_query = $wp_query ; + if ( class_exists('xili_language') ) { + + + $tmp_query = ( isset( $wp_query->query_vars[QUETAG]) ) ? $wp_query->query_vars[QUETAG] : "" ; + $wp_query->query_vars[QUETAG] = ""; + //$wp_query = null; + if ($the_lang == '') + $thequery = array('xlrp' => 0, 'showposts' => $number, + 'post_type' => $post_type_arr , 'no_found_rows' => true, + 'post_status' => 'publish', 'ignore_sticky_posts' => 1); //2.2.3 + else if ($the_lang == '*') + $thequery = array ('xlrp' => 1, 'showposts' => $number, + 'post_type' => $post_type_arr , 'no_found_rows' => true, + 'post_status' => 'publish', 'ignore_sticky_posts' => 1, QUETAG => the_curlang()); + else + $thequery = array ('xlrp' => 1, 'showposts' => $number, + 'post_type' => $post_type_arr , 'no_found_rows' => true, + 'post_status' => 'publish', 'ignore_sticky_posts' => 1, QUETAG => $the_lang); + //echo '===='.the_curlang(); + add_action('parse_query','xiliml_add_lang_to_parsed_query'); + $r = new WP_Query($thequery); + remove_filter('parse_query','xiliml_add_lang_to_parsed_query'); + + } else { + $thequery = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1); + $r = new WP_Query($thequery); + } + + if ($r->have_posts()) : +?> + + + + +query_vars[QUETAG] = $tmp_query; + $cache[$args['widget_id']] = ob_get_flush(); + wp_cache_add('xili_widget_recent_posts', $cache, 'widget'); + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['the_lang'] = strtolower($new_instance['the_lang']); + $instance['number'] = (int) $new_instance['number']; + $instance['post_type'] = $new_instance['post_type']; + $this->flush_widget_cache(); + + $alloptions = wp_cache_get( 'alloptions', 'options' ); + if ( isset($alloptions['xili_widget_recent_entries']) ) + delete_option('xili_widget_recent_entries'); + + return $instance; + } + + function flush_widget_cache() { + wp_cache_delete('xili_widget_recent_posts', 'widget'); + } + + function form( $instance ) { + $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; + $the_lang = isset($instance['the_lang']) ? strtolower($instance['the_lang']) : ''; + if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) + $number = 5; + $post_type = isset($instance['post_type']) ? esc_attr($instance['post_type']) : 'post'; +?> +

+

+ + +

+ + +

+ +

+ +
+

+ +

+
+

+

© xili-language v.

+ 'xili_widget_recent_comments', 'description' => __( 'The most recent comments by xili-language','xili-language-widget' ).' © v. '.XILILANGUAGE_VER ); + $this->WP_Widget('xili-recent-comments', __('Recent Comments list','xili-language-widget'), $widget_ops); + $this->alt_option_name = 'xili_widget_recent_comments'; + + if ( is_active_widget(false, false, $this->id_base) ) + add_action( 'wp_head', array(&$this, 'recent_comments_style') ); + + add_action( 'comment_post', array(&$this, 'flush_widget_cache') ); + add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); + } + + function recent_comments_style() { ?> + + $number, 'status' => 'approve' ) ); + } + $output .= $before_widget; + if ( $title ) + $output .= $before_title . $title . $after_title; + + $output .= ''; + $output .= $after_widget; + + echo $output; + $cache[$args['widget_id']] = $output; + wp_cache_set('xili_widget_recent_comments', $cache, 'widget'); + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['number'] = (int) $new_instance['number']; + $this->flush_widget_cache(); + + $alloptions = wp_cache_get( 'alloptions', 'options' ); + if ( isset($alloptions['xili_widget_recent_comments']) ) + delete_option('xili_widget_recent_comments'); + + return $instance; + } + + function form( $instance ) { + $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; + $number = isset($instance['number']) ? absint($instance['number']) : 5; + +?> +

+

+ +

+

+

© xili-language v.

+ 'xili-language_Widgets', 'description' => __( "List of available languages by xili-language plugin", 'xili-language-widget' ).' © v. '.XILILANGUAGE_VER ); + $this->WP_Widget('xili_language_widgets', __("List of languages", 'xili-language-widget'), $widget_ops); + $this->alt_option_name = 'xili_language_widgets_options'; + } + + function widget( $args, $instance ) { + + extract($args, EXTR_SKIP); + $thecondition = trim( $instance['thecondition'],'!' ) ; + + if ( '' != $instance['thecondition'] && function_exists( $thecondition ) ) { + $not = ( $thecondition == $instance['thecondition'] ) ? false : true ; + $arr_params = ('' != $instance['theparams']) ? array(explode( ',', $instance['theparams'] )) : array(); + $condition_ok = ($not) ? !call_user_func_array ( $thecondition, $arr_params ) : call_user_func_array ( $thecondition, $arr_params ); + } else { + $condition_ok = true; + } + + if ( $condition_ok ) { + $output = ''; + $output .= $before_widget; + $title = apply_filters( 'widget_title', $instance['title'] ); + if ( $title ) + $output .= $before_title . $title . $after_title; + + if ( function_exists( 'xili_language_list' ) ) { + $hidden = ( $instance['hidden'] == 'hidden' ) ? true : false ; + $output .= $instance['beforelist']; + $output .= xili_language_list( $instance['beforeline'], $instance['afterline'], $instance['theoption'], false, $hidden ); + $output .= $instance['afterlist']; + } + $output .= $after_widget; + echo $output; + } + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + + $instance['title'] = strip_tags($new_instance['title']); + $instance['beforelist'] = stripslashes($new_instance['beforelist']); + $instance['beforeline'] = stripslashes($new_instance['beforeline']); + $instance['afterline'] = stripslashes($new_instance['afterline']); + $instance['afterlist'] = stripslashes($new_instance['afterlist']); + $instance['theoption'] = strip_tags(stripslashes($new_instance['theoption'])); + $instance['thecondition'] = strip_tags(stripslashes($new_instance['thecondition'])); // 1.8.4 + $instance['theparams'] = strip_tags(stripslashes($new_instance['theparams'])); + $instance['hidden'] = isset($new_instance['hidden']) ? $new_instance['hidden'] : '' ; // 2.4.0 checkbox + return $instance; + } + + function form( $instance ) { + global $xili_language; + $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; + $beforelist = isset($instance['beforelist']) ? htmlentities(stripslashes($instance['beforelist'])) : "'; + $theoption = isset($instance['theoption']) ? stripslashes($instance['theoption']) : '' ; + $thecondition = isset($instance['thecondition']) ? stripslashes($instance['thecondition']) : '' ; + $theparams = isset($instance['theparams']) ? stripslashes($instance['theparams']) : '' ; + $hidden = isset($instance['hidden']) ? $instance['hidden'] : '' ; // 1.8.9.1 + + ?> +

+

+ this_has_filter('xili_language_list')) // one external action + $xili_language->langs_list_options = array(); + if ( has_filter('xili_language_list_options') ) { // is list of options described + do_action('xili_language_list_options', $theoption); // update the list of external action + } + } + if ( class_exists('xili_language') && isset($xili_language->langs_list_options) && $xili_language->langs_list_options != array()) { + echo '
'; + } else { + echo '
'; + } + + ?> +    + +
+ : + + + : + + + : + + + : +
+
+ : + + ( ) +
+

© xili-language v.

+ \ No newline at end of file