function toggle_css_file($mod_dir, $base_css_file = 'frontend.css')
 {
     global $page_id, $section_id, $TEXT;
     // check if the required edit_module_css.php file exists
     if (!file_exists(LEPTON_PATH . '/modules/edit_module_files.php')) {
         return false;
     }
     // do sanity check of specified css file
     if (!in_array($base_css_file, array('frontend.css', 'css/frontend.css', 'backend.css', 'css/backend.css'))) {
         return;
     }
     // display button to toggle between the two CSS files: frontend.css, backend.css
     // Patch Aldus
     switch ($base_css_file) {
         case 'frontend.css':
             $toggle_file = 'backend.css';
             break;
         case 'backend.css':
             $toggle_file = 'frontend.css';
             break;
         case 'css/frontend.css':
             $toggle_file = 'css/backend.css';
             break;
         case 'css/backend.css':
             $toggle_file = 'css/frontend.css';
             break;
     }
     // Aldus: another patch for the css-paths.
     $toggle_file_label = str_replace("css/", "", $toggle_file);
     if (mod_file_exists($mod_dir, $toggle_file)) {
         if (!isset($parser)) {
             require_once LEPTON_PATH . "/modules/lib_twig/library.php";
         }
         $loader->prependPath(LEPTON_PATH . "/templates/" . DEFAULT_THEME . "/templates/");
         $fields = array('LEPTON_URL' => LEPTON_URL, 'page_id' => $page_id, 'section_id' => $section_id, 'mod_dir' => $mod_dir, 'edit_file' => $toggle_file_label, 'label_submit' => ucfirst($toggle_file_label));
         echo $parser->render('edit_module_css_form.lte', $fields);
         return true;
     } else {
         return false;
     }
 }
 function edit_module_css($mod_dir)
 {
     global $page_id, $section_id, $TEXT;
     global $parser, $loader;
     // check if the required edit_module_css.php file exists
     if (!file_exists(LEPTON_PATH . '/modules/edit_module_files.php')) {
         return;
     }
     // check if frontend.css or backend.css exist
     $frontend_css = mod_file_exists($mod_dir, 'frontend.css');
     $backend_css = mod_file_exists($mod_dir, 'backend.css');
     // output the "edit CSS" form
     if ($frontend_css || $backend_css) {
         if (!isset($parser)) {
             require_once LEPTON_PATH . "/modules/lib_twig/library.php";
         }
         $loader->prependPath(LEPTON_PATH . "/templates/" . DEFAULT_THEME . "/templates/");
         $fields = array('LEPTON_URL' => LEPTON_URL, 'page_id' => $page_id, 'section_id' => $section_id, 'mod_dir' => $mod_dir, 'edit_file' => $frontend_css ? 'frontend.css' : 'backend.css', 'label_submit' => $TEXT['CAP_EDIT_CSS']);
         echo $parser->render('edit_module_css_form.lte', $fields);
     }
 }
Example #3
0
require LEPTON_PATH . '/modules/admin.php';
// leave if the required module.functions.php file does not exist
if (!file_exists(LEPTON_PATH . '/framework/summary.module_edit_css.php')) {
    echo 'The required file: /framework/summary.module_edit_css.php is missing - script stopped.';
    die;
}
echo function_exists('registerEditArea') ? registerEditArea('code_area', 'css', false) : 'none';
// set default text output if varibles are not defined in the global WB language files
$HEADING_CSS_FILE = isset($GLOBALS['TEXT']['HEADING_CSS_FILE']) ? $GLOBALS['TEXT']['HEADING_CSS_FILE'] : 'Actual module file: ';
$TXT_EDIT_CSS_FILE = isset($GLOBALS['TEXT']['TXT_EDIT_CSS_FILE']) ? $GLOBALS['TEXT']['TXT_EDIT_CSS_FILE'] : 'Edit the CSS definitions in the textarea below.';
// include functions to edit the optional module CSS files (frontend.css, backend.css)
require_once LEPTON_PATH . '/framework/summary.module_edit_css.php';
// check if the module directory is valid
$mod_dir = $_POST['mod_dir'];
// check if action is: save or edit
if ($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) {
    /** 
    	SAVE THE UPDATED CONTENTS TO THE CSS FILE
    */
    $css_content = '';
    if (isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) {
        $css_content = stripslashes($_POST['css_data']);
    }
    $bytes = 0;
    if ($css_content != '') {
        // open the module CSS file for writting
        $mod_file = fopen(LEPTON_PATH . '/modules/' . $mod_dir . '/' . $_POST['edit_file'], 'wb');
        // write new content to the module CSS file
        $bytes = fwrite($mod_file, $css_content);
        // close the file
        fclose($mod_file);
    function toggle_css_file($mod_dir, $base_css_file = 'frontend.css')
    {
        global $page_id, $section_id, $admin;
        // check if the required edit_module_css.php file exists
        if (!file_exists(WB_PATH . '/modules/edit_module_files.php')) {
            return;
        }
        // check if specified module directory is valid
        if (check_module_dir($mod_dir) == '') {
            return;
        }
        // do sanity check of specified css file
        if (!in_array($base_css_file, array('frontend.css', 'backend.css'))) {
            return;
        }
        // display button to toggle between the two CSS files: frontend.css, backend.css
        $toggle_file = $base_css_file == 'frontend.css' ? 'backend.css' : 'frontend.css';
        if (mod_file_exists($mod_dir, $toggle_file)) {
            ?>
         <form name="toggle_module_file" action="<?php 
            echo WB_URL . '/modules/edit_module_files.php?page_id=' . $page_id;
            ?>
" method="post" style="margin: 0; align:right;">
            <?php 
            echo $admin->getFTAN();
            ?>
            <input type="hidden" name="page_id" value="<?php 
            echo $page_id;
            ?>
" />
            <input type="hidden" name="section_id" value="<?php 
            echo $section_id;
            ?>
" />
            <input type="hidden" name="mod_dir" value="<?php 
            echo $mod_dir;
            ?>
" />
            <input type="hidden" name="edit_file" value="<?php 
            echo $toggle_file;
            ?>
" />
            <input type="hidden" name="action" value="edit" />
            <input type="submit" value="<?php 
            echo ucwords($toggle_file);
            ?>
" class="mod_<?php 
            echo $mod_dir;
            ?>
_edit_css" />
         </form>
         <?php 
        }
    }