[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/sitemgr/inc/ -> class.Modules_UI.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * --------------------------------------------                             *
   6      *  This program is free software; you can redistribute it and/or modify it *
   7      *  under the terms of the GNU General Public License as published by the   *
   8      *  Free Software Foundation; either version 2 of the License, or (at your  *
   9      *  option) any later version.                                              *
  10      \**************************************************************************/
  11  
  12      /* $Id: class.Modules_UI.inc.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14      class Modules_UI
  15      {
  16          var $common_ui;
  17          var $t;
  18          var $bo;
  19          var $acl;
  20          var $modules;
  21          var $errormsg;
  22  
  23          var $public_functions = array
  24          (
  25              'manage' => True,
  26              'findmodules' => True,
  27              'configure' => True
  28          );
  29  
  30  		function Modules_UI()
  31          {
  32              $this->common_ui =& CreateObject('sitemgr.Common_UI',True);
  33              $this->t = $GLOBALS['egw']->template;
  34              $this->bo = &$GLOBALS['Common_BO']->modules;
  35              $this->acl = &$GLOBALS['Common_BO']->acl;
  36              $this->catbo = &$GLOBALS['Common_BO']->cats;
  37          }
  38  
  39  		function manage($msg = '')
  40          {
  41              if ($this->acl->is_admin())
  42              {
  43                  $GLOBALS['Common_BO']->globalize(array('btnselect','inputmodules','inputarea'));
  44                  global $btnselect,$inputmodules,$inputarea;
  45                  $cat_id = $_GET['cat_id'];
  46  
  47                  $this->modules = $this->bo->getallmodules();
  48  
  49                  if ($cat_id != CURRENT_SITE_ID)
  50                  {
  51                          $cat = $this->catbo->getCategory($cat_id);
  52                          $cat_name = $cat->name;
  53                          $managelink = $GLOBALS['egw']->link('/index.php','menuaction=sitemgr.Categories_UI.manage');
  54                          $goto = lang('Category manager');
  55                          $scopename = lang('Category');
  56                  }
  57                  else
  58                  {
  59                      $scopename = lang('Site');
  60                  }
  61  
  62                  $this->t->set_file('Managemodules', 'manage_modules.tpl');
  63                  $this->t->set_block('Managemodules','Contentarea','CBlock');
  64                  $this->t->set_var(array(
  65  //                    'module_manager' => lang('%1 module manager', $scopename),
  66                      'lang_help_module_manager' => lang('You can choose the modules that can be used on the site. The first list is a sort of master list, that is consulted if you do not configure lists specific to contentareas or (sub)categories. Then you can choose lists specific to each content area. In the category manager these lists can be overriden for each (sub)category.'),
  67                      'lang_findmodules' => lang('Register new modules'),
  68                      'lang_select_allowed_modules' => lang('Select allowed modules'),
  69                      'lang_configure_module_properties' => lang('Configure module properties'),
  70  //                    'cat_name' => ($cat_name ? (' - ' . $cat_name) : ''),
  71                      'managelink' => ($managelink ? ('<a href="' . $managelink . '">&lt; ' . lang('Go to') . ' ' . $goto . ' &gt;</a>') : ''),
  72                      'action_url' => $GLOBALS['egw']->link('/index.php',array('menuaction'=>'sitemgr.Modules_UI.manage','cat_id'=>$cat_id)),
  73                  ));
  74                  $link_data['cat_id'] = $cat_id;
  75                  $link_data['menuaction'] = "sitemgr.Modules_UI.findmodules";
  76                  $this->t->set_var('findmodules', $GLOBALS['egw']->link('/index.php',$link_data));
  77                  $link_data['menuaction'] = "sitemgr.Modules_UI.configure";
  78                  $this->t->set_var('configureurl', $GLOBALS['egw']->link('/index.php',$link_data));
  79                  $contentareas = $GLOBALS['Common_BO']->content->getContentAreas();
  80                  if (!is_array($contentareas))
  81                  {
  82                      $contentareas = array();
  83                  }
  84                  array_unshift($contentareas,'__PAGE__');
  85  
  86                  if ($btnselect)
  87                  {
  88                      $this->bo->savemodulepermissions($inputarea,$cat_id,$inputmodules);
  89                  }
  90  
  91                  foreach ($contentareas as $contentarea)
  92                  {
  93                      $permittedmodulesconfigured = $this->bo->getpermittedmodules($contentarea,$cat_id);
  94                      $permittedmodulescascading = $this->bo->getcascadingmodulepermissions($contentarea,$cat_id);
  95  
  96                      $this->t->set_var(Array(
  97                          'title' => ($contentarea == '__PAGE__') ?
  98                              lang('Master list of permitted modules') :
  99                              lang('List of permitted modules specific to content area %1',$contentarea),
 100                          'contentarea' => $contentarea,
 101                          'selectmodules' => $this->inputmoduleselect(array_keys($permittedmodulesconfigured)),
 102                          'configuremodules' => $this->inputmoduleconfigure($permittedmodulescascading),
 103                          'error' => ($contentarea == $inputarea && $this->errormsg) ? $this->errormsg : '',
 104                      ));
 105                      $this->t->parse('CBlock','Contentarea', true);
 106                  }
 107                  $this->common_ui->DisplayHeader(lang('%1 module manager', $scopename).($cat_name ? (' - ' . $cat_name) : ''));
 108  
 109                  if (!empty($msg))
 110                  {
 111                      echo '<p style="color: red; text-align: center;">'.$msg."</p>\n";
 112                  }
 113  
 114                  $this->t->pfp('out', 'Managemodules');
 115              }
 116              else
 117              {
 118                  $this->common_ui->DisplayHeader();
 119  
 120                  echo lang("You must be an admin to manage module properties.") ."<br><br>";
 121              }
 122              $this->common_ui->DisplayFooter();
 123          }
 124  
 125  		function findmodules()
 126          {
 127              $new_modules = $this->bo->findmodules();
 128              $this->manage(count($new_modules) ? lang('Following new modules registed: %1',implode('<br>',$new_modules)) :
 129                  lang('No new modules found !!!'));
 130          }
 131  
 132  		function configure()
 133          {
 134              if ($this->acl->is_admin())
 135              {
 136                  $GLOBALS['Common_BO']->globalize(array('btnSaveProperties','btnDeleteProperties','inputmodule_id','inputarea','element'));
 137                  global $btnSaveProperties,$btnDeleteProperties,$inputarea,$inputmodule_id,$element;
 138  
 139                  if (!$inputmodule_id)
 140                  {
 141                      $this->errormsg = lang("You did not choose a module.");
 142                      $this->manage();
 143                      return;
 144                  }
 145                  $cat_id = $_GET['cat_id'];
 146  
 147                  if ($btnSaveProperties)
 148                  {
 149                      $this->bo->savemoduleproperties($inputmodule_id,$element,$inputarea,$cat_id);
 150                      $this->manage();
 151                      return;
 152                  }
 153                  elseif ($btnDeleteProperties)
 154                  {
 155                      $this->bo->deletemoduleproperties($inputmodule_id,$inputarea,$cat_id);
 156                      $this->manage();
 157                      return;
 158                  }
 159  
 160                  $this->common_ui->DisplayHeader();
 161                  
 162                  if ($cat_id != CURRENT_SITE_ID)
 163                  {
 164                          $cat = $this->catbo->getCategory($cat_id);
 165                          $cat_name = $cat->name;
 166                  }
 167  
 168                  $this->t->set_file('Editproperties', 'edit_properties.tpl');
 169                  $this->t->set_block('Editproperties','EditorElement','EBlock');
 170  
 171                  $module = $this->bo->getmodule($inputmodule_id);
 172                  $moduleobject =& $this->bo->createmodule($module['module_name']);
 173                  $blockcontext =& CreateObject('sitemgr.Block_SO',True);
 174                  $blockcontext->module_id = $inputmodule_id;
 175                  $blockcontext->area = $inputarea;
 176                  $blockcontext->cat_id = $cat_id;
 177                  $moduleobject->set_block($blockcontext);
 178  
 179                  $editorstandardelements = array(
 180                      array('label' => lang('Title'),
 181                              'form' => $moduleobject->title
 182                      )
 183                  );
 184                  $editormoduleelements = $moduleobject->properties ? $moduleobject->get_admin_interface() : False;
 185                  $interface = array_merge($editorstandardelements,$editormoduleelements);
 186                  while (list(,$element) = each($interface))
 187                  {
 188                      $this->t->set_var(Array(
 189                          'label' => $element['label'],
 190                          'form' => $element['form'])
 191                      );
 192                      $this->t->parse('EBlock','EditorElement', true);                
 193                  }
 194  
 195                  $this->t->set_var(Array(
 196                      'module_edit' => lang('Edit properties of module %1 for %2 with scope %3',
 197                          $module['module_name'],
 198                          ($inputarea == '__PAGE__' ? lang('the whole page') : (lang('Contentarea') . $inputarea)),
 199                          (($cat_id != CURRENT_SITE_ID) ? ('category ' . $cat_name) : ' the whole site')
 200                      ),
 201                      'module_id' => $inputmodule_id,
 202                      'contentarea' => $inputarea,
 203                      'savebutton' => ($editormoduleelements ? 
 204                          '<input type="submit" value="'.lang('Save').'" name="btnSaveProperties" />' :
 205                          lang('There are no properties defined for this module')
 206                      ),
 207                      'deletebutton' => $properties === False ? '' : '<input type="submit" value="'.lang('Delete').'" name="btnDeleteProperties" />',
 208                      'action_url' => $GLOBALS['egw']->link('/index.php',array('menuaction'=>'sitemgr.Modules_UI.configure','cat_id'=>$cat_id)),
 209                      )
 210                  );
 211                  $this->t->set_var('backlink',
 212                      '<a href="' . $GLOBALS['egw']->link('/index.php',array(
 213                          'menuaction' => 'sitemgr.Modules_UI.manage',
 214                          'cat_id' => $cat_id
 215                      )) . '">&lt; ' . lang('Back to module manager') . ' &gt;</a>'
 216                  );
 217  
 218                  $this->t->pfp('out', 'Editproperties');
 219              }
 220              else
 221              {
 222                  $this->common_ui->DisplayHeader();
 223                  echo lang("You must be an admin to manage module properties.") ."<br><br>";
 224              }
 225              $this->common_ui->DisplayFooter();
 226          }
 227  
 228  		function inputmoduleselect($permitted)
 229          {
 230              $returnValue = '';
 231              reset($this->modules);
 232              while (list($id,$module) = @each($this->modules))
 233              { 
 234                  $selected = (in_array($id,$permitted)) ? $selected = 'selected="selected" ' : '';
 235                  $returnValue.='<option title="' . lang($module['description']) . '" ' . $selected . 'value="' .$id . '">' .
 236                      $module['module_name'].'</option>'."\n";
 237              }
 238              return $returnValue;
 239          }
 240  
 241  		function inputmoduleconfigure($permitted)
 242          {
 243              $returnValue = '';
 244              while (list($id,$module) = @each($permitted))
 245              { 
 246                  $returnValue.='<option title="' . lang($module['description']) . '" value="'.$id.'">'.
 247                      $module['module_name'].'</option>'."\n";
 248              }
 249              return $returnValue;
 250          }
 251      }


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