/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button_slider($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button_slider: missing required param (module)"); } else { if (empty($params['buttons'])) { $smarty->trigger_error("sugar_button_slider: missing required param (buttons)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button_slider: missing required param (view)"); } } } $module = $params['module']; $view = $params['view']; $buttons = $params['buttons']; $str = ''; if (is_array($buttons)) { if (count($buttons) <= 2) { foreach ($buttons as $val => $button) { $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); } } else { $str = '<div id="buttonSlide" class="yui-module">'; $str .= '<table border="0">'; $str .= '<tr><td>'; $str .= '<div class="yui-hd">'; for ($i = 0; $i < 2; $i++) { $button = $buttons[$i]; $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); $str .= ' '; } $str .= '</div></td>'; $str .= '<td align="right"> <div class="yui-bd">'; for ($i = 2; $i < count($buttons); $i++) { $button = $buttons[$i]; $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); $str .= ' '; } $str .= '</div></td>'; $str .= '</tr></table>'; } } return $str; }
<?php } } unset($_from); } else { echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'SAVE', 'view' => $this->_tpl_vars['view'], 'form_id' => $this->_tpl_vars['form_id'], 'location' => 'FOOTER', 'appendTo' => 'footer_buttons'), $this); ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'CANCEL', 'view' => $this->_tpl_vars['view'], 'form_id' => $this->_tpl_vars['form_id'], 'location' => 'FOOTER', 'appendTo' => 'footer_buttons'), $this); ?> <?php } if (empty($this->_tpl_vars['form']['hideAudit']) || !$this->_tpl_vars['form']['hideAudit']) { echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'Audit', 'view' => $this->_tpl_vars['view'], 'form_id' => $this->_tpl_vars['form_id'], 'appendTo' => 'footer_buttons'), $this); ?> <?php } echo smarty_function_sugar_action_menu(array('buttons' => $this->_tpl_vars['footer_buttons'], 'class' => 'fancymenu', 'flat' => true), $this); ?> </div> <?php } ?> </form> <?php if ($this->_tpl_vars['externalJSFile']) { ?>
} if (count($_from)) { foreach ($_from as $this->_tpl_vars['val'] => $this->_tpl_vars['button']) { ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => $this->_tpl_vars['button'], 'location' => 'FOOTER', 'view' => $this->_tpl_vars['view']), $this); ?> <?php } } unset($_from); } else { ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'SAVE', 'view' => $this->_tpl_vars['view']), $this); ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'CANCEL', 'view' => $this->_tpl_vars['view']), $this); ?> <?php } ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'Audit', 'view' => $this->_tpl_vars['view']), $this); ?> </div>
echo smarty_function_sugar_field(array('parentFieldArray' => 'fields', 'vardef' => $this->_tpl_vars['fields'][$this->_tpl_vars['colData']['field']['name']], 'accesskey' => $this->_tpl_vars['ACCKEY'], 'displayType' => 'searchView', 'displayParams' => $this->_tpl_vars['colData']['field']['displayParams'], 'typeOverride' => $this->_tpl_vars['colData']['field']['type'], 'formName' => $this->_tpl_vars['form_name']), $this); ?> <?php } ?> </td> <?php } } unset($_from); ?> {if $formData|@count >= $basicMaxColumns+1} </tr> <tr> <td colspan="{$searchTableColumnCount}"> {else} <td class="sumbitButtons"> {/if} <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'search', 'view' => 'searchView'), $this); ?> <input tabindex='2' title='{$APP.LBL_CLEAR_BUTTON_TITLE}' onclick='SUGAR.searchForm.clear_form(this.form); return false;' class='button' type='button' name='clear' id='search_form_clear' value='{$APP.LBL_CLEAR_BUTTON_LABEL}'/> {if $HAS_ADVANCED_SEARCH} <a id="advanced_search_link" onclick="SUGAR.searchForm.searchFormSelect('{$module}|advanced_search','{$module}|basic_search')" href="javascript:void(0);" accesskey="{$APP.LBL_ADV_SEARCH_LNK_KEY}" >{$APP.LNK_ADVANCED_SEARCH}</a> {/if} </td> <td class="helpIcon" width="*"><img alt="Help" border='0' id="filterHelp" src='{sugar_getimagepath file="help-dashlet.gif"}'></td> </tr> </table>
<?php } ?> <?php } } unset($_from); ?> <?php } ?> <?php if (empty($this->_tpl_vars['form']['hideAudit']) || !$this->_tpl_vars['form']['hideAudit']) { ?> <?php echo smarty_function_sugar_button(array('module' => $this->_tpl_vars['module'], 'id' => 'Audit', 'view' => 'EditView', 'form_id' => 'formDetailView', 'appendTo' => 'detail_header_buttons'), $this); ?> <?php } } ?> <form action="index.php" method="post" name="DetailView" id="formDetailView"> <input type="hidden" name="module" value="{$module}"> <input type="hidden" name="record" value="{$fields.id.value}"> <input type="hidden" name="return_action"> <input type="hidden" name="return_module"> <input type="hidden" name="return_id"> <input type="hidden" name="module_tab"> <input type="hidden" name="isDuplicate" value="false">
public function testBuildSugarHtml() { $sugar_html = array('type' => 'submit', 'value' => '{$APP.LBL_CLOSE_AND_CREATE_BUTTON_TITLE}', 'htmlOptions' => array('title' => '{$APP.LBL_CLOSE_AND_CREATE_BUTTON_TITLE}', 'name' => 'button', 'class' => 'button', 'onclick' => 'this.form.isSaveFromDetailView.value=true; this.form.status.value=\'Held\'; this.form.action.value=\'Save\';this.form.return_module.value=\'Meetings\';this.form.isDuplicate.value=true;this.form.isSaveAndNew.value=true;this.form.return_action.value=\'EditView\'; this.form.isDuplicate.value=true;this.form.return_id.value=\'{$fields.id.value}\';'), 'template' => '{if $fields.status.value != "Held"}[CONTENT]{/if}'); $expected_html = '{if $fields.status.value != "Held"}<input title="{$APP.LBL_CLOSE_AND_CREATE_BUTTON_TITLE}" name="button" class="button" onclick="var _form = document.getElementById(\'DetailView\');_form.isSaveFromDetailView.value=true; _form.status.value=\'Held\'; _form.action.value=\'Save\';_form.return_module.value=\'Meetings\';_form.isDuplicate.value=true;_form.isSaveAndNew.value=true;_form.return_action.value=\'EditView\'; _form.isDuplicate.value=true;_form.return_id.value=\'{$fields.id.value}\';_form.submit();" type="button" value="{$APP.LBL_CLOSE_AND_CREATE_BUTTON_TITLE}"/>{/if}'; $params = array('module' => 'Accounts', 'view' => 'DetailView', 'id' => array('sugar_html' => $sugar_html), 'form_id' => 'DetailView'); //Test for smarty_function_sugar_button for sugar_html $this->assertEquals($expected_html, smarty_function_sugar_button($params, $this->_smarty)); }