コード例 #1
0
function RecentImages($arg = '', $slice = 5, $timeout = 0)
{
    global $PTRevisited, $wpdb;
    // check cache
    if ($timeout > 0) {
        $filename = 'recentimages' . md5($arg);
        $dirname = get_pt_options('base_path') . '/' . get_pt_options('folder_name') . '/_cache/';
        $ret_str = pt_load_cache($filename, $dirname, $timeout);
        if ($ret_str !== false) {
            return $ret_str;
        }
    }
    $ListImages = array();
    $ListImages['pic'] = array();
    $ListImages['endDB'] = false;
    // Retrieves specific parameters
    $new_args = pt_parse_arg($arg);
    if (isset($new_args['LIMIT'])) {
        $limit = (int) $new_args['LIMIT'];
    } else {
        $limit = 10;
    }
    $offset = 0;
    $i = 0;
    while ($i < $limit) {
        $ListImages = RecentImages_sub($ListImages, $slice, $offset, $i, $limit);
        $offset = $offset + $slice;
        $i = count($ListImages['pic']);
        if ($ListImages['endDB']) {
            break;
        }
    }
    // Delete image in excess
    while (count($ListImages['pic']) > $limit) {
        array_pop($ListImages['pic']);
    }
    $ret_str = '';
    foreach ($ListImages['pic'] as $image) {
        $t = new pt_thumbnail(get_pt_options_all(), $image[0], $arg);
        // Add thumbnail & highslide expand to image
        if (POSTTHUMB_USE_HS) {
            $h = new pt_highslide($image[0], $t->thumb_url, $image[1]);
            $h->set_borders(get_pt_options('ovframe'));
            $h->set_title($image[1]);
            if (get_pt_options('caption') == 'true') {
                $h->set_caption(addslashes($image[1]));
            }
            $h->set_html_size();
            $h->set_href_text('', $add_tag);
            $ret_str .= $h->highslide_link();
            unset($h);
        } else {
            $ret_str .= '<a href="' . $image[0] . '" title="' . $image[1] . '" ><img src="' . $t->thumb_url . '" alt="' . $image[1] . '" /></a>';
        }
        unset($t);
    }
    unset($ListImages);
    if ($timeout > 0) {
        pt_save_cache($filename, $dirname, $ret_str);
    }
    return $ret_str;
}
コード例 #2
0
 function MakeThumb($ListAttr)
 {
     // Initialize parameters
     //		$the_image = NormalizeURL($ListAttr['img'].'.'.$ListAttr['ext']);
     $the_image = $ListAttr['img'] . '.' . $ListAttr['ext'];
     $ListAttr['alt'] = htmlspecialchars($ListAttr['alt']);
     $ListAttr['title'] = htmlspecialchars($ListAttr['title']);
     if ($ListAttr['align']) {
         $align = ' align="' . $ListAttr['align'] . '"';
     } else {
         $align = "";
     }
     if ($ListAttr['rel']) {
         $rel = ' rel="' . $ListAttr['rel'] . '"';
     } else {
         $rel = $this->lightbox;
     }
     // Prepare parameter for thumbnail
     $arg = 'ALTAPPEND=' . get_pt_options('p_append_text') . '&WIDTH=' . get_pt_options('p_resize_width') . '&HEIGHT=' . get_pt_options('p_resize_height') . $this->addArg;
     // Retrieve thumbnail
     $t = new pt_thumbnail(get_pt_options_all(), $the_image, $arg);
     $add_tag = $align;
     // Add thumbnail & highslide expand to image
     if (POSTTHUMB_USE_HS) {
         $h = new pt_highslide($the_image, $t->thumb_url, $ListAttr['alt']);
         $h->set_borders(get_pt_options('ovframe'));
         $h->set_title($ListAttr['title']);
         if ($this->p_has_caption) {
             $h->set_caption(addslashes($ListAttr['alt']));
         }
         $h->set_html_size();
         $h->set_href_text('', $add_tag);
         $h_str = $h->highslide_link();
         unset($h);
     } elseif (POSTTHUMB_USE_TB || POSTTHUMB_USE_SB) {
         $h = new pt_thickbox($the_image, $t->thumb_url, $ListAttr['alt']);
         $h->set_href_text('', $add_tag);
         $h_str = $h->thickbox_link();
         unset($h);
     } else {
         $h_str = '<a href="' . $the_image . '" title="' . $ListAttr['title'] . '" ' . $rel . ' ><img src="' . $t->thumb_url . '" alt="' . $ListAttr['alt'] . '"' . $align . ' /></a>';
     }
     unset($t);
     return $h_str;
 }
コード例 #3
0
 function GetImgHTML()
 {
     if ($this->def_image && $this->nodef) {
         return '';
     }
     // Starts Highslide output
     if ($this->LB_effect && $this->use_hs) {
         // If showpost true, or post doesn't has picture, and post doesn't have media
         if ($this->showpost || $this->showlink || !$this->has_image && !$this->has_media && !$this->has_youtube) {
             if ($this->showlink) {
                 $link = $this->default_link;
             } else {
                 $link = $this->post_url;
             }
             $h = new pt_highslide($link, $this->thumb_url, $this->title);
             $h->set_wrapClass('highslide-wrapper');
             $h->set_borders($this->settings['hsframe']);
             $h->set_href_text($this->img_title, $this->myclassimg . $this->align);
             $h->set_myclassimg($this->myclassimg);
             $h->set_myclasshref($this->myclasshref);
             $h->set_bottom(__('Direct link to: ', 'post-thumb') . $this->title, $link);
             $h->set_size($this->settings['hs_width'], $this->settings['hs_height'], $this->settings['hsmargin']);
             if ($this->ajax) {
                 $this->html = $h->highslide_link('ajax');
             } else {
                 $this->html = $h->highslide_link('iframe');
             }
             unset($h);
         } elseif ($this->has_media) {
             $this->html = $this->GetVideo($this->title, $this->the_default_media, $this->thumb_url, $this->settings['wordtube_pwidth'], $this->settings['wordtube_pheight']);
         } elseif ($this->has_youtube) {
             $this->html = SetYoutubeVideo($this->the_default_media, $this->title, $this->thumb_url, $this->settings, $this->myclassimg . $this->align);
         } else {
             $h = new pt_highslide($this->the_image, $this->thumb_url, $this->title);
             $h->set_borders($this->settings['ovframe']);
             $h->set_myclassimg($this->myclassimg);
             $h->set_myclasshref($this->myclasshref);
             $h->set_href_text('', $this->align);
             if ($this->has_caption) {
                 $h->set_caption(htmlspecialchars(str_replace("'", "\\'", $this->title), ENT_QUOTES));
             }
             $this->html = $h->highslide_link('overlay');
             unset($h);
         }
     } elseif ($this->LB_effect && ($this->use_tb || $this->use_sb)) {
         // If an image and showpost false
         if ($this->showpost || $this->showlink || !$this->has_image && !$this->has_media && !$this->has_youtube) {
             if ($this->showlink) {
                 $link = $this->default_link;
             } else {
                 $link = $this->post_url;
             }
             $this->html = $this->n . '<a href="' . $link . '"';
             $this->html .= ' title="' . $this->title . '"';
             if ($this->myclasshref != '') {
                 $this->html .= ' class="' . $this->myclasshref . '"';
             }
             $this->html .= '>';
             $this->html .= $this->nt . '<img src="' . $this->thumb_url . '" alt="' . $this->alt_text . '"';
             if ($this->myclassimg != '') {
                 $this->html .= $this->myclassimg;
             }
             $this->html .= ' />' . $this->n . '</a>';
             unset($h);
         } elseif ($this->has_media) {
             $this->html = $this->GetVideo($this->title, $this->the_default_media, $this->thumb_url, $this->settings['wordtube_pwidth'], $this->settings['wordtube_pheight']);
         } elseif ($this->has_youtube) {
             $this->html = SetYoutubeVideo($this->the_default_media, $this->title, $this->thumb_url, $this->settings, $this->myclassimg . $this->align);
         } else {
             $h = new pt_thickbox($this->the_image, $this->thumb_url, $this->title);
             $h->set_myclasshref($this->myclasshref);
             $this->html = $h->thickbox_link('overlay');
             unset($h);
         }
     } else {
         if ($this->showpost || !$this->has_image) {
             $this->html = $this->n . '<a href="' . $this->post_url . '"';
         } elseif ($this->showlink) {
             $this->html = $this->n . '<a href="' . $this->default_link . '"';
         } else {
             $this->html = $this->n . '<a href="' . $this->the_image . '"';
         }
         $this->html .= ' title="' . htmlspecialchars($this->title) . '"';
         if ($this->myclasshref != '') {
             $this->html .= ' class="' . $this->myclasshref . '"';
         }
         $this->html .= '>';
         $this->html .= $this->nt . '<img src="' . $this->thumb_url . '" alt="' . htmlspecialchars($this->alt_text) . '"';
         $this->html .= $this->myclassimg;
         $this->html .= $this->align;
         $this->html .= ' />' . $this->n . '</a>';
     }
     if ($this->show_title != '') {
         $this->get_add_html();
     }
     return $this->html;
 }