. */ define('tas_osshaft_colors_THEME_VERSION', '3.0'); if(!OC_ADMIN) { if(!function_exists('tas_osshaft_colors_add_close_button_action')) { function tas_osshaft_colors_add_close_button_action() { echo ''; } osc_add_hook('footer', 'tas_osshaft_colors_add_close_button_action'); } } function tas_osshaft_colors_admin_actions() { switch(Params::getParam('action_specific')) { case('settings'): $footerLink = Params::getParam('footer_link'); osc_set_preference('keyword_placeholder', Params::getParam('keyword_placeholder'), 'osshaft_colors_theme'); osc_set_preference('footer_link', ($footerLink ? '1' : '0'), 'osshaft_colors_theme'); osc_set_preference('theme_preset', Params::getParam('theme_preset'), 'osshaft_colors_theme'); osc_add_flash_ok_message(__('Theme settings updated correctly', 'osshaft_colors'), 'admin'); osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osshaft_colors/admin/settings.php')); break; case('upload_logo'): $package = Params::getFiles('logo'); if($package['error'] == UPLOAD_ERR_OK) { if(move_uploaded_file($package['tmp_name'], WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) { osc_add_flash_ok_message(__('The logo image has been uploaded correctly', 'osshaft_colors'), 'admin'); } else { osc_add_flash_error_message(__("An error has occurred, please try again", 'osshaft_colors'), 'admin'); } } else { osc_add_flash_error_message(__("An error has occurred, please try again", 'osshaft_colors'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osshaft_colors/admin/header.php')); break; case('remove'): if(file_exists(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) { @unlink(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg"); osc_add_flash_ok_message(__('The logo image has been removed', 'osshaft_colors'), 'admin'); } else { osc_add_flash_error_message(__("Image not found", 'osshaft_colors'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osshaft_colors/admin/header.php')); break; } } function tas_osshaft_colors_theme_preset_apply() { $theme_preset = tas_osshaft_colors_theme_preset(); switch($theme_preset) { case 'light': osc_enqueue_style('style', osc_current_web_theme_url('css/style.css')); break; case 'red': osc_enqueue_style('style_red', osc_current_web_theme_url('css/style_r.css')); break; case 'black': osc_enqueue_style('style_black', osc_current_web_theme_url('css/style_d.css')); break; case 'blue': osc_enqueue_style('style_blue', osc_current_web_theme_url('css/style_b.css')); break; } } function tas_osshaft_colors_theme_preset() { $theme_preset = osc_get_preference('theme_preset', 'osshaft_colors_theme'); // override theme preset in theme demo mode if(defined('DEMO_THEME')) { // read theme preset from get if(isset($_GET['tas_theme_preset']) && tas_osshaft_colors_theme_preset_isvalid($_GET['tas_theme_preset'])) { $theme_preset = $_GET['tas_theme_preset']; setcookie('tas_theme_preset', $theme_preset, null, '/'); } elseif(isset($_COOKIE['tas_theme_preset']) && tas_osshaft_colors_theme_preset_isvalid($_COOKIE['tas_theme_preset'])) { // read theme preset from cookie $theme_preset = $_COOKIE['tas_theme_preset']; } } // if not valid preset then get first defined preset if(!tas_osshaft_colors_theme_preset_isvalid($theme_preset)) { $tas_osshaft_colors_theme_presets = tas_osshaft_colors_theme_presets(); // get first preset from array reset($tas_osshaft_colors_theme_presets); $theme_preset = key($tas_osshaft_colors_theme_presets); } return $theme_preset; } function tas_osshaft_colors_theme_preset_isvalid($theme_preset) { $tas_osshaft_colors_theme_presets = tas_osshaft_colors_theme_presets(); if(isset($tas_osshaft_colors_theme_presets[$theme_preset])) { return true; } return false; } osc_add_hook('init_admin', 'tas_osshaft_colors_admin_actions'); osc_add_hook('header', 'tas_osshaft_colors_theme_preset_apply', 1); osc_admin_menu_appearance(__('Header logo', 'osshaft_colors'), osc_admin_render_theme_url('oc-content/themes/osshaft_colors/admin/header.php'), 'header_osshaft_colors'); osc_admin_menu_appearance(__('Theme settings', 'osshaft_colors'), osc_admin_render_theme_url('oc-content/themes/osshaft_colors/admin/settings.php'), 'settings_osshaft_colors'); if(!function_exists('tas_osshaft_colors_logo_header')) { function tas_osshaft_colors_logo_header() { $html = ''; if(file_exists(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) { return $html; } else { return osc_page_title(); } } } // install update options if(!function_exists('tas_osshaft_colors_theme_install')) { function tas_osshaft_colors_theme_install() { osc_set_preference('keyword_placeholder', __('ie. PHP Programmer', 'osshaft_colors'), 'osshaft_colors_theme'); osc_set_preference('version', tas_osshaft_colors_THEME_VERSION, 'osshaft_colors_theme'); osc_set_preference('footer_link', true, 'osshaft_colors_theme'); osc_set_preference('donation', '0', 'osshaft_colors_theme'); osc_reset_preferences(); } } if(!function_exists('tas_osshaft_colors_check_install')) { function tas_osshaft_colors_check_install() { $current_version = osc_get_preference('version', 'osshaft_colors_theme'); //check if current version is installed or need an update< if(!$current_version) { tas_osshaft_colors_theme_install(); } } } tas_osshaft_colors_check_install(); /** * New functions */ if(!function_exists('tas_osshaft_colors_add_body_class_construct')) { function tas_osshaft_colors_add_body_class_construct($classes){ $osshaft_colorsBodyClass = osshaft_colorsBodyClass::newInstance(); $classes = array_merge($classes, $osshaft_colorsBodyClass->get()); return $classes; } } if(!function_exists('tas_osshaft_colors_body_class')) { function tas_osshaft_colors_body_class($echo = true){ /** * Print body classes. * * @param string $echo Optional parameter. * @return print string with all body classes concatenated */ osc_add_filter('osshaft_colors_bodyClass','osshaft_colors_add_body_class_construct'); $classes = osc_apply_filter('osshaft_colors_bodyClass', array()); if($echo && count($classes)){ echo 'class="'.implode(' ',$classes).'"'; } else { return $classes; } } } if(!function_exists('tas_osshaft_colors_add_body_class')) { function tas_osshaft_colors_add_body_class($class){ /** * Add new body class to body class array. * * @param string $class required parameter. */ $osshaft_colorsBodyClass = osshaft_colorsBodyClass::newInstance(); $osshaft_colorsBodyClass->add($class); } } if(!function_exists('tas_osshaft_colors_nofollow_construct')) { /** * Hook for header, meta tags robots nofollos */ function tas_osshaft_colors_nofollow_construct() { echo '' . PHP_EOL; echo '' . PHP_EOL; } } if( !function_exists('tas_osshaft_colors_follow_construct') ) { /** * Hook for header, meta tags robots follow */ function tas_osshaft_colors_follow_construct() { echo '' . PHP_EOL; echo '' . PHP_EOL; } } if(!function_exists('tas_osshaft_colors_format_category_ad_count')) { function tas_osshaft_colors_format_category_ad_count() { return osc_category_total_items() ? '' . osc_category_total_items() . '' : ''; } } if(!function_exists('tas_osshaft_colors_format_region_ad_count')) { function tas_osshaft_colors_format_region_ad_count() { return osc_list_region_items() ? '' . osc_list_region_items() . '' : ''; } } if(!function_exists('tas_osshaft_colors_format_city_ad_count')) { function tas_osshaft_colors_format_city_ad_count() { return osc_list_city_items() ? '' . osc_list_city_items() . '' : ''; } } if(!function_exists('tas_osshaft_colors_format_list_title')) { /** * Format ad title for premium and regular ad for list tables * * @param string $title * @param string $url * @param bool $premium * @param bool $highlight searched keyword * @return string */ function tas_osshaft_colors_format_list_title($title, $url, $premium = false, $highlight = false) { if($highlight && osc_search_pattern()) { $title = osc_highlight(strip_tags($title)); } if($premium) { return '' . $title . ' ' . __("Premium Listing", "osshaft_colors") . ' '; } else { return '' . $title . ''; } } } if(!function_exists('tas_osshaft_colors_format_alert_description')) { /** * Format alert parameters to human readible html * * @param array $alert object * @return string */ function tas_osshaft_colors_format_alert_description($alert) { // Taken from \oc-includes\osclass\classes\datatables\AlertsDataTable.php $pieces = array(); $conditions = osc_get_raw_search((array) json_decode(base64_decode($alert['s_search']), true)); if(isset($conditions['sPattern']) && $conditions['sPattern'] != '') { $pieces[] = sprintf(__("Pattern: %s"), $conditions['sPattern']); } if(isset($conditions['aCategories']) && !empty($conditions['aCategories'])) { $l = min(count($conditions['aCategories']), 4); $cat_array = array(); for($c = 0; $c < $l; $c++) { $cat_array[] = $conditions['aCategories'][$c]; } if(count($conditions['aCategories']) > $l) { $cat_array[] = '' . __("...More") . ''; } $pieces[] = sprintf(__("Categories: %s"), implode(", ", $cat_array)); } return implode($pieces, ", "); } } if(!function_exists('tas_osshaft_colors_format_image_count')) { /** * Format ad image count if there are more than one image * * @return string */ function tas_osshaft_colors_format_image_count() { if(osc_count_item_resources() > 1) { return '' . osc_count_item_resources() . ''; } return ''; } } if(!function_exists('tas_osshaft_colors_theme_presets')) { function tas_osshaft_colors_theme_presets() { return array( 'light' => __('Light', 'osshaft_colors'), 'red' => __('Red', 'osshaft_colors'), 'black' => __('Black', 'osshaft_colors'), 'blue' => __('Blue', 'osshaft_colors') ); } } function tas_debug_info() { if(defined('DEBUG')) { //$q = LogDatabase::newInstance()->queries; $q = LogDatabase::newInstance()->messages; //$q = DBCommandClass::$queries; echo '[total-queries:' . LogDatabase::newInstance()->getTotalNumberQueries() . ', query time:' . LogDatabase::newInstance()->getTotalQueriesTime() . ', memory usage:' . round(memory_get_peak_usage(true) / 1024) . ' KB' . ', execution-time:' . (microtime(true) - $_SERVER['REQUEST_TIME']) . ']
'; } } /*CLASSES*/ class osshaft_colorsBodyClass { /** * Custom Class for add, remove or get body classes. * * @param string $instance used for singleton. * @param array $class. */ private static $instance; private $class; private function __construct() { $this->class = array(); } public static function newInstance() { if ( !self::$instance instanceof self) { self::$instance = new self; } return self::$instance; } public function add($class) { $this->class[] = $class; } public function get() { return $this->class; } } osc_add_hook('footer', 'tas_debug_info'); osc_add_hook('before_user_register', 'tas_demo_theme_restriction'); ?>