PageRenderTime 26ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/interface/owner/skin/index.php

https://github.com/hinablue/TextCube
PHP | 280 lines | 245 code | 22 blank | 13 comment | 44 complexity | 08c21ad0260b53e76895a21279cfab8c MD5 | raw file
Possible License(s): ISC, GPL-2.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, MIT
  1. <?php
  2. /// Copyright (c) 2004-2016, Needlworks / Tatter Network Foundation
  3. /// All rights reserved. Licensed under the GPL.
  4. /// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
  5. require ROOT . '/library/preprocessor.php';
  6. require ROOT . '/interface/common/owner/header.php';
  7. if(isset($_POST['search'])) {
  8. $search = $_POST['search'];
  9. } else $search = null;
  10. // get the list type.
  11. $listType = Setting::getBlogSettingGlobal('skinViewType', 'iconview');
  12. $skins = array();
  13. $dirHandler = dir(__TEXTCUBE_SKIN_DIR__);
  14. while ($file = $dirHandler->read()) {
  15. $skin = array();
  16. if ($file == '.' || $file == '..')
  17. continue;
  18. if (!file_exists(__TEXTCUBE_SKIN_DIR__ . "/$file/skin.html"))
  19. continue;
  20. $preview = "";
  21. if (file_exists(__TEXTCUBE_SKIN_DIR__ . "/$file/preview.jpg"))
  22. $preview = "{$context->getProperty('service.path')}/skin/blog/$file/preview.jpg";
  23. if (file_exists(__TEXTCUBE_SKIN_DIR__ . "/$file/preview.gif"))
  24. $preview = "{$context->getProperty('service.path')}/skin/blog/$file/preview.gif";
  25. if (file_exists(__TEXTCUBE_SKIN_DIR__ . "/$file/index.xml")) {
  26. $xml = file_get_contents(__TEXTCUBE_SKIN_DIR__ . "/$file/index.xml");
  27. $xmls = new XMLStruct();
  28. $xmls->open($xml, $service['encoding']);
  29. $skin['skinName'] = $xmls->getValue('/skin/information/name');
  30. $skin['version'] = $xmls->getValue('/skin/information/version');
  31. $skin['license'] = $xmls->getValue('/skin/information/license');
  32. $skin['maker'] = $xmls->getValue('/skin/author/name');
  33. $skin['homepage'] = $xmls->getValue('/skin/author/homepage');
  34. $skin['email'] = $xmls->getValue('/skin/author/email');
  35. $skin['description'] = $xmls->getValue('/skin/information/description');
  36. }
  37. if(!empty($search) &&
  38. (stristr($skin['skinName'],$search) === false) &&
  39. (stristr($skin['maker'],$search) === false) &&
  40. (stristr($skin['homepage'],$search) === false) &&
  41. (stristr($skin['email'],$search) === false) &&
  42. (stristr($skin['description'],$search) === false)) continue; // Search.
  43. $skin['name'] = $file;
  44. $skin['path'] = __TEXTCUBE_SKIN_DIR__ . "/$file/";
  45. $skin['preview'] = $preview;
  46. array_push($skins, $skin);
  47. }
  48. function writeValue($value, $label, $className) {
  49. ?>
  50. <dl class="<?php echo $className;?>-line">
  51. <dt class="name"><?php echo $label;?></dt>
  52. <dd class="explain"><?php echo nl2br(addLinkSense($value, ' onclick="window.open(this.href); return false;"'));?></dd>
  53. </dl>
  54. <?php
  55. }
  56. ?>
  57. <script type="text/javascript">
  58. //<![CDATA[
  59. var isSkinModified = <?php echo ($skinSetting['skin'] == "customize/$blogid") ? 'true' : 'false';?>;
  60. function selectSkin(name) {
  61. if(isSkinModified) {
  62. if(!confirm("<?php echo _t('수정된 스킨을 사용중입니다. 새로운 스킨을 선택하면 수정된 스킨의 내용과 스킨에 적용된 출력 설정, 사이드바의 변경점은 모두 지워집니다.\n스킨을 적용하시겠습니까?');?>"))
  63. return;
  64. } else {
  65. if(!confirm("<?php echo _t('새로운 스킨을 선택하면 이전 스킨에 적용된 출력 설정들과 사이드바의 변경점은 모두 지워집니다.\n스킨을 적용하시겠습니까?');?>"))
  66. return;
  67. }
  68. try {
  69. var request = new HTTPRequest("POST", "<?php echo $context->getProperty('uri.blog');?>/owner/skin/change/");
  70. request.onSuccess = function() {
  71. isSkinModified = false;
  72. PM.showMessage("<?php echo _t('성공적으로 변경했습니다.');?>", "center", "bottom");
  73. document.getElementById('currentPreview').innerHTML = document.getElementById('preview_'+name).innerHTML;
  74. document.getElementById('currentInfo').innerHTML = document.getElementById('info_'+name).innerHTML;
  75. //document.getElementById('currentButton').innerHTML = document.getElementById('button_'+name).innerHTML;
  76. //window.location.href = "#currentSkinAnchor";
  77. //eleganceScroll('currentSkin',8);
  78. /*
  79. document.getElementById('currentSkinPreview').innerHTML = document.getElementById('preivew_'+name).innerHTML
  80. document.getElementById('currentSkinInfo').innerHTML = document.getElementById('info_'+name).innerHTML
  81. */
  82. }
  83. request.onError = function() {
  84. msg = this.getText("/response/msg");
  85. if (this.getText("/response/msg") == null)
  86. msg = "<?php echo _t('올바른 스킨 디렉토리명이 아닙니다.\n디렉토리명에는 알파벳, 숫자, 언더바(_), 공백문자, 대쉬(-)만 사용하실 수 있습니다.');?>";
  87. alert(msg);
  88. }
  89. request.send("skinName=" + encodeURIComponent(name));
  90. } catch(e) {
  91. alert(e.message);
  92. }
  93. }
  94. function changeList(obj) {
  95. if(document.getElementById('list-view').checked == true) {
  96. viewtype = 'listview';
  97. } else {
  98. viewtype = 'iconview';
  99. }
  100. var request = new HTTPRequest("POST", "<?php echo $context->getProperty('uri.blog');?>/owner/skin/saveScope");
  101. request.onSuccess = function() {
  102. document.getElementById('search-form').submit();
  103. }
  104. request.onError = function() {
  105. alert("<?php echo _t('선택하신 조건을 적용할 수 없었습니다.');?>");
  106. }
  107. request.send("viewtype=" + viewtype);
  108. }
  109. //]]>
  110. </script>
  111. <div id="part-skin-current" class="part">
  112. <h2 class="caption"><span class="main-text"><?php echo _t('현재 사용중인 스킨');?></span></h2>
  113. <div class="data-inbox">
  114. <div id="currentSkin" class="section">
  115. <a id="currentSkinAnchor"></a>
  116. <div id="currentPreview" class="preview">
  117. <?php
  118. if (file_exists(getSkinPath($skinSetting['skin'])."/preview.jpg")) {
  119. ?>
  120. <img src="<?php echo $context->getProperty('service.path');?>/skin/blog/<?php echo $skinSetting['skin'];?>/preview.jpg" width="150" height="150" alt="<?php echo _t('스킨 미리보기');?>" />
  121. <?php
  122. } else if (file_exists(getSkinPath($skinSetting['skin'])."/preview.gif")) {
  123. ?>
  124. <img src="<?php echo $context->getProperty('service.path');?>/skin/blog/<?php echo $skinSetting['skin'];?>/preview.gif" width="150" height="150" alt="<?php echo _t('스킨 미리보기');?>" />
  125. <?php
  126. } else {
  127. ?>
  128. <img src="<?php echo $context->getProperty('service.path').$context->getProperty('panel.skin');?>/image/noPreview.gif" width="150" height="150" alt="<?php echo _t('스킨 미리보기');?>" />
  129. <?php
  130. }
  131. ?>
  132. </div>
  133. <div class="information">
  134. <?php
  135. if (file_exists(getSkinPath($skinSetting['skin']) . "/index.xml")) {
  136. ?>
  137. <div id="currentInfo">
  138. <?php
  139. $xml = file_get_contents(getSkinPath($skinSetting['skin']) . "/index.xml");
  140. $xmls = new XMLStruct();
  141. $xmls->open($xml, $service['encoding']);
  142. writeValue('<span class="skin-name">' . $xmls->getValue('/skin/information/name') . '</span> <span class="version">ver.' . $xmls->getValue('/skin/information/version') . ($skinSetting['skin'] == "customize/$blogid" ? _t('(사용자 수정본)') : NULL) . '</span>', _t('제목'), "title");
  143. writeValue($xmls->getValue('/skin/information/license'), _t('저작권'), "license");
  144. writeValue($xmls->getValue('/skin/author/name'), _t('만든이'), "maker");
  145. writeValue($xmls->getValue('/skin/author/homepage'), _t('홈페이지'), "homepage");
  146. writeValue($xmls->getValue('/skin/author/email'), _t('e-mail'), "email");
  147. writeValue($xmls->getValue('/skin/information/description'), _t('설명'), "explain");
  148. ?>
  149. </div>
  150. <div class="button-box">
  151. <a class="edit-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/skin/edit"><span class="text"><?php echo _t('편집하기');?></span></a>
  152. <span class="hidden">|</span>
  153. <a class="setting-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/skin/setting"><span class="text"><?php echo _t('세부 설정');?></span></a>
  154. </div>
  155. <?php
  156. } else {
  157. ?>
  158. <div id="currentInfo">
  159. <div id="customizedTable">
  160. <?php echo _t('선택하신 스킨이 존재하지 않습니다. 다른 스킨을 선택해 주시기 바랍니다.').CRLF;?>
  161. </div>
  162. </div>
  163. <?php
  164. }
  165. ?>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <div id="currentSkinLoading" class="system-message" style="display: none;">
  171. <?php echo _t('불러오는 중..');?>
  172. </div>
  173. <hr class="hidden" />
  174. <div id="part-skin-list" class="part">
  175. <h2 class="caption"><span class="main-text"><?php echo _t('사용가능한 스킨들의 목록입니다');?></span></h2>
  176. <form id="search-form" class="data-subbox" method="post" action="<?php echo $context->getProperty('uri.blog');?>/owner/skin">
  177. <h2><?php echo _t('검색');?></h2>
  178. <div id="search-box" class="section">
  179. <label for="search"><?php echo _t('제목');?>, <?php echo _t('내용');?></label>
  180. <input type="text" id="search" class="input-text" name="search" value="<?php echo htmlspecialchars($search);?>" onkeydown="if (event.keyCode == '13') { document.getElementById('search-form').submit();return false; }" />
  181. <input type="submit" class="search-button input-button" value="<?php echo _t('검색');?>" onclick="document.getElementById('search-form').submit();return false;" />
  182. </div>
  183. </form>
  184. <form id="skin-search-form" class="data-subbox" method="post" action="<?php echo $context->getProperty('uri.blog');?>/owner/skin">
  185. <dl id="viewmode-line" class="line">
  186. <dt class="hidden"><?php echo _t('출력 설정');?></dt>
  187. <dd id="viewmode-line-align">
  188. <input type="radio" class="radio" id="list-view" name="viewType" value="listview" onclick="changeList(this);return false;"<?php echo $listType == 'listview' ? ' checked="checked"' : '';?> /><label for="list-view"><?php echo _t('리스트 보기');?></label>
  189. <input type="radio" class="radio" id="icon-view" name="viewType" value="iconview" onclick="changeList(this);return false;"<?php echo $listType == 'iconview' ? ' checked="checked"' : '';?> /><label for="icon-view"><?php echo _t('아이콘 보기');?></label>
  190. </dd>
  191. </dl>
  192. </form>
  193. <div class="main-explain-box">
  194. <p class="explain"><?php echo _t('블로그에 적용하기 원하시는 스킨의 적용 버튼을 누르면 스킨이 블로그에 반영됩니다.');?></p>
  195. </div>
  196. <div id="<?php echo $listType;?>-box" class="data-inbox">
  197. <?php
  198. $count = 0;
  199. for ($i = 0; $i < count($skins); $i++) {
  200. $skin = $skins[$i];
  201. ?>
  202. <div class="section">
  203. <div id="preview_<?php echo $skin['name'];?>" class="preview">
  204. <?php
  205. if ($skin['preview'] == '') {
  206. ?>
  207. <img src="<?php echo $context->getProperty('service.path').$context->getProperty('panel.skin');?>/image/noPreview.gif" width="150" height="150" alt="<?php echo _t('스킨 미리보기');?>" />
  208. <?php
  209. } else {
  210. ?>
  211. <img src="<?php echo $skin['preview'];?>" width="150" height="150" alt="<?php echo _t('스킨 미리보기');?>" />
  212. <?php
  213. }
  214. ?>
  215. </div>
  216. <div class="information">
  217. <div id="info_<?php echo $skin['name'];?>">
  218. <?php
  219. if (isset($skin['skinName'])) {
  220. writeValue('<span class="skin-name">' . ($listType == 'iconview' ? Utils_Unicode::lessenAsEm($skin['skinName'],15) : $skin['skinName']) . '</span> <span class="version">' . ($listType == 'iconview' ? Utils_Unicode::lessenAsEm($skin['version'],5,'') : $skin['version']) . '</span>', _t('제목'), "title");
  221. writeValue($skin['license'], _t('저작권'), "license");
  222. writeValue($skin['maker'], _t('만든이'), "maker");
  223. writeValue($skin['homepage'], _t('홈페이지'), "homepage");
  224. writeValue($skin['email'], _t('e-mail'), "email");
  225. writeValue($skin['description'], _t('설명'), "explain");
  226. } else {
  227. writeValue($skin['name'], _t('제목'));
  228. }
  229. ?>
  230. </div>
  231. <div id="button_<?php echo $skin['name'];?>" class="button-box">
  232. <a class="preview-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/skin/preview/?skin=<?php echo $skin['name'];?>" onclick="window.open(this.href, &quot;<?php echo $skin['name'];?>&quot;,&quot;location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0&quot;); return false;"><span><?php echo _t('미리보기');?></span></a>
  233. <span class="hidden">|</span>
  234. <a class="apply-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/skin/change/?skinName=<?php echo urlencode($skin['name']);?>" onclick="selectSkin('<?php echo $skin['name'];?>'); return false;"><span><?php echo _t('적용');?></span></a>
  235. </div>
  236. </div>
  237. </div>
  238. <?php
  239. if((($i+1) % 4) == 0) echo CRLF.TAB.TAB.TAB.TAB.TAB.TAB.'<hr class="hidden list-divider" />'.CRLF;
  240. }
  241. ?>
  242. </div>
  243. <hr class="hidden clear" />
  244. </div>
  245. <hr class="hidden" />
  246. <div id="part-skin-more" class="part">
  247. <h2 class="caption"><span class="main-text"><?php echo _t('스킨을 구하려면');?></span></h2>
  248. <?php
  249. $linkString = '<a href="http://www.textcube.org/theme" onclick="window.open(this.href); return false;" title="' . _t('텍스트큐브 홈페이지의 스킨 업로드 게시판으로 연결합니다.') . '">' . _t('스킨 업로드 게시판'). '</a>';
  250. $tempString = _f('텍스트큐브 홈페이지의 %1을 방문하시면 다양한 스킨을 다운로드 하실 수 있습니다. 일반적으로 스킨 파일을 텍스트큐브의 skin 디렉토리로 업로드하면 설치가 완료됩니다. 업로드가 완료된 스킨은 이 메뉴에서 적용 버튼을 눌러 사용하실 수 있습니다.', $linkString);
  251. ?>
  252. <div class="main-explain-box">
  253. <p class="explain"><?php echo $tempString;?></p>
  254. </div>
  255. </div>
  256. <?php
  257. require ROOT . '/interface/common/owner/footer.php';
  258. ?>