[ Index ]
 

Code source de SugarCRM 5.0.0beta1

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

title

Body

[fermer]

/ModuleInstall/PackageManager/ -> PackageManagerDisplay.php (source)

   1  <?php
   2  /*********************************************************************************

   3   * SugarCRM is a customer relationship management program developed by

   4   * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.

   5   * 

   6   * This program is free software; you can redistribute it and/or modify it under

   7   * the terms of the GNU General Public License version 3 as published by the

   8   * Free Software Foundation.

   9   * 

  10   * This program is distributed in the hope that it will be useful, but WITHOUT

  11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

  12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more

  13   * details.

  14   * 

  15   * You should have received a copy of the GNU General Public License along with

  16   * this program; if not, see http://www.gnu.org/licenses or write to the Free

  17   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

  18   * 02110-1301 USA.

  19   * 

  20   * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,

  21   * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.

  22   * 

  23   * The interactive user interfaces in modified source and object code versions

  24   * of this program must display Appropriate Legal Notices, as required under

  25   * Section 5 of the GNU General Public License version 3.

  26   * 

  27   * In accordance with Section 7(b) of the GNU General Public License version 3,

  28   * these Appropriate Legal Notices must retain the display of the "Powered by

  29   * SugarCRM" logo. If the display of the logo is not reasonably feasible for

  30   * technical reasons, the Appropriate Legal Notices must display the words

  31   * "Powered by SugarCRM".

  32   ********************************************************************************/
  33  require_once ('include/Sugar_Smarty.php');
  34  require_once ('data/SugarBean.php');
  35  require_once ('ModuleInstall/PackageManager/PackageManager.php');
  36  require_once ('include/utils.php');
  37  require_once ('include/ytree/Tree.php');
  38  require_once ('include/ytree/Node.php');
  39  require_once ('ModuleInstall/PackageManager/ListViewPackages.php');
  40  class PackageManagerDisplay{
  41     
  42     /** 

  43       * A Static method to Build the display for the package manager

  44       *

  45       * @param String form1 - the form to display for manual downloading 

  46       * @param String hidden_fields - the hidden fields related to downloading a package

  47       * @param String form_action - the form_action to be used when downloading from the server

  48       * @param String types - the types of objects we will request from the server

  49       * @param String active_form - the form to display first   

  50       * @return String - a string of html which will be used to display the forms

  51       */
  52      function buildPackageDisplay($form1, $hidden_fields, $form_action, $types = array('module'), $active_form = 'form1', $install = false){
  53          $mod_strings = return_module_language('en', "Administration");
  54          global $app_strings;
  55          global $sugar_version, $sugar_config;
  56          global $theme;
  57          if(empty($theme)){
  58              $theme = 'Sugar';   
  59          }
  60          $theme_path="themes/".$theme."/";
  61          $image_path=$theme_path."images/";
  62          $app_strings = return_application_language('en_us');
  63          $ss = new Sugar_Smarty();
  64          $ss->assign('FORM_1_PLACE_HOLDER', $form1);
  65          $ss->assign('form_action', $form_action);
  66          $ss->assign('hidden_fields', $hidden_fields);
  67          
  68          $result = PackageManagerDisplay::getHeader();
  69          $header_text = $result['text'];
  70          $isAlive = $result['isAlive'];
  71          $show_login = $result['show_login'];
  72          $mi_errors = ModuleInstaller::getErrors();
  73          $error_html = "";
  74          if(!empty($mi_errors)){
  75              $error_html = "<tr><td><span>";
  76              foreach($mi_errors as $error){
  77                  $error_html .= "<font color='red'>".$error."</font><br>";
  78              }
  79              $error_html .= "</span></td></tr>";
  80          }
  81          $form2 = "<table  class='tabForm' width='100%'  cellpadding='0' cellspacing='0' width='100%' border='0'>";
  82          $form2 .= $error_html;
  83          $form2 .= "<tr><td><span id='span_display_html'>".$header_text."</span></td></tr>";
  84          $form2 .= "</table>";
  85          
  86          $tree = null;
  87          //if($isAlive){

  88              $tree = PackageManagerDisplay::buildTreeView('treeview', $isAlive);
  89              $tree->tree_style= 'include/ytree/TreeView/css/check/tree.css';   
  90              $ss->assign('TREEHEADER',$tree->generate_header());
  91          //}

  92          //$form2 .= PackageManagerDisplay::buildLoginPanel($mod_strings);

  93          $form2 .= "<table  class='tabForm' cellpadding='0' cellspacing='0' width='100%' border='0'>";
  94          $form2 .= "<tr><td></td><td align='left'><div id='workingStatusDiv' style='display:none'>".get_image($image_path."sqsWait","border='0' align='bottom'")."</div></td><td align='right'>";
  95          if($show_login){
  96              $form2 .= "<a href='javascript:void(0);' onClick='PackageManager.showLoginDialog(true);'>".$mod_strings['LBL_MODIFY_CREDENTIALS']."</a>";
  97          }
  98          $form2 .= "</td><td align='right'><slot><a class=\"listViewTdToolsS1\" id='href_animate' onClick=\"PackageManager.toggleDiv('span_animate_server_div', 'catview');\"><span id='span_animate_server_div'><img src='themes/Sugar/images/basic_search.gif' width='8' height='8' border='0'>&nbsp;Collapse</span></a></slot></td></tr>";
  99          $form2 .= "</table>";
 100  
 101          $ss->assign('installation', ($install ? 'true' : 'false'));
 102          
 103         
 104         $mod_strings = return_module_language('en', "Administration");
 105  
 106          $ss->assign('MOD', $mod_strings);
 107          $ss->assign('module_load', 'true');
 108          $ss->assign('scripts', PackageManagerDisplay::getDisplayScript($install));
 109          $ss->assign('MODULE_SELECTOR', PackageManagerDisplay::buildGridOutput($tree, $mod_strings, $isAlive, $show_login));
 110         $ss->assign('FORM_2_PLACE_HOLDER', $form2);
 111          $ss->assign('MOD', $mod_strings);
 112          $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'];
 113          $ss->assign('INSTALLED_PACKAGES_HOLDER', PackageManagerDisplay::buildInstalledGrid($mod_strings, $types));
 114         
 115     $str = $ss->fetch('ModuleInstall/PackageManager/tpls/PackageForm.tpl'); 
 116        return $str;
 117      }
 118      
 119      /** 

 120       * A Static method to Build the display for the package manager

 121       *

 122       * @param String form1 - the form to display for manual downloading 

 123       * @param String hidden_fields - the hidden fields related to downloading a package

 124       * @param String form_action - the form_action to be used when downloading from the server

 125       * @param String types - the types of objects we will request from the server

 126       * @param String active_form - the form to display first   

 127       * @return String - a string of html which will be used to display the forms

 128       */
 129      function buildPatchDisplay($form1, $hidden_fields, $form_action, $types = array('module'), $active_form = 'form1'){
 130          $mod_strings = return_module_language('en', "Administration");
 131          global $theme;
 132          if(empty($theme)){
 133              $theme = 'Sugar';   
 134          }
 135          $theme_path="themes/".$theme."/";
 136          $image_path=$theme_path."images/";
 137          $ss = new Sugar_Smarty();
 138          $ss->assign('FORM_1_PLACE_HOLDER', $form1);
 139          $ss->assign('form_action', $form_action);
 140          $ss->assign('hidden_fields', $hidden_fields);
 141          $mod_strings = return_module_language('en', "Administration");
 142  
 143          $ss->assign('MOD', $mod_strings);
 144          $result = PackageManagerDisplay::getHeader();
 145          $header_text = $result['text'];
 146          $isAlive = $result['isAlive'];
 147          $show_login = $result['show_login'];
 148          $display = 'none';
 149          //if($isAlive){

 150              $display = 'block';
 151          //}

 152          $form2 = "<table  class='tabForm' width='100%'  cellpadding='0' cellspacing='0' width='100%' border='0'>";
 153          $form2 .= "<tr><td><span id='span_display_html'>".$header_text."</span></td></tr>";
 154          $form2 .= "</table>";
 155          $form2 .= "<table width='100%'><tr><td align='right'><div id='workingStatusDiv' style='display:none'>".get_image($image_path."sqsWait","border='0' align='bottom'")."</div></td><td align='right'>";
 156          if($show_login){
 157              $form2 .= "<a href='javascript:void(0);' onClick='PackageManager.showLoginDialog(true);'>".$mod_strings['LBL_MODIFY_CREDENTIALS']."</a>";
 158          }
 159          $form2 .= "</td></tr><tr><td colspan='2'>";
 160          $loginViewStyle = ($isAlive ? 'none' : 'block');
 161          $selectViewStyle = ($isAlive ? 'block' : 'none');
 162          $form2 .= "<div id='selectView' style='display:".$selectViewStyle."'>";
 163          $form2 .= "  <div id='patch_downloads' class='ygrid-mso' style='height:205px; display: ".$display.";'></div>";
 164           $form2 .= "</div>"; 
 165           if(!$show_login)
 166               $loginViewStyle = 'none';
 167           $form2 .= "<div id='loginView' style='display:".$loginViewStyle."'>";
 168           $form2 .= PackageManagerDisplay::buildLoginPanel($mod_strings, $isAlive);
 169           $form2 .= "</div>";
 170        
 171          $form2 .= "</td></tr></table>";
 172          $packages = array();
 173          $releases = array();
 174          if($isAlive){
 175                $filter = array();
 176                $count = count($types);
 177                $index = 1;
 178                $type_str = '"';
 179                foreach($types as $type){
 180                    $type_str .= "'".$type."'";
 181                    if($index < $count)
 182                        $type_str .= ",";
 183                    $index++;
 184                }
 185                $type_str .= '"';
 186                $filter = array('type' => $type_str);
 187                $filter = PackageManager::toNameValueList($filter);
 188              $pm = new PackageManager();
 189              /*if(in_array('patch', $types)){

 190                  $releases = $pm->getReleases('3', '3', $filter);

 191              }else{

 192                  $releases = $pm->getReleases('', '', $filter);

 193              }*/
 194          }
 195          if($form_action == 'install.php' && (empty($releases) || count($releases['packages']) == 0)){
 196              //return false;

 197          }
 198          $ss->assign('module_load', 'false');
 199          $ss->assign('MODULE_SELECTOR', '');
 200          $ss->assign('FORM_2_PLACE_HOLDER', $form2);      
 201          $ss->assign('scripts', PackageManagerDisplay::getDisplayScript(false, 'patch', $releases, $types, $isAlive));
 202          $str = $ss->fetch('ModuleInstall/PackageManager/tpls/PackageForm.tpl'); 
 203          return $str;
 204      }
 205      
 206      function buildInstalledGrid($mod_strings, $types = array('modules')){
 207            $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'];
 208            $output = '<table width="100%" border="0" cellspacing="0" cellpadding="0" ><tr><td align="left">'.$descItemsInstalled.'</td>';
 209            $output .= '</td></tr></table>';
 210            $output .= "<table width='100%' class='moduleTitle' border=1><tr><td class='leftColumn'><div id='installed_grid' class='ygrid-mso' style='height:205px;'></div></td></tr></table>";
 211            return $output;
 212      }
 213      
 214      function buildLoginPanel($mod_strings, $display_cancel){
 215          $credentials = PackageManager::getCredentials();
 216          $output = "<div id='login_panel'><div class='hd'><b>".$mod_strings['HDR_LOGIN_PANEL']."</b></div>";
 217          $output .= "<div class='bd'><form><table><tr><td>".$mod_strings['LBL_USERNAME']."</td><td><input type='text' name='login_panel_username' id='login_panel_username' value='".$credentials['username']."'></td><td><a href='http://www.sugarcrm.com/crm/index.php?option=com_registration&task=register' target='blank'>".$mod_strings['LNK_NEW_ACCOUNT']."</a></td>";
 218  
 219          $output .= "</tr><tr><td>".$mod_strings['LBL_PASSWORD']."</td><td><input type='password' name='login_panel_password' id='login_panel_password'></td><td><a href='http://www.sugarcrm.com/crm/component/option,com_registration/Itemid,0/task,lostPassword/' target='blank'>".$mod_strings['LNK_FORGOT_PASS']."</a></td>";
 220  
 221          $terms = PackageManager::getTermsAndConditions();
 222          $output .= "</tr><tr><td colspan='6' valign='top'><b>".$mod_strings['LBL_TERMS_AND_CONDITIONS']."</b><br><textarea readonly cols=80 rows=8>" . $terms['terms'] . '</textarea></td>';
 223             $_SESSION['SugarDepot_TermsVersion'] = (!empty($terms['version']) ? $terms['version'] : '');
 224  
 225          $output .= "</td></tr><tr><td colspan='6'><input class='checkbox' type='checkbox' name='cb_terms' id='cb_terms' onclick='if(this.checked){this.form.panel_login_button.disabled=false;}else{this.form.panel_login_button.disabled=true;}'>".$mod_strings['LBL_ACCEPT_TERMS']."</td></tr><tr><td></td>";
 226          $output .= "<td>";
 227          $output .= "<input type='button' id='panel_login_button' name='panel_login_button' value='Login' class='button' onClick='PackageManager.authenticate(this.form.login_panel_username.value, this.form.login_panel_password.value, \"\",\"" . $terms['version'] . "\");' disabled>";
 228          
 229          if($display_cancel){
 230              $output .= "&nbsp;<input type='button' id='panel_cancel_button' value='Cancel' class='button' onClick='PackageManager.showLoginDialog(false);'>";
 231          }
 232          $output .= "</td></tr>";
 233          $output .= "<tr></td><td></td></tr>";
 234          $output .= "</table></div>";
 235          $output .= "<div class='ft'></div></form></div>";  
 236          return $output;  
 237      }
 238      
 239      /**

 240       *  Build html in order to display the grids relevant for module loader

 241       * 

 242       *  @param Tree tree - the tree which we are using to display the categories 

 243       *  @param Array mod_strings - the local mod strings to display

 244       *  @return String - a string of html

 245       */
 246  	function buildGridOutput($tree, $mod_strings, $display = true, $show_login = true){
 247           global $theme;
 248          if(empty($theme)){
 249              $theme = 'Sugar';   
 250          }
 251          $theme_path="themes/".$theme."/";
 252          $image_path=$theme_path."images/";
 253          $output = "<div id='catview'>";
 254          $loginViewStyle = ($display ? 'none' : 'block');
 255          $selectViewStyle = ($display ? 'block' : 'none');
 256          $output .= "<div id='selectView' style='display:".$selectViewStyle."'>";
 257           //if($display){            

 258              $output .= "<table border=0 width='100%' class='moduleTitle'><tr><td width='100%' valign='top' class='leftColumn'>";
 259              $output .= "<div id='treeview'>";
 260              $output .= $tree->generate_nodes_array();
 261              $output .= "</div>";           
 262              $output .= "</td></tr>"; 
 263              $output .= "<tr><td width='100%'>"; 
 264              $output .= "<div id='tabs1'></div>"; 
 265              $output .= "</td></tr>";
 266              $output .= "<tr><td width='100%' align='right'>";
 267              $output .= "<input type='button' class='button' value='Download Selected' onClick='PackageManager.download();'>";
 268              $output .= "</td></tr></table>"; 
 269          // }

 270           $output .= "</div>"; 
 271           if(!$show_login)
 272               $loginViewStyle = 'none';
 273           $output .= "<div id='loginView' style='display:".$loginViewStyle."'>";
 274           $output .= PackageManagerDisplay::buildLoginPanel($mod_strings, $display);
 275           $output .= "</div>";
 276           //$output .= "<table width='100%' class='moduleTitle' border=1><tr><td class='leftColumn'><div id='patch_downloads' class='ygrid-mso' style='height:205px;'></div></td></tr></table>";  

 277          $output .= "</div>";
 278                        
 279          return $output;
 280      }
 281      
 282       /** 

 283       * A Static method used to build the initial treeview when the page is first displayed

 284       *

 285       * @param String div_id - this div in which to display the tree   

 286       * @return Tree - the tree that is built

 287       */
 288      function buildTreeView($div_id, $isAlive = true){       
 289          $tree = new Tree($div_id);
 290          $nodes = array();
 291          if($isAlive)
 292              $nodes = PackageManager::getCategories('');
 293  
 294          foreach($nodes as $arr_node){
 295              $node = new Node($arr_node['id'], $arr_node['label']);
 296              $node->dynamicloadfunction = 'PackageManager.loadDataForNodeForPackage';
 297              $node->expanded = false;
 298              $node->dynamic_load = true;
 299              $node->set_property('href',"javascript:PackageManager.catClick('treeview');");
 300              $tree->add_node($node);  
 301              $node->set_property('description', $arr_node['description']);        
 302          }
 303          return $tree;
 304      }
 305      
 306      /** 

 307       * A Static method used to obtain the div for the license

 308       *

 309       * @param String license_file - the path to the license file

 310       * @param String form_action - the form action when accepting the license file

 311       * @param String next_step - the value for the next step in the installation process

 312       * @param String zipFile - a string representing the path to the zip file

 313       * @param String type - module/patch....

 314       * @param String manifest - the path to the manifest file

 315       * @param String modify_field - the field to update when the radio button is changed

 316       * @return String - a form used to display the license

 317       */
 318      function getLicenseDisplay($license_file, $form_action, $next_step, $zipFile, $type, $manifest, $modify_field){
 319          $mod_strings = return_module_language('en', "Administration");
 320          $fh = fopen($license_file, 'r');
 321          $contents = fread($fh, filesize($license_file));
 322          fclose($fh);
 323          $div_id = urlencode($zipFile);
 324          $display = "<form name='delete{$zipFile}' action='{$form_action}' method='POST'>";
 325          $display .= "<input type='hidden' name='current_step' value='{$next_step}'>";
 326          $display .= "<input type='hidden' name='languagePackAction' value='{$type}'>";
 327          $display .= "<input type='hidden' name='manifest' value='\".urlencode($manifest).\"'>";
 328          $display .= "<input type='hidden' name='zipFile' value='\".urlencode($zipFile).\"'>";
 329          $display .= "<table><tr>";
 330          $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
 331          $display .= "<b><font color='red' >{$mod_strings['LBL_MODULE_LICENSE']}</font></b>";
 332          $display .= "</td>";
 333          $display .= "<td>";
 334          $display .= "<slot><a class=\"listViewTdToolsS1\" id='href_animate' onClick=\"PackageManager.toggleLowerDiv('span_animate_div_$div_id', 'span_license_div_$div_id', 350, 0);\"><span id='span_animate_div_$div_id'<img src='themes/Sugar/images/advanced_search.gif' width='8' height='8' alt='Advanced' border='0'>&nbsp;Expand</span></a></slot></td>";
 335          $display .= "</td>";
 336          $display .= "</tr>";
 337          $display .= "</table>";
 338          $display .= "<div id='span_license_div_$div_id' style=\"display: none;\">";
 339          $display .= "<table>";
 340          $display .= "<tr>";
 341          $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
 342          $display .= "<textarea cols=\"100\" rows=\"8\">{$contents}</textarea>";  
 343          $display .= "</td>";
 344          $display .= "</tr>";
 345          $display .= "<tr>";
 346          $display .= "<td align=\"left\" valign=\"top\" colspan=2>";
 347          $display .= "<input type='radio' id='radio_license_agreement_accept' name='radio_license_agreement' value='accept' onClick=\"document.getElementById('$modify_field').value = 'yes';\">{$mod_strings['LBL_ACCEPT']}&nbsp;";
 348          $display .= "<input type='radio' id='radio_license_agreement_reject' name='radio_license_agreement' value='reject' checked onClick=\"document.getElementById('$modify_field').value = 'no';\">{$mod_strings['LBL_DENY']}";
 349          $display .= "</td>";
 350          $display .= "</tr>";
 351          $display .= "</table>";
 352          $display .= "</div>";
 353          $display .= "</form>";
 354          return $display;
 355      }
 356   
 357       /** 

 358       * A Static method used to generate the javascript for the page

 359       *

 360       * @return String - the javascript required for the page

 361       */
 362      function getDisplayScript($install = false, $type = 'module', $releases = null, $types = array(), $isAlive = true){
 363          global $sugar_version, $sugar_config;
 364          global $theme;
 365          if(empty($theme)){
 366              $theme = 'Sugar';   
 367          }
 368          $theme_path="themes/".$theme."/";
 369          $image_path=$theme_path."images/";
 370          $mod_strings = return_module_language('en', "Administration");
 371          $ss = new Sugar_Smarty();
 372          $ss->assign('MOD', $mod_strings);
 373          if(!$install){
 374              $install = 0;   
 375          }
 376          $ss->assign('INSTALLATION', $install);
 377          $ss->assign('WAIT_IMAGE', get_image($image_path."loading","border='0' align='bottom'"));
 378          $ss->assign('sugar_version', $sugar_version);
 379          $ss->assign('js_custom_version', $sugar_config['js_custom_version']);
 380           $ss->assign('IS_ALIVE', $isAlive);   
 381          //if($type == 'patch' && $releases != null){

 382          if($type == 'patch'){
 383              $ss->assign('module_load', 'false');
 384              $patches = PackageManagerDisplay::createJavascriptPackageArray($releases);
 385              $ss->assign('PATCHES', $patches);
 386               $ss->assign('GRID_TYPE', implode(',', $types));     
 387          }else{
 388                 $pm = new PackageManager();
 389                 $releases = $pm->getPackagesInStaging();
 390                 $patches = PackageManagerDisplay::createJavascriptModuleArray($releases);
 391              $ss->assign('PATCHES', $patches); 
 392              $installeds = $pm->getinstalledPackages();
 393                 $patches = PackageManagerDisplay::createJavascriptModuleArray($installeds, 'mti_installed_data');
 394              $ss->assign('INSTALLED_MODULES', $patches);
 395               $ss->assign('UPGARDE_WIZARD_URL', 'index.php?module=UpgradeWizard&action=index');
 396              $ss->assign('module_load', 'true');   
 397          }
 398          $str = $ss->fetch('ModuleInstall/PackageManager/tpls/PackageManagerScripts.tpl'); 
 399          return $str;        
 400      }
 401      
 402      function createJavascriptPackageArray($releases){
 403          $output = "var mti_data = [";
 404          $count = count($releases);
 405          $index = 1;
 406          if(!empty($releases['packages'])){
 407              foreach($releases['packages'] as $release){
 408                  $release = PackageManager::fromNameValueList($release);
 409                  $output .= "[";
 410                  $output .= "'".$release['description']."', '".$release['version']."', '".$release['build_number']."', '".$release['id']."'";                
 411                  $output .= "]"; 
 412                  if($index < $count) 
 413                      $output .= ",";
 414                  $index++;
 415              }   
 416          }
 417          $output .= "]\n;"; 
 418          return $output;  
 419      }
 420      
 421      function createJavascriptModuleArray($modules, $variable_name = 'mti_data'){
 422          $output = "var ".$variable_name." = [";
 423          $count = count($modules);
 424          $index = 1;
 425          if(!empty($modules)){
 426              foreach($modules as $module){
 427                  $output .= "[";
 428                  $output .= "'".$module['name']."', '".$module['type']."', '".$module['version']."', '".$module['published_date']."', '".$module['uninstallable']."', '".$module['description']."', '".$module['file_install']."', '".$module['file']."'";  
 429                  if(!empty($module['enabled']))
 430                      $output .= ", '".$module['enabled'].'_'.$module['file']."'";            
 431                  $output .= "]"; 
 432                  if($index < $count) 
 433                      $output .= ",";
 434                  $index++;
 435              }  
 436              
 437          }
 438          $output .= "]\n;"; 
 439          return $output;  
 440      }
 441      
 442     /**

 443      *  This method is meant to be used to display the license agreement inline on the page

 444      *  if the system would like to perform the installation on the same page via an Ajax call

 445      */    
 446      function buildLicenseOutput($file){
 447          $mod_strings = return_module_language('en', "Administration");
 448          $contents = '';
 449          $pm = new PackageManager();
 450          $contents = $pm->getLicenseFromFile($file);
 451          $ss = new Sugar_Smarty();
 452          $ss->assign('MOD', $mod_strings);
 453          $ss->assign('LICENSE_CONTENTS', $contents);
 454          $ss->assign('FILE', $file);
 455          $str = $ss->fetch('ModuleInstall/PackageManagerLicense.tpl');
 456          $GLOBALS['log']->debug('LICENSE OUTPUT: '.$str); 
 457          return $str;        
 458      }
 459      
 460      function getHeader(){
 461          $mod_strings = return_module_language('en', "Administration");
 462          $header_text = '';
 463          $isAlive = false;
 464          $show_login = true;
 465          if(!function_exists('curl_init')){
 466              $header_text = "<font color='red'><b>".$mod_strings['ERR_ENABLE_CURL']."</b></font>";
 467              $show_login = false;    
 468          }
 469          else if(!PackageManagerComm::isAlive()){
 470              $header_text = "<font color='red'><b>".$mod_strings['ERR_SUGAR_DEPOT_DOWN']."</b></font>";  
 471              $show_login = false;  
 472          }else{
 473              $credentials = PackageManager::getCredentials();
 474              if(empty($credentials['username']) || empty($credentials['password'])){
 475                  $header_text = "<font color='red'><b>".$mod_strings['ERR_CREDENTIALS_MISSING']."</b></font>";        
 476              }
 477              else{
 478                  $result = PackageManagerComm::login();
 479                  if((is_array($result) && !empty($result['faultcode'])) || $result == false){
 480                      $header_text = "<font color='red'><b>".$result['faultstring']."</b></font>";        
 481                  }else{
 482                      $header_text = PackageManager::getPromotion();
 483                      $isAlive = true;  
 484                  }
 485              }      
 486          }
 487          return array('text' => $header_text, 'isAlive' => $isAlive, 'show_login' => $show_login);        
 488      }
 489      
 490      function buildInstallGrid($view){
 491          $uh = new UpgradeHistory();
 492          $installeds = $uh->getAll();
 493          $upgrades_installed = 0;
 494          $installed_objects = array();
 495          foreach($installeds as $installed)
 496          {
 497              $filename = from_html($installed->filename);
 498              $date_entered = $installed->date_entered;
 499              $type = $installed->type;
 500              $version = $installed->version;
 501              $upgrades_installed++;
 502              $link = "";
 503  
 504              switch($type)
 505              {
 506                  case "theme":
 507                  case "langpack":
 508                  case "module":
 509                  case "patch":
 510                  $manifest_file = extractManifest($filename);
 511                  require_once($manifest_file);
 512              
 513                  $name = empty($manifest['name']) ? $filename : $manifest['name'];
 514                  $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description'];
 515                  if(($upgrades_installed==0 || $uh->UninstallAvailable($installeds, $installed))
 516                      && is_file($filename) && !empty($manifest['is_uninstallable']))
 517                  {
 518                      $link = urlencode( $filename );
 519                  }
 520                  else
 521                  {
 522                      $link = 'false';
 523                  }
 524              
 525                  break;
 526                  default:
 527                      break;
 528              }
 529  
 530              if($view == 'default' && $type != 'patch')
 531              {
 532                  continue;
 533              }
 534  
 535              if($view == 'module'
 536                  && $type != 'module' && $type != 'theme' && $type != 'langpack')
 537              {
 538                  continue;
 539              }
 540  
 541              $target_manifest = remove_file_extension( $filename ) . "-manifest.php";
 542              require_once( "$target_manifest" );
 543  
 544              if(isset($manifest['icon']) && $manifest['icon'] != "")
 545              {
 546                  $manifest_copy_files_to_dir = isset($manifest['copy_files']['to_dir']) ? clean_path($manifest['copy_files']['to_dir']) : "";
 547                  $manifest_copy_files_from_dir = isset($manifest['copy_files']['from_dir']) ? clean_path($manifest['copy_files']['from_dir']) : "";
 548                  $manifest_icon = clean_path($manifest['icon']);
 549                  $icon = "<img src=\"" . $manifest_copy_files_to_dir . ($manifest_copy_files_from_dir != "" ? substr($manifest_icon, strlen($manifest_copy_files_from_dir)+1) : $manifest_icon ) . "\">";
 550              }
 551              else
 552              {
 553                  $icon = getImageForType( $manifest['type'] );
 554              }
 555              $installed_objects[] = array('icon' => $icon, 'name' => $name, 'type' => $type, 'version' => $version, 'date_entered' => $date_entered, 'description' => $description, 'file' => $link);
 556              //print( "<form action=\"" . $form_action . "_prepare\" method=\"post\">\n" );

 557              //print( "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$date_entered</td><td>$description</td><td>$link</td></tr>\n" );

 558              //print( "</form>\n" );

 559          }
 560      }
 561   }
 562  ?>


Généré le : Tue Sep 11 10:48:47 2007 par Balluche grâce à PHPXref 0.7