本文整理汇总了PHP中nggdb::find_gallery方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::find_gallery方法的具体用法?PHP nggdb::find_gallery怎么用?PHP nggdb::find_gallery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::find_gallery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_gallery_preview
/**
* nggAdmin::set_gallery_preview() - define a preview pic after the first upload, can be changed in the gallery settings
*
* @class nggAdmin
* @param int $galleryID
* @return void
*/
function set_gallery_preview($galleryID)
{
global $wpdb;
$gallery = nggdb::find_gallery($galleryID);
// in the case no preview image is setup, we do this now
if ($gallery->previewpic == 0) {
$firstImage = $wpdb->get_var("SELECT pid FROM {$wpdb->nggpictures} WHERE exclude != 1 AND galleryid = '{$galleryID}' ORDER by pid DESC limit 0,1");
if ($firstImage) {
$wpdb->query("UPDATE {$wpdb->nggallery} SET previewpic = '{$firstImage}' WHERE gid = '{$galleryID}'");
wp_cache_delete($galleryID, 'ngg_gallery');
}
}
return;
}
示例2: find_last_images
/**
* Get the last images registered in the database with a maximum number of $limit results
*
* @param integer $page start offset as page number (0,1,2,3,4...)
* @param integer $limit the number of result
* @param bool $exclude do not show exluded images
* @param int $galleryId Only look for images with this gallery id, or in all galleries if id is 0
* @param string $orderby is one of "id" (default, order by pid), "date" (order by exif date), sort (order by user sort order)
* @return
*/
static function find_last_images($page = 0, $limit = 30, $exclude = true, $galleryId = 0, $orderby = "id")
{
global $wpdb;
// Check for the exclude setting
$exclude_clause = $exclude ? ' AND exclude<>1 ' : '';
// a limit of 0 makes no sense
$limit = $limit == 0 ? 30 : $limit;
// calculate the offset based on the pagr number
$offset = (int) $page * $limit;
$galleryId = (int) $galleryId;
$gallery_clause = $galleryId === 0 ? '' : ' AND galleryid = ' . $galleryId . ' ';
// default order by pid
$order = 'pid DESC';
switch ($orderby) {
case 'date':
$order = 'imagedate DESC';
break;
case 'sort':
$order = 'sortorder ASC';
break;
}
$result = array();
$gallery_cache = array();
// Query database
$images = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE 1=1 {$exclude_clause} {$gallery_clause} ORDER BY {$order} LIMIT {$offset}, {$limit}");
// Build the object from the query result
if ($images) {
foreach ($images as $key => $image) {
// cache a gallery , so we didn't need to lookup twice
if (!array_key_exists($image->galleryid, $gallery_cache)) {
$gallery_cache[$image->galleryid] = nggdb::find_gallery($image->galleryid);
}
// Join gallery information with picture information
foreach ($gallery_cache[$image->galleryid] as $index => $value) {
$image->{$index} = $value;
}
// Now get the complete image data
$result[$key] = new nggImage($image);
}
}
return $result;
}
示例3: post_processor_galleries
function post_processor_galleries()
{
global $wpdb, $ngg, $nggdb;
// bulk update in a single gallery
if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
check_admin_referer('ngg_bulkgallery');
switch ($_POST['bulkaction']) {
case 'no_action':
// No action
break;
case 'recover_images':
// Recover images from backup
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
break;
case 'set_watermark':
// Set watermark
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
break;
case 'import_meta':
// Import Metadata
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
break;
case 'delete_gallery':
// Delete gallery
if (is_array($_POST['doaction'])) {
$deleted = false;
foreach ($_POST['doaction'] as $id) {
// get the path to the gallery
$gallery = nggdb::find_gallery($id);
if ($gallery) {
//TODO:Remove also Tag reference, look here for ids instead filename
$imagelist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery->gid}' ");
if ($ngg->options['deleteImg']) {
if (is_array($imagelist)) {
foreach ($imagelist as $filename) {
@unlink(WINABSPATH . $gallery->path . '/thumbs/thumbs_' . $filename);
@unlink(WINABSPATH . $gallery->path . '/' . $filename);
@unlink(WINABSPATH . $gallery->path . '/' . $filename . '_backup');
}
}
// delete folder
@rmdir(WINABSPATH . $gallery->path . '/thumbs');
@rmdir(WINABSPATH . $gallery->path);
}
}
do_action('ngg_delete_gallery', $id);
$deleted = nggdb::delete_gallery($id);
}
if ($deleted) {
nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
}
}
break;
}
}
if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
check_admin_referer('ngg_addgallery');
if (!nggGallery::current_user_can('NextGEN Add new gallery')) {
wp_die(__('Cheatin’ uh?'));
}
// get the default path for a new gallery
$defaultpath = $ngg->options['gallerypath'];
$newgallery = esc_attr($_POST['galleryname']);
if (!empty($newgallery)) {
nggAdmin::create_gallery($newgallery, $defaultpath);
}
do_action('ngg_update_addgallery_page');
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
check_admin_referer('ngg_thickbox_form');
//save the new values for the next operation
$ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
$ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
// What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
update_option('ngg_options', $ngg->options);
$gallery_ids = explode(',', $_POST['TB_imagelist']);
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
check_admin_referer('ngg_thickbox_form');
//save the new values for the next operation
$ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
$ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
$ngg->options['thumbfix'] = isset($_POST['thumbfix']) ? true : false;
// What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
update_option('ngg_options', $ngg->options);
$gallery_ids = explode(',', $_POST['TB_imagelist']);
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
}
}
示例4: getImages
/**
* Method "ngg.getImages"
* Return the list of all images inside a gallery
*
* @since 1.4
*
* @param array $args Method parameters.
* - int blog_id
* - string username
* - string password
* - int gallery_id
* @return array with all images
*/
function getImages($args)
{
global $nggdb;
require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
// admin functions
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
$gid = (int) $args[3];
if (!($user = $this->login($username, $password))) {
return $this->error;
}
// Look for the gallery , could we find it ?
if (!($gallery = nggdb::find_gallery($gid))) {
return new IXR_Error(404, __('Could not find gallery ' . $gid));
}
// Now check if you have the correct capability for this gallery
if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
logIO('O', '(NGG) User does not have upload_files capability');
$this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
return $this->error;
}
// get picture values
$picture_list = $nggdb->get_gallery($gid, 'pid', 'ASC', false);
return $picture_list;
}
示例5: nggallery_image_upload_hook
/**
* call the callback after nggallery image upload
* @param $image_info
*/
public function nggallery_image_upload_hook($image_info)
{
//get the gallery path gallerypath
$nggdb = new nggdb();
$current_gallery = $nggdb->find_gallery($image_info['galleryID']);
$current_filename = $image_info["filename"];
//now get the absolute path
$ws_image_path = $options = get_option('siteurl') . "/" . $current_gallery->path . "/" . $current_filename;
$static_generator = new StaticGenerator();
$options = get_option(MakeItStatic::CONFIG_TABLE_FIELD);
$callback_urls = $options["nggallery_callback_url"];
$static_generator->callback_file($ws_image_path, $callback_urls, $current_filename, 'nggallery_image');
}
示例6: post_processor_galleries
function post_processor_galleries()
{
global $wpdb, $ngg, $nggdb;
// bulk update in a single gallery
if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
check_admin_referer('ngg_bulkgallery');
switch ($_POST['bulkaction']) {
case 'no_action':
// No action
break;
case 'recover_images':
// Recover images from backup
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
break;
case 'set_watermark':
// Set watermark
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
break;
case 'import_meta':
// Import Metadata
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
break;
case 'delete_gallery':
// Delete gallery
if (is_array($_POST['doaction'])) {
$deleted = false;
foreach ($_POST['doaction'] as $id) {
// get the path to the gallery
$gallery = nggdb::find_gallery($id);
if ($gallery) {
//TODO:Remove also Tag reference, look here for ids instead filename
$imagelist = $wpdb->get_col("SELECT pid FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery->gid}' ");
if ($ngg->options['deleteImg']) {
$storage = C_Component_Registry::get_instance()->get_utility('I_Gallery_Storage');
if (is_array($imagelist)) {
foreach ($imagelist as $pid) {
$storage->delete_image($pid);
}
}
// delete folder. abspath provided by nggdb::find_gallery()
$fs = C_Fs::get_instance();
@rmdir($fs->join_paths($gallery->abspath, 'thumbs'));
@rmdir($fs->join_paths($gallery->abspath, 'dynamic'));
@rmdir($gallery->abspath);
}
}
do_action('ngg_delete_gallery', $id);
$deleted = nggdb::delete_gallery($id);
}
if ($deleted) {
nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
}
}
break;
}
}
if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
check_admin_referer('ngg_addgallery');
if (!nggGallery::current_user_can('NextGEN Add new gallery')) {
wp_die(__('Cheatin’ uh?', 'nggallery'));
}
// get the default path for a new gallery
$defaultpath = $ngg->options['gallerypath'];
$newgallery = $_POST['galleryname'];
if (!empty($newgallery)) {
nggAdmin::create_gallery($newgallery, $defaultpath);
}
do_action('ngg_update_addgallery_page');
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
check_admin_referer('ngg_thickbox_form');
//save the new values for the next operation
$ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
$ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
// What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
update_option('ngg_options', $ngg->options);
$gallery_ids = explode(',', $_POST['TB_imagelist']);
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
check_admin_referer('ngg_thickbox_form');
// save the new values for the next operation
$settings = C_NextGen_Settings::get_instance();
$settings->thumbwidth = (int) $_POST['thumbwidth'];
$settings->thumbheight = (int) $_POST['thumbheight'];
$settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE;
$settings->save();
ngg_refreshSavedSettings();
// What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
$gallery_ids = explode(',', $_POST['TB_imagelist']);
// A prefix 'gallery_' will first fetch all ids from the selected galleries
nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
}
}
示例7: find_last_images
/**
* Get the last images registered in the database with a maximum number of $limit results
*
* @param integer $page
* @param integer $limit
* @param bool $use_exclude
* @return
*/
function find_last_images($page = 0, $limit = 30, $exclude = true)
{
global $wpdb;
// Check for the exclude setting
$exclude_clause = $exclude ? ' AND exclude<>1 ' : '';
$offset = (int) $page * $limit;
$result = array();
$gallery_cache = array();
// Query database
$images = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE 1=1 {$exclude_clause} ORDER BY pid DESC LIMIT {$offset}, {$limit}");
// Build the object from the query result
if ($images) {
foreach ($images as $key => $image) {
// cache a gallery , so we didn't need to lookup twice
if (!array_key_exists($image->galleryid, $gallery_cache)) {
$gallery_cache[$image->galleryid] = nggdb::find_gallery($image->galleryid);
}
// Join gallery information with picture information
foreach ($gallery_cache[$image->galleryid] as $index => $value) {
$image->{$index} = $value;
}
// Now get the complete image data
$result[$key] = new nggImage($image);
}
}
return $result;
}
示例8: getNgg2DownloadTitle
/**
* build download title from NextGEN 2 displayed gallery properties, e.g. selected galleries, taglist, etc.
* @param C_Displayed_Gallery $displayed_gallery
* @return string
*/
protected static function getNgg2DownloadTitle($displayed_gallery)
{
switch ($displayed_gallery->source) {
case 'galleries':
$titles = array();
foreach ($displayed_gallery->container_ids as $gallery_id) {
$gallery = nggdb::find_gallery($gallery_id);
$titles[] = $gallery->title;
}
$title = implode(',', $titles);
break;
case 'tags':
$taglist = implode(',', $displayed_gallery->container_ids);
$title = self::getTitleFromTaglist($taglist);
break;
default:
// allow title to be confected
// TODO: extend this function to pick up other NGG2 gallery sources
$title = '';
break;
}
// restrict length to 250 characters
$title = substr($title, 0, 250);
return $title;
}
示例9: copy_images
/**
* Copy images to another gallery
*/
function copy_images($pic_ids, $dest_gid)
{
$errors = $messages = '';
if (!is_array($pic_ids)) {
$pic_ids = array($pic_ids);
}
// Get destination gallery
$destination = nggdb::find_gallery($dest_gid);
if ($destination == null) {
nggGallery::show_error(__('The destination gallery does not exist', 'nggallery'));
return;
}
// Check for folder permission
if (!is_writeable(WINABSPATH . $destination->path)) {
$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path);
nggGallery::show_error($message);
return;
}
// Get pictures
$images = nggdb::find_images_in_list($pic_ids);
$destination_path = WINABSPATH . $destination->path;
foreach ($images as $image) {
// WPMU action
if (nggAdmin::check_quota()) {
return;
}
$i = 0;
$tmp_prefix = '';
$destination_file_name = $image->filename;
while (file_exists($destination_path . '/' . $destination_file_name)) {
$tmp_prefix = 'copy_' . $i++ . '_';
$destination_file_name = $tmp_prefix . $image->filename;
}
$destination_file_path = $destination_path . '/' . $destination_file_name;
$destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
// Copy files
if (!@copy($image->imagePath, $destination_file_path)) {
$errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />';
continue;
}
// Copy the thumbnail if possible
!@copy($image->thumbPath, $destination_thumb_file_path);
// Create new database entry for the image
$new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
if (!isset($new_pid)) {
$errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />';
continue;
}
// Copy tags
nggTags::copy_tags($image->pid, $new_pid);
if ($tmp_prefix != '') {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
} else {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
}
}
// Finish by showing errors or success
if ($errors == '') {
$link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
$messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link);
}
if ($messages != '') {
nggGallery::show_message($messages);
}
if ($errors != '') {
nggGallery::show_error($errors);
}
return;
}
示例10: nggallery_picturelist
function nggallery_picturelist()
{
// *** show picture list
global $wpdb, $user_ID, $ngg;
// GET variables
$act_gid = $ngg->manage_page->gid;
$showTags = $ngg->manage_page->showTags;
$hideThumbs = $ngg->manage_page->hideThumbs;
// Load the gallery metadata
$gallery = nggdb::find_gallery($act_gid);
if (!$gallery) {
nggGallery::show_error(__('Gallery not found.', 'nggallery'));
return;
}
// get picture values
$picturelist = nggdb::get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false);
// get the current author
$act_author_user = get_userdata((int) $gallery->author);
// list all galleries
$gallerylist = nggdb::find_all_galleries();
?>
<script type="text/javascript">
function showDialog( windowId ) {
var form = document.getElementById('updategallery');
var elementlist = "";
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].name == "doaction[]")
if(form.elements[i].checked == true)
if (elementlist == "")
elementlist = form.elements[i].value
else
elementlist += "," + form.elements[i].value ;
}
}
jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
jQuery("#" + windowId + "_imagelist").val(elementlist);
// console.log (jQuery("#TB_imagelist").val());
tb_show("", "#TB_inline?width=640&height=120&inlineId=" + windowId + "&modal=true", false);
}
</script>
<script type="text/javascript">
<!--
function checkAll(form)
{
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].name == "doaction[]") {
if(form.elements[i].checked == true)
form.elements[i].checked = false;
else
form.elements[i].checked = true;
}
}
}
}
function getNumChecked(form)
{
var num = 0;
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].name == "doaction[]")
if(form.elements[i].checked == true)
num++;
}
}
return num;
}
// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {
var numchecked = getNumChecked(document.getElementById('updategallery'));
if(numchecked < 1) {
alert('<?php
echo js_escape(__("No images selected", 'nggallery'));
?>
');
return false;
}
//TODO: For copy to and move to we need some better way around
if (jQuery('#bulkaction').val() == 'copy_to') {
showDialog('selectgallery');
return false;
}
if (jQuery('#bulkaction').val() == 'move_to') {
showDialog('selectgallery');
return false;
}
return confirm('<?php
echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
?>
');
}
//.........这里部分代码省略.........