edit.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <extend name="Public:base" />
  2. <block name="content">
  3. <div class="page-header">
  4. <h1>
  5. {$breadcrumb2}
  6. <small>
  7. <i class="icon-double-angle-right"></i>
  8. {$crumbs}
  9. </small>
  10. <button name="send" form="form-blog" type="submit" style="float:right;" class="btn btn-sm btn-primary">提交</button>
  11. </h1>
  12. </div>
  13. <div class="row">
  14. <div class="col-xs-12">
  15. <div class="alert alert-block alert-success">
  16. 1、文章类型为:“商家后台”、“常见问题” 的,可以添加多篇文章<br/>
  17. 2、文章类型为:“拼团介绍” 的目前仅需要添加1篇文章即可
  18. </div>
  19. </div>
  20. <div class="col-xs-12">
  21. <div class="panel-body">
  22. <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-blog" class="form-horizontal">
  23. <notempty name="Think.get.id">
  24. <input name="blog_id" type="hidden" value="{$Think.get.id}" />
  25. </notempty>
  26. <ul class="nav nav-tabs">
  27. <li class="active"><a href="#tab-general" data-toggle="tab">常规项</a></li>
  28. </ul>
  29. <div class="tab-content">
  30. <!-- 常规 START -->
  31. <div class="tab-pane active" id="tab-general">
  32. <div class="form-group required">
  33. <label class="col-sm-2 control-label" for="input-name2">标题:</label>
  34. <div class="col-sm-10">
  35. <input id="input-name2" class="form-control" type="text" placeholder="标题" name="title" value="{$blog.title|default=''}" />
  36. </div>
  37. </div>
  38. <div class="form-group required">
  39. <label class="col-sm-2 control-label" for="input-name2">内容摘要:</label>
  40. <div class="col-sm-10">
  41. <textarea id="input-meta-description2" class="form-control" placeholder="内容摘要" rows="5" name="summary">{$blog_content.summary|default=''}</textarea>
  42. </div>
  43. </div>
  44. <div class="form-group required">
  45. <label class="col-sm-2 control-label" for="input-name2">作者:</label>
  46. <div class="col-sm-10">
  47. <input id="input-name2" class="form-control" type="text" placeholder="作者" name="author" value="<?php echo empty($blog['author'])?C('SITE_NAME'):$blog['author']; ?>" />
  48. </div>
  49. </div>
  50. <div class="form-group required">
  51. <label class="col-sm-2 control-label" for="input-name2">文章类型:</label>
  52. <div class="col-sm-10">
  53. <select name="type" class="form-control">
  54. <?php foreach($blog_type as $key => $type){ ?>
  55. <option value="<?php echo $key; ?>" <?php if(!empty($blog['type']) && $blog['type'] == $key){ echo 'selected';} ?> ><?php echo $type;?></option>
  56. <?php } ?>
  57. </select>
  58. </div>
  59. </div>
  60. <div class="form-group required">
  61. <label class="col-sm-2 control-label" for="input-image">
  62. <span title="" data-toggle="tooltip" data-original-title="上传640x320的图片">图片:</span>
  63. </label>
  64. <div class="col-sm-10" id="thumb">
  65. <a href="#" data-toggle="image" class="img-thumbnail">
  66. <img osctype="image" <if condition="!empty($blog['image'])">
  67. src="__ROOT__{$blog.thumb_image}"
  68. <else />
  69. src="__ROOT__/Common/image/no_image_100x100.jpg"
  70. </if> />
  71. </a>
  72. <input osctype="image_input" type="hidden" name="image" value="{$blog.image|default=''}" id="input-image" />
  73. </div>
  74. </div>
  75. <div class="form-group">
  76. <label class="col-sm-2 control-label">状态:</label>
  77. <div class="col-sm-10">
  78. <label class="radio-inline">
  79. <input type="radio" checked="checked" value="1" name="status">启用</label>
  80. <label class="radio-inline">
  81. <input type="radio" value="0" name="status">停用</label>
  82. </div>
  83. </div>
  84. <div class="form-group">
  85. <label class="col-sm-2 control-label" for="input-description">详情:</label>
  86. <div class="col-sm-10">
  87. <textarea id="description" name="content" >{$blog_content.content|default=''}</textarea>
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <label class="col-sm-2 control-label" for="input-meta-description2">Meta标签描述:</label>
  92. <div class="col-sm-10">
  93. <textarea id="input-meta-description2" class="form-control" placeholder="Meta标签描述" rows="5" name="meta_description">{$blog.meta_description|default=''}</textarea>
  94. </div>
  95. </div>
  96. <div class="form-group">
  97. <label class="col-sm-2 control-label" for="input-meta-keyword2">Meta标签关键词:</label>
  98. <div class="col-sm-10">
  99. <textarea id="input-meta-keyword2" class="form-control" placeholder="Meta标签关键词" rows="5" name="meta_keywords">{$blog.meta_keywords|default=''}</textarea>
  100. </div>
  101. </div>
  102. </div>
  103. <!-- 常规 END -->
  104. </div>
  105. </form>
  106. </div>
  107. </div>
  108. </div>
  109. </block>
  110. <block name="javascript">
  111. <style>
  112. .table thead > tr > td, .table tbody > tr > td {
  113. vertical-align: middle;
  114. }
  115. .table thead td span[data-toggle="tooltip"]:after, label.control-label span:after {
  116. font-family: FontAwesome;
  117. color: #1E91CF;
  118. content: "\f059";
  119. margin-left: 4px;
  120. }
  121. </style>
  122. <script src="__PUBLIC__/fileupload/jquery.ui.widget.js"></script>
  123. <script src="__PUBLIC__/fileupload/jquery.fileupload.js"></script>
  124. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
  125. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
  126. <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
  127. <script>
  128. $(function(){
  129. var ue = UE.getEditor('description',{
  130. initialFrameHeight:500,
  131. serverUrl: "__PUBLIC__/ueditor/php/controller.php",
  132. scaleEnabled:true
  133. });
  134. })
  135. $(function(){
  136. <present name="Think.get.id">
  137. Oscshop.setValue("status", {$blog.status|default=1});
  138. Oscshop.setValue("allow_reply", {$blog.allow_reply|default=1});
  139. </present>
  140. // tooltips on hover button-upload
  141. $('[data-toggle=\'tooltip\']').tooltip({container: 'body', html: true});
  142. // Makes tooltips work on ajax generated content
  143. $(document).ajaxStop(function() {
  144. $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
  145. });
  146. $(document).delegate('a[data-toggle=\'image\']', 'click', function(e) {
  147. e.preventDefault();
  148. var index=$(this).attr('num');
  149. var element = this;
  150. if(index==undefined){
  151. $(element).popover({
  152. html: true,
  153. placement: 'right',
  154. trigger: 'manual',
  155. content: function() {
  156. return '<button type="button" id="thumb-image" class="btn btn-primary"><i class="icon-edit"></i></button> <button type="button" id="button-clear" class="btn btn-danger"><i class="icon-trash"></i></button>';
  157. }
  158. });
  159. }else{
  160. $(element).popover({
  161. html: true,
  162. placement: 'right',
  163. trigger: 'manual',
  164. content: function() {
  165. return '<button type="button" n="'+index+'" class="btn btn-primary button-image"><i class="icon-edit"></i></button> <button type="button" id="button-clear" class="btn btn-danger"><i class="icon-trash"></i></button>';
  166. }
  167. });
  168. }
  169. $(element).popover('toggle');
  170. //图片
  171. $('#thumb-image').on('click', function() {
  172. $('#modal-image').remove();
  173. $('#form-upload').remove();
  174. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  175. $('#form-upload input[name=\'file\']').trigger('click');
  176. $(element).popover('hide');
  177. $('[osctype="btn_upload_image"]').fileupload({
  178. dataType: 'json',
  179. url: "{:U('Image/upload_image',array('dir'=>'blog2'))}",
  180. add: function(e, data) {
  181. $parent = $('#thumb');
  182. $input = $parent.find('[osctype="image_input"]');
  183. $img = $parent.find('[osctype="image"]');
  184. data.formData = {old_blog_images:$input.val()};
  185. $img.attr('src', "__IMG__/loading.gif");
  186. data.submit();
  187. },
  188. done: function (e,data) {
  189. var image=data.result;
  190. $parent = $('#thumb');
  191. $input = $parent.find('[osctype="image_input"]');
  192. $img = $parent.find('[osctype="image"]');
  193. if(image) {
  194. // $img.prev('i').hide();
  195. $img.attr('src', '__ROOT__'+image.image_thumb);
  196. $img.show();
  197. $input.val(image.image);
  198. } else {
  199. alert('上传失败');
  200. }
  201. }
  202. });
  203. });
  204. //相册
  205. $('.button-image').on('click', function() {
  206. $('#modal-image').remove();
  207. $('#form-upload').remove();
  208. var i=$(this).attr('n');
  209. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  210. $('#form-upload input[name=\'file\']').trigger('click');
  211. $(element).popover('hide');
  212. $('[osctype="btn_upload_image"]').fileupload({
  213. dataType: 'json',
  214. url: "{:U('Image/upload_image',array('dir'=>'blog_gallery'))}",
  215. add: function(e, data) {
  216. $parent = $('#image-row'+i);
  217. $input = $parent.find('[osctype="gallery_image_input'+i+'"]');
  218. $img = $parent.find('[osctype="gallery_image'+i+'"]');
  219. data.formData = {old_gallery_image:$input.val()};
  220. $img.attr('src', "__IMG__/loading.gif");
  221. data.submit();
  222. },
  223. done: function (e,data) {
  224. var image=data.result;
  225. $parent = $('#image-row'+i);
  226. $input = $parent.find('[osctype="gallery_image_input'+i+'"]');
  227. $img = $parent.find('[osctype="gallery_image'+i+'"]');
  228. if(image) {
  229. // $img.prev('i').hide();
  230. $img.attr('src', '__ROOT__'+image.image_thumb);
  231. $img.show();
  232. $input.val(image.image);
  233. } else {
  234. alert('上传失败');
  235. }
  236. }
  237. });
  238. });
  239. $('#button-clear').on('click', function() {
  240. $(element).find('img').attr('src', $(element).find('img').attr('data-placeholder'));
  241. $(element).parent().find('input').attr('value', '');
  242. $(element).popover('hide');
  243. });
  244. });
  245. });
  246. </script>
  247. </block>