Beispiel #1
0
function list_videos()
{
    global $id, $tool_content, $themeimg, $course_id, $langTitle, $langDescr, $langDate, $langChoice, $langCatVideoDirectory, $langAddModulesButton, $langNoVideo, $course_code;
    $count = 0;
    $video_found = FALSE;
    $cnt1 = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM video WHERE course_id = ?d", $course_id)->cnt;
    $cnt2 = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM videolink WHERE course_id = ?d", $course_id)->cnt;
    $count = $cnt1 + $cnt2;
    if ($count > 0) {
        $video_found = TRUE;
        $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />";
        $tool_content .= "<table class='table-default'>";
        $tool_content .= "<tr>" . "<th width='200' class='text-left'>&nbsp;{$langTitle}</th>" . "<th class='text-left'>{$langDescr}</th>" . "<th width='100'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
        foreach (array('video', 'videolink') as $table) {
            $result = Database::get()->queryArray("SELECT * FROM {$table} WHERE (category IS NULL OR category = 0) AND course_id = ?d", $course_id);
            foreach ($result as $row) {
                $row->course_id = $course_id;
                if ($table == 'video') {
                    $vObj = MediaResourceFactory::initFromVideo($row);
                    $videolink = MultimediaHelper::chooseMediaAhref($vObj);
                } else {
                    $vObj = MediaResourceFactory::initFromVideoLink($row);
                    $videolink = MultimediaHelper::chooseMedialinkAhref($vObj);
                }
                $tool_content .= "<td>&nbsp;" . icon('fa-film') . "&nbsp;&nbsp;" . $videolink . "</td>" . "<td>" . q($row->description) . "</td>" . "<td class='text-center'>" . nice_format($row->date, true, true) . "</td>" . "<td class='text-center'><input type='checkbox' name='video[]' value='{$table}:{$row->id}' /></td>" . "</tr>";
            }
        }
        $sql = Database::get()->queryArray("SELECT * FROM video_category WHERE course_id = ?d ORDER BY name", $course_id);
        if ($sql) {
            $tool_content .= "<tr><td colspan='3' class='bold'>&nbsp;{$langCatVideoDirectory}</td></tr>";
            foreach ($sql as $videocat) {
                $tool_content .= "<tr>";
                $tool_content .= "<td>" . icon('fa-folder-o') . "&nbsp;&nbsp;" . q($videocat->name) . "</td>";
                $tool_content .= "<td colspan='2'>" . standard_text_escape($videocat->description) . "</td>";
                $tool_content .= "<td align='center'><input type='checkbox' name='videocatlink[]' value='{$videocat->id}' /></td>";
                $tool_content .= "</tr>";
                foreach (array('video', 'videolink') as $table) {
                    $sql2 = Database::get()->queryArray("SELECT * FROM {$table} WHERE category = ?d", $videocat->id);
                    foreach ($sql2 as $linkvideocat) {
                        $tool_content .= "<tr>";
                        $tool_content .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;<img src='{$themeimg}/links_on.png' />&nbsp;&nbsp;<a href='" . q($linkvideocat->url) . "' target='_blank'>" . q($linkvideocat->title == '' ? $linkvideocat->url : $linkvideocat->title) . "</a></td>";
                        $tool_content .= "<td>" . standard_text_escape($linkvideocat->description) . "</td>";
                        $tool_content .= "<td class='text-center'>" . nice_format($linkvideocat->date, true, true) . "</td>";
                        $tool_content .= "<td class='text-center'><input type='checkbox' name='video[]' value='{$table}:{$linkvideocat->id}' /></td>";
                        $tool_content .= "</tr>";
                    }
                }
            }
        }
        $tool_content .= "<tr><th colspan='4'><div align='right'><input class='btn btn-primary' type='submit' name='submit_video' value='" . q($langAddModulesButton) . "' />&nbsp;&nbsp;</div></th></tr></table></form>";
    }
    if (!$video_found) {
        $tool_content .= "<div class='alert alert-warning'>{$langNoVideo}</div>";
    }
}
Beispiel #2
0
/**
 * @brief display resource video category
 * @global type $is_editor
 * @global type $course_id
 * @global type $langInactiveModule
 * @param array $table
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $videolinkcat_id
 * @param type $visibility
 * @return string
 */
function show_videocat($table, $title, $comments, $resource_id, $videolinkcat_id, $visibility)
{
    global $is_editor, $course_id, $langInactiveModule;
    $content = $linkcontent = '';
    $module_visible = visible_module(MODULE_ID_VIDEO);
    // checks module visibility
    if (!$module_visible and !$is_editor) {
        return '';
    }
    $comment_box = $class_vis = $imagelink = $link = '';
    $class_vis = ($visibility == 0 or !$module_visible) ? ' class="not_visible"' : ' ';
    $title = q($title);
    $sql = Database::get()->queryArray("SELECT * FROM video_category WHERE id = ?d AND course_id = ?d", $videolinkcat_id, $course_id);
    foreach ($sql as $vlcat) {
        $content .= "\n            <tr{$class_vis}>\n              <td width='1'>" . icon('fa-folder-o') . "</td>\n              <td>" . q($vlcat->name);
        if (!empty($vlcat->description)) {
            $comment_box = "<br />{$vlcat->description}";
        } else {
            $comment_box = '';
        }
        foreach (array('video', 'videolink') as $table) {
            $sql2 = Database::get()->queryArray("SELECT * FROM {$table} WHERE category = ?d AND course_id = ?d", $vlcat->id, $course_id);
            foreach ($sql2 as $row) {
                if (!$is_editor and !resource_access(1, $row->public)) {
                    return '';
                }
                $status = $row->public;
                if ($table == 'video') {
                    $vObj = MediaResourceFactory::initFromVideo($row);
                    $videolink = MultimediaHelper::chooseMediaAhref($vObj);
                } else {
                    $vObj = MediaResourceFactory::initFromVideoLink($row);
                    $videolink = MultimediaHelper::chooseMedialinkAhref($vObj);
                }
                if (!$module_visible) {
                    $videolink .= " <i>({$langInactiveModule})</i>";
                }
                if (!empty($comments)) {
                    $comment_box = "<br />{$comments}";
                } else {
                    $comment_box = "";
                }
                $class_vis = ($visibility == 0 or !$module_visible or $status == 'del') ? ' class="not_visible"' : ' ';
                $ltitle = q($row->title == '' ? $row->url : $row->title);
                $linkcontent .= "<br />" . icon('fa-film') . "&nbsp;&nbsp;{$videolink}</a>";
                if (!$module_visible) {
                    $linkcontent .= " <i>({$langInactiveModule})</i>";
                }
            }
        }
    }
    return $content . $comment_box . $linkcontent . '
           </td>' . actions('videolinkcategory', $resource_id, $visibility) . '</tr>';
}
Beispiel #3
0
/**
 * @brief display multimedia files
 * @global type $langName
 * @global type $langSelection
 * @global type $langAddModulesButton
 * @global type $course_code
 * @return string
 */
function showmedia() {
    global $langName, $langSelection, $langAddModulesButton, $course_code, $course_id;
        
    $output = "<form action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='POST'>
               <div class='table-responsive'>
               <table class='table-default'>
               <thead>
               <tr class='list-header'>
               <th>$langName</th>
               <th width='50'>$langSelection</th>
               </tr>
               </thead>
               <tbody>";

    $i = 1;
    $resultMedia = Database::get()->queryArray("SELECT * FROM video WHERE visible = 1 AND course_id = ?d ORDER BY title", $course_id);
    foreach ($resultMedia as $myrow) {
        $vObj = MediaResourceFactory::initFromVideo($myrow);

        $output .= "<tr>                    
                    <td align='text-left'>" . MultimediaHelper::chooseMediaAhref($vObj) . "
                    <br />
                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMedia_" . $i . "' id='insertMedia_" . $i . "' value='" . $myrow->id . "' /></div></td></tr>";
        $i++;
    }

    $j = 1;
    $resultMediaLinks = Database::get()->queryArray("SELECT * FROM videolink WHERE visible = 1 AND course_id = ?d ORDER BY title", $course_id);
    foreach ($resultMediaLinks as $myrow) {
        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
        $output .= "<tr>                    
                    <td align='left' valign='top'>" . MultimediaHelper::chooseMedialinkAhref($vObj) . "
                    <br />
                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMediaLink_" . $j . "' id='insertMediaLink_" . $j . "' value='" . $myrow->id . "' /></div></td></tr>";
        $j++;
    }

    $output .= "
                </tbody>
                <tfooter>
                <tr>
                <th colspan='3'>
                <div align='right'>
                  <input type='hidden' name='maxMediaForm' value ='" . ($i + $j - 2) . "' />
                  <input class='btn btn-primary' type='submit' name='submitInsertedMedia' value='$langAddModulesButton'/>
                </div></th>
                </tr>
                </tfooter>
                </table>
                </div>
                </form>";
    return $output;
}
Beispiel #4
0
function showmedia()
{
    global $langName, $langSelection, $langAddModulesButton, $course_code, $themeimg;
    $sqlMedia = "SELECT * FROM video WHERE visible = 1 ORDER BY title";
    $sqlMediaLinks = "SELECT * FROM videolink WHERE visible = 1 ORDER BY title";
    $output = "<form action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' method='POST'>\n               <table width='100%' class='tbl_alt'>\n               <tr>\n               <th colspan='2'>{$langName}</th>\n               <th width='50'>{$langSelection}</th>\n               </tr>\n               <tbody>";
    $i = 1;
    $resultMedia = Database::get()->queryArray($sqlMedia);
    foreach ($resultMedia as $myrow) {
        $vObj = MediaResourceFactory::initFromVideo($myrow);
        $output .= "<tr>\n                    <td width='1' valign='top'><img src='{$themeimg}/arrow.png' border='0'></td>\n                    <td align='left' valign='top'>" . MultimediaHelper::chooseMediaAhref($vObj) . "\n                    <br />\n                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMedia_" . $i . "' id='insertMedia_" . $i . "' value='" . $myrow->id . "' /></div></td></tr>";
        $i++;
    }
    $j = 1;
    $resultMediaLinks = Database::get()->queryArray($sqlMediaLinks);
    foreach ($resultMediaLinks as $myrow) {
        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
        $output .= "<tr>\n                    <td width='1' valign='top'><img src='{$themeimg}/arrow.png' border='0'></td>\n                    <td align='left' valign='top'>" . MultimediaHelper::chooseMedialinkAhref($vObj) . "\n                    <br />\n                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMediaLink_" . $j . "' id='insertMediaLink_" . $j . "' value='" . $myrow->id . "' /></div></td></tr>";
        $j++;
    }
    $output .= "<tr>\n                <th colspan='3'>\n                <div align='right'>\n                  <input type='hidden' name='maxMediaForm' value ='" . ($i + $j - 2) . "' />\n                  <input class='btn btn-primary' type='submit' name='submitInsertedMedia' value='{$langAddModulesButton}'/>\n                </div></th>\n                </tr>\n                </tbody>\n                </table>\n                </form>";
    return $output;
}
Beispiel #5
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langViewHide
 * @global type $langViewShow
 * @global type $langPreview
 * @global type $langDownload
 * @global type langResourceAccessLock
 * @global type langResourceAccessUnlock
 * @global type $langEditChange
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0) {
    global $course_id, $is_in_tinymce, $tool_content, $is_editor, $course_code,
        $langDelete, $langViewHide, $langViewShow, $langConfirmDelete,
        $display_tools, $is_in_tinymce, $langDownload, $langResourceAccessLock,
        $langResourceAccessUnlock, $langEditChange, $filterv, $filterl, $order,
        $compatiblePlugin, $langcreator, $langpublisher;

    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
    }

    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL() . '&amp;attachment';
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr $row_class><td class='nocategory-link'>" . $link_href;
                if (!$is_in_tinymce and ( !empty($myrow->creator) or ! empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "$langcreator: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "$langcreator: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "$langpublisher: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= "</small>";
                }
                $tool_content .= "</td>
                    <td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td>";
                if (!$is_in_tinymce) {
                    if ($display_tools) {
                        $tool_content .= "<td class='option-btn-cell'>" .
                            action_button(array(
                                array('title' => $langEditChange,
                                     'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;table_edit=$table",
                                     'icon' => 'fa-edit',
                                     'show' => !$is_in_tinymce and $is_editor),
                                array('title' => $myrow->visible ? $langViewHide : $langViewShow,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;vis=" .
                                          ($myrow->visible ? '0' : '1'),
                                      'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'),
                                array('title' => $myrow->public ? $langResourceAccessLock : $langResourceAccessUnlock,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;" .
                                         ($myrow->public ? 'limited=1' : 'public=1'),
                                      'icon' => $myrow->public ? 'fa-lock' : 'fa-unlock',
                                      'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN),
                                array('title' => $langDownload,
                                      'url' => $link_to_save,
                                      'icon' => 'fa-download'),
                                array('title' => $langDelete,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;delete=yes&amp;table=$table",
                                      'icon' => 'fa-times',
                                      'confirm' => $langConfirmDelete,
                                      'class' => 'delete'))) .
                            "</td>";
                    } else {
                        $tool_content .= "<td class='text-center'>" .
                            ($table == 'video'? icon('fa-download', $langDownload, $link_to_save): '&nbsp;') .
                            '</td>';
                    }
                }
                $tool_content .= "</tr>";
            } // end of check resource access
        } // foreach row
    } // foreach table
}
Beispiel #6
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langVisible
 * @global type $langPreview
 * @global type $langSave
 * @global type $langResourceAccess
 * @global type $langResourceAccess
 * @global type $langModify
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0)
{
    global $course_id, $is_in_tinymce, $themeimg, $tool_content, $is_editor, $course_code;
    global $langDelete, $langVisible, $langConfirmDelete;
    global $langPreview, $langSave, $langResourceAccess, $langResourceAccess, $langModify;
    global $filterv, $filterl, $compatiblePlugin, $langcreator, $langpublisher;
    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
    }
    $i = 0;
    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) {
                            // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL();
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr {$row_class}><td>" . $link_href;
                if (!$is_in_tinymce and (!empty($myrow->creator) or !empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "{$langcreator}: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "{$langcreator}: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "{$langpublisher}: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= '</small>';
                }
                $tool_content .= "</td><td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td><td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;delete=yes&amp;table={$table}", 'icon' => 'fa-times', 'confirm' => $langConfirmDelete, 'class' => 'delete'), array('title' => $langSave, 'url' => $link_to_save, 'icon' => 'fa-floppy-o'), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;table_edit={$table}", 'icon' => 'fa-edit', 'show' => !$is_in_tinymce and $is_editor), array('title' => $langVisible, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;vis=" . ($myrow->visible ? '0' : '1'), 'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'), array('title' => $langResourceAccess, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;" . ($myrow->public ? 'limited=1' : 'public=1'), 'icon' => $myrow->public ? 'fa-unlock' : 'fa-lock', 'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN))) . "</td></tr>";
            }
            // end of check resource access
        }
        // foreach row
    }
    // foreach table
}