add *.inc files to project
This commit is contained in:
119
include/ECM/EcmDropdownEditor/EcmDropdownEditor.inc
Normal file
119
include/ECM/EcmDropdownEditor/EcmDropdownEditor.inc
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*
|
||||
* important:
|
||||
* add to return_app_list_strings_language in include/utils.php:
|
||||
* //add mz 2015-01-07
|
||||
* //include EcmDropdownEditor custom doms
|
||||
* $path = 'include/language/'.$language.'.EcmDropdownEditor.php';
|
||||
* if (file_exists($path)) {
|
||||
* include $path;
|
||||
* foreach ($customDoms as $key => $val)
|
||||
* $app_list_strings[$key] = $val;
|
||||
* }
|
||||
* //end mz
|
||||
*/
|
||||
class EcmDropdownEditor {
|
||||
const MY_PATH = "include/ECM/EcmDropdownEditor/";
|
||||
private $module;
|
||||
private $fieldName;
|
||||
private $dom; // name of edited list
|
||||
private $dropdowns; // values of edited list
|
||||
private $languages; // Sugar languages list
|
||||
private $container; //name of div with edit form
|
||||
public function EcmDropdownEditor($module, $container) {
|
||||
$this->module = $module;
|
||||
$this->languages = get_languages ();
|
||||
$this->container = $container;
|
||||
$tmp = explode ( "___", $container );
|
||||
$this->fieldName = $tmp [0];
|
||||
}
|
||||
|
||||
// Get all dropdowns from module vardefs (including all Sugar languages)
|
||||
private function getDropdowns() {
|
||||
// get list values
|
||||
global $sugar_config; // just to get current language
|
||||
$l = array ();
|
||||
foreach ( $this->languages as $id => $lang ) {
|
||||
$l [$id] = return_app_list_strings_language ( $id );
|
||||
}
|
||||
// get dom name
|
||||
include_once ('modules/' . $this->module . '/vardefs.php');
|
||||
//evolpe begin
|
||||
if(file_exists('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php')){
|
||||
include('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php');
|
||||
}
|
||||
//evolpe end
|
||||
$this->dom = $dictionary [substr ( $this->module, 0, - 1 )] ['fields'] [$this->fieldName] ['options'];
|
||||
$tmp = array ();
|
||||
foreach ( $l [$sugar_config ['default_language']] [$this->dom] as $key => $value ) {
|
||||
$tmp [$key] = array ();
|
||||
foreach ( $this->languages as $id => $lang )
|
||||
$tmp [$key] [$id] = $l [$id] [$this->dom] [$key];
|
||||
}
|
||||
$this->dropdowns[$this->dom] = $tmp;
|
||||
unset ( $tmp );
|
||||
return true;
|
||||
}
|
||||
public function DrawEditView() {
|
||||
$this->getDropdowns ();
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'DROPDOWNS', $this->dropdowns );
|
||||
$smarty->assign ( 'LANGUAGES', $this->languages );
|
||||
$smarty->assign ( 'CONTAINER', $this->container );
|
||||
return $smarty->fetch ( self::MY_PATH . 'EditView.tpl' );
|
||||
}
|
||||
public static function getOptionTemplate() {
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'KEY', create_guid () );
|
||||
$smarty->assign ( 'LANGUAGES', get_languages () );
|
||||
return $smarty->fetch ( self::MY_PATH . 'addOption.tpl' );
|
||||
}
|
||||
public static function saveDom($name, $normal) {
|
||||
require_once 'include/utils/file_utils.php';
|
||||
// save normal
|
||||
foreach ( $normal as $lang => $options ) {
|
||||
$customDoms = null;
|
||||
$path = 'include/language/' . $lang . '.EcmDropdownEditor.php';
|
||||
if (file_exists ( $path ))
|
||||
require ($path);
|
||||
else
|
||||
$customDoms = array ();
|
||||
$customDoms [$name] = array ();
|
||||
foreach ( $options as $key => $val )
|
||||
$customDoms [$name] [$key] = $val;
|
||||
write_array_to_file ( 'customDoms', $customDoms, $path );
|
||||
}
|
||||
// clear sugar cache
|
||||
include_once ('modules/Administration/QuickRepairAndRebuild.php');
|
||||
$repair = new RepairAndClear ();
|
||||
$modules = array (
|
||||
'All Modules'
|
||||
);
|
||||
$selected_actions = array (
|
||||
'clearTpls',
|
||||
'clearJsLangFiles',
|
||||
'clearLangFiles'
|
||||
);
|
||||
$repair->repairAndClearAll ( $selected_actions, $modules, false, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getOptionsHTML() {
|
||||
// get dom names
|
||||
include_once ('modules/' . $this->module . '/vardefs.php');
|
||||
//evolpe begin
|
||||
if(file_exists('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php')){
|
||||
include('custom/modules/' . $this->module . '/Ext/Vardefs/vardefs.ext.php');
|
||||
}
|
||||
//evolpe end
|
||||
$dom = $dictionary [substr ( $this->module, 0, - 1 )] ['fields'] [$this->fieldName] ['options'];
|
||||
//current language
|
||||
global $current_language;
|
||||
$options = return_app_list_strings_language($current_language);
|
||||
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'OPTIONS', $options[$dom] );
|
||||
return $smarty->fetch ( self::MY_PATH . 'createOptions.tpl' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user