content.html.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php js::set('confirmDelete', $lang->doc->confirmDelete);?>
  2. <?php $sessionString = session_name() . '=' . session_id();?>
  3. <div style="height:100%" id="h-full">
  4. <div class="main-col col-8 flex-content">
  5. <div class="cell" id="content">
  6. <div class="detail no-padding">
  7. <div class="detail-title no-padding doc-title">
  8. <div class="flex-left">
  9. <div class="title" title="<?php echo $doc->title;?>">
  10. <?php echo $doc->title;?>
  11. <?php if($doc->deleted):?>
  12. <span class='label label-danger'><?php echo $lang->doc->deleted;?></span>
  13. <?php endif;?>
  14. </div>
  15. <?php if($doc->status != 'draft'):?>
  16. <div class="info">
  17. <?php $version = $version ? $version : $doc->version;?>
  18. <div class="version" data-version='<?php echo $version;?>'>
  19. <div id="diffBtnGroup" class='btn-group exchangeDiffGroup'>
  20. <a href='javascript:;' class='btn btn-link btn-limit text-ellipsis left-dom' data-toggle='dropdown' style="max-width: 120px;">
  21. V<?php echo $version;?>
  22. <span class="caret"></span>
  23. </a>
  24. <i id="exchangeDiffBtn" class="icon icon-exchange right-dom"></i>
  25. <a href='javascript:;' class='btn btn-link btn-limit text-ellipsis right-dom' data-toggle='dropdown' style="max-width: 120px;">
  26. <span class="caret"></span>
  27. </a>
  28. <ul id="docVersionMenu" class='dropdown-menu doc-version-menu' style='width: 260px; overflow-y:auto'>
  29. <li class="drop-title flex-between dropdown-header not-clear-menu"><div><?php echo $lang->doc->allVersion?></div></li>
  30. <div class="drop-body menu-active-primary menu-hover-primary">
  31. <?php for($itemVersion = $doc->version; $itemVersion > 0; $itemVersion--):?>
  32. <li class="li-item <?php if($itemVersion == $version) echo 'active';?>"><div class="checkbox-primary"><input type="checkbox" <?php echo "data-id=".$doc->id." data-version=".$itemVersion;?> ></input><label for=""></label></div><a href='javascript:void(0)' data-url='<?php echo $this->createLink('doc', 'view', "docID=$doc->id&version=$itemVersion"); ?>'>V<?php echo $itemVersion;?></a></li>
  33. <?php endfor;?>
  34. </div>
  35. <li class="drop-bottom"><button data-id="confirm" class="btn btn-primary"><?php echo $lang->confirm?></button><button data-id="cancel" class="btn"><?php echo $lang->doc->cancelDiff?></button></li>
  36. </ul>
  37. </div>
  38. </div>
  39. </div>
  40. <?php endif;?>
  41. </div>
  42. <div class="actions">
  43. <?php echo html::a("javascript:fullScreen()", '<span class="icon-fullscreen"></span>', '', "title='{$lang->fullscreen}' class='btn btn-link fullscreen-btn'");?>
  44. <?php if(common::hasPriv('doc', 'collect')):?>
  45. <?php $star = strpos($doc->collector, ',' . $this->app->user->account . ',') !== false ? 'star' : 'star-empty';?>
  46. <a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$doc->id&objectType=doc");?>" title="<?php echo $lang->doc->collect;?>" class='ajaxCollect btn btn-link'><?php echo html::image("static/svg/{$star}.svg", "class='$star'");?></a>
  47. <?php endif;?>
  48. <?php if($config->vision == 'rnd' and in_array($config->edition, array('max', 'ipd')) and $app->tab == 'project'):?>
  49. <?php
  50. $canImportToPracticeLib = (common::hasPriv('doc', 'importToPracticeLib') and helper::hasFeature('practicelib'));
  51. $canImportToComponentLib = (common::hasPriv('doc', 'importToComponentLib') and helper::hasFeature('componentlib'));
  52. if($canImportToPracticeLib or $canImportToComponentLib)
  53. {
  54. echo "<div class='btn-group inline'>";
  55. echo html::a('javascript:;', "<span class='icon icon-diamond'></span>", '', "data-toggle='dropdown' id='more' title='{$lang->import}' class='btn btn-link'");
  56. echo "<ul class='dropdown-menu pull-right'>";
  57. if($canImportToPracticeLib) echo '<li>' . html::a('#importToPracticeLib', $lang->doc->importToPracticeLib, '', 'data-toggle="modal"') . '</li>';
  58. if($canImportToComponentLib) echo '<li>' . html::a('#importToComponentLib', $lang->doc->importToComponentLib, '', 'data-toggle="modal"') . '</li>';
  59. echo '</ul></div>';
  60. }
  61. ?>
  62. <?php endif;?>
  63. <?php
  64. if(common::hasPriv('doc', 'edit'))
  65. {
  66. $iframe = '';
  67. $onlybody = false;
  68. if($doc->type != 'text' or isonlybody())
  69. {
  70. $iframe = 'iframe';
  71. $onlybody = 'true';
  72. }
  73. echo html::a(inlink('edit', "docID=$doc->id&comment=false&objectType=$objectType&objectID=$object->id&libID=$libID", '', $onlybody), '<span class="icon-edit"></span>', '', "title='{$lang->doc->edit}' class='btn btn-link $iframe' data-app='{$this->app->tab}'");
  74. }
  75. if(common::hasPriv('doc', 'delete'))
  76. {
  77. $deleteURL = $this->createLink('doc', 'delete', "docID=$doc->id&confirm=yes&from=lib");
  78. echo html::a("javascript:ajaxDeleteDoc(\"$deleteURL\", \"docList\", confirmDelete)", '<span class="icon-trash"></span>', '', "title='{$lang->doc->delete}' class='btn btn-link'");
  79. }?>
  80. <a id="hisTrigger" href="###" class="btn btn-link" title=<?php echo $lang->history?>><span class="icon icon-clock"></span></a>
  81. </div>
  82. <?php if(!empty($editors)):?>
  83. <div id='editorBox'>
  84. <?php $groupClass = count($editors) == 1 ? 'noDropdown' : '';?>
  85. <div class="btn-group <?php echo $groupClass;?>">
  86. <?php
  87. $space = common::checkNotCN() ? ' ' : '';
  88. $firstEditor = current($editors);
  89. $editorInfo = zget($users, $firstEditor->account) . ' ' . substr($firstEditor->date, 0, 10) . $space . $lang->doc->update;
  90. array_shift($editors);
  91. ?>
  92. <?php if(!empty($editors)):?>
  93. <button class="btn btn-link dropdown-toggle" data-toggle="dropdown">
  94. <span class="text" title='<?php echo $editorInfo;?>'><?php echo $editorInfo;?></span>
  95. <span class="caret"></span>
  96. </button>
  97. <ul class="dropdown-menu" id='editorMenu'>
  98. <?php
  99. foreach($editors as $editor)
  100. {
  101. $editorInfo = zget($users, $editor->account) . ' ' . substr($editor->date, 0, 10) . $space . $lang->doc->update;
  102. echo "<li title='$editorInfo'>$editorInfo</li>";
  103. }
  104. ?>
  105. </ul>
  106. <?php else:?>
  107. <span class="text" title='<?php echo $editorInfo;?>'><?php echo $editorInfo;?></span>
  108. <?php endif;?>
  109. </div>
  110. </div>
  111. <?php endif;?>
  112. </div>
  113. <div id="diffContain">
  114. <div class="detail-content article-content table-col" <?php if('attachment' == $doc->type) echo 'style="max-height: 60px"';?>>
  115. <div class='info'>
  116. <?php $createInfo = $doc->status == 'draft' ? zget($users, $doc->addedBy) . " {$lang->hyphen} " . substr($doc->addedDate, 0, 10) . (common::checkNotCN() ? ' ' : '') . $lang->doc->createAB : zget($users, $doc->releasedBy) . " {$lang->hyphen} " . substr($doc->releasedDate, 0, 10) . (common::checkNotCN() ? ' ' : '') . $lang->doc->release;?>
  117. <span class='user-time text-muted'><i class='icon-contacts'></i> <?php echo $createInfo;?></span>
  118. <span class='user-time text-muted'><i class='icon-star'></i> <?php echo $doc->collects;?></span>
  119. <span class='user-time text-muted'><i class='icon-eye'></i> <?php echo $doc->views;?></span>
  120. <?php if($doc->keywords):?>
  121. <span class='keywords'>
  122. <?php foreach($doc->keywords as $keywords):?>
  123. <?php if($keywords) echo "<span class='label label-outline' title='{$keywords}'>{$keywords}</span>";?>
  124. <?php endforeach;?>
  125. </span>
  126. <?php endif;?>
  127. </div>
  128. <?php
  129. if($doc->type == 'url' and $autoloadPage)
  130. {
  131. $url = $doc->content;
  132. if(!preg_match('/^https?:\/\//', $doc->content)) $url = 'http://' . $url;
  133. $urlIsHttps = strpos($url, 'https://') === 0;
  134. $ztIsHttps = ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'));
  135. if(($urlIsHttps and $ztIsHttps) or (!$urlIsHttps and !$ztIsHttps))
  136. {
  137. echo "<iframe width='100%' id='urlIframe' src='$url'></iframe>";
  138. }
  139. else
  140. {
  141. $parsedUrl = parse_url($url);
  142. $urlDomain = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
  143. $title = '';
  144. $response = common::http($url);
  145. preg_match_all('/<title>(.*)<\/title>/Ui', $response, $out);
  146. if(isset($out[1][0])) $title = $out[1][0];
  147. echo "<div id='urlCard'>";
  148. echo "<div class='url-icon'><img src='{$urlDomain}/favicon.ico' width='45' height='45' /></div>";
  149. echo "<div class='url-content'>";
  150. echo "<div class='url-title'>{$title}</div>";
  151. echo "<div class='url-href'>" . html::a($url, $url, '_target') . "</div>";
  152. echo "</div></div>";
  153. }
  154. }
  155. elseif($doc->contentType == 'markdown')
  156. {
  157. echo "<textarea id='markdownContent'>{$doc->content}</textarea>";
  158. }
  159. elseif($doc->type != 'attachment')
  160. {
  161. echo $doc->content;
  162. }
  163. ?>
  164. <?php if($doc->type != 'attachment'):?>
  165. <?php foreach($doc->files as $file):?>
  166. <?php if(in_array($file->extension, $config->file->imageExtensions)):?>
  167. <div class='file-image'>
  168. <a href="<?php echo $file->webPath?>" target="_blank">
  169. <img onload="setImageSize(this, 0)" src="<?php echo $this->createLink('file', 'read', "fileID={$file->id}");?>" alt="<?php echo $file->title?>" title="<?php echo $file->title;?>">
  170. </a>
  171. <span class='right-icon'>
  172. <?php
  173. if(common::hasPriv('file', 'download'))
  174. {
  175. $downloadLink = $this->createLink('file', 'download', 'fileID=' . $file->id);
  176. $downloadLink .= strpos($downloadLink, '?') === false ? '?' : '&';
  177. $downloadLink .= $sessionString;
  178. echo html::a($downloadLink, "<i class='icon icon-import'></i>", '', "class='btn-icon' style='margin-right: 10px;' title=\"{$lang->doc->download}\"");
  179. }
  180. ?>
  181. <?php if(common::hasPriv('doc', 'deleteFile')) echo html::a('###', "<i class='icon icon-trash'></i>", '', "class='btn-icon' title=\"{$lang->doc->deleteFile}\" onclick='deleteFile($file->id)'");?>
  182. </span>
  183. </div>
  184. <?php unset($doc->files[$file->id]);?>
  185. <?php endif;?>
  186. <?php endforeach;?>
  187. <?php endif;?>
  188. </div>
  189. </div>
  190. </div>
  191. <?php echo $this->fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true', 'object' => $doc));?>
  192. <div id="mainActions" class='main-actions hidden'>
  193. <?php common::printPreAndNext($preAndNext);?>
  194. </div>
  195. </div>
  196. <div id="outlineMenu" class="outline table-col">
  197. <div class="outline-content">
  198. <?php echo isset($outline) ? $outline : '';?>
  199. </div>
  200. </div>
  201. <div class="outline-toggle"><i class="icon icon-menu-arrow-left"></i></div>
  202. <div id="history" class='panel hidden' style="margin-left: 2px;">
  203. <?php
  204. $canBeChanged = common::canBeChanged('doc', $doc);
  205. if($canBeChanged) $actionFormLink = $this->createLink('action', 'comment', "objectType=doc&objectID=$doc->id");
  206. ?>
  207. <?php include '../../common/view/action.html.php';?>
  208. </div>
  209. </div>
  210. </div>
  211. <?php if(in_array($config->edition, array('max', 'ipd'))):?>
  212. <div class="modal fade" id="importToPracticeLib">
  213. <div class="modal-dialog mw-500px">
  214. <div class="modal-content">
  215. <div class="modal-header">
  216. <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
  217. <h4 class="modal-title"><?php echo $lang->doc->importToPracticeLib;?></h4>
  218. </div>
  219. <div class="modal-body">
  220. <form method='post' class='form-ajax' action='<?php echo $this->createLink('doc', 'importToPracticeLib', "doc=$doc->id");?>'>
  221. <table class='table table-form'>
  222. <tr>
  223. <th class='w-120px'><?php echo $lang->doc->practiceLib;?></th>
  224. <td>
  225. <?php echo html::select('lib', $practiceLibs, '', "class='form-control chosen' required");?>
  226. </td>
  227. </tr>
  228. <?php if(!common::hasPriv('assetlib', 'approvePractice') and !common::hasPriv('assetlib', 'batchApprovePractice')):?>
  229. <tr>
  230. <th><?php echo $lang->doc->approver;?></th>
  231. <td>
  232. <?php echo html::select('assignedTo', $practiceApprovers, '', "class='form-control chosen'");?>
  233. </td>
  234. </tr>
  235. <?php endif;?>
  236. <tr>
  237. <td colspan='2' class='text-center'>
  238. <?php echo html::submitButton($lang->import, '', 'btn btn-primary');?>
  239. </td>
  240. </tr>
  241. </table>
  242. </form>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. <div class="modal fade" id="importToComponentLib">
  248. <div class="modal-dialog mw-500px">
  249. <div class="modal-content">
  250. <div class="modal-header">
  251. <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
  252. <h4 class="modal-title"><?php echo $lang->doc->importToComponentLib;?></h4>
  253. </div>
  254. <div class="modal-body">
  255. <form method='post' class='form-ajax' action='<?php echo $this->createLink('doc', 'importToComponentLib', "doc=$doc->id");?>'>
  256. <table class='table table-form'>
  257. <tr>
  258. <th><?php echo $lang->doc->componentLib;?></th>
  259. <td>
  260. <?php echo html::select('lib', $componentLibs, '', "class='form-control chosen' required");?>
  261. </td>
  262. </tr>
  263. <?php if(!common::hasPriv('assetlib', 'approveComponent') and !common::hasPriv('assetlib', 'batchApproveComponent')):?>
  264. <tr>
  265. <th><?php echo $lang->doc->approver;?></th>
  266. <td>
  267. <?php echo html::select('assignedTo', $componentApprovers, '', "class='form-control chosen'");?>
  268. </td>
  269. </tr>
  270. <?php endif;?>
  271. <tr>
  272. <td colspan='2' class='text-center'>
  273. <?php echo html::submitButton($lang->import, '', 'btn btn-primary');?>
  274. </td>
  275. </tr>
  276. </table>
  277. </form>
  278. </div>
  279. </div>
  280. </div>
  281. </div>
  282. <?php endif;?>
  283. <?php include '../../common/view/syntaxhighlighter.html.php';?>
  284. <?php if($doc->contentType == 'markdown'):?>
  285. <?php css::import($jsRoot . "markdown/simplemde.min.css");?>
  286. <?php js::import($jsRoot . 'markdown/simplemde.min.js'); ?>
  287. <?php js::set('markdownText', htmlspecialchars($doc->content));?>
  288. <script>
  289. $(function()
  290. {
  291. var simplemde = new SimpleMDE({element: $("#markdownContent")[0],toolbar:false, status: false});
  292. simplemde.value(String(markdownText));
  293. simplemde.togglePreview();
  294. $('#content .CodeMirror .editor-preview a').attr('target', '_blank');
  295. })
  296. </script>
  297. <?php endif;?>