diff -r 2f6f6f7551ca -r 32102edaa81b web/wp-content/plugins/xili-dictionary/xili-dictionary.php
--- a/web/wp-content/plugins/xili-dictionary/xili-dictionary.php Thu Sep 16 15:45:36 2010 +0000
+++ b/web/wp-content/plugins/xili-dictionary/xili-dictionary.php Mon Nov 19 18:26:13 2012 +0100
@@ -2,110 +2,2269 @@
/*
Plugin Name: xili-dictionary
Plugin URI: http://dev.xiligroup.com/xili-dictionary/
-Description: ONLY for >= WP 2.8. This plugin is a tool using wordpress's taxonomy for localized themes or multilingual themes managed by xili-language - a powerful tool to create .mo file(s) on the fly in the theme's folder and more... -
-Author: MS
-Version: 1.0.3
+Description: A tool using wordpress's CPT and taxonomy for localized themes or multilingual themes managed by xili-language - a powerful tool to create .mo file(s) on the fly in the theme's folder and more... - ONLY for >= WP 3.2.1 -
+Author: dev.xiligroup - MS
+Version: 2.2.0
Author URI: http://dev.xiligroup.com
+License: GPLv2
+Text Domain: xili-dictionary
+Domain Path: /languages/
*/
-# beta 1.0.3 - fixes some directories issues in (rare) xamp servers and in theme's terms import. Create .po with empty translations.
-# beta 1.0.2 - JS and vars, create lang list, if xili-language absent, for international themes - lot of fixes
-# beta 1.0.1 - add scripts for form with plural msg (id or str)
-# beta 1.0.0 - use pomo libraries and classes - ONLY >= 2.8
-# beta 0.9.9 - fixes existing msgid terms - better log display when importing theme's terms
-# beta 0.9.8.2 - more html tags in msg str or id
-# beta 0.9.8.1 - some fixes for IIS server and PHP 5.2.1
-# beta 0.9.8 - WP 2.8 - fix query error
-# beta 0.9.7.3 <- to - see readme.txt - from 0.9.4
+# 2.2.0 - 120922 - fixes issues with .mo and .po inserts - better messages and warning
+# 2.1.3 - 120728 - fixes
+# 2.1.2 - 120715 - list in msg edit - new query - new metabox - new pointers - ...
+# 2.1.1 - 120710 - fixes - new icons
+# 2.1.0 - 120507 - options to save on new local-xx_XX.mo and more... needs XL 2.6
+# 2.0.0 - 120417 - repository as current
+# beta 2.0.0-rc4 - 120415 - fixes
+# beta 2.0.0-rc3 - 120406 - pre-tests WP3.4: fixes metaboxes columns, conditional edit link in list
+# beta 2.0.0-rc2 - 120402 - latest fixes (writers)
+# beta 2.0.0-rc1 - 120318 - before svn
+# beta 2.0.0 - 120219 - new way of saving lines in CPT
+
+
+#
+# now msg lines full commented as in .po
+# now translated lines (msgstr) attached to same taxonomy as xili-language
+# before upgrading from 1.4.4 to 2.0, export all the dictionary in .po files and empty the dictionary.
+#
+# beta 1.4.4 - 111221 - fixes
+# between 0.9.3 and 1.4.4 see version 1.4.4 - 20120219
# beta 0.9.3 - first published - 090131 MS
-# This plugin is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This plugin 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this plugin; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-define('XILIDICTIONARY_VER','1.0.3');
+define('XILIDICTIONARY_VER','2.2.0');
include_once(ABSPATH . WPINC . '/pomo/po.php'); /* not included in wp-settings */
+// the class
class xili_dictionary {
+ var $plugin_url = ''; // Url to this plugin - see construct
+ var $plugin_path = ''; // The path to this plugin - see construct
+
var $subselect = ''; /* used to subselect by msgid or languages*/
+ var $searchtranslated = ''; /* used to search untranslated - 2.1.2 */
+ var $languages_key_slug = array(); // used for slug to other items
+ var $msg_action_message = '';
var $xililanguage = ''; /* neveractive isactive wasactive */
+ var $xililanguage_ms = false; // xlms
var $tempoutput = "";
- var $langfolder ='/'; /* where po or mo files */
+ var $langfolder =''; /* where po or mo files */
var $xili_settings; /* saved in options */
var $ossep = "/"; /* for recursive file search in xamp */
+
+ // 2.0 new vars
+ var $xdmsg = "xdmsg";
+ var $xd_settings_page = "edit.php?post_type=xdmsg&page=dictionary_page"; // now in CPT menu
- function xili_dictionary($langsfolder = '/') {
+ // post meta
+ var $ctxt_meta = '_xdmsg_ctxt'; // to change to xdctxt
+ var $msgtype_meta = '_xdmsg_msgtype'; // to hidden
+ var $msgchild_meta = '_xdmsg_msgchild';
+ var $msglang_meta = '_xdmsg_msglangs';
+ var $msgidlang_meta = '_xdmsg_msgid_id'; // origin of the msgstr
+ var $msg_extracted_comments = '_xdmsg_extracted_comments';
+ var $msg_translator_comments = '_xdmsg_translator_comments';
+ var $msg_flags = '_xdmsg_flags';
+
+ var $origin_theme = ""; // used when importing
+ var $local_tag = '[local]';
+ var $exists_style_ext = false; // wp_enqueue_style( 'xili_dictionary_stylesheet' );
+ var $style_message = '';
+ var $xilidev_folder = '/xilidev-libraries'; //must be in plugins
+
+ var $theme_mos = array(); // $this->get_pomo_from_theme();
+ var $local_mos = array() ; // $this->get_pomo_from_theme( true ); // 2.1
+ // is_multisite
+ var $file_site_mos = array() ; // $this->get_pomo_from_site(); // since 1.2.0 - mo of site
+ var $file_site_local_mos = array() ; // $this->get_pomo_from_site( true );
+
+ var $default_langs_array = array(); // default languages
+ var $internal_list = false; // created by xl or xd
+
+ var $importing_mode = false ; // for new action by hand ( action save when new )
+ var $msg_str_labels = array (
+ 'msgid' => 'msgid', 'msgid_plural' => 'msgid_plural',
+ 'msgstr' => 'msgstr', 'msgstr_0' => 'msgstr[0]',
+ 'msgstr_1' => 'msgstr[1]', 'msgstr_2' => 'msgstr[2]',
+ 'msgstr_3' => 'msgstr[3]', 'msgstr_4' => 'msgstr[4]'
+ ) ;
+ var $importing_po_comments = '' ; // mode replace or append 2.0-rc2
+ var $create_line_lang = ''; // line between box
+
+ var $langs_group_id; /* group ID and Term Taxo ID */
+ var $langs_group_tt_id;
+
+
+
+ public function xili_dictionary( $langsfolder = '/' ) { // ?? php4
+ $this->__construct( $langsfolder );
+ }
+
+ public function __construct( $langsfolder = '/' ) {
+ global $wp_version;
/* activated when first activation of plug */
- register_activation_hook(__FILE__,array(&$this,'xili_dictionary_activation'));
+ // 2.0
+ define ( 'XDMSG', $this->xdmsg ); // CPT to change from msg to xdmsg (less generic) 20120217
+
+ $this->plugin_path = plugin_dir_path(__FILE__) ;
+ $this->plugin_url = plugins_url('', __FILE__) ;
+
+ register_activation_hook( __FILE__, array( &$this,'xili_dictionary_activation') );
+
$this->ossep = strtoupper(substr(PHP_OS,0,3)=='WIN')?'\\':'/'; /* for rare xamp servers*/
+
/* get current settings - name of taxonomy - name of query-tag */
$this->xililanguage_state();
- $this->xili_settings = get_option('xili_dictionary_settings');
- if(empty($this->xili_settings)) {
+ $this->xili_settings = get_option('xili_dictionary_settings');
+ if(empty($this->xili_settings) || $this->xili_settings['taxonomy'] != 'dictionary') { // to fix
$this->xili_dictionary_activation();
$this->xili_settings = get_option('xili_dictionary_settings');
}
- define('DTAXONAME',$this->xili_settings['taxonomy']);
- define('XDDICTLANGS','xl-'.DTAXONAME.'-langs');
- /** * @since 1.0 */
- define('XPLURAL','[XPLURAL]'); /* to separate singular and plural entries */
-
-
- /* add new taxonomy in available taxonomies here dictionary terms */
- register_taxonomy( DTAXONAME, 'post',array('hierarchical' => true, 'update_count_callback' => ''));
- /* groups of terms by langs */
- register_taxonomy( XDDICTLANGS, 'term',array('hierarchical' => false, 'update_count_callback' => ''));
/* test if version changed */
$version = $this->xili_settings['version'];
- if ($version <= '0.2') {
+ if ( $version <= '0.2' ) {
/* update relationships for grouping existing dictionary terms */
$this->update_terms_langs_grouping();
$this->xili_settings['version'] = '1.0';
update_option('xili_dictionary_settings', $this->xili_settings);
+ }
+ if ( $version == '1.0' ) {
+ $this->xili_settings['external_xd_style'] = "off";
+ $this->xili_settings['version'] = '2.0';
+ update_option('xili_dictionary_settings', $this->xili_settings);
+ }
+ if ( $version == '2.0' ) {
+ $this->update_postmeta_msgid();
+ $this->xili_settings['version'] = '2.1';
+ update_option('xili_dictionary_settings', $this->xili_settings);
}
+
$this->fill_default_languages_list();
/* Actions */
- add_action('admin_menu', array(&$this,'xili_add_dict_pages'));
- add_action('init', array(&$this, 'init_textdomain'));
- add_filter('plugin_action_links', array(&$this,'xilidict_filter_plugin_actions'), 10, 2);
+ /* admin */
+ add_action( 'admin_init', array(&$this,'admin_init') ); // 1.3.0
+ add_action( 'admin_init', array(&$this,'ext_style_init') ); // 2.1
+ add_action( 'admin_menu', array(&$this,'xili_add_dict_pages') );
+
+ add_action( 'add_meta_boxes', array(&$this, 'add_custom_box_in_post_msg') ); // 2.1.2
+
+ add_action( 'init', array(&$this, 'xili_dictionary_register_taxonomies')); // and init
+
+ add_action( 'init', array(&$this, 'post_type_msg') );
+
+ if ( is_admin() ) {
+ add_filter( 'manage_posts_columns', array(&$this,'xili_manage_column_name') ,9 , 1);
+ add_filter( "manage_pages_custom_column", array(&$this,'xili_manage_column_row'), 9, 2); // hierarchic
+ add_filter( 'manage_edit-'.XDMSG.'_sortable_columns', array(&$this,'msgcontent_column_register_sortable') );
+ add_filter( 'request', array(&$this,'msgcontent_column_orderby' ) );
+
+ if ( !class_exists ('xili_language' ) )
+ add_action( 'restrict_manage_posts', array(&$this,'restrict_manage_languages_posts') );
+
+ add_action( 'restrict_manage_posts', array(&$this,'restrict_manage_writer_posts'), 11 );
+ add_action( 'restrict_manage_posts', array(&$this,'restrict_manage_origin_posts'), 10 );
+ add_action( 'pre_get_posts', array(&$this,'wpse6066_pre_get_posts' ) );
+
+
+ add_action( 'wp_print_scripts', array(&$this,'auto_save_unsetting' ), 2 ); // before other
+
+ add_filter( 'user_can_richedit', array(&$this, 'disable_richedit_for_cpt') );
+
+ if ( defined ('WP_DEBUG') && WP_DEBUG != true ) {
+ add_filter( 'page_row_actions', array(&$this, 'remove_quick_edit'), 10, 1); // before to solve metas column
+ }
+ add_action( 'save_post', array(&$this, 'custom_post_type_title'),11 ,2); //
+ add_action( 'save_post', array(&$this, 'msgid_post_new_create'),12 ,2 );
+ add_action( 'save_post', array(&$this, 'update_msg_comments'),13, 2 ); // comments and contexts
+ add_filter( 'post_updated_messages', array(&$this, 'msg_post_messages'));
+
+ add_action( 'before_delete_post', array(&$this, 'msgid_post_links_delete') );
+ add_action( 'admin_print_styles-post.php', array(&$this, 'print_styles_xdmsg_edit') );
+ add_action( 'admin_print_styles-post-new.php', array(&$this, 'print_styles_xdmsg_edit') );
+
+ add_action( 'admin_print_styles-post.php', array(&$this,'admin_enqueue_styles') );
+ add_action( 'admin_print_scripts-post.php', array(&$this,'admin_enqueue_scripts') );
+
+ add_action( 'admin_print_styles-edit.php', array(&$this, 'print_styles_xdmsg_list') ); // list of msgs
+
+ add_action( 'admin_print_styles-xdmsg_page_dictionary_page', array(&$this, 'print_styles_xdmsg_tool') );
+
+
+ add_action( 'add_meta_boxes_' . XDMSG, array(&$this, 'msg_update_action')); // to locally update files from editing...
+ }
+
+ add_filter( 'plugin_action_links', array(&$this,'xilidict_filter_plugin_actions'), 10, 2);
+
+ /* special to detect theme changing since 1.1.9 */
+ add_action( 'switch_theme', array(&$this,'xd_theme_switched') );
+
+ add_action( 'contextual_help', array(&$this,'add_help_text'), 10, 3 ); /* 1.2.2 */
+
+
+ if ( class_exists('xili_language_ms') ) $this->xililanguage_ms = true; // 1.3.4
+
}
+
+ /* wp 3.0 WP-net */
+ function xili_dictionary_register_taxonomies () {
+
+ if ( is_admin() ) {
+ global $wp_roles;
+
+ if ( current_user_can ('activate_plugins') ) {
+ $wp_roles->add_cap ('administrator', 'xili_dictionary_set');
+ }
+ }
+ if (function_exists('is_child_theme') && is_child_theme() ) { // move here from init 1.4.1
+ if ( isset( $this->xili_settings['langs_in_root_theme'] ) && $this->xili_settings['langs_in_root_theme'] == 'root' ) { // for future uses
+ $this->get_template_directory = get_template_directory();
+ } else {
+ $this->get_template_directory = get_stylesheet_directory();
+ }
+ } else {
+ $this->get_template_directory = get_template_directory();
+ }
+ $this->init_textdomain();
+
+ // new method for languages 2.0
+ $this->internal_list = $this->default_language_taxonomy ();
+
+ if ( $this->internal_list ) { // test if empty
+ $listlanguages = get_terms(TAXONAME, array('hide_empty' => false));
+ if ( $listlanguages == array() ) {
+ $this->create_default_languages();
+ }
+ }
+ $thegroup = get_terms( TAXOLANGSGROUP, array('hide_empty' => false,'slug' => 'the-langs-group'));
+ if ( $thegroup != array() ) { // notice on first start
+ $this->langs_group_id = $thegroup[0]->term_id;
+ $this->langs_group_tt_id = $thegroup[0]->term_taxonomy_id;
+ }
+ }
+
function xili_dictionary_activation() {
- $this->xili_settings = get_option('xili_dictionary_settings');
- if(empty($this->xili_settings)) {
+ $this->xili_settings = get_option('xili_dictionary_settings');
+ if ( empty($this->xili_settings) || $this->xili_settings['taxonomy'] != 'dictionary') { // to fix
$submitted_settings = array(
'taxonomy' => 'dictionary',
'langs_folder' => '',
- 'version' => '1.0'
+ 'external_xd_style' => 'off',
+ 'version' => '2.1'
);
update_option('xili_dictionary_settings', $submitted_settings);
}
}
- /** * add js in admin * @updated 1.0.2 */
- function xili_add_js() {
- wp_enqueue_script( 'xd-plural', '/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/plural.php?var='.XPLURAL, array('jquery'), XILIDICTIONARY_VER);
+ function post_type_msg() {
+
+ $labels = array(
+ 'name' => _x('xili-dictionary©', 'post type general name', 'xili-dictionary'),
+ 'singular_name' => _x('Msg', 'post type singular name', 'xili-dictionary'),
+ 'add_new' => __('New msgid', 'xili-dictionary'),
+ 'add_new_item' => __('Add New Msgid', 'xili-dictionary'),
+ 'edit_item' => __('Edit Msg', 'xili-dictionary'),
+ 'new_item' => __('New Msg', 'xili-dictionary'),
+ 'view_item' => __('View Msg', 'xili-dictionary'),
+ 'search_items' => __('Search Msg', 'xili-dictionary'),
+ 'not_found' => __('No Msg found', 'xili-dictionary'),
+ 'not_found_in_trash' => __('No Msg found in Trash', 'xili-dictionary'),
+ 'parent_item_colon' => ''
+ );
+
+ // impossible to see in front-end (no display in edit list)
+ $args = array(
+ 'labels' => $labels,
+ 'public' => false,
+ 'publicly_queryable' => false,
+ '_edit_link' => 'post.php?post=%d',
+ '_builtin' => false,
+ 'show_ui' => true,
+ 'query_var' => true,
+ 'rewrite' => false,
+ 'capability_type' => 'post',
+ 'show_in_menu' => current_user_can ('xili_dictionary_set'), // ?? if not admin
+ 'hierarchical' => true,
+ 'menu_position' => null,
+ 'supports' => array('author','editor', 'excerpt','custom-fields','page-attributes'),
+ 'taxonomies' => array ('appearance', 'writer', 'origin' ),
+ 'rewrite' => array( 'slug' => XDMSG, 'with_front' => FALSE, ),
+ 'menu_icon' => plugins_url( 'images/xilidico-logo-16.jpg', __FILE__ ) // 16px16
+ );
+ register_post_type(XDMSG,$args);
+
+ register_taxonomy( 'writer', array(XDMSG),
+ array( 'hierarchical' => true,
+ 'label' => __('Writer','xili-dictionary'),
+ 'rewrite' => true,
+ 'query_var' => 'writer_name',
+ 'public' => false,
+ 'show_ui' => true,
+ )
+ );
+ /*
+ register_taxonomy( 'appearance', array(XDMSG),
+ array( 'hierarchical' => true, // theme and child
+ 'label' => __('Theme','xili-dictionary'),
+ 'rewrite' => true,
+ 'query_var' => 'theme_slug',
+ 'public' => false,
+ 'show_ui' => true,
+ )
+ );
+ */
+ register_taxonomy( 'origin', array(XDMSG),
+ array('hierarchical' => false,
+ 'label' => __('Origin','xili-dictionary'),
+ 'query_var' => 'origin',
+ 'rewrite' => array('slug' => 'origin' )
+ )
+ );
+ }
+
+ /**
+ * register language taxonomy if no xili_language - 'update_count_callback' => array(&$this, '_update_post_lang_count'),
+ *
+ *
+ */
+ function default_language_taxonomy () {
+ if ( ! defined ( 'TAXONAME' ) ) {
+ if ( ! defined ( 'QUETAG' ) ) define ('QUETAG', 'lang');
+ define ('TAXONAME', 'language');
+ register_taxonomy( TAXONAME, 'post', array('hierarchical' => false, 'label' => false, 'rewrite' => false , 'show_ui' => false, '_builtin' => false, 'query_var' => QUETAG ));
+ define('TAXOLANGSGROUP', 'languages_group');
+ register_taxonomy( TAXOLANGSGROUP, 'term', array('hierarchical' => false, 'update_count_callback' => '', 'show_ui' => false, 'label'=>false, 'rewrite' => false, '_builtin' => false ));
+ $thegroup = get_terms(TAXOLANGSGROUP, array('hide_empty' => false,'slug' => 'the-langs-group'));
+ if ( array() == $thegroup ) {
+ $args = array( 'alias_of' => '', 'description' => 'the group of languages', 'parent' => 0, 'slug' =>'the-langs-group');
+ wp_insert_term( 'the-langs-group', TAXOLANGSGROUP, $args); /* create and link to existing langs */
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * add styles in edit msg screenstyle="clear:both; border-top:1px solid #666;"
+ *
+ */
+ function print_styles_xdmsg_edit ( ) {
+ global $post;
+ if ( get_post_type( $post->ID ) == XDMSG ) {
+ echo ''."\n";
+ echo ''."\n";
+ if ( $this->exists_style_ext && $this->xili_settings['external_xd_style'] == "on" ) wp_enqueue_style( 'xili_dictionary_stylesheet' );
+ }
+ }
+
+ /**
+ * add styles in list of msgs screen icon32-posts-xdmsg
+ *
+ */
+ function print_styles_xdmsg_list ( ) {
+
+ if ( isset( $_GET['post_type']) && $_GET['post_type'] == XDMSG ) {
+
+ echo ''."\n";
+ echo ''."\n";
+ if ( $this->exists_style_ext && $this->xili_settings['external_xd_style'] == "on" ) wp_enqueue_style( 'xili_dictionary_stylesheet' );
+
+ }
+ }
+
+ /**
+ * add styles in tool screen
+ *
+ */
+ function print_styles_xdmsg_tool ( ) {
+ echo ''."\n";
+ echo ''."\n";
+ if ( $this->exists_style_ext && $this->xili_settings['external_xd_style'] == "on" ) wp_enqueue_style( 'xili_dictionary_stylesheet' );
+ }
+
+
+ /**
+ * style for new dashboard
+ * @since 2.1
+ *
+ */
+ function ext_style_init () {
+ // test successively style file in theme, plugins, current plugin subfolder
+ if ( file_exists ( get_stylesheet_directory().'/xili-css/xd-style.css' ) ) { // in child theme
+ $this->exists_style_ext = true;
+ $this->style_folder = get_stylesheet_directory_uri();
+ $this->style_flag_folder_path = get_stylesheet_directory () . '/images/flags/';
+ $this->style_message = __( 'xd-style.css is in sub-folder xili-css of current theme folder', 'xili-dictionary' );
+ } elseif ( file_exists( WP_PLUGIN_DIR . $this->xilidev_folder . '/xili-css/xd-style.css' ) ) { // in plugin xilidev-libraries
+ $this->exists_style_ext = true;
+ $this->style_folder = plugins_url() . $this->xilidev_folder;
+ $this->style_flag_folder_path = WP_PLUGIN_DIR . $this->xilidev_folder . '/xili-css/flags/' ;
+ $this->style_message = sprintf( __( 'xd-style.css is in sub-folder xili-css of %s folder', 'xili-dictionary' ), $this->style_folder );
+ } elseif ( file_exists ( $this->plugin_path.'/xili-css/xd-style.css' ) ) { // in current plugin
+ $this->exists_style_ext = true;
+ $this->style_folder = $this->plugin_url ;
+ $this->style_flag_folder_path = $this->plugin_path . '/xili-css/flags/' ;
+ $this->style_message = __( 'xd-style.css is in sub-folder xili-css of xili-dictionary plugin folder (example)', 'xili-dictionary' );
+ } else {
+ $this->style_message = __( 'no xd-style.css', 'xili-dictionary' );
+ }
+ if ( $this->exists_style_ext ) wp_register_style( 'xili_dictionary_stylesheet', $this->style_folder . '/xili-css/xd-style.css' );
+ }
+
+
+ /**
+ * create default languages if no xili_language
+ *
+ *
+ */
+ function create_default_languages () {
+
+ $this->default_langs_array = array(
+ 'en_us' => array('en_US', 'english'),
+ 'fr_fr' => array('fr_FR', 'french'),
+ 'de_de' => array('de_DE', 'german'),
+ 'es_es' => array('es_ES', 'spanish'),
+ 'it_it' => array('it_IT', 'italian'),
+ 'pt_pt' => array('pt_PT', 'portuguese'),
+ 'ru_ru' => array('ru_RU', 'russian'),
+ 'zh_cn' => array('zh_CN', 'chinese'),
+ 'ja' => array('ja', 'japanese'),
+ 'ar_ar' => array('ar_AR', 'arabic')
+ );
+
+ $term = 'en_US';
+ $args = array( 'alias_of' => '', 'description' => 'english', 'parent' => 0, 'slug' =>'en_us');
+ $theids = $this->safe_lang_term_creation ( $term, $args );
+ wp_set_object_terms($theids['term_id'], 'the-langs-group', TAXOLANGSGROUP);
+
+ /* default values */
+ if ( ''!= WPLANG && ( strlen( WPLANG )==5 || strlen( WPLANG ) == 2 ) ) : // for japanese
+ $this->default_lang = WPLANG;
+ else:
+ $this->default_lang = 'en_US';
+ endif;
+
+ $term = $this->default_lang;
+ $desc = $this->default_lang;
+ $slug = strtolower( $this->default_lang ) ; // 2.3.1
+ if (!defined('WPLANG') || $this->default_lang == 'en_US' || $this->default_lang == '' ) {
+ $term = 'fr_FR'; $desc = 'French'; $slug = 'fr_fr' ;
+ }
+ $args = array( 'alias_of' => '', 'description' => $desc, 'parent' => 0, 'slug' => $slug);
+
+ $theids = $this->safe_lang_term_creation ( $term, $args ) ;
+ wp_set_object_terms($theids['term_id'], 'the-langs-group', TAXOLANGSGROUP);
+
+ }
+
+ /**
+ * Safe language term creation (if XL inactive)
+ *
+ * @since 2.0 (from XL 2.4.1)
+ */
+ function safe_lang_term_creation ( $term, $args ) {
+ global $wpdb ;
+ // test if exists with other slug or name
+ if ( $term_id = term_exists( $term ) ) {
+ $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name, slug FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
+ if ( $existing_term['slug'] != $args['slug'] ) {
+ $res = wp_insert_term( $term.'xl', TAXONAME, $args); // temp insert with temp other name
+ $args['name'] = $term ;
+ $res = wp_update_term( $res['term_id'], TAXONAME, $args);
+ } else {
+ return new WP_Error('term_exists', __('A term with the name provided already exists.'), $term_id );
+ }
+ } else {
+ $res = wp_insert_term( $term, TAXONAME, $args);
+ }
+ if (is_wp_error($res)) {
+ return $res ;
+ } else {
+ $theids = $res;
+ }
+ return $theids ;
+ }
+
+ /**
+ * call from filter disable_richedit
+ *
+ * disable rich editor in msg cpt
+ *
+ * @since 2.0
+ *
+ */
+ function disable_richedit_for_cpt ( $default ) {
+ global $post;
+ if ( XDMSG == get_post_type( $post ) )
+ return false;
+ return $default;
+ }
+ function remove_quick_edit( $actions ) {
+ if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] == XDMSG )
+ unset($actions['inline hide-if-no-js']);
+
+ return $actions;
+ }
+
+
+ /**
+ * call from filter save_post
+ *
+ * save content in title - fixes empty msgid
+ *
+ * @since 2.0
+ *
+ */
+ function custom_post_type_title ( $post_id, $post ) {
+ global $wpdb;
+ if ( get_post_type( $post_id ) == XDMSG ) {
+ $where = array( 'ID' => $post_id );
+ $what = array ();
+
+ if ( false === strpos( $post->post_title, 'MSG:' ) ) {
+ $title = 'MSG:'.$post_id;
+ $what['post_title'] = $title ;
+ }
+
+ if ( $post->post_content == '' ) {
+ $what['post_content'] = "XD say: do not save empty ".$post_id;
+ }
+ if ( $what != array() )
+ $wpdb->update( $wpdb->posts, $what, $where );
+ }
+ }
+
+ /**
+ * clean msgid postmeta before deleting
+ */
+ function msgid_post_links_delete ( $post_id ) {
+ // type of msg
+ if ( get_post_type( $post_id ) == XDMSG ) {
+ $type = get_post_meta ( $post_id, $this->msgtype_meta, true);
+
+ if ( $type == 'msgid_plural' ) {
+
+ $parent = get_post($post_id)->post_parent;
+ $res = get_post_meta ( $parent, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $res != '' ) {
+ unset ( $thechilds['msgid']['plural'] ) ;
+ update_post_meta ( $parent, $this->msgchild_meta, $thechilds );
+ }
+
+ } elseif ( $type != 'msgid' ) {
+ $langs = get_the_terms( $post_id, TAXONAME );
+ $target_lang = $langs[0]->name ;
+ // id of msg id or parent
+ if ( $type == 'msgstr' && $target_lang != '' ) {
+ $msgid_ID = get_post_meta ( $post_id, $this->msgidlang_meta , true);
+ $res = get_post_meta ( $msgid_ID, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $res != '' && is_array ( $thelangs ) ) {
+
+ unset ( $thelangs['msgstrlangs'][$target_lang]['msgstr'] ) ;
+ update_post_meta ( $msgid_ID, $this->msglang_meta, $thelangs ); // update id post_meta
+ }
+ } elseif ( false !== strpos( $type, 'msgstr_' ) && $target_lang != '' ) {
+ $indices = explode ('_', $type);
+ $msgid_ID = get_post_meta ( $post_id, $this->msgidlang_meta , true);
+ if ( $indices[1] == 0 ) {
+ $res = get_post_meta ( $msgid_ID, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $res != '' && is_array ( $thelangs ) ) {
+ unset ( $thelangs['msgstrlangs'][$target_lang]['msgstr_0'] ) ;
+ // delete childs or trash ??
+ // ?? recursive
+ update_post_meta ( $msgid_ID, $this->msglang_meta, $thelangs ); // update id post_meta
+ }
+ } else {
+ $res = get_post_meta ( $msgid_ID, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $res != '' && is_array ( $thelangs ) ) {
+ if ( isset ( $thelangs['msgstrlangs'][$target_lang]['msgstr_0'] ) ) {
+ $parent = $thelangs['msgstrlangs'][$target_lang]['msgstr_0'] ;
+ $res = get_post_meta ( $parent, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $res != '' ) {
+ unset ( $thechilds['msgstr']['plural'][$indices[1]] ) ;
+ update_post_meta ( $parent, $this->msgchild_meta, $thechilds );
+ }
+ }
+ }
+ } // indice > 0
+ } // str plural
+ } // msgstr
+ } // XDMSG
+ }
+
+ /**
+ * a new msgid is created manually
+ */
+ function msgid_post_new_create ( $post_id, $post ) {
+ global $wpdb;
+ if ( isset($_POST['_inline_edit']) ) return;
+ if ( isset( $_GET['bulk_edit']) ) return;
+ if ( get_post_type( $post_id ) == XDMSG ) {
+ if ( !wp_is_post_revision( $post_id ) && $this->importing_mode != true ) {
+
+ //$temp_post = $this->temp_get_post ( $post_id );
+ $type = get_post_meta ( $post_id, $this->msgtype_meta, true ) ;
+ if ( $type == "" ) {
+ update_post_meta ( $post_id, $this->msgtype_meta, 'msgid' );
+ update_post_meta ( $post_id, $this->msglang_meta, array() );
+ update_post_meta ( $post_id, $this->msg_extracted_comments, $this->local_tag . ' '); // 2.2.0 local by default if hand created
+ }
+ $result = $this->msgid_exists ( $post->post_content );
+ if ( $result === false || $result[0] == $post_id ) {
+ return ;
+ } else {
+ if ( $type == get_post_meta ( $result[0], $this->msgtype_meta, true ) && $type == 'msgid') {
+ $newcontent = sprintf( __('msgid exists as %d with content: %s','xili-dictionary'), $result[0], $post->post_content ) ;
+ $where = array( 'ID' => $post_id );
+ $wpdb->update( $wpdb->posts, array( 'post_content' => $newcontent ), $where );
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Main "dashboard" box in msg edit to display and link the series of msg
+ *
+ * @since 2.0
+ * @updated 2.1.2 - called by action add_meta_boxes
+ *
+ */
+ function add_custom_box_in_post_msg () {
+ $singular_name = __('series','xili-dictionary');
+
+ add_meta_box('msg_state', sprintf(__("msg %s",'xili-dictionary'), $singular_name), array(&$this,'msg_state_box'), XDMSG , 'normal','high');
+ if ( get_current_screen()->action != 'add' ) { // only for edit not new
+ add_meta_box('msg_untranslated_list', sprintf(__("List of MSG %s to translate",'xili-dictionary'), $singular_name), array(&$this,'msg_untranslated_list_box'), XDMSG , 'normal','high');
+ add_meta_box('msg_tools_shortcuts', __("Shortcuts to update mo files",'xili-dictionary'), array(&$this,'msg_tools_shortcuts_box'), XDMSG , 'side','high');
+ }
+ }
+
+ function mo_files_array () {
+ $this->theme_mos = $this->get_pomo_from_theme();
+ $this->local_mos = $this->get_pomo_from_theme( true ); // 2.1
+ if ( is_multisite() ) {
+ $this->file_site_mos = $this->get_pomo_from_site(); // since 1.2.0 - mo of site
+ $this->file_site_local_mos = $this->get_pomo_from_site( true );
+ }
+ }
+
+ function get_list_languages () {
+ $listlanguages = $this->get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' );
+ $this->languages_key_slug = array();
+ foreach ( $listlanguages as $language ) {
+ $this->languages_key_slug[$language->slug] = array ('name'=>$language->name, 'description'=>$language->description );
+ }
+ return $listlanguages;
+ }
+
+
+ /**
+ * display shortcut links to update mo
+ *
+ * called add_meta_box('msg_tools_shortcuts'
+ *
+ *
+ */
+ function msg_tools_shortcuts_box ( $post ) {
+ $post_ID = $post->ID;
+ $lang = $this->cur_lang ( $post_ID );
+
+ if ( $lang ) {
+ $link_theme_mo = wp_nonce_url (admin_url().'post.php?post='.$post_ID.'&action=edit&msgupdate=updatetheme&langstr='.$lang->name.'&message=33', 'xd-updatemo');
+ $link_local_mo = wp_nonce_url (admin_url().'post.php?post='.$post_ID.'&action=edit&msgupdate=updatelocal&langstr='.$lang->name.'&message=34', 'xd-updatemo');
+ if ( function_exists('is_child_theme') && is_child_theme() ) { // 1.8.1 and WP 3.0
+ $theme_name = get_option("stylesheet");
+ } else {
+ $theme_name = get_option("template");
+ }
+ echo '
' . sprintf(__('This msg translation is in %1$s (%2$s)','xili-dictionary'),$lang->description, $lang->name).'
';
+ echo ''. __('Updating shortcuts', 'xili-dictionary').' ';
+
+ if ( $this->count_msgids ( $lang->name, true ) > 0 ) {
+ echo '' . sprintf(''.__('Update','xili-dictionary').' local-%3$s.mo ','#', '#', $lang->name).'
';
+ } else {
+ echo '' . sprintf( __('No local translated msgid to be saved in %s','xili-dictionary'), ' local-'.$lang->name.'.mo' ) . '
';
+ }
+
+ echo '' . sprintf(__('It is possible to update the .mo files of current theme %s','xili-dictionary'), ''.$theme_name.' ' ).'
';
+ echo '' . __('Before to use this button, it is very important that you verify that your term list is quite achieved inside the dictionary. It is because the original .mo delivered with theme is updated (erased) !!!', 'xili-dictionary') .'
';
+
+ if ( $this->count_msgids ( $lang->name, false, $theme_name ) > 0 ) {
+ echo '' . sprintf(''.__('Update','xili-dictionary').' %3$s.mo ','#', '#', $lang->name).'
';
+ } else {
+ echo '' . sprintf( __('No translated msgid to be saved in %s','xili-dictionary'), $lang->name.'.mo' ) . '
';
+ }
+
+ //echo '- ' . sprintf('%3$s.mo - '.__('local','xili-dictionary').'-%3$s.mo ',$link_theme_mo, $link_local_mo, $lang->name).'
';
+ echo ''.$this->msg_action_message.' ';
+ } else {
+
+ echo '' . __('Links are available if a translation (msgstr) is edited.','xili-dictionary').'
';
+ }
+
+ if ( $lang ) {
+ ?>
+
+ XD v.
+
+ xili_settings['langs_folder'];
+ $this->langfolder = ( $langfolderset !='' ) ? $langfolderset.'/' : '/';
+ // doublon
+ $this->langfolder = str_replace ("//","/", $this->langfolder ); // upgrading... 2.0 and sub folder sub
+ if ( isset ($_GET['msgupdate'] ) && isset ($_GET['langstr']) ) { // shortcut to update .mo - 2.1.2
+ check_admin_referer( 'xd-updatemo' );
+ $filetype = $_GET['msgupdate'];
+ $selectlang = $_GET['langstr'];
+
+ if ( is_multisite() ) {
+ if (($uploads = xili_upload_dir()) && false === $uploads['error'] ) {
+
+ if ( $filetype == 'updatelocal' ) { // only current site - need tools for other superadmin place
+ $local = 'local-';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $uploads['path']."/local-".$selectlang.".mo" ;
+
+ } else {
+ if ( is_child_theme() ) {
+ $theme_name = get_option("stylesheet");
+ } else {
+ $theme_name = get_option("template");
+ }
+ $extract_array [ 'origin' ] = array( $theme_name ); // only if assigned to current theme domain
+
+ $local = '';
+ $file = $uploads['path']."/".$selectlang.".mo" ;
+
+ }
+ $mo = $this->from_cpt_to_POMO_wpmu ( $selectlang, 'mo', true, $extract_array ); // do diff if not superadmin
+ }
+
+
+ } else { // standalone
+
+ if ( $filetype == 'updatelocal' ) {
+ $local = 'local-';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $this->get_template_directory.$this->langfolder.'local-'.$selectlang.'.mo' ;
+
+ } else {
+ if ( is_child_theme() ) {
+ $theme_name = get_option("stylesheet");
+ } else {
+ $theme_name = get_option("template");
+ }
+ $extract_array [ 'origin' ] = array( $theme_name );
+ $local = '';
+ $file = '';
+ }
+ $mo = $this->from_cpt_to_POMO ( $selectlang, 'mo', $extract_array );
+ }
+
+ if ( count ($mo->entries) > 0 ){
+
+ if ( false === $this->Save_MO_to_file ( $selectlang , $mo, $file ) ) {
+ $this->msg_action_message = sprintf(''.__('Error with File %s !', 'xili-dictionary').' ('.$file.')', $local.$selectlang.'.mo');
+ } else {
+ $this->msg_action_message = sprintf(__('File %1s updated with %2s msgids', 'xili-dictionary'), $local.$selectlang.'.mo', count ($mo->entries) );
+ }
+
+ } else {
+ $this->msg_action_message = sprintf(''.__('Nothing modified in %s, file not updated', 'xili-dictionary').' ', $local.$selectlang.'.mo');
+ }
+ }
+ }
+
+
+ // the first lang of msgstr or false for msgid
+ function cur_lang ( $post_ID ) {
+ $langs = wp_get_object_terms( $post_ID, TAXONAME);
+ if ( ! is_wp_error( $langs ) && ! empty( $langs ) ) {
+ return $langs[0];
+ }
+ return false;
+ }
+
+ /**
+ * Normal metabox : List to display untranslated msgid in target lang like msgstr currently displayed
+ *
+ * @since 2.1.2
+ */
+ function msg_untranslated_list_box ( $post ) {
+ $post_ID = $post->ID;
+ $type = get_post_meta ( $post_ID, $this->msgtype_meta, true);
+ $msglang = '';
+ $message = '';
+ $arraylink = array();
+ $sortparent = (($this->subselect == '') ? '' : '&tagsgroup_parent_select='.$this->subselect );
+ $listlanguages = $this->get_list_languages();
+ foreach ( $listlanguages as $language ) {
+ $arraylink[] = sprintf( ''.$language->name.' ', 'post.php?post='.$post_ID.'&action=edit&workinglang='.$language->slug );
+ }
+ $listlink = implode (' ', $arraylink );
+ $working_lang = ( isset ($_GET['workinglang']) ) ? $_GET['workinglang'] : '' ;
+
+ if ( $type == 'msgstr' ) {
+
+ $lang = $this->cur_lang ( $post_ID );
+
+ if ( $lang ) $msglang = $lang->slug ;
+
+ $this->subselect = ( $working_lang == '' ) ? $msglang : $working_lang ;
+ $this->searchtranslated = 'not';
+ $message = sprintf(__('MSGs not translated in %1$s. Sub-select in %2$s ', 'xili-dictionary' ), $this->languages_key_slug[$this->subselect]['name'], $listlink ) ;
+
+ } else { // msgid
+
+ $this->subselect = $working_lang;
+
+ $message = ( $working_lang == '' ) ? sprintf( __('No selection: Sub-select in %s', 'xili-dictionary' ), $listlink ) : sprintf(__('MSGs not translated in %1$s. Sub-select in %2$s ', 'xili-dictionary' ), $_GET['workinglang'], $listlink );
+ $this->searchtranslated = ( $working_lang == '' ) ? '' : 'not' ;
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xili_dict_cpt_row(); /* the lines */
+ ?>
+
+
+
+
+ insert_js_for_datatable( array('swidth2'=>'50%') );
+ }
+
+ /**
+ * insert js for datatable - used in post and in tools
+ *
+ * @since 2.1.2
+ *
+ */
+
+ function insert_js_for_datatable( $args ) {
+ ?>
+
+
+ msgtype_meta, true);
+ //error_log ( '----'.$this->langfolder);
+ //$langfolderset = $this->xili_settings['langs_folder'];
+ //$this->langfolder = ( $langfolderset !='' ) ? $langfolderset.'/' : '/';
+ // doublon
+ //$this->langfolder = str_replace ("//","/", $this->langfolder ); // upgrading... 2.0 and sub folder sub
+ $this->mo_files_array (); //error_log( serialize( $this->theme_mos ));
+
+ ?>
+
+ msg_status_display ( $post_ID );
+
+ ?>
+
+
+
+
'; ?>
+
+ '; ?>
+ name;
+ }
+ echo __( 'Come from theme(s):', 'xili-dictionary') .' '. implode (' ', $names).' ';;
+ } else {
+ if ( !$for_bottom_box['state'] ) {
+ if ( $type == 'msgid' ) _e ( 'Not yet assigned', 'xili-dictionary') ;
+ }
+ } ?>
+
+
+ ctxt_meta, true);
+ $res = $this->is_saved_cpt_in_theme( htmlspecialchars_decode ($post->post_content), $type, $context );
+ $save_state = ' '. ( ( false === strpos ( $res[0], '**' ) ) ? sprintf( __('theme folder %s','xili-dictionary') ,$res[0]) : '' ) . ( ( false == strpos ( $res[2], '?' ) ) ? ' (local: '.$res[2].')' : '' );
+ if ( is_multisite() ) $save_state .= ' '. __('this site','xili-dictionary') . ( ( false === strpos ( $res[1], '**' ) ) ? sprintf( __('folder %s','xili-dictionary') ,$res[1]) : ' ' ) . ( ( false == strpos ( $res[3], '?' ) ) ? ' (local: '.$res[3].')' : '' );
+
+ echo $type.' ' . $post->post_content . ' ' . __('saved in ','xili-dictionary') . $save_state;
+
+ ?>
+
+ XD v.
+
+ prepare("SELECT ID FROM $wpdb->posts WHERE post_content = %s AND post_type = %s", $content, XDMSG );
+
+ } else {
+ $posts_query = $wpdb->prepare("SELECT ID FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) INNER JOIN $wpdb->postmeta as mt1 ON ($wpdb->posts.ID = mt1.post_id) WHERE post_content = %s AND post_type = %s AND $wpdb->postmeta.meta_key= '{$this->ctxt_meta}' AND mt1.meta_key= '{$this->ctxt_meta}' AND mt1.meta_value = %s ", $content, XDMSG, $ctxt);
+ }
+ // 2.2.0
+ $found_posts = $wpdb->get_col($posts_query);
+ if ( empty($found_posts) ) {
+ return false;
+ } else {
+ return $found_posts;
+ }
+ }
+
+ }
+ /**
+ * test unique content for msgstr + msgid + language
+ *
+ * @since 2.0
+ * @return ID is true
+ */
+ function msgstr_exists ( $content = "", $msgid, $curlang ) {
+ global $wpdb;
+ if ( "" != $content) {
+ $posts_query = $wpdb->prepare("SELECT ID FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) INNER JOIN $wpdb->postmeta as mt1 ON ($wpdb->posts.ID = mt1.post_id) WHERE post_content = %s AND post_type = %s AND $wpdb->postmeta.meta_key='{$this->msgidlang_meta}' AND mt1.meta_key='{$this->msgidlang_meta}' AND mt1.meta_value = %s ", $content, XDMSG, $msgid);
+
+
+ $found_posts = $wpdb->get_col($posts_query);
+ if ( empty($found_posts) ) {
+ return false;
+ } else {
+
+ if ( in_array ( $curlang , wp_get_object_terms( $found_posts, TAXONAME, array ( 'fields' => 'names' ) ) ) ) {
+ // select only this with $curlang
+ return $found_posts ;
+
+ } else {
+ return false;
+ }
+
+ }
+ }
+ return false;
+ }
+
+ /**
+ * import po and mo in cpts series
+ *
+ * @since 2.0
+ * @return
+ */
+ function from_pomo_to_cpts ( $po, $curlang = 'en_US' ) {
+ $nblines = array( 0, 0); // id, str count
+ $this->importing_mode = true ;
+ foreach ( $po->entries as $pomsgid => $pomsgstr ) {
+ // test if msgid exists
+ $result = $this->msgid_exists ( $pomsgstr->singular, $pomsgstr->context ) ;
+
+ if ( $result === false ) {
+ // create the msgid
+ $type = 'msgid';
+ $msgid_post_ID = $this->insert_one_cpt_and_meta( $pomsgstr->singular, $pomsgstr->context, $type, 0, $pomsgstr ) ;
+ $nblines[0]++ ;
+ } else {
+ $msgid_post_ID = $result[0];
+ if ( $this->importing_po_comments != '' ) {
+ $this->insert_comments( $msgid_post_ID, $pomsgstr, $this->importing_po_comments );
+ }
+
+ }
+
+ // add origin taxonomy
+ if ( ''!= $this->origin_theme )
+ wp_set_object_terms( $msgid_post_ID, $this->origin_theme, 'origin', true ); // true to append to existing
+
+ if ( $pomsgstr->is_plural != null ) {
+ // create msgid plural (child of msgid)
+ // $pomsgstr->plural, $msgid_post_ID
+ $result = $this->msgid_exists ( $pomsgstr->plural ) ;
+ if ( $result === false )
+ $msgid_post_ID_plural = $this->insert_one_cpt_and_meta( $pomsgstr->plural, null, 'msgid_plural' , $msgid_post_ID, $pomsgstr );
+
+ }
+
+ // create msgstr - taxonomy
+
+ if ( $pomsgstr->is_plural == null ) {
+
+ $msgstr_content = ( isset( $pomsgstr->translations[0]) ) ? $pomsgstr->translations[0] : "" ;
+ if ( $msgstr_content != "" ) {
+ // test exists with taxo before
+ $result = $this->msgstr_exists ( $msgstr_content, $msgid_post_ID, $curlang ) ;
+ if ( $result === false ) {
+ $msgstr_post_ID = $this->insert_one_cpt_and_meta( $msgstr_content, null, 'msgstr', 0, $pomsgstr );
+ wp_set_object_terms( $msgstr_post_ID, $curlang, TAXONAME );
+ $nblines[1]++ ;
+ } else {
+ $msgstr_post_ID = $result[0];
+ }
+
+ // create link according lang
+
+ $res = get_post_meta ( $msgid_post_ID, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ $thelangs['msgstrlangs'][$curlang]['msgstr'] = $msgstr_post_ID;
+ update_post_meta ( $msgid_post_ID, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_post_ID, $this->msgidlang_meta, $msgid_post_ID );
+ }
+
+
+ } else {
+ // $pomsgstr->translations
+ $i=0; $parentplural = 0;
+ foreach ( $pomsgstr->translations as $onetranslation ) {
+ $msgstr_plural = 'msgstr_' . $i ;
+ $parent = ( $i == 0 ) ? 0 : $parentplural ;
+ if ( $onetranslation != "" ) {
+ // test exists with taxo before
+ $result = $this->msgstr_exists ( $onetranslation, $msgid_post_ID, $curlang ) ;
+ if ( $result === false ) {
+ $msgstr_post_ID_plural = $this->insert_one_cpt_and_meta( $onetranslation, null, $msgstr_plural , $parent, $pomsgstr );
+ wp_set_object_terms( $msgstr_post_ID_plural, $curlang, TAXONAME );
+ $nblines[1]++ ;
+ } else {
+ $msgstr_post_ID_plural = $result[0];
+ }
+ update_post_meta ( $msgstr_post_ID_plural, $this->msgidlang_meta, $msgid_post_ID );
+ }
+
+ if ( $i == 0 ) {
+ $parentplural = $msgstr_post_ID_plural;
+
+ // create link according lang in msgid
+ $res = get_post_meta ( $msgid_post_ID, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ $thelangs['msgstrlangs'][$curlang][$msgstr_plural] = $msgstr_post_ID_plural;
+ update_post_meta ( $msgid_post_ID, $this->msglang_meta, $thelangs );
+
+ } // only first str
+
+ $i++;
+ }
+ }
+
+ }
+ $this->importing_mode = false ;
+ return $nblines;
}
- /** *add admin menu and associated page */
+ /**
+ * import a msg line
+ *
+ * @since 2.0
+ *
+ * @updated 2.1.2
+ *
+ * @return ID
+ */
+ function insert_one_cpt_and_meta ( $content, $context = null, $type , $parent = 0, $entry = null ) {
+ global $user_ID;
+ /* if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
+ if (!empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
+ if (!empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
+ if (!empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
+ */
+ if ( null != $entry ) {
+ $references = (!empty($entry->references)) ? implode ( ' #: ' , $entry->references ) : '' ;
+ $flags = (!empty($entry->flags)) ? implode ( ', ' , $entry->flags ) : '' ;
+ $extracted_comments = (!empty($entry->extracted_comments)) ? $entry->extracted_comments : '' ;
+ $translator_comments = (!empty($entry->translator_comments)) ? $entry->translator_comments : '' ;
+ } else {
+ $references = "";
+ $flags = "";
+ $extracted_comments = "";
+ $translator_comments = "";
+
+ }
+
+ $params = array('post_status' => 'publish', 'post_type' => XDMSG, 'post_author' => $user_ID,
+ 'ping_status' => get_option('default_ping_status'), 'post_parent' => $parent,
+ 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
+ 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => $references, 'import_id' => 0,
+ 'post_content' => $content, 'post_title' => '');
+
+ $post_id = wp_insert_post( $params ) ;
+
+ if ( $post_id != 0 ) {
+ if ( $context != null ) // postmeta
+ update_post_meta ( $post_id, $this->ctxt_meta, $context );
+
+ // type postmeta
+
+ update_post_meta ( $post_id, $this->msgtype_meta, $type );
+
+ if ( $type == 'msgid' ) {
+ if ( $extracted_comments != "" ) update_post_meta ( $post_id, $this->msg_extracted_comments, $extracted_comments );
+ if ( $translator_comments != "") update_post_meta ( $post_id, $this->msg_translator_comments, $translator_comments );
+ if ( $flags != "")
+ update_post_meta ( $post_id, $this->msg_flags, $flags );
+ update_post_meta ( $post_id, $this->msglang_meta, array() ); // 2.1.2
+ }
+
+ if ( $type == 'msgstr' || $type == 'msgstr_0' ) {
+ if ( $translator_comments != "") update_post_meta ( $post_id, $this->msg_translator_comments, $translator_comments );
+ }
+ // update postmeta children
+ // create array
+ if ( $parent != 0 ) {
+
+ $res = get_post_meta ( $parent, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ if ( $type == 'msgid_plural' ) {
+ $thechilds['msgid']['plural'] = $post_id;
+
+ } elseif ( $type != 'msgstr' ){
+ $indices = explode ('_', $type);
+ $thechilds['msgstr']['plural'][$indices[1]] = $post_id;
+ }
+
+ update_post_meta ( $parent, $this->msgchild_meta, $thechilds );
+
+ }
+ }
+ return $post_id;
+ }
+
+ /**
+ * insert comments of msgid / msgstr
+ *
+ * called by from_pomo_to_cpts
+ *
+ */
+ function insert_comments( $post_id, $entry, $import_comment_mode = 'replace' ) {
+
+ $references = (!empty($entry->references)) ? implode ( ' #: ' , $entry->references ) : '' ;
+ $flags = (!empty($entry->flags)) ? implode ( ', ' , $entry->flags ) : '' ;
+ $extracted_comments = (!empty($entry->extracted_comments)) ? $entry->extracted_comments : '' ;
+ $translator_comments = (!empty($entry->translator_comments)) ? $entry->translator_comments : '' ;
+
+ if ( $import_comment_mode == 'replace' ) {
+ // update references in excerpt
+ $postarr = wp_get_single_post( $post_id, ARRAY_A ) ;
+
+ $postarr['post_excerpt'] = $references;
+
+ wp_insert_post( $postarr );
+
+ // update comments in meta
+ if ( $extracted_comments != "" ) update_post_meta ( $post_id, $this->msg_extracted_comments, $extracted_comments );
+ if ( $translator_comments != "") update_post_meta ( $post_id, $this->msg_translator_comments, $translator_comments );
+ if ( $flags != "") update_post_meta ( $post_id, $this->msg_flags, $flags );
+
+ } elseif ( $import_comment_mode == 'append' ) { // don't erase existing comments - can be risked
+
+
+ }
+
+ }
+
+ /**
+ * new columns in cpt list
+ *
+ */
+ function xili_manage_column_name( $columns ) { // must be verified
+
+ if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] == XDMSG ) {
+ $ends = array('author', 'date', 'rel', 'visible');
+ $end = array();
+ foreach( $columns AS $k=>$v ) {
+ if ( in_array($k, $ends) ) {
+ $end[$k] = $v;
+ unset($columns[$k]);
+ }
+ }
+ $columns['msgcontent'] = __('Content','xili-dictionary'); // ? sortable ?
+ $columns['msgpostmeta'] = __('Metas','xili-dictionary');
+ if ( !class_exists ( 'xili_language' ) ) {
+ $columns[TAXONAME] = __('Language','xili-dictionary');
+ }
+ $columns = array_merge($columns, $end);
+ }
+ return $columns;
+
+ }
+
+ function xili_manage_column_row ( $column , $id ) {
+ global $post;
+
+ if ($column == 'msgcontent' && $post->post_type == XDMSG )
+ echo htmlspecialchars( $post->post_content );
+ if ($column == 'msgpostmeta' && $post->post_type == XDMSG ) {
+
+ $this->msg_link_display ( $id );
+ }
+ if ($column == 'language' && $post->post_type == XDMSG ) {
+ if ( !class_exists ( 'xili_language' ) ) {
+
+ $lang = $this->cur_lang( $id );
+ echo $lang->name;
+
+ }
+ }
+
+ return;
+
+ }
+
+ // Register the column as sortable
+ function msgcontent_column_register_sortable( $columns ) {
+ $columns['msgcontent'] = 'msgcontent';
+ $columns['msgpostmeta'] = 'msgpostmeta';
+ return $columns;
+ }
+
+ function msgcontent_column_orderby( $vars ) {
+ if ( isset( $vars['orderby'] ) && 'msgpostmeta' == $vars['orderby'] ) {
+ $vars = array_merge( $vars, array(
+ 'meta_key' => $this->msgtype_meta,
+ 'orderby' => 'meta_value'
+ ) );
+ }
+
+ return $vars;
+ }
+
+ /**
+ * Add Languages selector in edit.php edit after Category Selector (hook: restrict_manage_posts) only if no XL
+ *
+ * @since 2.0
+ *
+ */
+ function restrict_manage_languages_posts () {
+ $listlanguages = $this->get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' ); //get_terms(TAXONAME, array('hide_empty' => false));
+ ?>
+
+
+
+ slug == $_GET[QUETAG] ) ? "selected=selected" : "" ;
+ echo ''.__($language->description, 'xili-dictionary').' ';
+ }
+ ?>
+
+ false));
+ if ( $listorigins != array() ) {
+ $selected = "";
+ if ( isset ( $_GET['origin'] ) ) {
+ $selected = $_GET['origin'];
+ }
+ $dropdown_options = array(
+ 'taxonomy' => 'origin',
+ 'show_option_all' => __( 'View all origins', 'xili-dictionary' ),
+ 'hide_empty' => 0,
+ 'hierarchical' => 1,
+ 'show_count' => 0,
+ 'orderby' => 'name',
+ 'name' => 'origin',
+ 'selected' => $selected
+ );
+ wp_dropdown_categories( $dropdown_options );
+ }
+ }
+ }
+
+ /**
+ * Add writer selector in edit.php edit
+ *
+ * @since 2.0
+ *
+ */
+ function restrict_manage_writer_posts () {
+ if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] == XDMSG ) {
+ $listwriters = get_terms('writer', array('hide_empty' => false));
+ if ( $listwriters != array() ) {
+ $selected = "";
+ if ( isset ( $_GET['writer_name'] ) ) {
+ $selected = $_GET['writer_name'];
+ }
+ $dropdown_options = array(
+ 'taxonomy' => 'writer',
+ 'show_option_all' => __( 'View all writers', 'xili-dictionary' ),
+ 'hide_empty' => 0,
+ 'hierarchical' => 1,
+ 'show_count' => 0,
+ 'orderby' => 'name',
+ 'name' => 'writer_name',
+ 'selected' => $selected
+ );
+ wp_dropdown_categories( $dropdown_options );
+ }
+ }
+ }
+
+ /**
+ * to fixes wp_dropdown_categories id value in option
+ * thanks to http://wordpress.stackexchange.com/questions/6066/query-custom-taxonomy-by-term-id
+ */
+ function wpse6066_pre_get_posts( &$wp_query ) {
+
+ if ( $wp_query->is_tax ) { ;
+ if ( is_numeric( $wp_query->get( 'writer_name' ) ) ) {
+ // Convert numberic terms to term slugs for dropdown
+
+ $term = get_term_by( 'term_id', $wp_query->get( 'writer_name' ), 'writer' );
+
+ if ( $term ) {
+ $wp_query->set( 'writer_name', $term->slug );
+ }
+ }
+
+ if ( is_numeric( $wp_query->get( 'origin' ) ) ) {
+
+ // Convert numberic terms to term slugs for dropdown
+
+ $term = get_term_by( 'term_id', $wp_query->get( 'origin' ), 'origin' );
+
+ if ( $term ) {
+ $wp_query->set( 'origin', $term->slug );
+ }
+ }
+ }
+ }
+
+
+ /**
+ * display msg comments
+ *
+ * @param post ID
+ *
+ */
+ function msg_status_comments ( $id ) {
+
+ $type = get_post_meta ( $id, $this->msgtype_meta, true);
+ // search msgid
+ if ( $type == 'msgid' ) {
+ $target_id = $id;
+ } elseif ( $type == 'msgid_plural' ) {
+ $temp_post = $this->temp_get_post ( $id );
+ $target_id = $temp_post->post_parent;
+ } else {
+ $target_id = get_post_meta ( $id, $this->msgidlang_meta, true);
+ }
+ $for_bottom_box = array('link'=> '','state' => false );
+ if ( $temp_post = $this->temp_get_post ( $target_id ) ) {
+
+ $ctxt = get_post_meta ( $target_id, $this->ctxt_meta, true );
+ if ( $ctxt != "" && $type != 'msgid' ) printf ( 'ctxt: %s ' , $ctxt );
+ if ( $type == 'msgid' ) {
+ if ( isset ($_GET['msgaction'] ) && $_GET['msgaction'] == 'addctxt' ) {
+ ?>
+
+
+ ctxt: %s ' , $ctxt );
+ printf( __(' Edit context ', 'xili-dictionary'), 'post.php?post='.$id.'&action=edit&msgaction=addctxt' );
+ } else {
+ // link to add ctxt
+ printf( __(' Create context ', 'xili-dictionary'), 'post.php?post='.$id.'&action=edit&msgaction=addctxt' );
+
+ }
+ }
+ }
+ // local or not
+ $linktotax ='';
+ $extracted_comments = get_post_meta ( $target_id, $this->msg_extracted_comments, true );
+ if ( $extracted_comments != "" ) {
+
+ $pattern = '/([^local\]].*?)from\s(.*?)\swith/';
+ $matches = array();
+ if ( 1 == preg_match($pattern, $extracted_comments, $matches) ) {
+
+ $search = '';
+ if ( $type == 'msgid' && false !== strpos( $extracted_comments, 'name from' ) )
+ $search = '&s='.str_replace(' ', '+', $temp_post->post_content );
+
+ $linktotax = sprintf('%2s ', 'edit-tags.php?taxonomy='.$matches[2].'&post_type=post'.$search, sprintf(__('Return to %s list', 'xili-dictionary'), $matches[2] ));
+
+ }
+ }
+
+ echo '';
+
+ if ( $extracted_comments != "" )
+ printf ( __('Extracted comments: %s', 'xili-dictionary').' ', $extracted_comments );
+
+ $translator_comments = get_post_meta ( $target_id, $this->msg_translator_comments, true );
+ if ( $translator_comments != "") printf ( __('Translator comments: %s', 'xili-dictionary').' ', $translator_comments );
+ $flags = get_post_meta ( $target_id, $this->msg_flags, true );
+ if ( $flags != "") printf ( __('Flags: %s', 'xili-dictionary').' ', $flags );
+
+ echo '
';
+ if ( $type == 'msgstr' || $type == 'msgstr_0' ) {
+ $translator_comments = get_post_meta ( $id, $this->msg_translator_comments, true );
+ //if ( $translator_comments != "") printf ( __('Msgstr Translator comments: %s', 'xili-dictionary').' ', $translator_comments );
+
+ ?>
+
+
+ post_excerpt;
+ if ( $lines != "") {
+ echo '';
+ printf ( __('Lines: %s', 'xili-dictionary').' ', $lines );
+ echo '
';
+ }
+ echo ''.sprintf(__('Return to msg list ','xili-dictionary'), $this->xd_settings_page).' '.$linktotax.'
';
+ echo ( $this->create_line_lang != "" ) ? ''.$this->create_line_lang.'
' : "-";
+
+
+ if ( $type == 'msgid' ) {
+ if ( ( $extracted_comments == "" ) || ( $extracted_comments != "" && false === strpos( $extracted_comments, $this->local_tag .' ' ) ) ) {
+
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=setlocal', 'xd-setlocal' ) ;
+
+ $for_bottom_box['link'] = sprintf( __('Set in theme (set local )', 'xili-dictionary'), $nonce_url );
+
+ } else {
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=unsetlocal', 'xd-setlocal' ) ;
+
+ $for_bottom_box['link'] = sprintf( __('Set in local (unset )', 'xili-dictionary'), $nonce_url );
+ $for_bottom_box['state'] = true; // false by default
+ }
+ }
+
+
+ } else {
+ printf ( __('The msgid (%d) was deleted. The msg series must be recreated and commented.','xili-dictionary' ), $target_id );
+ echo ''.sprintf(__('Return to msg list ','xili-dictionary'), $this->xd_settings_page).'
';
+ }
+ return $for_bottom_box ;
+ }
+
+ function update_msg_comments ( $post_id ) {
+ if ( get_post_type( $post_id ) == XDMSG ) {
+ // only visible if msgstr
+ $translator_comments = ( isset ( $_POST['add_translator_comments'] )) ? $_POST['add_translator_comments'] : "" ;
+ if ( '' != $translator_comments ) {
+ update_post_meta ( $post_id, $this->msg_translator_comments, $translator_comments );
+ }
+ // add_ctxt
+
+ if ( isset ( $_POST['add_ctxt'] ) ) {
+ $ctxt = $_POST['add_ctxt'] ;
+ if ( '' != $ctxt ) {
+ update_post_meta ( $post_id, $this->ctxt_meta, $ctxt );
+ } else {
+ delete_post_meta ( $post_id, $this->ctxt_meta);
+ }
+ }
+ }
+ }
+
+ /**
+ * msg dashboard left
+ *
+ * @since 2.0
+ *
+ */
+ function msg_status_display ( $id ) {
+ global $post;
+ $spanred = '';
+ $spanend = ' ';
+
+ $type = get_post_meta ( $id, $this->msgtype_meta, true);
+ // search msgid
+ if ( $type == 'msgid' ) {
+ $msgid_id = $id;
+ } elseif ( $type == 'msgid_plural' ) {
+ $temp_post_msg_id_plural = $this->temp_get_post ( $id );
+ $msgid_id = $temp_post_msg_id_plural->post_parent;
+ $temp_post_msg_id = $this->temp_get_post ( $msgid_id );
+ } else {
+ $msgid_id = get_post_meta ( $id, $this->msgidlang_meta, true);
+ }
+
+ if ( $temp_post_msg_id = $this->temp_get_post ( $msgid_id ) ) {
+ if ( defined ('WP_DEBUG') && WP_DEBUG == true ) {
+ //echo '';
+ //printf( __('%s saved as: %s ', 'xili-dictionary'), $this->msg_str_labels[$type], $post->post_content );
+ //echo '
';
+ }
+ $res = get_post_meta ( $msgid_id, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+
+ $res = get_post_meta ( $msgid_id, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+
+ if ( isset ($_GET['msgaction'] ) && isset ($_GET['langstr']) ) { // action to create child and default line - single or plural...
+ check_admin_referer( 'xd-langstr' );
+ $target_lang = $_GET['langstr'];
+ if ( $_GET['msgaction'] == 'msgstr' && !isset( $thelangs['msgstrlangs'][$target_lang] ) ) {
+ // create post
+ if ( !isset ( $thechilds['msgid']['plural'] ) ) {
+
+ $msgstr_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate:', 'xili-dictionary').$temp_post_msg_id->post_content , null, 'msgstr' , 0 );
+ wp_set_object_terms( $msgstr_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['msgstr'] = $msgstr_post_ID;
+ update_post_meta ( $msgid_id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_post_ID, $this->msgidlang_meta, $msgid_id );
+
+ $translated_post_ID = $msgstr_post_ID;
+ //printf( 'msgstr created in %s ', $target_lang ) ;
+
+ } else {
+ // create msgstr_0
+ $msgstr_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate (msgstr[0]): ', 'xili-dictionary').$temp_post_msg_id->post_content , null, 'msgstr_0' , 0 );
+ wp_set_object_terms( $msgstr_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['msgstr_0'] = $msgstr_post_ID;
+ update_post_meta ( $msgid_id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_post_ID, $this->msgidlang_meta, $msgid_id );
+
+ $translated_post_ID = $msgstr_post_ID;
+ //printf( 'msgstr[0] created in %s ', $target_lang ) ;
+
+ // create msgstr_1
+ $temp_post_msg_id_plural = $this->temp_get_post ( $thechilds['msgid']['plural'] );
+ $content_plural = htmlspecialchars( $temp_post_msg_id_plural->post_content );
+ $msgstr_1_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate (msgstr[1]): ', 'xili-dictionary'). $content_plural , null, 'msgstr_1' , $msgstr_post_ID );
+ wp_set_object_terms( $msgstr_1_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['plural'][1] = $msgstr_1_post_ID;
+ update_post_meta ( $msgid_id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_1_post_ID, $this->msgidlang_meta, $msgid_id );
+
+ //printf( 'msgstr[1] created in %s ', $target_lang ) ;
+ }
+ // redirect
+
+ //if ( $translated_post_ID > 0 && $this->xili_settings['creation_redirect'] == 'redirect') {
+ $url_redir = admin_url().'post.php?post='.$translated_post_ID.'&action=edit';
+
+ ?>
+
+insert_one_cpt_and_meta ( __('XD say id to plural: ', 'xili-dictionary').$temp_post_msg_id->post_content , null, 'msgid_plural' , $msgid_id );
+ $res = get_post_meta ( $msgid_id, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+
+ } elseif ( $type == 'msgid' && isset ($_GET['msgaction']) && $_GET['msgaction'] == 'setlocal' ) {
+ check_admin_referer( 'xd-setlocal' );
+ $extracted_comments = get_post_meta ( $msgid_id, $this->msg_extracted_comments, true );
+ $extracted_comments = $this->local_tag .' '. $extracted_comments;
+ update_post_meta ( $msgid_id, $this->msg_extracted_comments, $extracted_comments );
+
+ } elseif ( $type == 'msgid' && isset ($_GET['msgaction']) && $_GET['msgaction'] == 'unsetlocal' ) {
+ check_admin_referer( 'xd-setlocal' );
+ $extracted_comments = get_post_meta ( $msgid_id, $this->msg_extracted_comments, true );
+ $extracted_comments = str_replace ( $this->local_tag .' ', '', $extracted_comments);
+ update_post_meta ( $msgid_id, $this->msg_extracted_comments, $extracted_comments );
+ }
+
+
+ // display current saved content
+
+ //if ( $type != "msgid" ) {
+ $line = __('msgid:', 'xili-dictionary');
+ $line .= ' '. htmlspecialchars($temp_post_msg_id->post_content ) . ' ' ;
+ if ( $post->ID != $msgid_id ) {
+ $line .= sprintf( __('( %s ) ', 'xili-dictionary'),'post.php?post='.$msgid_id.'&action=edit', $msgid_id, __('Edit') ) ;
+ } else {
+ $line .= ' ';
+ }
+ $this->hightlight_line ( $line, $type, 'msgid' );
+ //}
+ if ( isset ( $thechilds['msgid']['plural'] ) ) {
+ $post_status = get_post_status ( $thechilds['msgid']['plural'] ) ;
+ $line = "";
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanred;
+ $line .= ''. __('msgid_plural:', 'xili-dictionary') . ' ';
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanend;
+ $temp_post_msg_id_plural = $this->temp_get_post ( $thechilds['msgid']['plural'] );
+ $content_plural = htmlspecialchars( $temp_post_msg_id_plural->post_content );
+ $line .= ''. $content_plural . ' ' ;
+ if ( $post->ID != $thechilds['msgid']['plural'] )
+ $line .= sprintf( __('( %s ) ', 'xili-dictionary'),'post.php?post='.$thechilds['msgid']['plural'].'&action=edit', $thechilds['msgid']['plural'], __('Edit') ) ;
+ $this->hightlight_line ( $line, $type, 'msgid_plural' );
+
+
+ } else {
+ if ( !isset ( $thelangs['msgstrlangs'] ) && !isset ( $thechilds['msgid']['plural'] ) ) { // not yet translated
+
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=msgid_plural', 'xd-plural' ) ;
+ printf( __(' Create msgid_plural ', 'xili-dictionary'), $nonce_url );
+ echo ' ';
+ }
+ }
+
+ // display series
+ $listlanguages = $this->get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' ); //get_terms(TAXONAME, array('hide_empty' => false));
+ if (isset ( $thelangs['msgstrlangs'] ) ) {
+ $translated_langs = array ();
+ echo '';
+ _e( 'translated in', 'xili-dictionary');
+ echo ' ‟msgstr” ';
+ foreach ( $thelangs['msgstrlangs'] as $curlang => $msgtr ) {
+
+ $strid = 0;
+ if ( isset ( $msgtr['msgstr'] ) ) {
+ $strid = $msgtr['msgstr'] ;
+ $str_plural = false ;
+ $translated_langs[] = $curlang;
+ $typeref = 'msgstr';
+ } elseif ( isset ( $msgtr['msgstr_0'] ) ) {
+ $strid = $msgtr['msgstr_0'] ;
+ $str_plural = true ;
+ $translated_langs[] = $curlang; // detect content empty
+ $typeref = 'msgstr_0';
+ }
+
+ if ( $strid != 0 ) {
+ $target_lang = implode ( ' ', wp_get_object_terms( $id, TAXONAME, $args = array( 'fields' => 'names')) );
+ echo '';
+ printf( '%s : ', $curlang );
+ echo ' ';
+ $temp_post = $this->temp_get_post ( $strid );
+ $content = htmlspecialchars( $temp_post->post_content );
+ $line = "";
+ if ( $str_plural ) $line .= "[0] ";
+
+ $line .= '‟'. $content . ' ”' ;
+ $post_status = get_post_status ( $strid );
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanred;
+ if ( $post->ID != $strid ) {
+ $line .= sprintf( ' ( %s ) ', 'post.php?post='.$strid.'&action=edit', $strid, __('Edit') ) ;
+ } else {
+ $line .= ' ';
+ }
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanend;
+
+ $this->hightlight_line_str ( $line, $type, $typeref, $curlang, $target_lang );
+
+ if ( $str_plural ) {
+ $res = get_post_meta ( $strid, $this->msgchild_meta, false );
+ $strthechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ foreach ( $strthechilds['msgstr']['plural'] as $key => $strchildid ) {
+ $temp_post = $this->temp_get_post ( $strchildid );
+ $content = htmlspecialchars( $temp_post->post_content );
+ $line = "";
+ $post_status = get_post_status ( $strchildid ); // fixed 2.1
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanred;
+ $line .= sprintf ( '[%s] ', $key );
+ if ( $post_status == "trash" || $post_status === false ) $line .= $spanend;
+ if ( $post->ID != $strchildid ) {
+ $line .= sprintf ( '‟%s ” ( %s )', $content, ''.__('Edit').' ' ) ;
+ } else {
+ $line .= sprintf ( '‟%s ”', $content );
+ }
+ $this->hightlight_line_str ( $line, $type, 'msgstr_'.$key, $curlang, $target_lang );
+ echo ' ';
+ }
+ // if possible against current lang add links - compare to count of $strthechilds['msgstr']['plural']
+
+ }
+ echo ' ';
+ }
+
+ }
+ echo '
';
+ $this->create_line_lang = "";
+ if ( count ($translated_langs) != count ($listlanguages) ) {
+ //echo ' ';
+ $this->create_line_lang = __('Create msgstr in: ', 'xili-dictionary');
+ foreach ( $listlanguages as $tolang ) {
+ if ( !in_array ( $tolang->name , $translated_langs ) ) {
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=msgstr&langstr='.$tolang->name, 'xd-langstr' ) ;
+ $this->create_line_lang .= sprintf( ' '.$tolang->name.' ', $nonce_url ); }
+ }
+ }
+ } else {
+ $this->create_line_lang = "";
+ if ( !isset ($_POST['msgaction'] ) || ( isset ($_GET['msgaction'] ) && $_GET['msgaction'] == 'msgid_plural' ) ) {
+ _e( 'not yet translated.', 'xili-dictionary');
+
+ $this->create_line_lang = __('Create msgstr in: ', 'xili-dictionary');
+ foreach ( $listlanguages as $tolang ) {
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=msgstr&langstr='.$tolang->name, 'xd-langstr' ) ;
+ $this->create_line_lang .= sprintf( ' '.$tolang->name.' ', $nonce_url ); }
+ }
+ }
+ } else {
+
+ printf ( __('The msgid (%d) was deleted. The msg series must be recreated.','xili-dictionary' ), $msgid_id );
+ }
+ }
+
+ function hightlight_line ( $line, $cur_type, $type ) {
+ if ( $cur_type == $type) {
+ echo ''. $line .' ';
+ } else {
+ echo ''. $line .' ';
+ }
+ }
+
+ function hightlight_line_str ( $line, $cur_type, $type, $cur_lang, $lang ) {
+ if ( $cur_type == $type && $cur_lang == $lang ) {
+ echo ''.$line.' ';
+ } else {
+ echo ''. $line .' ';
+ }
+ }
+
+
+ /**
+ * display msg series linked together
+ *
+ * @param post ID, display (true for single edit)
+ *
+ */
+ function msg_link_display ( $id , $display = false, $thepost = null ) {
+
+ if ( $thepost != null ) {
+ $post = $thepost ;
+ } else {
+ global $post ;
+ }
+
+ $spanred = '';
+ $spanend = ' ';
+ // type
+ $type = get_post_meta ( $id, $this->msgtype_meta, true);
+
+ $res = get_post_meta ( $id, $this->msgchild_meta, false );
+ $thechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+
+ $res = get_post_meta ( $id, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+
+ if ( $type == 'msgid' ) {
+ $ctxt = get_post_meta ( $id, $this->ctxt_meta, true );
+ if ( $post->post_status == "trash" ) echo $spanred;
+ if ( $display ) {
+ echo '';
+ printf( __('msgid saved as: %s ', 'xili-dictionary'), ( $post->post_content ) );
+ echo '
';
+ } else {
+ echo 'msgid';
+ }
+ if ( $post->post_status == "trash" ) echo $spanend;
+ echo ' ';
+ if ( $ctxt != "" && !$display ) printf ( 'ctxt: %s ' , $ctxt );
+
+ if ( isset ( $thechilds['msgid']['plural'] ) ) {
+ $post_status = get_post_status ( $thechilds['msgid']['plural'] ) ;
+ if ( !$display ) {
+ if ( $post_status == "trash" || $post_status === false ) echo $spanred;
+ printf( __('has plural: %d ', 'xili-dictionary'),'post.php?post='.$thechilds['msgid']['plural'].'&action=edit', $thechilds['msgid']['plural'] ) ;
+ if ( $post_status == "trash" || $post_status === false ) echo $spanend;
+ } else {
+ if ( $post_status == "trash" || $post_status === false ) echo $spanred;
+ _e('has plural:', 'xili-dictionary'); echo ' ';
+ if ( $post_status == "trash" || $post_status === false ) echo $spanend;
+ $temp_post = $this->temp_get_post ( $thechilds['msgid']['plural'] );
+ $content_plural = htmlspecialchars( $temp_post->post_content );
+ echo ''. $content_plural . ' ' ;
+ printf( __('( %s ) ', 'xili-dictionary'),'post.php?post='.$thechilds['msgid']['plural'].'&action=edit', $thechilds['msgid']['plural'], __('Edit') ) ;
+ }
+ } else {
+ if ( $display && !isset ( $thelangs['msgstrlangs'] ) && !isset ( $thechilds['msgid']['plural'] ) ) { // not yet translated
+
+ printf( __(' Create msgid_plural ', 'xili-dictionary'), 'post.php?post='.$id.'&action=edit&msgaction=msgid_plural' );
+ echo ' ';
+ }
+ }
+ $res = get_post_meta ( $id, $this->msglang_meta, false );
+ $thelangs = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ // action to create child and default line - single or plural...
+ if ( isset ($_GET['msgaction'] ) && isset ($_GET['langstr']) && $display) {
+ $target_lang = $_GET['langstr'];
+ if ( $_GET['msgaction'] == 'msgstr' && !isset( $thelangs['msgstrlangs'][$target_lang] ) ) {
+ // create post
+ if ( !isset ( $thechilds['msgid']['plural'] ) ) {
+
+ $msgstr_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate: ', 'xili-dictionary').$post->post_content , null, 'msgstr' , 0 );
+ wp_set_object_terms( $msgstr_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['msgstr'] = $msgstr_post_ID;
+ update_post_meta ( $id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_post_ID, $this->msgidlang_meta, $id );
+
+ sprintf( 'msgstr created in %s ', $target_lang ) ;
+
+ } else {
+ // create msgstr_0
+ $msgstr_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate (msgstr[0]): ', 'xili-dictionary').$post->post_content , null, 'msgstr_0' , 0 );
+ wp_set_object_terms( $msgstr_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['msgstr_0'] = $msgstr_post_ID;
+ update_post_meta ( $id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_post_ID, $this->msgidlang_meta, $id );
+
+ sprintf( 'msgstr[0] created in %s ', $target_lang ) ;
+
+ // create msgstr_1
+ $msgstr_1_post_ID = $this->insert_one_cpt_and_meta ( __('XD say to translate (msgstr[1]): ', 'xili-dictionary'). $content_plural , null, 'msgstr_1' , $msgstr_post_ID );
+ wp_set_object_terms( $msgstr_1_post_ID, $target_lang, TAXONAME );
+ $thelangs['msgstrlangs'][$target_lang]['plural'][1] = $msgstr_1_post_ID;
+ update_post_meta ( $id, $this->msglang_meta, $thelangs );
+ update_post_meta ( $msgstr_1_post_ID, $this->msgidlang_meta, $msgid_id );
+
+ sprintf( 'msgstr[1] created in %s ', $target_lang ) ;
+ }
+ } elseif ( $_GET['msgaction'] == 'msgid_plural' && !isset( $thelangs['msgstrlangs'][$target_lang] ) ) {
+
+ $msgid_plural_post_ID = $this->insert_one_cpt_and_meta ( __('XD say id to plural: ', 'xili-dictionary').$post->post_content , null, 'msgid_plural' , $id );
+
+ }
+ }
+ $listlanguages = $this->get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' ); //get_terms(TAXONAME, array('hide_empty' => false));
+ if (isset ( $thelangs['msgstrlangs'] ) ) {
+ //$thelangs['msgstrlangs'][$curlang]['msgstr'] = $msgstr_post_ID;
+
+ $translated_langs = array ();
+ if ( $display ) {
+ echo '';
+ _e( 'translated in', 'xili-dictionary');
+ echo ' msgstr ';
+ } else {
+ echo ( __( 'translated in', 'xili-dictionary').': ');
+ }
+ foreach ( $thelangs['msgstrlangs'] as $curlang => $msgtr ) {
+
+ $strid = 0;
+ if ( isset ( $msgtr['msgstr'] ) ) {
+ $strid = $msgtr['msgstr'] ;
+ $str_plural = false ;
+ $translated_langs[] = $curlang;
+ } elseif ( isset ( $msgtr['msgstr_0'] ) ) {
+ $strid = $msgtr['msgstr_0'] ;
+ $str_plural = true ;
+ $translated_langs[] = $curlang; // detect content empty
+ }
+
+ if ( $strid != 0 ) {
+ if ( !$display ) {
+ // get strid status
+ $post_status = get_post_status ( $strid );
+ if ( $post_status == "trash" || $post_status === false ) echo $spanred;
+ printf( '- %s : %d ', $curlang, 'post.php?post='.$strid.'&action=edit', $strid ) ;
+ if ( $post_status == "trash" || $post_status === false ) echo $spanend;
+ } else {
+ echo '';
+ printf( '%s : ', $curlang );
+ echo ' ';
+ $temp_post = $this->temp_get_post ( $strid );
+ $content = htmlspecialchars( $temp_post->post_content );
+
+ if ( $str_plural ) echo "[0] ";
+
+ echo ''. $content . ' ' ;
+ $post_status = get_post_status ( $strid );
+ if ( $post_status == "trash" || $post_status === false ) echo $spanred;
+ printf( ' ( %s ) ', 'post.php?post='.$strid.'&action=edit', $strid, __('Edit') ) ;
+ if ( $post_status == "trash" || $post_status === false ) echo $spanend;
+
+ if ( $str_plural ) {
+ $res = get_post_meta ( $strid, $this->msgchild_meta, false );
+ $strthechilds = ( is_array ( $res ) && array() != $res ) ? $res[0] : array();
+ foreach ( $strthechilds['msgstr']['plural'] as $key => $strchildid ) {
+ $temp_post = $this->temp_get_post ( $strchildid );
+ $content = htmlspecialchars( $temp_post->post_content );
+ $post_status = get_post_status ( $strchildid );
+ if ( $post_status == "trash" || $post_status === false ) echo $spanred;
+ printf ( '[%s] ', $key );
+ if ( $post_status == "trash" || $post_status === false ) echo $spanend;
+ printf ( '%s ( %s ) ', $content, ''.__('Edit').' ' ) ;
+
+ }
+ // if possible against current lang add links - compare to count of $strthechilds['msgstr']['plural']
+
+ }
+ echo ' ';
+ }
+ }
+
+ }
+ if ( $display ) echo '
';
+ $this->create_line_lang = "";
+ if ( $display && ( count ($translated_langs) != count ($listlanguages) ) ) {
+ //echo ' ';
+ $this->create_line_lang = __('Create msgstr in: ', 'xili-dictionary');
+ foreach ( $listlanguages as $tolang ) {
+ if ( !in_array ( $tolang->name , $translated_langs ) ) {
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=msgstr&langstr='.$tolang->name, 'xd-langstr' ) ;
+ $this->create_line_lang .= sprintf( ' '.$tolang->name.' ', $nonce_url );
+ }
+ }
+ }
+
+ } else { // no translation
+ if ( !isset ($_POST['msgaction'] ) || ( isset ($_GET['msgaction'] ) && $_GET['msgaction'] == 'msgid_plural' ) ) {
+ _e( 'not yet translated.', 'xili-dictionary');
+ echo ' ';
+ if ( $display ) {
+ _e('Create msgstr in: ', 'xili-dictionary');
+
+ foreach ( $listlanguages as $tolang ) {
+ $nonce_url = wp_nonce_url ('post.php?post='.$id.'&action=edit&msgaction=msgstr&langstr='.$tolang->name, 'xd-langstr' ) ;
+ printf( ' '.$tolang->name.' ', $nonce_url );
+ }
+ }
+ }
+ }
+
+
+ } elseif ( $type != '' ) {
+
+ $msgid_ID = get_post_meta ( $id, $this->msgidlang_meta , true);
+
+
+
+
+ if ( $display && ( $type == 'msgid_plural' || ( false !== strpos( $type, 'msgstr_' ) && substr( $type, -1 ) !='0') ) ) {
+ $temp_post = $this->temp_get_post ( $post->post_parent );
+ $content = htmlspecialchars( $temp_post->post_content ) ;
+ $target_lang = implode ( ' ', wp_get_object_terms( $id, TAXONAME, $args = array( 'fields' => 'names')) );
+ $is_plural = true;
+ } elseif ( $display ) {
+ $temp_post = $this->temp_get_post ( $msgid_ID );
+ $content = htmlspecialchars( $temp_post->post_content ) ;
+ $target_lang = implode ( ' ', wp_get_object_terms( $id, TAXONAME, $args = array( 'fields' => 'names')) );
+ $is_plural = false;
+ }
+
+ $span_msgid = ( get_post_status ( $msgid_ID ) == "trash" || get_post_status ( $msgid_ID ) === false ) ;
+ $span_parent = ( get_post_status ( $post->post_parent ) == "trash" || get_post_status ( $post->post_parent ) === false ) ;
+
+ if ( $display ) {
+ echo '';
+ printf( __('%s saved as: %s ', 'xili-dictionary'), $this->msg_str_labels[$type], $post->post_content );
+ echo '
';
+ }
+
+ switch ( $type ) {
+ case 'msgid_plural':
+
+ if ( $span_parent ) echo $spanred ;
+ if ( $display ) {
+ printf( __('msgid plural of: %s ( %s ) ', 'xili-dictionary'), $content,'post.php?post='.$post->post_parent.'&action=edit', $post->post_parent, __('Edit') );
+ } else {
+ printf( __('msgid plural of: %d ', 'xili-dictionary'),'post.php?post='.$post->post_parent.'&action=edit',$post->post_parent ) ;
+ }
+ if ( $span_parent ) echo $spanend ;
+
+
+ break;
+ case 'msgstr':
+ if ( $display ) echo ''.$target_lang." translation of: " . $content . ' ';
+ if ( $span_msgid ) echo $spanred ;
+ if ( $display ) {
+ printf( __('( %s ) ', 'xili-dictionary'), 'post.php?post='.$msgid_ID.'&action=edit', $msgid_ID, __('Edit') );
+ } else {
+
+ printf( __('msgstr of: %d ', 'xili-dictionary'), 'post.php?post='.$msgid_ID.'&action=edit', $msgid_ID );
+ }
+ if ( $span_msgid ) echo $spanend ;
+ //if ( $display ) echo ''.$content .' ';
+ break;
+
+ default:
+ if ( false !== strpos( $type, 'msgstr_' ) ) {
+ $indices = explode ('_', $type);
+ $indice = $indices[1];
+ $edit_id = ( $indice == 0 ) ? $msgid_ID : $post->post_parent ;
+
+ if ( $display ) {
+ if ( $is_plural ) {
+ printf(__( '%s plural of: %s ( %s ) ', ''),$target_lang, $content, 'post.php?post='.$edit_id.'&action=edit' , $edit_id, __('Edit') );
+ } else {
+ printf(__( '%s translation of: %s ( %s ) ', ''),$target_lang, $content, 'post.php?post='.$edit_id.'&action=edit' , $edit_id, __('Edit') );
+ }
+ } else {
+ if ( $indice == 0 ) {
+ if ( $span_msgid ) echo $spanred ;
+ printf( __('msgstr of: %d ', 'xili-dictionary'), 'post.php?post='.$msgid_ID.'&action=edit', $msgid_ID );
+ if ( $span_msgid ) echo $spanend ;
+ } else {
+ if ( $span_parent ) echo $spanred ;
+ printf( __('msgstr[%d] plural of: %d ', 'xili-dictionary'), $indice, 'post.php?post='.$post->post_parent.'&action=edit', $post->post_parent ) ;
+ if ( $span_parent ) echo $spanend ;
+ }
+ }
+ if ( $display && $indice > 0) {
+ printf(__('go to msgid ', 'xili-dictionary'), 'post.php?post='.$msgid_ID.'&action=edit', $msgid_ID ) ;
+ }
+ }
+ }
+
+ }
+ return $type;
+ }
+
+ function temp_get_post ( $post_id ) {
+ global $wpdb ;
+ $res = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
+ if ( $res && !is_wp_error($res) )
+ return $res;
+ else
+ return false;
+ }
+
+ /**
+ * unset autosave for msg
+ * @since 2.0
+ */
+ function auto_save_unsetting() {
+ global $hook_suffix, $post ;
+ $type = '';
+ if ( isset($_GET['post_type']) )
+ $type = $_GET['post_type'];
+
+ if ( ( $hook_suffix == 'post-new.php' && $type == XDMSG ) || ( $hook_suffix == 'post.php' && $post->post_type == XDMSG )) {
+
+ wp_dequeue_script('autosave');
+ //wp_deregister_script('autosave');
+ //$wp_scripts->queue = array_diff( $wp_scripts->queue , array('autosave') );
+ }
+ }
+
+
+ /**
+ * Reset values when theme was changed... updated by previous function
+ * @since 1.0.5
+ */
+ function xd_theme_switched ($theme) {
+ $this->xili_settings['langs_folder'] ="unknown";
+ /* to force future search in new theme */
+ update_option('xili_dictionary_settings', $this->xili_settings);
+ }
+
+ /**
+ * @since 1.3.0 for js in tools list
+ */
+ function admin_enqueue_scripts() {
+ wp_enqueue_script( 'datatables', plugins_url('js/jquery.dataTables.min.js', __FILE__ ) , array( 'jquery' ), '1.7.4', true );
+ }
+
+ function admin_enqueue_styles() {
+ wp_enqueue_style('table_xdstyle'); // style of js table
+ }
+
+ function admin_init() {
+ /* Register our script. */
+ wp_register_script( 'datatables', plugins_url('js/jquery.dataTables.min.js', __FILE__ ) );
+ wp_register_style( 'table_xdstyle', plugins_url('/css/xd_table.css', __FILE__ ), array(), XILIDICTIONARY_VER, 'screen' );
+ }
+
+ /**
+ *add admin menu and associated page
+ */
function xili_add_dict_pages() {
- $this->thehook = add_management_page(__('Dictionary','xili-dictionary'), __('Dictionary','xili-dictionary'), 'import', 'dictionary_page', array(&$this,'xili_dictionary_settings'));
- add_action('load-'.$this->thehook, array(&$this,'on_load_page'));
- add_action( "admin_print_scripts-".$this->thehook, array(&$this,'xili_add_js'));
+
+ //$this->thehook = add_management_page(__('Xili Dictionary','xili-dictionary'), __('xili Dictionary','xili-dictionary'), 'import', 'dictionary_page', array(&$this,'xili_dictionary_settings'));
+
+ $this->thehook = add_submenu_page( 'edit.php?post_type='.XDMSG, __('Xili Dictionary','xili-dictionary'), __('Tools, Files po mo','xili-dictionary'), 'import', 'dictionary_page', array(&$this,'xili_dictionary_settings') );
+
+ add_action('load-'.$this->thehook, array(&$this,'on_load_page'));
+
+ add_action( 'admin_print_scripts-'.$this->thehook, array(&$this,'admin_enqueue_scripts') );
+ add_action( 'admin_print_styles-'.$this->thehook, array(&$this,'admin_enqueue_styles') );
+
+ // Add to end of admin_menu action function
+ global $submenu;
+ $submenu['edit.php?post_type='.XDMSG][5][0] = __('Msg list','xili-dictionary'); // sub menu
+ $post_type_object = get_post_type_object(XDMSG);
+ $post_type_object->labels->name = __('XD Msg list','xili-dictionary'); // title list screen
+
+ $this->insert_news_pointer ( 'xd_new_version' ); // pointer in menu for updated version
+ add_action( 'admin_print_footer_scripts', array(&$this, 'print_the_pointers_js') );
}
function on_load_page() {
@@ -113,10 +2272,9 @@
wp_enqueue_script('wp-lists');
wp_enqueue_script('postbox');
- add_meta_box('xili-dictionary-sidebox-1', __('Message','xili-dictionary'), array(&$this,'on_sidebox_1_content'), $this->thehook , 'side', 'core');
- add_meta_box('xili-dictionary-sidebox-2', __('Info','xili-dictionary'), array(&$this,'on_sidebox_2_content'), $this->thehook , 'side', 'core');
-
-
+ add_meta_box('xili-dictionary-sidebox-message', __('Message','xili-dictionary'), array(&$this,'on_sidebox_message_content'), $this->thehook , 'side', 'core');
+ add_meta_box('xili-dictionary-sidebox-info', __('Info','xili-dictionary'), array(&$this,'on_sidebox_info_content'), $this->thehook , 'side', 'core');
+ add_meta_box('xili-dictionary-sidebox-style', __('XD style settings','xili-dictionary'), array(&$this,'on_sidebox_style_content'), $this->thehook , 'side', 'core');
}
/**
@@ -132,7 +2290,7 @@
if (!$this_plugin ) $this_plugin = plugin_basename(__FILE__);
if ($file == $this_plugin ) {
- $settings_link = '' . __('Settings') . ' ';
+ $settings_link = '' . __('Settings') . ' ';
$links = array_merge( array($settings_link), $links); // before other links
}
return $links;
@@ -140,28 +2298,41 @@
function init_textdomain() {
/*multilingual for admin pages and menu*/
- load_plugin_textdomain('xili-dictionary',PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)), dirname(plugin_basename(__FILE__)));
+
+ load_plugin_textdomain('xili-dictionary', false, 'xili-dictionary/languages' );
- if (!defined('THEME_LANGS_FOLDER')) { /* set or detect at least a .mo or .po */
- if ($this->xili_settings['langs_folder'] == "") {
- $this->find_files(get_template_directory(), '/.[mp]o$/', array(&$this,'searchpath'));
- update_option('xili_dictionary_settings', $this->xili_settings);
- }
- define('THEME_LANGS_FOLDER',$this->xili_settings['langs_folder']); // for bkwd compatibility with xili-dictionary
+ if ( class_exists('xili_language') ) {
+ global $xili_language ;
+ $langs_folder = $xili_language->xili_settings['langs_folder']; // set by override_load_textdomain filter
+ if ( $this->xili_settings['langs_folder'] != $langs_folder ) {
+ $this->xili_settings['langs_folder'] = $langs_folder ;
+ update_option('xili_dictionary_settings', $this->xili_settings);
+ }
+ } else {
+ if ( file_exists( $this->get_template_directory ) ) // when theme was unavailable
+ $this->find_files($this->get_template_directory, '/^.*\.(mo|po|pot)$/', array(&$this,'searchpath'));
}
}
+
+ /* call by findfiles */
function searchpath($path, $filename) {
- $this->xili_settings['langs_folder'] = str_replace(get_template_directory(),'',$path);
+ $langs_folder = str_replace($this->get_template_directory,'',$path); // updated 1.2.0
+ if ( $this->xili_settings['langs_folder'] != $langs_folder ) {
+ $this->xili_settings['langs_folder'] = $langs_folder ;
+ update_option('xili_dictionary_settings', $this->xili_settings);
+ }
}
-
+
function xililanguage_state() {
/* test if xili-language is present or was present */
if (class_exists('xili_language')) {
+
$this->xililanguage = 'isactive';
+
} else {
/* test if language taxonomy relationships are present */
$xl_settings = get_option('xili_language_settings');
- if (empty($xl_settings)) {
+ if ( empty($xl_settings) ) {
$this->xililanguage = 'neveractive';
} else {
$this->xililanguage = 'wasactive';
@@ -170,56 +2341,77 @@
}
/** * @since 1.02 */
function fill_default_languages_list() {
- if ($this->xililanguage == 'neveractive' || $this->xililanguage == 'wasactive') {
+ if ( $this->xililanguage == 'neveractive' || $this->xililanguage == 'wasactive' ) {
- if (!$this->xili_settings[XDDICTLANGS]) {
+ if ( !isset( $this->xili_settings['xl-dictionary-langs'] ) ) {
+
$default_langs_array = array(
'en_us' => array('en_US', 'english'),
'fr_fr' => array('fr_FR', 'french'),
'de_de' => array('de_DE', 'german'),
'es_es' => array('es_ES', 'spanish'),
- 'it_it' => array('it_IT', 'italian')
+ 'it_it' => array('it_IT', 'italian'),
+ 'pt_pt' => array('pt_PT', 'portuguese'),
+ 'ru_ru' => array('ru_RU', 'russian'),
+ 'zh_cn' => array('zh_CN', 'chinese'),
+ 'ja' => array('ja', 'japanese'),
+ 'ar_ar' => array('ar_AR', 'arabic')
);
/* add wp admin lang */
- if (defined ('WPLANG')) {
+ if ( defined ('WPLANG') ) {
$lkey = strtolower(WPLANG);
if (!array_key_exists($lkey, $default_langs_array)) $default_langs_array[$lkey] = array (WPLANG, WPLANG);
}
- $this->xili_settings[XDDICTLANGS] = $default_langs_array;
+ $this->xili_settings['xl-dictionary-langs'] = $default_langs_array;
update_option('xili_dictionary_settings', $this->xili_settings);
}
}
}
/**
- * private function to update grouping of terms if xili-language is active
- *
- *
- *
+ * for slug with 5 (_fr_fr) or 2 letters (as japanese)
+ *
*/
- function update_terms_langs_grouping() {
- if ($this->xililanguage == 'isactive') {
-
- $listdictiolines = get_terms(DTAXONAME, array('hide_empty' => false,'get'=>'all'));
- if (!empty($listdictiolines)) {
- foreach ($listdictiolines as $dictioline) {
- /* check slug before creating relationship if parent = O select msgid */
- if ($dictioline->parent != 0) {
- $extend = substr($dictioline->slug,-5);
- $lang = get_term_by('slug',$extend,TAXONAME,OBJECT);
- if ($lang) {
- $term = $lang->name;
- } else {
- $term = $extend;
- }
- $args = array( 'alias_of' => '', 'description' => 'Dictionary Group in '.$term, 'parent' => 0, 'slug' =>$extend);
- $theids = wp_insert_term( $term, XDDICTLANGS, $args);
- wp_set_object_terms((int) $dictioline->term_id, $extend, XDDICTLANGS,false);
- }
- }
- }
- }
- }
+ function extract_extend ( $line_slug ) {
+ $end = substr($line_slug, -6 ) ;
+ if ( substr($end, 0, 1) == '_' && substr($end, 3, 1) == '_' ) {
+ return substr($line_slug, -5 );
+ } else {
+ return substr($line_slug, -2 ); // as ja
+ }
+ }
+
+ function popupmenu_language_list ( $action = "" ) { ?>
+get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP, TAXONAME, 'ASC' ); //get_terms(TAXONAME, array('hide_empty' => false));
+ if ( $listlanguages ) {
+ foreach ($listlanguages as $reflanguage) {
+ echo 'name) {
+ echo ' selected="selected"';
+ }
+ echo ">".__($reflanguage->description,'xili-dictionary').' ';
+
+ }
+ }
+ if ( $action=='import' ) { // to import .pot of current domain 1.0.5
+ if ( function_exists('is_child_theme') && is_child_theme() ) { // 1.8.1 and WP 3.0
+ $theme_name = get_option("stylesheet");
+ } else {
+ $theme_name = get_option("template");
+ }
+ if (function_exists('the_theme_domain')) {// in new xili-language
+ echo ''.the_theme_domain().'.pot ';
+ } else {
+
+ echo ''.$theme_name.'.pot ';
+ }
+ }
+ ?>
+
+
-
-
+
+
-
-
-
-
- xili_settings['langs_folder'];
+ function get_theme_name () {
+ if ( function_exists('is_child_theme') && is_child_theme() ) { // 1.8.1 and WP 3.0
+ $theme_name = get_option("stylesheet").' '.__('child of','xili-dictionary').' '.get_option("template");
+ } else {
+ $theme_name = get_option("template");
+ }
+ return $theme_name;
+ }
+
+ function on_sidebox_info_content() {
+ $template_directory = $this->get_template_directory;
+
+ $theme_name = $this->get_theme_name ();
+ if ( $this->xililanguage_ms ) {
+ echo '
'.__('xili-language-ms is active !','xili-dictionary').'
';
+
+ } else {
+ switch ( $this->xililanguage ) {
+ case 'neveractive';
+ echo ''.__('xili-language plugin is not present !','xili-dictionary').'
';
+ break;
+ case 'wasactive';
+ echo ''.__('xili-language plugin is not activated !','xili-dictionary').'
';
+ break;
+ }
+ }
+ ?>
+
+
+
+
+
+ xili_settings['langs_folder'];
echo __("Languages sub-folder:",'xili-dictionary').' '. $langfolder; ?>
- ';
- $this->find_files(get_template_directory(), '/.mo$/', array(&$this,'available_mo_files')) ;?>
-
-
+ add at least a .po or a .mo inside. Errors will occur if you try to import or export!",'xili-dictionary'); echo ' '; ?> ';
+ if ( file_exists( $this->get_template_directory ) ) // when theme was unavailable
+ $this->find_files($this->get_template_directory, '/.mo$/', array(&$this,'available_mo_files')) ;
+ }
+
+ ?>
+
+
+
+
+ exists_style_ext ) {
+
+ echo ''. __( 'There is no style for dashboard','xili-dictionary' ) .' ('.$this->style_message . ' )
';
+
+ } else {
+
+ echo ''. $this->style_message . '
';
+ }
+
+ if ( $this->xili_settings['external_xd_style'] == "on" ) {
+
+ $style_action = __( 'No style for dashboard','xili-dictionary' );
+ $what = 'off';
+
+ } else {
+
+ $style_action = __( 'Activate style for dashboard','xili-dictionary' );
+ $what = 'on';
+ }
+ ?>
+
+
+
+
+
+ subselect == '') ? '' : '&tagsgroup_parent_select='.$this->subselect );
?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- xili_dict_row($orderby,$tagsnamelike,$tagsnamesearch); /* the lines */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xili_dict_cpt_row( $orderby, $tagsnamelike, $tagsnamesearch ); /* the lines */
?>
-
-
-
- ( )
-
+
+
+
+
+
+
- /* the create - edit - delete form */ ?>
-
- '.the_theme_domain().'.pot';
+ } else {
+
+ echo '
'.$theme_name.'.pot ';
+ }
+ }
+ ?>
+
+
+
+
+ parent == 0) {
- $noedited = 'disabled="disabled"';
- $extend = "";
- } elseif ($action=='edit') {
- /* search default */
- $extend = substr($dictioline->slug,-5);
- } elseif ($action=='delete' && $dictioline->parent == 0) {
- $noedit = 'disabled="disabled"';
- $extend = "";
- } elseif ($action=='delete') {
- $noedit = 'disabled="disabled"';
- $extend = substr($dictioline->slug,-5);
- }
- ?>
-
-
-
-
-
+ if ( $action == 'importtaxonomy' ) { ?>
+
+
+
+
+
+
+
+ '.__( 'This box is used for input dialog, leave it opened and visible…', 'xili-dictionary' ).'';
+ }
+ ?>
+ false) );
+ if ( $listterms ) {
+ foreach ( $listterms as $onetheme) {
+ $idcheck = 'theme-'.$onetheme->term_id;
+ if ( isset ( $_POST[$idcheck] ) ) $checked_themes[] = $onetheme->name;
+ }
}
- }
- /** * @updated 1.0.2 * manage files */
- function on_normal_3_content($data) { ?>
-
- xililanguage) {
- case 'neveractive';
- echo ''._e('xili-language plugin is not present !','xili-dictionary').'
';
- break;
- case 'wasactive';
- echo ''._e('xili-language plugin is not activated !','xili-dictionary').'
';
- break;
- }
- $linkstyle = "text-decoration:none; text-align:center; display:block; width:70%; margin:0px 1px 1px 30px; padding:4px 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;" ;
- $linkstyle3 = "text-decoration:none; text-align:center; display:inline-block; width:16%; margin:0px 1px 1px 10px; padding:4px 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; border:1px #ccc solid;" ;
- $linkstyle1 = $linkstyle." border:1px #33f solid;";
- $linkstyle2 = $linkstyle." border:1px #ccc solid;";
- ?>
-
- :PO
- MO
-
-
-
-
-
-
+ return $checked_themes;
+ }
-
+
+
+ :PO
+MO
+
+
+
+
+
+
+ '2.3.9' ) {
+ _e ( '…and comment, locale, date terms.', 'xili-dictionary' ); echo ' ';
+ } ?>
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
subselect == "msgid") ? 'selected="selected"' :'' ;
- echo ''.__('Only MsgID (en_US)','xili-dictionary').' ';
- echo $this->build_grouplist();
+ echo ''.__('Only MsgID (en_US)','xili-dictionary').' ';
+ $checked = ($this->subselect == "msgstr") ? 'selected="selected"' :'' ;
+ echo ''.__('Only Msgstr','xili-dictionary').' ';
+ $checked = ($this->subselect == "msgstr_0") ? 'selected="selected"' :'' ;
+ echo ''.__('Only Msgstr plural','xili-dictionary').' ';
+ echo $this->build_grouplist();
+ echo $this->build_grouplist('nottransin_'); // 2.1.2 - not translated in
?>
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
build_grouplist('');
?>
-
-
-
-
- :
-
- :
-
-
-
-
+
+
+
+
+
+
+
+
+ :
+
+ :
+
+
+
+
+
+
xililanguage == 'isactive') {
- $listdictlanguages = get_terms(XDDICTLANGS, array('hide_empty' => false));
+ function build_grouplist ($left_line = '') {
+
+ $listdictlanguages = $this->get_terms_of_groups_lite ( $this->langs_group_id, TAXOLANGSGROUP,TAXONAME, 'ASC' ); //get_terms(TAXONAME, array('hide_empty' => false));
+ $optionlist = "";
+ $lefttext = "";
+ if ( $left_line == 'nottransin_' ) $lefttext = __('not translated in','xili-dictionary').' ';
foreach($listdictlanguages as $dictlanguage) {
- $checked = ($this->subselect == $dictlanguage->slug) ? 'selected="selected"' :'' ;
- $optionlist .= ''.__('Only:','xili-dictionary').' '.$dictlanguage->name.' ';
+ $checked = ($this->subselect == $left_line.$dictlanguage->slug) ? 'selected="selected"' :'' ;
+ $optionlist .= ''.$lefttext.$dictlanguage->name .' ('.$dictlanguage->description.') ';
}
- } else {
- $langs_array = $this->xili_settings[XDDICTLANGS];
- foreach ($langs_array as $lkey => $dictlanguage) {
- $checked = ($this->subselect == $lkey) ? 'selected="selected"' :'' ;
- $optionlist .= ''.__($left_line,'xili-dictionary').' '.$dictlanguage[0].' ';
- }
- }
+
return $optionlist;
}
+
/**
- * @since 0.9.9
+ * @since 1.3.3
*
*
*/
- function test_and_create_slug($description, $slug, $lang='') {
- $slug = sanitize_title(str_replace(' ','_',$slug));
- //echo $slug;
- $found = is_term($slug,DTAXONAME);
- if ($found){
- /* compare description*/
- $found_term = get_term($found['term_id'],DTAXONAME);
- if ($found_term->description == $description) {
- return $slug;
- } else {
- if ( '' == $lang) {
- //echo 'nul';
- $slug = $slug.'z';
- return $this->test_and_create_slug($description, $slug, $lang);
- } else {
- //echo $slug;
- $theslug = str_replace('_'.$lang,'',$slug);
- $theslug = $theslug.'z'.'_'.$lang; /* risk the parent term cannot be created after */
- return $this->test_and_create_slug($description, $theslug, $lang);
- }
- }
- } else {
- //echo 'pas nul';
- return $slug;
- }
+ function xd_wp_set_object_terms( $term_id, $lang_slug, $taxo_dictgroup , $bool = false) {
+
+ // check if lang_slug exists in this dict taxonomy
+ if ( ! $term_info = term_exists($lang_slug, $taxo_dictgroup) ) {
+ // Skip if a non-existent term ID is passed.
+ if ( is_int( $term_info ) )
+ continue;
+ $args = array( 'alias_of' => '', 'description' => 'Dictionary Group in '.$lang_slug );
+ $term_info = wp_insert_term($lang_slug, $taxo_dictgroup, $args); //print_r ($term_info);
+ }
+ wp_set_object_terms( $term_id, $lang_slug, $taxo_dictgroup, $bool );
+
}
- /** * @since 1.0.0 */
- function xili_dic_update_term($term, $taxonomy, $args) {
- remove_filter('pre_term_description', 'wp_filter_kses'); /* 0.9.8.2 to allow more tag in msg str or id */
- $rterm_id = wp_update_term( $term, $taxonomy, $args);
- add_filter('pre_term_description', 'wp_filter_kses');
- return $rterm_id;
- }
- function xili_dic_insert_term($termname, $taxonomy, $args) {
- remove_filter('pre_term_description', 'wp_filter_kses'); /* 0.9.8.2 to allow more tag in msg str or id */
- $rterm_id = wp_insert_term( $termname, $taxonomy, $args);
- add_filter('pre_term_description', 'wp_filter_kses');
- return $rterm_id;
- }
+
+
+ /**
+ * Dashboard - Manage - Dictionary
+ *
+ * @since 0.9
+ * @updated 2.0
+ *
+ */
+ function xili_dictionary_settings() {
+ $action = "";
- /* Dashboard - Manage - Dictionary */
- function xili_dictionary_settings() {
- $formtitle = __('Add a term','xili-dictionary');
+ $term_id = 0;
+ $formtitle = __('Dialog box','xili-dictionary');
$formhow = " ";
- $submit_text = __('Add »','xili-dictionary');
+ $submit_text = __('Do »','xili-dictionary');
$cancel_text = __('Cancel');
- $this->langfolder = (defined('THEME_LANGS_FOLDER') && THEME_LANGS_FOLDER !='/') ? '/'.str_replace("/","",THEME_LANGS_FOLDER).'/' : "/";
- $tagsnamelike = $_POST['tagsnamelike'];
+ $langfolderset = $this->xili_settings['langs_folder'];
+ $this->langfolder = ( $langfolderset !='' ) ? $langfolderset.'/' : '/';
+ // doublon
+ $this->langfolder = str_replace ("//","/", $this->langfolder ); // upgrading... 2.0 and sub folder sub
+ $selecttaxonomy = "";
+
+ $tagsnamelike = ( isset ( $_POST['tagsnamelike'] ) ) ? $_POST['tagsnamelike'] : '';
if (isset($_GET['tagsnamelike']))
$tagsnamelike = $_GET['tagsnamelike']; /* if link from table */
- $tagsnamesearch = $_POST['tagsnamesearch'];
+ $tagsnamesearch = ( isset ( $_POST['tagsnamesearch'] ) ) ? $_POST['tagsnamesearch'] : '';
if (isset($_GET['tagsnamesearch']))
$tagsnamesearch = $_GET['tagsnamesearch'];
@@ -630,7 +2898,7 @@
if (isset($_GET['action'])) {
$action=$_GET['action'];
- $term_id = $_GET['term_id'];
+
}
/* language delete or add */
if (isset($_POST['lang_delete'])) {
@@ -652,44 +2920,75 @@
else :
$orderby = 't.term_id'; /* 0.9.8 */
endif;
- if(isset($_POST['tagsgroup_parent_select']) && $_POST['tagsgroup_parent_select'] != 'no_select') {
+ if ( isset($_POST['tagsgroup_parent_select']) && $_POST['tagsgroup_parent_select'] != 'no_select') {
$this->subselect = $_POST['tagsgroup_parent_select'];
} else {
$this->subselect = '';
}
- if (isset($_GET['tagsgroup_parent_select']))
+ if ( isset($_GET['tagsgroup_parent_select']))
$this->subselect = $_GET['tagsgroup_parent_select'];
if (isset($_POST['subselection'])) {
$action='subselection';
}
- $message = $action." = " ;
- switch($action) {
+ if ( function_exists('is_child_theme') && is_child_theme() ) {
+ $cur_theme_name = get_option("stylesheet");
+ } else {
+ $cur_theme_name = get_option("template");
+ }
+
+ $message = ''; //$action." = " ;
+ $msg = 0;
+ switch($action) {
+ case 'setstyle'; // external xd-style.css
+ check_admin_referer( 'xdsetstyle' );
+ if ( isset ( $_GET['what'] ) ) {
+ $what = 'off';
+ if ( $_GET['what'] == 'on' ) {
+ $what = 'on';
+ } else if ( $_GET['what'] == 'off' ) {
+ $what = 'off';
+ }
+ $this->xili_settings['external_xd_style'] = $what ;
+ update_option('xili_dictionary_settings', $this->xili_settings);
+ }
+ $actiontype = "add";
+ break;
+
case 'lang_delete';
- $reflang = $_POST['langs_list'];
- $wp_lang = (defined('WPLANG')) ? strtolower(WPLANG) : 'en_us';
- if ($reflang != 'no_select' && $reflang != 'en_us' && $reflang != $wp_lang) {
- unset($this->xili_settings[XDDICTLANGS][$reflang]);
- update_option('xili_dictionary_settings', $this->xili_settings);
- $message .= ' '.$reflang.' deleted';
- } else {
- $message .= ' nothing to delete';
- }
+ $reflang = $_POST['langs_list'];
+ $wp_lang = (defined('WPLANG')) ? strtolower(WPLANG) : 'en_us';
+ if ($reflang != 'no_select' && $reflang != 'en_us' && $reflang != $wp_lang) {
+ $ids = term_exists($reflang, TAXONAME);
+ if ( $ids ) {
+ if ( is_wp_error( $ids ) ) {
+ $message .= ' '.$reflang.' error';
+ } else {
+ $t_id = $ids['term_id'];
+ wp_delete_term( $t_id, TAXONAME );
+ $message .= ' '.$reflang.' deleted';
+ }
+ } else {
+ $message .= ' '.$reflang.' not exist';
+ }
- $actiontype = "add";
- break;
+ } else {
+ $message .= ' nothing to delete';
+ }
+
+ $actiontype = "add";
+ break;
case 'lang_add';
$reflang = ('' != $_POST['lang_ISO'] ) ? $_POST['lang_ISO'] : "???";
$reflangname = ('' !=$_POST['lang_name']) ? $_POST['lang_name'] : $reflang;
- if ($reflang != '???' && strlen($reflang) == 5 && substr($reflang,2,1) == '_') {
- $lkey = strtolower($reflang);
- $reflang = strtolower(substr($reflang,0,3)).strtoupper(substr($reflang,-2));
- $msg = (array_key_exists($lkey, $this->xili_settings[XDDICTLANGS])) ? ' updated' : ' added';
- $this->xili_settings[XDDICTLANGS][$lkey] = array($reflang,$reflangname);
- update_option('xili_dictionary_settings', $this->xili_settings);
+ if ($reflang != '???' && ( ( strlen($reflang) == 5 && substr($reflang,2,1) == '_') ) || ( strlen($reflang) == 2 ) ) {
+
+ $args = array( 'alias_of' => '', 'description' => $reflangname, 'parent' => 0, 'slug' =>strtolower( $reflang ));
+ $theids = $this->safe_lang_term_creation ( $reflang, $args );
+ wp_set_object_terms($theids['term_id'], 'the-langs-group', TAXOLANGSGROUP);
$message .= ' '.$reflang.$msg;
} else {
$message .= ' error ('.$reflang.') ! no add';
@@ -716,140 +3015,86 @@
$message .= ' sub list of terms starting with '.$_POST['tagsnamelike'];
$actiontype = "add";
break;
-
- case 'add':
-
- $originalortrans = $_POST['dictioline_description1'];
- $nblines = $_POST['termnblines']; /**/
- if ( $nblines > 1 ) {
- for ($i = 2; $i <= $nblines; $i++) {
- $originalortrans .= XPLURAL.$_POST['dictioline_description'.$i];
- }
- }
-
- /*create the slug with term and add prefix*/
- $possible = true;
- if (''!=$_POST['dictioline_lang']) {
- if ('no_parent' != $_POST['dictioline_parent'] ) {
- $parent_id = $_POST['dictioline_parent'];
- $parent_term = get_term($parent_id,DTAXONAME,OBJECT,'edit');
- $sslug = $parent_term->slug.'_'.$_POST['dictioline_lang'] ;
-
- $lang = $_POST['dictioline_lang'];
- } else {
- $message .= __('No parent term defined','xili-dictionary');
- $possible = false;
- }
- } else {
- $lang = '';
- /* is content plural */
- if (false === strpos($originalortrans,XPLURAL)) {
- $sslug = htmlentities($originalortrans);
-
- } else {
- $plurals = explode (XPLURAL,$originalortrans);
- $sslug = htmlentities($plurals[0]); /* in term slug only first*/
- }
- }
- $sslug = $this->test_and_create_slug($originalortrans, $sslug, $lang);
-
- if ($possible) {
- $aliasof = $_POST['alias_of'];
- $args = array('alias_of' => $aliasof, 'description' => $originalortrans, 'parent' => $_POST['dictioline_parent'], 'slug' => $sslug);
-
- $rterm_id = $this->xili_dic_insert_term( $originalortrans, DTAXONAME, $args);
-
- if (''!=$_POST['dictioline_lang']) {
- if (is_wp_error($rterm_id)) {$message .= ' ---- error ---- '; $possible = false ;} else {
- wp_set_object_terms((int) $rterm_id['term_id'], $_POST['dictioline_lang'], XDDICTLANGS,false);
- }
- } else {
- if (is_wp_error($rterm_id)) { $message .= ' ---- error ---- '; $possible = false ; } else { $message .= " (". $rterm_id['term_id'] .") "; }
- }
- }
- $actiontype = "add";
- if ($possible) $message .= " - ".__('A new term was added.','xili-dictionary');
- break;
-
- case 'edit';
- $actiontype = "edited";
-
- $dictioline = get_term($term_id,DTAXONAME,OBJECT,'edit');
- $submit_text = __('Update »','xili-dictionary');
- $formtitle = 'Edit term';
- $message .= " - ".__('Term to update.','xili-dictionary');
- break;
-
- case 'edited';
- $actiontype = "add";
- $term = $_POST['dictioline_term_id'];
- $termname = $_POST['dictioline_name'];
- $sslug = $_POST['dictioline_slug'];
- $originalortrans = $_POST['dictioline_description1'];
- $nblines = $_POST['termnblines']; /**/
- if ( $nblines > 1 ) {
- for ($i = 2; $i <= $nblines; $i++) {
- $originalortrans .= XPLURAL.$_POST['dictioline_description'.$i];
- }
- }
-
- if (''!=$_POST['dictioline_lang']) {
- $parent_id = $_POST['dictioline_parent'];
- $parent_term = get_term($parent_id,DTAXONAME,OBJECT,'edit');
- $sslug = $parent_term->slug.'_'.$_POST['dictioline_lang'] ;
- }
-
- $args = array('name'=>$termname, 'alias_of' => $_POST['alias_of'], 'description' => $originalortrans , 'parent' => $_POST['dictioline_parent'], 'slug' => $sslug);
-
- $this->xili_dic_update_term($term, DTAXONAME, $args);
-
- if (''!=$_POST['dictioline_lang']) {
- if (is_wp_error($rterm_id)) {$message .= ' ---- error ---- ';} else {
- wp_set_object_terms((int) $rterm_id['term_id'], $_POST['dictioline_lang'], XDDICTLANGS,false);
- }
- }
- $message .= " - ".__('A term was updated.','xili-dictionary').' '.$_POST['dictioline_term_id'];
- break;
-
- case 'delete';
- $actiontype = "deleting";
- $submit_text = __('Delete »','xili-dictionary');
- $formtitle = 'Delete term ?';
- $dictioline = get_term($term_id,DTAXONAME,OBJECT,'edit');
-
- $message .= " - ".__('A term to delete. CLICK MENU DICTIONARY TO CANCEL !','xili-dictionary');
-
- break;
-
- case 'deleting';
- $actiontype = "add";
- $term_id = $_POST['dictioline_term_id'];
- wp_delete_object_term_relationships( $term_id, XDDICTLANGS );
- wp_delete_term( $term_id, DTAXONAME, $args);
- $message .= " - ".__('A term was deleted.','xili-dictionary');
- $term_id = 0; /* 0.9.7.2 */
- break;
-
+
case 'export';
$actiontype = "exporting";
$formtitle = __('Export mo file','xili-dictionary');
$formhow = __('To create a .mo file, choose language and click below.','xili-dictionary');
$submit_text = __('Export »','xili-dictionary');
break;
- case 'exporting';
+
+ case 'exporting'; // MO
+ check_admin_referer( 'xilidicoptions' );
$actiontype = "add";
$selectlang = $_POST['language_file'];
if ("" != $selectlang){
//$this->xili_create_mo_file(strtolower($selectlang));
- $mo = $this->from_twin_to_POMO ($selectlang);
- if (false === $this->Save_MO_to_file ($selectlang , $mo )) {
- $message .= ' '.sprintf(__('error during exporting in %1s.mo file.','xili-dictionary'),$selectlang);
+ $file = "";
+ $extract_array = array();
+ $checked_themes = $this->checked_themes_array();
+ if ( is_multisite() ) { /* complete theme's language with db structure languages (cats, desc,…) in uploads */
+ //global $wpdb;
+ //$thesite_ID = $wpdb->blogid;
+ $superadmin = ( isset ( $_POST['only-theme'] ) && $_POST['only-theme'] == 'only') ? true : false ;
+ $message .= ( isset ( $_POST['only-theme'] ) && $_POST['only-theme'] == 'only') ? "- exported only in theme - " : "- exported in uploads - " ;
+
+
+ if (($uploads = xili_upload_dir()) && false === $uploads['error'] ) {
+
+ if ( $superadmin === true ) {
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $this->get_template_directory.$this->langfolder.'local-'.$selectlang.'.mo' ;
+ } else {
+ $extract_array [ 'origin' ] = $checked_themes;
+ $local = '';
+ $file = '';
+ }
+ } else {
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $uploads['path']."/local-".$selectlang.".mo" ;
+ } else {
+ $extract_array [ 'origin' ] = $checked_themes;
+ $local = '';
+ $file = $uploads['path']."/".$selectlang.".mo" ;
+ }
+ }
+
+ $mo = $this->from_cpt_to_POMO_wpmu ( $selectlang, 'mo', $superadmin, $extract_array ); // do diff if not superadmin
+ }
+ } else {
+
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $this->get_template_directory.$this->langfolder.'local-'.$selectlang.'.mo' ;
+ } else {
+ $extract_array [ 'origin' ] = $checked_themes;
+ $local = '';
+ $file = '';
+ }
+
+ $mo = $this->from_cpt_to_POMO ( $selectlang, 'mo', $extract_array );
+ }
+ if ( count ($mo->entries) > 0 ){ // 2.2
+ if ( false === $this->Save_MO_to_file ($selectlang , $mo, $file ) ) {
+ $message .= $file.' '.sprintf(__('error during exporting in %2s %1s.mo file.','xili-dictionary'), $selectlang, $local);
+ } else {
+ $message .= ' '.sprintf(__('exported in %2s %1s.mo file with %3s msgids.','xili-dictionary'),$selectlang, $local, count ($mo->entries));
+ }
} else {
- $message .= ' '.sprintf(__('exported in %1s.mo file.','xili-dictionary'),$selectlang);
- }
+ $message .= sprintf(''.__('Nothing in %s, not updated', 'xili-dictionary').' ', $local.$selectlang.'.mo');
+ }
} else {
$message .= ' : error "'.$selectlang.'"';
- }
+ }
+ $msg = 6 ;
break;
case 'exportpo';
@@ -858,17 +3103,74 @@
$formhow = __('To export terms in a .po file, choose language and click below.','xili-dictionary');
$submit_text = __('Export »','xili-dictionary');
break;
- case 'exportingpo';
+
+ case 'exportingpo'; // PO
+ check_admin_referer( 'xilidicoptions' );
$actiontype = "add";
$selectlang = $_POST['language_file'];
if ("" != $selectlang){
- $po = $this->from_twin_to_POMO ($selectlang,'po');
- //if ($this->xili_exportterms_inpo(strtolower($selectlang))) {
- if (false === $this->Save_PO_to_file ($selectlang , $po )) {
- $message .= ' '.sprintf(__('error during exporting in %1s.po file.','xili-dictionary'),$selectlang);
+
+ $extract_array = array();
+ $checked_themes = $this->checked_themes_array();
+ if ( is_multisite() ) { /* complete theme's language with db structure languages (cats, desc,…) in uploads */
+
+ $superadmin = ( isset ( $_POST['only-theme'] ) && $_POST['only-theme'] == 'only') ? true : false ;
+ $message .= ( isset ( $_POST['only-theme'] ) && $_POST['only-theme'] == 'only') ? "- exported only in theme - " : "- exported in uploads - " ;
+
+ if (($uploads = xili_upload_dir()) && false === $uploads['error'] ) {
+
+ if ( $superadmin === true ) {
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $this->get_template_directory.$this->langfolder.'local-'.$selectlang.'.po' ; // theme folder
+ } else {
+ $local = '';
+ $file = '';
+ }
+ } else {
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+ $file = $uploads['path']."/local-".$selectlang.".po" ; // blogs.dir folder
+ } else {
+ $extract_array [ 'origin' ] = $checked_themes;
+
+ $local = '';
+ $file = $uploads['path']."/".$selectlang.".po" ;
+ }
+ }
+
+ }
+ } else { // standalone
+
+ if ( isset ( $_POST['only-local'] ) && $_POST['only-local'] == 'local' ) {
+ $local = 'local';
+ $extract_array [ $this->msg_extracted_comments ] = $this->local_tag;
+ $extract_array [ 'like-'.$this->msg_extracted_comments ] = true;
+
+ $file = $this->get_template_directory.$this->langfolder.'local-'.$selectlang.'.po' ;
+ } else {
+ $extract_array [ 'origin' ] = $checked_themes;
+ $local = '';
+ $file = '';
+ }
+ }
+
+
+
+ $po = $this->from_cpt_to_POMO ( $selectlang, 'po', $extract_array );
+ if ( count ($po->entries) > 0 ){ // 2.2
+ if ( false === $this->Save_PO_to_file ( $selectlang , $po, $file ) ) {
+ $message .= ' '.sprintf(__('error during exporting in %2s %1s.po file.','xili-dictionary'), $selectlang, $local );
+ } else {
+ $message .= ' '.sprintf(__('exported in %2s %1s.po file with %3s msgids.','xili-dictionary'), $selectlang, $local, count ($po->entries));
+ }
} else {
- $message .= ' '.sprintf(__('exported in %1s.po file.','xili-dictionary'),$selectlang);
- }
+ $message .= sprintf(''.__('Nothing saved in %s, not updated', 'xili-dictionary').' ', $local.$selectlang.'.po');
+ }
} else {
$message .= ' : error "'.$selectlang.'"';
}
@@ -880,6 +3182,7 @@
$formhow = __('To import terms of the current .po, choose language and click below.','xili-dictionary');
$submit_text = __('Import »','xili-dictionary');
break;
+
case 'importmo';
$actiontype = "importingmo";
$formtitle = __('Import mo file','xili-dictionary');
@@ -887,77 +3190,141 @@
$submit_text = __('Import »','xili-dictionary');
break;
- case 'importing';
+ case 'importing'; // PO
$actiontype = "add";
$message .= ' '.__('line imported from po file: ','xili-dictionary');
$selectlang = $_POST['language_file'];
+ $this->importing_po_comments = $_POST['importing_po_comments']; // 2.0-rc2
- $po = $this->pomo_import_PO ($selectlang); //print_r($po);
- if (false !== $po ) $twintexts = $this->from_PO_to_twin ($po);
-
- if (is_array($twintexts)) {
- $nblines = $this->xili_import_in_tables($twintexts,$selectlang);
- $message .= __('id lines = ','xili-dictionary').$nblines[0].' & ' .__('str lines = ','xili-dictionary').$nblines[1].' & ' .__('str lines up = ','xili-dictionary').$nblines[2];
+ if ( isset ( $_POST['local-import'] ) && $_POST['local-import'] == 'local-import' ) {
+ $local = 'local-';
+ if ( is_multisite() ) {
+
+ $po = $this->pomo_import_PO ( $selectlang, true ); // temp - only in theme if model
+
+ } else {
+
+ $po = $this->pomo_import_PO ( $selectlang, true );
+ }
+
+ } else {
+ $local = '';
+ $po = $this->pomo_import_PO ( $selectlang );
+ }
+
+ if (false !== $po ) {
+ $this->origin_theme = $cur_theme_name ;
+ $nblines = $this->from_pomo_to_cpts ( $po, $selectlang ) ; //echo "new method";
+
+ $message .= ' - '. __('id lines = ','xili-dictionary').$nblines[0].' & ' .__('str lines = ','xili-dictionary').$nblines[1] ;
} else {
- $readfile = get_template_directory().$this->langfolder.$selectlang.'.po';
- $message .= ' '.$readfile.__('po file is not present.','xili-dictionary');
+ $readfile = $this->get_template_directory.$this->langfolder.$local.$selectlang.'.po';
+ $message .= ' '.$readfile.' > '.__('po file is not present.','xili-dictionary');
}
break;
- case 'importingmo';
+ case 'importingmo'; // MO
$actiontype = "add";
$message .= ' '.__('line imported from mo file: ','xili-dictionary');
$selectlang = $_POST['language_file'];
- $mo = $this->pomo_import_MO ($selectlang);
- if (false !== $mo ) $twintexts = $this->from_MO_to_twin ($mo);
- if (is_array($twintexts)) {
- $nblines = $this->xili_import_in_tables($twintexts,$selectlang);
- $message .= __('id lines = ','xili-dictionary').$nblines[0].' & ' .__('str lines = ','xili-dictionary').$nblines[1].' & ' .__('str lines up = ','xili-dictionary').$nblines[2];
+
+ if ( isset ( $_POST['local-import'] ) && $_POST['local-import'] == 'local-import' ) {
+ $local = 'local-';
+ if ( is_multisite() ) {
+ if ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) {
+ $folder = $uploads['basedir']."/languages";
+ }
+ $folder_file = $folder . '/local-' . $selectlang . '.mo';
+ $mo = $this->pomo_import_MO ( $selectlang, $folder_file, false ); // - only in local site if saved - false because folder_file
+
+ } else {
+
+ $mo = $this->pomo_import_MO ( $selectlang, '', true ); // file set in function
+ }
+ } else {
+ $local = '';
+ $mo = $this->pomo_import_MO ( $selectlang );
+ }
+
+ if (false !== $mo ) {
+ $this->origin_theme = $cur_theme_name ;
+ $nblines = $this->from_pomo_to_cpts ( $mo, $selectlang ) ;
+
+ $message .= ' - '.__('id lines = ','xili-dictionary').$nblines[0].' & ' .__('str lines = ','xili-dictionary').$nblines[1];
} else {
- $readfile = get_template_directory().$this->langfolder.$selectlang.'.mo';
- $message .= ' '.$readfile.__('mo file is not present.','xili-dictionary');
+ $readfile = $this->get_template_directory.$this->langfolder.$local.$selectlang.'.mo';
+ $message .= ' '.$readfile.' > '.__('mo file is not present.','xili-dictionary');
}
break;
-
- case 'importcats';
- $actiontype = "importingcats";
- $formtitle = __('Import terms of categories','xili-dictionary');
- $formhow = __('To import terms of the current categories, click below.','xili-dictionary');
- $submit_text = __('Import category’s terms »','xili-dictionary');
+
+ case 'importbloginfos'; // bloginfos and others since 1.1.0
+ $actiontype = "importingbloginfos";
+ $formtitle = __('Import terms of blog info and others…','xili-dictionary');
+ $formhow = __('To import terms of blog info and others…, click below.','xili-dictionary');
+ $submit_text = __('Import blog info terms »','xili-dictionary');
+ break;
+
+ case 'importingbloginfos'; // bloginfos and others since 1.1.0
+ check_admin_referer( 'xilidicoptions' );
+ $actiontype = "add";
+
+ $infosterms = $this->xili_import_infosterms_cpt ();
+
+ $msg = 4;
+ if ($infosterms[1] > 0) {
+ $message .= ' ('.$infosterms[1].'/'.$infosterms[0].') '.__('imported with success','xili-dictionary');
+ } else {
+ $message .= ' '.__('already imported','xili-dictionary') . ' (' .$infosterms[0].') ';
+ }
+ break;
+
+ case 'importtaxonomy';
+ $actiontype = "importingtax";
+ $formtitle = __('Import terms of taxonomy','xili-dictionary');
+ $formhow = __('To import terms of the current taxonomy named, click below.', 'xili-dictionary');
+ $submit_text = __('Import taxonomy’s terms »', 'xili-dictionary');
break;
- case 'importingcats';
+ case 'importingtax';
+ check_admin_referer( 'xilidicoptions' );
$actiontype = "add";
- $message .= ' '.__('terms imported from WP: ','xili-dictionary');
+ $selecttaxonomy = $_POST['taxonomy_name']; //
+ if ( taxonomy_exists( $selecttaxonomy ) ) {
+ $nbterms = $this->xili_read_catsterms_cpt( $selecttaxonomy, $this->local_tag ); //$this->xili_read_catsterms();
+ $msg = 4;
+ if ( is_array($nbterms) ) {
+ //$nbterms = $this->xili_importcatsterms_in_tables($catterms);
+ $message .= __('names = ','xili-dictionary').$nbterms[0].' & ' .__('descs = ','xili-dictionary').$nbterms[1];
+ } else {
+ $message .= ' '.sprintf(__('taxonomy -%s- terms pbs!', 'xili-dictionary'), $selecttaxonomy );
+ }
+ } else {
+ $msg = 8;
+ $message .= ' '.sprintf(__('taxonomy -%s- do not exists', 'xili-dictionary'), $selecttaxonomy );
+ }
+
+ break;
- $catterms = $this->xili_read_catsterms();
-
- if (is_array($catterms)) {
- $nbterms = $this->xili_importcatsterms_in_tables($catterms);
- $message .= __('names = ','xili-dictionary').$nbterms[0].' & ' .__('descs = ','xili-dictionary').$nbterms[1];
- } else {
- $message .= ' '.$readfile.__('category’terms pbs!','xili-dictionary');
- }
- break;
case 'erasedictionary';
$actiontype = "erasingdictionary";
$formtitle = __('Erase all terms','xili-dictionary');
$formhow = __('To erase terms of the dictionary, click below. (before, create a .po if necessary!)');
$submit_text = __('Erase all terms »','xili-dictionary');
break;
+
case 'erasingdictionary';
+ check_admin_referer( 'xilidicoptions' );
+
+ $selection = ""; // $selecttaxonomy = $_POST['erasing_selection'];
+ $this->erase_dictionary( $selection );
+
+
$actiontype = "add";
- $message .= ' '.__('All terms erased !','xili-dictionary');
- $listdictiolines = get_terms(DTAXONAME, array('hide_empty' => false));
- if (!empty($listdictiolines)) {
- foreach ($listdictiolines as $dictioline) {
- wp_delete_object_term_relationships( $dictioline->term_id, XDDICTLANGS );
- wp_delete_term($dictioline->term_id, DTAXONAME, $args);
- }
- $dictioline = null;
- }
+ $message .= ' '.__('All terms erased !','xili-dictionary'); $msg = 7;
+ // for next update
break;
+
case 'importcurthemeterms';
$actiontype = "importingcurthemeterms";
$formtitle = __('Import all terms from current theme','xili-dictionary');
@@ -970,12 +3337,12 @@
break;
- case 'importingcurthemeterms';
+ case 'importingcurthemeterms'; // temporary inactive 2.1
$actiontype = "add";
- $message .= ' '.__('All terms imported !','xili-dictionary');
+ $message .= ' '.__('All terms imported !','xili-dictionary'); $msg = 5 ;
$themeterms = $this->scan_import_theme_terms(array(&$this,'build_scanned_files'),0);
if (is_array($themeterms)) {
- $nbterms = $this->xili_importthemeterms_in_tables($themeterms);
+ //$nbterms = $this->xili_importthemeterms_in_tables($themeterms);
$message .= __('terms = ','xili-dictionary').$nbterms;
} else {
$message .= ' '.$readfile.__('theme’s terms pbs!','xili-dictionary');
@@ -986,7 +3353,7 @@
break;
default:
$actiontype = "add";
- $message .= ' '.__('Find above the list of terms.','xili-dictionary');
+ $message .= ' '.__('Find below the list of terms.','xili-dictionary');
}
/* register the main boxes always available */
@@ -996,234 +3363,884 @@
if ($this->xililanguage != 'isactive')
add_meta_box('xili-dictionary-sidebox-5', __('Languages list management','xili-dictionary'), array(&$this,'on_normal_5_content'), $this->thehook , 'side', 'core'); /* Languages list when xili-language is absent */
- add_meta_box('xili-dictionary-normal-2', __('Multilingual Terms','xili-dictionary'), array(&$this,'on_normal_1_content'), $this->thehook , 'normal', 'core'); /* list of terms*/
- add_meta_box('xili-dictionary-normal-1', __($formtitle,'xili-dictionary'), array(&$this,'on_normal_2_content'), $this->thehook , 'normal', 'core'); /* input form */
+ add_meta_box('xili-dictionary-normal-1', __( $formtitle, 'xili-dictionary'), array(&$this,'on_normal_2_files_dialog'), $this->thehook , 'normal', 'core'); /* input form */
+ add_meta_box('xili-dictionary-normal-cpt', __('Multilingual Terms','xili-dictionary'), array(&$this,'on_normal_cpt_content_list'), $this->thehook , 'normal', 'core'); /* list of terms*/
+
+ // since 1.2.2 - need to be upgraded...
+ if ($msg == 0 && $message != '' ) $msg = 6 ; //by temporary default
+ $themessages[1] = __('A new term was added.','xili-dictionary');
+ $themessages[2] = __('A term was updated.','xili-dictionary');
+ $themessages[3] = __('A term was deleted.','xili-dictionary');
+ $themessages[4] = __('terms imported from WP: ','xili-dictionary') . $message;
+ $themessages[5] = __('All terms imported !','xili-dictionary');
+ $themessages[6] = 'beta testing log: '.$message ;
+ $themessages[7] = __('All terms erased !','xili-dictionary');
+ $themessages[8] = __('Error when adding !','xili-dictionary');
+ $themessages[9] = __('Error when updating !','xili-dictionary');
/* form datas in array for do_meta_boxes() */
- $data = array('message'=>$message,'messagepost'=>$messagepost,'action'=>$action, 'formtitle'=>$formtitle, 'dictioline'=>$dictioline,'submit_text'=>$submit_text,'cancel_text'=>$cancel_text, 'formhow'=>$formhow, 'orderby'=>$orderby,'term_id'=>$term_id, 'tagsnamesearch'=>$tagsnamesearch, 'tagsnamelike'=>$tagsnamelike);
+ $data = array('message'=>$message, 'action'=>$action, 'formtitle'=>$formtitle, 'submit_text'=>$submit_text,'cancel_text'=>$cancel_text, 'formhow'=>$formhow, 'orderby'=>$orderby,'term_id'=>$term_id, 'tagsnamesearch'=>$tagsnamesearch, 'tagsnamelike'=>$tagsnamelike, 'selecttaxonomy' =>$selecttaxonomy);
+ if ( isset ( $dictioline ) ) $data['dictioline'] = $dictioline ;
+
?>
-