public function test_lightboxgallery_resize_text()
 {
     $this->assertEquals('test123', lightboxgallery_resize_text('test123', 10));
     $this->assertEquals('test123456...', lightboxgallery_resize_text('test1234567', 10));
 }
Example #2
0
function lightboxgallery_resize_label($label)
{
    return lightboxgallery_resize_text($label, MAX_IMAGE_LABEL);
}
Example #3
0
/**
 * Given a course and a time, this module should find recent activity
 * that has occurred in newmodule activities and print it out.
 * Return true if there was output, or false is there was none.
 *
 * @return boolean
 * @todo Finish documenting this function
 */
function lightboxgallery_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $DB, $CFG, $OUTPUT;
    $sql = "SELECT c.*, l.name, u.firstname, u.lastname\n              FROM {lightboxgallery_comments} c\n                   JOIN {lightboxgallery} l ON l.id = c.gallery\n                   JOIN {user}            u ON u.id = c.userid\n             WHERE c.timemodified > {$timestart} AND l.course = {$course->id}\n          ORDER BY c.timemodified ASC";
    if ($comments = $DB->get_records_sql($sql)) {
        echo $OUTPUT->heading(get_string('newgallerycomments', 'lightboxgallery') . ':', 3);
        echo '<ul class="unlist">';
        foreach ($comments as $comment) {
            $display = lightboxgallery_resize_text(trim(strip_tags($comment->comment)), MAX_COMMENT_PREVIEW);
            $output = '<li>' . ' <div class="head">' . '  <div class="date">' . userdate($comment->timemodified, get_string('strftimerecent')) . '</div>' . '  <div class="name">' . fullname($comment, $viewfullnames) . ' - ' . format_string($comment->name) . '</div>' . ' </div>' . ' <div class="info">' . '  "<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $comment->gallery . '#c' . $comment->id . '">' . $display . '</a>"' . ' </div>' . '</li>';
            echo $output;
        }
        echo '</ul>';
    }
    return true;
}
Example #4
0
 public function get_image_display_html($editing = false)
 {
     if ($this->gallery->captionfull) {
         $caption = $this->get_image_caption();
     } else {
         $caption = lightboxgallery_resize_text($this->get_image_caption(), MAX_IMAGE_LABEL);
     }
     $timemodified = strftime(get_string('strftimedatetimeshort', 'langconfig'), $this->stored_file->get_timemodified());
     $filesize = round($this->stored_file->get_filesize() / 100) / 10;
     $width = round(100 / $this->gallery->perrow);
     // Hide the caption.
     if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_HID) {
         $caption = '';
         // Hide by cleaning the content (looks better than cleaning the whole div).
     }
     $posclass = $this->gallery->captionpos == LIGHTBOXGALLERY_POS_TOP ? 'top' : 'bottom';
     $captiondiv = html_writer::tag('div', $caption, array('class' => "lightbox-gallery-image-caption {$posclass}"));
     $html = '<div class="lightbox-gallery-image-container" style="width: ' . $width . '%;">' . '<div class="lightbox-gallery-image-wrapper">' . '<div class="lightbox-gallery-image-frame">';
     if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_TOP) {
         $html .= $captiondiv;
     }
     $html .= '<a class="lightbox-gallery-image-thumbnail" href="' . $this->image_url . '" rel="lightbox_gallery" title="' . $caption . '" style="background-image: url(\'' . $this->thumb_url . '\'); width: ' . THUMBNAIL_WIDTH . 'px; height: ' . THUMBNAIL_HEIGHT . 'px;"></a>';
     if ($this->gallery->captionpos == LIGHTBOXGALLERY_POS_BOT or $this->gallery->captionpos == LIGHTBOXGALLERY_POS_HID) {
         $html .= $captiondiv;
     }
     $html .= $this->gallery->extinfo ? '<div class="lightbox-gallery-image-extinfo">' . $timemodified . '<br/>' . $filesize . 'KB ' . $this->width . 'x' . $this->height . 'px</div>' : '';
     $html .= $editing ? $this->get_editing_options() : '';
     $html .= '</div>' . '</div>' . '</div>';
     return $html;
 }