Skip to content

Instantly share code, notes, and snippets.

@zroger
Created April 2, 2012 13:57
Show Gist options
  • Save zroger/2283606 to your computer and use it in GitHub Desktop.
Save zroger/2283606 to your computer and use it in GitHub Desktop.
diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.info b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.info
index 64079f2..9bd3f8f 100755
--- a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.info
+++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.info
@@ -7,3 +7,5 @@ core = "7.x"
dependencies[] = "elc_video"
#dependencies[] = "template_api"
#dependencies[] = "template_mustache"
+
+files[] = "plugins/input_types/video.inc"
diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.install b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.install
index 5db7034..7262516 100755
--- a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.install
+++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.install
@@ -161,6 +161,11 @@ function elc_video_content_field_schema($field) {
'length' => 255,
'not null' => TRUE,
),
+ 'cue_subtitle' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ ),
);
$indexes = array(
'cue_points' => array(
diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.module b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.module
index 22791e0..03f7256 100755
--- a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.module
+++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/elc_video_content.module
@@ -344,6 +344,12 @@ function elc_video_content_field_widget_form(&$form, &$form_state, $field, $inst
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['cue_pid']) ? $items[$delta]['cue_pid'] : '',
),
+ 'cue_subtitle' => array(
+ '#title' => t('Subtitle'),
+ '#description' => t('Subtitle to display at this point'),
+ '#type' => 'textarea',
+ '#default_value' => isset($items[$delta]['cue_subtitle']) ? $items[$delta]['cue_subtitle'] : '',
+ ),
);
break;
}
@@ -410,6 +416,20 @@ function elc_video_content_menu() {
return $items;
}
+/**
+ * Implements hook_template_api_input_types()
+ * add Video to the list of template field input types
+ */
+function elc_video_content_template_api_input_types() {
+ $plugins = array();
+
+ $plugins['video'] = array(
+ 'class' => 'ELCVideoContentTemplateApiInputType',
+ 'label' => t('Video'),
+ );
+ return $plugins;
+}
+
/*
* Construct the settings page to hold the video player options for the js
diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.inc b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.inc
new file mode 100644
index 0000000..10db3f0
--- /dev/null
+++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.inc
@@ -0,0 +1,57 @@
+<?php
+
+class ELCVideoContentTemplateApiInputType extends TemplateApiInputType {
+
+ public function form($input_definition, $input_values) {
+ $form = array();
+
+ $form['nid'] = array(
+ '#type' => 'select',
+ '#title' => $input_definition['label'],
+ '#options' => $this->getVideos(),
+ );
+
+ return $form;
+ }
+
+ public function getVideos() {
+
+ global $language;
+ $site_language = $language->language;
+ $base_language = explode('-', $site_language, 1);
+
+ $query = new EntityFieldQuery;
+
+ $query
+ ->entityCondition('entity_type', 'node')
+ ->entityCondition('bundle', 'elc_video_content')
+ ->propertyCondition('status', 1)
+ ->propertyCondition('language', $site_language)
+ ->propertyCondition('language', $base_language);
+
+ $result = $query->execute();
+ $nids = array_keys($result['node']);
+ $videos = node_load_multiple($nids);
+
+ $video_menu = array(0 => 'Select video');
+ foreach ($videos as $video) {
+ $video_menu[$video->nid] = $video->title;
+ }
+ return $video_menu;
+ }
+
+ public function getVariable($input_definition, $input_values) {
+ if($input_values['nid'] == 0) {
+ return;
+ }
+ $data = node_load($input_values['nid']);
+return 'now all we need is a template to run $data through';
+ // run $data through a template and return it
+ //return new PerlgemProductMustacheView($data);
+ }
+
+ public function isEmpty($input_definition, $input_values) {
+ return empty($input_values['nid']);
+ }
+
+}
diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.pm b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.pm
new file mode 100644
index 0000000..bb7aa80
--- /dev/null
+++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_video_content/plugins/input_types/video.pm
@@ -0,0 +1,24 @@
+<?php
+
+class ELCVideoContentTemplateApiInputType extends TemplateApiInputType {
+ public function form($input_definition, $input_values) {
+ $form = array();
+
+ $form['_id'] = array(
+ '#type' => 'textfield',
+ '#title' => $input_definition['label'],
+ '#default_value' => 'hi'; //isset($input_values['product_id']) ? $input_values['product_id'] : '',
+ );
+
+ return $form;
+ }
+
+ public function getVariable($input_definition, $input_values) {
+ $data = perlgem_request()->getProduct($input_values['product_id']);
+ return new PerlgemProductMustacheView($data);
+ }
+
+ public function isEmpty($input_definition, $input_values) {
+ return empty($input_values['product_id']);
+ }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment