/** ====================================================================================================================================================
  * Send the feedback form
  * 
  * @access private
  * @return void
  */
 public function send_feedback()
 {
     // We sanitize the entries
     $plugin = preg_replace("/[^a-zA-Z0-9_-]/", "", $_POST['plugin']);
     $pluginID = preg_replace("/[^a-zA-Z0-9_]/", "", $_POST['pluginID']);
     $name = strip_tags($_POST['name']);
     $mail = preg_replace("/[^:\\/a-z0-9@A-Z_.-]/", "", $_POST['mail']);
     $comment = strip_tags($_POST['comment']);
     // If applicable, we select the log file
     $logfile = SLFramework_Debug::get_log_path();
     $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR . "/" . $plugin . "/" . $plugin . ".php");
     $to = $info_file['Email'];
     $subject = "[" . ucfirst($plugin) . "] Feedback of " . $name;
     $message = "";
     $message .= "From {$name} (" . $mail . ")\n\n\n";
     $message .= $comment . "\n\n\n";
     $message .= "* Accounts \n";
     $message .= "**************************************** \n";
     $admin = get_userdata(1);
     $message .= "Admin User Name: " . $admin->display_name . "\n";
     $message .= "Admin User Login: "******"\n";
     $message .= "Admin User Mail: " . $admin->user_email . "\n";
     $current_user = wp_get_current_user();
     $message .= "Logged User Name: " . $current_user->display_name . "\n";
     $message .= "Logged User Login: "******"\n";
     $message .= "Logged User Mail: " . $current_user->user_email . "\n";
     $message .= "\n\n\n";
     $message .= "* Information \n";
     $message .= "**************************************** \n";
     $message .= "Plugin: " . $plugin . "\n";
     $message .= "Plugin Version: " . $info_file['Version'] . "\n";
     $message .= "Wordpress Version: " . get_bloginfo('version') . "\n";
     $message .= "URL (home): " . home_url('/') . "\n";
     $message .= "URL (site): " . site_url('/') . "\n";
     $message .= "Language: " . get_bloginfo('language') . "\n";
     $message .= "Charset: " . get_bloginfo('charset') . "\n";
     $message .= "\n\n\n";
     $message .= "* Configuration of the plugin \n";
     $message .= "**************************************** \n";
     $options = get_option($pluginID . '_options');
     // mask the password
     $new_option = array();
     $new_plugin_copy = call_user_func(array($pluginID, 'getInstance'));
     foreach ($options as $o => $v) {
         if ($new_plugin_copy->get_default_option($o) !== "[password]") {
             $new_option[$o] = $v;
         } else {
             $new_option[$o] = "********** (masked)";
         }
     }
     ob_start();
     print_r($new_option);
     $message .= ob_get_clean();
     $message .= "\n\n\n";
     $message .= "* Activated plugins \n";
     $message .= "**************************************** \n";
     $plugins = get_plugins();
     $active = get_option('active_plugins');
     foreach ($plugins as $file => $p) {
         if (array_search($file, $active) !== false) {
             $message .= $p['Name'] . "(" . $p['Version'] . ") => " . $p['PluginURI'] . "\n";
         }
     }
     $headers = "";
     if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\\.[a-z]{2,4}\$#", $mail)) {
         $headers = "Reply-To: {$mail}\n" . "Return-Path: {$mail}";
     }
     $attachments = array($logfile);
     // send the email
     if (wp_mail($to, $subject, $message, $headers, $attachments)) {
         echo "<div class='updated  fade'>";
         echo "<p>" . __("The feedback has been sent", 'SL_framework') . "</p>";
         echo "</div>";
         SLFramework_Debug::log(get_class(), "A feedback mail has been sent.", 4);
     } else {
         echo "<div class='error  fade'>";
         echo "<p>" . __("An error occured sending the email.", 'SL_framework') . "</p><p>" . __("Make sure that your wordpress is able to send email.", 'SL_framework') . "</p>";
         echo "</div>";
         SLFramework_Debug::log(get_class(), "A feedback mail has failed to be sent.", 2);
     }
     //Die in order to avoid the 0 character to be printed at the end
     die;
 }
 /** ====================================================================================================================================================
  * List all the language installed for this framework
  * 
  * @access private
  * @return void
  */
 static function installed_languages_framework($domain, $plugin)
 {
     require 'translation.inc.php';
     // The plugin_frame is the plugin that store the framework file
     $plugin_frame = explode("/", plugin_basename(__FILE__));
     $plugin_frame = $plugin_frame[0];
     $path = WP_PLUGIN_DIR . "/" . $plugin_frame;
     $path_cache = WP_PLUGIN_DIR . "/" . $plugin;
     $plugin_lien = $plugin;
     @chmod($path . "/core/lang/", 0755);
     $dir = @scandir($path . "/core/lang/");
     $dom = "SL_framework";
     $file = array();
     $signature_files = array();
     foreach ($dir as $item) {
         if ('.' == $item || '..' == $item) {
             continue;
         }
         if (preg_match("/([a-z]{2}_[A-Z]{2})\\.mo\$/", $item, $h)) {
             $file[] = $h[1];
             $signature_files[] = "SL_framework-" . $h[1] . ".mo" . filesize($path . "/core/lang/SL_framework-" . $h[1] . ".mo");
         }
     }
     if (!in_array('en_US', $file)) {
         $file[] = 'en_US';
     }
     sort($file);
     sort($signature_files);
     $signature_files = get_locale() . implode('', $signature_files);
     $signature_files = sha1($signature_files);
     $nb = count($file);
     if (!is_dir(WP_CONTENT_DIR . "/sedlex/translations/")) {
         @mkdir(WP_CONTENT_DIR . "/sedlex/translations/", 0777, true);
     }
     if (is_file(WP_CONTENT_DIR . "/sedlex/translations/SL_framework_" . $signature_files . ".html")) {
         echo file_get_contents(WP_CONTENT_DIR . "/sedlex/translations/SL_framework_" . $signature_files . ".html");
         echo "<p style='text-align:right;color:#AAAAAA;font-size:9px;'>" . sprintf(__('Summary cached %s', 'SL_framework'), $signature_files) . "</p>";
         return;
     }
     // We delete all cache file
     $dir = @scandir(WP_CONTENT_DIR . "/sedlex/translations");
     foreach ($dir as $item) {
         if ('.' == $item || '..' == $item) {
             continue;
         }
         if (preg_match("/SL_framework.*\\.html\$/", $item, $h)) {
             unlink(WP_CONTENT_DIR . "/sedlex/translations/" . $item);
         }
     }
     // We reconstruct the cache file
     $signature_files = get_locale();
     ob_start();
     echo "<p>" . __("The 'SL framework' is a framework used for developping many plugins like this one. Thus, if you participate translating the framework, it will be very helpful for a bunch of plugins.", 'SL_framework') . "</p>";
     echo "<p>" . sprintf(__("There is %s languages supported for the 'SL framework'.", 'SL_framework'), $nb) . "</p>";
     // We count the number of sentences to be translated
     $content_pot = file($path . "/core/lang/SL_framework.pot");
     $all_count_pot = 0;
     foreach ($content_pot as $ligne_pot) {
         if (preg_match("/^msgid \\\"(.*)\\\"\$/", trim($ligne_pot))) {
             $all_count_pot++;
         }
     }
     echo "<p>" . sprintf(__("There is %s sentence to be translated in the framework.", 'SL_framework'), $all_count_pot) . "</p>";
     $i = 1;
     $table = new SLFramework_Table();
     $table->title(array(__('Language', 'SL_framework'), __('Ratio %', 'SL_framework'), __('Translators', 'SL_framework')));
     foreach ($file as $f) {
         $flag = $code_locales[$f]['country-www'];
         $native = $code_locales[$f]['lang-native'];
         // We look for the position in the sprite image
         //-----------------------------------------------
         $style = "";
         $num = 0;
         $i = 1;
         // Note that $flags is defined in the translation.inc.php
         foreach ($flags as $fl) {
             if ($fl == $flag) {
                 $num = $i;
             }
             $i++;
         }
         // We convert the position of the flag into coordinates of the flags_sprite.png image
         // Note that there is 12 flags per line
         $number_of_flags_per_line = 12;
         $col = $num % $number_of_flags_per_line;
         $line = floor($num / $number_of_flags_per_line);
         // Each flag has a width of 18px and an height of 12px
         $style = "background-position: " . $col * -18 . "px " . $line * -12 . "px;";
         // We check if the present author have modify a translation here
         if ($f == "en_US") {
             $info['total'] = 0;
             $info['translated'] = __("This is the default language of the plugin. It cannot be modified.", "SL_framework");
             $info['close'] = 0;
             $info['translators'] = "##";
         } else {
             $info = SLFramework_Translation::get_info(file($path . "/core/lang/SL_framework-" . $f . ".po"), file($path . "/core/lang/SL_framework.pot"));
         }
         if ($f == "en_US" || $info['translated'] != 0) {
             $options = get_option('SL_framework_options');
             $nameTranslator = $options['nameTranslator'];
             $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR . "/" . $plugin . "/" . $plugin . ".php");
             $isEmailAuthor = false;
             if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\\.[a-z]{2,4}\$#", $info_file['Framework_Email'])) {
                 $isEmailAuthor = true;
             }
             // We build the table
             $cel_lang = new adminCell("<span class='pt_flag' style='" . $style . "'>&nbsp;</span><b>" . $native . "</b> ({$f})");
             if ($f != "en_US") {
                 $signature_files .= "SL_framework-" . $f . ".mo" . filesize($path . "/core/lang/SL_framework-" . $f . ".mo");
                 $cel_lang->add_action(__('Modify', 'SL_framework'), "modify_trans('" . $plugin_lien . "','" . $domain . "', '" . $plugin_frame . "', '" . $f . "')");
                 if ($isEmailAuthor == "true" && strlen($nameTranslator) > 3 && strpos($info['translators'], $nameTranslator) > 0) {
                     $cel_lang->add_action("<span class='tobehiddenOnSent'>" . __('Send to the author of the framework', 'SL_framework') . "</span>", "send_trans('" . $plugin_lien . "','" . $domain . "', '" . $plugin_frame . "' , \"" . $f . "\")");
                 }
             }
             if ($f != "en_US") {
                 if ($info['close'] == 0) {
                     $cel_pour = new adminCell("<p>" . sprintf(__("%s sentences have been translated (i.e. %s).", 'SL_framework'), "<b>" . $info['translated'] . "/" . $info['total'] . "</b>", "<b>" . floor($info['translated'] / $info['total'] * 1000) / 10 . "%</b>") . "</p>");
                 } else {
                     $cel_pour = new adminCell("<p>" . sprintf(__("%s sentences have been translated (i.e. %s) %s %s sentences have to be checked because they are close (but not identical) to those to translate.%s", 'SL_framework'), "<b>" . $info['translated'] . "/" . $info['total'] . "</b>", "<b>" . floor($info['translated'] / $info['total'] * 1000) / 10 . "%</b>", "<span style='color:#CCCCCC'>", $info['close'], "</span>") . "</p>");
                 }
                 $cel_tran = new adminCell($info['translators']);
             } else {
                 $cel_pour = new adminCell("<p style='color:#CCCCCC'>" . $info['translated'] . "</p>");
                 $cel_tran = new adminCell("");
             }
             $table->add_line(array($cel_lang, $cel_pour, $cel_tran), $f);
             $i++;
         } else {
             // If empty, we delete the files
             unlink($path . "/core/lang/SL_framework-" . $f . ".po");
             unlink($path . "/core/lang/SL_framework-" . $f . ".mo");
         }
     }
     echo $table->flush();
     echo "<br/>";
     echo "<h3>" . __('Add a new translation', 'SL_framework') . "</h3>";
     echo "<p>" . __('You may add a new translation hereafter (Please note that it is recommended to send your translation to the author so that he would be able to add your translation to the future release of the plugin !)', 'SL_framework') . "</p>";
     echo "<SELECT id='new_translation_frame' name='new_translation_frame' size='1'>";
     foreach ($code_locales as $c => $array) {
         $already_translated = false;
         foreach ($file as $f) {
             if ($f == $c) {
                 $already_translated = true;
             }
         }
         if (!$already_translated) {
             echo "<option name='{$c}' value='{$c}' id='{$c}'>" . $array['lang-native'] . "</option>\n";
         }
     }
     echo "</SELECT>";
     echo "<input type='submit' name='add' class='button-primary validButton' onclick='translate_add(\"" . $plugin_lien . "\",\"" . $domain . "\", \"" . $plugin_frame . "\"); return false;' value='" . __('Add', 'SL_framework') . "' />";
     $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
     echo "<img id='wait_translation_add_frame' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
     $content = ob_get_clean();
     $signature_files = sha1($signature_files);
     file_put_contents(WP_CONTENT_DIR . "/sedlex/translations/SL_framework_" . $signature_files . ".html", $content);
     echo $content;
 }