[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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/LanguageExport.php'); 11 12 /** 13 * Provides API to import language into vtiger CRM 14 * @package vtlib 15 */ 16 class Vtiger_LanguageImport extends Vtiger_LanguageExport { 17 18 /** 19 * Constructor 20 */ 21 function __construct() { 22 parent::__construct(); 23 $this->_export_tmpdir; 24 } 25 26 function getPrefix() { 27 return (string)$this->_modulexml->prefix; 28 } 29 30 /** 31 * Initialize Import 32 * @access private 33 */ 34 function initImport($zipfile, $overwrite) { 35 $this->__initSchema(); 36 37 $name = $this->getModuleNameFromZip($zipfile); 38 return $name; 39 } 40 41 /** 42 * Import Module from zip file 43 * @param String Zip file name 44 * @param Boolean True for overwriting existing module 45 */ 46 function import($zipfile, $overwrite=false) { 47 $this->initImport($zipfile, $overwrite); 48 49 // Call module import function 50 $this->import_Language($zipfile); 51 } 52 53 /** 54 * Update Module from zip file 55 * @param Object Instance of Language (to keep Module update API consistent) 56 * @param String Zip file name 57 * @param Boolean True for overwriting existing module 58 */ 59 function update($instance, $zipfile, $overwrite=true) { 60 $this->import($zipfile, $overwrite); 61 } 62 63 /** 64 * Import Module 65 * @access private 66 */ 67 function import_Language($zipfile) { 68 $name = $this->_modulexml->name; 69 $prefix = $this->_modulexml->prefix; 70 $label = $this->_modulexml->label; 71 72 self::log("Importing $label [$prefix] ... STARTED"); 73 $unzip = new Vtiger_Unzip($zipfile); 74 $filelist = $unzip->getList(); 75 $vtiger6format = false; 76 77 foreach($filelist as $filename=>$fileinfo) { 78 if(!$unzip->isdir($filename)) { 79 80 if(strpos($filename, '/') === false) continue; 81 82 $targetdir = substr($filename, 0, strripos($filename,'/')); 83 $targetfile = basename($filename); 84 85 $prefixparts = split('_', $prefix); 86 87 $dounzip = false; 88 if(is_dir($targetdir)) { 89 // Case handling for jscalendar 90 if(stripos($targetdir, 'jscalendar/lang') === 0 91 && stripos($targetfile, "calendar-".$prefixparts[0].".js")===0) { 92 93 if(file_exists("$targetdir/calendar-en.js")) { 94 $dounzip = true; 95 } 96 } 97 // Case handling for phpmailer 98 else if(stripos($targetdir, 'modules/Emails/language') === 0 99 && stripos($targetfile, "phpmailer.lang-$prefix.php")===0) { 100 101 if(file_exists("$targetdir/phpmailer.lang-en_us.php")) { 102 $dounzip = true; 103 } 104 } 105 // Handle javascript language file 106 else if(preg_match("/$prefix.lang.js/", $targetfile)) { 107 $corelangfile = "$targetdir/en_us.lang.js"; 108 if(file_exists($corelangfile)) { 109 $dounzip = true; 110 } 111 } 112 // Handle php language file 113 else if(preg_match("/$prefix.lang.php/", $targetfile)) { 114 $corelangfile = "$targetdir/en_us.lang.php"; 115 if(file_exists($corelangfile)) { 116 $dounzip = true; 117 } 118 } 119 // vtiger6 format 120 else if ($targetdir == "modules" || $targetdir == "modules/Settings" || $targetdir == "modules". DIRECTORY_SEPARATOR. "Settings") { 121 $vtiger6format = true; 122 $dounzip = true; 123 } 124 } 125 126 if($dounzip) { 127 // vtiger6 format 128 if ($vtiger6format) { 129 $targetdir = "languages/$prefix/" . str_replace("modules", "", $targetdir); 130 @mkdir($targetdir, 0777, true); 131 } 132 133 if($unzip->unzip($filename, "$targetdir/$targetfile") !== false) { 134 self::log("Copying file $filename ... DONE"); 135 } else { 136 self::log("Copying file $filename ... FAILED"); 137 } 138 } else { 139 self::log("Copying file $filename ... SKIPPED"); 140 } 141 } 142 } 143 if($unzip) $unzip->close(); 144 145 self::register($prefix, $label, $name); 146 147 self::log("Importing $label [$prefix] ... DONE"); 148 149 return; 150 } 151 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |