private function processData($pages) { if (!empty($pages)) { $prefLocale = osc_current_user_locale(); foreach ($pages as $aRow) { $row = array(); $content = array(); if (isset($aRow['locale'][$prefLocale]) && !empty($aRow['locale'][$prefLocale]['s_title'])) { $content = $aRow['locale'][$prefLocale]; } else { $content = current($aRow['locale']); } // -- options -- $options = array(); View::newInstance()->_exportVariableToView('page', $aRow); $options[] = '<a href="' . osc_static_page_url() . '" target="_blank">' . __('View page') . '</a>'; $options[] = '<a href="' . osc_admin_base_url(true) . '?page=pages&action=edit&id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>'; if (!$aRow['b_indelible']) { $options[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=pages&action=delete&id=' . $aRow['pk_i_id'] . '&' . osc_csrf_token_url() . '">' . __('Delete') . '</a>'; } $auxOptions = '<ul>' . PHP_EOL; foreach ($options as $actual) { $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL; } $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL; $row['bulkactions'] = '<input type="checkbox" name="id[]"" value="' . $aRow['pk_i_id'] . '"" />'; $row['internal_name'] = $aRow['s_internal_name'] . $actions; $row['title'] = $content['s_title']; $row['order'] = '<div class="order-box">' . $aRow['i_order'] . ' <img class="up" onclick="order_up(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_up.png') . '" alt="' . __('Up') . '" title="' . __('Up') . '" /> <img class="down" onclick="order_down(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_down.png') . '" alt="' . __('Down') . '" title="' . __('Down') . '" /></div>'; $row = osc_apply_filter('pages_processing_row', $row, $aRow); $this->addRow($row); $this->rawRows[] = $aRow; } } }
function pop_title_404($title) { $header_text = __("Sorry but I can't find the page you're looking for", 'pop'); if (View::newInstance()->_get('pop_404_header_text') != '') { $header_text = View::newInstance()->_get('pop_404_header_text'); } return $header_text; }
function osc_has_static_pages_seo() { if (!View::newInstance()->_exists('pages')) { View::newInstance()->_exportVariableToView('pages', Page::newInstance()->listAll(false, 0)); } $page = View::newInstance()->_next('pages'); View::newInstance()->_exportVariableToView('page_meta', json_decode($page['s_meta'], true)); return $page; }
/** * Gets the pagination links of search pagination * * @return string pagination links */ function osc_search_pagination() { $params = array(); if (View::newInstance()->_exists('search_uri')) { $params['url'] = osc_base_url() . View::newInstance()->_get('search_uri') . '/{PAGE}'; } $pagination = new Pagination($params); return $pagination->doPagination(); }
public function init() { $data = array_map(function ($v) { return array("s_internal_name" => $v["s_internal_name"], "locales" => array_map(function ($k, $v) { return array("fk_c_locale_code" => $k, "s_title" => $v["s_title"], "s_excerpt" => "", "s_text" => $v["s_text"]); }, array_keys($v["locale"]), array_values($v["locale"]))); }, $this->model->listAll(true)); View::newInstance()->_exportVariableToView("datas", json_encode(array("emails" => $data, "footer" => array("locales" => array_map(function ($v) { return array("fk_c_locale_code" => $v["pk_c_code"], "s_text" => ""); }, OSCLocale::newInstance()->listAll()))), JSON_PRETTY_PRINT)); }
function popular_ads($interval) { $num_ads = popular_ads_num_ads(); // SETS HOW MANY POPULAR ADS TO DISPLAY $conn = getConnection(); $item_array = $conn->osc_dbFetchResults("SELECT i.*, l.*, d.*, SUM(s.i_num_views) AS total_views FROM %st_item_stats s\n\tJOIN %st_item i ON s.fk_i_item_id = i.pk_i_id\n\tJOIN %st_item_location l ON s.fk_i_item_id = l.fk_i_item_id\n\tJOIN %st_item_description d ON s.fk_i_item_id = d.fk_i_item_id\n\tWHERE i.dt_pub_date > CURDATE()-INTERVAL %d DAY\n\tAND i.b_enabled = 1 AND i.b_active = 1 AND i.b_spam = 0 AND (i.b_premium = 1 || i.dt_expiration >= CURDATE())\n\tGROUP BY s.fk_i_item_id\n\tORDER BY total_views DESC\n\tLIMIT 0, %d", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, $interval, $num_ads); if (count($item_array) > 0) { View::newInstance()->_exportVariableToView('customItems', $item_array); } else { echo __('No listings', 'flatter'); } }
private function processData($comments) { if (!empty($comments)) { $csrf_token_url = osc_csrf_token_url(); foreach ($comments as $aRow) { $row = array(); $options = array(); $options_more = array(); View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($aRow['fk_i_item_id'])); if ($aRow['b_enabled']) { $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&action=status&id=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '&value=DISABLE">' . __('Block') . '</a>'; } else { $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&action=status&id=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '&value=ENABLE">' . __('Unblock') . '</a>'; } $options_more[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=comments&action=delete&id=' . $aRow['pk_i_id'] . '" id="dt_link_delete">' . __('Delete') . '</a>'; $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&action=comment_edit&id=' . $aRow['pk_i_id'] . '" id="dt_link_edit">' . __('Edit') . '</a>'; if ($aRow['b_active']) { $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&action=status&id=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '&value=INACTIVE">' . __('Deactivate') . '</a>'; } else { $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&action=status&id=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '&value=ACTIVE">' . __('Activate') . '</a>'; } // more actions $moreOptions = '<li class="show-more">' . PHP_EOL . '<a href="#" class="show-more-trigger">' . __('Show more') . '...</a>' . PHP_EOL . '<ul>' . PHP_EOL; foreach ($options_more as $actual) { $moreOptions .= '<li>' . $actual . "</li>" . PHP_EOL; } $moreOptions .= '</ul>' . PHP_EOL . '</li>' . PHP_EOL; // create list of actions $auxOptions = '<ul>' . PHP_EOL; foreach ($options as $actual) { $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL; } $auxOptions .= $moreOptions; $auxOptions .= '</ul>' . PHP_EOL; $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL; $status = $this->get_row_status($aRow); $row['status-border'] = ''; $row['status'] = $status['text']; $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" />'; if (empty($aRow['s_author_name'])) { $user = User::newInstance()->findByPrimaryKey($aRow['fk_i_user_id']); $aRow['s_author_name'] = $user['s_email']; } $row['author'] = $aRow['s_author_name'] . ' (<a target="_blank" href="' . osc_item_url() . '">' . osc_item_title() . '</a>)' . $actions; $row['comment'] = $aRow['s_body']; $row['date'] = osc_format_date($aRow['dt_pub_date']); $row = osc_apply_filter('comments_processing_row', $row, $aRow); $this->addRow($row); $this->rawRows[] = $aRow; } } }
/** * Gets the pagination links of search pagination * * @return string pagination links */ function osc_search_pagination() { $params = array(); if (View::newInstance()->_exists('search_uri')) { // CANONICAL URL $params['url'] = osc_base_url() . View::newInstance()->_get('search_uri') . '/{PAGE}'; $params['first_url'] = osc_base_url() . View::newInstance()->_get('search_uri'); } else { $params['first_url'] = osc_update_search_url(array('iPage' => null)); } $pagination = new Pagination($params); return $pagination->doPagination(); }
function doModel() { switch ($this->action) { case 'spamNbots': // calling the spam and bots view $akismet_key = osc_akismet_key(); $akismet_status = 3; if ($akismet_key != '') { require_once osc_lib_path() . 'Akismet.class.php'; $akismet_obj = new Akismet(osc_base_url(), $akismet_key); $akismet_status = 2; if ($akismet_obj->isKeyValid()) { $akismet_status = 1; } } View::newInstance()->_exportVariableToView('akismet_status', $akismet_status); $this->doView('settings/spamNbots.php'); break; case 'akismet_post': // updating spam and bots option osc_csrf_check(); $updated = 0; $akismetKey = Params::getParam('akismetKey'); $akismetKey = trim($akismetKey); $updated = osc_set_preference('akismetKey', $akismetKey); if ($akismetKey == '') { osc_add_flash_info_message(_m('Your Akismet key has been cleared'), 'admin'); } else { osc_add_flash_ok_message(_m('Your Akismet key has been updated'), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots'); break; case 'recaptcha_post': // updating spam and bots option osc_csrf_check(); $iUpdated = 0; $recaptchaPrivKey = Params::getParam('recaptchaPrivKey'); $recaptchaPrivKey = trim($recaptchaPrivKey); $recaptchaPubKey = Params::getParam('recaptchaPubKey'); $recaptchaPubKey = trim($recaptchaPubKey); $iUpdated += osc_set_preference('recaptchaPrivKey', $recaptchaPrivKey); $iUpdated += osc_set_preference('recaptchaPubKey', $recaptchaPubKey); if ($recaptchaPubKey == '') { osc_add_flash_info_message(_m('Your reCAPTCHA key has been cleared'), 'admin'); } else { osc_add_flash_ok_message(_m('Your reCAPTCHA key has been updated'), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots'); break; } }
function payment_pro_recurring_buttons($subscription, $extra = null) { $services = View::newInstance()->_get('_payment_pro_services'); if (is_array($services)) { foreach ($services as $service => $file) { $payment = Payment::newInstance($service); if ($payment) { $payment->recurringButton($subscription, $extra); } } } else { _e('No method of payment is available', 'payment_pro'); } }
public static function category_select($categories = null, $item = null, $default_item = null, $parent_selectable = false) { // Did user select a specific category to post in? $catId = Params::getParam('catId'); if (Session::newInstance()->_getForm('catId') != "") { $catId = Session::newInstance()->_getForm('catId'); } if ($categories == null) { if (View::newInstance()->_exists('categories')) { $categories = View::newInstance()->_get('categories'); } else { $categories = osc_get_categories(); } } if ($item == null) { $item = osc_item(); } echo '<select name="catId" id="catId">'; if (isset($default_item)) { echo '<option value="">' . $default_item . '</option>'; } else { echo '<option value="">' . __('Select a category') . '</option>'; } if (count($categories) == 1) { $parent_selectable = 1; } foreach ($categories as $c) { if (!osc_selectable_parent_categories() && !$parent_selectable) { echo '<optgroup label="' . $c['s_name'] . '">'; if (isset($c['categories']) && is_array($c['categories'])) { ItemForm::subcategory_select($c['categories'], $item, $default_item, 1); } } else { $selected = isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id'] || isset($catId) && $catId == $c['pk_i_id']; echo '<option value="' . $c['pk_i_id'] . '"' . ($selected ? 'selected="selected"' : '') . '>' . $c['s_name'] . '</option>'; if (isset($c['categories']) && is_array($c['categories'])) { ItemForm::subcategory_select($c['categories'], $item, $default_item, 1); } } } echo '</select>'; return true; }
private function toArrayFormat() { $this->result['iTotalRecords'] = $this->total; $this->result['iTotalDisplayRecords'] = $this->total_filtered; $this->result['iDisplayLength'] = $this->_get['iDisplayLength']; $this->result['aaData'] = array(); if (count($this->pages) == 0) { return; } $prefLocale = osc_current_user_locale(); $count = 0; foreach ($this->pages as $aRow) { $row = array(); $content = array(); if (isset($aRow['locale'][$prefLocale]) && !empty($aRow['locale'][$prefLocale]['s_title'])) { $content = $aRow['locale'][$prefLocale]; } else { $content = current($aRow['locale']); } // -- options -- $options = array(); View::newInstance()->_exportVariableToView('page', $aRow); $options[] = '<a href="' . osc_static_page_url() . '" target="_blank">' . __('View page') . '</a>'; $options[] = '<a href="' . osc_admin_base_url(true) . '?page=pages&action=edit&id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>'; if (!$aRow['b_indelible']) { $options[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=pages&action=delete&id=' . $aRow['pk_i_id'] . '">' . __('Delete') . '</a>'; } $auxOptions = '<ul>' . PHP_EOL; foreach ($options as $actual) { $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL; } $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL; $row[] = '<input type="checkbox" name="id[]"" value="' . $aRow['pk_i_id'] . '"" />'; $row[] = $aRow['s_internal_name'] . $actions; $row[] = $content['s_title']; $row[] = '<div class="order-box">' . $aRow['i_order'] . ' <img class="up" onclick="order_up(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_up.png') . '" alt="' . __('Up') . '" title="' . __('Up') . '" /> <img class="down" onclick="order_down(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_down.png') . '" alt="' . __('Down') . '" title="' . __('Down') . '" /></div>'; $this->result['aaData'][] = $row; } }
<img title="<?php echo $tooltip; ?> " src="<?php voting_star(4, $avg_vote); ?> "> <img title="<?php echo $tooltip; ?> " src="<?php voting_star(5, $avg_vote); ?> "> <span style="position:relative; top:-5px;padding-right: 4px; padding-left: 4px; margin-bottom: 3px;"><?php echo $total; ?> <?php _e('votes', 'voting'); ?> </span> </p> </div> </li> <?php $count++; View::newInstance()->_erase('user'); } ?> </ul> </div>
<h1> <a href="<?php echo View::newInstance()->_get('login_admin_url'); ?> " title="<?php echo View::newInstance()->_get('login_admin_title'); ?> "> <img src="<?php echo View::newInstance()->_get('login_admin_image'); ?> " border="0" title="<?php echo View::newInstance()->_get('login_admin_title'); ?> " alt="<?php echo View::newInstance()->_get('login_admin_title'); ?> " /> </a> </h1> <?php osc_show_flash_message('admin'); ?> <form name="loginform" id="loginform" action="<?php echo osc_admin_base_url(true); ?> " method="post"> <input type="hidden" name="page" value="login" /> <input type="hidden" name="action" value="login_post" /> <p> <label for="user_login">
/** * Gets current locale object * * @return array */ function osc_get_current_user_locale() { $locale = OSCLocale::newInstance()->findByPrimaryKey(osc_current_user_locale()); View::newInstance()->_exportVariableToView('locale', $locale); return $locale; }
/** * Gets next user in users array * * @return <type> */ function osc_prepare_user_info() { if (!View::newInstance()->_exists('users')) { View::newInstance()->_exportVariableToView('users', array(User::newInstance()->findByPrimaryKey(osc_item_user_id()))); } return View::newInstance()->_next('users'); }
function doModel() { //calling the view... $locales = OSCLocale::newInstance()->listAllEnabled(); $this->_exportVariableToView('locales', $locales); switch ($this->action) { case 'item_add': // post if (osc_reg_user_post() && $this->user == null) { osc_add_flash_warning_message(_m('Only registered users are allowed to post listings')); $this->redirectTo(osc_user_login_url()); } $countries = Country::newInstance()->listAll(); $regions = array(); if (isset($this->user['fk_c_country_code']) && $this->user['fk_c_country_code'] != '') { $regions = Region::newInstance()->findByCountry($this->user['fk_c_country_code']); } else { if (count($countries) > 0) { $regions = Region::newInstance()->findByCountry($countries[0]['pk_c_code']); } } $cities = array(); if (isset($this->user['fk_i_region_id']) && $this->user['fk_i_region_id'] != '') { $cities = City::newInstance()->findByRegion($this->user['fk_i_region_id']); } else { if (count($regions) > 0) { $cities = City::newInstance()->findByRegion($regions[0]['pk_i_id']); } } $this->_exportVariableToView('countries', $countries); $this->_exportVariableToView('regions', $regions); $this->_exportVariableToView('cities', $cities); $form = count(Session::newInstance()->_getForm()); $keepForm = count(Session::newInstance()->_getKeepForm()); if ($form == 0 || $form == $keepForm) { Session::newInstance()->_dropKeepForm(); } if (Session::newInstance()->_getForm('countryId') != "") { $countryId = Session::newInstance()->_getForm('countryId'); $regions = Region::newInstance()->findByCountry($countryId); $this->_exportVariableToView('regions', $regions); if (Session::newInstance()->_getForm('regionId') != "") { $regionId = Session::newInstance()->_getForm('regionId'); $cities = City::newInstance()->findByRegion($regionId); $this->_exportVariableToView('cities', $cities); } } $this->_exportVariableToView('user', $this->user); osc_run_hook('post_item'); $this->doView('item-post.php'); break; case 'item_add_post': //post_item if (osc_reg_user_post() && $this->user == null) { osc_add_flash_warning_message(_m('Only registered users are allowed to post listings')); $this->redirectTo(osc_base_url(true)); } $mItems = new ItemActions(false); // prepare data for ADD ITEM $mItems->prepareData(true); // set all parameters into session foreach ($mItems->data as $key => $value) { Session::newInstance()->_setForm($key, $value); } $meta = Params::getParam('meta'); if (is_array($meta)) { foreach ($meta as $key => $value) { Session::newInstance()->_setForm('meta_' . $key, $value); Session::newInstance()->_keepForm('meta_' . $key); } } if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) { if (!osc_check_recaptcha()) { osc_add_flash_error_message(_m('The Recaptcha code is wrong')); $this->redirectTo(osc_item_post_url()); return false; // BREAK THE PROCESS, THE RECAPTCHA IS WRONG } } if (!osc_is_web_user_logged_in()) { $user = User::newInstance()->findByEmail($mItems->data['contactEmail']); // The user exists but it's not logged if (isset($user['pk_i_id'])) { foreach ($mItems->data as $key => $value) { Session::newInstance()->_keepForm($key); } osc_add_flash_error_message(_m('A user with that email address already exists, if it is you, please log in')); $this->redirectTo(osc_user_login_url()); } } // POST ITEM ( ADD ITEM ) $success = $mItems->add(); if ($success != 1 && $success != 2) { osc_add_flash_error_message($success); $this->redirectTo(osc_item_post_url()); } else { Session::newInstance()->_dropkeepForm('meta_' . $key); if ($success == 1) { osc_add_flash_ok_message(_m('Check your inbox to validate your listing')); } else { osc_add_flash_ok_message(_m('Your listing has been published')); } $itemId = Params::getParam('itemId'); $item = $this->itemManager->findByPrimaryKey($itemId); osc_run_hook('posted_item', $item); $category = Category::newInstance()->findByPrimaryKey(Params::getParam('catId')); View::newInstance()->_exportVariableToView('category', $category); $this->redirectTo(osc_search_category_url()); } break; case 'item_edit': // edit item $secret = Params::getParam('secret'); $id = Params::getParam('id'); $item = $this->itemManager->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s' AND i.fk_i_user_id IS NULL) OR (i.fk_i_user_id = '%d'))", addslashes($id), addslashes($secret), addslashes($this->userId)); if (count($item) == 1) { $item = Item::newInstance()->findByPrimaryKey($id); $form = count(Session::newInstance()->_getForm()); $keepForm = count(Session::newInstance()->_getKeepForm()); if ($form == 0 || $form == $keepForm) { Session::newInstance()->_dropKeepForm(); } $this->_exportVariableToView('item', $item); osc_run_hook("before_item_edit", $item); $this->doView('item-edit.php'); } else { // add a flash message [ITEM NO EXISTE] osc_add_flash_error_message(_m("Sorry, we don't have any listings with that ID")); if ($this->user != null) { $this->redirectTo(osc_user_list_items_url()); } else { $this->redirectTo(osc_base_url()); } } break; case 'item_edit_post': // recoger el secret y el $secret = Params::getParam('secret'); $id = Params::getParam('id'); $item = $this->itemManager->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s' AND i.fk_i_user_id IS NULL) OR (i.fk_i_user_id = '%d'))", addslashes($id), addslashes($secret), addslashes($this->userId)); if (count($item) == 1) { $this->_exportVariableToView('item', $item[0]); $mItems = new ItemActions(false); // prepare data for ADD ITEM $mItems->prepareData(false); // set all parameters into session foreach ($mItems->data as $key => $value) { Session::newInstance()->_setForm($key, $value); } $meta = Params::getParam('meta'); if (is_array($meta)) { foreach ($meta as $key => $value) { Session::newInstance()->_setForm('meta_' . $key, $value); Session::newInstance()->_keepForm('meta_' . $key); } } if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) { if (!osc_check_recaptcha()) { osc_add_flash_error_message(_m('The Recaptcha code is wrong')); $this->redirectTo(osc_item_edit_url()); return false; // BREAK THE PROCESS, THE RECAPTCHA IS WRONG } } $success = $mItems->edit(); osc_run_hook('edited_item', Item::newInstance()->findByPrimaryKey($id)); if ($success == 1) { osc_add_flash_ok_message(_m("Great! We've just updated your listing")); View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($id)); $this->redirectTo(osc_item_url()); } else { osc_add_flash_error_message($success); $this->redirectTo(osc_item_edit_url($secret)); } } break; case 'activate': $secret = Params::getParam('secret'); $id = Params::getParam('id'); $item = $this->itemManager->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s') OR (i.fk_i_user_id = '%d'))", addslashes($id), addslashes($secret), addslashes($this->userId)); // item doesn't exist if (count($item) == 0) { $this->do404(); return; } View::newInstance()->_exportVariableToView('item', $item[0]); if ($item[0]['b_active'] == 0) { // ACTIVETE ITEM $mItems = new ItemActions(false); $success = $mItems->activate($item[0]['pk_i_id'], $item[0]['s_secret']); if ($success) { osc_add_flash_ok_message(_m('The listing has been validated')); } else { osc_add_flash_error_message(_m("The listing can't be validated")); } } else { osc_add_flash_warning_message(_m('The listing has already been validated')); } $this->redirectTo(osc_item_url()); break; case 'item_delete': $secret = Params::getParam('secret'); $id = Params::getParam('id'); $item = $this->itemManager->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s') OR (i.fk_i_user_id = '%d'))", addslashes($id), addslashes($secret), addslashes($this->userId)); if (count($item) == 1) { $mItems = new ItemActions(false); $success = $mItems->delete($item[0]['s_secret'], $item[0]['pk_i_id']); if ($success) { osc_add_flash_ok_message(_m('Your listing has been deleted')); } else { osc_add_flash_error_message(_m("The listing you are trying to delete couldn't be deleted")); } if ($this->user != null) { $this->redirectTo(osc_user_list_items_url()); } else { $this->redirectTo(osc_base_url()); } } else { osc_add_flash_error_message(_m("The listing you are trying to delete couldn't be deleted")); $this->redirectTo(osc_base_url()); } break; case 'mark': $id = Params::getParam('id'); $as = Params::getParam('as'); $item = Item::newInstance()->findByPrimaryKey($id); View::newInstance()->_exportVariableToView('item', $item); require_once osc_lib_path() . 'osclass/user-agents.php'; foreach ($user_agents as $ua) { if (preg_match('|' . $ua . '|', @$_SERVER['HTTP_USER_AGENT'])) { // mark item if it's not a bot $mItem = new ItemActions(false); $mItem->mark($id, $as); break; } } osc_add_flash_ok_message(_m("Thanks! That's very helpful")); $this->redirectTo(osc_item_url()); break; case 'send_friend': $item = $this->itemManager->findByPrimaryKey(Params::getParam('id')); $this->_exportVariableToView('item', $item); $this->doView('item-send-friend.php'); break; case 'send_friend_post': $item = $this->itemManager->findByPrimaryKey(Params::getParam('id')); $this->_exportVariableToView('item', $item); Session::newInstance()->_setForm("yourEmail", Params::getParam('yourEmail')); Session::newInstance()->_setForm("yourName", Params::getParam('yourName')); Session::newInstance()->_setForm("friendName", Params::getParam('friendName')); Session::newInstance()->_setForm("friendEmail", Params::getParam('friendEmail')); Session::newInstance()->_setForm("message_body", Params::getParam('message')); if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) { if (!osc_check_recaptcha()) { osc_add_flash_error_message(_m('The Recaptcha code is wrong')); $this->redirectTo(osc_item_send_friend_url()); return false; // BREAK THE PROCESS, THE RECAPTCHA IS WRONG } } $mItem = new ItemActions(false); $success = $mItem->send_friend(); if ($success) { Session::newInstance()->_clearVariables(); $this->redirectTo(osc_item_url()); } else { $this->redirectTo(osc_item_send_friend_url()); } break; case 'contact': $item = $this->itemManager->findByPrimaryKey(Params::getParam('id')); if (empty($item)) { osc_add_flash_error_message(_m("This listing doesn't exist")); $this->redirectTo(osc_base_url(true)); } else { $this->_exportVariableToView('item', $item); if (osc_item_is_expired()) { osc_add_flash_error_message(_m("We're sorry, but the listing has expired. You can't contact the seller")); $this->redirectTo(osc_item_url()); } if (osc_reg_user_can_contact() && osc_is_web_user_logged_in() || !osc_reg_user_can_contact()) { $this->doView('item-contact.php'); } else { osc_add_flash_error_message(_m("You can't contact the seller, only registered users can")); $this->redirectTo(osc_item_url()); } } break; case 'contact_post': $item = $this->itemManager->findByPrimaryKey(Params::getParam('id')); $this->_exportVariableToView('item', $item); if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) { if (!osc_check_recaptcha()) { osc_add_flash_error_message(_m('The Recaptcha code is wrong')); Session::newInstance()->_setForm("yourEmail", Params::getParam('yourEmail')); Session::newInstance()->_setForm("yourName", Params::getParam('yourName')); Session::newInstance()->_setForm("phoneNumber", Params::getParam('phoneNumber')); Session::newInstance()->_setForm("message_body", Params::getParam('message')); $this->redirectTo(osc_item_url()); return false; // BREAK THE PROCESS, THE RECAPTCHA IS WRONG } } if (osc_isExpired($item['dt_expiration'])) { osc_add_flash_error_message(_m("We're sorry, but the listing has expired. You can't contact the seller")); $this->redirectTo(osc_item_url()); } $mItem = new ItemActions(false); $result = $mItem->contact(); if (is_string($result)) { osc_add_flash_error_message($result); } else { osc_add_flash_ok_message(_m("We've just sent an e-mail to the seller")); } $this->redirectTo(osc_item_url()); break; case 'add_comment': $mItem = new ItemActions(false); $status = $mItem->add_comment(); switch ($status) { case -1: $msg = _m('Sorry, we could not save your comment. Try again later'); osc_add_flash_error_message($msg); break; case 1: $msg = _m('Your comment is awaiting moderation'); osc_add_flash_info_message($msg); break; case 2: $msg = _m('Your comment has been approved'); osc_add_flash_ok_message($msg); break; case 3: $msg = _m('Please fill the required field (email)'); osc_add_flash_warning_message($msg); break; case 4: $msg = _m('Please type a comment'); osc_add_flash_warning_message($msg); break; case 5: $msg = _m('Your comment has been marked as spam'); osc_add_flash_error_message($msg); break; } $this->redirectTo(osc_item_url()); break; case 'delete_comment': $mItem = new ItemActions(false); $status = $mItem->add_comment(); $itemId = Params::getParam('id'); $commentId = Params::getParam('comment'); $item = Item::newInstance()->findByPrimaryKey($itemId); if (count($item) == 0) { osc_add_flash_error_message(_m("This listing doesn't exist")); $this->redirectTo(osc_base_url(true)); } View::newInstance()->_exportVariableToView('item', $item); if ($this->userId == null) { osc_add_flash_error_message(_m('You must be logged in to delete a comment')); $this->redirectTo(osc_item_url()); } $commentManager = ItemComment::newInstance(); $aComment = $commentManager->findByPrimaryKey($commentId); if (count($aComment) == 0) { osc_add_flash_error_message(_m("The comment doesn't exist")); $this->redirectTo(osc_item_url()); } if ($aComment['b_active'] != 1) { osc_add_flash_error_message(_m('The comment is not active, you cannot delete it')); $this->redirectTo(osc_item_url()); } if ($aComment['fk_i_user_id'] != $this->userId) { osc_add_flash_error_message(_m('The comment was not added by you, you cannot delete it')); $this->redirectTo(osc_item_url()); } $commentManager->deleteByPrimaryKey($commentId); osc_add_flash_ok_message(_m('The comment has been deleted')); $this->redirectTo(osc_item_url()); break; default: // if there isn't ID, show an error 404 if (Params::getParam('id') == '') { $this->do404(); return; } if (Params::getParam('lang') != '') { Session::newInstance()->_set('userLocale', Params::getParam('lang')); } $item = $this->itemManager->findByPrimaryKey(Params::getParam('id')); // if item doesn't exist show an error 404 if (count($item) == 0) { $this->do404(); return; } if ($item['b_active'] != 1) { if ($this->userId == $item['fk_i_user_id']) { osc_add_flash_warning_message(_m("The listing hasn't been validated. Please validate it in order to make it public")); } else { osc_add_flash_warning_message(_m("This listing hasn't been validated")); $this->redirectTo(osc_base_url(true)); } } else { if ($item['b_enabled'] == 0) { osc_add_flash_warning_message(_m('The listing has been suspended')); $this->redirectTo(osc_base_url(true)); } } if (!osc_is_admin_user_logged_in()) { require_once osc_lib_path() . 'osclass/user-agents.php'; foreach ($user_agents as $ua) { if (preg_match('|' . $ua . '|', @$_SERVER['HTTP_USER_AGENT'])) { $mStats = new ItemStats(); $mStats->increase('i_num_views', $item['pk_i_id']); break; } } } foreach ($item['locale'] as $k => $v) { $item['locale'][$k]['s_title'] = osc_apply_filter('item_title', $v['s_title']); $item['locale'][$k]['s_description'] = nl2br(osc_apply_filter('item_description', $v['s_description'])); } if ($item['fk_i_user_id'] != '') { $user = User::newInstance()->findByPrimaryKey($item['fk_i_user_id']); $this->_exportVariableToView('user', $user); } $this->_exportVariableToView('item', $item); osc_run_hook('show_item', $item); // redirect to the correct url just in case it has changed $itemURI = str_replace(osc_base_url(), '', osc_item_url()); $URI = preg_replace('|^' . REL_WEB_URL . '|', '', $_SERVER['REQUEST_URI']); // do not clean QUERY_STRING if permalink is not enabled if (osc_rewrite_enabled()) { $URI = str_replace('?' . $_SERVER['QUERY_STRING'], '', $URI); } else { $params_keep = array('page', 'id'); $params = array(); foreach (Params::getParamsAsArray('get') as $k => $v) { if (in_array($k, $params_keep)) { $params[] = "{$k}={$v}"; } } $URI = 'index.php?' . implode('&', $params); } // redirect to the correct url if ($itemURI != $URI) { $this->redirectTo(osc_base_url() . $itemURI); } $this->doView('item.php'); break; } }
/** * Gets the current latest search * * @return array */ function osc_latest_search() { if (View::newInstance()->_exists('latest_searches')) { return View::newInstance()->_current('latest_searches'); } return null; }
/** * Helper to use twitter pagination in user items */ function twitter_user_item_pagination() { $params = array('total' => (int) View::newInstance()->_get('list_total_pages'), 'selected' => (int) View::newInstance()->_get('list_page'), 'class_first' => '', 'class_last' => '', 'class_prev' => 'prev', 'class_next' => 'next', 'delimiter' => '', 'text_prev' => sprintf(__('%s Previous', 'twitter'), '←'), 'text_next' => sprintf(__('Next %s', 'twitter'), '→'), 'class_selected' => 'active', 'class_non_selected' => '', 'force_limits' => false, 'url' => osc_user_list_items_url('{PAGE}')); $pagination = new TwitterPagination($params); return $pagination->doPagination(); }
<input type="hidden" name="page" value="settings" /> <input type="hidden" name="action" value="akismet_post" /> <fieldset> <div class="form-horizontal"> <div class="form-row"> <div class="form-label"><?php _e('Akismet API Key'); ?> </div> <div class="form-controls"> <input type="text" class="input-large" name="akismetKey" value="<?php echo osc_akismet_key() ? osc_esc_html(osc_akismet_key()) : ''; ?> " /> <?php $akismet_status = View::newInstance()->_get('akismet_status'); $alert_msg = ''; $alert_type = 'error'; switch ($akismet_status) { case 1: $alert_type = 'ok'; $alert_msg = __('This key is valid'); break; case 2: $alert_type = 'error'; $alert_msg = __('The key you entered is invalid. Please double-check it'); break; case 3: $alert_type = 'warning'; $alert_msg = sprintf(__('Akismet is disabled, please enter an API key. <a href="%s" target="_blank">(Get your key)</a>'), 'http://akismet.com/get/'); break;
/** * Gets list of non-empty categories * * @return void */ function osc_get_non_empty_categories() { $aCategories = Category::newInstance()->toTree(false); View::newInstance()->_exportVariableToView('categories', $aCategories); return View::newInstance()->_get('categories'); }
} } ?> <?php foreach ($sliced_array as $sa) { ?> <?php $top_item = select_top_item($sa['cat_id']); if ($top_item == null || empty($top_item)) { $no_item = false; $category_name = get_category_name($sa['cat_id']); } else { $no_item = true; $primary_id = (int) $top_item[0]['fk_i_item_id']; $item = Item::newInstance()->findByPrimaryKey($primary_id); View::newInstance()->_exportVariableToView('item', $item); $category_name = get_parent_category_name(osc_item_category_id()); } ?> <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12"> <div class="automobile"> <h5 class="auto"><?php echo $category_name; ?> </h5> <?php if (osc_count_item_resources()) { ?> <a href="<?php echo osc_item_url(); ?>
?> <?php related_listings(); ?> <?php if (osc_count_items() > 0) { ?> <div class="similar_ads"> <h2 class="title"> <?php _e('Related items', 'osclasswizards'); ?> </h2> <?php View::newInstance()->_exportVariableToView("listType", 'items'); osc_current_web_theme_path('loop-grid.php'); ?> </div> <?php } ?> </div> <div class="col-sm-6 col-md-5"> <?php osc_current_web_theme_path('item-sidebar.php'); ?> </div> </div> <?php osc_current_web_theme_path('footer.php');
<div class="user-phone"> <i class="fa fa-phone"></i> <span><?php echo osc_user_phone() ?></span> </div> <?php }*/ ?> <div class="divider"></div> <?php } ?> <?php $aItems = Item::newInstance()->findByUserID(osc_item_user_id(), 0, 3); View::newInstance()->_exportVariableToView('items', $aItems); ?> <div class="user-products"> <p><?php printf(__('Other products from %s', 'pop'), osc_user_name()); ?> </p> <div> <?php while (osc_has_items()) { if (osc_count_item_resources()) { osc_get_item_resources(); ?> <a class="user-item" href="<?php echo osc_item_url(); ?>
if (View::newInstance()->_exists('listType')) { $type = View::newInstance()->_get('listType'); } ?> <div class="listing-card-list listings_grid listings_grids" id="listing-card-list"> <?php $i = 0; $listcount = 0; while (osc_has_items()) { if ($listcount % 3 == 0) { echo '</ul><ul class="row">'; } $listcount++; $admin = false; if (View::newInstance()->_exists("listAdmin")) { $admin = true; } ?> <?php $size = explode('x', osc_thumbnail_dimensions()); ?> <li class="col-sm-6 col-md-4 <?php if (osc_item_is_premium()) { echo ' premium'; } ?> "> <div class="listing-card"> <?php if (osc_images_enabled_at_items()) {
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public * License along with this program. If not, see <http://www.gnu.org/licenses/>. */ ?> <?php $loopClass = ''; $type = 'items'; if (View::newInstance()->_exists('listType')) { $type = View::newInstance()->_get('listType'); } if (View::newInstance()->_exists('listClass')) { $loopClass = View::newInstance()->_get('listClass'); } ?> <ul class="listing-card-list <?php echo $loopClass; ?> " id="listing-card-list"> <?php $i = 0; if ($type == 'latestItems') { while (osc_has_latest_items()) { $class = ''; if ($i % 3 == 0) { $class = 'first'; } nepcoders_draw_item($class);
public function sendEmails($aItem){ $item = $aItem['item']; View::newInstance()->_exportVariableToView('item', $item); /** * Send email to non-reg user requesting item activation */ if( Session::newInstance()->_get('userId') == '' && $aItem['active']=='INACTIVE' ) { osc_run_hook('hook_email_item_validation_non_register_user', $item); } else if ( $aItem['active']=='INACTIVE' ) { // USER IS REGISTERED osc_run_hook('hook_email_item_validation', $item); } else if( Session::newInstance()->_get('userId') == '' ){ // USER IS NOT REGISTERED osc_run_hook('hook_email_new_item_non_register_user', $item); } /** * Send email to admin about the new item */ if (osc_notify_new_item()) { osc_run_hook('hook_email_admin_new_item', $item); } }
/** * Getting from View the $key index * * @param string $key * @return array */ function __get($key) { return View::newInstance()->_get($key); }
/** * Gets premium meta fields * * @return array */ function osc_get_premium_meta() { if (!View::newInstance()->_exists('metafields')) { View::newInstance()->_exportVariableToView('metafields', Item::newInstance()->metaFields(osc_premium_id())); } return View::newInstance()->_get('metafields'); }
function sendCommentActivated($commentId) { $aComment = $this->itemCommentManager->findByPrimaryKey($commentId); $aItem = Item::newInstance()->findByPrimaryKey($aComment['fk_i_item_id']); View::newInstance()->_exportVariableToView('item', $aItem); osc_run_hook('hook_email_comment_validated', $aComment); }