[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/vtlib/Vtiger/ -> ThemeImport.php (source)

   1  <?php
   2  /*+**********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   ************************************************************************************/
  10  include_once ('vtlib/Vtiger/ThemeExport.php');
  11  
  12  /**
  13   * Provides API to import language into vtiger CRM
  14   * @package vtlib
  15   */
  16  class Vtiger_ThemeImport extends Vtiger_ThemeExport {
  17      
  18      /**
  19       * Constructor
  20       */
  21  	function __construct() {
  22          parent::__construct();
  23          $this->_export_tmpdir;
  24      }
  25          
  26      /**
  27       * Initialize Import
  28       * @access private
  29       */
  30  	function initImport($zipfile, $overwrite) {
  31          $this->__initSchema();
  32          $name = $this->getModuleNameFromZip($zipfile);
  33                  return $name;
  34      }
  35  
  36      /**
  37       * Import Module from zip file
  38       * @param String Zip file name
  39       * @param Boolean True for overwriting existing module
  40       */
  41  	function import($zipfile, $overwrite=false) {
  42          $this->initImport($zipfile, $overwrite);
  43  
  44          // Call module import function
  45          $this->import_Theme($zipfile);
  46      }
  47  
  48      /**
  49       * Update Module from zip file
  50       * @param Object Instance of Language (to keep Module update API consistent)
  51       * @param String Zip file name
  52       * @param Boolean True for overwriting existing module
  53       */
  54  	function update($instance, $zipfile, $overwrite=true) {
  55          $this->import($zipfile, $overwrite);
  56      }
  57  
  58      /**
  59       * Import Module
  60       * @access private
  61       */
  62  	function import_Theme($zipfile) {
  63          $name = $this->_modulexml->name;
  64          $label = $this->_modulexml->label;
  65                  $parent = $this->_modulexml->parent;
  66  
  67          self::log("Importing $label ... STARTED");
  68          $unzip = new Vtiger_Unzip($zipfile);
  69          $filelist = $unzip->getList();
  70          $vtiger6format = false;
  71                  
  72          foreach($filelist as $filename=>$fileinfo) {
  73              if(!$unzip->isdir($filename)) {
  74  
  75                  if(strpos($filename, '/') === false) continue;
  76  
  77  
  78                  $targetdir  = substr($filename, 0, strripos($filename,'/'));
  79                  $targetfile = basename($filename);
  80                                  $dounzip = false;
  81                                  // Case handling for jscalendar
  82                                  if(stripos($targetdir, "layouts/$parent/skins/$label") === 0) {
  83                                      $dounzip = true;
  84                                      $vtiger6format = true;
  85                                  }
  86                  if($dounzip) {
  87                      // vtiger6 format
  88                      if ($vtiger6format) {
  89                                                 $targetdir = "layouts/$parent/skins/" . str_replace("layouts/$parent/skins", "", $targetdir);
  90                          @mkdir($targetdir, 0777, true);
  91                      }
  92  
  93                      if($unzip->unzip($filename, "$targetdir/$targetfile") !== false) {
  94                          self::log("Copying file $filename ... DONE");
  95                      } else {
  96                          self::log("Copying file $filename ... FAILED");
  97                      }
  98                  } else {
  99                      self::log("Copying file $filename ... SKIPPED");
 100                  }
 101              }
 102          }
 103          if($unzip) $unzip->close();
 104  
 105          self::register($label, $name, $parent);
 106  
 107          self::log("Importing $label [$prefix] ... DONE");
 108  
 109          return;
 110      }    
 111  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1