Ignore:
Timestamp:
Mar 26, 2008, 12:30:23 AM (16 years ago)
Author:
patdenice
Message:

Add editarea to LocalFiles Editor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/LocalFilesEditor/admin.php

    r2235 r2291  
    2727if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    2828include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
     29include_once(LOCALEDIT_PATH.'functions.inc.php');
    2930load_language('plugin.lang', LOCALEDIT_PATH);
    3031$my_base_url = get_admin_plugin_menu_link(__FILE__);
    31 
    32 /**
    33  * returns $code if php syntax is correct
    34  * else return false
    35  *
    36  * @param string php code
    37  */
    38 function eval_syntax($code)
    39 {
    40     $code = str_replace(array('<?php', '?>'), '', $code);
    41     $b = 0;
    42     foreach (token_get_all($code) as $token)
    43         {
    44         if ('{' == $token) ++$b;
    45         else if ('}' == $token) --$b;
    46     }
    47     if ($b) return false;
    48     else
    49         {
    50         ob_start();
    51         $eval = eval('if(0){' . $code . '}');
    52         ob_end_clean();
    53         if ($eval === false) return false;
    54         else return '<?php' . $code . '?>';
    55     }
    56 }
    57 
    5832
    5933// +-----------------------------------------------------------------------+
     
    10276*/\n\n\n\n\n?>";
    10377
     78// Editarea options
     79$editarea = array(
     80  'start_highlight' => true,
     81  'language' => substr($user['language'], 0, 2),
     82  'toolbar' => 'search,fullscreen, |,select_font, |, undo, redo, change_smooth_selection, highlight, reset_highlight, |, help');
     83if (isset($conf['editarea_options']) and is_array($conf['editarea_options']))
     84{
     85  $editarea = array_merge($editarea, $conf['editarea_options']);
     86}
     87
    10488// Edit selected file for CSS, template and language
    10589if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
     
    128112                . 'show_default.php?file=include/config_default.inc.php',
    129113              'FILE' => 'config_default.inc.php')));
    130     break;
    131 
     114    $editarea['syntax'] = 'php';
     115    break;
    132116
    133117  case 'css':
     
    155139        'OPTIONS' => $options,
    156140        'SELECTED' => $selected));
    157     break;
    158 
     141    $editarea['syntax'] = 'css';
     142    break;
    159143 
    160144  case 'tpl':
     
    182166        'OPTIONS' => $options,
    183167        'SELECTED' => $selected));
    184     break;
    185 
     168    $editarea['syntax'] = 'html';
     169    break;
    186170
    187171  case 'lang':
     
    208192        'OPTIONS' => $options,
    209193        'SELECTED' => $selected));
     194    $editarea['syntax'] = 'php';
    210195    break;
    211196   
     
    214199    $content_file = file_exists($edited_file) ?
    215200      file_get_contents($edited_file) : $new_file['plug'];
     201    $editarea['syntax'] = 'php';
    216202    break;
    217203}
     
    309295}
    310296
     297// Editarea
     298if (!isset($conf['editarea_options']) or $conf['editarea_options'] !== false)
     299{
     300  $template->assign('editarea', array(
     301    'URL' => LOCALEDIT_PATH . 'editarea/edit_area_full.js',
     302    'OPTIONS' => $editarea));
     303}
     304
    311305$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    312306
Note: See TracChangeset for help on using the changeset viewer.