summaryrefslogtreecommitdiff
path: root/fellowship_testimonials.module
blob: d34ec8425f1f4408b011bde89736660855d173a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php 
    function fellowship_testimonials_menu() {
        $items = 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["intership-experience"] = array(
        "title" => "Intership Experience",
        "page callback" => "drupal_get_form",
        "page arguments" => array(
            "fellowship_testimonials_display_form"
        ),
        "access arguments" => array(
            "view fellowship_testimonials"
        ),
        "type" => MENU_NORMAL_ITEM
        );
        $items["intership-experience/year-wise"] = array( 
            "title" => "Testimonials by FOSSEE Summer Fellows year wise",
            "page callback" => "intership-experience_display_year_wise",
            "access arguments" => array("view fellowship_testimonials"),
            "type" => MENU_CALLBACK,
            'file' => 'testimonials_year_wise.inc'
        );
        $items["intership-experience/add"] = array(
            "title" => "Add intership-experience",
            "page callback" => "fellowship_testimonials_add_all",
            "access arguments" => array("manage fellowship_testimonials"),
            "type" => MENU_CALLBACK,
            'file' => 'testimonials_add.inc'
        );
        $items["intership-experience/edit"] = array(
            "title" => "Edit intership-experience",
            "page callback" => "fellowship_testimonials_edit_all",
            "access arguments" => array("manage fellowship_testimonials"),
            "type" => MENU_CALLBACK,
            'file' => 'testimonials_edit.inc'
        );
        $items["intership-experience/delete"] = array(
            "title" => "Delete intership-experience",
            "page callback" => "fellowship_testimonials_delete_all",
            "access arguments" => array("manage fellowship_testimonials"),
            "type" => MENU_CALLBACK
        );
        return $items;
    }

    function fellowship_testimonials_permission() {
        return array(
            "view fellowship_testimonials" => array (
            "title" => t("view fellowship_testimonials"),
            'restrict access' => TRUE,
            ),
            "manage fellowship_testimonials" => array (
            "title" => t("manage fellowship_testimonials"),
            'restrict access' => TRUE,
            ),
        );
    }
    function get_video_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', 'V');
         $query->orderBy('year', 'DESC');
         //$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');
            $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; size: 10px;'>";
    }
            $page_content .= "Activity name</span>: {$row->activity}
            <br><br><span>Floss</span>: {$row->fellowship_task}
            <br><br><span>Year of participation</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;
    }

    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();
        $result = $query->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='text-align:right'><span>{$speakerrow->name}</span><br>{$speakerrow->institute}, {$speakerrow->place}<br>";
   // }
            $page_content .= "{$row->fellowship_task}, {$row->activity}, {$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="#intership-experience-text">Text</a></li>
                         <li><a data-toggle="tab" href="#intership-experience-video">Video</a></li>
                      </ul>
        <div class="tab-content">

        <div id="intership-experience-text"class="tab-pane fade in active">' . get_text_testimonials() . '
        </div>
     
        <div id="intership-experience-video" class="tab-pane fade ">' . get_video_testimonials() . '
        </div>   

 </div>'
    );
    $form['lastdiv'] = array(
        '#type' => 'item',
        '#markup' => '',
        '#suffix' => '</div></div>'
    );
    return $form;
}