Dotclear


Ignore:
Timestamp:
07/09/12 14:44:20 (13 years ago)
Author:
JcDenis
Branch:
default
Message:

Clean up structure, added (un)zip to flat import/export, fixes #1319

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/importExport/index.php

    r696 r840  
    22# -- BEGIN LICENSE BLOCK --------------------------------------- 
    33# 
    4 # This file is part of Dotclear 2. 
     4# This file is part of importExport, a plugin for DotClear2. 
    55# 
    6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2012 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1212if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    1313 
    14 require dirname(__FILE__).'/inc/class.dc.ieModule.php'; 
     14function listImportExportModules($core,$modules) 
     15{ 
     16     $res = ''; 
     17     foreach ($modules as $id) 
     18     { 
     19          $o = new $id($core); 
     20           
     21          $res .=  
     22          '<dt><a href="'.$o->getURL(true).'">'.html::escapeHTML($o->name).'</a></dt>'. 
     23          '<dd>'.html::escapeHTML($o->description).'</dd>'; 
     24           
     25          unset($o); 
     26     } 
     27     return '<dl class="modules">'.$res.'</dl>'; 
     28} 
    1529 
    16 $modules = new ArrayObject(); 
    17 $modules['i'] = new ArrayObject(array( 
    18      'dcImportFlat' => dirname(__FILE__).'/inc/class.dc.import.flat.php', 
    19      'dcImportFeed' => dirname(__FILE__).'/inc/class.dc.import.feed.php' 
    20 )); 
    21 $modules['e'] = new ArrayObject(array( 
    22      'dcExportFlat' => dirname(__FILE__).'/inc/class.dc.export.flat.php' 
    23 )); 
    24  
    25 if ($core->auth->isSuperAdmin()) { 
    26      $modules['i']['dcImportDC1']  = dirname(__FILE__).'/inc/class.dc.import.dc1.php'; 
    27      $modules['i']['dcImportWP']  = dirname(__FILE__).'/inc/class.dc.import.wp.php'; 
    28 } 
     30$modules = new ArrayObject(array('import' => array(),'export' => array())); 
    2931 
    3032# --BEHAVIOR-- importExportModules 
     
    3234 
    3335$type = null; 
    34 if (!empty($_REQUEST['t']) && ($_REQUEST['t'] == 'e' || $_REQUEST['t'] == 'i')) { 
    35      $type = $_REQUEST['t']; 
     36if (!empty($_REQUEST['type'])  && in_array($_REQUEST['type'],array('export','import'))) { 
     37     $type = $_REQUEST['type']; 
    3638} 
    3739 
    38 $current_module = null; 
    39 if ($type && !empty($_REQUEST['f'])) { 
    40      if (isset($modules[$type][$_REQUEST['f']])) { 
    41           require_once $modules[$type][$_REQUEST['f']]; 
    42           $current_module = new $_REQUEST['f']($core); 
    43           $current_module->init(); 
     40$module = null; 
     41if ($type && !empty($_REQUEST['module'])) { 
     42 
     43     if (isset($modules[$type]) && in_array($_REQUEST['module'],$modules[$type])) { 
     44      
     45          $module = new $_REQUEST['module']($core); 
     46          $module->init(); 
    4447     } 
    4548} 
    4649 
    47 if ($type && $current_module !== null && !empty($_REQUEST['do'])) 
     50if ($type && $module !== null && !empty($_REQUEST['do'])) 
    4851{ 
    4952     try { 
    50           $current_module->process($_REQUEST['do']); 
     53          $module->process($_REQUEST['do']); 
    5154     } catch (Exception $e) { 
    5255          $core->error->add($e->getMessage()); 
    5356     } 
    5457} 
    55 ?> 
     58 
     59$title = __('Import/Export'); 
     60 
     61echo ' 
    5662<html> 
    5763<head> 
    58      <title><?php echo __('Import/Export'); ?></title> 
    59      <style type="text/css"> 
    60      dl.modules dt { 
    61           font-weight: bold; 
    62           font-size: 1.1em; 
    63           margin: 1em 0 0 0; 
    64      } 
    65      dl.modules dd { 
    66           margin: 0 0 1.5em 0; 
    67      } 
    68      div.ie-progress { 
    69           background: #eee; 
    70           margin: 1em 0; 
    71      } 
    72      div.ie-progress div { 
    73           height: 10px; 
    74           width: 0; 
    75           font-size: 0.8em; 
    76           line-height: 1em; 
    77           height: 1em; 
    78           padding: 2px 0; 
    79           text-align: right; 
    80           background: green url(index.php?pf=importExport/progress.png) repeat-x top left; 
    81           color: white; 
    82           font-weight: bold; 
    83           -moz-border-radius: 2px; 
    84      } 
    85      </style> 
    86      <script type="text/javascript" src="index.php?pf=importExport/script.js"></script> 
     64     <title>'.$title.'</title> 
     65     <link rel="stylesheet" type="text/css" href="index.php?pf=importExport/style.css" /> 
     66     '.dcPage::jsLoad('index.php?pf=importExport/js/script.js').' 
    8767     <script type="text/javascript"> 
    8868     //<![CDATA[ 
    89      dotclear.msg.please_wait = '<?php echo html::escapeJS(__("Please wait...")); ?>'; 
     69     '.dcPage::jsVar('dotclear.msg.please_wait',__('Please wait...')).' 
    9070     //]]> 
    9171     </script> 
    9272</head> 
    93 <body> 
     73<body>'; 
    9474 
    95 <?php 
    96 if ($type && $current_module !== null) 
    97 { 
    98      echo '<h2><a href="'.$p_url.'">'.__('Import/Export').'</a>'. 
    99      ' &rsaquo; <span class="page-title">'.html::escapeHTML($current_module->name).'</span></h2>'; 
     75if ($type && $module !== null) { 
     76     echo 
     77     '<h2><a href="'.$p_url.'">'.$title.'</a>'. 
     78     ' &rsaquo; <span class="page-title">'.html::escapeHTML($module->name).'</span></h2>'. 
     79     '<div id="ie-gui">'; 
    10080      
    101      echo '<div id="ie-gui">'; 
    102      $current_module->gui(); 
     81     $module->gui(); 
     82      
    10383     echo '</div>'; 
    10484} 
    105 else 
    106 { 
    107      echo '<h2 class="page-title">'.__('Import/Export').'</h2>'; 
    108      echo '<h3>'.__('Import').'</h3>'; 
    109       
    110      echo '<dl class="modules">'; 
    111      foreach ($modules['i'] as $k => $v) 
    112      { 
    113           require_once $v; 
    114           $o = new $k($core); 
    115            
    116           echo  
    117           '<dt><a href="'.$o->getURL(true).'">'.html::escapeHTML($o->name).'</a></dt>'. 
    118           '<dd>'.html::escapeHTML($o->description).'</dd>'; 
    119            
    120           unset($o); 
    121      } 
    122      echo '</dl>'; 
    123       
    124      echo '<h3>'.__('Export').'</h3>'; 
    125       
    126      echo '<dl class="modules">'; 
    127      foreach ($modules['e'] as $k => $v) 
    128      { 
    129           require_once $v; 
    130           $o = new $k($core); 
    131            
    132           echo  
    133           '<dt><a href="'.$o->getURL(true).'">'.html::escapeHTML($o->name).'</a></dt>'. 
    134           '<dd>'.html::escapeHTML($o->description).'</dd>'; 
    135            
    136           unset($o); 
    137      } 
    138      echo '</dl>'; 
     85else { 
     86     echo 
     87     '<h2 class="page-title">'.$title.'</h2>'. 
     88     '<h3>'.__('Import').'</h3>'.listImportExportModules($core,$modules['import']). 
     89     '<h3>'.__('Export').'</h3>'.listImportExportModules($core,$modules['export']); 
    13990} 
     91 
     92echo ' 
     93</body> 
     94</html>'; 
    14095?> 
    141  
    142 </body> 
    143 </html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map