';
+ } else {
+ echo '
';
}
- echo '
';
- ?>
- '; } ?>
-
+
+ -
+
+ 0 ) { ?>
+
+
+ 0) { ?>
+ ()
+
+ ()
+
+
+ 0 ) { ?>
+
+
+ -
+ 0 ) { ?>
+ ()
+
+ ()
+
+
+
+
+
+
+
+ ';
+ ?>
+ '; } ?>
+ osc_search_total_items() ) {
- $search_to = osc_search_total_items();
- }
+}
+
+if( !function_exists('bender_search_number') ) {
+ function bender_search_number() {
+ $search_from = ((osc_search_page() * osc_default_results_per_page_at_search()) + 1);
+ $search_to = ((osc_search_page() + 1) * osc_default_results_per_page_at_search());
+ if( $search_to > osc_search_total_items() ) {
+ $search_to = osc_search_total_items();
+ }
+
+ return array(
+ 'from' => $search_from,
+ 'to' => $search_to,
+ 'of' => osc_search_total_items()
+ );
+ }
+}
- return array(
- 'from' => $search_from,
- 'to' => $search_to,
- 'of' => osc_search_total_items()
- );
- }
- }
- /*
- * Helpers used at view
- */
- if( !function_exists('bender_item_title') ) {
- function bender_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']];
- }
+//Helpers used at view
+
+if( !function_exists('bender_item_title') ) {
+ function bender_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('bender_item_description') ) {
- function bender_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 $title;
+ }
+}
+
+if( !function_exists('bender_item_description') ) {
+ function bender_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;
}
+ 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');
+if( !function_exists('related_listings') ) {
+ function related_listings() {
+ View::newInstance()->_exportVariableToView('items', array());
- $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);
+ $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');
- return 0;
+ $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;
- }
+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', 'bender');
- $lang['item_edit'] = __('Edit your listing', 'bender');
- $lang['item_send_friend'] = __('Send to a friend', 'bender');
- $lang['item_contact'] = __('Contact publisher', 'bender');
- $lang['search'] = __('Search results', 'bender');
- $lang['search_pattern'] = __('Search results: %s', 'bender');
- $lang['user_dashboard'] = __('Dashboard', 'bender');
- $lang['user_dashboard_profile'] = __("%s's profile", 'bender');
- $lang['user_account'] = __('Account', 'bender');
- $lang['user_items'] = __('Listings', 'bender');
- $lang['user_alerts'] = __('Alerts', 'bender');
- $lang['user_profile'] = __('Update account', 'bender');
- $lang['user_change_email'] = __('Change email', 'bender');
- $lang['user_change_username'] = __('Change username', 'bender');
- $lang['user_change_password'] = __('Change password', 'bender');
- $lang['login'] = __('Login', 'bender');
- $lang['login_recover'] = __('Recover password', 'bender');
- $lang['login_forgot'] = __('Change password', 'bender');
- $lang['register'] = __('Create a new account', 'bender');
- $lang['contact'] = __('Contact', 'bender');
- 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);
+ return false;
+ }
+}
+
+if( !function_exists('get_breadcrumb_lang') ) {
+ function get_breadcrumb_lang() {
+ $lang = array();
+ $lang['item_add'] = __('Publish a listing', 'bender');
+ $lang['item_edit'] = __('Edit your listing', 'bender');
+ $lang['item_send_friend'] = __('Send to a friend', 'bender');
+ $lang['item_contact'] = __('Contact publisher', 'bender');
+ $lang['search'] = __('Search results', 'bender');
+ $lang['search_pattern'] = __('Search results: %s', 'bender');
+ $lang['user_dashboard'] = __('Dashboard', 'bender');
+ $lang['user_dashboard_profile'] = __("%s's profile", 'bender');
+ $lang['user_account'] = __('Account', 'bender');
+ $lang['user_items'] = __('Listings', 'bender');
+ $lang['user_alerts'] = __('Alerts', 'bender');
+ $lang['user_profile'] = __('Update account', 'bender');
+ $lang['user_change_email'] = __('Change email', 'bender');
+ $lang['user_change_username'] = __('Change username', 'bender');
+ $lang['user_change_password'] = __('Change password', 'bender');
+ $lang['login'] = __('Login', 'bender');
+ $lang['login_recover'] = __('Recover password', 'bender');
+ $lang['login_forgot'] = __('Change password', 'bender');
+ $lang['register'] = __('Create a new account', 'bender');
+ $lang['contact'] = __('Contact', 'bender');
+ 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', 'bender'),
- 'url' => osc_user_list_items_url(),
- 'class' => 'opt_items'
- );
- $options[] = array(
- 'name' => __('Alerts', 'bender'),
- 'url' => osc_user_alerts_url(),
- 'class' => 'opt_alerts'
- );
- $options[] = array(
- 'name' => __('Account', 'bender'),
- 'url' => osc_user_profile_url(),
- 'class' => 'opt_account'
- );
- $options[] = array(
- 'name' => __('Change email', 'bender'),
- 'url' => osc_change_user_email_url(),
- 'class' => 'opt_change_email'
- );
- $options[] = array(
- 'name' => __('Change username', 'bender'),
- 'url' => osc_change_user_username_url(),
- 'class' => 'opt_change_username'
- );
- $options[] = array(
- 'name' => __('Change password', 'bender'),
- 'url' => osc_change_user_password_url(),
- 'class' => 'opt_change_password'
- );
- $options[] = array(
- 'name' => __('Delete account', 'bender'),
- '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('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', 'bender'),
+ 'url' => osc_user_list_items_url(),
+ 'class' => 'opt_items'
+ );
+ $options[] = array(
+ 'name' => __('Alerts', 'bender'),
+ 'url' => osc_user_alerts_url(),
+ 'class' => 'opt_alerts'
+ );
+ $options[] = array(
+ 'name' => __('Account', 'bender'),
+ 'url' => osc_user_profile_url(),
+ 'class' => 'opt_account'
+ );
+ $options[] = array(
+ 'name' => __('Change email', 'bender'),
+ 'url' => osc_change_user_email_url(),
+ 'class' => 'opt_change_email'
+ );
+ $options[] = array(
+ 'name' => __('Change username', 'bender'),
+ 'url' => osc_change_user_username_url(),
+ 'class' => 'opt_change_username'
+ );
+ $options[] = array(
+ 'name' => __('Change password', 'bender'),
+ 'url' => osc_change_user_password_url(),
+ 'class' => 'opt_change_password'
+ );
+ $options[] = array(
+ 'name' => __('Delete account', 'bender'),
+ '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);
}
+ 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( !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);
- ?>
+ 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);
+ ?>
- get_location() === 'user') && (Rewrite::newInstance()->get_section() === 'dashboard') ) {
header('Location: ' .osc_user_list_items_url());
exit;
}
}
+}
+
+if (!function_exists('bender_delete') ) {
function bender_delete() {
Preference::newInstance()->delete(array('s_section' => 'bender'));
}
+}
- osc_add_hook('init', 'bender_redirect_user_dashboard', 2);
- osc_add_hook('init_admin', 'theme_bender_actions_admin');
- osc_add_hook('theme_delete_bender', 'bender_delete');
- osc_admin_menu_appearance(__('Header logo', 'bender'), osc_admin_render_theme_url('oc-content/themes/bender/admin/header.php'), 'header_bender');
- osc_admin_menu_appearance(__('Theme settings', 'bender'), osc_admin_render_theme_url('oc-content/themes/bender/admin/settings.php'), 'settings_bender');
/**
+HOOKS
+*/
-TRIGGER FUNCTIONS
+osc_add_hook('init', 'bender_redirect_user_dashboard', 2);
+osc_add_hook('init_admin', 'theme_bender_actions_admin');
+osc_add_hook('theme_delete_bender', 'bender_delete');
+osc_admin_menu_appearance(__('Header logo', 'bender'), osc_admin_render_theme_url('oc-content/themes/bender/admin/header.php'), 'header_bender');
+osc_admin_menu_appearance(__('Theme settings', 'bender'), osc_admin_render_theme_url('oc-content/themes/bender/admin/settings.php'), 'settings_bender');
+/**
+TRIGGER FUNCTIONS
*/
+
check_install_bender_theme();
-if(osc_is_home_page()){
+
+if(osc_is_home_page()) {
osc_add_hook('inside-main','bender_draw_categories_list');
-} else if( osc_is_static_page() || osc_is_contact_page() ){
+} else if( osc_is_static_page() || osc_is_contact_page() ) {
osc_add_hook('before-content','bender_draw_categories_list');
}
-if(osc_is_home_page() || osc_is_search_page()){
+if(osc_is_home_page() || osc_is_search_page()) {
bender_add_body_class('has-searchbox');
}
+if (!function_exists('bender_sidebar_category_search') ) {
+ function bender_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;
+ }
+ }
-function bender_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 "";
}
- }
- if(count($aCategories) == 0) {
- return "";
+ bender_print_sidebar_category_search($aCategories, $catId);
}
-
- bender_print_sidebar_category_search($aCategories, $catId);
}
-function bender_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 '
';
- if($i==1) {
- echo '- '.__('All categories', 'bender')."
";
+if (!function_exists('bender_print_sidebar_category_search') ) {
+ function bender_print_sidebar_category_search($aCategories, $current_category = null, $i = 0) {
+ $class = '';
+ if(!isset($aCategories[$i])) {
+ return null;
}
- foreach($c as $key => $value) {
- ?>
- -
-
- '.$value['s_name'].''; }
- else{ echo $value['s_name']; } ?>
-
-
- ";
+
+ $c = $aCategories[$i];
+ $i++;
+
+ if(!isset($c['pk_i_id'])) {
+ echo '";
+ }
} else {
- echo "
";
+ ?>
+
+
-
-class = array();
- }
+ /**
+ * Custom Class for add, remove or get body classes.
+ *
+ * @param string $instance used for singleton.
+ * @param array $class.
+ */
+ private static $instance;
+ private $class;
- public static function newInstance()
- {
- if ( !self::$instance instanceof self)
+ private function __construct()
{
- self::$instance = new self;
+ $this->class = array();
}
- return self::$instance;
- }
- public function add($class)
- {
- $this->class[] = $class;
- }
- public function get()
- {
- return $this->class;
+ 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 = '') {
$logo = osc_get_preference('logo', 'bender');
@@ -720,10 +752,9 @@ function osc_uploads_url($item = '') {
}
/*
+ADS SEARCH
+*/
- ads SEARCH
-
- */
if (!function_exists('search_ads_listing_top_fn')) {
function search_ads_listing_top_fn() {
if(osc_get_preference('search-results-top-728x90', 'bender')!='') {
@@ -733,8 +764,8 @@ function search_ads_listing_top_fn() {
echo '
' . PHP_EOL;
}
}
+ //osc_add_hook('search_ads_listing_top', 'search_ads_listing_top_fn');
}
-//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() {
@@ -745,7 +776,7 @@ function search_ads_listing_medium_fn() {
echo '