/** ====================================================================================================================================================
  * Set the language ... according to the configuration
  * 
  * @return void
  */
 public function set_locale($loc)
 {
     $frmk = new coreSLframework();
     $lan = $frmk->get_param('lang');
     if (is_admin() && $lan != "") {
         $loc = $lan;
         SLFramework_Debug::log(get_class(), "Set locale from " . $loc . " to " . $lan . "", 4);
     }
     return $loc;
 }
 /** ====================================================================================================================================================
  * Log function
  *
  * @param string $where the name of the plugin which call the log function
  * @param string $text the text to be logged
  * @param integer $error_level 1=critical ; 2=error ; 3=warning ; 4=information ; 5=verbose
  * @return void
  */
 static function log($where, $text, $error_level = 5)
 {
     // Test if this message has to be loged
     $frmk = new coreSLframework();
     $level = $frmk->get_param('debug_level');
     if (!is_numeric($error_level)) {
         return;
     }
     $error_level = floor($error_level);
     if ($level < $error_level) {
         return;
     }
     $namelogfile = SLFramework_Debug::get_log_path();
     // We get the old content
     $old_content = @array_slice(@file($namelogfile), 0, 1999);
     if (!is_array($old_content)) {
         $old_content = array("");
     }
     // Once the file is identified, we stored the new logfile
     $error = "VERBOSE";
     if ($error_level == 1) {
         $error = "CRITICAL";
     }
     if ($error_level == 2) {
         $error = "ERROR";
     }
     if ($error_level == 3) {
         $error = "WARNING";
     }
     if ($error_level == 4) {
         $error = "INFO";
     }
     if ($error_level == 5) {
         $error = "VERBOSE";
     }
     $new_content = "[" . date("Ymd His") . "] [" . @getmypid() . "] [" . $where . "] [" . $error . "] - " . $text . "\r\n" . implode("", $old_content);
     // We store the content
     @file_put_contents($namelogfile, $new_content);
 }
    /** ====================================================================================================================================================
     * 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;
        $table_name = $wpdb->prefix . $this->pluginID;
        SLFramework_Debug::log(get_class(), "Display the configuration page", 4);
        ?>
		<div class="plugin-titleSL">
			<h2><?php 
        echo $this->pluginName;
        ?>
</h2>
		</div>
		
		<div class="plugin-contentSL">		
			<?php 
        echo $this->signature;
        ?>
			
			<p><?php 
        echo __('This plugin enables scheduled backups of important parts of your website!', $this->pluginID);
        ?>
</p>
			<p><?php 
        echo __('Just configure the schedule and the content to be save and enjoy: a background process will be triggered by the person who visits your website!', $this->pluginID);
        ?>
</p>
		<?php 
        // On verifie que les droits sont corrects
        $this->check_folder_rights(array(array(WP_CONTENT_DIR . "/sedlex/backup-scheduler/", "rw")));
        // On verifie que la fonction exist
        if (!@function_exists('gzcompress')) {
            SLFramework_Debug::log(get_class(), "GZCompress function is not supported on this server.", 1);
            echo "<div class='error fade'><p>" . sprintf(__('Sorry, but you should install/activate %s on your website. Otherwise, this plugin will not work properly!', $this->pluginID), "<code>gzcompress()</code>") . "</p><div>";
        }
        //==========================================================================================
        //
        // Mise en place du systeme d'onglet
        //
        //==========================================================================================
        $tabs = new SLFramework_Tabs();
        ob_start();
        $upload_dir = wp_upload_dir();
        $upload_dir = $upload_dir['basedir'] . "/";
        $params = new SLFramework_Parameters($this);
        $params->add_title(__('How often do you want to backup your website?', $this->pluginID));
        $params->add_param('frequency', __('Frequency (in days):', $this->pluginID));
        $params->add_param('save_time', __('Time of the backups:', $this->pluginID));
        $params->add_comment(__('Please note that 0 means midnight, 1 means 1am, 13 means 1pm, etc. The backup will occur at that time (server time) so make sure that your website is not too overloaded at that time.', $this->pluginID));
        $params->add_comment(__("Please also note that the backup won't be end exactly at that time. The backup process could take up to 6h especially if you do not have a lot of traffic on your website and/or if the backup is quite huge.", $this->pluginID));
        $params->add_param('delete_after', __('Keep the backup files for (in days):', $this->pluginID));
        $params->add_param('ftp_mail', __('If you want to be notify when the backup process is finished, please enter your email:', $this->pluginID));
        $params->add_title(__('Customize the name of the files?', $this->pluginID));
        $params->add_param('add_name', __('Add this string to the name of the files:', $this->pluginID));
        $params->add_comment(sprintf(__('The name of the files will be %s.', $this->pluginID), "<code>BackupScheduler<%addname%>_<%date%>_<%random%>.<%extension%></code>"));
        $params->add_comment(sprintf(__('%s is the string of the present option. You may set this option to %s.', $this->pluginID), "<code><%addname%></code>", "<code>_CustomName</code>"));
        $params->add_comment(sprintf(__('%s is a random string for security reasons.', $this->pluginID), "<code><%random%></code>"));
        $params->add_comment(sprintf(__('%s is the extension (i.e. %s).', $this->pluginID), "<code><%extension%></code>", "<code>zip</code>, <code>z01</code>, <code>z02</code>, <code>z03</code>, ..."));
        $params->add_title(__('What do you want to save?', $this->pluginID));
        if (!is_multisite() || is_multisite() && $blog_id == 1) {
            $params->add_param('save_all', __('All directories (the full Wordpress installation):', $this->pluginID), "", "", array('!save_upload', '!save_upload_all', '!save_theme', '!save_plugin'));
            $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), ABSPATH));
            $params->add_comment(__('Check this option if you want to save everything. Be careful, because the backup could be quite huge!', $this->pluginID));
            $params->add_param('save_plugin', __('The plugins directory:', $this->pluginID));
            $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), WP_CONTENT_DIR . "/plugins/"));
            $params->add_comment(__('Check this option if you want to save all plugins that you have installed and that you use on this website.', $this->pluginID));
            $params->add_param('save_theme', __('The themes directory:', $this->pluginID));
            $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), WP_CONTENT_DIR . "/themes/"));
            $params->add_comment(__('Check this option if you want to save all themes that you have installed and that you use on this website.', $this->pluginID));
        }
        if (is_multisite() && $blog_id != 1) {
            $params->add_param('save_upload', __('The upload directory for this blog:', $this->pluginID));
            // blogs.dir n'est plus utilisé pour les nouveaux blogs MU
            if (is_dir(WP_CONTENT_DIR . "/blogs.dir/" . $blog_id)) {
                $params->add_comment(sprintf(__('(i.e. %s and %s)', $this->pluginID), WP_CONTENT_DIR . "/blogs.dir/" . $blog_id, $upload_dir));
            } else {
                $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), $upload_dir));
            }
            $params->add_comment(__('Check this option if you want to save the images, the files, etc. that you have uploaded on your website to create your articles/posts/pages.', $this->pluginID));
        } else {
            if (is_multisite() && $blog_id == 1) {
                $params->add_param('save_upload_all', __('All upload directories (for this site and the sub-blogs):', $this->pluginID), "", "", array("!save_upload"));
                // blogs.dir n'est plus utilisé pour les nouveaux blogs MU
                if (is_dir(WP_CONTENT_DIR . "/blogs.dir/")) {
                    $params->add_comment(sprintf(__('(i.e. %s and %s)', $this->pluginID), WP_CONTENT_DIR . "/blogs.dir/", $upload_dir));
                } else {
                    $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), $upload_dir));
                }
                $params->add_comment(__('Check this option if you want to save the images, the files, etc. that people have uploaded on their websites to create articles/posts/pages.', $this->pluginID));
                // blogs.dir n'est plus utilisé pour les nouveaux blogs MU
                $params->add_param('save_upload', __('The upload directory for the main site:', $this->pluginID));
                if (is_dir(WP_CONTENT_DIR . "/blogs.dir/" . $blog_id)) {
                    $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), WP_CONTENT_DIR . "/blogs.dir/" . $blog_id));
                } else {
                    $root = scandir($upload_dir);
                    $val_folder = "";
                    foreach ($root as $value) {
                        if ($value !== "sites" && $value !== "." && $value !== "..") {
                            if ($val_folder != "") {
                                $val_folder .= ",";
                            }
                            $val_folder .= $upload_dir . $value;
                        }
                    }
                    $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), $val_folder));
                }
                $params->add_comment(__('Check this option if you want to save the images, the files, etc. that you have uploaded on your main website to create your articles/posts/pages.', $this->pluginID));
            } else {
                $params->add_param('save_upload', __('The upload directory:', $this->pluginID));
                $params->add_comment(sprintf(__('(i.e. %s)', $this->pluginID), $upload_dir));
                $params->add_comment(__('Check this option if you want to save the images, the files, etc. that you have uploaded on your website to create your articles/posts/pages.', $this->pluginID));
            }
        }
        if (is_multisite() && $blog_id != 1) {
            $params->add_param('save_db', __('The SQL database:', $this->pluginID));
            $params->add_comment(__('Check this option if you want to save the text of your posts, your configurations, etc. for this blog', $this->pluginID));
        } else {
            if (is_multisite() && $blog_id == 1) {
                $params->add_param('save_db_all', __('All SQL databases:', $this->pluginID), "", "", array("!save_db"));
                $params->add_comment(__('Check this option if you want to save all texts of posts, configurations, etc. for all blogs in this website', $this->pluginID));
                $params->add_param('save_db', __('Only your SQL database:', $this->pluginID));
                $params->add_comment(__('Check this option if you want to save the text of your posts, your configurations, etc. for the main website', $this->pluginID));
                $params->add_param('save_db_diff_blog', __('Save the SQL content of the sub-sites in different files:', $this->pluginID));
            } else {
                $params->add_param('save_db', __('The SQL database:', $this->pluginID));
                $params->add_comment(__('Check this option if you want to save the text of your posts, your configurations, etc.', $this->pluginID));
            }
        }
        $params->add_param('chunk', __('The maximum zip file size (in MB, namely the chunck size):', $this->pluginID));
        $params->add_comment(__('Please note that the zip file will be split into multiple files to comply with the maximum file size you have indicated', $this->pluginID));
        $params->add_param('exclude_folder', __('Exclude these folders:', $this->pluginID));
        $params->add_comment(__('Please enter one name of folder to be excluded per line', $this->pluginID));
        $params->add_comment(sprintf(__('By default, the line should exactely match the folder name or the folder path to exclude said folder (for instance %s or %s, to exclude the content folder)', $this->pluginID), "<code>wp-content</code>", "<code>" . WP_CONTENT_DIR . "</code>"));
        $params->add_comment(sprintf(__('If the line begins with %s, the line will be consider as a regexp (for instance %s, to exclude the content folder)', $this->pluginID), "<code>[regexp]</code>", "<code>[regexp].*\\/wp-content</code>"));
        $params->add_comment(__('For now, the following folder are exluded (please refresh the page if you just upfdate the options to see the correct list):', $this->pluginID));
        $exclu = explode("\n", $this->get_param('exclude_folder'));
        $exclu = array_map('trim', $exclu);
        $exclu[] = WP_CONTENT_DIR . "/sedlex";
        ob_start();
        $this->searchFolder(ABSPATH, $exclu);
        $params->add_comment(ob_get_clean());
        $params->add_title(__('Do you want that the backup is sent by email?', $this->pluginID));
        $params->add_param('email_check', __('Send the backup files by email:', $this->pluginID), '', '', array('email', 'rename'));
        $params->add_param('email', __('If so, please enter your email:', $this->pluginID));
        $params->add_param('rename', __('Do you want to add a suffix to sent files:', $this->pluginID));
        $params->add_comment(__('This option allows going round the blocking feature of some mail provider that block the mails with zip attachments (like GMail).', $this->pluginID));
        $params->add_comment(__('You do not need to fill this field if no mail is to be sent.', $this->pluginID));
        $params->add_title(__('Do you want that the backup is stored on a FTP?', $this->pluginID));
        if (function_exists("ftp_connect")) {
            $params->add_param('ftp', __('Save the backup files on a FTP?', $this->pluginID), '', '', array('ftp_host', 'ftp_login', 'ftp_pass', 'ftp_root', 'ftp_port', 'ftp_create_folder'));
            $params->add_param('ftp_host', __('FTP host:', $this->pluginID));
            $params->add_comment(sprintf(__('Should be at the form %s or %s', $this->pluginID), '<code>ftp://domain.tld/root_folder/</code>', '<code>ftps://domain.tld/root_folder/</code>'));
            $params->add_comment(sprintf(__('If %s is omitted then it is automatically added when connecting to your FTP. This is useful if you get an 404 error submitting these parameters with %s.', $this->pluginID), '<code>ftp://</code>', '<code>ftp://</code>'));
            $params->add_param('ftp_port', __('FTP port:', $this->pluginID));
            $params->add_comment(sprintf(__('By default the port is %s', $this->pluginID), '<code>21</code>'));
            $params->add_param('ftp_login', __('Your FTP login:'******'ftp_pass', __('Your FTP pass:'******'Click on that button %s to test if the above information is correct', $this->pluginID) . "<span id='testFTP_info'></span>", "<input type='button' id='testFTP_button' class='button validButton' onClick='testFTP();'  value='" . __('Test', $this->pluginID) . "' /><img id='wait_testFTP' src='" . WP_PLUGIN_URL . "/" . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/ajax-loader.gif' style='display: none;'>"));
            $params->add_param('ftp_create_folder', __('Create sub-folder with date in your FTP repository for all backup files:', $this->pluginID), '', '', array('ftp_prefix_folder'));
            $params->add_param('ftp_prefix_folder', __('Add a prefix to the created folder:', $this->pluginID));
        } else {
            $params->add_comment(__('Your PHP installation does not support FTP features, thus this option has been disabled! Sorry...', $this->pluginID));
        }
        $params->add_title(__('Advanced - Memory and time management', $this->pluginID));
        $params->add_param('max_allocated', __('What is the maximum size of allocated memory (in MB):', $this->pluginID));
        $params->add_comment(__("The files greater than this limit won't be included in the zip file!", $this->pluginID));
        $params->add_comment(__('On some Wordpress installation, you may have memory issues. Thus, try to reduce this number if you face such error.', $this->pluginID));
        $params->add_param('max_time', __('What is the maximum time for the php scripts execution (in seconds):', $this->pluginID));
        $params->add_comment(__('Even if you do not have time restriction, it is recommended to set this value to 15sec in order to avoid any killing of the php scripts by your web hoster.', $this->pluginID));
        $params->flush();
        $parameters = ob_get_clean();
        ob_start();
        echo "<p>" . __('Here is the backup files. You can force a new backup or download previous backup files.', $this->pluginID) . "</p>";
        echo "<p>" . sprintf(__('Please note that the current GMT time of the server is %s. If it is not correct, please configure the Wordpress installation correctly.', $this->pluginID), "<strong>" . date_i18n('Y-m-d H:i:s') . "</strong>") . "</p>";
        $hours = $this->backupInHours();
        if ($hours > 0) {
            $days = floor($hours / 24);
            $hours = $hours - 24 * $days;
            echo "<p>" . sprintf(__('An automatic backup will be launched in %s days and %s hours.', $this->pluginID), $days, $hours) . "</p>";
        } else {
            echo "<p>" . sprintf(__('The backup process has started %s hours ago but has not finished yet.', $this->pluginID), -$hours) . "</p>";
        }
        echo "<div id='zipfile'>";
        $this->displayBackup();
        echo "</div>";
        echo "<p>";
        echo "<img id='wait_backup' src='" . WP_PLUGIN_URL . "/" . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/ajax-loader.gif' style='display: none;'>";
        echo " <input type='button' id='backupButton' class='button-primary validButton' onClick='initForceBackup(\"external\")'  value='" . __('Force a new backup (with Mail/FTP)', $this->pluginID) . "' />";
        echo "<script>jQuery('#backupButton').removeAttr('disabled');</script>";
        echo " <input type='button' id='backupButton2' class='button validButton' onClick='initForceBackup(\"internal\")'  value='" . __('Force a new backup (without any external storage or sending)', $this->pluginID) . "' />";
        echo "<script>jQuery('#backupButton2').removeAttr('disabled');</script>";
        echo "</p>";
        $tabs->add_tab(__('Backups', $this->pluginID), ob_get_clean());
        $tabs->add_tab(__('Parameters', $this->pluginID), $parameters, WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . "core/img/tab_param.png");
        // HOW To
        ob_start();
        echo "<p>" . __("There is two different ways to create a backup:", $this->pluginID) . "</p>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>" . __("an automatic process (namely background process):", $this->pluginID) . "</p></li>";
        echo "<ul style='list-style-type: circle;padding-left:40px;'>";
        echo "<li><p>" . __("Every time a user visits a page of the frontside of your website, a small portion of the backup process is performed;", $this->pluginID) . "</p></li>";
        echo "<li><p>" . __("Note that if you have very few visits, a complete backup may be quite long.", $this->pluginID) . "</p></li>";
        echo "</ul>";
        echo "<li><p>" . __("a forced process:", $this->pluginID) . "</p></li>";
        echo "<ul style='list-style-type: circle;padding-left:40px;'>";
        echo "<li><p>" . __("The button that triggers this forced process may be found in the Backup tab;", $this->pluginID) . "</p></li>";
        echo "<li><p>" . __("You have to stay on that page for processing all attachments: if you go on another page (or if you reload the page), the process will be stopped.", $this->pluginID) . "</p></li>";
        echo "</ul>";
        echo "</ul>";
        $howto1 = new SLFramework_Box(__("How to backup the site?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("When forcing a backup process, the plugin indicates that another process is running.", $this->pluginID) . "</p>";
        echo "<p>" . __("99% of the time, it means that the memory limit and/or the chunck size have been increased and that you exceed the maximum memory limit authorized by your server: therefore, the PHP process related to the backup is killed.", $this->pluginID) . "</p>";
        echo "<p>" . __("Most of the time, this chunk size and memory limit do not have to be higher than 15Mo.", $this->pluginID) . "</p>";
        echo "<p><b>" . __("DO NOT contact me before trying to reduce the chunk size and the memory limit: 250Mo is, for instance, often not a good idea...", $this->pluginID) . "</b></p>";
        $howto2 = new SLFramework_Box(__("The backup process cannot end", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("This plugin create a plurality of split zip.", $this->pluginID) . "</p>";
        echo "<p>" . __("Indeed, a PHP process is not able, most of the time, to create, manipulate and handle files that exceed a certain amount of data.", $this->pluginID) . "</p>";
        echo "<p>" . __("In order to be able to backup websites of a size of a couple gigabytes, the plugin create different files.", $this->pluginID) . "</p>";
        $howto3 = new SLFramework_Box(__("Why the plugin creates multi-part zip?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("To open the backups, you will have to execute the following steps:", $this->pluginID) . "</p>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>" . __("Save all zip files (i.e. *.zip, *.z01, *.z02, etc.) in a single folder on your hard disk.", $this->pluginID) . "</p></li>";
        echo "<li><p>" . __("Unzip these files by using a software that support multi-part zip files (it is often indicated in the readme):", $this->pluginID) . "</p></li>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>IZArc (Windows)</p></li>";
        echo "<li><p>Winzip (Windows)</p></li>";
        echo "<li><p>Winrar (Windows)</p></li>";
        echo "<li><p>The UnArchiver (MacOS)</p></li>";
        echo "<li><p>" . __("Other software may works ... do not hesitate to inform me!", $this->pluginID) . "</p></li>";
        echo "</ul>";
        echo "</ul>";
        $howto4 = new SLFramework_Box(__("How to open the split zip files?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("No this plugin does not propose a 'one-click restoration'.", $this->pluginID) . "</p>";
        echo "<p>" . __("Indeed, how a plugin may restore an installation of Wordpress if Wordpress does not exists (it has to be restored) to run the plugin? I believe I made my point ...", $this->pluginID) . "</p>";
        echo "<p>" . __("Keep in mind that the restoration of a website may be a technical and long process (it depends on what you want to restore). For instance, you need to be familiar with manipulating FTP for accessing your website.", $this->pluginID) . "</p>";
        $howto5 = new SLFramework_Box(__("One click restoration?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("In the zip, you will find some sql files.", $this->pluginID) . "</p>";
        echo "<p>" . __("You could either:", $this->pluginID) . "</p>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>" . sprintf(__("Import each file in your new database (for instance, thanks to %s), in the alphabetical order of the files.", $this->pluginID), "phpMyAdmin") . "</p></li>";
        echo "<li><p>" . sprintf(__("Concatenate the sql files in one big file and import this latter file in your new database (for instance, thanks to %s).", $this->pluginID), "phpMyAdmin") . "</p></li>";
        echo "</ul>";
        echo "<p>" . sprintf(__("Please note that if you choose to save the SQL content of the sub-sites in different files, you will also have some %s files (with %s the index of the blog). You can separately handle these files.", $this->pluginID), "<code>blogx.sql</code>", "<code>x</code>") . "</p>";
        $howto6 = new SLFramework_Box(__("How to restore the database?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __("If you have backuped the entire website, the restoration is quite simple: you just have to copy the files in the zip files into your webserver.", $this->pluginID) . "</p>";
        echo "<p>" . __("If you have backuped only some folders, you will have to execute the following steps:", $this->pluginID) . "</p>";
        echo "<ul style='list-style-type: disc;padding-left:40px;'>";
        echo "<li><p>" . __("Install a fresh version of Wordpress on your webserver.", $this->pluginID) . "</p></li>";
        echo "<li><p>" . sprintf(__("Replace the folders (i.e. %s,  %s, and/or %s) of the root of your webserver by the extracted folders.", $this->pluginID), "'<code>plugins</code>'", "'<code>themes</code>'", "'<code>uploads</code>'") . "</p></li>";
        echo "<li><p>" . sprintf(__("Replace the %s (at the root of your webserver) with the extracted one.", $this->pluginID), "<code>wp-config.php</code>") . "</p></li>";
        echo "</ul>";
        echo "<p>" . sprintf(__("Please note that if you choose to save the SQL content of the sub-sites in different files, you will also have some %s files (with %s the index of the blog). You can separately handle these files.", $this->pluginID), "<code>blogx.sql</code>", "<code>x</code>") . "</p>";
        $howto7 = new SLFramework_Box(__("How to restore the other files?", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . sprintf(__("The backup files are stored in %s.", $this->pluginID), "<code>wp-content/sedlex/backup-scheduler/</code>") . "</p>";
        echo "<p>" . __("In addition, the plugin may store the files on a distant FTP.", $this->pluginID) . "</p>";
        echo "<p>" . __("Finally, you can configure the plugin to send the backup files by mail but be informed that there is some difficulties with most of mail provider (size issue, extension rejection, etc.).", $this->pluginID) . "</p>";
        $howto8 = new SLFramework_Box(__("Where the backup are stored?", $this->pluginID), ob_get_clean());
        ob_start();
        echo $howto1->flush();
        echo $howto8->flush();
        echo $howto3->flush();
        echo $howto2->flush();
        echo $howto4->flush();
        echo $howto5->flush();
        echo $howto6->flush();
        echo $howto7->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");
        $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(), WP_PLUGIN_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(), WP_PLUGIN_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-pirates-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(), WP_PLUGIN_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 
    }
Esempio n. 4
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 
    }
Esempio n. 5
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 
        echo $this->signature;
        ?>

			<?php 
        //===============================================================================================
        // After this comment, you may modify whatever you want
        // We check rights
        $this->check_folder_rights(array(array(WP_CONTENT_DIR . "/sedlex/test/", "rwx")));
        $tabs = new SLFramework_Tabs();
        ob_start();
        echo "<p>" . __("In this tab, you could re-order the page hierarchy by 'drag-and-dropping' page entries.", $this->pluginID) . "</p>";
        $args = array('sort_order' => 'ASC', 'sort_column' => 'menu_order,post_title', 'parent' => 0, 'child_of' => 0, 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish,draft,pending,future');
        SLFramework_Treelist::render($this->create_hierarchy_pages(get_pages($args)), true, 'savePageHierarchy', 'page_hiera');
        $tabs->add_tab(__('Order Pages', $this->pluginID), ob_get_clean());
        // HOW To
        ob_start();
        echo "<p>" . __('With this plugin you may order your pages into hierarchical tree and display the tree in them.', $this->pluginID) . "</p>";
        echo "<p>" . sprintf(__("To display the tree please add %s in your page.", $this->pluginID), "<code>[page_tree]</code>") . "</p>";
        $howto1 = new SLFramework_Box(__("Purpose of that plugin", $this->pluginID), ob_get_clean());
        ob_start();
        echo "<p>" . __('Just drag and drop each entry.', $this->pluginID) . "</p>";
        $howto2 = new SLFramework_Box(__("How to order the page", $this->pluginID), ob_get_clean());
        ob_start();
        echo $howto1->flush();
        echo $howto2->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();
        $params = new SLFramework_Parameters($this, "tab-parameters");
        $params->add_title(__("Tree view style (i.e. [page_tree] shortcode)", $this->pluginID));
        $params->add_param('current_style', __("Set the style of current page in tree:", $this->pluginID));
        $params->add_param('parent_style', __("Set the style of parent pages in tree:", $this->pluginID));
        $params->add_param('child_style', __("Set the style of child pages in tree:", $this->pluginID));
        $params->add_param('other_style', __("Set the style of other pages in tree:", $this->pluginID));
        $params->add_title(__("Breadcrumb style (i.e. [page_parents] shortcode)", $this->pluginID));
        $params->add_param('breadcrumb_all', __("Set the style of the breadcrumb:", $this->pluginID));
        $params->add_param('breadcrumb_item', __("Set the style of items of the breadcrumb:", $this->pluginID));
        $params->add_title(__("Order for editor", $this->pluginID));
        $params->add_param('show_order_in_page_edit', __("Show the order page for the editors users (menu under the page menu):", $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");
        $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 liste 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 
    }