function display($preview = false) { $packageName = !empty($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null; $subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName, $subpanelName); /* BEGIN - SECURITY GROUPS */ $groupLayout = ""; if (!empty($_REQUEST['grpLayout'])) { $groupLayout = $_REQUEST['grpLayout']; } global $groupName; $groupName = "Default"; if (!isset($groupLayout) || empty($groupLayout)) { $groupLayout = ""; } else { //Get group name for display require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupFocus->retrieve($groupLayout); $groupName = $groupFocus->name; } /* END - SECURITY GROUPS */ $smarty = $this->constructSmarty($parser); //SECURITY GROUPS $smarty->assign('grpLayout', $groupLayout); if ($preview) { echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl"); } else { $ajax = $this->constructAjax(); $ajax->addSection('center', $this->translatedViewType, $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); } }
/** * 删除缓存,从新生成所有文章 * 只有在登录后才有效,但是当前尚未实现登录 * * @return $this * @throws Exception */ public function Update() { global $postHelper; // 删除所有缓存的文章 $files = glob(CACHE_DIR . '/*.post'); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } $postHelper->Clear(); // 生成所有文章 $list = $this->getPostFileList(); foreach ($list as $file) { if (mb_check_encoding($file, 'gbk')) { echo "add post ", mb_convert_encoding($file, 'utf-8', 'gbk'), " <br>\n"; } $post = ParserFactory::TryParseFile($file); if ($post) { $postHelper->addPost($post); } else { throw new Exception("Parse file '{$file}' to post filed."); } } return $this; }
function display() { $this->parser = ParserFactory::getParser(MB_PORTAL . strtolower($this->editLayout), $this->editModule, null, null, MB_PORTAL); $smarty = new Sugar_Smarty(); //Add in the module we are viewing to our current mod strings global $mod_strings, $current_language; $editModStrings = return_module_language($current_language, $this->editModule); $mod_strings = sugarArrayMerge($editModStrings, $mod_strings); $smarty->assign('mod', $mod_strings); $smarty->assign('MOD', $mod_strings); // assign buttons $images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone'); foreach ($images as $image => $file) { $smarty->assign($image, SugarThemeRegistry::current()->getImage($file, '', null, null, '.gif', $file)); } $smarty->assign('icon_delete', SugarThemeRegistry::current()->getImage('icon_Delete', '', 48, 48, '.gif', $mod_strings['LBL_MB_DELETE'])); $buttons = array(); $buttons[] = array('id' => 'saveBtn', 'image' => SugarThemeRegistry::current()->getImage($images['icon_save'], '', null, null, '.gif', $mod_strings['LBL_BTN_SAVE']), 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(Studio2.checkCalcFields(\"{$_REQUEST['view']}\", \"ERROR_CALCULATED_PORTAL_FIELDS\"))Studio2.handleSave();'"); $buttons[] = array('id' => 'publishBtn', 'image' => SugarThemeRegistry::current()->getImage($images['icon_publish'], '', null, null, '.gif', $mod_strings['LBL_BTN_PUBLISH']), 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVEPUBLISH'], 'actionScript' => "onclick='if(Studio2.checkCalcFields(\"{$_REQUEST['view']}\", \"ERROR_CALCULATED_PORTAL_FIELDS\"))Studio2.handlePublish();'"); $html = ""; foreach ($buttons as $button) { if ($button['id'] == "spacer") { $html .= "<td style='width:{$button['width']}'> </td>"; } else { $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' " . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' " . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}' ></td>"; } } $smarty->assign('buttons', $html); // assign fields and layout $smarty->assign('available_fields', $this->parser->getAvailableFields()); $smarty->assign('field_defs', $this->parser->getFieldDefs()); $smarty->assign('layout', $this->parser->getLayout()); $smarty->assign('view_module', $this->editModule); $smarty->assign('calc_field_list', json_encode($this->parser->getCalculatedFields())); $smarty->assign('view', $this->editLayout); $smarty->assign('maxColumns', $this->parser->getMaxColumns()); $smarty->assign('fieldwidth', '150px'); $smarty->assign('translate', true); $smarty->assign('fromPortal', true); // flag for form submittal - when the layout is submitted the actions are the same for layouts and portal layouts, but the parsers must be different... if (!empty($this->parser->usingWorkingFile)) { $smarty->assign('layouttitle', $GLOBALS['mod_strings']['LBL_LAYOUT_PREVIEW']); } else { $smarty->assign('layouttitle', $GLOBALS['mod_strings']['LBL_CURRENT_LAYOUT']); } $ajax = new AjaxCompose(); $ajax->addCrumb(translate('LBL_SUGARPORTAL', 'ModuleBuilder'), 'ModuleBuilder.main("sugarportal")'); $ajax->addCrumb(translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&portal=1&layout=1")'); $ajax->addCrumb(ucwords(translate('LBL_MODULE_NAME', $this->editModule)), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&portal=1&view_module=' . $this->editModule . '")'); $ajax->addCrumb(ucwords($this->editLayout), ''); // set up language files $smarty->assign('language', $this->parser->getLanguage()); // for sugar_translate in the smarty template //navjeet- assistant logic has changed //include('modules/ModuleBuilder/language/en_us.lang.php'); //$smarty->assign('assistantBody', $mod_strings['assistantHelp']['module']['editView'] ); $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_EDIT_LAYOUT'], $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl')); echo $ajax->getJavascript(); }
public function setUp() { require 'include/modules.php'; $GLOBALS['beanList'] = $beanList; $GLOBALS['beanFiles'] = $beanFiles; $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $this->_parser = ParserFactory::getParser('EditView', 'Accounts'); }
public function ListAvailableParsers() { $logger = \Swiftriver\Core\Setup::GetLogger(); $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method invoked]", \PEAR_LOG_DEBUG); $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [START: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG); $parsers = ParserFactory::ReturnAllAvailablePushParsers(); $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [END: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG); $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method finished]", \PEAR_LOG_DEBUG); return $parsers; }
public static function removeAllCreatedFields() { foreach (self::$_fieldsAdded as $module_name => $views) { foreach ($views as $view => $fields) { $parser = ParserFactory::getParser($view, $module_name); foreach ($fields as $field_name) { $parser->removeField($field_name); } $parser->handleSave(false); unset($parser); } } }
/** * This method will take the information prvided in the * instance of a Swiftriver\Core\ObjectModel\Channel object * and will make a call to the channel to fetch and content * that can be fetched and then parse the content into an array * of Swiftriver\Core\ObjectModel\Content items * * @param Swiftriver\Core\ObjectModel\Channel $channel * @return Swiftriver\Core\ObjectModel\Content[] $contentItems */ public function FetchContentFromChannel($channel) { //get the type of the channel $channelType = $channel->GetType(); //Get a Parser from the ParserFactory based on the channel type $factory = ParserFactory::GetParser($channelType); //Extract the parameters from the channel object $parameters = $channel->GetParameters(); //Get and parse all avaliable content items from the parser $contentItems = $factory->GetAndParse($parameters); //Return the content items return $contentItems; }
function display($preview = false) { require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->editPackage); $smarty = $this->constructSmarty($parser); if ($preview) { echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl"); } else { $ajax = $this->constructAjax(); $ajax->addSection('center', translate('LBL_DASHLET'), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); } }
function display() { require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser(MB_PORTALLISTVIEW, $this->editModule, null, null, MB_PORTAL); $smarty = $this->constructSmarty($parser); $smarty->assign('fromPortal', true); // flag for form submittal - when the layout is submitted the actions are the same for layouts and portal layouts, but the parsers must be different... //Override the list view buttons to remove references to the history feature as the portal editors do not support it. $buttons = array(array('id' => 'savebtn', 'name' => 'savebtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");" . "if (countListFields()==0) ModuleBuilder.layoutValidation.popup() ; else ModuleBuilder.handleSave(\"edittabs\" )'")); $smarty->assign('buttons', $this->_buildImageButtons($buttons)); $ajax = $this->constructAjax(); $ajax->addSection('center', translate('LBL_EDIT_LAYOUT', 'ModuleBuilder'), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); }
function display($preview = false) { $packageName = !empty($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null; $subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName, $subpanelName); $smarty = $this->constructSmarty($parser); if ($preview) { echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl"); } else { $ajax = $this->constructAjax(); $ajax->addSection('center', $this->translatedViewType, $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); } }
function display() { $this->layout = strtolower($_REQUEST['view']); $subpanelName = null; if (strtolower($this->layout) == 'listview' && !empty($_REQUEST['subpanel'])) { $subpanelName = $_REQUEST['subpanel']; } $packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null; $this->module = $_REQUEST['view_module']; $this->parser = ParserFactory::getParser($this->layout, $this->module, $packageName, $subpanelName); $this->history = $this->parser->getHistory(); $action = !empty($_REQUEST['histAction']) ? $_REQUEST['histAction'] : 'browse'; $GLOBALS['log']->debug(get_class($this) . "->display(): performing History action {$action}"); $this->{$action}(); }
function display($preview = false) { $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : ''; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName); $smarty = parent::constructSmarty($parser); $smarty->assign('action', 'searchViewSave'); $smarty->assign('view', $this->editLayout); $smarty->assign('helpName', 'searchViewEditor'); $smarty->assign('helpDefault', 'modify'); if ($preview) { echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl"); } else { $ajax = $this->constructAjax(); $ajax->addSection('center', translate($this->title), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); } }
/** * Upgrade Task to Run */ public function run() { if (version_compare($this->from_version, '7.0.0', '<') && $this->toFlavor('ent')) { $settings = Opportunity::getSettings(); if ($settings['opps_view_by'] !== 'RevenueLineItems') { $this->log('Not using Revenue Line Items; Skipping Upgrade Script'); return; } $fields = array('sales_stage', 'probability', 'commit_stage'); require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $this->log('Processing Opportunity RecordView'); $recordViewDefsParser = ParserFactory::getParser(MB_RECORDVIEW, 'Opportunities', null, null, 'base'); if ($this->removeFields($recordViewDefsParser, $fields)) { $recordViewDefsParser->handleSave(false); } $this->log('Processing Opportunity ListView'); $recordViewDefsParser = ParserFactory::getParser(MB_LISTVIEW, 'Opportunities', null, null, 'base'); if ($this->removeFields($recordViewDefsParser, $fields)) { $recordViewDefsParser->handleSave(false); } $modules = array('Accounts', 'Contacts', 'Campaigns', 'Documents'); global $modInvisList; if (array_search('Project', $modInvisList)) { $modules[] = 'Project'; } foreach ($modules as $module) { $this->log('Processing Opportunity SubPanel for ' . $module . ' module'); if (isModuleBWC($module)) { require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php'; $pf = new SubpanelMetaDataParser('opportunities', $module); } else { $pf = ParserFactory::getParser(MB_LISTVIEW, $module, null, 'opportunities'); } if ($this->removeFields($pf, $fields)) { $pf->handleSave(false); } } } }
<?php function __autoload($class_name) { include $class_name . '.php'; } $file = __DIR__ . "/file.json"; $obj = ParserFactory::getParser($file); var_dump($obj->parseFile());
/** * Walk through default record view lookng for fields that did not exist on the original pre-sidecar layout defs * Any such fields should be appended to the final defs * * @param array $newDefs * @param array $defaultDefs */ protected function addNewFieldsToLayout(array $newDefs) { $defaultDefs = $this->loadDefaultMetadata(); $parser = ParserFactory::getParser($this->viewtype, $this->module, $this->package, null, $this->client); $defaultFields = $parser->getFieldsFromPanels($defaultDefs['panels'], $parser->_fielddefs); $currentFields = $parser->getFieldsFromPanels($newDefs['panels'], $parser->_fielddefs); $origFields = array(); foreach ($this->originalLegacyViewdefs as $lViewtype => $data) { // We will need a parser no matter what if ($this->sidecar) { $legacyParser = ParserFactory::getParser($lViewtype, $this->module, $this->package, null, $this->client); } else { $legacyParser = ParserFactory::getParser($lViewtype, $this->module, $this->package); } // replace viewdefs with defaults, since parser's viewdefs can be already customized by other parts // of the upgrade $legacyParser->_viewdefs['panels'] = $legacyParser->convertFromCanonicalForm($data['panels'], $legacyParser->_fielddefs); // get field list $origData = $legacyParser->getFieldsFromPanels($data['panels'], $legacyParser->_fielddefs); $origFields = array_merge($origFields, $origData); } //Add fields always defaults to the bottom of the first panel. //In this case the 'first panel' is the first non-header panel, AKA panel[1] if (empty($newDefs['panels'][1]['fields'])) { $this->logUpgradeStatus("Unable to find panels to add to"); } foreach ($defaultFields as $field => $def) { // If the special field was not present on legacy layout we shouldn't add it. if ($this->isSpecialFieldBySidecarName($field) && empty($currentFields[$field])) { continue; } //If a field wasn't on the lagacy layout, add it to the custom one. if (empty($origFields[$field]) && empty($currentFields[$field]) && !empty($newDefs['panels'][1]['fields'])) { $newDefs['panels'][1]['fields'][] = $def; } } return $newDefs; }
function action_dashletSave() { $this->view = 'dashlet'; $packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName); $parser->handleSave(); }
} //If we have metadata files to alter if (!empty($module_entries)) { $modules = array_keys($module_entries); $views = array('basic_search', 'advanced_search', 'detailview', 'editview', 'quickcreate'); $class_names = array(); require_once 'include/TemplateHandler/TemplateHandler.php'; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; foreach ($modules as $module) { if (isset($GLOBALS['beanList'][$module])) { $class_names[] = $GLOBALS['beanList'][$module]; } $repairClass->module_list[] = $module; foreach ($views as $view) { try { $parser = ParserFactory::getParser($view, $module); } catch (Exception $e) { $GLOBALS['log']->fatal("Caught exception in RepairFieldCasing script: " . $e->getMessage()); continue; } if (isset($parser->_viewdefs['panels'])) { foreach ($parser->_viewdefs['panels'] as $panel_id => $panel) { foreach ($panel as $row_id => $row) { foreach ($row as $entry_id => $entry) { if (is_array($entry) && isset($entry['name'])) { $parser->_viewdefs['panels'][$panel_id][$row_id][$entry_id]['name'] = strtolower($entry['name']); } } } } } else {
function set_custom_field($session, $module_name, $type, $properties, $add_to_layout) { global $current_user; global $beanList, $beanFiles; global $custom_field_meta; $error = new SoapError(); $request_arr = array('action' => 'SaveField', 'is_update' => 'true', 'module' => 'ModuleBuilder', 'view_module' => $module_name, 'view_package' => 'studio'); // ERROR CHECKING if (!validate_authenticated($session)) { $error->set_error('invalid_login'); return $error->get_soap_array(); } if (!is_admin($current_user)) { $error->set_error('no_admin'); return $error->get_soap_array(); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return $error->get_soap_array(); } if (empty($custom_field_meta[$type])) { $error->set_error('custom_field_type_not_supported'); return $error->get_soap_array(); } $new_properties = array(); foreach ($properties as $value) { $new_properties[$value['name']] = $value['value']; } foreach ($custom_field_meta[$type] as $property) { if (!isset($new_properties[$property])) { $error->set_error('custom_field_property_not_supplied'); return $error->get_soap_array(); } $request_arr[$property] = $new_properties[$property]; } // $request_arr should now contain all the necessary information to create a custom field // merge $request_arr with $_POST/$_REQUEST, where the action_saveField() method expects them $_REQUEST = array_merge($_REQUEST, $request_arr); $_POST = array_merge($_POST, $request_arr); require_once 'modules/ModuleBuilder/controller.php'; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $mbc = new ModuleBuilderController(); $mbc->setup(); $mbc->action_SaveField(); // add the field to the given module's EditView and DetailView layouts if ($add_to_layout == 1) { $layout_properties = array('name' => $new_properties['name'], 'label' => $new_properties['label']); if (isset($new_properties['customCode'])) { $layout_properties['customCode'] = $new_properties['customCode']; } if (isset($new_properties['customLabel'])) { $layout_properties['customLabel'] = $new_properties['customLabel']; } // add the field to the DetailView $parser = ParserFactory::getParser('layoutview', FALSE); $parser->init($module_name, 'DetailView', FALSE); $parser->_addField($layout_properties); $parser->writeWorkingFile(); $parser->handleSave(); unset($parser); // add the field to the EditView $parser = ParserFactory::getParser('layoutview', FALSE); $parser->init($module_name, 'EditView', FALSE); $parser->_addField($layout_properties); $parser->writeWorkingFile(); $parser->handleSave(); } return $error->get_soap_array(); }
function display($preview = false) { global $mod_strings; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->package); if (isset($this->view_object_map['new_parser'])) { $parser = $this->view_object_map['new_parser']; } $history = $parser->getHistory(); $smarty = new Sugar_Smarty(); //Add in the module we are viewing to our current mod strings if (!$this->fromModuleBuilder) { global $current_language; $editModStrings = return_module_language($current_language, $this->editModule); $mod_strings = sugarArrayMerge($editModStrings, $mod_strings); } $smarty->assign('mod', $mod_strings); $smarty->assign('MOD', $mod_strings); // assign buttons $images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone'); foreach ($images as $image => $file) { $smarty->assign($image, SugarThemeRegistry::current()->getImage($file, '', null, null, '.gif', $file)); } $requiredFields = implode($parser->getRequiredFields(), ','); $slashedRequiredFields = addslashes($requiredFields); $buttons = array(); $disableLayout = false; if ($preview) { $smarty->assign('layouttitle', translate('LBL_LAYOUT_PREVIEW', 'ModuleBuilder')); } else { $smarty->assign('layouttitle', translate('LBL_CURRENT_LAYOUT', 'ModuleBuilder')); //Check if we need to synch edit view to other layouts if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) { $parser2 = ParserFactory::getParser(MB_EDITVIEW, $this->editModule, $this->package); if ($this->editLayout == MB_DETAILVIEW) { $disableLayout = $parser2->getSyncDetailEditViews(); } if (!empty($_REQUEST['copyFromEditView'])) { $editViewPanels = $parser2->convertFromCanonicalForm($parser2->_viewdefs['panels'], $parser2->_fielddefs); $parser->_viewdefs['panels'] = $editViewPanels; $parser->_fielddefs = $parser2->_fielddefs; $parser->setUseTabs($parser2->getUseTabs()); $parser->setTabDefs($parser2->getTabDefs()); } } if (!$this->fromModuleBuilder) { $buttons[] = array('id' => 'saveBtn', 'text' => translate('LBL_BTN_SAVE'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'publishBtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'spacer', 'width' => '33px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'", 'disabled' => $disableLayout); } else { $buttons[] = array('id' => 'saveBtn', 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'spacer', 'width' => '33px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'", 'disabled' => $disableLayout); } if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) { $buttons[] = array('id' => 'copyFromEditView', 'text' => translate('LBL_COPY_FROM_EDITVIEW'), 'actionScript' => "onclick='ModuleBuilder.copyFromView(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); } } $html = ""; foreach ($buttons as $button) { if ($button['id'] == "spacer") { $html .= "<td style='width:{$button['width']}'> </td>"; } else { $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' " . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' " . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}'"; if (!empty($button['disabled'])) { $html .= " disabled"; } $html .= "></td>"; } } $smarty->assign('buttons', $html); // assign fields and layout $smarty->assign('available_fields', $parser->getAvailableFields()); $smarty->assign('disable_layout', $disableLayout); $smarty->assign('required_fields', $requiredFields); $smarty->assign('layout', $parser->getLayout()); $smarty->assign('field_defs', $parser->getFieldDefs()); $smarty->assign('view_module', $this->editModule); $smarty->assign('view', $this->editLayout); $smarty->assign('maxColumns', $parser->getMaxColumns()); $smarty->assign('nextPanelId', $parser->getFirstNewPanelId()); $smarty->assign('displayAsTabs', $parser->getUseTabs()); $smarty->assign('tabDefs', $parser->getTabDefs()); $smarty->assign('syncDetailEditViews', $parser->getSyncDetailEditViews()); $smarty->assign('fieldwidth', 150); $smarty->assign('translate', $this->fromModuleBuilder ? false : true); if ($this->fromModuleBuilder) { $smarty->assign('fromModuleBuilder', $this->fromModuleBuilder); $smarty->assign('view_package', $this->package); } $labels = array(MB_EDITVIEW => 'LBL_EDITVIEW', MB_DETAILVIEW => 'LBL_DETAILVIEW', MB_QUICKCREATE => 'LBL_QUICKCREATE'); $layoutLabel = 'LBL_LAYOUTS'; $layoutView = 'layouts'; $ajax = new AjaxCompose(); $translatedViewType = ''; if (isset($labels[strtolower($this->editLayout)])) { $translatedViewType = translate($labels[strtolower($this->editLayout)], 'ModuleBuilder'); } else { if (isset($this->sm)) { foreach ($this->sm->sources as $file => $def) { if (!empty($def['view']) && $def['view'] == $this->editLayout && !empty($def['name'])) { $translatedViewType = $def['name']; } } if (empty($translatedViewType)) { $label = "LBL_" . strtoupper($this->editLayout); $translated = translate($label, $this->editModule); if ($translated != $label) { $translatedViewType = $translated; } } } } if ($this->fromModuleBuilder) { $ajax->addCrumb(translate('LBL_MODULEBUILDER', 'ModuleBuilder'), 'ModuleBuilder.main("mb")'); $ajax->addCrumb($this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")'); $ajax->addCrumb($this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '&view_package=' . $this->package . '")'); $ajax->addCrumb($translatedViewType, ''); } else { $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")'); $ajax->addCrumb($this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '")'); $ajax->addCrumb($translatedViewType, ''); } // set up language files $smarty->assign('language', $parser->getLanguage()); // for sugar_translate in the smarty template $smarty->assign('from_mb', $this->fromModuleBuilder); $smarty->assign('calc_field_list', json_encode($parser->getCalculatedFields())); if ($this->fromModuleBuilder) { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($this->package, $this->editModule); $smarty->assign('current_mod_strings', $module->getModStrings()); } $ajax->addSection('center', $translatedViewType, $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl')); if ($preview) { echo $smarty->fetch('modules/ModuleBuilder/tpls/Preview/layoutView.tpl'); } else { echo $ajax->getJavascript(); } }
function removeFieldFromLayouts($fieldName) { require_once "modules/ModuleBuilder/parsers/ParserFactory.php"; $GLOBALS['log']->info(get_class($this) . "->removeFieldFromLayouts({$fieldName})"); $sources = $this->getViewMetadataSources(); $sources[] = array('type' => MB_BASICSEARCH); $sources[] = array('type' => MB_ADVANCEDSEARCH); $sources[] = array('type' => MB_POPUPSEARCH); $GLOBALS['log']->debug(print_r($sources, true)); foreach ($sources as $name => $defs) { //If this module type doesn't support a given metadata type, we will get an exception from getParser() try { $parser = ParserFactory::getParser($defs['type'], $this->module); if ($parser->removeField($fieldName)) { $parser->handleSave(false); } // don't populate from $_REQUEST, just save as is... } catch (Exception $e) { } } //Remove the fields in subpanel $data = $this->getParentModulesOfSubpanel($this->module); foreach ($data as $parentModule) { //If this module type doesn't support a given metadata type, we will get an exception from getParser() try { $parser = ParserFactory::getParser(MB_LISTVIEW, $parentModule, null, $this->module); if ($parser->removeField($fieldName)) { $parser->handleSave(false); } } catch (Exception $e) { } } }
function removeFieldFromLayouts($fieldName) { $GLOBALS['log']->info(get_class($this) . "->removeFieldFromLayouts({$fieldName})"); $sources = $this->getViews(); $sources[] = array('type' => MB_BASICSEARCH); $sources[] = array('type' => MB_ADVANCEDSEARCH); $GLOBALS['log']->debug(print_r($sources, true)); foreach ($sources as $name => $defs) { $parser = ParserFactory::getParser($defs['type'], $this->module); if ($parser->removeField($fieldName)) { $parser->handleSave(false); } // don't populate from $_REQUEST, just save as is... } }
public function action_copyLayout() { $module = $_REQUEST['view_module']; $view = $_REQUEST['view']; $role = $_REQUEST['role']; $source = $_REQUEST['source']; $sourceParser = ParserFactory::getParser($view, $module, null, null, null, array('role' => $source)); $sourceImplementation = $sourceParser->getImplementation(); $fileName = $sourceImplementation->getFileNameNoDefault($view, $module); if (!file_exists($fileName)) { return; } $parser = ParserFactory::getParser($view, $module, null, null, null, array('role' => $role)); $history = $parser->getHistory(); $history->savePreview($fileName); $this->view = 'layoutview'; }
/** * Applies the Action to the target. * * @param SugarBean $target * * Should only be fired when saving from an edit view and the expression is false. */ public function fire(&$target) { $result = Parser::evaluate($this->expression, $target)->evaluate(); if ($result === AbstractExpression::$FALSE) { require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; require_once 'modules/ModuleBuilder/parsers/constants.php'; $view = isModuleBWC($target->module_name) ? MB_EDITVIEW : MB_RECORDVIEW; $parser = ParserFactory::getParser($view, $target->module_dir); $fields = $parser->getFieldsInPanel($this->targetPanel); foreach ($fields as $field) { unset($target->{$field}); } } }
/** * Get parsed dependencies * * @return array */ public function getDependencies() { return array_merge($this->parserFactory->getStaticCalls()->getDependencies($this->parserFactory->getUses()), $this->parserFactory->getThrows()->getDependencies($this->parserFactory->getUses())); }
function display($preview = false) { global $mod_strings; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->package); $history = $parser->getHistory(); $smarty = new Sugar_Smarty(); //Add in the module we are viewing to our current mod strings if (!$this->fromModuleBuilder) { global $current_language; $editModStrings = return_module_language($current_language, $this->editModule); $mod_strings = sugarArrayMerge($editModStrings, $mod_strings); } $smarty->assign('mod', $mod_strings); $smarty->assign('MOD', $mod_strings); // assign buttons $images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone'); foreach ($images as $image => $file) { $smarty->assign($image, SugarThemeRegistry::current()->getImage($file)); } $buttons = array(); if ($preview) { $smarty->assign('layouttitle', translate('LBL_LAYOUT_PREVIEW', 'ModuleBuilder')); } else { $smarty->assign('layouttitle', translate('LBL_CURRENT_LAYOUT', 'ModuleBuilder')); if (!$this->fromModuleBuilder) { $buttons[] = array('id' => 'saveBtn', 'text' => translate('LBL_BTN_SAVE'), 'actionScript' => "onclick='if (countGridFields()==0) ModuleBuilder.layoutValidation.popup() ; else Studio2.handleSave();'"); $buttons[] = array('id' => 'publishBtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='if (countGridFields()==0) ModuleBuilder.layoutValidation.popup() ; else Studio2.handlePublish();'"); $buttons[] = array('id' => 'spacer', 'width' => '50px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'"); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"); } else { $buttons[] = array('id' => 'saveBtn', 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if (countGridFields()==0) ModuleBuilder.layoutValidation.popup() ; else Studio2.handlePublish();'"); $buttons[] = array('id' => 'spacer', 'width' => '50px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'"); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"); } } $html = ""; foreach ($buttons as $button) { if ($button['id'] == "spacer") { $html .= "<td style='width:{$button['width']}'> </td>"; } else { $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' " . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' " . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}' ></td>"; } } $smarty->assign('buttons', $html); // assign fields and layout $smarty->assign('available_fields', $parser->getAvailableFields()); $smarty->assign('layout', $parser->getLayout()); $smarty->assign('view_module', $this->editModule); $smarty->assign('view', $this->editLayout); $smarty->assign('maxColumns', $parser->getMaxColumns()); $smarty->assign('nextPanelId', $parser->getFirstNewPanelId()); $smarty->assign('fieldwidth', 150); $smarty->assign('translate', true); if ($this->fromModuleBuilder) { $smarty->assign('fromModuleBuilder', $this->fromModuleBuilder); $smarty->assign('view_package', $this->package); } $labels = array(MB_EDITVIEW => 'LBL_EDITVIEW', MB_DETAILVIEW => 'LBL_DETAILVIEW', MB_QUICKCREATE => 'LBL_QUICKCREATE'); $layoutLabel = 'LBL_LAYOUTS'; $layoutView = 'layouts'; $ajax = new AjaxCompose(); $viewType; $translatedViewType = ''; if (isset($labels[strtolower($this->editLayout)])) { $translatedViewType = translate($labels[strtolower($this->editLayout)], 'ModuleBuilder'); } if ($this->fromModuleBuilder) { $ajax->addCrumb(translate('LBL_MODULEBUILDER', 'ModuleBuilder'), 'ModuleBuilder.main("mb")'); $ajax->addCrumb($this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")'); $ajax->addCrumb($this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '&view_package=' . $this->package . '")'); $ajax->addCrumb($translatedViewType, ''); } else { $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")'); $ajax->addCrumb($this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '")'); $ajax->addCrumb($translatedViewType, ''); } // set up language files $smarty->assign('language', $parser->getLanguage()); // for sugar_translate in the smarty template $smarty->assign('from_mb', $this->fromModuleBuilder); $ajax->addSection('center', $translatedViewType, $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl')); if ($preview) { echo $smarty->fetch('modules/ModuleBuilder/tpls/Preview/layoutView.tpl'); } else { echo $ajax->getJavascript(); } }
function display() { global $locale; $editModule = $_REQUEST['view_module']; $allLabels = !empty($_REQUEST['labels']) && $_REQUEST['labels'] == 'all'; if (!isset($_REQUEST['MB'])) { global $app_list_strings; $moduleNames = array_change_key_case($app_list_strings['moduleList']); $translatedEditModule = $moduleNames[strtolower($editModule)]; } $selected_lang = null; if (!empty($_REQUEST['selected_lang'])) { $selected_lang = $_REQUEST['selected_lang']; } else { $selected_lang = $locale->getAuthenticatedUserLanguage(); } $smarty = new Sugar_Smarty(); global $mod_strings; $smarty->assign('mod_strings', $mod_strings); $smarty->assign('available_languages', get_languages()); $objectName = BeanFactory::getObjectName($editModule); VardefManager::loadVardef($editModule, $objectName); global $dictionary; $vnames = array(); //jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them. $parser = ParserFactory::getParser(MB_LISTVIEW, $editModule); foreach ($parser->getLayout() as $key => $def) { if (isset($def['label'])) { $vnames[$def['label']] = $def['label']; } } require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php'; $variableMap = $this->getVariableMap($editModule); foreach ($variableMap as $key => $value) { $gridLayoutMetaDataParserTemp = ParserFactory::getParser($key, $editModule); foreach ($gridLayoutMetaDataParserTemp->getLayout() as $panel) { foreach ($panel as $row) { foreach ($row as $fieldArray) { // fieldArray is an array('name'=>name,'label'=>label) if (isset($fieldArray['label'])) { $vnames[$fieldArray['label']] = $fieldArray['label']; } } } } } //end //Get Subpanel Labels: require_once 'include/SubPanel/SubPanel.php'; $subList = SubPanel::getModuleSubpanels($editModule); foreach ($subList as $subpanel => $titleLabel) { $vnames[$titleLabel] = $titleLabel; } foreach ($dictionary[$objectName]['fields'] as $name => $def) { if (isset($def['vname'])) { $vnames[$def['vname']] = $def['vname']; } } $formatted_mod_strings = array(); // we shouldn't set the $refresh=true here, or will lost template language // mod_strings. // return_module_language($selected_lang, $editModule,false) : // the mod_strings will be included from cache files here. foreach (return_module_language($selected_lang, $editModule, false) as $name => $label) { //#25294 if ($allLabels || isset($vnames[$name]) || preg_match('/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si', $name)) { // Bug 58174 - Escaped labels are sent to the client escaped // even in the label editor in studio $formatted_mod_strings[$name] = html_entity_decode($label, null, 'UTF-8'); } } //Grab everything from the custom files $mod_bak = $mod_strings; $files = array("custom/modules/{$editModule}/language/{$selected_lang}.lang.php", "custom/modules/{$editModule}/Ext/Language/{$selected_lang}.lang.ext.php"); foreach ($files as $langfile) { $mod_strings = array(); if (is_file($langfile)) { include $langfile; foreach ($mod_strings as $key => $label) { // Bug 58174 - Escaped labels are sent to the client escaped // even in the label editor in studio $formatted_mod_strings[$key] = html_entity_decode($label, null, 'UTF-8'); } } } $mod_strings = $mod_bak; ksort($formatted_mod_strings); $smarty->assign('MOD', $formatted_mod_strings); $smarty->assign('view_module', $editModule); $smarty->assign('APP', $GLOBALS['app_strings']); $smarty->assign('selected_lang', $selected_lang); $smarty->assign('defaultHelp', 'labelsBtn'); $smarty->assign('assistant', array('key' => 'labels', 'group' => 'module')); $smarty->assign('labels_choice', $mod_strings['labelTypes']); $smarty->assign('labels_current', $allLabels ? "all" : ""); $ajax = new AjaxCompose(); $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")'); $ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $editModule . '")'); $ajax->addCrumb($mod_strings['LBL_LABELS'], ''); $html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl'); $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html); echo $ajax->getJavascript(); }
function action_popupSave() { $this->view = 'popupview'; $packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName); $parser->handleSave(); if (empty($packageName)) { include_once 'modules/Administration/QuickRepairAndRebuild.php'; global $mod_strings; $mod_strings['LBL_ALL_MODULES'] = 'all_modules'; $repair = new RepairAndClear(); $repair->show_output = false; $class_name = $GLOBALS['beanList'][$_REQUEST['view_module']]; $repair->module_list = array($class_name); $repair->clearTpls(); } }
private function create_panel_on_view($view, $field, $module, $panel_name) { //require and create object. require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($view, $module); if (!array_key_exists($field['0']['name'], $parser->_fielddefs)) { //add newly created fields to fielddefs as they wont be there. $parser->_fielddefs[$field['0']['name']] = $field['0']; } if (!array_key_exists($panel_name, $parser->_viewdefs['panels'])) { //create the layout for the row. $field_defs = array(0 => $field['0']['name']); //add the row to the panel. $panel = array(0 => $field_defs); //add the panel to the view. $parser->_viewdefs['panels'][$panel_name] = $panel; //save the panel. } else { //if the panel already exists we need to push items on to it. foreach ($parser->_viewdefs['panels'][$panel_name] as $row_key => $row) { foreach ($row as $key_field => $single_field) { if ($single_field == "(empty)") { $parser->_viewdefs['panels'][$panel_name][$row_key][$key_field] = $field['0']['name']; } } } } $parser->handleSave(false); }
function removeFieldFromLayouts($fieldName) { // hardcoded list of types for now, as also hardcoded in a different form in getNodes // TODO: replace by similar mechanism to StudioModule to determine the list of available views for this module $views = array('editview', 'detailview', 'listview', 'basic_search', 'advanced_search', 'dashlet', 'popuplist'); foreach ($views as $type) { $parser = ParserFactory::getParser($type, $this->name, $this->package); if ($parser->removeField($fieldName)) { $parser->handleSave(false); } // don't populate from $_REQUEST, just save as is... } //Remove the fields in subpanel $psubs = $this->getProvidedSubpanels(); foreach ($psubs as $sub) { $parser = ParserFactory::getParser(MB_LISTVIEW, $this->name, $this->package, $sub); if ($parser->removeField($fieldName)) { $parser->handleSave(false); } } }
function removeFieldsFromLayout($layoutAdditions) { // these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. // In either case, we don't want to attempt to add a relate field to them // would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here $invalidModules = array('emails', 'kbdocuments'); foreach ($layoutAdditions as $deployedModuleName => $fieldName) { if (!in_array(strtolower($deployedModuleName), $invalidModules)) { // Handle decision making on views for BWC/non-BWC modules if (isModuleBWC($deployedModuleName)) { $views = array(MB_EDITVIEW, MB_DETAILVIEW); } else { $views = array(MB_RECORDVIEW); } foreach ($views as $view) { $GLOBALS['log']->debug(get_class($this) . ": adding {$fieldName} to {$view} layout for module {$deployedModuleName}"); $parser = ParserFactory::getParser($view, $deployedModuleName); $parser->removeField($fieldName); $parser->handleSave(false); } } } }