PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/include/SugarFields/Fields/File/EditView.tpl

https://github.com/jacknicole/sugarcrm_dev
Smarty Template | 221 lines | 166 code | 17 blank | 38 comment | 24 complexity | 76ef95550d9f50581f43fdaa2af3cc77 MD5 | raw file
  1. {*
  2. /*********************************************************************************
  3. * SugarCRM Community Edition is a customer relationship management program developed by
  4. * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License version 3 as published by the
  8. * Free Software Foundation with the addition of the following permission added
  9. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  10. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  11. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License along with
  19. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  20. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA.
  22. *
  23. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  24. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  25. *
  26. * The interactive user interfaces in modified source and object code versions
  27. * of this program must display Appropriate Legal Notices, as required under
  28. * Section 5 of the GNU Affero General Public License version 3.
  29. *
  30. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  31. * these Appropriate Legal Notices must retain the display of the "Powered by
  32. * SugarCRM" logo. If the display of the logo is not reasonably feasible for
  33. * technical reasons, the Appropriate Legal Notices must display the words
  34. * "Powered by SugarCRM".
  35. ********************************************************************************/
  36. *}
  37. {{if isset($vardef.allowEapm) && $vardef.allowEapm}}
  38. <script type="text/javascript" src='{{sugar_getjspath file="cache/include/externalAPI.cache.js"}}'></script>
  39. {{/if}}
  40. <script type="text/javascript" src='{{sugar_getjspath file="include/SugarFields/Fields/File/SugarFieldFile.js"}}'></script>
  41. {{capture name=idName assign=idName}}{{sugarvar key='name'}}{{/capture}}
  42. {{if !empty($displayParams.idName)}}
  43. {{assign var=idName value=$displayParams.idName}}
  44. {{/if}}
  45. {{if !isset($vardef.noRemove) || !$vardef.noRemove}}
  46. {if !empty({{sugarvar key='value' stringFormat=true}}) }
  47. {assign var=showRemove value=true}
  48. {else}
  49. {assign var=showRemove value=false}
  50. {/if}
  51. {{else}}
  52. {assign var=showRemove value=false}
  53. {{/if}}
  54. {{if isset($vardef.noChange) && $vardef.noChange }}
  55. {if !empty({{sugarvar key='value' stringFormat=true}}) }
  56. {assign var=showRemove value=true}
  57. {assign var=noChange value=true}
  58. {else}
  59. {assign var=noChange value=false}
  60. {/if}
  61. {{else}}
  62. {assign var=noChange value=false}
  63. {{/if}}
  64. <input type="hidden" name="deleteAttachment" value="0">
  65. <input type="hidden" name="{{$idName}}" id="{{$idName}}" value="{{sugarvar key='value'}}">
  66. {{if isset($vardef.allowEapm) && $vardef.allowEapm}}
  67. <input type="hidden" name="{{$vardef.docId}}" id="{{$vardef.docId}}" value="{$fields.{{$vardef.docId}}.value}">
  68. <input type="hidden" name="{{$vardef.docUrl}}" id="{{$vardef.docUrl}}" value="{$fields.{{$vardef.docUrl}}.value}">
  69. <input type="hidden" name="{{$idName}}_old_doctype" id="{{$idName}}_old_doctype" value="{$fields.{{$vardef.docType}}.value}">
  70. {{/if}}
  71. <span id="{{$idName}}_old" style="display:{if !$showRemove}none;{/if}">
  72. <a href="index.php?entryPoint=download&id={$fields.{{$vardef.fileId}}.value}&type={{$vardef.linkModule}}" class="tabDetailViewDFLink">{{sugarvar key='value'}}</a>
  73. {{if isset($vardef.allowEapm) && $vardef.allowEapm}}
  74. {if isset($fields.{{$vardef.docType}}) && !empty($fields.{{$vardef.docType}}.value) && $fields.{{$vardef.docType}}.value != 'Sugar' && !empty($fields.{{$vardef.docUrl}}.value) }
  75. {capture name=imageNameCapture assign=imageName}
  76. {$fields.{{$vardef.docType}}.value}_image_inline.png
  77. {/capture}
  78. <a href="{$fields.{{$vardef.docUrl}}.value}" class="tabDetailViewDFLink" target="_blank"><img src="{sugar_getimagepath file=$imageName}" border="0"></a>
  79. {/if}
  80. {{/if}}
  81. {if !$noChange}
  82. <input type='button' class='button' value='{$APP.LBL_REMOVE}' onclick='SUGAR.field.file.deleteAttachment("{{$idName}}","{{$vardef.docType}}",this);'>
  83. {/if}
  84. </span>
  85. {if !$noChange}
  86. <span id="{{$idName}}_new" style="display:{if $showRemove}none;{/if}">
  87. <input type="hidden" name="{{$idName}}_escaped">
  88. <input id="{{$idName}}_file" name="{{$idName}}_file"
  89. type="file" title='{{$vardef.help}}' size="{{$displayParams.size|default:30}}"
  90. {{if !empty($vardef.len)}}
  91. maxlength='{{$vardef.len}}'
  92. {{elseif !empty($displayParams.maxlength)}}
  93. maxlength="{{$displayParams.maxlength}}"
  94. {{else}}
  95. maxlength="255"
  96. {{/if}}
  97. {{$displayParams.field}}>
  98. {{if isset($vardef.allowEapm) && $vardef.allowEapm}}
  99. <span id="{{$idName}}_externalApiSelector" style="display:none;">
  100. <br><h4 id="{{$idName}}_externalApiLabel">
  101. <span id="{{$idName}}_more">{sugar_image name="advanced_search" width="8px" height="8px"}</span>
  102. <span id="{{$idName}}_less" style="display: none;">{sugar_image name="basic_search" width="8px" height="8px"}</span>
  103. {$APP.LBL_SEARCH_EXTERNAL_API}</h4>
  104. <span id="{{$idName}}_remoteNameSpan" style="display: none;">
  105. <input type="text" class="sqsEnabled" name="{{$idName}}_remoteName" id="{{$idName}}_remoteName" size="{{$displayParams.size|default:30}}"
  106. {{if !empty($vardef.len)}}
  107. maxlength='{{$vardef.len}}'
  108. {{elseif !empty($displayParams.maxlength)}}
  109. maxlength="{{$displayParams.maxlength}}"
  110. {{else}}
  111. maxlength="255"
  112. {{/if}} autocomplete="off" value="{if !empty($fields[{{$vardef.docId}}].value)}{{sugarvar key='name'}}{/if}">
  113. {{if empty($displayParams.hideButtons) }}
  114. <span class="id-ff multiple">
  115. <button type="button" name="{{$idName}}_remoteSelectBtn" id="{{$idName}}_remoteSelectBtn" tabindex="{{$tabindex}}" title="{$APP.LBL_SELECT_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECT_BUTTON_KEY}" class="button firstChild" value="{$APP.LBL_SELECT_BUTTON_LABEL}"
  116. onclick="SUGAR.field.file.openPopup('{{$idName}}'); return false;"
  117. ><img src="{sugar_getimagepath file="id-ff-select.png"}"></button
  118. ><button type="button" name="{{$idName}}_remoteClearBtn" id="{{$idName}}_remoteClearBtn" tabindex="{{$tabindex}}" title="{$APP.LBL_CLEAR_BUTTON_TITLE}" accessKey="{$APP.LBL_CLEAR_BUTTON_KEY}" class="button lastChild" value="{$APP.LBL_CLEAR_BUTTON_LABEL}"
  119. onclick="SUGAR.field.file.clearRemote('{{$idName}}'); return false;"
  120. ><img src="{sugar_getimagepath file="id-ff-clear.png"}"></button>
  121. </span>
  122. {{/if}}
  123. </span>
  124. <div style="display: none;" id="{{$idName}}_securityLevelBox">
  125. <b>{$APP.LBL_EXTERNAL_SECURITY_LEVEL}: </b>
  126. <select name="{{$idName}}_securityLevel" id="{{$idName}}_securityLevel">
  127. </select>
  128. </div>
  129. <script type="text/javascript">
  130. YAHOO.util.Event.onDOMReady(function() {ldelim}
  131. SUGAR.field.file.setupEapiShowHide("{{$idName}}","{{$vardef.docType}}","{$form_name}");
  132. {rdelim});
  133. if ( typeof(sqs_objects) == 'undefined' ) {ldelim}
  134. sqs_objects = new Array;
  135. {rdelim}
  136. sqs_objects["{$form_name}_{{$idName}}_remoteName"] = {ldelim}
  137. "form":"{$form_name}",
  138. "method":"externalApi",
  139. "api":"",
  140. "modules":["EAPM"],
  141. "field_list":["name", "id", "url", "id"],
  142. "populate_list":["{{$idName}}_remoteName", "{{$vardef.docId}}", "{{$vardef.docUrl}}", "{{$idName}}"],
  143. "required_list":["name"],
  144. "conditions":[],
  145. "no_match_text":"No Match"
  146. {rdelim};
  147. if(typeof QSProcessedFieldsArray != 'undefined') {ldelim}
  148. QSProcessedFieldsArray["{$form_name}_{{$idName}}_remoteName"] = false;
  149. {rdelim}
  150. {if $showRemove && strlen("{{$vardef.docType}}") > 0 }
  151. document.getElementById("{{$vardef.docType}}").disabled = true;
  152. {/if}
  153. enableQS(false);
  154. </script>
  155. {{/if}}
  156. {else}
  157. {* No change possible *}
  158. {{if isset($vardef.allowEapm) && $vardef.allowEapm}}
  159. <script type="text/javascript">
  160. YAHOO.util.Event.onDOMReady(function()
  161. {ldelim}
  162. document.getElementById("{{$vardef.docType}}").disabled = true;
  163. {rdelim});
  164. </script>
  165. {{/if}}
  166. {/if}
  167. {{if !empty($displayParams.onchangeSetFileNameTo) }}
  168. <script type="text/javascript">
  169. var {{$idName}}_setFileName = function()
  170. {literal}
  171. {
  172. var dom = YAHOO.util.Dom;
  173. {/literal}
  174. sourceElement = "{{$idName}}_file";
  175. targetElement = "{{$displayParams.onchangeSetFileNameTo}}";
  176. src = new String(dom.get(sourceElement).value);
  177. target = new String(dom.get(targetElement).value);
  178. {literal}
  179. if (target.length == 0)
  180. {
  181. lastindex=src.lastIndexOf("/");
  182. if (lastindex == -1) {
  183. lastindex=src.lastIndexOf("\\");
  184. }
  185. if (lastindex == -1) {
  186. dom.get(targetElement).value=src;
  187. } else {
  188. dom.get(targetElement).value=src.substr(++lastindex, src.length);
  189. }
  190. }
  191. }
  192. {/literal}
  193. YAHOO.util.Event.onDOMReady(function()
  194. {ldelim}
  195. if(document.getElementById("{{$displayParams.onchangeSetFileNameTo}}"))
  196. {ldelim}
  197. YAHOO.util.Event.addListener('{{$idName}}_file', 'change', {{$idName}}_setFileName);
  198. YAHOO.util.Event.addListener(['{{$idName}}_file', '{{$vardef.docType}}'], 'change', SUGAR.field.file.checkFileExtension,{ldelim} fileEl: '{{$idName}}_file', targEl: '{{$displayParams.onchangeSetFileNameTo}}'{rdelim});
  199. {rdelim}
  200. {rdelim});
  201. </script>
  202. {{/if}}
  203. </span>