本文整理汇总了PHP中nggGallery::get_thumbnail_folder方法的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery::get_thumbnail_folder方法的具体用法?PHP nggGallery::get_thumbnail_folder怎么用?PHP nggGallery::get_thumbnail_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggGallery
的用法示例。
在下文中一共展示了nggGallery::get_thumbnail_folder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_thumbnail_url
/**
* get the thumbnail url to the image
*/
static function get_thumbnail_url($imageID, $picturepath = '', $fileName = '')
{
// get the complete url to the thumbnail
global $wpdb;
// safety first
$imageID = (int) $imageID;
// get gallery values
if (empty($fileName)) {
list($fileName, $picturepath) = $wpdb->get_row("SELECT p.filename, g.path FROM {$wpdb->nggpictures} AS p INNER JOIN {$wpdb->nggallery} AS g ON (p.galleryid = g.gid) WHERE p.pid = '{$imageID}' ", ARRAY_N);
}
if (empty($picturepath)) {
$picturepath = $wpdb->get_var("SELECT g.path FROM {$wpdb->nggpictures} AS p INNER JOIN {$wpdb->nggallery} AS g ON (p.galleryid = g.gid) WHERE p.pid = '{$imageID}' ");
}
// set gallery url
$folder_url = site_url() . '/' . $picturepath . nggGallery::get_thumbnail_folder($picturepath, FALSE);
$thumbnailURL = $folder_url . 'thumbs_' . $fileName;
return $thumbnailURL;
}
示例2: import_gallery
/**
* nggAdmin::import_gallery()
* TODO: Check permission of existing thumb folder & images
*
* @class nggAdmin
* @param string $galleryfolder contains relative path to the gallery itself
* @return void
*/
function import_gallery($galleryfolder)
{
global $wpdb, $user_ID;
// get the current user ID
get_currentuserinfo();
$created_msg = '';
// remove trailing slash at the end, if somebody use it
if (substr($galleryfolder, -1) == '/') {
$galleryfolder = substr($galleryfolder, 0, -1);
}
$gallerypath = WINABSPATH . $galleryfolder;
if (!is_dir($gallerypath)) {
nggGallery::show_error(__('Directory', 'nggallery') . ' <strong>' . $gallerypath . '</strong> ' . __('doesn`t exist!', 'nggallery'));
return;
}
// read list of images
$new_imageslist = nggAdmin::scandir($gallerypath);
if (empty($new_imageslist)) {
nggGallery::show_message(__('Directory', 'nggallery') . ' <strong>' . $gallerypath . '</strong> ' . __('contains no pictures', 'nggallery'));
return;
}
// check & create thumbnail folder
if (!nggGallery::get_thumbnail_folder($gallerypath)) {
return;
}
// take folder name as gallery name
$galleryname = basename($galleryfolder);
$galleryname = apply_filters('ngg_gallery_name', $galleryname);
// check for existing gallery folder
$gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' ");
if (!$gallery_id) {
$result = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->nggallery} (name, path, title, author) VALUES (%s, %s, %s, %s)", $galleryname, $galleryfolder, $galleryname, $user_ID));
if (!$result) {
nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery'));
return;
}
$created_msg = _n('Gallery', 'Galleries', 1, 'nggallery') . ' <strong>' . $galleryname . '</strong> ' . __('successfully created!', 'nggallery') . '<br />';
$gallery_id = $wpdb->insert_id;
// get index_id
}
// Look for existing image list
$old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' ");
// if no images are there, create empty array
if ($old_imageslist == NULL) {
$old_imageslist = array();
}
// check difference
$new_images = array_diff($new_imageslist, $old_imageslist);
// all images must be valid files
foreach ($new_images as $key => $picture) {
if (!@getimagesize($gallerypath . '/' . $picture)) {
unset($new_images[$key]);
@unlink($gallerypath . '/' . $picture);
}
}
// add images to database
$image_ids = nggAdmin::add_Images($gallery_id, $new_images);
//add the preview image if needed
nggAdmin::set_gallery_preview($gallery_id);
// now create thumbnails
nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
//TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
nggGallery::show_message($created_msg . count($image_ids) . __(' picture(s) successfully added', 'nggallery'));
return;
}
示例3: import_gallery
/**
* nggAdmin::import_gallery()
* TODO: Check permission of existing thumb folder & images
*
* @class nggAdmin
* @param string $galleryfolder contains relative path to the gallery itself
* @return void
*/
function import_gallery($galleryfolder)
{
global $wpdb, $user_ID;
// get the current user ID
get_currentuserinfo();
$created_msg = '';
// remove trailing slash at the end, if somebody use it
$galleryfolder = untrailingslashit($galleryfolder);
$gallerypath = WINABSPATH . $galleryfolder;
if (!is_dir($gallerypath)) {
nggGallery::show_error(__('Directory', 'nggallery') . ' <strong>' . esc_html($gallerypath) . '</strong> ' . __('doesn`t exist!', 'nggallery'));
return;
}
// read list of images
$new_imageslist = nggAdmin::scandir($gallerypath);
if (empty($new_imageslist)) {
nggGallery::show_message(__('Directory', 'nggallery') . ' <strong>' . esc_html($gallerypath) . '</strong> ' . __('contains no pictures', 'nggallery'));
return;
}
// check & create thumbnail folder
if (!nggGallery::get_thumbnail_folder($gallerypath)) {
return;
}
// take folder name as gallery name
$galleryname = basename($galleryfolder);
$galleryname = apply_filters('ngg_gallery_name', $galleryname);
// check for existing gallery folder
$gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' ");
if (!$gallery_id) {
// now add the gallery to the database
$gallery_id = nggdb::add_gallery($galleryname, $galleryfolder, '', 0, 0, $user_ID);
if (!$gallery_id) {
nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery'));
return;
} else {
do_action('ngg_created_new_gallery', $gallery_id);
}
$created_msg = _n('Gallery', 'Galleries', 1, 'nggallery') . ' <strong>' . esc_html($galleryname) . '</strong> ' . __('successfully created!', 'nggallery') . '<br />';
}
// Look for existing image list
$old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' ");
// if no images are there, create empty array
if ($old_imageslist == NULL) {
$old_imageslist = array();
}
// check difference
$new_images = array_diff($new_imageslist, $old_imageslist);
// all images must be valid files
foreach ($new_images as $key => $picture) {
// filter function to rename/change/modify image before
$picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id);
$new_images[$key] = $picture;
if (!@getimagesize($gallerypath . '/' . $picture)) {
unset($new_images[$key]);
@unlink($gallerypath . '/' . $picture);
}
}
// add images to database
$image_ids = nggAdmin::add_Images($gallery_id, $new_images);
do_action('ngg_after_new_images_added', $gallery_id, $image_ids);
//add the preview image if needed
nggAdmin::set_gallery_preview($gallery_id);
// now create thumbnails
nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
//TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
$message = $created_msg . count($image_ids) . __(' picture(s) successfully added', 'nggallery');
$message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >';
$message .= __('Edit gallery', 'nggallery');
$message .= '</a>]';
nggGallery::show_message($message);
return;
}
示例4: getgallerycontainer
function getgallerycontainer($galleryid = 0, $used = false)
{
global $wpdb;
$gallery = $wpdb->get_row("SELECT * FROM {$wpdb->nggallery} WHERE gid = '{$galleryid}'");
if ($gallery) {
// set image url
$act_thumbnail_url = get_option('siteurl') . '/' . $gallery->path . nggGallery::get_thumbnail_folder($gallery->path, FALSE);
$post = get_post($gallery->pageid);
$pagename = $post->post_title;
$filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$gallery->previewpic}'");
$img = $filename ? '<img src="' . $act_thumbnail_url . 'thumbs_' . $filename . '" />' : '';
// add class if it's in use in other albums
$used = $used ? ' inUse' : '';
echo '<div id="gid-' . $gallery->gid . '" class="groupItem' . $used . '">
<div class="innerhandle">
<div class="item_top">
<a href="#" class="min" title="close">[-]</a>
ID: ' . $gallery->gid . ' || Title: ' . $gallery->title . '
</div>
<div class="itemContent">
<div class="inlinepicture">' . $img . '</div>
<p><strong>' . __('ID', 'nggallery') . ' : </strong>' . $gallery->gid . '</p>
<p><strong>' . __('Name', 'nggallery') . ' : </strong>' . $gallery->name . '</p>
<p><strong>' . __('Title', 'nggallery') . ' : </strong>' . $gallery->title . '</p>
<p><strong>' . __('Page', 'nggallery') . ' : </strong>' . $pagename . '</p>
</div>
</div>
</div>';
}
}
示例5: nggallery_sortorder
/**
* @author Alex Rabe
* @copyright 2008
*/
function nggallery_sortorder($galleryID = 0)
{
global $wpdb, $ngg;
if ($galleryID == 0) {
return;
}
$galleryID = (int) $galleryID;
if (isset($_POST['updateSortorder'])) {
check_admin_referer('ngg_updatesortorder');
// get variable new sortorder
parse_str($_POST['sortorder']);
if (is_array($sortArray)) {
$neworder = array();
foreach ($sortArray as $pid) {
$pid = substr($pid, 4);
// get id from "pid-x"
$neworder[] = (int) $pid;
}
$sortindex = 1;
foreach ($neworder as $pic_id) {
$wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
$sortindex++;
}
nggGallery::show_message(__('Sort order changed', 'nggallery'));
}
}
//TODO:A unique gallery call must provide me with this information, like $gallery = new nggGallery($id);
// get gallery values
$act_gallery = $wpdb->get_row("SELECT * FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
// set gallery url
$act_gallery_url = get_option('siteurl') . "/" . $act_gallery->path . "/";
$act_thumbnail_url = get_option('siteurl') . "/" . $act_gallery->path . nggGallery::get_thumbnail_folder($act_gallery->path, FALSE);
// look for presort args
$presort = $_GET['presort'];
$dir = $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
$sortitems = array('pid', 'filename', 'alttext', 'imagedate');
// ensure that nobody added some evil sorting :-)
if (in_array($presort, $sortitems)) {
$picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY {$presort} {$dir}");
} else {
$picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY sortorder {$dir}");
}
//this is the url without any presort variable
$clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID;
// In the case somebody presort, then we take this url
if (isset($_GET['dir']) || isset($_GET['presort'])) {
$base_url = $_SERVER['REQUEST_URI'];
} else {
$base_url = $clean_url;
}
?>
<script type='text/javascript' src='<?php
echo NGGALLERY_URLPATH;
?>
admin/js/sorter.js'></script>
<div class="wrap">
<form id="sortGallery" method="POST" action="<?php
echo $clean_url;
?>
" onsubmit="saveImageOrder()" accept-charset="utf-8">
<h2><?php
_e('Sort Gallery', 'nggallery');
?>
</h2>
<div class="tablenav">
<div class="alignleft actions">
<?php
wp_nonce_field('ngg_updatesortorder');
?>
<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php
_e('Update Sort Order', 'nggallery');
?>
" />
</div>
<div class="alignright actions">
<input class="button-secondary action" type="submit" name="backToGallery" value="<?php
_e('Back to gallery', 'nggallery');
?>
" />
</div>
</div>
<input name="sortorder" type="hidden" />
<ul class="subsubsub">
<li><?php
_e('Presort', 'nggallery');
?>
:</li>
<li><a href="<?php
echo attribute_escape(remove_query_arg('presort', $base_url));
?>
" <?php
if ($presort == '') {
echo 'class="current"';
}
?>
><?php
//.........这里部分代码省略.........
示例6: processor
function processor()
{
global $wpdb, $ngg;
if ($this->mode == 'delete') {
// Delete a gallery
check_admin_referer('ngg_editgallery');
// get the path to the gallery
$gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
if ($gallerypath) {
// delete pictures
//TODO:Remove also Tag reference
$imagelist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$this->gid}' ");
if ($ngg->options['deleteImg']) {
if (is_array($imagelist)) {
foreach ($imagelist as $filename) {
@unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
@unlink(WINABSPATH . $gallerypath . '/' . $filename);
}
}
// delete folder
@rmdir(WINABSPATH . $gallerypath . '/thumbs');
@rmdir(WINABSPATH . $gallerypath);
}
}
$delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE galleryid = {$this->gid}");
$delete_galllery = $wpdb->query("DELETE FROM {$wpdb->nggallery} WHERE gid = {$this->gid}");
if ($delete_galllery) {
nggGallery::show_message(__ngettext('Gallery', 'Galleries', 1, 'nggallery') . ' \'' . $this->gid . '\' ' . __('deleted successfully', 'nggallery'));
}
$this->mode = 'main';
// show mainpage
}
if ($this->mode == 'delpic') {
// Delete a picture
//TODO:Remove also Tag reference
check_admin_referer('ngg_delpicture');
$filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$this->pid}' ");
if ($filename) {
$gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
if ($gallerypath) {
$thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
if ($ngg->options['deleteImg']) {
@unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
@unlink(WINABSPATH . $gallerypath . '/' . $filename);
}
}
$delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$this->pid}");
}
if ($delete_pic) {
nggGallery::show_message(__('Picture', 'nggallery') . ' \'' . $this->pid . '\' ' . __('deleted successfully', 'nggallery'));
}
$this->mode = 'edit';
// show pictures
}
if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
// do bulk update
check_admin_referer('ngg_updategallery');
$gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
$imageslist = array();
if (is_array($_POST['doaction'])) {
foreach ($_POST['doaction'] as $imageID) {
$imageslist[] = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
}
}
switch ($_POST['bulkaction']) {
case 'no_action':
// No action
break;
case 'set_watermark':
// Set watermark
nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
break;
case 'new_thumbnail':
// Create new thumbnails
nggAdmin::do_ajax_operation('create_thumbnail', $_POST['doaction'], __('Create new thumbnails', 'nggallery'));
break;
case 'resize_images':
// Resample images
nggAdmin::do_ajax_operation('resize_image', $_POST['doaction'], __('Resize images', 'nggallery'));
break;
case 'delete_images':
// Delete images
if (is_array($_POST['doaction'])) {
if ($gallerypath) {
$thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
foreach ($_POST['doaction'] as $imageID) {
$filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
if ($ngg->options['deleteImg']) {
@unlink(WINABSPATH . $gallerypath . '/' . $thumb_folder . '/' . "thumbs_" . $filename);
@unlink(WINABSPATH . $gallerypath . '/' . $filename);
}
$delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$imageID}");
}
}
if ($delete_pic) {
nggGallery::show_message(__('Pictures deleted successfully ', "nggallery"));
}
}
break;
case 'import_meta':
//.........这里部分代码省略.........