Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing getFileName and layouts in module builder and studio. #3918

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/ModuleBuilder/MB/MBLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function save($key_name, $duplicate=false, $rename=false){
'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_SEARCH_FORM_TITLE'=>$mod_strings['LBL_SEARCH_BUTTON'] ." ". $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,
Expand Down
5 changes: 5 additions & 0 deletions modules/ModuleBuilder/MB/ModuleBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ function getPackageKey ($name)
return false ;
}

/**
* @param $package
* @param $module
* @return mixed
*/
function &getPackageModule ($package , $module)
{
$this->getPackage ( $package ) ;
Expand Down
8 changes: 0 additions & 8 deletions modules/ModuleBuilder/Module/StudioModuleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,12 @@
*/
class StudioModuleFactory
{
/**
* @var array $loadedMods - array( 'module' => StudioModule )
*/
protected static $loadedMods = array();

/**
* @param string $module name
* @return StudioModule
*/
public static function getStudioModule($module)
{
if (!empty(self::$loadedMods[$module]))
return self::$loadedMods[$module];

$studioModClass = "{$module}StudioModule";
if (file_exists("custom/modules/{$module}/{$studioModClass}.php"))
Expand All @@ -75,7 +68,6 @@ public static function getStudioModule($module)
{
$sm = new StudioModule($module);
}
self::$loadedMods[$module] = $sm;
return $sm;
}
}
Expand Down
71 changes: 49 additions & 22 deletions modules/ModuleBuilder/parsers/parser.label.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?php

if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2016 SalesAgility Ltd.
* Copyright (C) 2011 - 2017 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
Expand All @@ -19,7 +16,7 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
Expand All @@ -37,13 +34,37 @@
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/

if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}


require_once 'modules/ModuleBuilder/parsers/ModuleBuilderParser.php';

/**
* Class ParserLabel
*/
class ParserLabel
{
/**
* @var string $packageName
*/
protected $packageName;

/**
* @var string $moduleName
*/
protected $moduleName;

/**
* ParserLabel constructor.
* @param string $moduleName
* @param string $packageName
*/
public function __construct($moduleName, $packageName = '')
{
$this->moduleName = $moduleName;
Expand Down Expand Up @@ -92,18 +113,19 @@ public function handleSave($params, $language)
}
}

/*
/**
* Remove a label from the language pack for a module
* @param string $language Language key, for example 'en_us'
* @param string $label The label to remove
* @param string $labelvalue The value of the label to remove
* @param string $moduleName Name of the module to which to add these labels
* @param string $basepath base path of the language file
* @param string $forRelationshipLabel whether this is a relationship label
* @param bool $forRelationshipLabel whether this is a relationship label
* @return bool
*/
public static function removeLabel($language, $label, $labelvalue, $moduleName, $basepath = null, $forRelationshipLabel = false)
{
$GLOBALS [ 'log' ]->debug("ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );");
$GLOBALS [ 'log' ]->debug("ParserLabel::removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );");
if (is_null($basepath)) {
$deployedModule = true;
$basepath = "custom/modules/$moduleName/language";
Expand Down Expand Up @@ -154,7 +176,7 @@ public static function removeLabel($language, $label, $labelvalue, $moduleName,
} else {
// if we have a cache to worry about, then clear it now
if ($deployedModule) {
$GLOBALS ['log']->debug('PaserLabel->addLabels: clearing language cache');
$GLOBALS ['log']->debug('PaserLabel::addLabels: clearing language cache');
$cache_key = 'module_language.'.$language.$moduleName;
sugar_cache_clear($cache_key);
LanguageManager::clearLanguageCache($moduleName, $language);
Expand All @@ -165,20 +187,22 @@ public static function removeLabel($language, $label, $labelvalue, $moduleName,
return true;
}

/*
/**
* Add a set of labels to the language pack for a module, deployed or undeployed
* @param string $language Language key, for example 'en_us'
* @param array $labels The labels to add in the form of an array of System label => Display label pairs
* @param string $moduleName Name of the module to which to add these labels
* @param string $packageName If module is undeployed, name of the package to which it belongs
* @param string $basepath
* @param bool $forRelationshipLabel
* @return bool
*/
public static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false)
{
$GLOBALS [ 'log' ]->debug("ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );");
$GLOBALS [ 'log' ]->debug("ParserLabel::addLabels($language, \$labels, $moduleName, $basepath );");
$GLOBALS [ 'log' ]->debug('$labels:'.print_r($labels, true));

$deployedModule = false;
if (is_null($basepath)) {
if (null === $basepath) {
$deployedModule = true;
$basepath = "custom/modules/$moduleName/language";
if ($forRelationshipLabel) {
Expand Down Expand Up @@ -221,15 +245,15 @@ public static function addLabels($language, $labels, $moduleName, $basepath = nu
}

if ($changed) {
$GLOBALS [ 'log' ]->debug("ParserLabel->addLabels: writing new mod_strings to $filename");
$GLOBALS [ 'log' ]->debug('ParserLabel->addLabels: mod_strings='.print_r($mod_strings, true));
$GLOBALS [ 'log' ]->debug("ParserLabel::addLabels: writing new mod_strings to $filename");
$GLOBALS [ 'log' ]->debug('ParserLabel::addLabels: mod_strings='.print_r($mod_strings, true));
if (!write_array_to_file('mod_strings', $mod_strings, $filename)) {
$GLOBALS [ 'log' ]->fatal("Could not write $filename");
} else {
// if we have a cache to worry about, then clear it now
if ($deployedModule) {
SugarCache::cleanOpcodes();
$GLOBALS [ 'log' ]->debug('PaserLabel->addLabels: clearing language cache');
$GLOBALS [ 'log' ]->debug('PaserLabel::addLabels: clearing language cache');
$cache_key = 'module_language.'.$language.$moduleName;
sugar_cache_clear($cache_key);
LanguageManager::clearLanguageCache($moduleName, $language);
Expand Down Expand Up @@ -332,7 +356,7 @@ public static function addLabels($language, $labels, $moduleName, $basepath = nu
// if we have a cache to worry about, then clear it now
if ($deployedModule) {
SugarCache::cleanOpcodes();
$GLOBALS ['log']->debug('PaserLabel->addLabels: clearing language cache');
$GLOBALS ['log']->debug('PaserLabel::addLabels: clearing language cache');
$cache_key = 'module_language.'.$language.$moduleName;
sugar_cache_clear($cache_key);
LanguageManager::clearLanguageCache($moduleName, $language);
Expand All @@ -349,7 +373,7 @@ public static function addLabels($language, $labels, $moduleName, $basepath = nu
* Takes in the request params from a save request and processes
* them for the save.
*
* @param $metadata
* @param array $metadata
* @param string $language Language key, for example 'en_us'
*/
public function handleSaveRelationshipLabels($metadata, $language)
Expand All @@ -361,11 +385,14 @@ public function handleSaveRelationshipLabels($metadata, $language)
}
}

/**
* @param array $labels
*/
public function addLabelsToAllLanguages($labels)
{
$langs = get_languages();
foreach ($langs as $lang_key => $lang_display) {
$this->addLabels($lang_key, $labels, $this->moduleName);
self::addLabels($lang_key, $labels, $this->moduleName);
}
}
}
2 changes: 1 addition & 1 deletion modules/ModuleBuilder/parsers/parser.modifylayoutview.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function _parseData ($panels)
{
$fields = array();
if (empty($panels))
return;
return $fields;

// Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined, it goes straight into rows
// See EditView2 for similar treatment
Expand Down