PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/modern/functions.php

https://github.com/trains58554/osclass-themes
PHP | 214 lines | 177 code | 18 blank | 19 comment | 30 complexity | 7591d8d3aec77e61359e6c1e1001c0d7 MD5 | raw file
  1. <?php
  2. /*
  3. * OSCLass – software for creating and publishing online classified
  4. * advertising platforms
  5. *
  6. * Copyright (C) 2010 OSCLASS
  7. *
  8. * This program is free software: you can redistribute it and/or
  9. * modify it under the terms of the GNU Affero General Public License
  10. * as published by the Free Software Foundation, either version 3 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. if( !function_exists('add_logo_header') ) {
  22. function add_logo_header() {
  23. $html = '<img border="0" alt="' . osc_page_title() . '" src="' . osc_current_web_theme_url('images/logo.jpg') . '">';
  24. $js = "<script>
  25. $(document).ready(function () {
  26. $('#logo').html('".$html."');
  27. });
  28. </script>";
  29. if( file_exists( WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg" ) ) {
  30. echo $js;
  31. }
  32. }
  33. osc_add_hook("header", "add_logo_header");
  34. }
  35. if( !function_exists('modern_admin_menu') ) {
  36. function modern_admin_menu() {
  37. echo '<h3><a href="#">'. __('Modern theme','modern') .'</a></h3>
  38. <ul>
  39. <li><a href="' . osc_admin_render_theme_url('oc-content/themes/modern/admin/admin_settings.php') . '">&raquo; '.__('Settings theme', 'modern').'</a></li>
  40. </ul>';
  41. }
  42. osc_add_hook('admin_menu', 'modern_admin_menu');
  43. }
  44. if( !function_exists('meta_title') ) {
  45. function meta_title( ) {
  46. $location = Rewrite::newInstance()->get_location();
  47. $section = Rewrite::newInstance()->get_section();
  48. switch ($location) {
  49. case ('item'):
  50. switch ($section) {
  51. case 'item_add': $text = __('Publish an item', 'modern') . ' - ' . osc_page_title(); break;
  52. case 'item_edit': $text = __('Edit your item', 'modern') . ' - ' . osc_page_title(); break;
  53. case 'send_friend': $text = __('Send to a friend', 'modern') . ' - ' . osc_item_title() . ' - ' . osc_page_title(); break;
  54. case 'contact': $text = __('Contact seller', 'modern') . ' - ' . osc_item_title() . ' - ' . osc_page_title(); break;
  55. default: $text = osc_item_title() . ' - ' . osc_page_title(); break;
  56. }
  57. break;
  58. case('page'):
  59. $text = osc_static_page_title() . ' - ' . osc_page_title();
  60. break;
  61. case('error'):
  62. $text = __('Error', 'modern') . ' - ' . osc_page_title();
  63. break;
  64. case('search'):
  65. $region = Params::getParam('sRegion');
  66. $city = Params::getParam('sCity');
  67. $pattern = Params::getParam('sPattern');
  68. $category = osc_search_category_id();
  69. $category = ((count($category) == 1) ? $category[0] : '');
  70. $s_page = '';
  71. $i_page = Params::getParam('iPage');
  72. if($i_page != '' && $i_page > 0) {
  73. $s_page = __('page', 'modern') . ' ' . ($i_page + 1) . ' - ';
  74. }
  75. $b_show_all = ($region == '' && $city == '' & $pattern == '' && $category == '');
  76. $b_category = ($category != '');
  77. $b_pattern = ($pattern != '');
  78. $b_city = ($city != '');
  79. $b_region = ($region != '');
  80. if($b_show_all) {
  81. $text = __('Show all items', 'modern') . ' - ' . $s_page . osc_page_title();
  82. }
  83. $result = '';
  84. if($b_pattern) {
  85. $result .= $pattern . ' &raquo; ';
  86. }
  87. if($b_category) {
  88. $list = array();
  89. $aCategories = Category::newInstance()->toRootTree($category);
  90. if(count($aCategories) > 0) {
  91. foreach ($aCategories as $single) {
  92. $list[] = $single['s_name'];
  93. }
  94. $result .= implode(' &raquo; ', $list) . ' &raquo; ';
  95. }
  96. }
  97. if($b_city) {
  98. $result .= $city . ' &raquo; ';
  99. }
  100. if($b_region) {
  101. $result .= $region . ' &raquo; ';
  102. }
  103. $result = preg_replace('|\s?&raquo;\s$|', '', $result);
  104. if($result == '') {
  105. $result = __('Search', 'modern');
  106. }
  107. $text = $result . ' - ' . $s_page . osc_page_title();
  108. break;
  109. case('login'):
  110. switch ($section) {
  111. case('recover'): $text = __('Recover your password', 'modern') . ' - ' . osc_page_title();
  112. default: $text = __('Login', 'modern') . ' - ' . osc_page_title();
  113. }
  114. break;
  115. case('register'):
  116. $text = __('Create a new account', 'modern') . ' - ' . osc_page_title();
  117. break;
  118. case('user'):
  119. switch ($section) {
  120. case('dashboard'): $text = __('Dashboard', 'modern') . ' - ' . osc_page_title(); break;
  121. case('items'): $text = __('Manage my items', 'modern') . ' - ' . osc_page_title(); break;
  122. case('alerts'): $text = __('Manage my alerts', 'modern') . ' - ' . osc_page_title(); break;
  123. case('profile'): $text = __('Update my profile', 'modern') . ' - ' . osc_page_title(); break;
  124. case('change_email'): $text = __('Change my email', 'modern') . ' - ' . osc_page_title(); break;
  125. case('change_password'): $text = __('Change my password', 'modern') . ' - ' . osc_page_title(); break;
  126. case('forgot'): $text = __('Recover my password', 'modern') . ' - ' . osc_page_title(); break;
  127. default: $text = osc_page_title(); break;
  128. }
  129. break;
  130. case('contact'):
  131. $text = __('Contact','modern') . ' - ' . osc_page_title();
  132. break;
  133. default:
  134. $text = osc_page_title();
  135. break;
  136. }
  137. $text = str_replace('"', "'", $text);
  138. return ($text);
  139. }
  140. }
  141. if( !function_exists('meta_description') ) {
  142. function meta_description( ) {
  143. $location = Rewrite::newInstance()->get_location();
  144. $section = Rewrite::newInstance()->get_section();
  145. $text = '';
  146. switch ($location) {
  147. case ('item'):
  148. switch ($section) {
  149. case 'item_add': $text = ''; break;
  150. case 'item_edit': $text = ''; break;
  151. case 'send_friend': $text = ''; break;
  152. case 'contact': $text = ''; break;
  153. default:
  154. $text = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
  155. break;
  156. }
  157. break;
  158. case('page'):
  159. $text = osc_highlight(strip_tags(osc_static_page_text()), 140);
  160. break;
  161. case('search'):
  162. $result = '';
  163. if(osc_count_items() == 0) {
  164. $text = '';
  165. }
  166. if(osc_has_items ()) {
  167. $result = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
  168. }
  169. osc_reset_items();
  170. $text = $result;
  171. case(''): // home
  172. $result = '';
  173. if(osc_count_latest_items() == 0) {
  174. $text = '';
  175. }
  176. if(osc_has_latest_items()) {
  177. $result = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
  178. }
  179. osc_reset_items();
  180. $text = $result;
  181. break;
  182. }
  183. $text = str_replace('"', "'", $text);
  184. return ($text);
  185. }
  186. }
  187. ?>