public function get_listing_upload_limits($listing) { $payment_term = $this->payments->get_ad_payment_term($listing); if (awpcp_are_images_allowed()) { $upload_limits = array('images' => $this->get_listing_upload_limits_for_images($listing, $payment_term)); } else { $upload_limits = array(); } return apply_filters('awpcp-listing-upload-limits', $upload_limits, $listing, $payment_term); }
public function preview_step() { $transaction = $this->get_transaction(); if (is_null($transaction)) { $message = __('We were unable to find a Payment Transaction assigned to this operation.', 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } $ad = AWPCP_Ad::find_by_id($transaction->get('ad-id', 0)); if (is_null($ad)) { $message = __('The Ad associated with this transaction doesn\'t exists.', 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } if (isset($_POST['edit-details'])) { return $this->details_step(); } else { if (isset($_POST['manage-images'])) { return $this->upload_images_step(); } else { if (isset($_POST['finish'])) { return $this->checkout_step(); } else { $payment_term = awpcp_payments_api()->get_ad_payment_term($ad); $manage_images = awpcp_are_images_allowed() && $payment_term->images > 0; $params = array('ad' => $ad, 'edit' => false, 'messages' => $this->messages, 'hidden' => array('preview-hash' => $this->get_preview_hash($ad), 'transaction_id' => $transaction->id), 'ui' => array('manage-images' => $manage_images)); $template = AWPCP_DIR . '/frontend/templates/page-place-ad-preview-step.tpl.php'; return $this->render($template, $params); } } } }
public function actions($ad, $filter = false) { $is_moderator = awpcp_current_user_is_moderator(); $actions = array(); $actions['view'] = array(__('View', 'AWPCP'), $this->url(array('action' => 'view', 'id' => $ad->ad_id))); $actions['edit'] = array(__('Edit', 'AWPCP'), $this->url(array('action' => 'edit', 'id' => $ad->ad_id))); $actions['trash'] = array(__('Delete', 'AWPCP'), $this->url(array('action' => 'delete', 'id' => $ad->ad_id))); if ($is_moderator) { if ($ad->disabled) { $actions['enable'] = array(__('Enable', 'AWPCP'), $this->url(array('action' => 'enable', 'id' => $ad->ad_id))); } else { $actions['disable'] = array(__('Disable', 'AWPCP'), $this->url(array('action' => 'disable', 'id' => $ad->ad_id))); } if ($ad->flagged) { $actions['unflag'] = array(__('Unflag', 'AWPCP'), $this->url(array('action' => 'unflag', 'id' => $ad->ad_id))); } if (get_awpcp_option('useakismet')) { $actions['spam'] = array('SPAM', $this->url(array('action' => 'spam', 'id' => $ad->ad_id))); } $has_featured_ads = function_exists('awpcp_featured_ads'); if ($has_featured_ads && $ad->is_featured_ad) { $actions['remove-featured'] = array(__('Remove Featured', 'AWPCP'), $this->url(array('action' => 'remove-featured', 'id' => $ad->ad_id))); } else { if ($has_featured_ads) { $actions['make-featured'] = array(__('Make Featured', 'AWPCP'), $this->url(array('action' => 'make-featured', 'id' => $ad->ad_id))); } } $actions['send-key'] = array(__('Send Access Key', 'AWPCP'), $this->url(array('action' => 'send-key', 'id' => $ad->ad_id))); } if ($ad->is_about_to_expire() || $ad->has_expired()) { $hash = awpcp_get_renew_ad_hash($ad->ad_id); $params = array('action' => 'renew', 'id' => $ad->ad_id, 'awpcprah' => $hash); $actions['renwew-ad'] = array(__('Renew Ad', 'AWPCP'), $this->url($params)); } if ($images = $ad->count_image_files()) { $label = __('Manage Images', 'AWPCP'); $url = $this->url(array('action' => 'manage-images', 'id' => $ad->ad_id)); $actions['manage-images'] = array($label, array('', $url, " ({$images})")); } else { if (awpcp_are_images_allowed()) { $actions['add-image'] = array(__('Add Images', 'AWPCP'), $this->url(array('action' => 'add-image', 'id' => $ad->ad_id))); } } if ($is_moderator && !$ad->disabled) { $fb = AWPCP_Facebook::instance(); if (!awpcp_get_ad_meta($ad->ad_id, 'sent-to-facebook') && $fb->get('page_id')) { $actions['send-to-facebook'] = array(__('Send to Facebook', 'AWPCP'), $this->url(array('action' => 'send-to-facebook', 'id' => $ad->ad_id))); } else { if (!awpcp_get_ad_meta($ad->ad_id, 'sent-to-facebook-group') && $fb->get('group_id')) { $actions['send-to-facebook'] = array(__('Send to Facebook Group', 'AWPCP'), $this->url(array('action' => 'send-to-facebook', 'id' => $ad->ad_id))); } } } $actions = apply_filters('awpcp-admin-listings-table-actions', $actions, $ad, $this); if ($is_moderator && isset($_REQUEST['filterby']) && $_REQUEST['filterby'] == 'new') { $actions['mark-reviewed'] = array(__('Mark Reviewed', 'AWPCP'), $this->url(array('action' => 'mark-reviewed', 'id' => $ad->ad_id))); } if (is_array($filter)) { $actions = array_intersect_key($actions, array_combine($filter, $filter)); } return $actions; }
/** * @since 3.0 */ function awpcp_do_placeholder_images($ad, $placeholder) { global $wpdb; global $awpcp_imagesurl; static $replacements = array(); if (isset($replacements[$ad->ad_id])) { return $replacements[$ad->ad_id][$placeholder]; } $placeholders = array('featureimg' => '', 'awpcpshowadotherimages' => '', 'images' => '', 'awpcp_image_name_srccode' => ''); $url = awpcp_listing_renderer()->get_view_listing_url($ad); $thumbnail_width = get_awpcp_option('displayadthumbwidth'); if (awpcp_are_images_allowed()) { $images_uploaded = $ad->count_image_files(); $primary_image = awpcp_media_api()->get_ad_primary_image($ad); $gallery_name = 'awpcp-gallery-' . $ad->ad_id; if ($primary_image) { $large_image = $primary_image->get_large_image_url('large'); $thumbnail = $primary_image->get_primary_thumbnail_url('primary'); if (get_awpcp_option('show-click-to-enlarge-link', 1)) { $link = '<a class="thickbox enlarge" href="%s">%s</a>'; $link = sprintf($link, $large_image, __('Click to enlarge image.', 'AWPCP')); } else { $link = ''; } // single ad $content = '<div class="awpcp-ad-primary-image">'; $content .= '<a class="awpcp-listing-primary-image-thickbox-link thickbox thumbnail" href="%s" rel="%s">'; $content .= '<img class="thumbshow" src="%s"/>'; $content .= '</a>%s'; $content .= '</div>'; $placeholders['featureimg'] = sprintf($content, esc_attr($large_image), $gallery_name, esc_attr($thumbnail), $link); // listings $content = '<a class="awpcp-listing-primary-image-listing-link" href="%s"><img src="%s" width="%spx" border="0" alt="%s" /></a>'; $content = sprintf($content, $url, $thumbnail, $thumbnail_width, awpcp_esc_attr($ad->ad_title)); $placeholders['awpcp_image_name_srccode'] = $content; } if ($images_uploaded >= 1) { $results = awpcp_media_api()->find_public_images_by_ad_id($ad->ad_id); $columns = get_awpcp_option('display-thumbnails-in-columns', 0); $rows = $columns > 0 ? ceil(count($results) / $columns) : 0; $shown = 0; $images = array(); foreach ($results as $image) { $large_image = $image->get_url('large'); $thumbnail = $image->get_url('thumbnail'); if ($columns > 0) { $css = join(' ', awpcp_get_grid_item_css_class(array(), $shown, $columns, $rows)); } else { $css = ''; } $content = '<li class="%s">'; $content .= '<a class="thickbox" href="%s" rel="%s">'; $content .= '<img class="thumbshow" src="%s" />'; $content .= '</a>'; $content .= '</li>'; $images[] = sprintf($content, esc_attr($css), esc_attr($large_image), esc_attr($gallery_name), esc_attr($thumbnail)); $shown = $shown + 1; } $placeholders['awpcpshowadotherimages'] = join('', $images); $content = '<ul class="awpcp-single-ad-images">%s</ul>'; $placeholders['images'] = sprintf($content, $placeholders['awpcpshowadotherimages']); } } // fallback thumbnail if (awpcp_are_images_allowed() && empty($placeholders['awpcp_image_name_srccode'])) { $thumbnail = sprintf('%s/adhasnoimage.png', $awpcp_imagesurl); $content = '<a class="awpcp-listing-primary-image-listing-link" href="%s"><img src="%s" width="%spx" border="0" alt="%s" /></a>'; $content = sprintf($content, $url, $thumbnail, $thumbnail_width, awpcp_esc_attr($ad->ad_title)); $placeholders['awpcp_image_name_srccode'] = $content; } $placeholders['featureimg'] = apply_filters('awpcp-featured-image-placeholder', $placeholders['featureimg'], 'single', $ad); $placeholders['awpcp_image_name_srccode'] = apply_filters('awpcp-featured-image-placeholder', $placeholders['awpcp_image_name_srccode'], 'listings', $ad); $placeholders['featured_image'] = $placeholders['featureimg']; $placeholders['imgblockwidth'] = "{$thumbnail_width}px"; $placeholders['thumbnail_width'] = "{$thumbnail_width}px"; $replacements[$ad->ad_id] = apply_filters('awpcp-placeholders-image', $placeholders, $ad); return $replacements[$ad->ad_id][$placeholder]; }
public function upload_images_step() { $ad = $this->get_ad(); if (is_null($ad)) { $message = __('The specified Ad doesn\'t exists. No images can be added at this time.', 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } extract($params = $this->get_images_config($ad)); // see if we can move to the next step if (!awpcp_are_images_allowed()) { return $this->finish_step(); } else { if (awpcp_post_param('submit-no-images', false)) { return $this->finish_step(); } else { if ($images_uploaded == 0 && $images_allowed == 0) { return $this->finish_step(); } } } // we are still here... let's show the upload images form return $this->show_upload_images_form($ad, null, $params, array()); }
protected function render_item_image($item, $instance) { global $awpcp_imagesurl; $show_images = $instance['show-images'] && awpcp_are_images_allowed(); $image = awpcp_media_api()->get_ad_primary_image($item); if (!is_null($image) && $show_images) { $image_url = $image->get_url(); } else { if ($instance['show-blank'] && $show_images) { $image_url = "{$awpcp_imagesurl}/adhasnoimage.png"; } else { $image_url = ''; } } if (empty($image_url)) { $html_image = ''; } else { $html_image = sprintf('<a class="awpcp-listings-widget-item-listing-link self" href="%1$s"><img src="%2$s" alt="%3$s" /></a>', url_showad($item->ad_id), $image_url, esc_attr($item->ad_title)); } return apply_filters('awpcp-listings-widget-listing-thumbnail', $html_image, $item); }