init
This commit is contained in:
335
include/SugarFields/Parsers/CreateViewMetaParser.php
Normal file
335
include/SugarFields/Parsers/CreateViewMetaParser.php
Normal file
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
|
||||
if (!defined('sugarEntry') || !sugarEntry)
|
||||
die('Not A Valid Entry Point');
|
||||
|
||||
/* * *******************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
* ****************************************************************************** */
|
||||
|
||||
/**
|
||||
* CreateViewMetaParser.php
|
||||
* This is a utility file that attempts to provide support for parsing pre 5.0 SugarCRM
|
||||
* CreateView.html files and produce a best guess editviewdefs.php file equivalent.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
require_once('include/SugarFields/Parsers/MetaParser.php');
|
||||
|
||||
class CreateViewMetaParser extends MetaParser {
|
||||
|
||||
function CreateViewMetaParser() {
|
||||
$this->mView = 'CreateView';
|
||||
}
|
||||
|
||||
/**
|
||||
* parse
|
||||
*
|
||||
* @param $filePath The file path of the HTML file to parse
|
||||
* @param $vardefs The module's vardefs
|
||||
* @param $moduleDir The module's directory
|
||||
* @param $merge boolean value indicating whether or not to merge the parsed contents
|
||||
* @param $masterCopy The file path of the mater copy of the metadata file to merge against
|
||||
* @return String format of metadata contents
|
||||
* */
|
||||
function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) {
|
||||
|
||||
global $app_strings;
|
||||
$contents = file_get_contents($filePath);
|
||||
$contents = $this->trimHTML($contents);
|
||||
$contents = $this->stripFlavorTags($contents);
|
||||
$moduleName = '';
|
||||
|
||||
$contents = $this->fixDuplicateTrTags($contents);
|
||||
$contents = $this->fixRowsWithMissingTr($contents);
|
||||
|
||||
$tables = $this->getElementsByType("table", $contents);
|
||||
$formElements = $this->getFormElements($tables[0]);
|
||||
$hiddenInputs = array();
|
||||
foreach ($formElements as $elem) {
|
||||
$type = $this->getTagAttribute("type", $elem);
|
||||
if (preg_match('/hidden/si', $type)) {
|
||||
$name = $this->getTagAttribute("name", $elem);
|
||||
$value = $this->getTagAttribute("value", $elem);
|
||||
$hiddenInputs[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the second table in the page and onward
|
||||
$tables = array_slice($tables, 1);
|
||||
$panels = array();
|
||||
$tableCount = 0;
|
||||
$addedElements = array();
|
||||
$maxTableCountNum = 0;
|
||||
$tableCount = 0;
|
||||
foreach ($tables as $table) {
|
||||
$table = $this->fixTablesWithMissingTr($table);
|
||||
$toptr = $this->getElementsByType("tr", $table);
|
||||
foreach ($toptr as $tr) {
|
||||
$tabledata = $this->getElementsByType("table", $tr);
|
||||
$data = array();
|
||||
$panelKey = $tableCount == 0 ? "default" : '';
|
||||
foreach ($tabledata as $t) {
|
||||
$vals = array_values($this->getElementsByType("tr", $t));
|
||||
if (preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) {
|
||||
array_shift($vals);
|
||||
$panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey;
|
||||
}
|
||||
|
||||
//If $panelKey is empty use the maxTableCountNum value
|
||||
if (empty($panelKey)) {
|
||||
$panels[$maxTableCountNum++] = $vals;
|
||||
} else {
|
||||
$panels[$panelKey] = $vals;
|
||||
}
|
||||
} //foreach
|
||||
$tableCount++;
|
||||
} //foreach;
|
||||
} //foreach
|
||||
|
||||
foreach ($panels as $id => $tablerows) {
|
||||
|
||||
$metarow = array();
|
||||
|
||||
foreach ($tablerows as $trow) {
|
||||
|
||||
$emptyCount = 0;
|
||||
$tablecolumns = $this->getElementsByType("td", $trow);
|
||||
$col = array();
|
||||
$slot = 0;
|
||||
|
||||
foreach ($tablecolumns as $tcols) {
|
||||
$hasRequiredLabel = false;
|
||||
|
||||
//Get the sugar attribute value in the span elements of each table row
|
||||
$sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'");
|
||||
|
||||
//If there was no sugar attribute, try id (some versions of CreateView.html used this instead)
|
||||
if (empty($sugarAttrLabel)) {
|
||||
$sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'");
|
||||
}
|
||||
|
||||
//Check if this field is required
|
||||
if (!empty($sugarAttrLabel)) {
|
||||
$hasRequiredLabel = $this->hasRequiredSpanLabel($tcols);
|
||||
}
|
||||
|
||||
$sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
|
||||
|
||||
//If there was no sugar attribute, try id (some versions of CreateView.html used this instead)
|
||||
if (empty($sugarAttrValue)) {
|
||||
$sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'");
|
||||
}
|
||||
|
||||
// If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs
|
||||
$sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false;
|
||||
$sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false;
|
||||
$slot++;
|
||||
|
||||
if ($sugarAttrValue) {
|
||||
|
||||
$spanValue = $this->getElementValue("span", $tcols);
|
||||
|
||||
if (empty($spanValue)) {
|
||||
$spanValue = $this->getElementValue("slot", $tcols);
|
||||
}
|
||||
|
||||
if (empty($spanValue)) {
|
||||
$spanValue = $this->getElementValue("td", $tcols);
|
||||
}
|
||||
|
||||
//Get all the editable form elements' names
|
||||
$formElementNames = $this->getFormElementsNames($spanValue);
|
||||
$customField = $this->getCustomField($formElementNames);
|
||||
|
||||
$name = '';
|
||||
$fields = null;
|
||||
$customCode = null;
|
||||
|
||||
if (!empty($customField)) {
|
||||
// If it's a custom field we just set the name
|
||||
$name = $customField;
|
||||
} else if (empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) {
|
||||
// We are here if the $spanValue did not contain a form element for editing.
|
||||
// We will assume that it is read only (since there were no edit form elements)
|
||||
// If there is more than one matching {} value then try to find the right one to key off
|
||||
// based on vardefs.php file. Also, use the entire spanValue as customCode
|
||||
if (count($matches) > 1) {
|
||||
$name = $matches[0][1];
|
||||
$customCode = $spanValue;
|
||||
foreach ($matches as $pair) {
|
||||
if (preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) {
|
||||
$customCode = str_replace($pair[1], '$' . strtoupper($pair[1]), $customCode);
|
||||
} else {
|
||||
if (!empty($vardefs[$pair[1]])) {
|
||||
$name = $pair[1];
|
||||
$customCode = str_replace($pair[1], '$fields.' . strtolower($pair[1]) . '.value', $customCode);
|
||||
} else {
|
||||
$phpName = $this->findAssignedVariableName($pair[1], $filePath);
|
||||
$customCode = str_replace($pair[1], '$fields.' . strtolower($phpName) . '.value', $customCode);
|
||||
} //if-else
|
||||
}
|
||||
} //foreach
|
||||
} else {
|
||||
//If it is only a label, skip
|
||||
if (preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) {
|
||||
continue;
|
||||
}
|
||||
$name = strtolower($matches[0][1]);
|
||||
}
|
||||
} else if (is_array($formElementNames)) {
|
||||
|
||||
if (count($formElementNames) == 1) {
|
||||
|
||||
if (!empty($vardefs[$formElementNames[0]])) {
|
||||
$name = $formElementNames[0];
|
||||
} else {
|
||||
// Try to use the CreateView.php file to find author's intent
|
||||
$name = $this->findAssignedVariableName($formElementNames[0], $filePath);
|
||||
|
||||
//If it's still empty, just use the entire block as customCode
|
||||
if (empty($vardefs[$name])) {
|
||||
//Replace any { characters just in case
|
||||
$customCode = str_replace('{', '{$', $spanValue);
|
||||
}
|
||||
} //if-else
|
||||
} else {
|
||||
//If it is an Array of form elements, it is likely the _id and _name relate field combo
|
||||
$relateName = $this->getRelateFieldName($formElementNames);
|
||||
if (!empty($relateName)) {
|
||||
$name = $relateName;
|
||||
} else {
|
||||
//One last attempt to scan $formElementNames for one vardef field only
|
||||
$name = $this->findSingleVardefElement($formElementNames, $vardefs);
|
||||
if (empty($name)) {
|
||||
$fields = array();
|
||||
$name = $formElementNames[0];
|
||||
foreach ($formElementNames as $elementName) {
|
||||
if (isset($vardefs[$elementName])) {
|
||||
$fields[] = $elementName;
|
||||
} else {
|
||||
$fields[] = $this->findAssignedVariableName($elementName, $filePath);
|
||||
} //if-else
|
||||
} //foreach
|
||||
} //if
|
||||
} //if-else
|
||||
} //if-else
|
||||
}
|
||||
|
||||
// Build the entry
|
||||
if (preg_match("/<textarea/si", $spanValue)) {
|
||||
//special case for textarea form elements (add the displayParams)
|
||||
$displayParams = array();
|
||||
$displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
|
||||
$displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
|
||||
|
||||
if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
$field['displayParams'] = $displayParams;
|
||||
} else {
|
||||
$field = $name;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (isset($fields) || isset($customCode)) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
if (isset($fields)) {
|
||||
$field['fields'] = $fields;
|
||||
}
|
||||
if (isset($customCode)) {
|
||||
$field['customCode'] = $customCode;
|
||||
$field['description'] = 'This field was auto generated';
|
||||
}
|
||||
} else {
|
||||
$emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
|
||||
$field = $name;
|
||||
}
|
||||
} //if-else if-else block
|
||||
|
||||
$addedField = is_array($field) ? $field['name'] : $field;
|
||||
if (empty($addedField) || empty($addedElements[$addedField])) {
|
||||
//Add the meta-data definition for required fields
|
||||
if ($hasRequiredLabel) {
|
||||
if (is_array($field)) {
|
||||
if (isset($field['displayParams']) && is_array($field['displayParams'])) {
|
||||
$field['displayParams']['required'] = true;
|
||||
} else {
|
||||
$field['displayParams'] = array('required' => true);
|
||||
}
|
||||
} else {
|
||||
$field = array('name' => strtolower($field), 'displayParams' => array('required' => true));
|
||||
}
|
||||
}
|
||||
$col[] = is_array($field) ? $field : strtolower($field);
|
||||
$addedElements[$addedField] = $addedField;
|
||||
}
|
||||
} //if($sugarAttValue)
|
||||
} //foreach
|
||||
// One last final check. If $emptyCount does not equal Array $col count, don't add
|
||||
if ($emptyCount != count($col)) {
|
||||
|
||||
if ($hasRequiredLabel) {
|
||||
if (is_array($col)) {
|
||||
if (isset($col['displayParams'])) {
|
||||
$col['displayParams']['required'] = true;
|
||||
} else {
|
||||
$col['displayParams'] = array('required' => true);
|
||||
}
|
||||
} else {
|
||||
$col = array('name' => strtolower($col), 'displayParams' => array('required' => true));
|
||||
}
|
||||
}
|
||||
|
||||
$metarow[] = $col;
|
||||
} //if
|
||||
} //foreach
|
||||
|
||||
$panels[$id] = $metarow;
|
||||
} //foreach
|
||||
|
||||
$this->mCustomPanels = $panels;
|
||||
$panels = $this->applyPreRules($moduleDir, $panels);
|
||||
|
||||
$templateMeta = array();
|
||||
if ($merge && !empty($masterCopy) && file_exists($masterCopy)) {
|
||||
$panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
|
||||
$templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
|
||||
}
|
||||
$panels = $this->applyRules($moduleDir, $panels);
|
||||
return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
|
||||
}
|
||||
|
||||
}
|
||||
191
include/SugarFields/Parsers/DetailViewMetaParser.php
Executable file
191
include/SugarFields/Parsers/DetailViewMetaParser.php
Executable file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* DetailViewMetaParser.php
|
||||
* This is a utility file that attempts to provide support for parsing pre 5.0 SugarCRM
|
||||
* DetailView.html files and produce a best guess detailviewdefs.php file equivalent.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
require_once('include/SugarFields/Parsers/MetaParser.php');
|
||||
|
||||
/**
|
||||
* DetailViewMetaParser.php
|
||||
* This class is responsible for handling the parsing of DetailView.html files from
|
||||
* SugarCRM versions prior to 5.x. It will make a best guess of translating the
|
||||
* HTML file to a metadata format.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
class DetailViewMetaParser extends MetaParser {
|
||||
|
||||
function DetailViewMetaParser() {
|
||||
$this->mView = 'DetailView';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* parse
|
||||
*
|
||||
* @param $filePath The file path of the HTML file to parse
|
||||
* @param $vardefs The module's vardefs
|
||||
* @param $moduleDir The module's directory
|
||||
* @param $merge boolean value indicating whether or not to merge the parsed contents
|
||||
* @param $masterCopy The file path of the mater copy of the metadata file to merge against
|
||||
* @return String format of metadata contents
|
||||
**/
|
||||
function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
|
||||
|
||||
// Grab file contents
|
||||
$contents = file_get_contents($filePath);
|
||||
|
||||
// Remove \n,\r characters to allow for better text parsing
|
||||
$contents = $this->trimHTML($contents);
|
||||
$contents = $this->stripFlavorTags($contents);
|
||||
|
||||
|
||||
// Notes DetailView.html file is messed up
|
||||
if($moduleDir == 'Notes') {
|
||||
$contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents);
|
||||
$contents = str_replace('</td></tr></table><script>', '</table><script>', $contents);
|
||||
$contents = str_replace("<tr><div id='portal_flag_row' name='portal_flag_row' style='display:none'>", "<div id='portal_flag_row' name='portal_flag_row' style='display:none'>", $contents);
|
||||
}
|
||||
|
||||
$contents = $this->fixDuplicateTrTags($contents);
|
||||
$contents = $this->fixRowsWithMissingTr($contents);
|
||||
|
||||
// Get all the tables
|
||||
$tables = $this->getElementsByType("table", $contents);
|
||||
|
||||
// Skip the first one
|
||||
$tables = array_slice($tables, 1);
|
||||
|
||||
$panels = array();
|
||||
$tableCount = 0;
|
||||
$metarow = array();
|
||||
foreach($tables as $table) {
|
||||
|
||||
$table = $this->fixTablesWithMissingTr($table);
|
||||
$tablerows = $this->getElementsByType("tr", $table);
|
||||
|
||||
foreach($tablerows as $trow) {
|
||||
|
||||
$metacolumns = array();
|
||||
$columns = $this->getElementsByType("td", $trow);
|
||||
$columns = array_reverse($columns, true);
|
||||
foreach($columns as $tcols) {
|
||||
|
||||
$sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
|
||||
if(empty($sugarAttrValue)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$def = '';
|
||||
$field = $this->getElementValue("span", $tcols);
|
||||
//If it's a space, simply add a blank string
|
||||
if($field == ' ') {
|
||||
$metacolumns[] = "";
|
||||
} else if(!empty($field)) {
|
||||
|
||||
preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER);
|
||||
if(!empty($matches)) {
|
||||
if(count($matches) > 1) {
|
||||
|
||||
$def = array();
|
||||
|
||||
$def['name'] = preg_match('/_c$/i', $matches[0][1]) ? $matches[0][1] : strtolower($matches[0][1]);
|
||||
foreach($matches as $m) {
|
||||
if(isset($vardefs[strtolower($m[1])])) {
|
||||
$def['name'] = strtolower($m[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field);
|
||||
$field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field);
|
||||
|
||||
foreach($matches as $tag[1]) {
|
||||
if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) {
|
||||
$field = str_replace($tag[1][1], '$'.$tag[1][1], $field);
|
||||
} else {
|
||||
$theField = preg_match('/_c$/i', $tag[1][1]) ? $tag[1][1] : strtolower($tag[1][1]);
|
||||
if(!empty($vardefs[$theField])) {
|
||||
$field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field);
|
||||
} else {
|
||||
$phpName = $this->findAssignedVariableName($tag[1][1], $filePath);
|
||||
$field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field);
|
||||
} //if-else
|
||||
}
|
||||
}
|
||||
|
||||
$def['customCode'] = $field;
|
||||
$def['description'] = 'This field was auto generated';
|
||||
} else {
|
||||
$def = strtolower($matches[0][1]);
|
||||
}
|
||||
} //if
|
||||
$metacolumns[] = $def;
|
||||
} //if
|
||||
} //foreach($tablecolumns as $tcols)
|
||||
|
||||
$metarow[] = array_reverse($metacolumns);
|
||||
} //foreach($tablerows as $trow)
|
||||
|
||||
|
||||
$id = $tableCount == 0 ? 'default' : $tableCount;
|
||||
$tableCount++;
|
||||
$panels[$id] = $metarow;
|
||||
|
||||
} //foreach($tables as $table)
|
||||
|
||||
$this->mCustomPanels = $panels;
|
||||
$panels = $this->applyPreRules($moduleDir, $panels);
|
||||
|
||||
$templateMeta = array();
|
||||
if($merge && !empty($masterCopy) && file_exists($masterCopy)) {
|
||||
$panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
|
||||
$templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
|
||||
}
|
||||
|
||||
$panels = $this->applyRules($moduleDir, $panels);
|
||||
return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
341
include/SugarFields/Parsers/EditViewMetaParser.php
Executable file
341
include/SugarFields/Parsers/EditViewMetaParser.php
Executable file
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* EdtiViewMetaParser.php
|
||||
* This is a utility file that attempts to provide support for parsing pre 5.0 SugarCRM
|
||||
* EditView.html files and produce a best guess editviewdefs.php file equivalent.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/MetaParser.php');
|
||||
|
||||
class EditViewMetaParser extends MetaParser {
|
||||
|
||||
function EditViewMetaParser() {
|
||||
$this->mView = 'EditView';
|
||||
}
|
||||
|
||||
/**
|
||||
* parse
|
||||
*
|
||||
* @param $filePath The file path of the HTML file to parse
|
||||
* @param $vardefs The module's vardefs
|
||||
* @param $moduleDir The module's directory
|
||||
* @param $merge boolean value indicating whether or not to merge the parsed contents
|
||||
* @param $masterCopy The file path of the mater copy of the metadata file to merge against
|
||||
* @return String format of metadata contents
|
||||
**/
|
||||
function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
|
||||
|
||||
global $app_strings;
|
||||
$contents = file_get_contents($filePath);
|
||||
$contents = $this->trimHTML($contents);
|
||||
$contents = $this->stripFlavorTags($contents);
|
||||
$moduleName = '';
|
||||
|
||||
$contents = $this->fixDuplicateTrTags($contents);
|
||||
$contents = $this->fixRowsWithMissingTr($contents);
|
||||
|
||||
$tables = $this->getElementsByType("table", $contents);
|
||||
$formElements = $this->getFormElements($tables[0]);
|
||||
$hiddenInputs = array();
|
||||
foreach($formElements as $elem) {
|
||||
$type = $this->getTagAttribute("type", $elem);
|
||||
if(preg_match('/hidden/si',$type)) {
|
||||
$name = $this->getTagAttribute("name", $elem);
|
||||
$value = $this->getTagAttribute("value", $elem);
|
||||
$hiddenInputs[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the second table in the page and onward
|
||||
$tables = array_slice($tables, 1);
|
||||
$panels = array();
|
||||
$tableCount = 0;
|
||||
$addedElements = array();
|
||||
$maxTableCountNum = 0;
|
||||
$tableCount = 0;
|
||||
foreach($tables as $table) {
|
||||
$table = $this->fixTablesWithMissingTr($table);
|
||||
$toptr = $this->getElementsByType("tr", $table);
|
||||
foreach($toptr as $tr) {
|
||||
$tabledata = $this->getElementsByType("table", $tr);
|
||||
$data = array();
|
||||
$panelKey = $tableCount == 0 ? "default" : '';
|
||||
foreach($tabledata as $t) {
|
||||
$vals = array_values($this->getElementsByType("tr", $t));
|
||||
if(preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) {
|
||||
array_shift($vals);
|
||||
$panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey;
|
||||
}
|
||||
|
||||
//If $panelKey is empty use the maxTableCountNum value
|
||||
if(empty($panelKey)) {
|
||||
$panels[$maxTableCountNum++] = $vals;
|
||||
} else {
|
||||
$panels[$panelKey] = $vals;
|
||||
}
|
||||
} //foreach
|
||||
$tableCount++;
|
||||
} //foreach;
|
||||
} //foreach
|
||||
|
||||
foreach($panels as $id=>$tablerows) {
|
||||
|
||||
$metarow = array();
|
||||
|
||||
foreach($tablerows as $trow) {
|
||||
|
||||
$emptyCount = 0;
|
||||
$tablecolumns = $this->getElementsByType("td", $trow);
|
||||
$col = array();
|
||||
$slot = 0;
|
||||
|
||||
foreach($tablecolumns as $tcols) {
|
||||
$hasRequiredLabel = false;
|
||||
|
||||
//Get the sugar attribute value in the span elements of each table row
|
||||
$sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'");
|
||||
|
||||
//If there was no sugar attribute, try id (some versions of EditView.html used this instead)
|
||||
if(empty($sugarAttrLabel)) {
|
||||
$sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'");
|
||||
}
|
||||
|
||||
//Check if this field is required
|
||||
if(!empty($sugarAttrLabel)) {
|
||||
$hasRequiredLabel = $this->hasRequiredSpanLabel($tcols);
|
||||
}
|
||||
|
||||
$sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
|
||||
|
||||
//If there was no sugar attribute, try id (some versions of EditView.html used this instead)
|
||||
if(empty($sugarAttrValue)) {
|
||||
$sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'");
|
||||
}
|
||||
|
||||
// If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs
|
||||
$sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false;
|
||||
$sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false;
|
||||
$slot++;
|
||||
|
||||
if($sugarAttrValue) {
|
||||
|
||||
$spanValue = $this->getElementValue("span", $tcols);
|
||||
|
||||
if(empty($spanValue)) {
|
||||
$spanValue = $this->getElementValue("slot", $tcols);
|
||||
}
|
||||
|
||||
if(empty($spanValue)) {
|
||||
$spanValue = $this->getElementValue("td", $tcols);
|
||||
}
|
||||
|
||||
//Get all the editable form elements' names
|
||||
$formElementNames = $this->getFormElementsNames($spanValue);
|
||||
$customField = $this->getCustomField($formElementNames);
|
||||
|
||||
$name = '';
|
||||
$fields = null;
|
||||
$customCode = null;
|
||||
|
||||
if(!empty($customField)) {
|
||||
// If it's a custom field we just set the name
|
||||
$name = $customField;
|
||||
|
||||
} else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) {
|
||||
// We are here if the $spanValue did not contain a form element for editing.
|
||||
// We will assume that it is read only (since there were no edit form elements)
|
||||
|
||||
|
||||
// If there is more than one matching {} value then try to find the right one to key off
|
||||
// based on vardefs.php file. Also, use the entire spanValue as customCode
|
||||
if(count($matches) > 1) {
|
||||
$name = $matches[0][1];
|
||||
$customCode = $spanValue;
|
||||
foreach($matches as $pair) {
|
||||
if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) {
|
||||
$customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode);
|
||||
} else {
|
||||
if(!empty($vardefs[$pair[1]])) {
|
||||
$name = $pair[1];
|
||||
$customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode);
|
||||
} else {
|
||||
$phpName = $this->findAssignedVariableName($pair[1], $filePath);
|
||||
$customCode = str_replace($pair[1], '$fields.'.strtolower($phpName).'.value', $customCode);
|
||||
} //if-else
|
||||
}
|
||||
} //foreach
|
||||
} else {
|
||||
//If it is only a label, skip
|
||||
if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) {
|
||||
continue;
|
||||
}
|
||||
$name = strtolower($matches[0][1]);
|
||||
}
|
||||
|
||||
} else if(is_array($formElementNames)) {
|
||||
|
||||
if(count($formElementNames) == 1) {
|
||||
|
||||
if(!empty($vardefs[$formElementNames[0]])) {
|
||||
$name = $formElementNames[0];
|
||||
} else {
|
||||
// Try to use the EdtiView.php file to find author's intent
|
||||
$name = $this->findAssignedVariableName($formElementNames[0], $filePath);
|
||||
|
||||
//If it's still empty, just use the entire block as customCode
|
||||
if(empty($vardefs[$name])) {
|
||||
//Replace any { characters just in case
|
||||
$customCode = str_replace('{', '{$', $spanValue);
|
||||
}
|
||||
} //if-else
|
||||
} else {
|
||||
//If it is an Array of form elements, it is likely the _id and _name relate field combo
|
||||
$relateName = $this->getRelateFieldName($formElementNames);
|
||||
if(!empty($relateName)) {
|
||||
$name = $relateName;
|
||||
} else {
|
||||
//One last attempt to scan $formElementNames for one vardef field only
|
||||
$name = $this->findSingleVardefElement($formElementNames, $vardefs);
|
||||
if(empty($name)) {
|
||||
$fields = array();
|
||||
$name = $formElementNames[0];
|
||||
foreach($formElementNames as $elementName) {
|
||||
if(isset($vardefs[$elementName])) {
|
||||
$fields[] = $elementName;
|
||||
} else {
|
||||
$fields[] = $this->findAssignedVariableName($elementName, $filePath);
|
||||
} //if-else
|
||||
} //foreach
|
||||
} //if
|
||||
} //if-else
|
||||
} //if-else
|
||||
}
|
||||
|
||||
// Build the entry
|
||||
if(preg_match("/<textarea/si", $spanValue)) {
|
||||
//special case for textarea form elements (add the displayParams)
|
||||
$displayParams = array();
|
||||
$displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
|
||||
$displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
|
||||
|
||||
if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
$field['displayParams'] = $displayParams;
|
||||
} else {
|
||||
$field = $name;
|
||||
}
|
||||
} else {
|
||||
|
||||
if(isset($fields) || isset($customCode)) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
if(isset($fields)) {
|
||||
$field['fields'] = $fields;
|
||||
}
|
||||
if(isset($customCode)) {
|
||||
$field['customCode'] = $customCode;
|
||||
$field['description'] = 'This field was auto generated';
|
||||
}
|
||||
} else {
|
||||
$emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
|
||||
$field = $name;
|
||||
}
|
||||
} //if-else if-else block
|
||||
|
||||
$addedField = is_array($field) ? $field['name'] : $field;
|
||||
if(empty($addedField) || empty($addedElements[$addedField])) {
|
||||
//Add the meta-data definition for required fields
|
||||
if($hasRequiredLabel) {
|
||||
if(is_array($field)) {
|
||||
if(isset($field['displayParams']) && is_array($field['displayParams'])) {
|
||||
$field['displayParams']['required']=true;
|
||||
} else {
|
||||
$field['displayParams'] = array('required'=>true);
|
||||
}
|
||||
} else {
|
||||
$field = array('name'=>strtolower($field), 'displayParams'=>array('required'=>true));
|
||||
}
|
||||
}
|
||||
$col[] = is_array($field) ? $field : strtolower($field);
|
||||
$addedElements[$addedField] = $addedField;
|
||||
}
|
||||
} //if($sugarAttValue)
|
||||
} //foreach
|
||||
|
||||
// One last final check. If $emptyCount does not equal Array $col count, don't add
|
||||
if($emptyCount != count($col)) {
|
||||
|
||||
if($hasRequiredLabel) {
|
||||
if(is_array($col)) {
|
||||
if(isset($col['displayParams'])) {
|
||||
$col['displayParams']['required']=true;
|
||||
} else {
|
||||
$col['displayParams']=array('required'=>true);
|
||||
}
|
||||
} else {
|
||||
$col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true));
|
||||
}
|
||||
}
|
||||
|
||||
$metarow[] = $col;
|
||||
} //if
|
||||
} //foreach
|
||||
|
||||
$panels[$id] = $metarow;
|
||||
|
||||
} //foreach
|
||||
|
||||
$this->mCustomPanels = $panels;
|
||||
$panels = $this->applyPreRules($moduleDir, $panels);
|
||||
|
||||
$templateMeta = array();
|
||||
if($merge && !empty($masterCopy) && file_exists($masterCopy)) {
|
||||
$panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
|
||||
$templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
|
||||
}
|
||||
$panels = $this->applyRules($moduleDir, $panels);
|
||||
return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
810
include/SugarFields/Parsers/MetaParser.php
Executable file
810
include/SugarFields/Parsers/MetaParser.php
Executable file
@@ -0,0 +1,810 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* MetaParser.php
|
||||
*
|
||||
* This is a utility base file to parse HTML
|
||||
* @author Collin Lee
|
||||
*/
|
||||
class MetaParser {
|
||||
|
||||
var $mPHPFile;
|
||||
var $mView;
|
||||
var $mModule;
|
||||
var $mCustomPanels;
|
||||
|
||||
function MetaParser() {
|
||||
|
||||
}
|
||||
|
||||
function parse() {
|
||||
return "NOT AVAILABLE";
|
||||
}
|
||||
|
||||
/**
|
||||
* getFormContents
|
||||
* Parses for contents enclosed within <form>...</form> tags
|
||||
*/
|
||||
function getFormContents($contents, $all = true) {
|
||||
if($all) {
|
||||
preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches);
|
||||
return $matches;
|
||||
}
|
||||
|
||||
preg_match("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches);
|
||||
return $this->convertToTagElement($matches);
|
||||
//return $matches;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getFormElements
|
||||
* Parses for input, select, textarea types from string content
|
||||
* @param $contents The String contents to parse
|
||||
* @return $matches Array of matches of PREG_SET_ORDER
|
||||
*/
|
||||
function getFormElements($contents) {
|
||||
preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER);
|
||||
$elems = array();
|
||||
foreach($matches[3] as $match) {
|
||||
$elems[] = $match;
|
||||
}
|
||||
return $elems;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getFormElementsNames
|
||||
* Parses for the name values of input, select, textarea types from string content
|
||||
* @param $contents The String contents to parse
|
||||
* @return $matches Array of name/value pairs
|
||||
*/
|
||||
function getFormElementsNames($contents) {
|
||||
preg_match_all("'(<[ ]*?)(textarea|input|select)[^>]*?name=[\'\"]([^\'\"]*?)(\[\])?(_basic)?[\'\"]([^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER);
|
||||
return !empty($matches[3]) ? $matches[3] : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTagAttribute
|
||||
* Returns the name/value of a tag attribute where name is set to $name
|
||||
* @param $name The name of the attribute
|
||||
* @param $contents The contents to parse
|
||||
* @param $filter Option regular expression to filter value
|
||||
* @return Array of name/value for matching attribute
|
||||
*/
|
||||
function getTagAttribute($name, $contents, $filter = '') {
|
||||
//$exp = "'".$name."[ ]*?=[ ]*?[\'\"]([a-zA-Z0-9\_\[\]]*)[\'\"]'si";
|
||||
|
||||
$exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si";
|
||||
preg_match_all($exp, $contents, $matches, PREG_SET_ORDER);
|
||||
if(empty($filter)) {
|
||||
return !empty($matches[0][1]) ? $matches[0][1] : '';
|
||||
}
|
||||
|
||||
$filtered = array();
|
||||
foreach($matches as $tag) {
|
||||
if(preg_match($filter, $tag[1])) {
|
||||
$filtered[] = $tag;
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* getTables
|
||||
* Returns an Array of the tables found in the file. If $tableClass parameter
|
||||
* is supplied, it'll return only those tables that have a matching class attribute
|
||||
* equal to $tableClass
|
||||
* @param $tableClass Optional table class parameter value
|
||||
* @return Array of table elements found
|
||||
*/
|
||||
function getTables($tableClass = null, $contents) {
|
||||
preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER);
|
||||
if($tableClass == null) {
|
||||
return $matches;
|
||||
}
|
||||
|
||||
$tables = array();
|
||||
foreach($matches as $key => $table) {
|
||||
if(strpos($table[1], $tableClass) > 0) {
|
||||
$tables[] = $table;
|
||||
}
|
||||
}
|
||||
return $this->convertToTagElement($tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* getElementsByType
|
||||
*
|
||||
* Returns an Array of all elements matching type. It will match
|
||||
* for the outermost tags. For example given contents:
|
||||
* "<tr><td>Text <table><tr><td>a</td></tr></table></td></tr>"
|
||||
* and method call getElementsByType("<td>", $contents) returns
|
||||
* "<td>Text <table><tr><td>a</td></tr></table></td>"
|
||||
*
|
||||
* @param $type The type of element to parse out and return
|
||||
* @return a tag element format Array
|
||||
*/
|
||||
function getElementsByType($type, $contents) {
|
||||
$x = strlen($contents);
|
||||
$mark = 0;
|
||||
$count = 0;
|
||||
$stag1 = "<" . trim($type, " <>") . '>';
|
||||
$stag2 = "<" . trim($type, " <>") . ' ';
|
||||
$etag = "</".$type.">";
|
||||
$sincrement = strlen($stag1);
|
||||
$eincrement = strlen($etag);
|
||||
$sarr = array();
|
||||
$values = array();
|
||||
|
||||
while($count < $x) {
|
||||
$stok = substr($contents, $count, $sincrement);
|
||||
$etok = substr($contents, $count, $eincrement);
|
||||
if($stok == $stag1 || $stok == $stag2) {
|
||||
//Reset mark;
|
||||
if(count($sarr) == 0) {
|
||||
$mark = $count;
|
||||
}
|
||||
$sarr[] = $count;
|
||||
|
||||
} else if($etok == $etag) {
|
||||
array_shift($sarr);
|
||||
if(count($sarr) == 0) {
|
||||
$val = substr($contents, $mark, ($count - $mark) + $eincrement);
|
||||
$values[] = $val;
|
||||
$mark = $count;
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* getElementValue
|
||||
*
|
||||
*/
|
||||
function getElementValue($type, $contents, $filter = "(.*?)") {
|
||||
$exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si";
|
||||
preg_match($exp, $contents, $matches);
|
||||
return isset($matches[1]) ? $matches[1] : '';
|
||||
}
|
||||
|
||||
|
||||
function stripComments($contents) {
|
||||
return preg_replace("'(<!--.*?-->)'si", "", $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* stripFlavorTags
|
||||
* This method accepts the file contents and uses the $GLOBALS['sugar_flavor'] value
|
||||
* to remove the flavor tags in the file contents if present. If $GLOBALS['sugar_flavor']
|
||||
* is not set, it defaults to PRO flavor
|
||||
* @param $contents The file contents as a String value
|
||||
* @param $result The file contents with non-matching flavor tags and their nested comments removed
|
||||
*/
|
||||
function stripFlavorTags($contents) {
|
||||
$flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO';
|
||||
$isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false;
|
||||
if($isPro) {
|
||||
$contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents);
|
||||
} else {
|
||||
$contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents);
|
||||
}
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMaxColumns
|
||||
* Returns the highest number of <td>...</td> blocks within a <tr>...</tr> block.
|
||||
* @param $contents The table contents to parse
|
||||
* @param $filter Optional filter to parse for an attribute within the td block.
|
||||
* @return The maximum column count
|
||||
*/
|
||||
function getMaxColumns($contents, $filter) {
|
||||
preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER);
|
||||
$max = 0;
|
||||
foreach($matches as $tableRows) {
|
||||
$count = substr_count($tableRows[2], $filter);
|
||||
if($count > $max) {
|
||||
$max = $count;
|
||||
}
|
||||
}
|
||||
|
||||
return $max;
|
||||
}
|
||||
|
||||
function convertToTagElement($matches) {
|
||||
|
||||
$elements = array();
|
||||
|
||||
foreach($matches as $data) {
|
||||
// We need 4 because the 1,2,3 indexes make up start,body,end
|
||||
if(count($data) == 4) {
|
||||
$element = array();
|
||||
$element['start'] = $data[1];
|
||||
$element['body'] = $data[2];
|
||||
$element['end'] = $data[3];
|
||||
$elements[] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
return empty($elements) ? $matches : $elements;
|
||||
}
|
||||
|
||||
/*
|
||||
* trimHTML
|
||||
* This function removes the \r (return), \n (newline) and \t (tab) markup from string
|
||||
*/
|
||||
function trimHTML($contents) {
|
||||
$contents = str_replace(array("\r"), array(""), $contents);
|
||||
$contents = str_replace(array("\n"), array(""), $contents);
|
||||
$contents = str_replace(array("\t"), array(""), $contents);
|
||||
return $contents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getJavascript
|
||||
*
|
||||
* This method parses the given $contents String and grabs all <script...>...</script> blocks.
|
||||
* The method also converts values enclosed within "{...}" blocks that may need to be converted
|
||||
* to Smarty syntax.
|
||||
*
|
||||
* @param $contents The HTML String contents to parse
|
||||
*
|
||||
* @return $javascript The formatted script blocks or null if none found
|
||||
*/
|
||||
function getJavascript($contents, $addLiterals = true) {
|
||||
|
||||
$javascript = null;
|
||||
|
||||
//Check if there are Javascript blocks of code to process
|
||||
preg_match_all("'(<script[^>]*?>)(.*?)(</script[^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER);
|
||||
if(empty($matches)) {
|
||||
return $javascript;
|
||||
}
|
||||
|
||||
foreach($matches[0] as $scriptBlock) {
|
||||
$javascript .= "\n" . $scriptBlock;
|
||||
} //foreach
|
||||
|
||||
$javascript = substr($javascript, 1);
|
||||
|
||||
//Remove stuff first
|
||||
//1) Calendar.setup {..} blocks
|
||||
$javascript = preg_replace('/Calendar.setup[\s]*[\(][^\)]*?[\)][\s]*;/si', '', $javascript);
|
||||
|
||||
//Find all blocks that may need to be replaced with Smarty syntax
|
||||
preg_match_all("'([\{])([a-zA-Z0-9_]*?)([\}])'si", $javascript, $matches, PREG_PATTERN_ORDER);
|
||||
if(!empty($matches)) {
|
||||
$replace = array();
|
||||
|
||||
foreach($matches[0] as $xTemplateCode) {
|
||||
if(!isset($replace[$xTemplateCode])) {
|
||||
$replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode);
|
||||
} //if
|
||||
} //foreach
|
||||
|
||||
$javascript = str_replace(array_keys($replace), array_values($replace), $javascript);
|
||||
} //if
|
||||
|
||||
if(!$addLiterals) {
|
||||
return $javascript;
|
||||
}
|
||||
|
||||
return $this->parseDelimiters($javascript);
|
||||
|
||||
}
|
||||
|
||||
function parseDelimiters($javascript) {
|
||||
$newJavascript = '';
|
||||
$scriptLength = strlen($javascript);
|
||||
$count = 0;
|
||||
$inSmartyVariable = false;
|
||||
|
||||
while($count < $scriptLength) {
|
||||
|
||||
if($inSmartyVariable) {
|
||||
$start = $count;
|
||||
$numOfChars = 1;
|
||||
while(isset($javascript[$count]) && $javascript[$count] != '}') {
|
||||
$count++;
|
||||
$numOfChars++;
|
||||
}
|
||||
|
||||
$newJavascript .= substr($javascript, $start, $numOfChars);
|
||||
$inSmartyVariable = false;
|
||||
|
||||
} else {
|
||||
|
||||
$char = $javascript[$count];
|
||||
$nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1];
|
||||
|
||||
if($char == "{" && $nextChar == "$") {
|
||||
$inSmartyVariable = true;
|
||||
$newJavascript .= $javascript[$count];
|
||||
} else if($char == "{") {
|
||||
$newJavascript .= " {ldelim} ";
|
||||
} else if($char == "}") {
|
||||
$newJavascript .= " {rdelim} ";
|
||||
} else {
|
||||
$newJavascript .= $javascript[$count];
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
} //while
|
||||
|
||||
return $newJavascript;
|
||||
}
|
||||
|
||||
/**
|
||||
* findAssignedVariableName
|
||||
* This method provides additional support in attempting to parse the module's corresponding
|
||||
* PHP file for either the EditView or DetailView. In the event that the subclasses cannot
|
||||
* find a matching vardefs.php entry in the HTML file, this method can be called to parse the
|
||||
* PHP file to see if the assignment was made using the bean's variable. If so, we return
|
||||
* this variable name.
|
||||
*
|
||||
* @param $name The tag name found in the HTML file for which we want to search
|
||||
* @param $filePath The full file path for the HTML file
|
||||
* @return The variable name found in PHP file, original $name variable if not found
|
||||
*/
|
||||
function findAssignedVariableName($name, $filePath) {
|
||||
|
||||
if($this->mPHPFile == "INVALID") {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if(!isset($this->mPHPFile)) {
|
||||
if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) {
|
||||
$dir = $matches[1];
|
||||
} else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) {
|
||||
$dir = $matches[1];
|
||||
}
|
||||
|
||||
if(!isset($dir) || !is_dir($dir)) {
|
||||
$this->mPHPFile = "INVALID";
|
||||
return $name;
|
||||
}
|
||||
|
||||
$filesInDir = $this->dirList($dir);
|
||||
$phpFile = $matches[2].'.*?[\.]php';
|
||||
foreach($filesInDir as $file) {
|
||||
if(preg_match("/$phpFile/", $file)) {
|
||||
$this->mPHPFile = $matches[1] . $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) {
|
||||
$this->mPHPFile = "INVALID";
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
$phpContents = file_get_contents($this->mPHPFile);
|
||||
$uname = strtoupper($name);
|
||||
if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* dirList
|
||||
* Utility method to list all the files in a given directory.
|
||||
*
|
||||
* @param $directory The directory to scan
|
||||
* @return $results The files in the directory that were found
|
||||
*/
|
||||
function dirList ($directory) {
|
||||
|
||||
// create an array to hold directory list
|
||||
$results = array();
|
||||
|
||||
// create a handler for the directory
|
||||
$handler = opendir($directory);
|
||||
|
||||
// keep going until all files in directory have been read
|
||||
while ($file = readdir($handler)) {
|
||||
// if $file isn't this directory or its parent,
|
||||
// add it to the results array
|
||||
if ($file != '.' && $file != '..')
|
||||
$results[] = $file;
|
||||
}
|
||||
|
||||
// tidy up: close the handler
|
||||
closedir($handler);
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* isCustomField
|
||||
* This method checks the mixed variable $elementNames to see if it is a custom field. A custom
|
||||
* field is simply defined as a field that ends with "_c". If $elementNames is an Array
|
||||
* any matching custom field value will result in a true evaluation
|
||||
* @param $elementNames Array or String value of form element name(s).
|
||||
* @return String name of custom field; null if none found
|
||||
*/
|
||||
function getCustomField($elementNames) {
|
||||
|
||||
if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(is_string($elementNames)) {
|
||||
if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) {
|
||||
return count($matches) == 1 ? $matches[0] : $matches[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach($elementNames as $name) {
|
||||
if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) {
|
||||
return count($matches) == 1 ? $matches[0] : $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function applyPreRules($moduleDir, $panels) {
|
||||
if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) {
|
||||
require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php");
|
||||
$class = $moduleDir."ParseRule";
|
||||
$parseRule = new $class();
|
||||
$panels = $parseRule->preParse($panels, $this->mView);
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function applyRules($moduleDir, $panels) {
|
||||
return $this->applyPostRules($moduleDir, $panels);
|
||||
}
|
||||
|
||||
function applyPostRules($moduleDir, $panels) {
|
||||
//Run module specific rules
|
||||
if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) {
|
||||
require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php");
|
||||
$class = $moduleDir."ParseRule";
|
||||
$parseRule = new $class();
|
||||
$panels = $parseRule->parsePanels($panels, $this->mView);
|
||||
}
|
||||
|
||||
//Now run defined rules
|
||||
require_once("include/SugarFields/Parsers/Rules/ParseRules.php");
|
||||
$rules = ParseRules::getRules();
|
||||
|
||||
foreach($rules as $rule) {
|
||||
if(!file_exists($rule['file'])) {
|
||||
$GLOBALS['log']->error("Cannot run rule for " . $rule['file']);
|
||||
continue;
|
||||
} //if
|
||||
require_once($rule['file']);
|
||||
$runRule = new $rule['class'];
|
||||
$panels = $runRule->parsePanels($panels, $this->mView);
|
||||
|
||||
} //foreach
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) {
|
||||
|
||||
$header = "<?php\n\n";
|
||||
|
||||
if(empty($templateMeta)) {
|
||||
$header .= "\$viewdefs['$moduleDir']['$this->mView'] = array(
|
||||
'templateMeta' => array('maxColumns' => '2',
|
||||
'widths' => array(
|
||||
array('label' => '10', 'field' => '30'),
|
||||
array('label' => '10', 'field' => '30')
|
||||
),
|
||||
),";
|
||||
} else {
|
||||
$header .= "\$viewdefs['$moduleDir']['$this->mView'] = array(
|
||||
'templateMeta' =>" . var_export($templateMeta, true) . ",";
|
||||
}
|
||||
|
||||
//Replace all the @sq (single quote tags that may have been inserted)
|
||||
$header = preg_replace('/\@sq/', "'", $header);
|
||||
|
||||
/*
|
||||
$contents = file_get_contents($htmlFilePath);
|
||||
|
||||
$javascript = $this->getJavascript($contents, true);
|
||||
|
||||
if(!empty($javascript)) {
|
||||
$javascript = str_replace("'", "\\'", $javascript);
|
||||
$header .= "\n 'javascript' => '" . $javascript . "',\n";
|
||||
} //if
|
||||
*/
|
||||
$header .= "\n 'panels' =>";
|
||||
|
||||
$footer = "
|
||||
\n
|
||||
);
|
||||
?>";
|
||||
|
||||
$metadata = '';
|
||||
$body = var_export($panels, true);
|
||||
$metadata = $header . $body . $footer;
|
||||
$metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata);
|
||||
return $metadata;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mergePanels
|
||||
* This function merges the $panels Array against the $masterCopy's meta data definition
|
||||
* @param $panels meta data Array to merge
|
||||
* @param $moduleDir Directory name of the module
|
||||
* @param $masterCopy file path to the meta data master copy
|
||||
* @return Array of merged $panel definition
|
||||
*/
|
||||
function mergePanels($panels, $vardefs, $moduleDir, $masterCopy) {
|
||||
require($masterCopy);
|
||||
$masterpanels = $viewdefs[$moduleDir][$this->mView]['panels'];
|
||||
$hasMultiplePanels = $this->hasMultiplePanels($masterpanels);
|
||||
|
||||
if(!$hasMultiplePanels) {
|
||||
$keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']);
|
||||
if(!empty($keys) && count($keys) == 1) {
|
||||
if(strtolower($keys[0]) == 'default') {
|
||||
$masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]);
|
||||
} else {
|
||||
$firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']);
|
||||
$masterpanels = array('default'=> $firstPanel[0]);
|
||||
}
|
||||
} else {
|
||||
$masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']);
|
||||
}
|
||||
}
|
||||
foreach($masterpanels as $name=>$masterpanel) {
|
||||
if(isset($panels[$name])) {
|
||||
// Get all the names in the panel
|
||||
$existingElements = array();
|
||||
$existingLocation = array();
|
||||
|
||||
foreach($panels[$name] as $rowKey=>$row) {
|
||||
foreach($row as $colKey=>$column) {
|
||||
if(is_array($column) && !empty($column['name'])) {
|
||||
$existingElements[$column['name']] = $column['name'];
|
||||
$existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey);
|
||||
} else if(!is_array($column) && !empty($column)) {
|
||||
$existingElements[$column] = $column;
|
||||
$existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey);
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
// Now check against the $masterCopy
|
||||
foreach($masterpanel as $rowKey=>$row) {
|
||||
|
||||
$addRow = array();
|
||||
|
||||
foreach($row as $colKey=>$column) {
|
||||
if(is_array($column) && isset($column['name'])) {
|
||||
$id = $column['name'];
|
||||
} else if(!is_array($column) && !empty($column)) {
|
||||
$id = $column;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if(empty($existingElements[$id])) {
|
||||
//Only add if
|
||||
// 1) if it is a required field (as defined in metadata)
|
||||
// 2) or if it has a customLabel and customCode (a very deep customization)
|
||||
if((is_array($column) && !empty($column['displayParams']['required'])) ||
|
||||
(is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) {
|
||||
$addRow[] = $column;
|
||||
}
|
||||
} else {
|
||||
//Use definition from master copy instead
|
||||
$panels[$existingLocation[$id]['panel']][$existingLocation[$id]['row']][$existingLocation[$id]['col']] = $column;
|
||||
}
|
||||
} //foreach
|
||||
|
||||
// Add it to the $panels
|
||||
if(!empty($addRow)) {
|
||||
$panels[$name][] = $addRow;
|
||||
}
|
||||
} //foreach
|
||||
|
||||
} else {
|
||||
$panels[$name] = $masterpanel;
|
||||
}
|
||||
} //foreach
|
||||
|
||||
// We're not done yet... go through the $panels Array now and try to remove duplicate
|
||||
// or empty panels
|
||||
foreach($panels as $name=>$panel) {
|
||||
if(count($panel) == 0 || !isset($masterpanels[$name])) {
|
||||
unset($panels[$name]);
|
||||
}
|
||||
} //foreach
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
/**
|
||||
* mergeTemplateMeta
|
||||
* This function merges the $templateMeta Array against the $masterCopy's meta data definition
|
||||
* @param $templateMeta meta data Array to merge
|
||||
* @param $moduleDir Directory name of the module
|
||||
* @param $masterCopy file path to the meta data master copy
|
||||
* @return Array of merged $templateMeta definition
|
||||
*/
|
||||
function mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy) {
|
||||
require($masterCopy);
|
||||
$masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta'];
|
||||
|
||||
if(isset($masterTemplateMeta['javascript'])) {
|
||||
//Insert the getJSPath code back into src value
|
||||
$masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']);
|
||||
// BEGIN SUGAR INT
|
||||
//$GLOBALS['log']->fatal(var_export($masterTemplateMeta['javascript'], true));
|
||||
// END SUGAR INT
|
||||
}
|
||||
|
||||
return $masterTemplateMeta;
|
||||
}
|
||||
|
||||
function hasRequiredSpanLabel($html) {
|
||||
if(empty($html)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html);
|
||||
}
|
||||
|
||||
function hasMultiplePanels($panels) {
|
||||
|
||||
if(!isset($panels) || empty($panels) || !is_array($panels)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($panels as $panel) {
|
||||
if(!empty($panel) && !is_array($panel)) {
|
||||
return false;
|
||||
} else {
|
||||
foreach($panel as $row) {
|
||||
if(!empty($row) && !is_array($row)) {
|
||||
return false;
|
||||
} //if
|
||||
} //foreach
|
||||
} //if-else
|
||||
} //foreach
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getRelateFieldName($mixed='') {
|
||||
if(!is_array($mixed)) {
|
||||
return '';
|
||||
} else if(count($mixed) == 2){
|
||||
$id = '';
|
||||
$name = '';
|
||||
foreach($mixed as $el) {
|
||||
if(preg_match('/_id$/', $el)) {
|
||||
$id = $el;
|
||||
} else if(preg_match('/_name$/', $el)) {
|
||||
$name = $el;
|
||||
}
|
||||
}
|
||||
return (!empty($id) && !empty($name)) ? $name : '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getCustomPanels() {
|
||||
return $this->mCustomPanels;
|
||||
}
|
||||
|
||||
/**
|
||||
* fixTablesWithMissingTr
|
||||
* This is a very crude function to fix instances where files declared a table as
|
||||
* <table...><td> instead of <table...><tr><td>. Without this helper function, the
|
||||
* parsing could messed up.
|
||||
*
|
||||
*/
|
||||
function fixTablesWithMissingTr($tableContents) {
|
||||
if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) {
|
||||
return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents);
|
||||
}
|
||||
return $tableContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* fixRowsWithMissingTr
|
||||
* This is a very crude function to fix instances where files have an </tr> tag immediately followed by a <td> tag
|
||||
*/
|
||||
function fixRowsWithMissingTr($tableContents) {
|
||||
if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) {
|
||||
return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents);
|
||||
}
|
||||
return $tableContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* fixDuplicateTrTags
|
||||
* This is a very crude function to fix instances where files have two consecutive <tr> tags
|
||||
*/
|
||||
function fixDuplicateTrTags($tableContents) {
|
||||
if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) {
|
||||
return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents);
|
||||
}
|
||||
return $tableContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* findSingleVardefElement
|
||||
* Scans array of form elements to see if just one is a vardef element and, if so,
|
||||
* return that vardef name
|
||||
*/
|
||||
function findSingleVardefElement($formElements=array(), $vardefs=array()) {
|
||||
if(empty($formElements) || !is_array($formElements)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$found = array();
|
||||
foreach($formElements as $el) {
|
||||
if(isset($vardefs[$el])) {
|
||||
$found[] = $el;
|
||||
}
|
||||
}
|
||||
|
||||
return count($found) == 1 ? $found[0] : '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
265
include/SugarFields/Parsers/QuickCreateMetaParser.php
Executable file
265
include/SugarFields/Parsers/QuickCreateMetaParser.php
Executable file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* EdtiViewMetaParser.php
|
||||
* This is a utility file that attempts to provide support for parsing pre 5.0 SugarCRM
|
||||
* QuickCreate.html files and produce a best guess editviewdefs.php file equivalent.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/MetaParser.php');
|
||||
|
||||
class QuickCreateMetaParser extends MetaParser {
|
||||
|
||||
function QuickCreateMetaParser() {
|
||||
$this->mView = 'QuickCreate';
|
||||
}
|
||||
|
||||
/**
|
||||
* parse
|
||||
*
|
||||
* @param $filePath The file path of the HTML file to parse
|
||||
* @param $vardefs The module's vardefs
|
||||
* @param $moduleDir The module's directory
|
||||
* @param $merge boolean value indicating whether or not to merge the parsed contents
|
||||
* @param $masterCopy The file path of the mater copy of the metadata file to merge against
|
||||
* @return String format of metadata contents
|
||||
**/
|
||||
function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
|
||||
|
||||
global $app_strings;
|
||||
$contents = file_get_contents($filePath);
|
||||
|
||||
// The contents are not well formed so we add this section to make it easier to parse
|
||||
$contents = $this->trimHTML($contents) . '</td></tr></table>';
|
||||
$moduleName = '';
|
||||
|
||||
$forms = $this->getElementsByType("form", $contents);
|
||||
$tables = $this->getElementsByType("table", $forms[0] . "</td></tr></table>");
|
||||
$mainrow = $this->getElementsByType("tr", $tables[1]);
|
||||
$rows = substr($mainrow[0], strpos($mainrow[0], "</tr>"));
|
||||
$tablerows = $this->getElementsByType("tr", $rows);
|
||||
|
||||
foreach($tablerows as $trow) {
|
||||
|
||||
$emptyCount = 0;
|
||||
$tablecolumns = $this->getElementsByType("td", $trow);
|
||||
$col = array();
|
||||
$slot = 0;
|
||||
|
||||
foreach($tablecolumns as $tcols) {
|
||||
|
||||
$sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'");
|
||||
$sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
|
||||
|
||||
// If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs
|
||||
$sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false;
|
||||
$sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false;
|
||||
|
||||
$slot++;
|
||||
|
||||
if($sugarAttrValue) {
|
||||
|
||||
$spanValue = strtolower($this->getElementValue("span", $tcols));
|
||||
if(empty($spanValue)) {
|
||||
$spanValue = strtolower($this->getElementValue("slot", $tcols));
|
||||
}
|
||||
if(empty($spanValue)) {
|
||||
$spanValue = strtolower($this->getElementValue("td", $tcols));
|
||||
}
|
||||
|
||||
//Get all the editable form elements' names
|
||||
$formElementNames = $this->getFormElementsNames($spanValue);
|
||||
$customField = $this->getCustomField($formElementNames);
|
||||
|
||||
$name = '';
|
||||
$readOnly = false;
|
||||
$fields = null;
|
||||
$customCode = null;
|
||||
|
||||
if(!empty($customField)) {
|
||||
// If it's a custom field we just set the name
|
||||
$name = $customField;
|
||||
|
||||
} else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) {
|
||||
// We are here if the $spanValue did not contain a form element for editing.
|
||||
// We will assume that it is read only (since there were no edit form elements)
|
||||
|
||||
|
||||
// If there is more than one matching {} value then try to find the right one to key off
|
||||
// based on vardefs.php file. Also, use the entire spanValue as customCode
|
||||
if(count($matches) > 1) {
|
||||
$name = $matches[0][1];
|
||||
$customCode = $spanValue;
|
||||
foreach($matches as $pair) {
|
||||
if(preg_match("/^(mod[\.]|app[\.]).*?/s", $pair[1])) {
|
||||
$customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode);
|
||||
} else if(!empty($vardefs[$pair[1]])) {
|
||||
$name = $pair[1];
|
||||
$customCode = str_replace($pair[1], '$fields.'.$pair[1].'.value', $customCode);
|
||||
}
|
||||
} //foreach
|
||||
} else {
|
||||
//If it is only a label, skip
|
||||
if(preg_match("/^(mod[\.]|app[\.]).*?/s", $matches[0][1])) {
|
||||
continue;
|
||||
} else if(preg_match("/^[\$].*?/s", $matches[0][1])) {
|
||||
$name = '{' . strtoupper($matches[0][1]) . '}';
|
||||
} else {
|
||||
$name = $matches[0][1];
|
||||
}
|
||||
}
|
||||
|
||||
$readOnly = true;
|
||||
} else if(is_array($formElementNames)) {
|
||||
|
||||
if(count($formElementNames) == 1) {
|
||||
if(!empty($vardefs[$formElementNames[0]])) {
|
||||
$name = $formElementNames[0];
|
||||
}
|
||||
} else {
|
||||
$fields = array();
|
||||
foreach($formElementNames as $elementName) {
|
||||
// What we are doing here is saying that we will add all your fields assuming
|
||||
// there are none that are of type relate or link. However, if we find such a type
|
||||
// we'll take the first one found and assume that is the field you want (the SugarFields
|
||||
// library will handle rendering the popup and select and clear buttons for you).
|
||||
if(isset($vardefs[$elementName])) {
|
||||
$type = $vardefs[$elementName]['type'];
|
||||
if($type != 'relate' && $type != 'link') {
|
||||
$fields[] = $elementName;
|
||||
$name = $elementName;
|
||||
} else {
|
||||
unset($fields);
|
||||
$name = $elementName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //if-else
|
||||
}
|
||||
|
||||
// Build the entry
|
||||
if(preg_match("/<textarea/si", $spanValue)) {
|
||||
//special case for textarea form elements (add the displayParams)
|
||||
$displayParams = array();
|
||||
$displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
|
||||
$displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
|
||||
|
||||
if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
$field['displayParams'] = $displayParams;
|
||||
} else {
|
||||
$field = $name;
|
||||
}
|
||||
$col[] = $field;
|
||||
} else if($readOnly) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
$field['type'] = 'readonly';
|
||||
if(isset($customCode)) {
|
||||
$field['customCode'] = $customCode;
|
||||
} //if
|
||||
$col[] = $field;
|
||||
} else {
|
||||
|
||||
if(isset($fields) || isset($customCode)) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
if(isset($fields)) {
|
||||
$field['fields'] = $fields;
|
||||
}
|
||||
if(isset($customCode)) {
|
||||
$field['customCode'] = $customCode;
|
||||
}
|
||||
|
||||
$col[] = $field;
|
||||
} else {
|
||||
$emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
|
||||
$col[] = $name;
|
||||
}
|
||||
} //if-else if-else block
|
||||
} //if($sugarAttrValue)
|
||||
} //foreach
|
||||
|
||||
// One last final check. If $emptyCount does not equal Array $col count, don't add
|
||||
if($emptyCount != count($col)) {
|
||||
$metarow[] = $col;
|
||||
} //if
|
||||
} //foreach
|
||||
|
||||
$templateMeta = array();
|
||||
$templateMeta['form']['buttons'] = 'button';
|
||||
|
||||
preg_match_all("/(<input[^>]*?)>/si", $tables[0], $matches);
|
||||
$buttons = array();
|
||||
foreach($matches[0] as $button) {
|
||||
$buttons[] = array('customCode'=>$button);
|
||||
}
|
||||
$templateMeta['form']['buttons'] = $buttons;
|
||||
|
||||
$formElements = $this->getFormElements($contents);
|
||||
$hiddenInputs = array();
|
||||
foreach($formElements as $elem) {
|
||||
$type = $this->getTagAttribute("type", $elem);
|
||||
if(preg_match('/hidden/si',$type, $matches)) {
|
||||
$name = $this->getTagAttribute("name", $elem);
|
||||
$value = $this->getTagAttribute("value", $elem);
|
||||
$index = stripos($value, '$REQUEST');
|
||||
$value = !empty($index) ? '$smarty.request.' . substr($value, 10) : $value;
|
||||
$hiddenInputs[] = '<input id="' . $name . '" name="' . $name . '" value="' . $value . '">';
|
||||
}
|
||||
} //foreach
|
||||
|
||||
$templateMeta['form']['hidden'] = $hiddenInputs;
|
||||
$templateMeta['widths'] = array(array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30'));
|
||||
$templateMeta['maxColumns'] = 2;
|
||||
|
||||
$panels = array();
|
||||
$panels['default'] = $metarow;
|
||||
$panels = $this->appplyRules($moduleDir, $panels);
|
||||
return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
67
include/SugarFields/Parsers/Rules/AccountsParseRule.php
Executable file
67
include/SugarFields/Parsers/Rules/AccountsParseRule.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class AccountsParseRule extends BaseRule {
|
||||
|
||||
function AccountsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^parent_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'parent_name';
|
||||
} else if($this->matches($column, '/_address_(street|country)$/') && is_array($column) && isset($column['customCode'])) {
|
||||
if(preg_match('/\{\$fields\.push_contacts_(billing|shipping)\.value\}/', $column['customCode'], $m)) {
|
||||
$column['customCode'] = str_replace('{$fields.push_contacts_'. $m[1].'.value}', '{$custom_code_'.$m[1].'}', $column['customCode']);
|
||||
$panels[$name][$rowCount][$key] = $column;
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
77
include/SugarFields/Parsers/Rules/ActivitiesParseRule.php
Executable file
77
include/SugarFields/Parsers/Rules/ActivitiesParseRule.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class ActivitiesParseRule extends BaseRule {
|
||||
|
||||
function ActivitiesParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^duration_minutes$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'duration_hours';
|
||||
} else if($this->matches($column, '/^time_start$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'date_start';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^duration_minutes$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
153
include/SugarFields/Parsers/Rules/AddressRule.php
Executable file
153
include/SugarFields/Parsers/Rules/AddressRule.php
Executable file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* AddressRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules. Address fields defined in the
|
||||
* address panel will be removed as the new metadata definition will be merged later.
|
||||
* If the address fields are outside the address panel, we will keep them as is, but
|
||||
* ensure that they are not defined as Arrays.
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class AddressRule extends BaseRule {
|
||||
|
||||
function AddressRule() {
|
||||
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
$searchedAddressPanel = array();
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
|
||||
$isAddressPanel = $name == 'lbl_address_information';
|
||||
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
|
||||
if($this->matches($column, '/_address_(city|state|country|postalcode)$/si')) {
|
||||
if($view == 'DetailView' && !is_array($column)) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if($view == 'DetailView' && $this->matches($column, '/_address_country$/') && is_array($column)) {
|
||||
$match = $this->getMatch($column, '/(.*?)_address_country$/');
|
||||
$panels[$name][$rowCount][$key]['name'] = $match[1] . '_address_street';
|
||||
$panels[$name][$rowCount][$key]['label'] = 'LBL_' . strtoupper($match[1]) . '_ADDRESS';
|
||||
} else if($view == 'EditView' && $isAddressPanel) {
|
||||
|
||||
$field = is_array($column) ? $column['name'] : $column;
|
||||
preg_match('/^(.*?)_address_/si', $field, $matches);
|
||||
|
||||
if(empty($searchedAddressPanel[$matches[1]])) {
|
||||
$intact = $this->hasAddressFieldsIntact($panel, $matches[1]);
|
||||
|
||||
//now we actually have to go back in and replace the street field
|
||||
if(!$intact) {
|
||||
$panels = $this->removeStreetFieldOverride($panels, $matches[1]);
|
||||
}
|
||||
|
||||
$addressFieldsIntact[$matches[1]] = $intact;
|
||||
$searchedAddressPanel[$matches[1]] = true;
|
||||
}
|
||||
|
||||
//Only remove in address panel if the street field is in there by itself
|
||||
if($addressFieldsIntact[$matches[1]]) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
}
|
||||
} else if($this->matches($column, '/^push_.*?_(shipping|billing)$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
return $panels;
|
||||
}
|
||||
|
||||
/**
|
||||
* hasAddressFieldsIntact
|
||||
* This function checks to see if the address fields for the given street key is
|
||||
* intact. This means that all five fields (street, city, state, country and postalcode)
|
||||
* have not been moved from the address panel
|
||||
*
|
||||
* @param $addressPanel Array of address panel contents
|
||||
* @param $suffix The address suffix (billing, shipping, primary, alternate) to check for
|
||||
* @return boolean
|
||||
*/
|
||||
function hasAddressFieldsIntact($addressPanel, $suffix) {
|
||||
$expression = '/^' . $suffix . '_address_(street|city|state|country|postalcode)$/si';
|
||||
$count = 0;
|
||||
foreach($addressPanel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, $expression)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count == 5;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* removeStreetFieldOverride
|
||||
* This function scans the panels and locates the street address field for the given key
|
||||
* and replaces the Array definition (from the merging process) with a String value.
|
||||
* @param $panels Array of the view's panels
|
||||
* @param $street String key value of the street to search for
|
||||
* @returns $panels Array of view's panels with street value substituted
|
||||
*/
|
||||
function removeStreetFieldOverride($panels, $street) {
|
||||
$expression = '/^' . $street . '_address_street$/si';
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, $expression)) {
|
||||
$panels[$name][$rowCount][$key] = $street . '_address_street';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
94
include/SugarFields/Parsers/Rules/BaseRule.php
Executable file
94
include/SugarFields/Parsers/Rules/BaseRule.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* BaseRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules.
|
||||
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
class BaseRule {
|
||||
|
||||
function BaseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function postParse($panels, $view) {
|
||||
return $this->parsePanels($panels, $view);
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function isCustomField($mixed) {
|
||||
if(is_array($mixed) && isset($mixed['name']) && preg_match('/.*?_c$/s', $mixed['name'])) {
|
||||
return true;
|
||||
} else if(!is_array($mixed) && isset($mixed) && preg_match('/.*?_c$/s', $mixed)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function matches($mixed, $regExp) {
|
||||
if(is_array($mixed) && isset($mixed['name']) && preg_match($regExp, $mixed['name'])) {
|
||||
return true;
|
||||
} else if(!is_array($mixed) && isset($mixed) && preg_match($regExp, $mixed)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getMatch($mixed, $regExp) {
|
||||
if(is_array($mixed) && isset($mixed['name']) && preg_match($regExp, $mixed['name'], $matches)) {
|
||||
return $matches;
|
||||
} else if(!is_array($mixed) && isset($mixed) && preg_match($regExp, $mixed, $matches)) {
|
||||
return $matches;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
62
include/SugarFields/Parsers/Rules/BugsParseRule.php
Executable file
62
include/SugarFields/Parsers/Rules/BugsParseRule.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class BugsParseRule extends BaseRule {
|
||||
|
||||
function BugsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^release$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'found_in_release';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
68
include/SugarFields/Parsers/Rules/CallsParseRule.php
Executable file
68
include/SugarFields/Parsers/Rules/CallsParseRule.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/ActivitiesParseRule.php');
|
||||
|
||||
class CallsParseRule extends ActivitiesParseRule {
|
||||
|
||||
function CallsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
$panels = parent::preParse($panels, $view);
|
||||
if($view == 'EditView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^direction$/si')) {
|
||||
$panels[$name][$rowCount][$key] = 'status';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
$panels = parent::parsePanels($panels, $view);
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
74
include/SugarFields/Parsers/Rules/CampaignsParseRule.php
Executable file
74
include/SugarFields/Parsers/Rules/CampaignsParseRule.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class CampaignsParseRule extends BaseRule {
|
||||
|
||||
function CampaignsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'EditView') {
|
||||
$frequencyAdded = false;
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if(empty($column) && !$frequencyAdded) {
|
||||
//Add the frequency label
|
||||
$panels[$name][$rowCount][$key] = 'frequency';
|
||||
$frequencyAdded = true;
|
||||
} else if($this->matches($column, '/^deleted$/')) {
|
||||
//This is to fix the error where the Created By field
|
||||
//in Campaigns EditView.html actually references the deleted field
|
||||
//We will just remove the field since you shouldn't be able to edit this information anyway
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
//If all the row/columns were taken up, then add frequency as a last row
|
||||
if(!$frequencyAdded) {
|
||||
$panels['default'][][] = 'frequency';
|
||||
}
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
81
include/SugarFields/Parsers/Rules/ContactsParseRule.php
Executable file
81
include/SugarFields/Parsers/Rules/ContactsParseRule.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class ContactsParseRule extends BaseRule {
|
||||
|
||||
function ContactsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function preParse($panels, $view) {
|
||||
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^(last_)?name$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'full_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function parsePanels(& $panels, $view) {
|
||||
|
||||
if($view == 'EditView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/portal_password1/si')) {
|
||||
$panels[$name][$rowCount][$key] = array('name'=>'portal_password1', 'type'=>'password', 'customCode'=>'<input id="portal_password1" name="portal_password1" type="password" size="32" maxlength="32" value="{$fields.portal_password.value}">', 'label'=>'LBL_PORTAL_PASSWORD');
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
62
include/SugarFields/Parsers/Rules/ContractsParseRule.php
Executable file
62
include/SugarFields/Parsers/Rules/ContractsParseRule.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class ContractsParseRule extends BaseRule {
|
||||
|
||||
function ContractsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'EditView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^expiration_notice_date$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'expiration_notice';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
96
include/SugarFields/Parsers/Rules/DocumentsParseRule.php
Executable file
96
include/SugarFields/Parsers/Rules/DocumentsParseRule.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class DocumentsParseRule extends BaseRule {
|
||||
|
||||
function DocumentsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^related_doc_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'related_doc_name';
|
||||
} else if($this->matches($column, '/^related_doc_rev_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = ($view == 'EditView') ? 'related_doc_rev_number' : 'related_doc_name';
|
||||
} else if($this->matches($column, '/^user_date_format$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'active_date';
|
||||
} else if($this->matches($column, '/^is_template_checked$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'is_template';
|
||||
} else if($this->matches($column, '/^last_rev_creator$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'last_rev_created_name';
|
||||
} else if($this->matches($column, '/^last_rev_date$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'last_rev_create_date';
|
||||
} else if($this->matches($column, '/^save_file$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'filename';
|
||||
} else if($this->matches($column, '/^subcategory$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'subcategory_id';
|
||||
} else if($this->matches($column, '/^category$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'category_id';
|
||||
} else if($this->matches($column, '/^related_document_version$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'related_doc_rev_number';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
return $panels;
|
||||
}
|
||||
|
||||
function parsePanels(& $panels, $view) {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/related_doc_id/si') ||
|
||||
$this->matches($column, '/related_doc_rev_id/si') ||
|
||||
$this->matches($column, '/latest_revision/si') ||
|
||||
$this->matches($column, '/file_name/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
121
include/SugarFields/Parsers/Rules/EmailAddressRule.php
Executable file
121
include/SugarFields/Parsers/Rules/EmailAddressRule.php
Executable file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* EmailAddressRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules. We basically scan for email1 or
|
||||
* email2 defined outside of the email address panel and remove it.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class EmailAddressRule extends BaseRule {
|
||||
|
||||
function EmailAddressRule() {
|
||||
|
||||
}
|
||||
|
||||
function parsePanels(& $panels, $view) {
|
||||
|
||||
if($view == 'DetailView') {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
|
||||
if(preg_match('/lbl_email_addresses/si', $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
|
||||
if($this->isCustomField($column)) {
|
||||
continue;
|
||||
} else if(is_array($column) && !empty($column['name']) && preg_match('/^email(s|2)$/si', $column['name']) && !isset($column['type'])) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if($this->matches($column, '/^email[1]_link$/si')) {
|
||||
$panels[$name][$rowCount][$key] = 'email1';
|
||||
} else if($this->matches($column, '/^email[2]_link$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if(!is_array($column) && !empty($column)) {
|
||||
if(preg_match('/^email(s|2)$/si', $column) ||
|
||||
preg_match('/^invalid_email$/si', $column) ||
|
||||
preg_match('/^email_opt_out$/si', $column) ||
|
||||
preg_match('/^primary_email$/si', $column)) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
} else if($view == 'EditView') {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
|
||||
if(preg_match('/lbl_email_addresses/si', $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
|
||||
if($this->isCustomField($column)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($this->matches($column, '/email(s)*?([1|2])*?/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
|
||||
} //foreach
|
||||
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
90
include/SugarFields/Parsers/Rules/EmptyRowRule.php
Executable file
90
include/SugarFields/Parsers/Rules/EmptyRowRule.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* EmptyRowRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules. This rule goes through the panels
|
||||
* and deletes rows for which there are no fields.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class EmptyRowRule extends BaseRule {
|
||||
|
||||
function EmptyRowRule() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
$emptyCount = 0;
|
||||
|
||||
foreach($row as $key=>$column) {
|
||||
if(is_array($column) && (!isset($column['name']) || empty($column['name']))) {
|
||||
$emptyCount++;
|
||||
} else if(!is_array($column) && (!isset($column) || empty($column))) {
|
||||
$emptyCount++;
|
||||
}
|
||||
} //foreach
|
||||
|
||||
// If we have unset everything, then just remove the whole row entirely
|
||||
if($emptyCount == count($row)) {
|
||||
unset($panels[$name][$rowCount]);
|
||||
continue;
|
||||
} else if(count($row) > 2) {
|
||||
foreach($row as $key=>$column) {
|
||||
if(empty($column) || $column == '') {
|
||||
unset($panels[$name][$rowCount][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
65
include/SugarFields/Parsers/Rules/LeadsParseRule.php
Executable file
65
include/SugarFields/Parsers/Rules/LeadsParseRule.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class LeadsParseRule extends BaseRule {
|
||||
|
||||
function LeadsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^lead_view_c$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'full_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
return $panels;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
64
include/SugarFields/Parsers/Rules/MeetingsParseRule.php
Executable file
64
include/SugarFields/Parsers/Rules/MeetingsParseRule.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/ActivitiesParseRule.php');
|
||||
|
||||
class MeetingsParseRule extends ActivitiesParseRule {
|
||||
|
||||
function MeetingsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
$panels = parent::preParse($panels, $view);
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
//Fix issue of not having parent_name in Meetings vardefs.php in pre 5.x versions
|
||||
if($this->matches($column, '/^tag.parent$/') || $this->matches($column, '/^parent_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'parent_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
64
include/SugarFields/Parsers/Rules/NotesParseRule.php
Executable file
64
include/SugarFields/Parsers/Rules/NotesParseRule.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class NotesParseRule extends BaseRule {
|
||||
|
||||
function NotesParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^related_doc_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'related_doc_name';
|
||||
} else if($this->matches($column, '/^related_doc_rev_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = ($view == 'EditView') ? 'related_doc_rev_number' : 'related_doc_name';
|
||||
} else if($this->matches($column, '/^filelink$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'filename';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
62
include/SugarFields/Parsers/Rules/OpportunitiesParseRule.php
Executable file
62
include/SugarFields/Parsers/Rules/OpportunitiesParseRule.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class OpportunitiesParseRule extends BaseRule {
|
||||
|
||||
function OpportunitiesParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if ($this->matches($column, '/^type$/i')) {
|
||||
$panels[$name][$rowCount][$key] = 'opportunity_type';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
70
include/SugarFields/Parsers/Rules/ParseRules.php
Executable file
70
include/SugarFields/Parsers/Rules/ParseRules.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* ParseRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules.
|
||||
|
||||
* @author Collin Lee
|
||||
*/
|
||||
class ParseRules {
|
||||
|
||||
function ParseRules() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getRules
|
||||
* Return Array of rules to run
|
||||
*
|
||||
*/
|
||||
function getRules() {
|
||||
$rules = array();
|
||||
$rules[] = array("class"=>"UndefinedVardefRule", "file"=>"include/SugarFields/Parsers/Rules/UndefinedVardefRule.php");
|
||||
$rules[] = array("class"=>"VariableCleanupRule", "file"=>"include/SugarFields/Parsers/Rules/VariableCleanupRule.php");
|
||||
$rules[] = array("class"=>"VariableSubstitutionRule", "file"=>"include/SugarFields/Parsers/Rules/VariableSubstitutionRule.php");
|
||||
$rules[] = array("class"=>"AddressRule", "file"=>"include/SugarFields/Parsers/Rules/AddressRule.php");
|
||||
$rules[] = array("class"=>"EmailAddressRule", "file"=>"include/SugarFields/Parsers/Rules/EmailAddressRule.php");
|
||||
$rules[] = array("class"=>"EmptyRowRule", "file"=>"include/SugarFields/Parsers/Rules/EmptyRowRule.php");
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
68
include/SugarFields/Parsers/Rules/ProductsParseRule.php
Executable file
68
include/SugarFields/Parsers/Rules/ProductsParseRule.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class ProductsParseRule extends BaseRule {
|
||||
|
||||
function ProductsParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if ($this->matches($column, '/^url$/i')) {
|
||||
$panels[$name][$rowCount][$key] = 'website';
|
||||
} else if ($this->matches($column, '/^manufacturer$/i')) {
|
||||
$panels[$name][$rowCount][$key] = 'manufacturer_name';
|
||||
} else if ($this->matches($column, '/^category$/i')) {
|
||||
$panels[$name][$rowCount][$key] = 'category_name';
|
||||
} else if ($this->matches($column, '/^type$/i')) {
|
||||
$panels[$name][$rowCount][$key] = 'type_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
130
include/SugarFields/Parsers/Rules/QuotesParseRule.php
Executable file
130
include/SugarFields/Parsers/Rules/QuotesParseRule.php
Executable file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class QuotesParseRule extends BaseRule {
|
||||
|
||||
function QuotesParseRule() {
|
||||
|
||||
}
|
||||
|
||||
function preParse($panels, $view) {
|
||||
|
||||
if($view == 'DetailView') {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
if($name == 'default') {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/billing_address_country/')) {
|
||||
$column['label'] = 'LBL_BILL_TO';
|
||||
$column['name'] = 'billing_address_street';
|
||||
$panels[$name][$rowCount][$key] = $column;
|
||||
} else if($this->matches($column, '/shipping_address_country/')) {
|
||||
$column['label'] = 'LBL_SHIP_TO';
|
||||
$column['name'] = 'shipping_address_street';
|
||||
$panels[$name][$rowCount][$key] = $column;
|
||||
} else if($this->matches($column, '/^date_quote_closed$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'date_quote_expected_closed';
|
||||
} else if($this->matches($column, '/^tag\.opportunity$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'opportunity_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //if
|
||||
} //foreach
|
||||
}
|
||||
|
||||
if($view == 'EditView') {
|
||||
$processedBillToPanel = false;
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
// This panel is an exception in that it has nested tables...
|
||||
if($name == 'lbl_bill_to' && !$processedBillToPanel) {
|
||||
$billToPanel = $panel;
|
||||
$newBillPanel = array();
|
||||
foreach($billToPanel as $subpanel) {
|
||||
$col = array();
|
||||
foreach($subpanel as $rowCount=>$row) {
|
||||
|
||||
if(!is_array($row)) {
|
||||
if(!$this->matches($row, '/^(shipping|billing)_address_(street|city|state|country|postalcode)$/si')) {
|
||||
$col[] = $row;
|
||||
}
|
||||
} else {
|
||||
foreach($row as $key=>$column) {
|
||||
if(is_array($column)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($this->matches($column, '/^(billing|shipping)_(account|contact)_name$/')) {
|
||||
$match = $this->getMatch($column, '/^(billing|shipping)_(account|contact)_name$/');
|
||||
$col[$match[0]] = $match[0];
|
||||
} else if(!$this->matches($column, '/^(shipping|billing)_address_(street|city|state|country|postalcode)$/si')) {
|
||||
$col[] = $column;
|
||||
}
|
||||
} //foreach
|
||||
}
|
||||
} //foreach
|
||||
if(!empty($col)) {
|
||||
$newBillPanel[] = $col;
|
||||
}
|
||||
} //foreach
|
||||
$panels['lbl_bill_to'] = $newBillPanel;
|
||||
$processedBillToPanel = true;
|
||||
continue;
|
||||
} //if
|
||||
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
//We are just going to clean up address fields since we have
|
||||
//to insert a new address panel anyway
|
||||
if($this->matches($column, '/^(shipping|billing)_address_(street|city|state|country|postalcode)$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
return $panels;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
74
include/SugarFields/Parsers/Rules/UndefinedVardefRule.php
Executable file
74
include/SugarFields/Parsers/Rules/UndefinedVardefRule.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* UndefinedVardefRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class UndefinedVardefRule extends BaseRule {
|
||||
|
||||
function UndefinedVardefRule() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if(is_array($column) && isset($column['name']) && empty($column['name'])) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if(!is_array($column) && isset($column['name']) && empty($column['name'])) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
105
include/SugarFields/Parsers/Rules/VariableCleanupRule.php
Executable file
105
include/SugarFields/Parsers/Rules/VariableCleanupRule.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* VariableCleanupRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class VariableCleanupRule extends BaseRule {
|
||||
|
||||
function VariableCleanupRule() {
|
||||
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
//This converts variable ended with "_c_checked" to just "_c" (for checkboxes in DetailView)
|
||||
if(!is_array($column) && isset($column) && preg_match('/(.*?)_c_checked$/s', $column, $matches)) {
|
||||
if(count($matches) == 2) {
|
||||
$panels[$name][$rowCount][$key] = $matches[1] . "_c";
|
||||
}
|
||||
} else if($this->matches($column, '/^parent_id$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if($this->matches($column, '/^assigned_user_id$/si')) {
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
|
||||
} else if ($view == 'EditView') {
|
||||
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^(.*?)_c\[\]$/s')) {
|
||||
//This converts multienum variables named with [] suffix back to normal and removes custom code
|
||||
$val = $this->getMatch($column, '/^(.*?)_c\[\]$/s');
|
||||
$panels[$name][$rowCount][$key] = $val[1] . '_c';
|
||||
} else if($this->matches($column, '/^parent_id$/si')) {
|
||||
//Remove parent_id field (replaced with parent_name from master copy)
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if($this->matches($column, '/^assigned_user_id$/si')) {
|
||||
//Remove assigned_user_id field (replaced with assigned_user_name from master copy)
|
||||
$panels[$name][$rowCount][$key] = '';
|
||||
} else if($this->matches($column, '/^RADIOOPTIONS_/si')) {
|
||||
//This converts radioenum variables
|
||||
$val = $this->getMatch($column, '/^RADIOOPTIONS_(.*)?$/si');
|
||||
$panels[$name][$rowCount][$key] = $val[1];
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
136
include/SugarFields/Parsers/Rules/VariableSubstitutionRule.php
Executable file
136
include/SugarFields/Parsers/Rules/VariableSubstitutionRule.php
Executable file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* VariableSubstitutionRule.php
|
||||
*
|
||||
* This is a utility base class to provide further refinement when converting
|
||||
* pre 5.x files to the new meta-data rules. This rule substitutes the current
|
||||
* definitions will the standard meta-data ones.
|
||||
*
|
||||
* @author Collin Lee
|
||||
*/
|
||||
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
|
||||
class VariableSubstitutionRule extends BaseRule {
|
||||
|
||||
function VariableSubstitutionRule() {
|
||||
|
||||
}
|
||||
|
||||
function parsePanels($panels, $view) {
|
||||
if($view == 'DetailView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
if($this->matches($column, '/^date_entered$/') || $this->matches($column, '/^created_by$/')) {
|
||||
$panels[$name][$rowCount][$key] = array (
|
||||
'name' => 'date_entered',
|
||||
'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}',
|
||||
'label' => 'LBL_DATE_ENTERED',
|
||||
);
|
||||
} else if($this->matches($column, '/^team.*?(_name)?$/s')) {
|
||||
$panels[$name][$rowCount][$key] = 'team_name';
|
||||
} else if($this->matches($column, '/^date_modified$/') || $this->matches($column, '/^modified_by$/')) {
|
||||
$panels[$name][$rowCount][$key] = array (
|
||||
'name' => 'date_modified',
|
||||
'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}',
|
||||
'label' => 'LBL_DATE_MODIFIED',
|
||||
);
|
||||
} else if($this->matches($column, '/^assigned.*?(_to|_name|_link)$/s')) {
|
||||
//Remove "assigned_to" variable... this will be replaced with "assigned_to"
|
||||
$panels[$name][$rowCount][$key] = 'assigned_user_name';
|
||||
} else if($this->matches($column, '/^vcard_link$/')) {
|
||||
$panels[$name][$rowCount][$key] = array (
|
||||
'name' => 'full_name',
|
||||
'customCode' => '{$fields.full_name.value} <input type="button" class="button" name="vCardButton" value="{$MOD.LBL_VCARD}" onClick="document.vcard.submit();">',
|
||||
'label' => 'LBL_NAME',
|
||||
);
|
||||
} else if($this->matches($column, '/^parent_type$/si')) {
|
||||
$panels[$name][$rowCount][$key] = 'parent_name';
|
||||
} else if($this->matches($column, '/^account_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'account_name';
|
||||
} else if($this->matches($column, '/^contact_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'contact_name';
|
||||
} else if($this->matches($column, '/^reports_to_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'report_to_name';
|
||||
} else if($this->matches($column, '/^reminder_time$/')) {
|
||||
$panels[$name][$rowCount][$key] = array(
|
||||
'name'=>'reminder_checked',
|
||||
'fields'=>array('reminder_checked', 'reminder_time')
|
||||
);
|
||||
} else if($this->matches($column, '/^currency(_name)*$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'currency_id';
|
||||
} else if($this->matches($column, '/^quote_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'quote_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
} else if($view == 'EditView') {
|
||||
foreach($panels as $name=>$panel) {
|
||||
foreach($panel as $rowCount=>$row) {
|
||||
foreach($row as $key=>$column) {
|
||||
|
||||
if($this->matches($column, '/^salutation$/si') && is_array($column) && isset($column['fields']) && count($column['fields']) == 2) {
|
||||
//Change salutation field to salutation + first_name'
|
||||
$panels[$name][$rowCount][$key] = array (
|
||||
'name' => 'first_name',
|
||||
'customCode' => '{html_options name="salutation" options=$fields.salutation.options selected=$fields.salutation.value} <input name="first_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
|
||||
);
|
||||
} else if($this->matches($column, '/^parent_type$/si')) {
|
||||
$panels[$name][$rowCount][$key] = 'parent_name';
|
||||
} else if($this->matches($column, '/^currency(_name)$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'currency_id';
|
||||
} else if($this->matches($column, '/^quote_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'quote_name';
|
||||
} else if($this->matches($column, '/^account_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'account_name';
|
||||
} else if($this->matches($column, '/^contact_id$/')) {
|
||||
$panels[$name][$rowCount][$key] = 'contact_name';
|
||||
}
|
||||
} //foreach
|
||||
} //foreach
|
||||
} //foreach
|
||||
}
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
269
include/SugarFields/Parsers/SearchFormMetaParser.php
Executable file
269
include/SugarFields/Parsers/SearchFormMetaParser.php
Executable file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* 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
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('include/SugarFields/Parsers/MetaParser.php');
|
||||
|
||||
class SearchFormMetaParser extends MetaParser {
|
||||
|
||||
function SearchFormMetaParser() {
|
||||
$this->mView = 'Search';
|
||||
}
|
||||
|
||||
/**
|
||||
* parse
|
||||
* @param $mixed
|
||||
* @return $obj A MetaDataBean instance
|
||||
**/
|
||||
function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
|
||||
|
||||
$contents = file_get_contents($filePath);
|
||||
$contents = $this->trimHTML($contents);
|
||||
|
||||
// Get the second table in the page and onward
|
||||
$tables = $this->getElementsByType("table", $contents);
|
||||
//basic search table
|
||||
$basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs);
|
||||
$advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs);
|
||||
if(file_exists($masterCopy)) {
|
||||
require($masterCopy);
|
||||
$layouts = $searchdefs[$moduleDir]['layout'];
|
||||
|
||||
if(isset($layouts['basic_search'])) {
|
||||
$basicSection = $this->mergeSection($basicSection, $layouts['basic_search']);
|
||||
$basicSection = $this->applyRules($moduleDir, $basicSection);
|
||||
}
|
||||
|
||||
if(isset($layouts['advanced_search'])) {
|
||||
$advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']);
|
||||
$advancedSection = $this->applyRules($moduleDir, $advancedSection);
|
||||
}
|
||||
} //if
|
||||
|
||||
$header = "<?php\n\n";
|
||||
$header .= "\$searchdefs['$moduleDir'] = array(
|
||||
'templateMeta' => array('maxColumns' => '3', 'widths' => array('label' => '10', 'field' => '30')),
|
||||
'layout' => array(
|
||||
\n\t'basic_search' =>";
|
||||
$header .= "\t" . var_export($basicSection, true);
|
||||
$header .= "\n\t,'advanced_search' =>";
|
||||
$header .= "\t" . var_export($advancedSection, true);
|
||||
$header .= "
|
||||
),\n
|
||||
);
|
||||
?>";
|
||||
|
||||
$header = preg_replace('/(\d+)[\s]=>[\s]?/',"",$header);
|
||||
return $header;
|
||||
|
||||
}
|
||||
|
||||
function mergeSection($section, $masterSection) {
|
||||
|
||||
// Get all the names in the panel
|
||||
$existingElements = array();
|
||||
$existingLocation = array();
|
||||
|
||||
foreach($section as $rowKey=>$row) {
|
||||
if(is_array($row) && !empty($row['name'])) {
|
||||
$existingElements[$row['name']] = $row['name'];
|
||||
$existingLocation[$row['name']] = array("row"=>$rowKey);
|
||||
} else if(!is_array($row) && !empty($row)) {
|
||||
$existingElements[$row] = $row;
|
||||
$existingLocation[$row] = array("row"=>$rowKey);
|
||||
}
|
||||
} //foreach
|
||||
|
||||
// Now check against the $masterCopy
|
||||
foreach($masterSection as $row) {
|
||||
|
||||
$addEntry = '';
|
||||
$id = is_array($row) ? $row['name'] : $row;
|
||||
|
||||
/*
|
||||
if(!isset($existingElements[$id])) {
|
||||
//$addEntry = $row;
|
||||
}
|
||||
*/
|
||||
|
||||
if(isset($existingElements[$id])) {
|
||||
//Use master copy instead
|
||||
$section[$existingLocation[$id]['row']] = $row;
|
||||
}
|
||||
|
||||
// Add it to the $panels
|
||||
/*
|
||||
if(!empty($addEntry)) {
|
||||
$section[] = $addEntry;
|
||||
}
|
||||
*/
|
||||
} //foreach
|
||||
|
||||
return $section;
|
||||
}
|
||||
|
||||
function processSection($section, $table, $filePath, $vardefs=array()) {
|
||||
|
||||
$toptr = $this->getElementsByType("tr", $table);
|
||||
|
||||
if(!is_array($toptr) || empty($toptr)) {
|
||||
$GLOBALS['log']->error("Could not process top row (<tr>) for $section section");
|
||||
$GLOBALS['log']->error($table);
|
||||
return array();
|
||||
}
|
||||
|
||||
$tabledata = $this->getElementsByType("table", $toptr[0]);
|
||||
|
||||
if(empty($tabledata)) {
|
||||
$GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate");
|
||||
$GLOBALS['log']->error($toptr[0]);
|
||||
$tabledata[0] = "<table>{$table}</table>";
|
||||
}
|
||||
|
||||
if(is_array($tabledata) && !empty($tabledata[0])) {
|
||||
$rows = $this->getElementsByType("tr", $tabledata[0]);
|
||||
} else {
|
||||
$rows = $toptr[0];
|
||||
}
|
||||
|
||||
if(!is_array($rows)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$metarow = array();
|
||||
foreach($rows as $trow) {
|
||||
$tablecolumns = $this->getElementsByType("td", $trow);
|
||||
|
||||
$emptyCount = 0;
|
||||
$metacolumn = array();
|
||||
$col = null;
|
||||
|
||||
foreach($tablecolumns as $tcols) {
|
||||
|
||||
$spanValue = strtolower($this->getElementValue("span", $tcols));
|
||||
$spanValue2 = strtolower($this->getElementValue("slot", $tcols));
|
||||
$spanValue = !empty($spanValue2) ? $spanValue2 : $spanValue;
|
||||
$spanValue3 = strtolower($this->getElementValue("td", $tcols));
|
||||
$spanValue = !empty($spanValue3) ? $spanValue3 : $spanValue;
|
||||
|
||||
//Get all the editable form elements' names
|
||||
$formElementNames = $this->getFormElementsNames($spanValue);
|
||||
$customField = $this->getCustomField($formElementNames);
|
||||
|
||||
$name = '';
|
||||
$fields = null;
|
||||
$customCode = null;
|
||||
|
||||
if(!empty($customField)) {
|
||||
// If it's a custom field we just set the name
|
||||
$name = $customField;
|
||||
} else if(is_array($formElementNames) && count($formElementNames) == 1
|
||||
&& (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) {
|
||||
$name = $formElementNames[0];
|
||||
}
|
||||
|
||||
//Skip and continue if $name is empty
|
||||
if(empty($name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build the entry
|
||||
if(preg_match("/<textarea/si", $spanValue)) {
|
||||
//special case for textarea form elements (add the displayParams)
|
||||
$displayParams = array();
|
||||
$displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
|
||||
$displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
|
||||
|
||||
if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
$field['displayParams'] = $displayParams;
|
||||
} else {
|
||||
$field = $name;
|
||||
}
|
||||
|
||||
$col = $field;
|
||||
|
||||
} else {
|
||||
|
||||
if(isset($fields)) {
|
||||
$field = array();
|
||||
$field['name'] = $name;
|
||||
if(isset($fields)) {
|
||||
$field['fields'] = $fields;
|
||||
}
|
||||
|
||||
if(!empty($customCode)) {
|
||||
$field['customCode'] = $customCode;
|
||||
}
|
||||
|
||||
$col = $field;
|
||||
} else {
|
||||
$emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
|
||||
$col = $name;
|
||||
}
|
||||
} //if-else if-else block
|
||||
$metarow[] = $col;
|
||||
} //foreach
|
||||
|
||||
// One last final check. If $emptyCount does not equal Array $col count, don't add
|
||||
if($emptyCount != count($col)) {
|
||||
//$metarow[] = $col;
|
||||
} //if
|
||||
|
||||
} //foreach
|
||||
|
||||
return $metarow;
|
||||
}
|
||||
|
||||
function applyRules($moduleDir, $section=array()) {
|
||||
require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
|
||||
$baseRule = new BaseRule();
|
||||
if(!is_array($section)) {
|
||||
$GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array");
|
||||
return $section;
|
||||
}
|
||||
|
||||
foreach($section as $key=>$row) {
|
||||
//Override email1 fields
|
||||
if($baseRule->matches($row, '/^email1$/si')) {
|
||||
$section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name');
|
||||
}
|
||||
}
|
||||
return $section;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user