本文整理汇总了PHP中override_value_to_string_recursive2函数的典型用法代码示例。如果您正苦于以下问题:PHP override_value_to_string_recursive2函数的具体用法?PHP override_value_to_string_recursive2怎么用?PHP override_value_to_string_recursive2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了override_value_to_string_recursive2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Workflow: Check module builder modules for "moduleList" and "moduleListSingular"
* labels and translations. Create or append fixed content to package
* language file to make it compatible with Studio or ModuleBuilder for future changes
*/
public function run()
{
if (empty($this->upgrader->state['MBModules'])) {
// No MB modules - nothing to do
return;
}
$app_list_strings = return_app_list_strings_language("en_us");
$changes = array();
$packages = $this->getPackages();
foreach ($this->upgrader->state['MBModules'] as $MBModule) {
// All custom modules will have package key in module name
$keys = explode('_', $MBModule);
$packageKey = $keys[0];
if (!isset($packages[$packageKey])) {
$this->upgrader->log('FixSingularList: can\'t find package for module: key - ' . $packageKey . '. Script will use current key as package name');
$packages[$packageKey] = $packageKey;
}
$changes[$packageKey] = isset($changes[$packageKey]) ? $changes[$packageKey] : array();
// Try to add custom module to moduleList
if (!isset($app_list_strings['moduleList'][$MBModule])) {
$langFile = $this->getLanguageFilePath($MBModule);
if (file_exists($langFile)) {
$mod_strings = array();
require $langFile;
$moduleName = isset($mod_strings['LBL_MODULE_NAME']) ? $mod_strings['LBL_MODULE_NAME'] : false;
if ($moduleName) {
$app_list_strings['moduleList'][$MBModule] = $moduleName;
$changes[$packageKey]['moduleList'][$MBModule] = $moduleName;
} else {
$this->upgrader->log('FixSingularList: warning - module ' . $MBModule . ' do not have module name translation');
}
}
}
if (!isset($app_list_strings['moduleListSingular'][$MBModule]) && !empty($app_list_strings['moduleList'][$MBModule])) {
$changes[$packageKey]['moduleListSingular'][$MBModule] = $app_list_strings['moduleList'][$MBModule];
}
}
$rebuildLang = false;
foreach ($changes as $packageKey => $content) {
// if no changes - continue
if (empty($content)) {
continue;
}
$packageName = $packages[$packageKey];
$fileName = $this->getPackageLangFile($packageName);
$values = $this->mergeCustomTranslations($fileName, $content);
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
$file = $header;
foreach ($values as $key => $array) {
$file .= override_value_to_string_recursive2('app_list_strings', $key, $array);
}
$this->upgrader->putFile($fileName, $file);
$rebuildLang = true;
}
if ($rebuildLang) {
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->rebuild_languages(array('en_us' => 'en_us'));
}
}
示例2: testoverride_value_to_string_recursive2
public function testoverride_value_to_string_recursive2()
{
//execute the method and test if it returns expected values
//null array
$expected = null;
$actual = override_value_to_string_recursive2('tempArray', 'key1', '', false);
$this->assertSame($actual, $expected);
//simple array
$tempArray = array('Key1' => 'value1', 'Key2' => 'value2');
$expected = "\$['tempArray']['Key1'] = 'value1';\n\$['tempArray']['Key2'] = 'value2';\n";
$actual = override_value_to_string_recursive2('', 'tempArray', $tempArray);
$this->assertSame($actual, $expected);
//complex array
$tempArray = array();
$tempArray['Key1']['Key2'] = array('Key3' => 'value', 'Key4' => 'value');
$expected = "\$tempArray['key1']['Key2']['Key3'] = 'value';\n\$tempArray['key1']['Key2']['Key4'] = 'value';\n";
$actual = override_value_to_string_recursive2('tempArray', 'key1', $tempArray['Key1']);
$this->assertSame($actual, $expected);
}
示例3: appendOverrideConfig
/**
* Append a array of new settings to the file "config_override.php".
* @param $settings Array of settings
* @return bool
* @throws Exception
*/
public function appendOverrideConfig($settings)
{
$file = 'config_override.php';
$sugar_config = array();
if (file_exists($file)) {
$this->upgrader->backupFile($file);
include $file;
}
foreach ($settings as $key => $val) {
$sugar_config[$key] = $val;
}
$out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n";
foreach (array_keys($sugar_config) as $key) {
$out .= override_value_to_string_recursive2('sugar_config', $key, $sugar_config[$key]);
}
if (!sugar_file_put_contents_atomic($file, $out)) {
throw new Exception("Failed writing to the {$file} file.");
}
return true;
}
示例4: handleOverride
function handleOverride()
{
global $sugar_config, $sugar_version;
$sc = SugarConfig::getInstance();
$overrideArray = $this->readOverride();
$this->previous_sugar_override_config_array = $overrideArray;
$diffArray = deepArrayDiff($this->config, $sugar_config);
$overrideArray = sugarArrayMerge($overrideArray, $diffArray);
$overideString = "<?php\n/***CONFIGURATOR***/\n";
sugar_cache_put('sugar_config', $this->config);
$GLOBALS['sugar_config'] = $this->config;
foreach ($overrideArray as $key => $val) {
if (in_array($key, $this->allow_undefined) || isset($sugar_config[$key])) {
if (strcmp("{$val}", 'true') == 0) {
$val = true;
$this->config[$key] = $val;
}
if (strcmp("{$val}", 'false') == 0) {
$val = false;
$this->config[$key] = false;
}
}
$overideString .= override_value_to_string_recursive2('sugar_config', $key, $val);
}
$overideString .= '/***CONFIGURATOR***/';
$this->saveOverride($overideString);
if (isset($this->config['logger']['level']) && $this->logger) {
$this->logger->setLevel($this->config['logger']['level']);
}
}
示例5: override_value_to_string_recursive2
function override_value_to_string_recursive2($array_name, $value_name, $value, $save_empty = true)
{
if (is_array($value)) {
$str = '';
$newArrayName = $array_name . "['{$value_name}']";
foreach ($value as $key => $val) {
$str .= override_value_to_string_recursive2($newArrayName, $key, $val, $save_empty);
}
return $str;
} else {
if (!$save_empty && empty($value)) {
return;
} else {
return "\${$array_name}" . "['{$value_name}'] = " . var_export($value, true) . ";\n";
}
}
}
示例6: saveConfig
public function saveConfig()
{
$config_str = "<?php\n/***CONNECTOR SOURCE***/\n";
foreach ($this->_config as $key => $val) {
if (!empty($val)) {
$config_str .= override_value_to_string_recursive2('config', $key, $val, false);
}
}
$dir = str_replace('_', '/', get_class($this));
if (!file_exists("custom/modules/Connectors/connectors/sources/{$dir}")) {
mkdir_recursive("custom/modules/Connectors/connectors/sources/{$dir}");
}
$fp = sugar_fopen("custom/modules/Connectors/connectors/sources/{$dir}/config.php", 'w');
fwrite($fp, $config_str);
fclose($fp);
}
示例7: save
function save($key_name, $duplicate = false, $rename = false)
{
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
$save_path = $this->path . '/language';
mkdir_recursive($save_path);
foreach ($this->strings as $lang => $values) {
//Check if the module Label has changed.
$renameLang = $rename || empty($values) || isset($values['LBL_MODULE_NAME']) && $this->label != $values['LBL_MODULE_NAME'];
$mod_strings = return_module_language(str_replace('.lang.php', '', $lang), 'ModuleBuilder');
$required = array('LBL_LIST_FORM_TITLE' => $this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME' => $this->label, 'LBL_MODULE_TITLE' => $this->label, 'LBL_HOMEPAGE_TITLE' => $mod_strings['LBL_HOMEPAGE_PREFIX'] . " " . $this->label, 'LNK_NEW_RECORD' => $mod_strings['LBL_CREATE'] . " " . $this->label, 'LNK_LIST' => $mod_strings['LBL_VIEW'] . " " . $this->label, 'LNK_IMPORT_' . strtoupper($this->key_name) => translate('LBL_IMPORT') . " " . $this->label, 'LBL_SEARCH_FORM_TITLE' => $mod_strings['LBL_SEARCH'] . " " . $this->label, 'LBL_HISTORY_SUBPANEL_TITLE' => $mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE' => $mod_strings['LBL_ACTIVITIES'], 'LBL_' . strtoupper($this->key_name) . '_SUBPANEL_TITLE' => $this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] . " " . $this->label);
foreach ($required as $k => $v) {
if (empty($values[$k]) || $renameLang) {
$values[$k] = $v;
}
}
write_array_to_file('mod_strings', $values, $save_path . '/' . $lang, 'w', $header);
}
$app_save_path = $this->path . '/../../language/application';
mkdir_recursive($app_save_path);
$key_changed = $this->key_name != $key_name;
foreach ($this->appListStrings as $lang => $values) {
// Load previously created modules data
// $app_list_strings = array (); --- fix for issue #305
$neededFile = $app_save_path . '/' . $lang;
if (file_exists($neededFile)) {
include $neededFile;
}
if (!$duplicate) {
unset($values['moduleList'][$this->key_name]);
}
// $values = sugarLangArrayMerge($values, $app_list_strings); --- fix for issue #305
$values['moduleList'][$key_name] = $this->label;
$appFile = $header . "\n";
require_once 'include/utils/array_utils.php';
$this->getGlobalAppListStringsForMB($values);
foreach ($values as $key => $array) {
if ($duplicate) {
//keep the original when duplicating
$appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array);
}
$okey = $key;
if ($key_changed) {
$key = str_replace($this->key_name, $key_name, $key);
}
if ($key_changed) {
$key = str_replace(strtolower($this->key_name), strtolower($key_name), $key);
}
// if we aren't duplicating or the key has changed let's add it
if (!$duplicate || $okey != $key) {
$appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array);
}
}
$fp = sugar_fopen($app_save_path . '/' . $lang, 'w');
fwrite($fp, $appFile);
fclose($fp);
}
}
示例8: handleOverride
function handleOverride($fromParseLoggerSettings = false)
{
global $sugar_config, $sugar_version;
$sc = SugarConfig::getInstance();
$overrideArray = $this->readOverride();
$this->previous_sugar_override_config_array = $overrideArray;
$diffArray = deepArrayDiff($this->config, $sugar_config);
$overrideArray = sugarArrayMergeRecursive($overrideArray, $diffArray);
// To remember checkbox state
if (!$this->useAuthenticationClass && !$fromParseLoggerSettings) {
if (isset($overrideArray['authenticationClass']) && $overrideArray['authenticationClass'] == 'SAMLAuthenticate') {
unset($overrideArray['authenticationClass']);
}
}
$overideString = "<?php\n/***CONFIGURATOR***/\n";
sugar_cache_put('sugar_config', $this->config);
$GLOBALS['sugar_config'] = $this->config;
//print_r($overrideArray);
//Bug#53013: Clean the tpl cache if action menu style has been changed.
if (isset($overrideArray['enable_action_menu']) && (!isset($this->previous_sugar_override_config_array['enable_action_menu']) || $overrideArray['enable_action_menu'] != $this->previous_sugar_override_config_array['enable_action_menu'])) {
require_once 'modules/Administration/QuickRepairAndRebuild.php';
$repair = new RepairAndClear();
$repair->module_list = array();
$repair->clearTpls();
}
foreach ($overrideArray as $key => $val) {
if (in_array($key, $this->allow_undefined) || isset($sugar_config[$key])) {
if (is_string($val) && strcmp($val, 'true') == 0) {
$val = true;
$this->config[$key] = $val;
}
if (is_string($val) && strcmp($val, 'false') == 0) {
$val = false;
$this->config[$key] = false;
}
}
$overideString .= override_value_to_string_recursive2('sugar_config', $key, $val);
}
$overideString .= '/***CONFIGURATOR***/';
$this->saveOverride($overideString);
if (isset($this->config['logger']['level']) && $this->logger) {
$this->logger->setLevel($this->config['logger']['level']);
}
}
示例9: addLabels
//.........这里部分代码省略.........
// 1. Changes to the label names should go to custom/Extension/modules/{ModuleName}/Ext/Language
// This is done in case different users edit the same Relationship concurrently.
// The changes from custom/Extension/modules/{ModuleName}/Ext/Language
// will overwrite stuff in custom/modules/{ModuleName}/Ext/Language/en_us.lang.ext.php after
// Quick Repair and Rebuild is applied.
if($forRelationshipLabel) {
if(!empty($_POST[view_module]) && !empty($_POST[relationship_name]) && !empty($_POST[rhs_label]) && !empty($_POST[lhs_module])) {
// 1. Overwrite custom/Extension/modules/{ModuleName}/Ext/Language
$extension_basepath = "custom/Extension/modules/" . $_POST[view_module] . "/Ext/Language";
mkdir_recursive($extension_basepath);
$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
$out = $headerString;
$extension_filename = "$extension_basepath/$language.custom" . $_POST[relationship_name] . ".php";
$mod_strings = array();
if (file_exists($extension_filename)) {
// obtain $mod_strings
include($extension_filename);
}
$changed_mod_strings = false;
foreach ($labels as $key => $value) {
foreach ($mod_strings as $key_mod_string => $value_mod_string) {
if (strpos($key_mod_string, strtoupper($_POST[relationship_name])) !== false) {
$mod_strings[$key_mod_string] = to_html(strip_tags(from_html($_POST[rhs_label]))); // must match encoding used in view.labels.php
$changed_mod_strings = true;
}
}
}
foreach ($mod_strings as $key => $val)
$out .= override_value_to_string_recursive2('mod_strings', $key, $val);
$failed_to_write = false;
try {
$file_contents = fopen($extension_filename, 'w');
fputs($file_contents, $out, strlen($out));
fclose($file_contents);
} catch (Exception $e) {
$GLOBALS ['log']->fatal("Could not write $filename");
$GLOBALS ['log']->fatal("Exception " . $e->getMessage());
$failed_to_write = true;
}
//2. Overwrite custom/Extension/modules/relationships/language/{ModuleName}.php
// Also need to overwrite custom/Extension/modules/relationships/language/{ModuleName}.php
// because whenever new relationship is created this place is checked by the system to get
// all the label names
$relationships_basepath = "custom/Extension/modules/relationships/language";
mkdir_recursive($relationships_basepath);
$headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
$out = $headerString;
$relationships_filename = "$relationships_basepath/" . $_POST[lhs_module] . ".php";
$mod_strings = array();
if (file_exists($relationships_filename)) {
// obtain $mod_strings
include($relationships_filename);
}
$changed_mod_strings = false;
示例10: updateConfigWorksheetColumnsMetadata
/**
* Update the metadata depending on what we are forecasting on
*
* @param String $forecast_by The Module that we are currently forecasting by
*/
public function updateConfigWorksheetColumnsMetadata($forecast_by)
{
if ($forecast_by === 'RevenueLineItems') {
$contents = "<?php\n\n";
$key = "viewdefs['Forecasts']['base']['view']['config-worksheet-columns']['panels'][0]['fields']";
foreach ($this->rli_worksheet_columns as $val) {
$contents .= override_value_to_string_recursive2($key, $val['name'], $val, false);
}
sugar_file_put_contents($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file, $contents);
} else {
if (SugarAutoLoader::fileExists($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file)) {
SugarAutoLoader::unlink($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file);
}
}
$this->runRebuildExtensions(array('Forecasts'));
MetaDataManager::refreshModulesCache('Forecasts');
}
示例11: handleOverride
function handleOverride($fromParseLoggerSettings = false)
{
global $sugar_config, $sugar_version;
$sc = SugarConfig::getInstance();
$overrideArray = $this->readOverride();
$this->previous_sugar_override_config_array = $overrideArray;
$diffArray = deepArrayDiff($this->config, $sugar_config);
$overrideArray = sugarArrayMergeRecursive($overrideArray, $diffArray);
// To remember checkbox state
if (!$this->useAuthenticationClass && !$fromParseLoggerSettings) {
if (isset($overrideArray['authenticationClass']) && $overrideArray['authenticationClass'] == 'SAMLAuthenticate') {
unset($overrideArray['authenticationClass']);
}
}
$overideString = "<?php\n/***CONFIGURATOR***/\n";
sugar_cache_put('sugar_config', $this->config);
$GLOBALS['sugar_config'] = $this->config;
//print_r($overrideArray);
foreach ($overrideArray as $key => $val) {
if (in_array($key, $this->allow_undefined) || isset($sugar_config[$key])) {
if (strcmp("{$val}", 'true') == 0) {
$val = true;
$this->config[$key] = $val;
}
if (strcmp("{$val}", 'false') == 0) {
$val = false;
$this->config[$key] = false;
}
}
$overideString .= override_value_to_string_recursive2('sugar_config', $key, $val);
}
$overideString .= '/***CONFIGURATOR***/';
$this->saveOverride($overideString);
if (isset($this->config['logger']['level']) && $this->logger) {
$this->logger->setLevel($this->config['logger']['level']);
}
}
示例12: removeFieldFromExt
/**
* Scan extension directories for file with bad field definition.
* @param SugarBean $seed
* @param String $field
*/
protected function removeFieldFromExt($seed, $field)
{
$mod = $seed->module_dir;
$files = $this->getFiles($seed, '', $field);
if (count($files) == 0) {
return false;
}
foreach ($files as $file) {
$dictionary = array();
include $file;
if (!empty($dictionary[$seed->object_name]['fields'][$field])) {
$this->upgrader->backupFile($file);
$this->log("Remove definition of {$field} for module {$mod}");
$out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n";
unset($dictionary[$seed->object_name]['fields'][$field]);
if (empty($dictionary)) {
$this->deleteFile($file);
} else {
foreach (array_keys($dictionary) as $key) {
$out .= override_value_to_string_recursive2('dictionary', $key, $dictionary[$key]);
}
file_put_contents($file, $out);
}
}
}
return true;
}
示例13: getConfigString
/**
* Get the config values encoded to string format to place into the custom modules directory
* @param $key array key
* @param $val array value
*/
public function getConfigString($key, $val)
{
return override_value_to_string_recursive2('config', $key, $val, false);
}
示例14: saveConfig
/**
* Save source's config to custom directory
*/
public function saveConfig()
{
$config_str = "<?php\n/***CONNECTOR SOURCE***/\n";
// Handle encryption
if (!empty($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && !empty($this->_config['properties'])) {
require_once 'include/utils/encryption_utils.php';
foreach ($this->_config['encrypt_properties'] as $name) {
if (!empty($this->_config['properties'][$name])) {
$this->_config['properties'][$name] = blowfishEncode(blowfishGetKey('encrypt_field'), $this->_config['properties'][$name]);
}
}
}
foreach ($this->_config as $key => $val) {
if (!empty($val)) {
$config_str .= override_value_to_string_recursive2('config', $key, $val, false);
}
}
$dir = str_replace('_', '/', get_class($this));
if (!file_exists("custom/modules/Connectors/connectors/sources/{$dir}")) {
mkdir_recursive("custom/modules/Connectors/connectors/sources/{$dir}");
}
file_put_contents("custom/modules/Connectors/connectors/sources/{$dir}/config.php", $config_str);
}
示例15: override_value_to_string_recursive2
/**
* Given an array name, key name and value of array, return a string of re-composed array.
*
* @param string $array_name : name of the array
* @param string $value_name : name of the array keys
* @param array $value : value of current array
* @param boolean $save_empty : flag to allow save empty
* @param array $original : original sugar_config array
*
* @return string : example - "\$sugar_config['a']['b']['c'][0] = 'hello';\n"
*/
function override_value_to_string_recursive2($array_name, $value_name, $value, $save_empty = true, $original = null)
{
$quoted_vname = var_export($value_name, true);
if (is_array($value)) {
$str = '';
$seq = false;
$newArrayName = $array_name . "[{$quoted_vname}]";
if (is_array($original)) {
if (!empty($original[$value_name]) && is_array($original[$value_name])) {
$original = $original[$value_name];
$seq = is_sequential($original);
} else {
$original = array();
}
} else {
$original = null;
}
foreach ($value as $key => $val) {
$org = null;
if (is_array($val) || $seq) {
$org = $original;
} else {
if (is_array($original) && empty($original)) {
$org = array();
}
}
$str .= override_value_to_string_recursive2($newArrayName, $key, $val, $save_empty, $org);
}
return $str;
} else {
if (!$save_empty && empty($value)) {
return;
} else {
if (is_numeric($value_name)) {
if ($original && !array_key_exists($value_name, $original)) {
return "\${$array_name}" . "[] = " . var_export($value, true) . ";\n";
}
if ($value_name === 0 && is_array($original) && empty($original)) {
return "\${$array_name}" . "[] = " . var_export($value, true) . ";\n";
}
}
return "\${$array_name}" . "[{$quoted_vname}] = " . var_export($value, true) . ";\n";
}
}
}