[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/mydms/inc/ -> class.uifolder.inc.php (source)

   1  <?php
   2      /***************************************************************************\
   3      * eGroupWare - mydms                                                        *
   4      * http://www.linux-at-work.de                                               *
   5      * http://www.phpgw.de                                                       *
   6      * http://www.egroupware.org                                                 *
   7      * Written by : Lars Kneschke [lkneschke@linux-at-work.de]                   *
   8      * -------------------------------------------------                         *
   9      * This program is free software; you can redistribute it and/or modify it   *
  10      * under the terms of the GNU General Public License as published by the     *
  11      * Free Software Foundation; version 2 of the License.                       *
  12      \***************************************************************************/
  13      
  14      /* $Id: class.uifolder.inc.php 22761 2006-10-28 07:42:00Z lkneschke $ */
  15  
  16      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.Settings.php');
  17      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.DBAccess.php');
  18      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.AccessUtils.php');
  19      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.ClassAccess.php');
  20      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.ClassUser.php');
  21      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.ClassGroup.php');
  22      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.ClassFolder.php');
  23      require_once (EGW_SERVER_ROOT.'/mydms/inc/inc.ClassDocument.php');
  24  
  25      class uifolder
  26      {
  27          var $public_functions = array
  28          (
  29              'copyFolder'        => 'true',
  30              'getInitialFolderView'    => 'true',
  31              'getSubFolder'        => 'true',
  32          );
  33          
  34  		function uifolder() {
  35              $this->charset  = $GLOBALS['egw']->translation->charset();
  36          }
  37          
  38  		function copyFolder()
  39          {
  40              if(isset($_GET['folderid']) && isset($_POST['targetid']) && isset($_POST['copy']))
  41              {
  42                  $bo    =& CreateObject('mydms.bofolder');
  43                  
  44                  $folderID = (int)$_GET['folderid'];
  45                  $targetID = (int)$_POST['targetid'];
  46                  $newFolderName = $_POST['newfoldername'];
  47                  
  48                  //var_export($_POST);
  49                  //options
  50                  $copySubFolder = ($_POST['copy_subfolder'] == 'on' ? true : false);
  51                  $copyDocuments = ($_POST['copy_documents'] == 'on' ? true : false);
  52                  
  53                  if($newFolder = $bo->copyFolder($folderID, $targetID, $newFolderName, $copySubFolder, $copyDocuments))
  54                  {
  55                      $newFolderID = $newFolder->getID();
  56                  }
  57                  else
  58                  {
  59                      $newFolderID = 1;
  60                  }
  61                  $GLOBALS['egw']->redirect_link('/mydms/out/out.ViewFolder.php','folderid=' . $newFolderID);
  62              }
  63              elseif(isset($_GET['folderid']) && isset($_POST['cancel']))
  64              {
  65                  $folderID = ((int)$_GET['folderid'] > 0 ? (int)$_GET['folderid'] : 1);
  66                  // redirect
  67                  $GLOBALS['egw']->redirect_link('/mydms/out/out.ViewFolder.php','folderid=' . $folderID);
  68              }
  69  
  70              $t     =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
  71  
  72              $folderID = (int)$_GET['folderid'];
  73              $formName = $_GET['form'];
  74              
  75              $folder = getFolder($folderID);
  76              $parent = $folder->getParent();
  77  
  78              $this->display_app_header();
  79              $this->translate($t);
  80          
  81              $t->set_file(array("copyFolder" => "copyFolder.tpl"));
  82              $t->set_block('copyFolder', 'main', 'main');
  83  
  84              $t->set_var('current_folder_id',$folderID);
  85              $t->set_var('newfoldername',$folder->getName());
  86  
  87              $t->set_var('foldername',$parent->getName());
  88              $t->set_var('folderid',$parent->getID());
  89              
  90              $linkData = array
  91              (
  92                  'menuaction'    => 'mydms.uimydms.folderChooser',
  93              );
  94              $t->set_var('folderChooserURL', $GLOBALS['egw']->link('/index.php',$linkData));
  95  
  96              $linkData = array
  97              (
  98                  'menuaction'    => 'mydms.uimydms.folderChooser',
  99              );
 100              $t->set_var('folderChooserURL', $GLOBALS['egw']->link('/index.php',$linkData));
 101  
 102              $linkData = array
 103              (
 104                  'menuaction'    => 'mydms.uifolder.copyFolder',
 105                  'folderid'    => $folderID,
 106              );
 107              $t->set_var('form_action', $GLOBALS['egw']->link('/index.php',$linkData));
 108  
 109              $t->parse("out","main");
 110              
 111              print $t->get('out','main');
 112          }
 113          
 114  		function display_app_header()
 115          {
 116              if(!@is_object($GLOBALS['egw']->js))
 117              {
 118                  $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
 119              }
 120              if (!is_object($GLOBALS['egw']->jscalendar))
 121              {
 122                  $GLOBALS['egw']->jscalendar = CreateObject('phpgwapi.jscalendar');
 123              }
 124              $GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
 125              $GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
 126              $GLOBALS['egw']->js->validate_file('jscode','mydms','mydms');
 127  
 128              $GLOBALS['egw_info']['flags']['include_xajax'] = True;
 129  
 130              $GLOBALS['egw']->common->egw_header();
 131              
 132              echo parse_navbar();
 133          }
 134  
 135  		function generateXML($_folder, $_childID, $_targetID, $_childContent) {
 136              
 137              $subFolders = $_folder->getSubFolders();
 138              
 139              foreach((array)$subFolders as $subFolderObject) {
 140                  $subFolderID    = $subFolderObject->getID();
 141                  $subFolderName    = htmlspecialchars($subFolderObject->getName(), ENT_QUOTES, $this->charset);
 142                  $hasSubfolder    = ($subFolderObject->getSubFolders() ? 1 : 0);
 143                  $childContent    = ($subFolderID == $_childID ? $_childContent : '');
 144                  $selectedNode    = ($subFolderID == $_targetID ? " select='1'" : '');
 145                  $openNode    = ($subFolderID == $_childID ? " open='1'" : '');
 146                  $retValue .="<item child='$hasSubfolder' id='$subFolderID' text='$subFolderName' im0='folderClosed.gif'$selectedNode$openNode>$childContent</item>";
 147              }
 148  
 149              return $retValue;
 150          }
 151          
 152  		function getInitialFolderView()
 153          {
 154              header("Content-type:text/xml"); 
 155              print("<?xml version=\"1.0\" encoding=\"$this->charset\"?>");
 156              
 157              if (isset($_GET["id"]))
 158                  $folderID=$_GET["id"];
 159              else
 160                  $folderID=1;
 161  
 162              if($folderObject = getFolder($folderID)) {
 163              
 164                  $path = $folderObject->getPathNew();
 165              
 166                  $xmlContent    = '';
 167                  $clientID    = $folderID;
 168              
 169                  // skip the last path part
 170                  array_pop($path);
 171  
 172                  while($subFolder = array_pop($path)) {
 173                      $xmlContent    = $this->generateXML($subFolder, $clientID, $folderID, $xmlContent);
 174                      $clientID    = $subFolder->getID();
 175                  }
 176  
 177              }
 178              print "<tree id='$clientID'>$xmlContent</tree>";
 179              
 180              $GLOBALS['egw']->common->egw_exit();
 181          }
 182              
 183  		function getSubFolder()
 184          {
 185              header("Content-type:text/xml");
 186              print("<?xml version=\"1.0\" encoding=\"$this->charset\"?>");
 187              if (isset($_GET["id"]))
 188                  $folderID=$_GET["id"];
 189              else
 190                  $folderID=1;
 191  
 192              print("<tree id='".$folderID."'>");
 193  
 194              if($folderObject = getFolder($folderID)) {
 195              
 196                  $subFolders = $folderObject->getSubFolders();
 197              
 198  
 199                  foreach((array)$subFolders as $subFolderObject) {
 200                      $subFolderID    = $subFolderObject->getID();
 201                      $subFolderName    = htmlspecialchars($subFolderObject->getName(), ENT_QUOTES, $this->charset);
 202                      $hasSubfolder    = ($subFolderObject->getSubFolders() ? 1 : 0);
 203                      print("<item child='$hasSubfolder' id='$subFolderID' text='$subFolderName' im0='folderClosed.gif'></item>");
 204                  }
 205  
 206              }
 207  
 208              print("</tree>");
 209  
 210              $GLOBALS['egw']->common->egw_exit();
 211          }
 212  
 213  		function translate(&$template)
 214          {
 215              $template->set_var('lang_cancel',lang('cancel'));
 216              $template->set_var('lang_copy',lang('copy'));
 217              $template->set_var('lang_copy_documents',lang('copy documents'));
 218              $template->set_var('lang_copy_options',lang('copy options'));
 219              $template->set_var('lang_copy_subfolders',lang('copy subfolders'));
 220              $template->set_var('lang_folder',lang('folder'));
 221              $template->set_var('lang_name',lang('name'));
 222              $template->set_var('lang_select_folder',lang('select folder'));
 223              $template->set_var('lang_select_target_folder',lang('Select target folder'));
 224              $template->set_var('lang_target_folder',lang('target folder'));
 225          }
 226      }
 227  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7