summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSashi202020-07-10 13:11:13 +0530
committerSashi202020-07-10 13:11:13 +0530
commit9ef68f741a6f47af7a1a350958387c2479295f97 (patch)
treead7e7b9f69d6724d88cbd596b183ee57d5815471
parented52d9caf03329c2956b811a364d5e0df17fdbdd (diff)
downloadfellowship_testimonials-9ef68f741a6f47af7a1a350958387c2479295f97.tar.gz
fellowship_testimonials-9ef68f741a6f47af7a1a350958387c2479295f97.tar.bz2
fellowship_testimonials-9ef68f741a6f47af7a1a350958387c2479295f97.zip
Update form to add text testimonials, display tab structure for text and video
-rwxr-xr-xfellowship_testimonials.module90
-rw-r--r--testimonials_add.inc251
-rw-r--r--testimonials_edit.inc362
-rw-r--r--testimonials_year_wise.inc37
4 files changed, 581 insertions, 159 deletions
diff --git a/fellowship_testimonials.module b/fellowship_testimonials.module
index 862f570..9424e8f 100755
--- a/fellowship_testimonials.module
+++ b/fellowship_testimonials.module
@@ -1,11 +1,29 @@
<?php
function fellowship_testimonials_menu() {
$items = array();
- $items["fellowship-testimonials"] = array(
+ /*$items["fellowship-testimonials"] = array(
"title" => "Testimonials by FOSSEE Summer Fellows",
"page callback" => "fellowship_testimonials_display_all",
"access arguments" => array("view fellowship_testimonials"),
"type" => MENU_CALLBACK
+ );*/
+ $items["fellowship-testimonials"] = array(
+ "title" => "Fellowship testimonials",
+ "page callback" => "drupal_get_form",
+ "page arguments" => array(
+ "fellowship_testimonials_display_form"
+ ),
+ "access arguments" => array(
+ "view fellowship_testimonials"
+ ),
+ "type" => MENU_NORMAL_ITEM
+ );
+ $items["fellowship-testimonials/year-wise"] = array(
+ "title" => "Testimonials by FOSSEE Summer Fellows year wise",
+ "page callback" => "fellowship_testimonials_display_year_wise",
+ "access arguments" => array("view fellowship_testimonials"),
+ "type" => MENU_CALLBACK,
+ 'file' => 'testimonials_year_wise.inc'
);
$items["fellowship-testimonials/add"] = array(
"title" => "Add fellowship testimonials",
@@ -19,7 +37,7 @@
"page callback" => "fellowship_testimonials_edit_all",
"access arguments" => array("manage fellowship_testimonials"),
"type" => MENU_CALLBACK,
- 'file' => 'testimonials_add.inc'
+ 'file' => 'testimonials_edit.inc'
);
$items["fellowship-testimonials/delete"] = array(
"title" => "Delete Testimonial",
@@ -42,7 +60,7 @@
),
);
}
- function fellowship_testimonials_display_all() {
+ function get_video_testimonials() {
$page_content = "";
/*$query = "
SELECT * FROM fellowship_testimonials
@@ -51,9 +69,10 @@
$result = pager_query($query, 4, 0, "SELECT COUNT(*) FROM fellowship_testimonials");*/
$query = db_select('fellowship_testimonials');
$query->fields('fellowship_testimonials');
+ $query->condition('testimonial_type', 'V');
$query->orderBy('year', 'DESC');
- $result = $query->extend('PagerDefault')->limit(3)->execute();
-
+ //$result = $query->extend('PagerDefault')->limit(3)->execute();
+ $result = $query->execute();
$page_content .= "<div id='fellowship_testimonials-wrapper'>";
while($row = $result->fetchObject()) {
$speakerquery = db_select('fellows');
@@ -79,7 +98,66 @@
return $page_content;
}
+ function get_text_testimonials() {
+ $page_content = "";
+ /*$query = "
+ SELECT * FROM fellowship_testimonials
+ ORDER BY id DESC
+ ";
+ $result = pager_query($query, 4, 0, "SELECT COUNT(*) FROM fellowship_testimonials");*/
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ $query->condition('testimonial_type', 'T');
+ $query->orderBy('year', 'DESC');
+ $result = $query->extend('PagerDefault')->limit(3)->execute();
+
+ $page_content .= "<div id='fellowship_testimonials-wrapper'>";
+ while($row = $result->fetchObject()) {
+ $speakerquery = db_select('fellows');
+ $speakerquery->fields('fellows');
+ $speakerquery->condition('t_id', $row->id);
+ $speakerresult = $speakerquery->execute();
+ $speakerrow = $speakerresult->fetchObject();
+ $page_content .= "
+ <div class='container-testimonial'> <p>{$row->testimonial_text}</p> ";
+ //while($speakerrow = $speakerresult->fetchObject()){
+ $page_content .= "<br><p style='float:right'><span>{$speakerrow->name}</span><br>{$speakerrow->institute}, {$speakerrow->place}<br>";
+ // }
+ $page_content .= "{$row->fellowship_task}
+ <br>{$row->year}</p></div>";
+
+ }
+ $page_content .= "</div> <!-- /#fellowship_testimonials-wrapper -->";
+ //$page_content .= theme("pager", NULL, 4, 0);
+ $page_content .= theme('pager', array('header' => NULL, 'rows' => 4 ));
+ return $page_content;
+ }
+
function fellowship_testimonials_init() {
drupal_add_css(drupal_get_path("module", "fellowship_testimonials") . "/css/fellowship_testimonials.css");
}
-?>
+function fellowship_testimonials_display_form($form, $form_state){
+ $form = array();
+ $form['tab_content'] = array(
+ '#type' => 'item',
+ '#markup' => '<ul class="nav nav-tabs">
+ <li class="active"><a data-toggle="tab" href="#fellowship-testimonials-text">Text</a></li>
+ <li><a data-toggle="tab" href="#fellowship-testimonials-video">Video</a></li>
+ </ul>
+ <div class="tab-content">
+
+ <div id="fellowship-testimonials-text"class="tab-pane fade in active">' . get_text_testimonials() . '
+ </div>
+
+ <div id="fellowship-testimonials-video" class="tab-pane fade ">' . get_video_testimonials() . '
+ </div>
+
+ </div>'
+ );
+ $form['lastdiv'] = array(
+ '#type' => 'item',
+ '#markup' => '',
+ '#suffix' => '</div></div>'
+ );
+ return $form;
+}
diff --git a/testimonials_add.inc b/testimonials_add.inc
index 43fa17b..15c95f7 100644
--- a/testimonials_add.inc
+++ b/testimonials_add.inc
@@ -5,7 +5,7 @@ function fellowship_testimonials_add_all() {
$page_content .= drupal_render($fellowship_testimonials_add_form);
return $page_content;
}
-function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0) {
+function fellowship_testimonials_add_form($form,$form_state, $no_js_use = FALSE, $testimonial_id = 0) {
$testimonial_id = arg(2);
//var_dump($testimonial_id);die;
$query = db_select('fellowship_testimonials');
@@ -20,7 +20,6 @@ function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0
'#attributes' => array(
'placeholder' => t('For eg: 2019')
),
- "#default_value" => $row->year,
"#required" => TRUE
);
$form["fellowship_task"] = array(
@@ -29,74 +28,74 @@ function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0
'#attributes' => array(
'placeholder' => t('For eg: Python, DWSIM, eSim etc')
),
- "#default_value" => $row->fellowship_task,
"#required" => TRUE
);
-
+ $form["opt_text_or_video"] = array(
+ "#type" => 'select',
+ "#title" => t('Select the type of testimonial'),
+ "#options" => array(
+ 'T' => 'Text',
+ 'V' => 'Video'
+ ),
+ "#required" => TRUE,
+ '#ajax' => array(
+ 'callback' => 'ajax_testimonial_type'
+ )
+ );
+ /*$form["testimonial_text"] = array(
+ "#type" => 'textfield',
+ //'#format' => 'full_html',
+ "#title" => t('Enter the testimonial by user'),
+ "#required" => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="opt_text_or_video"]' => array(
+ 'value' => 'T'
+ )
+ )
+ ),
+ '#default_value' => $row->testimonial_text
+ );*/
+ $form["testimonial_text"] = array(
+ "#type" => "text_format",
+ '#format' => 'full_html',
+ "#title" => "Testimonial text",
+ '#prefix' => '<div id="testimonial-text">',
+ '#suffix' => '</div>',
+ // "#required" => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="opt_text_or_video"]' => array(
+ 'value' => 'T'
+ )
+ )
+ ),
+ );
$form["testimonial_video"] = array(
"#type" => "textfield",
"#title" => "Testimonial Video",
'#attributes' => array(
'placeholder' => t('Copy paste the static url of the video, for eg: https://static.fossee.in/fossee/videos/FOSSEE_intern_Video/DSC_0006.m4v')
),
- "#default_value" => $row->testimonial_video,
'#size' => 90,
- "#required" => TRUE
+ '#prefix' => '<div id="testimonial-video">',
+ '#suffix' => '</div>',
+ //"#required" => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="opt_text_or_video"]' => array(
+ 'value' => 'V'
+ )
+ )
+ ),
);
- $query_s = db_select('fellows');
- $query_s->fields('fellows');
- $query_s->condition('t_id', $row->id);
- $result_s = $query_s->execute();
- $num_of_fellowresults = $result_s->rowCount();
$form['fellows_fieldset'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#prefix' => '<div id="fellows-fieldset-wrapper">',
'#suffix' => '</div>'
- );
-
- if ($num_of_fellowresults != 0) {
-
- $form_state['num_fellows'] = $num_of_fellowresults;
- $temp = 0;
- $i = 0;
- while ($row_s = $result_s->fetchObject()) {
- $temp = $i;
- $form['fellows_fieldset'][$i]["s_text"] = array(
- "#type" => "item",
- "#markup" => "<h4><label>fellows : " . ($temp + 1) . "</label></h4>"
- );
- $form['fellows_fieldset'][$i]["f_id"] = array(
- "#type" => "hidden",
- "#default_value" => $row_s->f_id
- );
- $form['fellows_fieldset'][$i]["fellowname"] = array(
- "#type" => "textfield",
- "#title" => "Name",
- "#default_value" => $row_s->name
- );
- $form['fellows_fieldset'][$i]["institute"] = array(
- "#type" => "textfield",
- "#title" => "Institute",
- "#default_value" => $row_s->institute
- );
- $form['fellows_fieldset'][$i]["place"] = array(
- "#type" => "textfield",
- "#title" => "Place",
- "#default_value" => $row_s->place
- );
- $i++;
- }
-
-
- $form["fellows_count"] = array(
- "#type" => "hidden",
- "#value" => $temp
- );
-
- }
- else {
+ );
if (empty($form_state['num_fellows'])) {
$form_state['num_fellows'] = 1;
}
@@ -160,12 +159,6 @@ function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0
}
unset($form['fellows_fieldset']['add_fellows']['#ajax']);
}
- }
-
- $form["testimonial_id"] = array(
- "#type" => "hidden",
- "#value" => $testimonial_id
- );
$form["submit"] = array(
"#type" => "submit",
"#value" => "Submit"
@@ -173,6 +166,22 @@ function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0
return $form;
}
+function ajax_testimonial_type($form, $form_state){
+ $type = $form_state['values']['opt_text_or_video'];
+ if($type == 'V'){
+ $commands[] = ajax_command_replace('#testimonial-video', drupal_render($form['testimonial_video']));
+ $commands[] = ajax_command_html('#testimonial-text', '');
+ }
+ else{
+ $commands[] = ajax_command_replace('#testimonial-text', drupal_render($form['testimonial_text']));
+ $commands[] = ajax_command_html('#testimonial-video', '');
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+
function fellows_add_more_callback($form, $form_state) {
return $form['fellows_fieldset'];
}
@@ -198,36 +207,36 @@ function fellows_add_more_remove_one($form, &$form_state) {
function fellowship_testimonials_add_form_submit($form, &$form_state) {
$v = $form_state["values"];
- if($v["testimonial_id"]) {
- $query = db_update('fellowship_testimonials');
- $query->fields(array(
- 'year' => $v["fellowship_year"],
- 'fellowship_task' => $v["fellowship_task"],
- 'testimonial_video' => $v["testimonial_video"]
- ));
- $query->condition('id', $v["testimonial_id"]);
- $result = $query->execute();
-
+
+ if($v['opt_text_or_video'] == 'V'){
+ $query = "
+ INSERT INTO fellowship_testimonials(year, fellowship_task, testimonial_video, testimonial_type)
+ VALUES (:year, :fellowship_task, :testimonial_video, :testimonial_type)";
+ $args = array(
+ ':year' => $v["fellowship_year"],
+ ':fellowship_task' => $v["fellowship_task"],
+ ':testimonial_video' => $v["testimonial_video"],
+ ':testimonial_type' => 'V'
+ );
+ }
+ else if($v['opt_text_or_video'] == 'T'){
+ $query = "
+ INSERT INTO fellowship_testimonials(year, fellowship_task, testimonial_text, testimonial_text_format, testimonial_type)
+ VALUES (:year, :fellowship_task, :testimonial_text, :testimonial_text_format, :testimonial_type)";
+ $args = array(
+ ':year' => $v["fellowship_year"],
+ ':fellowship_task' => $v["fellowship_task"],
+ ':testimonial_text' => $v["testimonial_text"]["value"],
+ ':testimonial_text_format' => $v["testimonial_text"]["format"],
+ ':testimonial_type' => 'T'
+ );
+ }
+ $result = db_query($query,$args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
$fellowsupload = 0;
for ($i = 0; $i <= $v["fellows_count"]; $i++) {
- $f_id=$v['fellows_fieldset'][$i]["f_id"];
- //var_dump($f_id);die;
- if ($f_id != "") {
- if ($v['fellows_fieldset'][$i]["fellowname"] != "") {
- $query = db_update('fellows');
- $query->fields(array(
- 'name' => $v['fellows_fieldset'][$i]["fellowname"],
- 'institute' => $v['fellows_fieldset'][$i]["institute"],
- 'place' => $v['fellows_fieldset'][$i]["place"]
- ));
- $query->condition('f_id', $v['fellows_fieldset'][$i]["f_id"]);
- $result = $query->execute();
- if ($result != 0) {
- $fellowsupload++;
- }
- }
- }
- else {
+ //$f_id=$v['fellows_fieldset'][$i]["f_id"];
if ($v['fellows_fieldset'][$i]["fellowname"] != "") {
$fellowsquery = "INSERT INTO fellows (t_id,name,institute,place) VALUES (:t_id,:name,:institute,:place)";
$fellowsargs = array(
@@ -245,75 +254,11 @@ function fellows_add_more_remove_one($form, &$form_state) {
}
}
}
-
- }
- }
- else {
- $query = "
- INSERT INTO fellowship_testimonials(year, fellowship_task, testimonial_video)
- VALUES (:year, :fellowship_task, :testimonial_video)";
- $args = array(
- ':year' => $v["fellowship_year"],
- ':fellowship_task' => $v["fellowship_task"],
- ':testimonial_video' => $v["testimonial_video"]
- );
-
- $result = db_query($query,$args, array(
- 'return' => Database::RETURN_INSERT_ID
- ));
//var_dump($result->name);die;
- }
if(!$result) {
drupal_set_message("Something went wrong, please try again.", "error");
} else {
drupal_set_message("Testimonial added successfully", "status");
}
drupal_goto('fellowship-testimonials/edit');
- }
-
-function fellowship_testimonials_edit_all($testimonial_id=0) {
-
- $page_content = "";
- //var_dump($testimonial_id);die;
- if($testimonial_id){
-
- $fellowship_testimonials_add_form = drupal_get_form("fellowship_testimonials_add_form", $testimonial_id);
- $page_content .= drupal_render($fellowship_testimonials_add_form);
- } else {
- $query = db_select('fellowship_testimonials');
- $query->fields('fellowship_testimonials');
- // $query->orderBy('time', 'DESC');
- //$query->condition('id', $speakerrow->t_id);
- $result = $query->execute();
-
- $headers = array(
- "Name", "Institute", "Action"
- );
- $rows = array();
- while($row = $result->fetchObject()) {
- $speakerquery = db_query("SELECT GROUP_CONCAT(name separator ', ') as name, GROUP_CONCAT(institute separator ', ') as institute FROM fellows WHERE t_id = :t_id GROUP BY t_id", array(
- ":t_id" => $row->id
- ));
- /*$speakerquery = db_select('fellows');
- $speakerquery->fields('fellows');
- $speakerquery->condition('t_id', $row->id);
- $speakerresult = $speakerquery->execute();*/
- while($speakerrow = $speakerquery->fetchObject()){
- $fellow_name = $speakerrow->name;
- $institute = $speakerrow->institute;
- }
- //$speakerrow = $speakerresult->fetchObject();
- $item = array(
- $fellow_name,
- $institute,
- l("Edit", "fellowship-testimonials/edit/{$row->id}")
- // l("Delete", "fellowship-testimonials/delete/{$row->id}")
- );
- array_push($rows, $item);
- //}
- }
- //$page_content .= theme("table", $headers, $rows);
- $page_content .= theme('table', array('header' => $headers, 'rows' => $rows ));
- }
- return $page_content;
- }
+ } \ No newline at end of file
diff --git a/testimonials_edit.inc b/testimonials_edit.inc
new file mode 100644
index 0000000..cd28d55
--- /dev/null
+++ b/testimonials_edit.inc
@@ -0,0 +1,362 @@
+<?php
+function fellowship_testimonials_edit() {
+ $page_content = "";
+ $fellowship_testimonials_edit_form = drupal_get_form("fellowship_testimonials_edit_form");
+ $page_content .= drupal_render($fellowship_testimonials_edit_form);
+ return $page_content;
+ }
+function fellowship_testimonials_edit_form($form,$form_state, $testimonial_id = 0) {
+ $testimonial_id = arg(2);
+ //var_dump($testimonial_id);die;
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ $query->condition('id', $testimonial_id);
+ $result = $query->execute();
+ $row = $result->fetchObject();
+ $form = array();
+ $form["fellowship_year"] = array(
+ "#type" => "textfield",
+ "#title" => "Enter the fellowship year participated by the fellow(s)",
+ '#attributes' => array(
+ 'placeholder' => t('For eg: 2019')
+ ),
+ "#default_value" => $row->year,
+ "#required" => TRUE,
+ '#disabled' => TRUE,
+ );
+ $form["fellowship_task"] = array(
+ "#type" => "textfield",
+ "#title" => "Enter the fellowship task done by the fellow(s)",
+ '#attributes' => array(
+ 'placeholder' => t('For eg: Python, DWSIM, eSim etc')
+ ),
+ "#default_value" => $row->fellowship_task,
+ "#required" => TRUE,
+ '#disabled' => TRUE,
+ );
+ $form["opt_text_or_video"] = array(
+ "#type" => 'select',
+ "#title" => t('Select the type of testimonial'),
+ "#options" => array(
+ 'T' => 'Text',
+ 'V' => 'Video'
+ ),
+ "#required" => TRUE,
+ '#default_value' => $row->testimonial_type,
+ '#disabled' => TRUE,
+ /*'#ajax' => array(
+ 'callback' => 'ajax_testimonial_type'
+ )*/
+ );
+ if($row->testimonial_type == 'T'){
+ $form["testimonial_text"] = array(
+ "#type" => "text_format",
+ '#format' => 'full_html',
+ "#title" => "Testimonial text",
+ "#default_value" => $row->testimonial_text,
+ '#prefix' => '<div id="testimonial-text">',
+ '#suffix' => '</div>',
+ // "#required" => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="opt_text_or_video"]' => array(
+ 'value' => 'T'
+ )
+ )
+ ),
+ );
+ }
+ else{
+ $form["testimonial_video"] = array(
+ "#type" => "textfield",
+ "#title" => "Testimonial Video",
+ '#attributes' => array(
+ 'placeholder' => t('Copy paste the static url of the video, for eg: https://static.fossee.in/fossee/videos/FOSSEE_intern_Video/DSC_0006.m4v')
+ ),
+ "#default_value" => $row->testimonial_video,
+ '#size' => 90,
+ '#prefix' => '<div id="testimonial-video">',
+ '#suffix' => '</div>',
+ //"#required" => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="opt_text_or_video"]' => array(
+ 'value' => 'V'
+ )
+ )
+ ),
+ );
+ }
+ $query_s = db_select('fellows');
+ $query_s->fields('fellows');
+ $query_s->condition('t_id', $row->id);
+ $result_s = $query_s->execute();
+ $num_of_fellowresults = $result_s->rowCount();
+
+ $form['fellows_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#tree' => TRUE,
+ '#prefix' => '<div id="fellows-fieldset-wrapper">',
+ '#suffix' => '</div>'
+ );
+
+ if ($num_of_fellowresults != 0) {
+
+ $form_state['num_fellows'] = $num_of_fellowresults;
+ $temp = 0;
+ $i = 0;
+ while ($row_s = $result_s->fetchObject()) {
+ $temp = $i;
+ $form['fellows_fieldset'][$i]["s_text"] = array(
+ "#type" => "item",
+ "#markup" => "<h4><label>fellows : " . ($temp + 1) . "</label></h4>"
+ );
+ $form['fellows_fieldset'][$i]["f_id"] = array(
+ "#type" => "hidden",
+ "#default_value" => $row_s->f_id
+ );
+ $form['fellows_fieldset'][$i]["fellowname"] = array(
+ "#type" => "textfield",
+ "#title" => "Name",
+ "#default_value" => $row_s->name
+ );
+ $form['fellows_fieldset'][$i]["institute"] = array(
+ "#type" => "textfield",
+ "#title" => "Institute",
+ "#default_value" => $row_s->institute
+ );
+ $form['fellows_fieldset'][$i]["place"] = array(
+ "#type" => "textfield",
+ "#title" => "Place",
+ "#default_value" => $row_s->place
+ );
+ $i++;
+ }
+
+
+ $form["fellows_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp
+ );
+
+ }
+ else {
+ if (empty($form_state['num_fellows'])) {
+ $form_state['num_fellows'] = 1;
+ }
+ $temp = 0;
+ for ($i = 0; $i < $form_state['num_fellows']; $i++) {
+ $temp = $i;
+ $form['fellows_fieldset'][$i]["s_text"] = array(
+ "#type" => "item",
+ "#markup" => "<h4><label>fellows : " . ($temp + 1) . "</label></h4>"
+ );
+ $form['fellows_fieldset'][$i]["fellowname"] = array(
+ "#type" => "textfield",
+ "#title" => "Name",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["institute"] = array(
+ "#type" => "textfield",
+ "#title" => "University",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["place"] = array(
+ "#type" => "textfield",
+ "#title" => "Place",
+ "#default_value" => ""
+ );
+
+ }
+ $form["fellows_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp
+ );
+ $form['fellows_fieldset']['add_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add fellow'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_add_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ if ($form_state['num_fellows'] > 1) {
+ $form['fellows_fieldset']['remove_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Remove'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_remove_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ }
+ if ($no_js_use) {
+ if (!empty($form['fellows_fieldset']['remove_fellows']['#ajax'])) {
+ unset($form['fellows_fieldset']['remove_fellows']['#ajax']);
+ }
+ unset($form['fellows_fieldset']['add_fellows']['#ajax']);
+ }
+ }
+
+ $form["testimonial_id"] = array(
+ "#type" => "hidden",
+ "#value" => $testimonial_id
+ );
+ $form["submit"] = array(
+ "#type" => "submit",
+ "#value" => "Submit"
+ );
+ return $form;
+ }
+
+/*function ajax_testimonial_type($form, $form_state){
+ $type = $form_state['values']['opt_text_or_video'];
+ if($type == 'V'){
+ $commands[] = ajax_command_replace('#testimonial-video', drupal_render($form['testimonial_video']));
+ $commands[] = ajax_command_html('#testimonial-text', '');
+ }
+ else{
+ $commands[] = ajax_command_replace('#testimonial-text', drupal_render($form['testimonial_text']));
+ $commands[] = ajax_command_html('#testimonial-video', '');
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}*/
+
+ function fellows_add_more_callback($form, $form_state) {
+ return $form['fellows_fieldset'];
+}
+
+
+function fellows_add_more_add_one($form, &$form_state) {
+ $form_state['num_fellows']++;
+ $form_state['rebuild'] = TRUE;
+ //$form_state['no_redirect'] = TRUE;
+}
+
+
+function fellows_add_more_remove_one($form, &$form_state) {
+ if ($form_state['num_fellows'] > 1) {
+ $form_state['num_fellows']--;
+ }
+ $form_state['rebuild'] = TRUE;
+}
+
+ function fellowship_testimonials_edit_form_validate($form, &$form_state) {
+ // for future use
+ }
+
+ function fellowship_testimonials_edit_form_submit($form, &$form_state) {
+ $v = $form_state["values"];
+ if($v['opt_text_or_video'] == 'V'){
+ $query = db_update('fellowship_testimonials');
+ $query->fields(array(
+ 'year' => $v["fellowship_year"],
+ 'fellowship_task' => $v["fellowship_task"],
+ 'testimonial_video' => $v["testimonial_video"]
+ ));
+ }
+ else if($v['opt_text_or_video'] == 'T'){
+ $query = db_update('fellowship_testimonials');
+ $query->fields(array(
+ 'year' => $v["fellowship_year"],
+ 'fellowship_task' => $v["fellowship_task"],
+ 'testimonial_text' => $v["testimonial_text"],
+ 'testimonial_text_format' => $v["testimonial_text_format"]
+ ));
+ }
+ $query->condition('id', $v["testimonial_id"]);
+ $result = $query->execute();
+
+ $fellowsupload = 0;
+ for ($i = 0; $i <= $v["fellows_count"]; $i++) {
+ $f_id=$v['fellows_fieldset'][$i]["f_id"];
+ //var_dump($f_id);die;
+ if ($f_id != "") {
+ if ($v['fellows_fieldset'][$i]["fellowname"] != "") {
+ $query = db_update('fellows');
+ $query->fields(array(
+ 'name' => $v['fellows_fieldset'][$i]["fellowname"],
+ 'institute' => $v['fellows_fieldset'][$i]["institute"],
+ 'place' => $v['fellows_fieldset'][$i]["place"]
+ ));
+ $query->condition('f_id', $v['fellows_fieldset'][$i]["f_id"]);
+ $result = $query->execute();
+ if ($result != 0) {
+ $fellowsupload++;
+ }
+ }
+ }
+ }
+ if(!$result) {
+ drupal_set_message("Something went wrong, please try again.", "error");
+ } else {
+ drupal_set_message("Testimonial updated successfully", "status");
+ }
+ drupal_goto('fellowship-testimonials/edit');
+ }
+
+function fellowship_testimonials_edit_all($testimonial_id=0) {
+
+ $page_content = "";
+ //var_dump($testimonial_id);die;
+ if($testimonial_id){
+
+ $fellowship_testimonials_edit_form = drupal_get_form("fellowship_testimonials_edit_form", $testimonial_id);
+ $page_content .= drupal_render($fellowship_testimonials_edit_form);
+ } else {
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ // $query->orderBy('time', 'DESC');
+ //$query->condition('id', $speakerrow->t_id);
+ $result = $query->execute();
+
+ $headers = array(
+ "Name", "Institute", "Type", "Action"
+ );
+
+ $rows = array();
+ while($row = $result->fetchObject()) {
+ $speakerquery = db_query("SELECT GROUP_CONCAT(name separator ', ') as name, GROUP_CONCAT(institute separator ', ') as institute FROM fellows WHERE t_id = :t_id GROUP BY t_id", array(
+ ":t_id" => $row->id
+ ));
+ if($row->testimonial_type == 'T'){
+ $testimonial_type = "Text";
+ }
+ else{
+ $testimonial_type = "Video";
+ }
+ /*$speakerquery = db_select('fellows');
+ $speakerquery->fields('fellows');
+ $speakerquery->condition('t_id', $row->id);
+ $speakerresult = $speakerquery->execute();*/
+ while($speakerrow = $speakerquery->fetchObject()){
+ $fellow_name = $speakerrow->name;
+ $institute = $speakerrow->institute;
+ }
+ //$speakerrow = $speakerresult->fetchObject();
+ $item = array(
+ $fellow_name,
+ $institute,
+ $testimonial_type,
+ l("Edit", "fellowship-testimonials/edit/{$row->id}")
+ // l("Delete", "fellowship-testimonials/delete/{$row->id}")
+ );
+ array_push($rows, $item);
+ //}
+ }
+ //$page_content .= theme("table", $headers, $rows);
+ $page_content .= theme('table', array('header' => $headers, 'rows' => $rows ));
+ }
+ return $page_content;
+ }
diff --git a/testimonials_year_wise.inc b/testimonials_year_wise.inc
new file mode 100644
index 0000000..527bfcc
--- /dev/null
+++ b/testimonials_year_wise.inc
@@ -0,0 +1,37 @@
+<?php
+function fellowship_testimonials_display_year_wise($year) {
+ $page_content = "";
+ /*$query = "
+ SELECT * FROM fellowship_testimonials
+ ORDER BY id DESC
+ ";
+ $result = pager_query($query, 4, 0, "SELECT COUNT(*) FROM fellowship_testimonials");*/
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ $query->orderBy('year', $year);
+ $result = $query->extend('PagerDefault')->limit(3)->execute();
+
+ $page_content .= "<div id='fellowship_testimonials-wrapper'>";
+ while($row = $result->fetchObject()) {
+ $speakerquery = db_select('fellows');
+ $speakerquery->fields('fellows');
+ $speakerquery->condition('t_id', $row->id);
+ $speakerresult = $speakerquery->execute();
+
+ $page_content .= "
+ <div class='container-testimonial'>
+ <video title='' controls='' preload='' data-setup='{}' width='500' height='400'>
+ <source src={$row->testimonial_video} type='video/mp4'>
+ </video> ";
+ while($speakerrow = $speakerresult->fetchObject()){
+ $page_content .= "<p><span>{$speakerrow->name}</span><br>Institute: {$speakerrow->institute}, {$speakerrow->place}<br><br><span style='margin-right:0;'>";
+ }
+ $page_content .= "Fellowship task</span>: {$row->fellowship_task}
+ <br><br><span>Fellowship Year</span>: {$row->year}</p></div>";
+
+ }
+ $page_content .= "</div> <!-- /#fellowship_testimonials-wrapper -->";
+ //$page_content .= theme("pager", NULL, 4, 0);
+ $page_content .= theme('pager', array('header' => NULL, 'rows' => 4 ));
+ return $page_content;
+ } \ No newline at end of file