function _makeFileAttached($value, $name) { global $THIS_RET, $PortalNotesFilesPath; static $filesAttachedCount = 0; static $js_included = false; $loadColorBox = false; if ($THIS_RET['ID']) { $id = $THIS_RET['ID']; if (empty($value)) { $return = ' '; } else { $filesAttachedCount++; //modif Francois: colorbox //colorbox extensions list $colorbox_list = array('.jpg', '.jpeg', '.png', '.gif', '.mp3', '.wav', '.avi', '.mp4', '.ogg'); if (in_array(mb_strtolower(mb_strrchr($value, '.')), $colorbox_list)) { if (($finfo = finfo_open(FILEINFO_MIME_TYPE)) !== false) { //modif Francois: detects if an audio or video embedded in HTML5 will be rendered //https://developer.mozilla.org/en-US/docs/Media_formats_supported_by_the_audio_and_video_elements //Checked on 2012.11.16 $browser = $_SERVER['HTTP_USER_AGENT']; $return = '<a href="' . $value . '" title="' . str_replace($PortalNotesFilesPath, '', $value) . '"><img src="assets/download.png" class="alignImg" /> ' . _('Download') . '</a>'; if (in_array(mb_strtolower(mb_strrchr($value, '.')), array('.mp3', '.mp4')) && (mb_stripos($browser, 'Firefox') || mb_stripos($browser, 'Opera'))) { return $return; } elseif (in_array(mb_strtolower(mb_strrchr($value, '.')), array('.ogg')) && mb_stripos($browser, 'MSIE')) { return $return; } elseif (in_array(mb_strtolower(mb_strrchr($value, '.')), array('.wav')) && (mb_stripos($browser, 'MSIE') || mb_stripos($browser, 'Opera'))) { return $return; } if (mb_strpos(finfo_file($finfo, $value), 'audio') !== false) { $return .= '<div><div style="display:none"><audio src="' . $value . '" preload="auto" controls class="audioHtml5" id="colorboxinline' . $filesAttachedCount . '"><p>Your browser does not support the audio element</p></audio></div>'; $return .= '<a class="colorboxinline" href="#colorboxinline' . $filesAttachedCount . '" title="' . str_replace($PortalNotesFilesPath, '', $value) . '"><img src="assets/visualize.png" class="alignImg" /> ' . _('View Online') . '</a></div>'; $loadColorBox = true; } elseif (mb_strpos(finfo_file($finfo, $value), 'video') !== false) { $return .= '<div><div style="display:none"><video src="' . $value . '" preload="auto" controls class="videoHtml5" id="colorboxinline' . $filesAttachedCount . '"><p>Your browser does not support the audio element</p></video></div>'; $return .= '<a class="colorboxinline" href="#colorboxinline' . $filesAttachedCount . '" title="' . str_replace($PortalNotesFilesPath, '', $value) . '"><img src="assets/visualize.png" class="alignImg" /> ' . _('View Online') . '</a></div>'; $loadColorBox = true; } else { $return = '<a href="' . $value . '" class="colorbox" title="' . str_replace($PortalNotesFilesPath, '', $value) . '"><img src="assets/visualize.png" class="alignImg" /> ' . _('View Online') . '</a>'; $loadColorBox = true; } } } elseif (filter_var($value, FILTER_VALIDATE_URL) !== false) { $return = '<a href="' . $value . '" title="' . $value . '" class="colorboxiframe"><img src="assets/visualize.png" class="alignImg" /> ' . _('View Online') . '</a>'; $loadColorBox = true; } else { $return = '<a href="' . $value . '" title="' . str_replace($PortalNotesFilesPath, '', $value) . '"><img src="assets/download.png" class="alignImg" /> ' . _('Download') . '</a>'; } } } else { $id = 'new'; $return = '<label><input type="radio" name="values[new][FILE_OR_EMBED]" value="FILE"> <input type="file" id="' . $name . '_FILE" name="' . $name . '_FILE" size="14" /></label><br /><br />'; $return .= '<label><input type="radio" name="values[new][FILE_OR_EMBED]" value="EMBED" onclick="javascript:document.getElementById(\'values[new][' . $name . '_EMBED]\').focus();"> ' . _('Embed Link') . ': <input type="text" id="values[new][' . $name . '_EMBED]" name="values[new][' . $name . '_EMBED]" size="14"></label>'; } if ($loadColorBox && !$js_included) { $return .= includeOnceJquery(); $return .= '<link rel="stylesheet" href="assets/js/colorbox/colorbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="assets/js/colorbox/jquery.colorbox-min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(\'.colorbox\').colorbox(); $(\'.colorboxinline\').colorbox({inline:true}); $(\'.colorboxiframe\').colorbox({iframe:true, innerWidth:425, innerHeight:344}); }); </script>'; $js_included = true; } return $return; }
function PortalPollsDisplay($value, $name) { global $THIS_RET; static $js_included = false; $poll_id = $THIS_RET['ID']; //get poll: $poll_RET = DBGet(DBQuery("SELECT EXCLUDED_USERS, VOTES_NUMBER, DISPLAY_VOTES FROM PORTAL_POLLS WHERE ID='" . $poll_id . "'")); $poll_questions_RET = DBGet(DBQuery("SELECT ID, QUESTION, OPTIONS, TYPE, VOTES FROM PORTAL_POLL_QUESTIONS WHERE PORTAL_POLL_ID='" . $poll_id . "' ORDER BY ID")); if (!$poll_RET || !$poll_questions_RET) { return ErrorMessage(array('Poll does not exist')); } //should never be displayed, so do not translate //verify if user is in excluded users list (format = '|[profile_id]:[user_id]') $profile_id = User('PROFILE_ID'); if ($profile_id != 0) { //modif Francois: call right Student/Staff ID $user_id = UserStaffID(); } else { $user_id = UserStudentID(); } $excluded_user = '******' . $profile_id . ':' . $user_id; if (mb_strpos($poll_RET[1]['EXCLUDED_USERS'], $excluded_user) !== false) { return PortalPollsVotesDisplay($poll_id, $poll_RET[1]['DISPLAY_VOTES'], $poll_questions_RET, $poll_RET[1]['VOTES_NUMBER']); } //user already voted, display votes $PollForm = ''; if (!$js_included) { $PollForm .= includeOnceJquery(); $PollForm .= '<script type="text/javascript" src="assets/js/jquery.form.js"></script>'; $PollForm .= '<script type="text/javascript"> $(document).ready(function() { $(\'.formPortalPoll\').ajaxForm({ //send the votes in AJAX success: function(data,status,xhr,form) { $(form).parent().html(data); } }); }); </script>'; $js_included = true; } $PollForm .= '<div id="divPortalPoll' . $poll_id . '" style="max-height:350px; overflow-y:auto;"><form method="POST" class="formPortalPoll" action="ProgramFunctions/PortalPolls.fnc.php"><input type="hidden" name="profile_id" value="' . $profile_id . '" /><input type="hidden" name="user_id" value="' . $user_id . '" /><input type="hidden" name="total_votes_string" value="' . _('Total Participants') . '" /><input type="hidden" name="poll_completed_string" value="' . _('Poll completed') . '" /><TABLE class="width-100p cellspacing-0">'; foreach ($poll_questions_RET as $question) { $PollForm .= '<TR><TD><b>' . $question['QUESTION'] . '</b></TD><TD><TABLE class="width-100p cellspacing-0">'; $options_array = explode('<br />', nl2br($question['OPTIONS'])); $checked = true; foreach ($options_array as $option_nb => $option_label) { if ($question['TYPE'] == 'multiple_radio') { $PollForm .= '<TR><TD><label><input type="radio" name="votes[' . $poll_id . '][' . $question['ID'] . ']" value="' . $option_nb . '" ' . ($checked ? 'checked' : '') . ' /> ' . $option_label . '</label></TD></TR>' . "\n"; } else { //multiple $PollForm .= '<TR><TD><label><input type="checkbox" name="votes[' . $poll_id . '][' . $question['ID'] . '][]" value="' . $option_nb . '" /> ' . $option_label . '</label></TD></TR>' . "\n"; } $checked = false; } $PollForm .= '</TABLE></TD></TR>'; } $PollForm .= '</TD></TR></TABLE><P><input type="submit" value="' . _('Submit') . '" /></P></form></div>'; return $PollForm; }