. */ /** DEFINES */ define('OSCLASSWIZARDS_THEME_VERSION', '1.0.7'); if( !osc_get_preference('keyword_placeholder', 'osclasswizards_theme') ) { osc_set_preference('keyword_placeholder', __('ie. PHP Programmer', 'osclasswizards'), 'osclasswizards_theme'); } osc_register_script('fancybox', osc_current_web_theme_url('js/fancybox/jquery.fancybox.pack.js'), array('jquery')); osc_enqueue_style('fancybox', osc_current_web_theme_url('js/fancybox/jquery.fancybox.css')); osc_enqueue_script('fancybox'); osc_enqueue_style('font-awesome', osc_current_web_theme_url('css/font-awesome-4.1.0/css/font-awesome.min.css')); // used for date/dateinterval custom fields osc_enqueue_script('php-date'); if(!OC_ADMIN) { osc_enqueue_style('fine-uploader-css', osc_assets_url('js/fineuploader/fineuploader.css')); osc_enqueue_style('osclasswizards-fine-uploader-css', osc_current_web_theme_url('css/ajax-uploader.css')); } osc_enqueue_script('jquery-fineuploader'); if( !osc_get_preference('welcome_message', 'osclasswizards_theme') ) { osc_set_preference('welcome_message', _('Hello Guest, Welcome to OsclassWizards'), 'osclasswizards_theme'); } /** FUNCTIONS */ // install options if( !function_exists('osclasswizards_theme_install') ) { function osclasswizards_theme_install() { osc_set_preference('keyword_placeholder', Params::getParam('keyword_placeholder'), 'osclasswizards_theme'); osc_set_preference('version', OSCLASSWIZARDS_THEME_VERSION, 'osclasswizards_theme'); osc_set_preference('footer_link', '1', 'osclasswizards_theme'); osc_set_preference('donation', '0', 'osclasswizards_theme'); osc_set_preference('defaultShowAs@all', 'list', 'osclasswizards_theme'); osc_set_preference('defaultShowAs@search', 'list'); osc_set_preference('welcome_message', 'Hello Guest, Welcome to OsclassWizards', 'osclasswizards_theme'); osc_reset_preferences(); } } // update options if( !function_exists('osclasswizards_theme_update') ) { function osclasswizards_theme_update() { osc_set_preference('version', OSCLASSWIZARDS_THEME_VERSION, 'osclasswizards_theme'); osc_delete_preference('default_logo', 'osclasswizards_theme'); $logo_prefence = osc_get_preference('logo', 'osclasswizards_theme'); $logo_name = 'osclasswizards_logo'; $temp_name = WebThemes::newInstance()->getCurrentThemePath() . 'images/logo.jpg'; if( file_exists( $temp_name ) && !$logo_prefence) { $img = ImageResizer::fromFile($temp_name); $ext = $img->getExt(); $logo_name .= '.'.$ext; $img->saveToFile(osc_uploads_path().$logo_name); @unlink($temp_name); osc_set_preference('logo', $logo_name, 'osclasswizards_theme'); } osc_reset_preferences(); } } if(!function_exists('check_install_osclasswizards_theme')) { function check_install_osclasswizards_theme() { $current_version = osc_get_preference('version', 'osclasswizards_theme'); //check if current version is installed or need an update< if( !$current_version ) { osclasswizards_theme_install(); } else if($current_version < OSCLASSWIZARDS_THEME_VERSION){ osclasswizards_theme_update(); } } } if(!function_exists('osclasswizards_add_body_class_construct')) { function osclasswizards_add_body_class_construct($classes){ $osclasswizardsBodyClass = osclasswizardsBodyClass::newInstance(); $classes = array_merge($classes, $osclasswizardsBodyClass->get()); return $classes; } } if(!function_exists('osclasswizards_body_class')) { function osclasswizards_body_class($echo = true){ /** * Print body classes. * * @param string $echo Optional parameter. * @return print string with all body classes concatenated */ osc_add_filter('osclasswizards_bodyClass','osclasswizards_add_body_class_construct'); $classes = osc_apply_filter('osclasswizards_bodyClass', array()); if($echo && count($classes)){ echo 'class="'.implode(' ',$classes).'"'; } else { return $classes; } } } if(!function_exists('osclasswizards_add_body_class')) { function osclasswizards_add_body_class($class){ /** * Add new body class to body class array. * * @param string $class required parameter. */ $osclasswizardsBodyClass = osclasswizardsBodyClass::newInstance(); $osclasswizardsBodyClass->add($class); } } if(!function_exists('osclasswizards_nofollow_construct')) { /** * Hook for header, meta tags robots nofollos */ function osclasswizards_nofollow_construct() { echo '' . PHP_EOL; echo '' . PHP_EOL; } } if( !function_exists('osclasswizards_follow_construct') ) { /** * Hook for header, meta tags robots follow */ function osclasswizards_follow_construct() { echo '' . PHP_EOL; echo '' . PHP_EOL; } } /* favicon */ if( !function_exists('osclasswizards_favicon') ) { function osclasswizards_favicon() { echo ''; } } /* logo */ if( !function_exists('logo_header') ) { function logo_header() { $logo = osc_get_preference('logo','osclasswizards_theme'); $html = '' . osc_page_title() . ''; if( $logo!='' && file_exists( osc_uploads_path() . $logo ) ) { return $html; } else { return ''.osc_page_title().''; } } } if( !function_exists('homepage_image') ) { function homepage_image() { $logo = osc_get_preference('homeimage','osclasswizards_theme'); $html = '' . osc_page_title() . ''; if( $logo!='' && file_exists( osc_uploads_path() . $logo ) ) { return $html; } else { return false; } } } /* favicon */ if( !function_exists('osclasswizards_favicon_url') ) { function osclasswizards_favicon_url() { $logo = osc_get_preference('favicon','osclasswizards_theme'); if( $logo ) { return osc_uploads_url($logo); } else { return osc_current_web_theme_url('images/favicon.png'); } } } /* logo */ if( !function_exists('osclasswizards_logo_url') ) { function osclasswizards_logo_url() { $logo = osc_get_preference('logo','osclasswizards_theme'); if( $logo ) { return osc_uploads_url($logo); } return false; } } if( !function_exists('osclasswizards_homeimage_url') ) { function osclasswizards_homeimage_url() { $logo = osc_get_preference('homeimage','osclasswizards_theme'); if( $logo ) { return osc_uploads_url($logo); } return false; } } if( !function_exists('osclasswizards_draw_item') ) { function osclasswizards_draw_item($class = false,$admin = false, $premium = false) { $filename = 'loop-single'; if($premium){ $filename .='-premium'; } require WebThemes::newInstance()->getCurrentThemePath().$filename.'.php'; } } if( !function_exists('osclasswizards_show_as') ){ function osclasswizards_show_as(){ $p_sShowAs = Params::getParam('sShowAs'); $aValidShowAsValues = array('list', 'gallery'); if (!in_array($p_sShowAs, $aValidShowAsValues)) { $p_sShowAs = osclasswizards_default_show_as(); } return $p_sShowAs; } } if( !function_exists('osclasswizards_default_show_as') ){ function osclasswizards_default_show_as(){ return getPreference('defaultShowAs@all','osclasswizards_theme'); } } if( !function_exists('osclasswizards_draw_categories_list') ) { function osclasswizards_draw_categories_list(){ ?> '; } ?>

'; } ?> '; $catcount = 0; } } echo ''; ?> '; } ?> osc_search_total_items() ) { $search_to = osc_search_total_items(); } return array( 'from' => $search_from, 'to' => $search_to, 'of' => osc_search_total_items() ); } } /* * Helpers used at view */ if( !function_exists('osclasswizards_item_title') ) { function osclasswizards_item_title() { $title = osc_item_title(); foreach( osc_get_locales() as $locale ) { if( Session::newInstance()->_getForm('title') != "" ) { $title_ = Session::newInstance()->_getForm('title'); if( @$title_[$locale['pk_c_code']] != "" ){ $title = $title_[$locale['pk_c_code']]; } } } return $title; } } if( !function_exists('osclasswizards_item_description') ) { function osclasswizards_item_description() { $description = osc_item_description(); foreach( osc_get_locales() as $locale ) { if( Session::newInstance()->_getForm('description') != "" ) { $description_ = Session::newInstance()->_getForm('description'); if( @$description_[$locale['pk_c_code']] != "" ){ $description = $description_[$locale['pk_c_code']]; } } } return $description; } } if( !function_exists('related_listings') ) { function related_listings() { View::newInstance()->_exportVariableToView('items', array()); $mSearch = new Search(); $mSearch->addCategory(osc_item_category_id()); $mSearch->addRegion(osc_item_region()); $mSearch->addItemConditions(sprintf("%st_item.pk_i_id < %s ", DB_TABLE_PREFIX, osc_item_id())); $mSearch->limit('0', '3'); $aItems = $mSearch->doSearch(); $iTotalItems = count($aItems); if( $iTotalItems == 3 ) { View::newInstance()->_exportVariableToView('items', $aItems); return $iTotalItems; } unset($mSearch); $mSearch = new Search(); $mSearch->addCategory(osc_item_category_id()); $mSearch->addItemConditions(sprintf("%st_item.pk_i_id != %s ", DB_TABLE_PREFIX, osc_item_id())); $mSearch->limit('0', '3'); $aItems = $mSearch->doSearch(); $iTotalItems = count($aItems); if( $iTotalItems > 0 ) { View::newInstance()->_exportVariableToView('items', $aItems); return $iTotalItems; } unset($mSearch); return 0; } } if( !function_exists('osc_is_contact_page') ) { function osc_is_contact_page() { if( Rewrite::newInstance()->get_location() === 'contact' ) { return true; } return false; } } if( !function_exists('get_breadcrumb_lang') ) { function get_breadcrumb_lang() { $lang = array(); $lang['item_add'] = __('Publish a listing', 'osclasswizards'); $lang['item_edit'] = __('Edit your listing', 'osclasswizards'); $lang['item_send_friend'] = __('Send to a friend', 'osclasswizards'); $lang['item_contact'] = __('Contact publisher', 'osclasswizards'); $lang['search'] = __('Search results', 'osclasswizards'); $lang['search_pattern'] = __('Search results: %s', 'osclasswizards'); $lang['user_dashboard'] = __('Dashboard', 'osclasswizards'); $lang['user_dashboard_profile'] = __("%s's profile", 'osclasswizards'); $lang['user_account'] = __('Account', 'osclasswizards'); $lang['user_items'] = __('Listings', 'osclasswizards'); $lang['user_alerts'] = __('Alerts', 'osclasswizards'); $lang['user_profile'] = __('Update account', 'osclasswizards'); $lang['user_change_email'] = __('Change email', 'osclasswizards'); $lang['user_change_username'] = __('Change username', 'osclasswizards'); $lang['user_change_password'] = __('Change password', 'osclasswizards'); $lang['login'] = __('Log in', 'osclasswizards'); $lang['login_recover'] = __('Recover password', 'osclasswizards'); $lang['login_forgot'] = __('Change password', 'osclasswizards'); $lang['register'] = __('Create a new account', 'osclasswizards'); $lang['contact'] = __('Contact', 'osclasswizards'); return $lang; } } if(!function_exists('user_dashboard_redirect')) { function user_dashboard_redirect() { $page = Params::getParam('page'); $action = Params::getParam('action'); if($page=='user' && $action=='dashboard') { if(ob_get_length()>0) { ob_end_flush(); } header("Location: ".osc_user_list_items_url(), TRUE,301); } } osc_add_hook('init', 'user_dashboard_redirect'); } if( !function_exists('get_user_menu') ) { function get_user_menu() { $options = array(); $options[] = array( 'name' => __('Public Profile'), 'url' => osc_user_public_profile_url(), 'class' => 'opt_publicprofile' ); $options[] = array( 'name' => __('Listings', 'osclasswizards'), 'url' => osc_user_list_items_url(), 'class' => 'opt_items' ); $options[] = array( 'name' => __('Alerts', 'osclasswizards'), 'url' => osc_user_alerts_url(), 'class' => 'opt_alerts' ); $options[] = array( 'name' => __('Account', 'osclasswizards'), 'url' => osc_user_profile_url(), 'class' => 'opt_account' ); $options[] = array( 'name' => __('Change email', 'osclasswizards'), 'url' => osc_change_user_email_url(), 'class' => 'opt_change_email' ); $options[] = array( 'name' => __('Change username', 'osclasswizards'), 'url' => osc_change_user_username_url(), 'class' => 'opt_change_username' ); $options[] = array( 'name' => __('Change password', 'osclasswizards'), 'url' => osc_change_user_password_url(), 'class' => 'opt_change_password' ); $options[] = array( 'name' => __('Delete account', 'osclasswizards'), 'url' => '#', 'class' => 'opt_delete_account' ); return $options; } } if( !function_exists('delete_user_js') ) { function delete_user_js() { $location = Rewrite::newInstance()->get_location(); $section = Rewrite::newInstance()->get_section(); if( ($location === 'user' && in_array($section, array('dashboard', 'profile', 'alerts', 'change_email', 'change_username', 'change_password', 'items'))) || (Params::getParam('page') ==='custom' && Params::getParam('in_user_menu')==true ) ) { osc_enqueue_script('delete-user-js'); } } osc_add_hook('header', 'delete_user_js', 1); } if( !function_exists('user_info_js') ) { function user_info_js() { $location = Rewrite::newInstance()->get_location(); $section = Rewrite::newInstance()->get_section(); if( $location === 'user' && in_array($section, array('dashboard', 'profile', 'alerts', 'change_email', 'change_username', 'change_password', 'items')) ) { $user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId') ); View::newInstance()->_exportVariableToView('user', $user); ?> getExt(); $logo_name = 'favicon'; $logo_name .= '.'.$ext; $path = osc_uploads_path() . $logo_name ; $img->saveToFile($path); osc_set_preference('favicon', $logo_name, 'osclasswizards_theme'); osc_add_flash_ok_message(__('The favicon image has been uploaded correctly', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("An error has occurred, please try again", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#favicon')); break; case('upload_logo'): $package = Params::getFiles('logo'); if( $package['error'] == UPLOAD_ERR_OK ) { $img = ImageResizer::fromFile($package['tmp_name']); $ext = $img->getExt(); $logo_name = 'osclasswizards_logo'; $logo_name .= '.'.$ext; $path = osc_uploads_path() . $logo_name ; $img->saveToFile($path); osc_set_preference('logo', $logo_name, 'osclasswizards_theme'); osc_add_flash_ok_message(__('The logo image has been uploaded correctly', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("An error has occurred, please try again", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#logo')); break; case('upload_homeimage'): $package = Params::getFiles('homeimage'); if( $package['error'] == UPLOAD_ERR_OK ) { $img = ImageResizer::fromFile($package['tmp_name']); $ext = $img->getExt(); $logo_name = 'homeimage'; $logo_name .= '.'.$ext; $path = osc_uploads_path() . $logo_name ; $img->saveToFile($path); osc_set_preference('homeimage', $logo_name, 'osclasswizards_theme'); osc_add_flash_ok_message(__('The banner image has been uploaded correctly', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("An error has occurred, please try again", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#banner')); break; case('remove_favicon'): $logo = osc_get_preference('favicon','osclasswizards_theme'); $path = osc_uploads_path() . $logo ; if(file_exists( $path ) ) { @unlink( $path ); osc_delete_preference('favicon','osclasswizards_theme'); osc_reset_preferences(); osc_add_flash_ok_message(__('The favicon image has been removed', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("Image not found", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#favicon')); break; case('remove'): $logo = osc_get_preference('logo','osclasswizards_theme'); $path = osc_uploads_path() . $logo ; if(file_exists( $path ) ) { @unlink( $path ); osc_delete_preference('logo','osclasswizards_theme'); osc_reset_preferences(); osc_add_flash_ok_message(__('The logo image has been removed', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("Image not found", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#logo')); break; case('remove_homeimage'): $logo = osc_get_preference('homeimage','osclasswizards_theme'); $path = osc_uploads_path() . $logo ; if(file_exists( $path ) ) { @unlink( $path ); osc_delete_preference('homeimage','osclasswizards_theme'); osc_reset_preferences(); osc_add_flash_ok_message(__('The banner image has been removed', 'osclasswizards'), 'admin'); } else { osc_add_flash_error_message(__("Image not found", 'osclasswizards'), 'admin'); } osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php#banner')); break; } } function osclasswizards_redirect_user_dashboard() { if( (Rewrite::newInstance()->get_location() === 'user') && (Rewrite::newInstance()->get_section() === 'dashboard') ) { header('Location: ' .osc_user_list_items_url()); exit; } } function osclasswizards_delete() { Preference::newInstance()->delete(array('s_section' => 'osclasswizards')); } osc_add_hook('init', 'osclasswizards_redirect_user_dashboard', 2); osc_add_hook('init_admin', 'theme_osclasswizards_actions_admin'); osc_add_hook('theme_delete_osclasswizards', 'osclasswizards_delete'); osc_admin_menu_appearance(__('Theme settings', 'osclasswizards'), osc_admin_render_theme_url('oc-content/themes/osclasswizards/admin/settings.php'), 'settings_osclasswizards'); /** TRIGGER FUNCTIONS */ check_install_osclasswizards_theme(); if(osc_is_home_page()){ osc_add_hook('inside-main','osclasswizards_draw_categories_list'); } if(osc_is_home_page() || osc_is_search_page()){ osclasswizards_add_body_class('has-searchbox'); } function osclasswizards_sidebar_category_search($catId = null) { $aCategories = array(); if($catId==null) { $aCategories[] = Category::newInstance()->findRootCategoriesEnabled(); } else { // if parent category, only show parent categories $aCategories = Category::newInstance()->toRootTree($catId); end($aCategories); $cat = current($aCategories); // if is parent of some category $childCategories = Category::newInstance()->findSubcategoriesEnabled($cat['pk_i_id']); if(count($childCategories) > 0) { $aCategories[] = $childCategories; } } if(count($aCategories) == 0) { return ""; } osclasswizards_print_sidebar_category_search($aCategories, $catId); } function osclasswizards_print_sidebar_category_search($aCategories, $current_category = null, $i = 0) { $class = ''; if(!isset($aCategories[$i])) { return null; } if($i===0) { $class = 'class="category"'; } $c = $aCategories[$i]; $i++; if(!isset($c['pk_i_id'])) { echo '"; } } else { ?> 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; } } /** HELPERS */ if( !function_exists('osc_uploads_url') ){ function osc_uploads_url($item = ''){ return osc_base_url().'oc-content/uploads/'.$item; } } /* ads SEARCH */ if (!function_exists('search_ads_listing_top_fn')) { function search_ads_listing_top_fn() { if(osc_get_preference('search-results-top-728x90', 'osclasswizards')!='') { echo '
' . PHP_EOL; echo '
' . PHP_EOL; echo osc_get_preference('search-results-top-728x90', 'osclasswizards'); echo '
' . PHP_EOL; } } } //osc_add_hook('search_ads_listing_top', 'search_ads_listing_top_fn'); if (!function_exists('search_ads_listing_medium_fn')) { function search_ads_listing_medium_fn() { if(osc_get_preference('search-results-middle-728x90', 'osclasswizards')!='') { echo '
' . PHP_EOL; echo '
' . PHP_EOL; echo osc_get_preference('search-results-middle-728x90', 'osclasswizards'); echo '
' . PHP_EOL; } } } osc_add_hook('search_ads_listing_medium', 'search_ads_listing_medium_fn'); /** * welcome message * */ function osclasswizards_welcome_message(){ if( osc_get_preference('welcome_message', 'osclasswizards_theme') ) { return osc_get_preference('welcome_message', 'osclasswizards_theme'); }else{ return false; } } /** * select regions * */ function osclasswizards_regions_select($name, $id, $label) { $aRegions = Region::newInstance()->listAll(); if(count($aRegions) > 0 ) { $html = ''; } echo $html; } /** * function to add head title and meta tags * */ function osclasswizards_meta(){ ?> <?php echo meta_title() ; ?>