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

/oc-admin/themes/modern/appearance/add.php

https://code.google.com/
PHP | 197 lines | 172 code | 8 blank | 17 comment | 8 complexity | 8dd89aaef07cce72e1df7963c1aeee69 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * OSClass รข&#x20AC;&#x201C; software for creating and publishing online classified advertising platforms
  4. *
  5. * Copyright (C) 2010 OSCLASS
  6. *
  7. * This program is free software: you can redistribute it and/or modify it under the terms
  8. * of the GNU Affero General Public License as published by the Free Software Foundation,
  9. * either version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  12. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public
  16. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. function addHelp() {
  19. echo '<p>' . __('Manually add OSClass themes in .zip format. If you prefer, you can manually upload the decompressed theme to <em>oc-content/themes</em>.') . '</p>';
  20. }
  21. osc_add_hook('help_box','addHelp');
  22. osc_add_hook('admin_page_header','customPageHeader');
  23. function customPageHeader(){ ?>
  24. <h1><?php _e('Appearance') ; ?>
  25. <a href="#" class="btn ico ico-32 ico-help float-right"></a>
  26. </h1>
  27. <?php
  28. }
  29. function customPageTitle($string) {
  30. return sprintf(__('Add theme &raquo; %s'), $string);
  31. }
  32. osc_add_filter('admin_title', 'customPageTitle');
  33. osc_current_admin_theme_path('parts/header.php') ; ?>
  34. <!-- themes list -->
  35. <div class="appearance">
  36. <h2 class="render-title"><?php _e('Add new theme') ; ?></h2>
  37. <div id="upload-themes" class="ui-osc-tabs-panel">
  38. <div class="form-horizontal">
  39. <?php if( is_writable( osc_themes_path() ) ) { ?>
  40. <div class="flashmessage flashmessage-info flashmessage-inline" style="display: block;">
  41. <p class="info"><?php printf( __('Download more themes at %s'), '<a href="https://sourceforge.net/projects/osclass/files/Themes/" target="_blank">Sourceforge</a>') ; ?></p>
  42. </div>
  43. <form class="separate-top" action="<?php echo osc_admin_base_url(true) ; ?>" method="post" enctype="multipart/form-data">
  44. <input type="hidden" name="action" value="add_post" />
  45. <input type="hidden" name="page" value="appearance" />
  46. <div class="form-row">
  47. <div class="form-label"><?php _e('Theme package (.zip)') ; ?></div>
  48. <div class="form-controls">
  49. <div class="form-label-checkbox"><input type="file" name="package" id="package" /></div>
  50. </div>
  51. </div>
  52. <div class="form-actions">
  53. <input type="submit" value="<?php echo osc_esc_html( __('Upload') ) ; ?>" class="btn btn-submit" />
  54. </div>
  55. </form>
  56. <?php } else { ?>
  57. <div class="flashmessage flashmessage-error">
  58. <a class="btn ico btn-mini ico-close" href="#">?&#x2014;</a>
  59. <p><?php _e("Can't install a new theme") ; ?></p>
  60. </div>
  61. <p class="text">
  62. <?php _e("The theme folder is not writable on your server so you can't upload themes from the administration panel. Please make the theme folder writable and try again.") ; ?>
  63. </p>
  64. <p class="text">
  65. <?php _e('To make the directory writable under UNIX execute this command from the shell:') ; ?>
  66. </p>
  67. <pre>chmod a+w <?php echo osc_themes_path() ; ?></pre>
  68. <?php } ?>
  69. </div>
  70. </div>
  71. <div id="market_installer" class="has-form-actions hide">
  72. <form action="" method="post">
  73. <input type="hidden" name="market_code" id="market_code" value="" />
  74. <div class="osc-modal-content-market">
  75. <img src="" id="market_thumb" class="float-left"/>
  76. <table class="table" cellpadding="0" cellspacing="0">
  77. <tbody>
  78. <tr class="table-first-row">
  79. <td><?php _e('Name') ; ?></td>
  80. <td><span id="market_name"><?php _e("Loading data"); ?></span></td>
  81. </tr>
  82. <tr class="even">
  83. <td><?php _e('Version') ; ?></td>
  84. <td><span id="market_version"><?php _e("Loading data"); ?></span></td>
  85. </tr>
  86. <tr>
  87. <td><?php _e('Author') ; ?></td>
  88. <td><span id="market_author"><?php _e("Loading data"); ?></span></td>
  89. </tr>
  90. <tr class="even">
  91. <td><?php _e('URL') ; ?></td>
  92. <td><a id="market_url" href="#"><?php _e("Download manually"); ?></span></td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <div class="clear"></div>
  97. </div>
  98. <div class="form-actions">
  99. <div class="wrapper">
  100. <button id="market_cancel" class="btn btn-red" ><?php echo osc_esc_html( __('Cancel') ) ; ?></button>
  101. <button id="market_install" class="btn btn-submit" ><?php echo osc_esc_html( __('Continue install') ) ; ?></button>
  102. </div>
  103. </div>
  104. </form>
  105. </div>
  106. <script>
  107. $(function() {
  108. $("#market_cancel").on("click", function(){
  109. $(".ui-dialog-content").dialog("close");
  110. return false;
  111. });
  112. $("#market_install").on("click", function(){
  113. $(".ui-dialog-content").dialog("close");
  114. //$(".ui-dialog-content").dialog({title:'Downloading...'}).html('Please wait until the download is completed');
  115. $('<div id="downloading"><div class="osc-modal-content">Please wait until the download is completed</div></div>').dialog({title:'Installing...',modal:true});
  116. $.getJSON(
  117. "<?php echo osc_admin_base_url(true); ?>?page=ajax&action=market",
  118. {"code" : $("#market_code").attr("value")},
  119. function(data){
  120. $("#downloading .osc-modal-content").html(data.message);
  121. setTimeout(function(){
  122. $(".ui-dialog-content").dialog("close");
  123. },1000);
  124. });
  125. return false;
  126. });
  127. $.getJSON(
  128. "<?php echo osc_admin_base_url(true); ?>?page=ajax&action=local_market",
  129. {"section" : "themes"},
  130. function(data){
  131. $("#market_themes").html(" ");
  132. if(data!=null && data.themes!=null) {
  133. for(var i=0;i<data.themes.length;i++) {
  134. var description = $(data.themes[i].s_description).text();
  135. dots = '';
  136. if(description.length > 80){
  137. dots = '...';
  138. }
  139. var imgsrc = '<?php echo osc_current_admin_theme("img/marketblank.jpg"); ?>';
  140. if(data.themes[i].s_image!=null) {
  141. imgsrc = data.themes[i].s_image;
  142. }
  143. $("#market_themes").append('<div class="theme">'
  144. +'<div class="theme-stage">'
  145. +'<img src="'+imgsrc+'" title="'+data.themes[i].s_title+'" alt="'+data.themes[i].s_title+'" />'
  146. +'<div class="theme-actions">'
  147. +'<a href="#'+data.themes[i].s_slug+'" class="btn btn-mini btn-green market-popup"><?php echo osc_esc_js(__('Install')); ?></a>'
  148. +'<a target="_blank" href="'+data.themes[i].s_preview+'" class="btn btn-mini btn-blue"><?php echo osc_esc_js(__('Preview')); ?></a>'
  149. +'</div>'
  150. +'</div>'
  151. +'<div class="theme-info">'
  152. +'<h3>'+data.themes[i].s_title+' '+data.themes[i].s_version+' <?php _e('by') ; ?> <a target="_blank" href="">'+data.themes[i].s_contact_name+'</a></h3>'
  153. +'</div>'
  154. +'<div class="theme-description">'
  155. +description.substring(0,80)+dots
  156. +'</div>'
  157. +'</div>');
  158. }
  159. }
  160. $("#market_themes").append('<div class="clear"></div>');
  161. }
  162. );
  163. });
  164. $('.market-popup').live('click',function(){
  165. $.getJSON(
  166. "<?php echo osc_admin_base_url(true); ?>?page=ajax&action=check_market",
  167. {"code" : $(this).attr('href').replace('#','')},
  168. function(data){
  169. if(data!=null) {
  170. $("#market_thumb").attr('src',data.s_thumbnail);
  171. $("#market_code").attr("value", data.s_slug);
  172. $("#market_name").html(data.s_title);
  173. $("#market_version").html(data.s_version);
  174. $("#market_author").html(data.s_contact_name);
  175. $("#market_url").attr('href',data.s_source_file);
  176. $('#market_installer').dialog({
  177. modal:true,
  178. title: '<?php echo osc_esc_js( __('OSClass Market') ) ; ?>',
  179. width:485
  180. });
  181. }
  182. }
  183. );
  184. return false;
  185. });
  186. </script>
  187. </div>
  188. <!-- /themes list -->
  189. <?php osc_current_admin_theme_path('parts/footer.php') ; ?>