Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add YouTube Video to the partner information page

  • Loading branch information...
commit d585561f8eaf67653316fc7498936d12ef0da3e1 1 parent 9d219a4
@haraldpdl authored
View
39 osCommerce/OM/Custom/Site/Website/Application/Services/Action/Dashboard/Edit/Process.php
@@ -87,6 +87,45 @@ public static function execute(ApplicationAbstract $application) {
}
}
+ if ( isset($_POST['youtube_video_id']) ) {
+ $youtube_video_id = trim(str_replace(array("\r\n", "\n", "\r"), '', $_POST['youtube_video_id']));
+
+ if ( strlen($youtube_video_id) > 255 ) {
+ $error = true;
+
+ $OSCOM_MessageStack->add('services', OSCOM::getDef('dashboard_error_youtube_video_id_length'));
+ } else {
+ $curl = curl_init('https://gdata.youtube.com/feeds/api/videos/' . $youtube_video_id);
+
+ $curl_options = array(CURLOPT_HEADER => true,
+ CURLOPT_SSL_VERIFYPEER => true,
+ CURLOPT_SSL_VERIFYHOST => 2,
+ CURLOPT_NOBODY => true,
+ CURLOPT_FORBID_REUSE => true,
+ CURLOPT_FRESH_CONNECT => true,
+ CURLOPT_FOLLOWLOCATION => false);
+
+ curl_setopt_array($curl, $curl_options);
+ $result = curl_exec($curl);
+
+ if ( $result !== false ) {
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+
+ if ( $http_code !== 200 ) {
+ $error = true;
+
+ $OSCOM_MessageStack->add('services', OSCOM::getDef('dashboard_error_youtube_video_id_invalid'));
+ } else {
+ $data['youtube_video_id'] = !empty($youtube_video_id) ? $youtube_video_id : null;
+ }
+ } else {
+ $error = true;
+
+ $OSCOM_MessageStack->add('services', OSCOM::getDef('dashboard_error_youtube_video_id_invalid'));
+ }
+ }
+ }
+
if ( !isset($_POST['public_url']) || empty($_POST['public_url']) ) {
$error = true;
View
8 osCommerce/OM/Custom/Site/Website/Application/Services/pages/dashboard_edit.html
@@ -59,6 +59,14 @@
</div>
<div class="control-group">
+ <label class="control-label" for="inputYouTubeVideoID"><strong>{lang}dashboard_field_youtube_video_id_title{lang}</strong></label>
+
+ <div class="controls">
+ <input type="text" id="inputYouTubeVideoID" name="youtube_video_id" value="{post}youtube_video_id|partner_campaign youtube_video_id{post}" class="span8" />
+ </div>
+ </div>
+
+ <div class="control-group">
<label class="control-label" for="inputPublicUrl"><strong>{lang}dashboard_field_public_url_title{lang}</strong> <span class="text-error">*</span></label>
<div class="controls">
View
4 osCommerce/OM/Custom/Site/Website/Application/Services/pages/info.html
@@ -11,6 +11,10 @@
<p>{nl2br}{value}partner desc_long{value}{nl2br}</p>
+{ifvalue partner youtube_video_id}
+ <div style="text-align: center; padding-bottom: 20px;"><iframe width="560" height="315" src="http://www.youtube.com/embed/{value}partner youtube_video_id{value}?rel=0" frameborder="0" allowfullscreen></iframe></div>
+{ifvalue}
+
<div class="hero-unit">
<p style="float: right;">
View
1  osCommerce/OM/Custom/Site/Website/Partner.php
@@ -123,6 +123,7 @@ public static function save($user_id, $code, $partner) {
'address' => isset($partner['address']) ? $partner['address'] : null,
'telephone' => isset($partner['telephone']) ? $partner['telephone'] : null,
'email' => isset($partner['email']) ? $partner['email'] : null,
+ 'youtube_video_id' => isset($partner['youtube_video_id']) ? $partner['youtube_video_id'] : null,
'url' => $partner['url'],
'public_url' => $partner['public_url'],
'image_small' => isset($partner['image_small']) ? $partner['image_small'] : null,
View
1  osCommerce/OM/Custom/Site/Website/SQL/ANSI/PartnerSave.php
@@ -19,6 +19,7 @@ public static function execute($data) {
'address' => $data['address'],
'telephone' => $data['telephone'],
'email' => $data['email'],
+ 'youtube_video_id' => $data['youtube_video_id'],
'url' => $data['url'],
'public_url' => $data['public_url'],
'image_promo_url' => $data['image_promo_url']);
View
1  osCommerce/OM/Custom/Site/Website/Setup/SQL/mysql.sql
@@ -87,6 +87,7 @@ CREATE TABLE osc_website_partner (
image_big varchar(255),
image_promo varchar(255),
image_promo_url varchar(255),
+ youtube_video_id varchar(255),
PRIMARY KEY (id),
KEY idx_ws_partner_title (title),
KEY idx_ws_partner_code (code),
View
3  osCommerce/OM/Custom/Site/Website/languages/en_US/Services.php
@@ -68,6 +68,7 @@
dashboard_field_address_desc = Max 255 characters; No HTML
dashboard_field_telephone_title = Telephone
dashboard_field_email_title = E-Mail
+dashboard_field_youtube_video_id_title = YouTube Video ID
dashboard_field_public_url_title = Public URL
dashboard_field_public_url_desc = Clean URL without custom tracking codes
dashboard_field_url_title = Target URL
@@ -97,6 +98,8 @@
dashboard_error_address_length = Address must not be greater than 255 characters.
dashboard_error_telephone_length = Telephone must not be greater than 255 characters.
dashboard_error_email_length = E-Mail must be valid and not be greater than 255 characters.
+dashboard_error_youtube_video_id_length = YouTube Video ID must be valid and not be greater than 255 characters.
+dashboard_error_youtube_video_id_invalid = YouTube Video ID is invalid. Please only provide the video ID and not a url.
dashboard_error_public_url_empty = Public URL must be provided.
dashboard_error_public_url_length = Public URL must not be greater than 255 characters.
dashboard_error_url_empty = Target URL must be provided.
Please sign in to comment.
Something went wrong with that request. Please try again.