Changeset 2291 for trunk


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

Add editarea to LocalFiles Editor.

Location:
trunk/plugins/LocalFilesEditor
Files:
49 added
8 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
  • trunk/plugins/LocalFilesEditor/admin.tpl

    r2235 r2291  
     1{if isset($editarea)}
     2<script type="text/javascript" src="{$editarea.URL}"></script>
     3<script type="text/javascript">
     4editAreaLoader.init({ldelim}
     5        id: "text"
     6        {foreach from=$editarea.OPTIONS key=option item=value}
     7  , {$option}: {$value|editarea_quote}
     8  {/foreach}
     9{rdelim});
     10</script>
     11{/if}
     12
    113<div class="titrePage">
    214  <h2>LocalFiles Editor</h2>
     
    1527
    1628{foreach from=$show_default item=file}
    17 <a href="{$file.SHOW_DEFAULT}" onclick="window.open( this.href, 'local_file', 'location=no,toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes,fullscreen=yes' ); return false;">{'locfiledit_show_default'|@translate} "{$file.FILE}"</a>
     29<a href="{$file.SHOW_DEFAULT}" onclick="window.open( this.href, 'local_file', 'location=no,toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes,width=800,height=600' ); return false;">{'locfiledit_show_default'|@translate} "{$file.FILE}"</a>
    1830<br>
    1931{/foreach}
     
    2436<b>{$zone_edit.FILE_NAME}</b>
    2537<br>
    26 <textarea rows="30" name="text" style="width:90%;">{$zone_edit.CONTENT_FILE}</textarea>
     38<textarea rows="30" name="text" id="text" style="width:90%;">{$zone_edit.CONTENT_FILE}</textarea>
    2739<br>{'locfiledit_save_bak'|@translate}
    2840<br><br>
    2941<input class="submit" type="submit" value="{'locfiledit_save_file'|@translate}" name="submit" {$TAG_INPUT_ENABLED}/>
    3042{if isset ($restore)}
    31 <input class="submit" type="submit" value="{'locfiledit_restore'|@translate}" name="restore" onclick="return confirm('{'locfiledit_restore_confirm'|@translate}');" {$TAG_INPUT_ENABLED}/>
     43<input class="submit" type="submit" value="{'locfiledit_restore'|@translate}" name="restore" onclick="return confirm('{'locfiledit_restore_confirm'|@translate|escape:'javascript'}');" {$TAG_INPUT_ENABLED}/>
    3244{/if}
    3345{/if}
  • trunk/plugins/LocalFilesEditor/language/en_UK/plugin.lang.php

    r2235 r2291  
    4040$lang['locfiledit_edit'] = 'Edit';
    4141$lang['locfiledit_restore'] = 'Restore the backup file';
    42 $lang['locfiledit_restore_confirm'] = 'Please confirm?\nRestore won\\\'t be effective till next save.';
     42$lang['locfiledit_restore_confirm'] = 'Please confirm?
     43Restore won\'t be effective till next save.';
    4344$lang['locfiledit_bak_loaded1'] = 'Backup file loaded.';
    4445$lang['locfiledit_bak_loaded2'] = 'You must save file to restore it.';
  • trunk/plugins/LocalFilesEditor/language/es_ES/plugin.lang.php

    r2235 r2291  
    4040$lang['locfiledit_edit'] = 'Editar';
    4141$lang['locfiledit_restore'] = 'Cargar el fichero de salvaguardia';
    42 $lang['locfiledit_restore_confirm'] = '¿ Desea cargar el fichero de salvaguardia?\nUsted deberá luego hacer clic Registrar para restaurarlo.';
     42$lang['locfiledit_restore_confirm'] = '¿ Desea cargar el fichero de salvaguardia?
     43Usted deberá luego hacer clic Registrar para restaurarlo.';
    4344$lang['locfiledit_bak_loaded1'] = 'Fichero cargado de salvaguardia';
    4445$lang['locfiledit_bak_loaded2'] = 'Usted debe registrarlo para salvaguardarlo.';
  • trunk/plugins/LocalFilesEditor/language/fr_FR/plugin.lang.php

    r2235 r2291  
    4040$lang['locfiledit_edit'] = 'Editer';
    4141$lang['locfiledit_restore'] = 'Charger le fichier de sauvegarde';
    42 $lang['locfiledit_restore_confirm'] = 'Souaitez-vous charger le fichier de sauvegarde?\nVous devrez ensuite cliquer sur Enregistrer pour le restaurer.';
     42$lang['locfiledit_restore_confirm'] = 'Souaitez-vous charger le fichier de sauvegarde?
     43Vous devrez ensuite cliquer sur Enregistrer pour le restaurer.';
    4344$lang['locfiledit_bak_loaded1'] = 'Fichier de sauvegarde chargé';
    4445$lang['locfiledit_bak_loaded2'] = 'Vous devez l\'enregistrer pour le sauvegarder.';
  • trunk/plugins/LocalFilesEditor/main.inc.php

    r2243 r2291  
    3838function localfiles_admin_menu($menu)
    3939{
    40     array_push($menu, array('NAME' => 'LocalFiles Editor',
    41             'URL' => get_admin_plugin_menu_link(LOCALEDIT_PATH . 'admin.php')));
     40    array_push($menu, array(
     41      'NAME' => 'LocalFiles Editor',
     42      'URL' => get_admin_plugin_menu_link(LOCALEDIT_PATH . 'admin.php')));
    4243    return $menu;
    4344}
  • trunk/plugins/LocalFilesEditor/show_default.php

    r2235 r2291  
    2727define('PHPWG_ROOT_PATH', '../../');
    2828include_once(PHPWG_ROOT_PATH . 'include/common.inc.php');
     29include_once(LOCALEDIT_PATH.'functions.inc.php');
    2930check_status(ACCESS_ADMINISTRATOR);
    3031
     
    3839   
    3940  $template->set_filename('show_default', dirname(__FILE__) . '/show_default.tpl');
    40    
     41 
     42  // Editarea
     43  if (!isset($conf['editarea_options']) or $conf['editarea_options'] !== false)
     44  {
     45    $editarea = array(
     46      'syntax' => 'php',
     47      'start_highlight' => true,
     48      'is_editable' => false,
     49      'language' => substr($user['language'], 0, 2));
     50
     51    $template->assign('editarea', array(
     52      'URL' => LOCALEDIT_PATH . 'editarea/edit_area_full.js',
     53      'OPTIONS' => $editarea));
     54  }
     55
    4156  $file = file_get_contents(PHPWG_ROOT_PATH . $path);
    42    
    43   $template->assign(array('DEFAULT_CONTENT' => nl2br($file)));
    44  
     57
     58  $template->assign(array('DEFAULT_CONTENT' => $file));
     59
    4560  $title = $path;
    4661  $page['page_banner'] = '<h1>'.str_replace('/', ' / ', $path).'</h1>';
     
    4863
    4964  include(PHPWG_ROOT_PATH.'include/page_header.php');
    50  
     65
    5166  $template->pparse('show_default');
    52  
     67
    5368  include(PHPWG_ROOT_PATH.'include/page_tail.php');
    5469}
  • trunk/plugins/LocalFilesEditor/show_default.tpl

    r2235 r2291  
    1 <div id="content" style="font-family:courier;text-align:left;padding:5px;">
    2 {$DEFAULT_CONTENT}
    3 </div> <!-- content -->
     1{if isset($editarea)}
     2<script type="text/javascript" src="{$editarea.URL}"></script>
     3<script type="text/javascript">
     4editAreaLoader.init({ldelim}
     5        id: "text"
     6        {foreach from=$editarea.OPTIONS key=option item=value}
     7  , {$option}: {$value|editarea_quote}
     8  {/foreach}
     9{rdelim});
     10</script>
     11{/if}
     12
     13<textarea rows="30" id="text" cols="90">{$DEFAULT_CONTENT}</textarea>
Note: See TracChangeset for help on using the changeset viewer.