[gnome-web-wppo] added support to store bloginfo translations and display accordingly



commit 856b2fafeb7c116c6ecffbb5e4aa7ede48517c16
Author: Vinicius Depizzol <vdepizzol gmail com>
Date:   Thu Mar 8 23:21:23 2012 -0300

    added support to store bloginfo translations and display accordingly

 backend.php |   15 +++++++++++++++
 wppo.php    |    8 +-------
 2 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/backend.php b/backend.php
index 3862839..eba4040 100644
--- a/backend.php
+++ b/backend.php
@@ -230,6 +230,21 @@ function wppo_check_for_po_changes($force = false, $coverage = array('dynamic',
                  */
                 $bloginfo = $dom->getElementsByTagName('bloginfo');
                 
+                foreach ($bloginfo->item(0)->childNodes as $option) {
+                    if (get_class($option) == 'DOMElement') {
+                        $option_node['option_name'] = $option->nodeName;
+                        $option_node['lang'] = $lang;
+                        $option_node['translated_value'] = $option->nodeValue;
+                        
+                        if (!$wpdb->get_row("SELECT option_name FROM ".WPPO_PREFIX."options WHERE option_name = '". mysql_real_escape_string($option_node['option_name']) ."' AND lang = '". mysql_real_escape_string($lang) ."'")) {
+                            $wpdb->insert(WPPO_PREFIX."options", $option_node);
+                        } else {
+                            $wpdb->update(WPPO_PREFIX."options", $option_node, array('option_name' => $option_node['options_name'], 'lang' => $lang));
+                        }
+                    }
+                }
+                
+                
                 /*
                  * Read the terms
                  */
diff --git a/wppo.php b/wppo.php
index 79ef748..15fea1d 100644
--- a/wppo.php
+++ b/wppo.php
@@ -245,17 +245,11 @@ if (!is_admin()) {
      */
 
     add_filter('bloginfo', function($bloginfo, $attribute) {
-        //return 'HEY '.$attribute;
 
         global $wppo_cache, $wpdb;
 
         $lang = wppo_get_lang();
-        
-        switch ($attribute) {
-            case 'name':        $col_attr = 'blogname';         break;
-            case 'description': $col_attr = 'blogdescription';  break;
-            default:            $col_attr = $attribute;         break;
-        }
+        $col_attr = $attribute;
         
         if (!isset($wppo_cache['bloginfo'][$col_attr]) && $lang != WPPO_DEFAULT_LANGUAGE_CODE) {
             $wppo_cache['bloginfo'][$col_attr] = $wpdb->get_row("SELECT * FROM " . WPPO_PREFIX . "options ".



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]