public function licenses() { $this->document->setTitle(tt('Licenses')); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', array(array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false), array('name' => tt('Licensing Policy'), 'href' => $this->url->link('common/information/licenses'), 'active' => true))); // Get all licenses $licenses = $this->model_common_license->getLicenses($this->language->getId()); $data['licenses'] = array(); foreach ($licenses as $license) { // Get license conditions $license_conditions = $this->model_common_license->getLicenseConditions($license->license_id, $this->language->getId()); $conditions = array(); foreach ($license_conditions as $license_condition) { if ($license_condition->optional) { $condition = sprintf($license_condition->condition, tt('may') . tt(' or ') . tt('shall not')); $conditions[$license_condition->license_condition_id] = highlight_license_condition($condition, tt('may'), tt('shall not')); } else { $conditions[$license_condition->license_condition_id] = highlight_license_condition($license_condition->condition, tt('may'), tt('shall not')); } } // Merge $data['licenses'][$license->license_id] = array('name' => $license->name . ' ' . tt('License'), 'description' => $license->description, 'conditions' => $conditions); } $this->response->setOutput($this->load->view('common/information/license.tpl', $data)); }
public function index() { // Init variables $data = array(); $breadcrumbs = array(); $product_info = array(); $categories = array(); // Check dependencies if (!isset($this->request->get['product_id']) || !($product_info = $this->model_catalog_product->getProduct((int) $this->request->get['product_id'], $this->language->getId(), $this->auth->getId(), ORDER_APPROVED_STATUS_ID))) { $this->security_log->write('Try to get product file without product_id parameter' . isset($this->request->get['product_id']) ? (int) $this->request->get['product_id'] : false); $this->response->redirect($this->url->link('error/not_found')); } // Check product status switch ($product_info->status) { case 'blocked': $this->response->redirect($this->url->link('error/not_found')); break; case 'disabled': $this->response->redirect($this->url->link('error/not_found')); break; default: } // Add product hit exclude owner's and search bot hits if (!$this->auth->isLogged() && !SearchEngines::isBot($this->request->getUserAgent()) || $this->auth->isLogged() && $product_info->user_id != $this->auth->getId()) { $this->model_catalog_product->addProductView($product_info->product_id); } // Misc $data['color_labels'] = array('label-default', 'label-primary', 'label-success', 'label-warning', 'label-danger', 'label-info', 'label-default', 'label-primary', 'label-success', 'label-warning', 'label-danger', 'label-info', 'label-default', 'label-primary', 'label-success', 'label-warning', 'label-danger', 'label-info'); // Breadcrumbs $parent_category_id = $product_info->category_id; do { $parent_category_info = $this->model_catalog_category->getCategory($parent_category_id, $this->language->getId()); if ($parent_category_info) { $parent_category_id = $parent_category_info->parent_category_id; $breadcrumbs[] = array('name' => $parent_category_info->title, 'href' => $this->url->link('catalog/category', 'category_id=' . $parent_category_info->category_id), 'active' => false); $categories[] = $parent_category_info->title; } } while ($parent_category_id); $breadcrumbs[] = array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false); array_multisort($breadcrumbs, SORT_ASC, SORT_NUMERIC); $breadcrumbs[] = array('name' => $product_info->title, 'href' => $this->url->link('catalog/product', 'product_id=' . $product_info->product_id), 'active' => true); // Product data $data['product_id'] = $product_info->product_id; $data['product_title'] = $product_info->title; $data['product_username'] = $product_info->username; $data['product_sales'] = $product_info->sales; $data['product_status'] = $product_info->status; $data['product_is_self'] = $product_info->user_id == $this->auth->getId() ? true : false; $data['user_is_logged'] = $this->auth->isLogged() ? true : false; $data['verified'] = $product_info->verified; $image_info = $this->model_catalog_product->getProductImageInfo($product_info->main_product_image_id); $data['product_image_url'] = $this->cache->image($product_info->main_product_image_id, $product_info->user_id, 350, 1000, $image_info->watermark, false, true); $data['product_image_orig_url'] = $this->cache->image($product_info->main_product_image_id, $product_info->user_id, 570, 1000, $image_info->watermark, false, true); $data['product_image_id'] = $product_info->main_product_image_id; switch ($product_info->order_status_id) { case ORDER_APPROVED_STATUS_ID: $data['product_order_status'] = 'approved'; break; case ORDER_PROCESSED_STATUS_ID: $data['product_order_status'] = 'processed'; break; default: $data['product_order_status'] = $product_info->user_id == $this->auth->getId() ? 'approved' : false; } $data['product_demo'] = $product_info->main_product_demo_id ? true : false; $data['product_favorites'] = $product_info->favorites ? $product_info->favorites : false; $data['product_favorite'] = $product_info->favorite; $data['product_description'] = nl2br($product_info->description); $data['product_href_view'] = $this->url->link('catalog/product', 'product_id=' . $product_info->product_id); $data['product_href_download'] = $this->url->link('catalog/product/download', 'product_id=' . $product_info->product_id); $data['product_href_demo'] = $this->url->link('catalog/product/demo', 'product_demo_id=' . $product_info->main_product_demo_id); $data['product_href_user'] = $this->url->link('catalog/search', 'user_id=' . $product_info->user_id); $data['product_date_added'] = date(tt('d.m.Y'), strtotime($product_info->date_added)); $data['product_date_modified'] = date(tt('d.m.Y'), strtotime($product_info->date_modified)); $data['product_demos'] = array(); foreach ($this->model_catalog_product->getProductDemos($product_info->product_id, $this->language->getId()) as $demo) { if (!$demo->main) { $data['product_demos'][] = array('title' => $demo->title, 'url' => $this->url->link('catalog/product/demo', 'product_demo_id=' . $demo->product_demo_id)); } } $data['product_images'] = array(); foreach ($this->model_catalog_product->getProductImages($product_info->product_id, $this->language->getId()) as $image) { if (!$image->main) { $data['product_images'][] = array('title' => $image->title, 'preview' => $this->cache->image($image->product_image_id, $product_info->user_id, 50, 50), 'original' => $this->cache->image($image->product_image_id, $product_info->user_id, 570, 1000, $image->watermark, false, true)); } } $data['product_videos'] = array(); foreach ($this->model_catalog_product->getProductVideos($product_info->product_id, $this->language->getId()) as $video) { $data['product_videos'][] = array('title' => $video->title, 'ogg' => $this->cache->video($video->product_video_id, $product_info->user_id, 'ogv', false, $video->reduce ? PRODUCT_VIDEO_REDUCED_QUALITY : PRODUCT_VIDEO_QUALITY), 'mp4' => $this->cache->video($video->product_video_id, $product_info->user_id, 'mp4', false, $video->reduce ? PRODUCT_VIDEO_REDUCED_QUALITY : PRODUCT_VIDEO_QUALITY)); } $data['product_audios'] = array(); foreach ($this->model_catalog_product->getProductAudios($product_info->product_id, $this->language->getId()) as $audio) { $data['product_audios'][] = array('title' => $audio->title, 'ogg' => $this->cache->audio($audio->product_audio_id, $product_info->user_id, 'oga', false, $audio->cut ? PRODUCT_AUDIO_CUT_TIME : 0), 'mp3' => $this->cache->audio($audio->product_audio_id, $product_info->user_id, 'mp3', false, $audio->cut ? PRODUCT_AUDIO_CUT_TIME : 0)); } $meta_tags = array(); $data['product_tags'] = array(); foreach ($this->model_catalog_product->getProductTags($product_info->product_id, $this->language->getId()) as $tag) { $meta_tags[] = $tag->name; $data['product_tags'][] = array('name' => $tag->name, 'url' => $this->url->link('catalog/search', 'q=' . urlencode($tag->name))); } // Prepare special counter if ($product_info->special_date_end) { $special_left_seconds = strtotime($product_info->special_date_end) - time(); $special_left_minutes = floor($special_left_seconds / 60); $special_left_hours = floor($special_left_minutes / 60); $special_left_days = floor($special_left_hours / 24); if ($special_left_minutes < 60) { $special_expires = sprintf(tt('%s %s left'), $special_left_minutes, plural($special_left_minutes, array(tt('minute'), tt('minutes'), tt('minutes ')))); } else { if ($special_left_hours < 24) { $special_expires = sprintf(tt('%s %s left'), $special_left_hours, plural($special_left_hours, array(tt('hour'), tt('hours'), tt('hours ')))); } else { $special_expires = sprintf(tt('%s %s left'), $special_left_days, plural($special_left_days, array(tt('day'), tt('days'), tt('days ')))); } } } else { $special_expires = false; } $data['product_special_expires'] = $special_expires; $data['product_special_regular_price'] = $product_info->special_regular_price > 0 ? $this->currency->format($product_info->special_regular_price, $product_info->currency_id) : 0; $data['product_special_exclusive_price'] = $product_info->special_exclusive_price > 0 ? $this->currency->format($product_info->special_exclusive_price, $product_info->currency_id) : 0; $data['product_regular_price'] = $this->currency->format($product_info->regular_price, $product_info->currency_id); $data['product_exclusive_price'] = $this->currency->format($product_info->exclusive_price, $product_info->currency_id); $data['product_has_regular_price'] = $product_info->regular_price > 0 ? true : false; $data['product_has_exclusive_price'] = $product_info->exclusive_price > 0 ? true : false; $data['product_has_special_regular_price'] = $product_info->special_regular_price > 0 ? true : false; $data['product_has_special_exclusive_price'] = $product_info->special_exclusive_price > 0 ? true : false; $data['license_form_action'] = $this->url->link('catalog/product', 'product_id=' . $product_info->product_id); $data['current_license_code'] = 'regular'; $data['regular'] = true; $data['exclusive'] = 0 == $product_info->regular_price && 0 == $product_info->special_regular_price ? true : false; if ('POST' == $this->request->getRequestMethod()) { switch ($this->request->post['license']) { case 'exclusive': $data['regular'] = false; $data['exclusive'] = true; $data['current_license_code'] = 'exclusive'; break; default: $data['regular'] = true; $data['exclusive'] = false; } } // Get license conditions $licenses = $this->model_common_license->getLicenses($this->language->getId()); $data['licenses'] = array(); foreach ($licenses as $license) { // Get license conditions $license_conditions = $this->model_common_license->getLicenseConditions($license->license_id, $this->language->getId()); $conditions = array(); foreach ($license_conditions as $license_condition) { if ($license_condition->optional) { $condition = sprintf($license_condition->condition, $this->model_catalog_product->getLicenseConditionValue($product_info->product_id, $license_condition->license_condition_id) ? tt('may') : tt('shall not')); $conditions[$license_condition->license_condition_id] = highlight_license_condition($condition, tt('may'), tt('shall not')); } else { $conditions[$license_condition->license_condition_id] = highlight_license_condition($license_condition->condition, tt('may'), tt('shall not')); } } // Merge if ($license->code == $data['current_license_code']) { $data['licenses'][$license->license_id] = array('name' => $license->name . ' ' . tt('License'), 'description' => $license->description, 'conditions' => $conditions); } } // Add meta-tags $this->document->setTitle(sprintf(tt('%s Buy with BitCoin'), $product_info->title) . ' | ' . implode(' ', $categories)); $this->document->setDescription(sprintf(tt('Royalty-free %s %s by %s with BitCoin. %s. Buy with BTC easy - Download instantly!'), $categories[0], $product_info->title, $product_info->username, FilterMeta::description($product_info->description, 100), implode(' and ', $categories))); $this->document->setKeywords(sprintf(tt('bitsybay, bitcoin, btc, indie, marketplace, store, buy, sell, royalty-free, %s, %s, %s'), $product_info->username, strtolower(implode(', ', $categories)), implode(', ', $meta_tags))); // Add schema $this->document->addSchema('Product', 'name', $product_info->title); $this->document->addSchema('Product', 'description', FilterMeta::description($product_info->description)); $this->document->addSchema('Product', 'category', $categories[0]); $this->document->addSchema('Product', 'image', $data['product_image_orig_url']); $this->document->addSchema('Offer', 'seller', $product_info->username); $this->document->addSchema('Offer', 'category', $categories[0]); $this->document->addSchema('Offer', 'availability', 'in_stock'); $this->document->addSchema('Offer', 'priceCurrency', $this->currency->getCode()); $this->document->addSchema('Offer', 'price', $product_info->special_regular_price > 0 ? $product_info->special_regular_price : $product_info->regular_price); // Add Open Graph $this->document->addOpenGraph('og:site_name', PROJECT_NAME); $this->document->addOpenGraph('og:type', 'product'); $this->document->addOpenGraph('og:url', $this->url->getCurrentLink()); $this->document->addOpenGraph('og:name', $product_info->title); $this->document->addOpenGraph('og:brand', $product_info->username); $this->document->addOpenGraph('og:image', $data['product_image_orig_url']); $this->document->addOpenGraph('og:description', FilterMeta::description($product_info->description)); $this->document->addOpenGraph('og:updated_time', $product_info->date_modified); $this->document->addOpenGraph('product:original_price:amount', $product_info->special_regular_price > 0 ? $product_info->special_regular_price : $product_info->regular_price); $this->document->addOpenGraph('product:original_price:currency', $this->currency->getCode()); $this->document->addOpenGraph('product:availability', 'instock'); $this->document->addOpenGraph('product:category', $categories[0]); // Load layout $data['title'] = $product_info->title; $data['alert_warning'] = $this->load->controller('common/alert/warning'); $data['alert_success'] = $this->load->controller('common/alert/success'); $data['alert_danger'] = $this->load->controller('common/alert/danger'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', $breadcrumbs); // Renter the template $this->response->setOutput($this->load->view('catalog/product.tpl', $data)); }
private function _populateForm($action) { $data = array(); // Common $data['date_today'] = date('Y-m-d'); $data['date_tomorrow'] = date('Y-m-d', strtotime('+1 day', strtotime(date('Y-m-d')))); $data['product_id'] = isset($this->request->get['product_id']) ? $this->request->get['product_id'] : false; $data['error'] = $this->_error; $data['action'] = $action; $data['href_account_product'] = $this->url->link('account/product'); $data['this_language_id'] = $this->language->getId(); // Get saved info if (isset($this->request->get['product_id'])) { $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id'], $this->language->getId(), $this->auth->getId(), ORDER_APPROVED_STATUS_ID); $this->document->setTitle(sprintf(tt('Edit %s'), $product_info->title)); $data['title'] = sprintf(tt('Edit %s'), $product_info->title); } else { $product_info = array(); $this->document->setTitle(tt('Add product')); $data['title'] = tt('Add product'); } // File if (isset($this->request->post['product_file_id']) && !empty($this->request->post['product_file_id']) && file_exists(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION) && ($file_content = file_get_contents(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION))) { $data['package_hash_md5'] = 'MD5: ' . md5($file_content); $data['package_hash_sha1'] = 'SHA1: ' . sha1($file_content); $data['product_file_id'] = $this->request->post['product_file_id']; } else { if ($product_info && ($product_file_info = $this->model_catalog_product->getProductFileInfo($product_info->product_id))) { $data['package_hash_md5'] = 'MD5: ' . $product_file_info->hash_md5; $data['package_hash_sha1'] = 'SHA1: ' . $product_file_info->hash_sha1; $data['product_file_id'] = $product_file_info->product_file_id; $file_size = $this->storage->getFileSize($product_file_info->product_file_id, $this->auth->getId(), STORAGE_FILE_EXTENSION); } else { $data['package_hash_md5'] = false; $data['package_hash_sha1'] = false; $data['product_file_id'] = false; } } // Languages $languages = $this->model_common_language->getLanguages($this->language->getId()); $data['languages'] = array(); foreach ($languages as $language) { $data['languages'][$language->language_id] = array('language_id' => $language->language_id, 'code' => $language->code, 'name' => $language->name); } // Licenses $licenses = $this->model_common_license->getLicenses($this->language->getId()); $data['licenses'] = array(); foreach ($licenses as $license) { // Get license conditions $license_conditions = $this->model_common_license->getLicenseConditions($license->license_id, $this->language->getId()); $conditions = array(); foreach ($license_conditions as $license_condition) { // Get product's license condition value if (isset($this->request->post['license_conditions'][$license_condition->license_condition_id])) { $license_condition_value = true; } else { if ($product_info) { $license_condition_value = $this->model_catalog_product->getLicenseConditionValue($product_info->product_id, $license_condition->license_condition_id); } else { $license_condition_value = true; } } if ($license_condition->optional) { $condition = sprintf($license_condition->condition, tt('may')); $conditions[$license_condition->license_condition_id] = array('license_condition_id' => $license_condition->license_condition_id, 'optional' => true, 'checked' => $license_condition_value, 'text' => highlight_license_condition($condition, tt('may'), tt('shall not'))); } else { $conditions[$license_condition->license_condition_id] = array('license_condition_id' => $license_condition->license_condition_id, 'optional' => false, 'checked' => true, 'text' => highlight_license_condition($license_condition->condition, tt('may'), tt('shall not'))); } } // Merge $data['licenses'][$license->license_id] = array('name' => $license->name . ' ' . tt('License'), 'description' => $license->description, 'conditions' => $conditions); } // Product descriptions $data['product_description'] = array(); if (isset($this->request->post['product_description'])) { foreach ($this->request->post['product_description'] as $language_id => $product_description) { $data['product_description'][$language_id] = array('title' => isset($product_description['title']) ? $product_description['title'] : false, 'description' => isset($product_description['description']) ? $product_description['description'] : false, 'tags' => isset($product_description['tags']) ? $product_description['tags'] : false); } } elseif ($product_info) { $product_tags = $this->model_catalog_product->getTagsByProductId($this->request->get['product_id']); $product_tag_descriptions = array(); foreach ($product_tags as $product_tag) { foreach ($this->model_catalog_tag->getTagDescriptions($product_tag->tag_id) as $tag_description) { $product_tag_descriptions[$tag_description->language_id][] = $tag_description->name; } } foreach ($this->model_catalog_product->getProductDescriptions($this->request->get['product_id'], $this->language->getId()) as $product_description) { $data['product_description'][$product_description->language_id] = array('title' => $product_description->title, 'description' => $product_description->description, 'tags' => isset($product_tag_descriptions[$product_description->language_id]) ? implode(', ', $product_tag_descriptions[$product_description->language_id]) : false); } } else { foreach ($languages as $language) { $data['product_description'][$language->language_id] = array('title' => false, 'description' => false, 'tags' => false); } } // Demos $demo_rows = array(0); $data['demos'] = array(); if (isset($this->request->post['demo'])) { foreach ($this->request->post['demo'] as $row => $demo) { $demo_rows[] = $row; $demo_titles = array(); foreach ($demo['title'] as $language_id => $title) { $demo_titles[$language_id] = $title; } $data['demos'][$row] = array('main' => isset($this->request->post['main_demo']) && $this->request->post['main_demo'] == $row ? true : false, 'url' => isset($demo['url']) ? $demo['url'] : false, 'title' => $demo_titles); } } else { if ($product_info) { foreach ($this->model_catalog_product->getProductDemos($product_info->product_id, $this->language->getId()) as $product_demo) { $demo_rows[] = $product_demo->product_demo_id; $demo_titles = array(); foreach ($this->model_catalog_product->getProductDemoDescriptions($product_demo->product_demo_id, $this->language->getId()) as $demo_description) { $demo_titles[$demo_description->language_id] = $demo_description->title; } $data['demos'][$product_demo->product_demo_id] = array('main' => $product_demo->main, 'url' => $product_demo->url, 'title' => $demo_titles); } } } $data['demo_max_row'] = max($demo_rows); $data['demo_total_rows'] = count($demo_rows) - 1; // Images $image_rows = array(0); $data['images'] = array(); if (isset($this->request->post['image'])) { foreach ($this->request->post['image'] as $row => $image) { $image_rows[] = $row; $image_titles = array(); $product_image_url = false; foreach ($image['title'] as $language_id => $title) { $image_titles[$language_id] = $title; } // If image already stored in exist product if (isset($image['product_image_id']) && !empty($image['product_image_id']) && file_exists(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $image['product_image_id'] . '.' . STORAGE_IMAGE_EXTENSION)) { $product_image_url = $this->cache->image($image['product_image_id'], $this->auth->getId(), 36, 36); } $data['images'][$row] = array('product_image_id' => $image['product_image_id'], 'url' => $product_image_url, 'identicon' => isset($image['identicon']) ? 1 : 0, 'watermark' => isset($image['watermark']) ? 1 : 0, 'main' => isset($this->request->post['main_image']) && $this->request->post['main_image'] == $row ? true : false, 'title' => $image_titles); } } else { if ($product_info) { foreach ($this->model_catalog_product->getProductImagesInfo($product_info->product_id) as $row => $image) { $row++; $image_rows[] = $row; $image_titles = array(); foreach ($this->model_catalog_product->getProductImageDescriptions($image->product_image_id, $this->language->getId()) as $image_description) { $image_titles[$image_description->language_id] = $image_description->title; } $data['images'][$row] = array('product_image_id' => $image->product_image_id, 'watermark' => $image->watermark, 'main' => $image->main, 'identicon' => $image->identicon, 'url' => $this->cache->image($image->product_image_id, $this->auth->getId(), 36, 36), 'title' => $image_titles); } } } $data['image_max_row'] = max($image_rows); $data['image_total_rows'] = count($image_rows) - 1; // Videos $video_rows = array(0); $data['videos'] = array(); if (isset($this->request->post['video'])) { foreach ($this->request->post['video'] as $row => $video) { $video_rows[] = $row; $video_titles = array(); $mp4 = false; $ogg = false; foreach ($video['title'] as $language_id => $title) { $video_titles[$language_id] = $title; } // If video already stored in exist product if (isset($video['product_video_id']) && !empty($video['product_video_id']) && file_exists(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $video['product_video_id'] . '.' . STORAGE_VIDEO_EXTENSION)) { $mp4 = $this->cache->video($video['product_video_id'], $this->auth->getId(), 'mp4'); $ogg = $this->cache->video($video['product_video_id'], $this->auth->getId(), 'ogv'); } $data['videos'][$row] = array('product_video_id' => $video['product_video_id'], 'ogg' => $ogg, 'mp4' => $mp4, 'reduce' => isset($video['reduce']) ? 1 : 0, 'title' => $video_titles); } } else { if ($product_info) { foreach ($this->model_catalog_product->getProductVideos($product_info->product_id, $this->language->getId()) as $row => $video) { $row++; $video_rows[] = $row; $video_titles = array(); foreach ($this->model_catalog_product->getProductVideoDescriptions($video->product_video_id, $this->language->getId()) as $video_description) { $video_titles[$video_description->language_id] = $video_description->title; } $data['videos'][$row] = array('product_video_id' => $video->product_video_id, 'reduce' => $video->reduce, 'ogg' => $this->cache->video($video->product_video_id, $this->auth->getId(), 'ogv'), 'mp4' => $this->cache->video($video->product_video_id, $this->auth->getId(), 'mp4'), 'title' => $video_titles); } } } $data['video_max_row'] = max($video_rows); $data['video_total_rows'] = count($video_rows) - 1; // Audios $audio_rows = array(0); $data['audios'] = array(); if (isset($this->request->post['audio'])) { foreach ($this->request->post['audio'] as $row => $audio) { $audio_rows[] = $row; $audio_titles = array(); $mp3 = false; $ogg = false; foreach ($audio['title'] as $language_id => $title) { $audio_titles[$language_id] = $title; } // If audio already stored in exist product if (isset($audio['product_audio_id']) && !empty($audio['product_audio_id']) && file_exists(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $audio['product_audio_id'] . '.' . STORAGE_AUDIO_EXTENSION)) { $mp3 = $this->cache->audio($audio['product_audio_id'], $this->auth->getId(), 'mp3'); $ogg = $this->cache->audio($audio['product_audio_id'], $this->auth->getId(), 'oga'); } $data['audios'][$row] = array('product_audio_id' => $audio['product_audio_id'], 'ogg' => $ogg, 'mp3' => $mp3, 'cut' => isset($audio['cut']) ? 1 : 0, 'title' => $audio_titles); } } else { if ($product_info) { foreach ($this->model_catalog_product->getProductAudios($product_info->product_id, $this->language->getId()) as $row => $audio) { $row++; $audio_rows[] = $row; $audio_titles = array(); foreach ($this->model_catalog_product->getProductAudioDescriptions($audio->product_audio_id, $this->language->getId()) as $audio_description) { $audio_titles[$audio_description->language_id] = $audio_description->title; } $data['audios'][$row] = array('product_audio_id' => $audio->product_audio_id, 'cut' => $audio->cut, 'ogg' => $this->cache->audio($audio->product_audio_id, $this->auth->getId(), 'oga'), 'mp3' => $this->cache->audio($audio->product_audio_id, $this->auth->getId(), 'mp3'), 'title' => $audio_titles); } } } $data['audio_max_row'] = max($audio_rows); $data['audio_total_rows'] = count($audio_rows) - 1; // Specials $special_rows = array(0); $data['specials'] = array(); if (isset($this->request->post['special'])) { foreach ($this->request->post['special'] as $row => $special) { $special_rows[] = $row; $data['specials'][$row] = array('regular_price' => isset($special['regular_price']) ? $special['regular_price'] : false, 'exclusive_price' => isset($special['exclusive_price']) ? $special['exclusive_price'] : false, 'date_start' => isset($special['date_start']) ? $special['date_start'] : false, 'date_end' => isset($special['date_end']) ? $special['date_end'] : false); } } else { if ($product_info) { foreach ($this->model_catalog_product->getProductSpecials($product_info->product_id) as $product_special) { $special_rows[] = $product_special->product_special_id; $data['specials'][$product_special->product_special_id] = array('regular_price' => $product_special->regular_price > 0 ? $product_special->regular_price : false, 'exclusive_price' => $product_special->exclusive_price > 0 ? $product_special->exclusive_price : false, 'date_start' => $product_special->date_start, 'date_end' => $product_special->date_end); } } } $data['special_max_row'] = max($special_rows); $data['special_total_rows'] = count($special_rows) - 1; // Current exclusive price if (isset($this->request->post['withdraw_address'])) { $data['withdraw_address'] = $this->request->post['withdraw_address']; } else { if ($product_info) { $data['withdraw_address'] = $this->model_catalog_product->getWithdrawAddress($product_info->product_id); } else { $data['withdraw_address'] = false; } } // Current exclusive price if (isset($this->request->post['exclusive_price'])) { $data['exclusive_price'] = $this->request->post['exclusive_price']; } else { if ($product_info) { $data['exclusive_price'] = $product_info->exclusive_price > 0 ? $product_info->exclusive_price : false; } else { $data['exclusive_price'] = false; } } // Current regular price if (isset($this->request->post['regular_price'])) { $data['regular_price'] = $this->request->post['regular_price']; } else { if ($product_info) { $data['regular_price'] = $product_info->regular_price > 0 ? $product_info->regular_price : false; } else { $data['regular_price'] = false; } } // Currencies list $data['currencies'] = array(); foreach ($this->model_common_currency->getCurrencies() as $currency) { $data['currencies'][$currency->currency_id] = $currency->code; } // Current currency if (isset($this->request->post['currency_id'])) { $data['currency_id'] = $this->request->post['currency_id']; } else { if ($product_info) { $data['currency_id'] = $product_info->currency_id; } else { $data['currency_id'] = 0; } } // Categories list $data['categories'] = array(); foreach ($this->model_catalog_category->getCategories(null, $this->language->getId()) as $category) { foreach ($this->model_catalog_category->getCategories($category->category_id, $this->language->getId()) as $child_category) { $data['categories'][$category->title][$child_category->category_id] = $child_category->title; } } // Current category if (isset($this->request->post['category_id'])) { $data['category_id'] = $this->request->post['category_id']; } else { if ($product_info) { $data['category_id'] = $product_info->category_id; } else { $data['category_id'] = 0; } } return $data; }