Exemple #1
0
        /** ====================================================================================================================================================
         * This function displays the configuration page of the core 
         * 
         * @access private
         * @return void
         */
        function sedlex_information()
        {
            global $submenu;
            global $blog_id;
            global $SLpluginActivated;
            echo get_option('plugin_error_on_activation');
            update_option('plugin_error_on_activation', "");
            if (is_multisite() && $blog_id == 1 || !is_multisite()) {
                ob_start();
                $params = new SLFramework_Parameters($this->frmk);
                $params->add_title(__('Log options', 'SL_framework'));
                $params->add_param("debug_level", __('What is the debug level:', 'SL_framework'));
                $params->add_comment("<a href='" . str_replace(WP_CONTENT_DIR, content_url(), SLFramework_Debug::get_log_path()) . "' target='_blank'>" . __('See the debug logs', 'SL_framework') . "</a>");
                $params->add_comment(__('1=log only the critical errors;', 'SL_framework'));
                $params->add_comment(__('2=log only the critical errors and the standard errors;', 'SL_framework'));
                $params->add_comment(__('3=log only the critical errors, the standard errors and the warnings;', 'SL_framework'));
                $params->add_comment(__('4=log information;', 'SL_framework'));
                $params->add_comment(__('5=log verbose;', 'SL_framework'));
                if (is_multisite()) {
                    $params->add_title(__('Multisite Management', 'SL_framework'));
                    $params->add_param("global_allow_translation_by_blogs", __('Do you want to allow sub-blogs to modify the translations of the plugins:', 'SL_framework'));
                    $params->add_comment(__("If this option is unchecked, the translation tab won't be displayed in the blog administration panel.", 'SL_framework'));
                }
                $params->add_title(__('Location of the SL plugins', 'SL_framework'));
                $params->add_param("global_location_plugin", __('Where do you want to display the SL plugins:', 'SL_framework'));
                echo $params->flush();
                $paramSave = ob_get_clean();
                echo "<a name='top'></a>";
            }
            //Information about the SL plugins
            ?>
			<div class="wrap">
				<div id="icon-themes" class="icon32"><br/></div>
				<h2><?php 
            echo __('Summary page for the plugins developped with the SL framework', 'SL_framework');
            ?>
</h2>
			</div>
			<div style="padding:20px;">
				<?php 
            echo $this->signature;
            ?>
				<p>&nbsp;</p>
				<?php 
            $plugins = get_plugins();
            $all_nb = 0;
            foreach ($plugins as $url => $data) {
                if (is_plugin_active($url)) {
                    $all_nb++;
                }
            }
            $sl_count = 0;
            foreach ($SLpluginActivated as $ov) {
                $sl_count++;
            }
            ?>
				<p><?php 
            printf(__("For now, you have installed %s plugins including %s plugins developped with the SedLex's framework", 'SL_framework'), $all_nb, $sl_count - 1);
            ?>
<p/>
				<p><?php 
            printf(__("The core plugin is located at %s", 'SL_framework'), "<code>" . str_replace(ABSPATH, "", SL_FRAMEWORK_DIR) . "</code>");
            ?>
<p/>
<?php 
            //======================================================================================
            //= Tab listing all the plugins
            //======================================================================================
            $tabs = new SLFramework_Tabs();
            ob_start();
            $table = new SLFramework_Table();
            $table->title(array(__("Plugin name", 'SL_framework'), __("Description", 'SL_framework')));
            $ligne = 0;
            foreach ($SLpluginActivated as $i => $url) {
                $ligne++;
                $plugin_name = explode("/", $url);
                if (isset($plugin_name[count($plugin_name) - 2])) {
                    $plugin_name = $plugin_name[count($plugin_name) - 2];
                } else {
                    $plugin_name = "?";
                }
                if ($i != 0) {
                    $info = pluginSedlex::get_plugins_data(WP_PLUGIN_DIR . "/" . $url);
                    ob_start();
                    ?>
								<p><b><?php 
                    echo $info['Plugin_Name'];
                    ?>
</b></p>
								<p><a href='admin.php?page=<?php 
                    echo $url;
                    ?>
'><?php 
                    echo __('Settings', 'SL_framework');
                    ?>
</a> | <?php 
                    echo SLFramework_Utils::byteSize(SLFramework_Utils::dirSize(dirname(WP_PLUGIN_DIR . '/' . $url)));
                    ?>
</p>
							<?php 
                    $cel1 = new adminCell(ob_get_clean());
                    ob_start();
                    $database = "";
                    if ($info['Database'] != "") {
                        $database = "<img src='" . plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/database.png" . "' alt='" . __('There is a SQL database for this plugin', 'SL_framework') . "'/>";
                    }
                    ?>
								<p><?php 
                    echo str_replace("<ul>", "<ul style='list-style-type:circle; padding-left:1cm;'>", $info['Description']);
                    ?>
</p>
								<p><?php 
                    echo sprintf(__('Version: %s by %s', 'SL_framework'), $info['Version'], $info['Author']);
                    ?>
 (<a href='<?php 
                    echo $info['Author_URI'];
                    ?>
'><?php 
                    echo $info['Author_URI'];
                    ?>
</a>)<?php 
                    echo $database;
                    ?>
</p>
								<?php 
                    $cel2 = new adminCell(ob_get_clean());
                    $table->add_line(array($cel1, $cel2), '1');
                }
            }
            echo $table->flush();
            $tabs->add_tab(__('List of SL plugins', 'SL_framework'), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_list.png");
            if (is_multisite() && $blog_id == 1 || !is_multisite()) {
                //======================================================================================
                //= Tab for parameters
                //======================================================================================
                $tabs->add_tab(__('Parameters of the framework', 'SL_framework'), $paramSave, plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
            }
            if (is_multisite() && $blog_id == 1 || !is_multisite() || $this->frmk->get_param('global_allow_translation_by_blogs')) {
                //======================================================================================
                //= Tab for the translation
                //======================================================================================
                ob_start();
                $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
                $trans = new SLFramework_Translation("SL_framework", $plugin);
                $trans->enable_translation();
                $tabs->add_tab(__('Manage translation of the framework', 'SL_framework'), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png");
            }
            echo $tabs->flush();
            echo $this->signature;
            ?>
			</div>
			<?php 
        }
 /** ====================================================================================================================================================
  * Display the list of plugins
  * 
  * @return void 
  */
 public function list_plugins()
 {
     // On cherche
     if (!is_file(dirname(__FILE__) . "/data/SLFramework_OtherPlugins_" . date('Ym') . ".data")) {
         // On efface les autres SLFramework_OtherPlugins s'ils existent
         $path = dirname(__FILE__) . "/data/";
         $files = @scandir($path);
         if ($files !== FALSE) {
             foreach ($files as $f) {
                 if (preg_match("/^SLFramework_OtherPlugins/i", $f)) {
                     @unlink($path . $f);
                 }
             }
         }
         $this->get_list_plugins();
     }
     $plugins = unserialize(@file_get_contents(dirname(__FILE__) . "/data/SLFramework_OtherPlugins_" . date('Ym') . ".data"));
     $plugins_active = get_plugins();
     echo "<h3>" . __("Plugins that you may install", 'SL_framework') . "</h3>";
     echo "<p>" . __("The following plugins have been developed by the author and are not yet been installed:", "SL_framework") . "</p>";
     $table = new SLFramework_Table();
     $table->title(array(__("Plugin not yet installed", "SL_framework"), __("Description and Screenshots", "SL_framework")));
     $nb = 0;
     foreach ($plugins as $slug => $plug) {
         $found = false;
         // We check if the plugin is installed
         foreach ($plugins_active as $slug_active => $plug_activ) {
             list($slug_active, $tmp) = explode("/", $slug_active, 2);
             if ($slug == $slug_active) {
                 $found = true;
             }
         }
         if (!$found) {
             if (is_ssl()) {
                 $plug[1] = str_replace("http://", "https://", $plug[1]);
             }
             $cel1 = new adminCell($plug[0]);
             $cel2 = new adminCell($plug[1]);
             $table->add_line(array($cel1, $cel2), '1');
             $nb++;
         }
     }
     if ($nb == 0) {
         $cel1 = new adminCell("<p>" . __("All author's plugins have been installed. Thank you!", "SL_framework") . "</p>");
         $cel2 = new adminCell("");
         $table->add_line(array($cel1, $cel2), '1');
     }
     echo $table->flush();
     echo "<h3>" . __("Installed plugins", 'SL_framework') . "</h3>";
     echo "<p>" . __("You have already installed the following author's plugins:", "SL_framework") . "</p>";
     $table = new SLFramework_Table();
     $table->title(array(__("Plugin already installed", "SL_framework"), __("Description and Screenshots", "SL_framework")));
     $nb = 0;
     foreach ($plugins as $slug => $plug) {
         $found = false;
         // We check if the plugin is installed
         foreach ($plugins_active as $slug_active => $plug_activ) {
             list($slug_active, $tmp) = explode("/", $slug_active, 2);
             if ($slug == $slug_active) {
                 $found = true;
             }
         }
         if ($found) {
             $cel1 = new adminCell($plug[0]);
             $cel2 = new adminCell($plug[1]);
             $table->add_line(array($cel1, $cel2), '1');
             $nb++;
         }
     }
     echo $table->flush();
 }
        /** ====================================================================================================================================================
         * Print the form with parameters
         * 	
         * @return void
         */
        function flush()
        {
            global $_POST;
            global $_FILES;
            global $wpdb;
            $this->buffer[] = array('end', "");
            // We create the beginning of the form
            $this->output = "<h3>" . __("Parameters", 'SL_framework') . "</h3>";
            if ($this->obj->getPluginID() != "") {
                $this->output .= "<p>" . __("Here are the parameters of the plugin. Modify them at will to fit your needs.", "SL_framework") . "</p>";
            } else {
                $this->output .= "<p>" . __("Here are the parameters of the framework. Modify them at will to fit your needs.", "SL_framework") . "</p>";
            }
            $this->output .= "<div class='wrap parameters'><form enctype='multipart/form-data' method='post' action='" . $_SERVER["REQUEST_URI"] . "'>\n";
            // We compute the parameter output
            $hastobeclosed = false;
            $maj = false;
            $modified = false;
            $error = false;
            $warning = false;
            $toExecuteWhenLoaded = "";
            $macroisdisplayed_count = 0;
            $macroisdisplayed = false;
            $macroisdisplayed_avoidnext = false;
            for ($iii = 0; $iii < count($this->buffer); $iii++) {
                $ligne = $this->buffer[$iii];
                // Is it a title
                if ($ligne[0] == "end" || $ligne[0] == "title" || $ligne[0] == "title_macro") {
                    if ($hastobeclosed) {
                        $this->output .= $currentTable->flush() . "<br/>";
                        $hastobeclosed = false;
                    }
                    // On test si on doit recommencer
                    if ($macroisdisplayed && !$macroisdisplayed_avoidnext) {
                        $nnn = 1;
                        // We search for the next parameter
                        $found_param = false;
                        while (isset($this->buffer[$macro_lasttitle + $nnn])) {
                            $first_param_after = $this->buffer[$macro_lasttitle + $nnn];
                            if ($first_param_after[0] == 'param') {
                                $found_param = true;
                                $first_param_after = $first_param_after[1];
                                break;
                            } else {
                                if ($first_param_after[0] == 'comment') {
                                    $nnn++;
                                } else {
                                    break;
                                }
                            }
                        }
                        // if the param has been found
                        if ($found_param) {
                            $all_names = $this->obj->get_name_params();
                            if (in_array($first_param_after . "_macro" . ($macroisdisplayed_count + 1), $all_names)) {
                                $iii = $macro_lasttitle - 1;
                                $macroisdisplayed_count++;
                                $macroisdisplayed_avoidnext = true;
                                continue;
                            } else {
                                $macroisdisplayed_count = 0;
                                $macroisdisplayed = false;
                                $macroisdisplayed_avoidnext = false;
                            }
                        }
                    }
                    $macroisdisplayed_avoidnext = false;
                    // We create a new table
                    $currentTable = new SLFramework_Table();
                    $currentTable->removeFooter();
                    $hastobeclosed = true;
                    if ($ligne[0] == "title") {
                        $currentTable->title(array($ligne[1], ""));
                        $macroisdisplayed = false;
                        $macroisdisplayed_text = "";
                    } else {
                        if ($ligne[0] == "title_macro") {
                            // Add delete button
                            $params = "[";
                            $count_param_temp = 0;
                            $nnn = 1;
                            while (isset($this->buffer[$iii + $nnn])) {
                                $first_param_after = $this->buffer[$iii + $nnn];
                                if ($first_param_after[0] == 'param') {
                                    if ($count_param_temp != 0) {
                                        $params .= ",";
                                    }
                                    $params .= "\"" . $first_param_after[1] . "_macro" . $macroisdisplayed_count . "\"";
                                    $nnn++;
                                    $count_param_temp++;
                                } else {
                                    if ($first_param_after[0] == 'comment') {
                                        $nnn++;
                                    } else {
                                        break;
                                    }
                                }
                            }
                            $params .= "]";
                            $md5 = sha1($params);
                            $delete = " <a href='#' onclick='del_param(" . $params . ", \"" . $md5 . "\", \"" . $this->obj->pluginID . "\");return false ; ' style='font-size:80%'>" . __('(Delete)', 'SL_framework') . "</a>";
                            $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
                            $delete .= "<img id='wait_" . $md5 . "' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
                            // Add add button
                            $add = "";
                            $macroisdisplayed_text = $ligne[2];
                            if ($macroisdisplayed_count == 0) {
                                $params = "[";
                                $count_param_temp = 0;
                                $nnn = 1;
                                while (isset($this->buffer[$iii + $nnn])) {
                                    $first_param_after = $this->buffer[$iii + $nnn];
                                    if ($first_param_after[0] == 'param') {
                                        if ($count_param_temp != 0) {
                                            $params .= ",";
                                        }
                                        $params .= "\"" . $first_param_after[1] . "_macro\"";
                                        $nnn++;
                                        $count_param_temp++;
                                    } else {
                                        if ($first_param_after[0] == 'comment') {
                                            $nnn++;
                                        } else {
                                            break;
                                        }
                                    }
                                }
                                $params .= "]";
                                $md5 = sha1($params);
                                $add = " <a href='#' onclick='add_param(" . $params . ", \"" . $md5 . "\", \"" . $this->obj->pluginID . "\");return false ; ' style='font-size:80%'>(" . $macroisdisplayed_text . ")</a>";
                                $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
                                $add .= "<img id='wait_" . $md5 . "' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
                            }
                            if (strpos($ligne[1], "%s") !== false) {
                                $currentTable->title(array(sprintf($ligne[1], $macroisdisplayed_count + 1) . $delete . $add, ""));
                            } else {
                                $currentTable->title(array($ligne[1] . $delete, ""));
                            }
                            $macro_lasttitle = $iii;
                            $macroisdisplayed_count_elements = 0;
                            $macroisdisplayed = true;
                        }
                    }
                }
                // compte le nombre d element dans la macro
                if ($macroisdisplayed) {
                    $macroisdisplayed_count_elements++;
                } else {
                    $macroisdisplayed_count_elements = 0;
                }
                // Is it a comment
                if ($ligne[0] == "comment") {
                    if (!$hastobeclosed) {
                        // We create a default table as no title has been provided
                        $currentTable = new SLFramework_Table();
                        $currentTable->removeFooter();
                        $currentTable->title(array(__("Parameters", "SL_framework"), __("Values", "SL_framework")));
                        $hastobeclosed = true;
                    }
                    $cl = "<p class='paramComment' style='color: #a4a4a4;'>" . $ligne[1] . "</p>";
                    // We check if there is a comment just after it
                    while (isset($this->buffer[$iii + 1])) {
                        if ($this->buffer[$iii + 1][0] != "comment") {
                            break;
                        }
                        $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                        $iii++;
                    }
                    $cel_label = new adminCell($cl);
                    $cel_value = new adminCell("");
                    $currentTable->add_line(array($cel_label, $cel_value), '1');
                }
                // Is it a param
                if ($ligne[0] == "param") {
                    $param = $ligne[1];
                    $param_default = $ligne[1];
                    //macro
                    if ($macroisdisplayed) {
                        $param = $param . "_macro" . $macroisdisplayed_count;
                    }
                    $name = $ligne[2];
                    $forbid = $ligne[3];
                    $allow = $ligne[4];
                    $related = $ligne[5];
                    if (!$hastobeclosed) {
                        // We create a default table as no title has been provided
                        $currentTable = new SLFramework_Table();
                        $currentTable->removeFooter();
                        $currentTable->title(array(__("Parameters", "SL_framework"), __("Values", "SL_framework")));
                        $hastobeclosed = true;
                    }
                    // What is the type of the parameter ?
                    //---------------------------------------
                    $type = "string";
                    if (is_bool($this->obj->get_default_option($param_default))) {
                        $type = "boolean";
                    }
                    if (is_int($this->obj->get_default_option($param_default))) {
                        $type = "int";
                    }
                    if (is_array($this->obj->get_default_option($param_default))) {
                        $type = "list";
                    }
                    // C'est un text si dans le texte par defaut, il y a une etoile
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (strpos($this->obj->get_default_option($param_default), "*") === 0) {
                            $type = "text";
                        }
                    }
                    // C'est un file si dans le texte par defaut est egal a [file]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[file]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "file";
                        }
                    }
                    // C'est un password si dans le texte par defaut est egal a [password]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[password]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "password";
                        }
                    }
                    // C'est un media si dans le texte par defaut est egal a [media]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[media]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "media";
                        }
                    }
                    // C'est un page si dans le texte par defaut est egal a [page]
                    if (is_string($this->obj->get_default_option($param_default))) {
                        if (str_replace("[page]", "", $this->obj->get_default_option($param_default)) != $this->obj->get_default_option($param_default)) {
                            $type = "page";
                        }
                    }
                    // We reset the param
                    //---------------------------------------
                    $problem_e = "";
                    $problem_w = "";
                    if (isset($_POST['resetOptions'])) {
                        $maj = true;
                        $new_param = $this->get_new_value($param_default);
                        $modified = true;
                        $this->obj->set_param($param, $new_param);
                    }
                    // We update the param
                    //---------------------------------------
                    $problem_e = "";
                    $problem_w = "";
                    if (isset($_POST['submitOptions'])) {
                        $maj = true;
                        $new_param = $this->get_new_value($param);
                        $old_param = $this->obj->get_param($param);
                        if (is_array($new_param) && isset($new_param[0]) && $new_param[0] == 'error') {
                            $problem_e .= $new_param[1];
                            $error = true;
                        } else {
                            // Warning management
                            if ($type == "string" || $type == "text" || $type == "password") {
                                if (isset($_POST[$param])) {
                                    if ($new_param != stripslashes($_POST[$param])) {
                                        $problem_w .= "<p>" . __('Warning: some characters have been removed because they are not allowed here', 'SL_framework') . " (" . $forbid . ")!</p>\n";
                                        $warning = true;
                                    }
                                }
                            }
                            // Update of the value
                            if ($new_param != $old_param) {
                                $modified = true;
                                $this->obj->set_param($param, $new_param);
                                SLFramework_Debug::log(get_class(), "The parameter " . $param . " of the plugin " . $this->obj->getPluginID() . " have been modified", 4);
                            }
                        }
                    }
                    // We built a new line for the table
                    //---------------------------------------
                    if ($type == "boolean") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>";
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $checked = "";
                        if ($this->obj->get_param($param)) {
                            $checked = "checked";
                        }
                        if (count($related) > 0) {
                            $onClick = "onClick='activateDeactivate_Params(\"" . $param . "\",new Array(\"" . implode("\",\"", $related) . "\"))'";
                            $toExecuteWhenLoaded .= "activateDeactivate_Params(\"" . $param . "\",new Array(\"" . implode("\",\"", $related) . "\"));\n";
                        } else {
                            $onClick = "";
                        }
                        $workaround = "<input type='hidden' value='0' name='" . $param . "_workaround' id='" . $param . "_workaround'>";
                        $cel_value = new adminCell("<p class='paramLine'>" . $workaround . "<input " . $onClick . " name='" . $param . "' id='" . $param . "' type='checkbox' " . $checked . " ></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "int") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='text' value='" . $this->obj->get_param($param) . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'> " . __('(integer)', 'SL_framework') . "</p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "string") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='text' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "password") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><input name='" . $param . "' id='" . $param . "' type='password' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' size='" . min(30, max(6, strlen($this->obj->get_param($param) . '') + 1)) . "'></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "text") {
                        $num = min(22, count(explode("\n", $this->obj->get_param($param))) + 1);
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cel_value = new adminCell("<p class='paramLine'><div style='width:100%'><textarea style='width:100%' name='" . $param . "' id='" . $param . "' rows='" . $num . "'>" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "</textarea></div></p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "list") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>";
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cc = "";
                        ob_start();
                        ?>
							<p class='paramLine'>
							<select name='<?php 
                        echo $param;
                        ?>
' id='<?php 
                        echo $param;
                        ?>
'>
							<?php 
                        $array = $this->obj->get_param($param);
                        echo "//";
                        print_r($array);
                        foreach ($array as $a) {
                            if (!is_array($a)) {
                                $selected = "";
                                if (is_string($a) && substr($a, 0, 1) == "*") {
                                    $selected = "selected";
                                    $a = substr($a, 1);
                                }
                                ?>
										<option value="<?php 
                                echo SLFramework_Utils::create_identifier($a);
                                ?>
" <?php 
                                echo $selected;
                                ?>
><?php 
                                echo $a;
                                ?>
</option>
									<?php 
                            } else {
                                $selected = "";
                                if (is_string($a[0]) && substr($a[0], 0, 1) == "*") {
                                    $selected = "selected";
                                    $a[0] = substr($a[0], 1);
                                }
                                ?>
										<option value="<?php 
                                echo $a[1];
                                ?>
" <?php 
                                echo $selected;
                                ?>
><?php 
                                echo $a[0];
                                ?>
</option>
									<?php 
                            }
                        }
                        ?>
							</select>
							</p>
						<?php 
                        $cc = ob_get_clean();
                        $cel_value = new adminCell($cc);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "media") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        // If this is the URL of an auto-generated thumbnail, get the URL of the original image
                        $attachment_url = preg_replace('/-\\d+x\\d+(?=\\.(jpg|jpeg|png|gif)$)/i', '', $this->obj->get_param($param));
                        $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid='%s';", $attachment_url));
                        if (isset($attachment[0])) {
                            $id_media = $attachment[0];
                            $msg_media = "<p class='paramComment' style='color: #a4a4a4;'>" . sprintf(__("The URL is correct and the ID of the media file is %s.", 'SL_framework'), '<code>' . $id_media . "</code>") . "</p>";
                            if (wp_attachment_is_image($id_media)) {
                                $msg_media .= '<p class="paramComment" style="color: #a4a4a4; text-align:center;"><a href="' . get_attachment_link($id_media) . '">' . wp_get_attachment_image($id_media, "thumbnail") . '</a></p>';
                            } else {
                                $msg_media .= '<p class="paramComment" style="color: #a4a4a4; text-align:center;>coucou</p>';
                            }
                        } else {
                            $msg_media = "<p class='paramComment' style='color: #a4a4a4;'>" . __("The URL is not a media file.", 'SL_framework') . "</p>";
                        }
                        $cel_value = new adminCell("<p class='paramLine'><div style='width:100%'><input id='" . $param . "' type='text' size='20' name='" . $param . "' value='" . htmlentities($this->obj->get_param($param), ENT_QUOTES, "UTF-8") . "' /><input id='media_" . $param . "' class='button' type='button' value='" . __('Choose a media', 'SL_framework') . "' onclick=\"paramMediaReturn = '" . $param . "'; formfield = jQuery('#" . $param . "').attr('name'); tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true'); return false;\"/></div></p>" . $msg_media);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "page") {
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $selected = 0;
                        if ($this->obj->get_param($param) != "[page]") {
                            $selected = $this->obj->get_param($param);
                        }
                        $cel_value = new adminCell("<p class='paramLine'>" . wp_dropdown_pages(array('echo' => 0, 'name' => $param, 'selected' => $selected, "show_option_none" => __('(none)', "SLFramework"), "option_none_value" => '[page]')) . "</p>");
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                    if ($type == "file") {
                        $ew = "";
                        if ($problem_e != "") {
                            $ew .= "<div class='errorSedLex'>" . $problem_e . "</div>";
                        }
                        if ($problem_w != "") {
                            $ew .= "<div class='warningSedLex'>" . $problem_w . "</div>";
                        }
                        $cl = "<p class='paramLine'><label for='" . $param . "'>" . $name . "</label></p>" . $ew;
                        // We check if there is a comment just after it
                        while (isset($this->buffer[$iii + 1])) {
                            if ($this->buffer[$iii + 1][0] != "comment") {
                                break;
                            }
                            $cl .= "<p class='paramComment' style='color: #a4a4a4;'>" . $this->buffer[$iii + 1][1] . "</p>";
                            $iii++;
                        }
                        $cel_label = new adminCell($cl);
                        $cc = "";
                        ob_start();
                        $upload_dir = wp_upload_dir();
                        if (!file_exists($upload_dir["basedir"] . $this->obj->get_param($param))) {
                            $this->obj->set_param($param, $this->obj->get_default_option($param_default));
                        }
                        if ($this->obj->get_default_option($param_default) == $this->obj->get_param($param)) {
                            ?>
								<p class='paramLine'><input type='file' name='<?php 
                            echo $param;
                            ?>
' id='<?php 
                            echo $param;
                            ?>
'/></p>
								<?php 
                        } else {
                            $path = $upload_dir["baseurl"] . $this->obj->get_param($param);
                            $pathdir = $upload_dir["basedir"] . $this->obj->get_param($param);
                            $info = pathinfo($pathdir);
                            if (strtolower($info['extension']) == "png" || strtolower($info['extension']) == "gif" || strtolower($info['extension']) == "jpg" || strtolower($info['extension']) == "bmp") {
                                list($width, $height) = getimagesize($pathdir);
                                $max_width = 100;
                                $max_height = 100;
                                $ratioh = $max_height / $height;
                                $ratiow = $max_width / $width;
                                $ratio = min($ratioh, $ratiow);
                                // New dimensions
                                $width = min(intval($ratio * $width), $width);
                                $height = min(intval($ratio * $height), $height);
                                ?>
									<p class='paramLine'><img src='<?php 
                                echo $path;
                                ?>
' width="<?php 
                                echo $width;
                                ?>
px" height="<?php 
                                echo $height;
                                ?>
px" style="vertical-align:middle;"/> <a href="<?php 
                                echo $path;
                                ?>
"><?php 
                                echo $this->obj->get_param($param);
                                ?>
</a></p>
									<?php 
                            } else {
                                ?>
									<p class='paramLine'><img src='<?php 
                                echo plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "img/file.png";
                                ?>
' width="75px" style="vertical-align:middle;"/> <a href="<?php 
                                echo $path;
                                ?>
"><?php 
                                echo $this->obj->get_param($param);
                                ?>
</a></p>
									<?php 
                            }
                            ?>
								<p class='paramLine'><?php 
                            echo sprintf(__("(If you want to delete this file, please check this box %s)", "SL_framework"), "<input type='checkbox'  name='delete_" . $param . "' value='1' id='delete_" . $param . "'>");
                            ?>
</p>
								<?php 
                        }
                        $cc = ob_get_clean();
                        $cel_value = new adminCell($cc);
                        $currentTable->add_line(array($cel_label, $cel_value), '1');
                    }
                }
                // End is it a param?
            }
            // We finish the form output
            ob_start();
            ?>
					<div class="submit">
						<input type="submit" name="submitOptions" class='button-primary validButton' value="<?php 
            echo __('Update', 'SL_framework');
            ?>
" />&nbsp;
						<input type="submit" name="resetOptions" class='button validButton' value="<?php 
            echo __('Reset to default values', 'SL_framework');
            ?>
" />
					</div>
				</form>
			</div>
			<script>
				if (window.attachEvent) {window.attachEvent('onload', toExecuteWhenLoadedParameter);}
				else if (window.addEventListener) {window.addEventListener('load', toExecuteWhenLoadedParameter, false);}
				else {document.addEventListener('load', toExecuteWhenLoadedParameter, false);} 
				
				function toExecuteWhenLoadedParameter() {
					<?php 
            echo $toExecuteWhenLoaded;
            ?>
				}
			</script>
			<?php 
            // If the parameter have been modified, we say it !
            if ($error && $maj) {
                ?>
				<div class="error fade">
					<p><?php 
                echo __('Some parameters have not been updated due to errors (see below)!', 'SL_framework');
                ?>
</p>
				</div>
				<?php 
            } else {
                if ($warning && $maj) {
                    ?>
				<div class="updated  fade">
					<p><?php 
                    echo __('Parameters have been updated (but with some warnings)!', 'SL_framework');
                    ?>
</p>
				</div>
				<?php 
                } else {
                    if ($modified && $maj) {
                        if (!isset($_POST['resetOptions'])) {
                            ?>
				<div class="updated  fade">
					<p><?php 
                            echo __('Parameters have been updated successfully!', 'SL_framework');
                            ?>
</p>
				</div>
				<?php 
                        } else {
                            ?>
				<div class="updated  fade">
					<p><?php 
                            echo __('Parameters have been reset to their default values!', 'SL_framework');
                            ?>
</p>
				</div>
				<?php 
                        }
                    }
                }
            }
            $this->output .= ob_get_clean();
            echo $this->output;
        }
 /** ====================================================================================================================================================
  * Create a table which summarize all the backup files
  *
  * @return void
  */
 function displayBackup()
 {
     global $blog_id;
     // We create the folder for the backup files
     $blog_fold = "";
     if (is_multisite()) {
         $blog_fold = $blog_id . "/";
     }
     $table = new SLFramework_Table();
     $table->title(array(__('Date of the backup', $this->pluginID), __('Backup files', $this->pluginID)));
     if (!is_dir(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold)) {
         @mkdir(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold, 0777, true);
     }
     $state = $this->get_param('process_state');
     // List zip files
     $files = @scandir(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold);
     $nb = 0;
     foreach ($files as $f) {
         if (preg_match("/^BackupScheduler.*zip\$/i", $f)) {
             if (!isset($state['rand']) || $f != "BackupScheduler" . $this->get_param('add_name') . "_" . $state['rand'] . ".zip") {
                 $date = explode("_", $f);
                 $date = $date[count($date) - 2];
                 $date = date_i18n(get_option('date_format'), mktime(0, 0, 0, intval(substr($date, 4, 2)), intval(substr($date, 6, 2)), intval(substr($date, 0, 4))));
                 $heure = date("H:i:s.", @filemtime(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f));
                 $lien = "<p>";
                 $i = 1;
                 $size = 0;
                 $racine = str_replace(".zip", ".z" . sprintf("%02d", $i), $f);
                 while (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine)) {
                     SLFramework_Debug::log(get_class(), "The sub-backup " . $racine . " has been found", 5);
                     $ftp_transfer_info = "";
                     if (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine . ".ftp.ok")) {
                         $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#006600'>" . __("FTP transfer OK", $this->pluginID) . "</span>)</span>";
                     } elseif (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine . ".ftp.ko")) {
                         $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#A31919'>" . sprintf(__("FTP transfer KO: %s", $this->pluginID), strip_tags(file_get_contents(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine . ".ftp.ko"))) . "</span>)</span>";
                     } elseif (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine . ".ftp.progress")) {
                         $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#B84A00'>" . __("FTP transfer reset", $this->pluginID) . "</span>)</span>";
                     }
                     $lien .= "<a href='" . WP_CONTENT_URL . "/sedlex/backup-scheduler/" . $blog_fold . $racine . "'>" . sprintf(__('Part %s', $this->pluginID), sprintf("%02d", $i)) . "</a> (" . SLFramework_Utils::byteSize(filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine)) . ") {$ftp_transfer_info} | ";
                     $size += filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $racine);
                     //MAJ
                     $i++;
                     $racine = str_replace(".zip", ".z" . sprintf("%02d", $i), $f);
                 }
                 $ftp_transfer_info = "";
                 if (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f . ".ftp.ok")) {
                     $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#006600'>" . __("FTP transfer OK", $this->pluginID) . "</span>)</span>";
                 } elseif (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f . ".ftp.ko")) {
                     $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#A31919'>" . sprintf(__("FTP transfer KO: %s", $this->pluginID), strip_tags(file_get_contents(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f . ".ftp.ko"))) . "</span>)</span>";
                 } elseif (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f . ".ftp.progress")) {
                     $ftp_transfer_info = "<span style='font-size:75%'>(<span style='color:#B84A00'>" . __("FTP transfer reset", $this->pluginID) . "</span>)</span>";
                 }
                 $size += filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f);
                 $lien .= "<a href='" . WP_CONTENT_URL . "/sedlex/backup-scheduler/" . $blog_fold . $f . "'>" . sprintf(__('Part %s', $this->pluginID), sprintf("%02d", $i)) . "</a> (" . SLFramework_Utils::byteSize(filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . $f)) . ") {$ftp_transfer_info}";
                 $lien .= "<p>";
                 // We compute in how many days the backup will be deleted
                 $name_file = explode("_", $f);
                 $new_date = date_i18n("Ymd");
                 $date2 = substr($name_file[count($name_file) - 2], 0, 8);
                 $s = strtotime($new_date) - strtotime($date2);
                 $delta = $this->get_param("delete_after") - intval($s / 86400);
                 $valeur = "<p>" . sprintf(__('Backup finished on %s at %s', $this->pluginID), $date, $heure) . "</p>";
                 $valeur .= "<p style='font-size:80%'>" . sprintf(__('The total size of the files is %s', $this->pluginID), SLFramework_Utils::byteSize($size)) . "</p>";
                 $valeur .= "<p style='font-size:80%'>" . sprintf(__('These files will be deleted in %s days', $this->pluginID), $delta) . "</p>";
                 $cel1 = new adminCell($valeur);
                 $racinefichier = explode(".", $f);
                 $cel1->add_action(__("Delete these backup files", $this->pluginID), "deleteBackup('" . $racinefichier[0] . "')");
                 $cel2 = new adminCell($lien);
                 $table->add_line(array($cel1, $cel2), '1');
                 $nb++;
             }
         }
     }
     if (!is_array($state)) {
         $state = array();
         $this->set_param('process_state', $state);
     }
     if (isset($state['step'])) {
         $sec_rand = $state['rand'];
         $date_tmp = explode("_", $sec_rand);
         $date_tmp = $date_tmp[0];
         $date = date_i18n(get_option('date_format'), mktime(0, 0, 0, substr($date_tmp, 4, 2), substr($date_tmp, 6, 2), substr($date_tmp, 0, 4)));
         $heure = date_i18n("H:i:s.", mktime(substr($date_tmp, 8, 2), substr($date_tmp, 10, 2), substr($date_tmp, 12, 2), substr($date_tmp, 4, 2), substr($date_tmp, 6, 2), substr($date_tmp, 0, 4)));
         $valeur = "<p>" . sprintf(__('The process is still in progress for this backup (begun %s at %s).', $this->pluginID), $date, $heure) . "</p>";
         // STEP SQL
         if ($state['step'] == "SQL") {
             $progress = SL_Database::progress(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand);
             $valeur .= "<p style='font-size:80%'>" . sprintf(__('The SQL extraction is in progress (%s entries extracted).', $this->pluginID), $progress) . "</p>";
         }
         // STEP ZIP
         if ($state['step'] == "ZIP") {
             // We create the zip file
             $progress = SL_Zip::progress(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand . ".zip");
             $num_file = 1;
             $str_num_file = "01";
             $size = 0;
             while (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand . ".z" . $str_num_file)) {
                 $size += @filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand . ".z" . $str_num_file);
                 $num_file++;
                 $str_num_file = "" . $num_file;
                 if (strlen($str_num_file) == 1) {
                     $str_num_file = "0" . $str_num_file;
                 }
             }
             if (is_file(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand . ".zip.tmp")) {
                 $size += @filesize(WP_CONTENT_DIR . "/sedlex/backup-scheduler/" . $blog_fold . "BackupScheduler" . $this->get_param('add_name') . "_" . $sec_rand . ".zip.tmp");
             }
             $num_file--;
             $valeur .= "<p style='font-size:80%'>" . sprintf(__('The ZIP creation is in progress (%s files has been added in %s zip files and the current size of the zip files is %s).', $this->pluginID), $progress, $num_file, SLFramework_Utils::byteSize($size)) . "</p>";
         }
         // STEP FTP
         if ($state['step'] == "FTP") {
             $files_to_sent = $this->get_param('ftp_to_be_sent');
             $files_sent = $this->get_param('ftp_sent');
             $progress = count($files_sent) . "/" . (count($files_to_sent) + count($files_sent));
             $valeur .= "<p style='font-size:80%'>" . sprintf(__('The FTP sending is in progress (%s files has been stored in the FTP).', $this->pluginID), $progress) . "</p>";
         }
         // STEP MAIL
         if ($state['step'] == "MAIL") {
             $files_to_sent = $this->get_param('mail_to_be_sent');
             $files_sent = $this->get_param('mail_sent');
             $progress = count($files_sent) . "/" . (count($files_to_sent) + count($files_sent));
             $valeur .= "<p style='font-size:80%'>" . sprintf(__('The MAIL sending is in progress (%s files has been sent).', $this->pluginID), $progress) . "</p>";
         }
         $cel1 = new adminCell($valeur);
         $cel1->add_action(__("Cancel this process", $this->pluginID), "cancelBackup()");
         $valeur = "<p>" . __('Please wait...', $this->pluginID) . "</p>";
         $cel2 = new adminCell($valeur);
         $table->add_line(array($cel1, $cel2), '1');
         $nb++;
     }
     if ($nb == 0) {
         $cel1 = new adminCell("<p>" . __('(For now, there is no backup files... You should wait or force a backup (see below) )', $this->pluginID) . "</p>");
         $cel2 = new adminCell("");
         $table->add_line(array($cel1, $cel2), '1');
         $nb++;
     }
     echo $table->flush();
 }
        /** ====================================================================================================================================================
         * Display the feedback form
         * Please note that the users will send you their comments/feedback at the email used is in the header of the main file of your plugin <code>Author Email : name@domain.tld</code>
         * 
         * @return void
         */
        public function enable_feedback()
        {
            $_POST['plugin'] = $this->plugin;
            $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR . "/" . $this->plugin . "/" . $this->plugin . ".php");
            if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\\.[a-z]{2,4}\$#", $info_file['Email'])) {
                ?>
<h3><?php 
                echo __("Donate", "SL_framework");
                ?>
</h3>
				<p><?php 
                echo __('If you like the plugin, do not hesitate to donate. Please note that this plugin is developed in my spare time for free.', 'SL_framework');
                ?>
</p>
				<p><?php 
                echo __('This is not mandatory! but it may be a sign that this plugin fits you needs: it makes me happy...', 'SL_framework');
                ?>
</p>
				<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
					<input type="hidden" name="cmd" value="_donations">
					<input type="hidden" name="business" value="<?php 
                echo $info_file['Email'];
                ?>
">
					<input type="hidden" name="item_name" value="Wordpress plugin (<?php 
                echo $this->plugin;
                ?>
)">
					<input type="hidden" name="currency_code" value="EUR">
					<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
					<input type="image" src="https://www.paypalobjects.com/en_US/i/bnr/vertical_solution_PP.gif" border="0" name="submit" alt="PayPal">
					<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
				</form>
			<?php 
            }
            echo "<h3>" . __("Feedback form", 'SL_framework') . "</h3>";
            echo "<p>" . __('This form is an easy way to contact the author and to discuss issues/incompatibilities/etc. with him', "SL_framework") . "</p>";
            echo "<a name='top_feedback'></a><div id='form_feedback_info'></div><div id='form_feedback'>";
            if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\\.[a-z]{2,4}\$#", $info_file['Email'])) {
                $table = new SLFramework_Table();
                $table->title(array(__("Contact the author", "SL_framework"), ""));
                // Name
                $cel1 = new adminCell("<p>" . __('Your name:', 'SL_framework') . "*</p>");
                $cel2 = new adminCell("<p><input onChange='modifyFormContact()' id='feedback_name' type='text' name='feedback_name' value='' /></p>");
                $table->add_line(array($cel1, $cel2), '1');
                // Email
                $cel1 = new adminCell("<p>" . __('Your email:', 'SL_framework') . "*</p><p class='paramComment' style='color: rgb(164, 164, 164);'>" . __('Useful... so that the author will be able to anwser you.', 'SL_framework') . "</p>");
                $cel2 = new adminCell("<p><input onChange='modifyFormContact()' id='feedback_mail' type='text' name='feedback_mail' value='' /></p>");
                $table->add_line(array($cel1, $cel2), '1');
                // Comment
                $cel1 = new adminCell("<p>" . __('Your comments:', 'SL_framework') . "*</p><p class='paramComment' style='color: rgb(164, 164, 164);'>" . __('Please note that additional information on your wordpress installation will be sent to the author in order to help the debugging if needed (such as : the wordpress version, the installed plugins, etc.)', 'SL_framework') . "</p>");
                $cel2 = new adminCell("<p><textarea id='feedback_comment' style='width:500px;height:200px;'></textarea></p>");
                $table->add_line(array($cel1, $cel2), '1');
                echo $table->flush();
                echo "<p id='feedback_submit'><input id='feedback_submit_button' disabled type='submit' name='add' class='button-primary validButton' onclick='send_feedback(\"" . $this->plugin . "\", \"" . $this->pluginID . "\");return false;' value='" . __('Send feedback', 'SL_framework') . "' /></p>";
                $x = plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
                echo "<img id='wait_feedback' src='" . $x . "/img/ajax-loader.gif' style='display:none;'>";
            } else {
                echo "<p>" . __('No email have been provided for the author of this plugin. Therefore, the feedback is impossible', 'SL_framework') . "</p>";
            }
            echo "</div>";
        }
 /** ====================================================================================================================================================
  * 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;
 }
Exemple #7
0
    /** ====================================================================================================================================================
     * The admin configuration page
     * This function will be called when you select the plugin in the admin backend 
     *
     * @return void
     */
    public function configuration_page()
    {
        global $wpdb;
        global $blog_id;
        SLFramework_Debug::log(get_class(), "Print the configuration page.", 4);
        ?>
		<div class="plugin-titleSL">
			<h2><?php 
        echo $this->pluginName;
        ?>
</h2>
		</div>
		<div class="plugin-contentSL">			
			<?php 
        //===============================================================================================
        // After this comment, you may modify whatever you want
        ?>
			<p><?php 
        echo __("This is the configuration page of the plugin", $this->pluginID);
        ?>
</p>
			<?php 
        // We check rights
        $this->check_folder_rights(array(array(WP_CONTENT_DIR . "/sedlex/test/", "rwx")));
        $tabs = new SLFramework_Tabs();
        ob_start();
        // Examples for creating tables
        //----------------------------------
        echo "<h5>" . __("Tables", $this->pluginID) . "</h5>";
        $table = new SLFramework_Table();
        $table->title(array(__("Col1", $this->pluginID), __("Col2", $this->pluginID), __("Col2", $this->pluginID)));
        ob_start();
        echo __("Cell 1-1", $this->pluginID);
        $cel1 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 1-2", $this->pluginID);
        $cel2 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 1-3", $this->pluginID);
        $cel3 = new adminCell(ob_get_clean());
        $table->add_line(array($cel1, $cel2, $cel3), '1');
        ob_start();
        echo __("Cell 2-1", $this->pluginID);
        $cel1 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 2-2", $this->pluginID);
        $cel2 = new adminCell(ob_get_clean());
        ob_start();
        echo __("Cell 2-3", $this->pluginID);
        $cel3 = new adminCell(ob_get_clean());
        $table->add_line(array($cel1, $cel2, $cel3), '2');
        echo $table->flush();
        $tabs->add_tab(__('Summary', $this->pluginID), ob_get_clean());
        ob_start();
        $params = new SLFramework_Parameters($this, "tab-parameters");
        $params->add_title(__('Title 1', $this->pluginID));
        $params->add_param('opt1', __('Modify arg 1:', $this->pluginID));
        $params->add_comment(__("This is a comment. The default value is:", $this->pluginID));
        $params->add_comment_default_value('opt1');
        $params->add_param('opt2', __('Modify arg 2:', $this->pluginID));
        $params->add_param('opt3', __('Modify arg 3:', $this->pluginID));
        $params->add_comment(__('This is another comment.', $this->pluginID));
        $params->add_comment(__('The default value is:', $this->pluginID));
        $params->add_comment_default_value('opt3');
        $params->add_title(__('Title 2', $this->pluginID));
        $params->add_param('opt4', __('Modify arg 4:', $this->pluginID));
        $params->add_comment(__("This is a comment. The default value is:", $this->pluginID));
        $params->add_comment_default_value('opt4');
        $params->flush();
        $tabs->add_tab(__('Parameters', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
        $frmk = new coreSLframework();
        if (is_multisite() && $blog_id == 1 || !is_multisite() || $frmk->get_param('global_allow_translation_by_blogs')) {
            ob_start();
            $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
            $trans = new SLFramework_Translation($this->pluginID, $plugin);
            $trans->enable_translation();
            $tabs->add_tab(__('Manage translations', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png");
        }
        ob_start();
        $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
        $trans = new SLFramework_Feedback($plugin, $this->pluginID);
        $trans->enable_feedback();
        $tabs->add_tab(__('Give feedback', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_mail.png");
        ob_start();
        // A list of plugin slug to be excluded
        $exlude = array('wp-pirate-search');
        // Replace sedLex by your own author name
        $trans = new SLFramework_OtherPlugins("sedLex", $exlude);
        $trans->list_plugins();
        $tabs->add_tab(__('Other plugins', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_plug.png");
        echo $tabs->flush();
        // Before this comment, you may modify whatever you want
        //===============================================================================================
        ?>
			<?php 
        echo $this->signature;
        ?>
		</div>
		<?php 
    }
Exemple #8
0
    /** ====================================================================================================================================================
     * The configuration page
     * 
     * @return void
     */
    function configuration_page()
    {
        global $wpdb;
        $table_name = $this->table_name;
        ?>
		<div class="plugin-titleSL">
			<h2><?php 
        echo $this->pluginName;
        ?>
</h2>
		</div>
		
		<div class="plugin-contentSL">		
			<?php 
        echo $this->signature;
        ?>
			
			<!--debut de personnalisation-->
		<?php 
        // Store the url if the user submit a file...
        if (isset($_POST['import'])) {
            if (is_file($_FILES['fileImport']['tmp_name'])) {
                $lines = @file($_FILES['fileImport']['tmp_name']);
                $success = true;
                $nb_import = 0;
                foreach ($lines as $l) {
                    $element = explode(",", $l);
                    $query = "INSERT INTO " . $this->table_name . " (id_post, nb_hits, short_url, url_externe, comment) VALUES('" . esc_sql($element[0]) . "','" . esc_sql($element[1]) . "','" . esc_sql($element[2]) . "','" . esc_sql($element[3]) . "','" . esc_sql($element[4]) . "');";
                    if ($wpdb->query($query) === FALSE) {
                        $success = false;
                    } else {
                        $nb_import++;
                    }
                }
                if ($success == false) {
                    if ($nb_import == 0) {
                        echo '<div class="error fade"><p>' . __('An error occurs when updating the database.', $this->pluginID) . '</p></div>';
                    } else {
                        echo '<div class="error fade"><p>' . sprintf(__('An error occurs when updating the database. Nevertheless %s sentences has been imported successfully.', $this->pluginID), $nb_import) . '</p></div>';
                    }
                } else {
                    echo '<div class="updated fade"><p>' . sprintf(__('%s short URL have been added to the database.', $this->pluginID), $nb_import) . '</p></div>';
                }
            }
        }
        // On verifie que les droits sont corrects
        $this->check_folder_rights(array());
        //==========================================================================================
        //
        // Mise en place du systeme d'onglet
        //		(bien mettre a jour les liens contenu dans les <li> qui suivent)
        //
        //==========================================================================================
        $tabs = new SLFramework_Tabs();
        // Mise en place de la barre de navigation
        ob_start();
        // on identifie la racine des short links
        echo '<script language="javascript">var site="' . $this->get_home_url() . '"</script>';
        $maxnb = 20;
        $table = new SLFramework_Table(0, $maxnb, true, true);
        // on construit le filtre pour la requete
        $filter = explode(" ", $table->current_filter());
        $paged = 1;
        $result = array();
        $nb_url = 0;
        while (true) {
            query_posts(array('post_type' => explode(',', $this->get_param('typepage')), 'posts_per_page' => 100, 'paged' => $paged));
            $nb_url += 100;
            if (!have_posts() || $nb_url >= $this->get_param('maxnb')) {
                break;
            }
            $paged++;
            while (have_posts()) {
                the_post();
                // we check if the title match the filter
                $match = true;
                $title = get_the_title();
                foreach ($filter as $fi) {
                    if ($fi != "") {
                        if (strpos($title, $fi) === FALSE) {
                            $match = false;
                            break;
                        }
                    }
                }
                if ($match) {
                    $result[] = array(get_the_ID(), $title, wp_get_shortlink(), get_post_type(), $wpdb->get_var("SELECT nb_hits FROM {$table_name} WHERE id_post='" . get_the_ID() . "'"));
                }
            }
        }
        if ($nb_url >= $this->get_param('maxnb')) {
            echo '<div class="updated">';
            echo '<p>' . sprintf(__('The number of displayed URL cannot exceed %s. Thus the number of url is limited to this number.', $this->pluginID), $this->get_param('maxnb')) . '</p>';
            echo '</div>';
        }
        $count = count($result);
        $table->set_nb_all_Items($count);
        $table->title(array(__('Title of your articles', $this->pluginID), __('Short URL', $this->pluginID), __('Type', $this->pluginID), __('Number of clicks', $this->pluginID)));
        // We order the posts page according to the choice of the user
        if ($table->current_orderdir() == "ASC") {
            $result = SLFramework_Utils::multicolumn_sort($result, $table->current_ordercolumn(), true);
        } else {
            $result = SLFramework_Utils::multicolumn_sort($result, $table->current_ordercolumn(), false);
        }
        // We limit the result to the requested zone
        $result = array_slice($result, ($table->current_page() - 1) * $maxnb, $maxnb);
        // lignes du tableau
        // boucle sur les differents elements
        $ligne = 0;
        foreach ($result as $r) {
            $ligne++;
            ob_start();
            ?>
					<b><?php 
            echo $r[1];
            ?>
</b>
					<img src="<?php 
            echo plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
            ?>
img/ajax-loader.gif" id="wait<?php 
            echo $r[0];
            ?>
" style="display: none;" />
					<?php 
            $cel1 = new adminCell(ob_get_clean());
            ob_start();
            ?>
					<span id="lien<?php 
            echo $r[0];
            ?>
" ><a href="<?php 
            echo $r[2];
            ?>
"><?php 
            echo $r[2];
            ?>
</a></span>
					<?php 
            $cel2 = new adminCell(ob_get_clean());
            $cel2->add_action(__("Reset", $this->pluginID), "resetLink");
            $cel2->add_action(__("Edit", $this->pluginID), "forceLink");
            if (get_post_status($r[0]) == "publish") {
                $cel3 = new adminCell($r[3]);
            } else {
                $cel3 = new adminCell($r[3] . " (" . get_post_status($r[0]) . ")");
            }
            $select = "SELECT nb_hits FROM {$table_name} WHERE id_post='" . $r[0] . "'";
            $nb_hits = $wpdb->get_var($select);
            $cel4 = new adminCell($nb_hits);
            $table->add_line(array($cel1, $cel2, $cel3, $cel4), $r[0]);
        }
        echo $table->flush();
        ob_start();
        ?>
					<form method='post' enctype='multipart/form-data' action='<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
'>
						<label for='fileImport'><?php 
        echo __('Select the file:', $this->pluginID);
        ?>
</label>
						<input name='fileImport' id='fileImport' type='file'/><br/>
						<div class="submit">
							<input type="submit" name="import" class='button-primary validButton' value="<?php 
        echo __('Import a file with shorturls', $this->pluginID);
        ?>
" />
							<input type="submit" name="export" class='button-primary validButton' value="<?php 
        echo __('Export the shorturls', $this->pluginID);
        ?>
" />
						</div>
					</form>
					<?php 
        $box = new SLFramework_Box(__('Import/Export Short URL', $this->pluginID), ob_get_clean());
        echo $box->flush();
        $tabs->add_tab(__('Internal Redirections', $this->pluginID), ob_get_clean());
        ob_start();
        if (isset($_POST['add'])) {
            $url_ext = str_replace("'", "", $_POST['url_externe']);
            $comment = str_replace("'", "", $_POST['comment']);
            if (!preg_match("/^http/i", $url_ext)) {
                $url_ext = "http://" . $url_ext;
            }
            $this->add_external_link($url_ext, $comment);
        }
        $maxnb = 20;
        $table = new SLFramework_Table($count, $maxnb, true, true);
        $table->title(array(__('External URL', $this->pluginID), __('Short URL', $this->pluginID), __('Comment', $this->pluginID), __('Number of clicks', $this->pluginID)));
        // on construit le filtre pour la requête
        $filter = explode(" ", $table->current_filter());
        $filter_words = "";
        foreach ($filter as $fi) {
            $filter_words .= " AND ";
            $filter_words .= "(url_externe like '%" . $fi . "%' OR comment like '%" . $fi . "%')";
        }
        $count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table_name . " WHERE id_post=0 " . $filter_words . " AND url_externe<>''; ");
        $table->set_nb_all_Items($count);
        if ($table->current_ordercolumn() == 1) {
            $orderby = " ORDER BY url_externe " . $table->current_orderdir();
        } else {
            if ($table->current_ordercolumn() == 2) {
                $orderby = " ORDER BY short_url " . $table->current_orderdir();
            } else {
                if ($table->current_ordercolumn() == 3) {
                    $orderby = " ORDER BY nb_hits " . $table->current_orderdir();
                }
            }
        }
        $res = $wpdb->get_results("SELECT * FROM " . $table_name . " WHERE id_post=0 " . $filter_words . " AND url_externe<>'' " . $orderby . " LIMIT " . $maxnb * ($table->current_page() - 1) . ", " . $maxnb . " ; ");
        foreach ($res as $r) {
            $id_temp = sha1($r->short_url);
            $cel1 = new adminCell("<a href='" . $r->url_externe . "'>" . $r->url_externe . "</a><img src='" . plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "img/ajax-loader.gif' id='wait_external" . $id_temp . "' style='display: none;' />");
            $cel1->add_action(__("Delete", $this->pluginID), "deleteLink_external('" . $id_temp . "')");
            $cel2 = new adminCell("<span id='lien_external" . $id_temp . "'><a href='" . $this->get_home_url() . "/" . $r->short_url . "'>" . $this->get_home_url() . "/" . $r->short_url . "</a></span>");
            $cel2->add_action(__("Reset", $this->pluginID), "resetLink_external('" . $id_temp . "')");
            $cel2->add_action(__("Edit", $this->pluginID), "forceLink_external('" . $id_temp . "')");
            $cel3 = new adminCell("<p>" . $r->comment . "</p>");
            $cel4 = new adminCell($r->nb_hits);
            $table->add_line(array($cel1, $cel2, $cel3, $cel4), $id_temp);
        }
        echo $table->flush();
        ob_start();
        ?>
					<form method='post' action='<?php 
        echo remove_query_arg("filter_" . $table->id, $_SERVER["REQUEST_URI"]);
        ?>
'>
						<label for='url_externe'><?php 
        echo __('External URL:', $this->pluginID);
        ?>
</label>
						<input name='url_externe' id='url_externe' type='text' value='' size='40'/><br/>
						<label for='comment'><?php 
        echo __('Comments:', $this->pluginID);
        ?>
</label>
						<input name='comment' id='comment' type='text' value='' size='40'/><br/>
						<div class="submit">
							<input type="submit" name="add" class='button-primary validButton' value="<?php 
        echo __('Add a new URL to shorten', $this->pluginID);
        ?>
" />
						</div>
					</form>
					<?php 
        $box = new SLFramework_Box(__('Add a new URL to shorten', $this->pluginID), ob_get_clean());
        echo $box->flush();
        ob_start();
        ?>
					<form method='post' enctype='multipart/form-data' action='<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
'>
						<label for='fileImport'><?php 
        echo __('Select the file:', $this->pluginID);
        ?>
</label>
						<input name='fileImport' id='fileImport' type='file'/><br/>
						<div class="submit">
							<input type="submit" name="import" class='button-primary validButton' value="<?php 
        echo __('Import a file with shorturls', $this->pluginID);
        ?>
" />
							<input type="submit" name="export" class='button-primary validButton' value="<?php 
        echo __('Export the shorturls', $this->pluginID);
        ?>
" />
						</div>
					</form>
					<?php 
        $box = new SLFramework_Box(__('Import/Export Short URL', $this->pluginID), ob_get_clean());
        echo $box->flush();
        $tabs->add_tab(__('External Redirections', $this->pluginID), ob_get_clean());
        // HOW To
        ob_start();
        echo "<p>" . __("This plugin helps you sharing your post with short-links.", $this->pluginID) . "</p>";
        $howto1 = new SLFramework_Box(__("Purpose of that plugin", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . sprintf(__('When the function %s is called, this plugin replace the normal short links by a special crafted short links.', $this->pluginID), "<code>wp_get_shortlink</code>") . "</p>";
        echo "<p>" . sprintf(__('The short URL may be for instance %s of %s (the length of the short link may be configured).', $this->pluginID), "<code>http://domain.tld/Fh67aa</code>", "<code>http://domain.tld/ZhbaG</code>") . "</p>";
        echo "<p>" . __('.', $this->pluginID) . "</p>";
        $howto2 = new SLFramework_Box(__("How it works?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __('To display the shorten URL, you just have to choose the position of the display (top, bottom, etc.) in the configuration tab.', $this->pluginID) . "</p>";
        echo "<p>" . sprintf(__('You may also display the shorten URL whereever you want by using the %s function (for instance in your theme).', $this->pluginID), "<code>wp_get_shortlink</code>", "<code>http://domain.tld/ZhbaG</code>") . "</p>";
        $howto3 = new SLFramework_Box(__("How to display the short URL?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __('When your server see the request short URL, it will automatically redirect to the normal page.', $this->pluginID) . "</p>";
        echo "<p>" . __('You may also choose to redirect the short URL through an internal page:', $this->pluginID) . "</p>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>" . __("You just have to choose a specially crafted page to display during the redirection;", $this->pluginID) . "</p></li>";
        echo "<li><p>" . sprintf(__("In the page, you may insert %s to display the number of seconds remaining;", $this->pluginID), "<code>[short_url_second]</code>") . "</p></li>";
        echo "<li><p>" . sprintf(__("You may also insert %s to display the URL of the page to where the redirection will be performed;", $this->pluginID), "<code>[short_url_url]</code>") . "</p></li>";
        echo "</ul>";
        $howto4 = new SLFramework_Box(__("How to redirect works?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . sprintf(__('Your WP install should not use default permalinks (i.e. %s) but instead any custom permalinks (i.e. %s or %s).', $this->pluginID), "<code>http://domain.tld/?p=453</code>", "<code>domain.tld/2015/02/12/sample-post/</code>", "<code>domain.tld/2015/sample-post/</code>") . "</p>";
        $howto5 = new SLFramework_Box(__("Requirements", $this->pluginID), ob_get_clean());
        ob_start();
        echo $howto1->flush();
        echo $howto2->flush();
        echo $howto3->flush();
        echo $howto4->flush();
        echo $howto5->flush();
        $tabs->add_tab(__('How To', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_how.png");
        ob_start();
        ?>
					<h3 class="hide-if-js"><?php 
        echo __('Parameters', $this->pluginID);
        ?>
</h3>
				
					<?php 
        $params = new SLFramework_Parameters($this, 'tab-parameters');
        $params->add_title(__('Do you want to use the following characters?', $this->pluginID));
        $params->add_comment(__('These parameters will be taken in account only for generation of new links', $this->pluginID));
        $params->add_param('low_char', __('Lower-case characters ([a-z]):', $this->pluginID));
        $params->add_param('upp_char', __('Upper-case characters ([A-Z]):', $this->pluginID));
        $params->add_param('num_char', __('Numeric characters ([0-9]):', $this->pluginID));
        $params->add_title(__('Do you want to use a prefix before your short URL?', $this->pluginID));
        $params->add_param('prefix', __('Prefix:', $this->pluginID), "@[^a-zA-Z0-9_]@");
        $params->add_title(__('What is the length of your short URL (without the prefix)?', $this->pluginID));
        $params->add_param('length', __('Length:', $this->pluginID));
        $params->add_title(__('What are the short links that are to be displayed?', $this->pluginID));
        $params->add_param('typepage', __('Types (separated with comma):', $this->pluginID));
        $args = array('public' => true);
        $output = 'names';
        // names or objects, note names is the default
        $operator = 'and';
        // 'and' or 'or'
        $post_types = get_post_types($args, $output, $operator);
        $exemple = "page,post";
        foreach ($post_types as $post_type) {
            $exemple .= "," . $post_type;
        }
        $params->add_comment(sprintf(__('For instance %s', $this->pluginID), "<code>" . $exemple . "</code>"));
        $params->add_comment(__('Note that ALL page will be shorten, but only this types will be displayed in the first tab of this plugin.', $this->pluginID));
        $params->add_title(__('Customize the short link URL', $this->pluginID));
        $params->add_param('removewww', __('Remove www:', $this->pluginID));
        $params->add_comment(sprintf(__('Therefore, the short URL will begin with %s', $this->pluginID), str_replace("://www.", "://", home_url())));
        $params->add_param('changeroot', __('Change the root URL of the short link:', $this->pluginID), "", "", array("!removewww", "changeroot_url"));
        $params->add_comment(__('If you have a shorter URL pointing to your Wordpress blog, you may configure it here by selecting this option', $this->pluginID));
        $params->add_param('changeroot_url', __('Your shorter domain URL:', $this->pluginID));
        $params->add_title(__('Do you want to automatically shorten links in article?', $this->pluginID));
        $params->add_param('catch_url', __('Automatic shorten links:', $this->pluginID), "", "", array('catch_url_filter'));
        $params->add_param('catch_url_filter', __('Regexp filter:', $this->pluginID));
        $params->add_comment(sprintf(__('The above regexp filter is to select the page in which the link urls are shorten. For instance, %s (or %s) configures the plugin to shorten all links, for instance, in pages %s and %s', $this->pluginID), "<code>.*cat_select.*</code>", "<code>cat_select</code>", "<code>http://domain.tld/cat_select/</code>", "<code>http://domain.tld/level/cat_select/child/</code>"));
        $params->add_comment(__('Please enter one regexp per line.', $this->pluginID));
        $params->add_comment(__('If no regexp is entered, links in all pages and posts will be shorten.', $this->pluginID));
        $params->add_title(__('Where to display the short URL?', $this->pluginID));
        $params->add_param('display_top_in_post', "" . __('At the top of posts:', $this->pluginID));
        $params->add_param('display_bottom_in_post', "" . __('At the bottom of posts:', $this->pluginID));
        $params->add_param('display_top_in_page', "" . __('At the top of pages:', $this->pluginID));
        $params->add_param('display_bottom_in_page', "" . __('At the bottom of pages:', $this->pluginID));
        $params->add_param('display_top_in_custom', "" . __('At the top of custom type article:', $this->pluginID));
        $params->add_param('display_bottom_in_custom', "" . __('At the bottom of custom type article:', $this->pluginID));
        $params->add_param('display_top_in_excerpt', "" . __('At the top of excerpt:', $this->pluginID));
        $params->add_param('display_bottom_in_excerpt', "" . __('At the bottom of excerpt:', $this->pluginID));
        $params->add_param('exclude', __('Page to be excluded:', $this->pluginID));
        $params->add_comment(sprintf(__("Please enter one entry per line. If the article %s is to be excluded, you may enter %s.", $this->pluginID), "<code>http://yourdomain.tld/contact/</code>", "<code>contact</code>"));
        $params->add_comment(sprintf(__("For instance, %s and %s will exclude the home page.", $this->pluginID), "<code>^\$</code>", "<code>^/\$</code>"));
        $params->add_title(__('Appearance of such display', $this->pluginID));
        $params->add_param('html', __('Displayed HTML:', $this->pluginID));
        $params->add_comment_default_value('html');
        $params->add_comment(sprintf(__('Note that %s will be automatically replaced by the shorten URL.', $this->pluginID), "<code>%short_url%</code>"));
        $params->add_comment(sprintf(__('In addition, %s will be replaced by the shorten URL withour any html link.', $this->pluginID), "<code>%short_url_without_link%</code>"));
        $params->add_param('css', __('CSS:', $this->pluginID));
        $params->add_comment_default_value('css');
        $params->add_title(__('Redirect first internally', $this->pluginID));
        $params->add_param('redirect_page', __('Redirect the short link before to an internal page:', $this->pluginID));
        $params->add_param('redirect_sec', __('Number of second before the redirection:', $this->pluginID));
        $params->add_param('redirect_only_external', __('Redirect through this internal page only the external redirection:', $this->pluginID));
        $params->add_title(__('Advanced options', $this->pluginID));
        $params->add_param('maxnb', __('Max number of displayed internal redirection:', $this->pluginID));
        $params->flush();
        $tabs->add_tab(__('Parameters', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
        ob_start();
        $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
        $trans = new SLFramework_Translation($this->pluginID, $plugin);
        $trans->enable_translation();
        $tabs->add_tab(__('Manage translations', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_trad.png");
        ob_start();
        $plugin = str_replace("/", "", str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
        $trans = new SLFramework_Feedback($plugin, $this->pluginID);
        $trans->enable_feedback();
        $tabs->add_tab(__('Give feedback', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_mail.png");
        ob_start();
        $trans = new SLFramework_OtherPlugins("sedLex", array('wp-pirates-search'));
        $trans->list_plugins();
        $tabs->add_tab(__('Other plugins', $this->pluginID), ob_get_clean(), plugin_dir_url("/") . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_plug.png");
        echo $tabs->flush();
        echo $this->signature;
        ?>
		</div>
		<?php 
    }