本文整理汇总了PHP中nggdb::find_images_in_list方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::find_images_in_list方法的具体用法?PHP nggdb::find_images_in_list怎么用?PHP nggdb::find_images_in_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::find_images_in_list方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_images
/**
* Parse the single image shortcode and return all images into an array
*
* @param array $atts
* @return
*/
function add_images($atts)
{
extract(shortcode_atts(array('id' => 0), $atts));
// make an array out of the ids (for thumbs shortcode))
$pids = explode(',', $id);
// Some error checks
if (count($pids) == 0) {
return;
}
$images = nggdb::find_images_in_list($pids);
foreach ($images as $image) {
$src = $image->imageURL;
$newimage = array();
if (!empty($image->title)) {
$newimage['title'] = $image->title;
}
if (!empty($image->alttext)) {
$newimage['alt'] = $image->alttext;
}
$this->images[$src] = $newimage;
}
return;
}
示例2: copy_images
/**
* Copy images to another gallery
*
* @class nggAdmin
* @param array|int $pic_ids ID's of the images
* @param int $dest_gid destination gallery
* @return void
*/
function copy_images($pic_ids, $dest_gid)
{
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
$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 (nggWPMU::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 backup file, if possible
@copy($image->imagePath . '_backup', $destination_file_path . '_backup');
// 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);
// Copy meta information
$meta = new nggMeta($image->pid);
nggdb::update_image_meta($new_pid, $meta->image->meta_data);
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;
}
示例3: show_thumbs
/**
* Function to show a thumbnail or a set of thumbnails with shortcode of type:
*
* [thumb id="1,2,4,5,..." template="filename" /]
* where
* - id is one or more picture ids
* - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
*
* @param array $atts
* @return the_content
*/
function show_thumbs($atts)
{
extract(shortcode_atts(array('id' => '', 'template' => ''), $atts));
// make an array out of the ids
$pids = explode(',', $id);
// Some error checks
if (count($pids) == 0) {
return __('[Pictures not found]', 'nggallery');
}
$picturelist = nggdb::find_images_in_list($pids);
// show gallery
if (is_array($picturelist)) {
$out = nggCreateGallery($picturelist, false, $template);
}
return $out;
}
示例4: find_images_for_tags
/**
* nggTags::find_images_for_tags()
*
* @param mixed $taglist
* @param string $mode could be 'ASC' or 'RAND'
* @return array of images
*/
function find_images_for_tags($taglist, $mode = "ASC")
{
// return the images based on the tag
global $wpdb;
// extract it into a array
$taglist = explode(",", $taglist);
if (!is_array($taglist)) {
$taglist = array($taglist);
}
$taglist = array_map('trim', $taglist);
$new_slugarray = array_map('sanitize_title', $taglist);
$sluglist = "'" . implode("', '", $new_slugarray) . "'";
//Treat % as a litteral in the database, for unicode support
$sluglist = str_replace("%", "%%", $sluglist);
// first get all $term_ids with this tag
$term_ids = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug IN ({$sluglist}) ORDER BY term_id ASC ", NULL));
$picids = get_objects_in_term($term_ids, 'ngg_tag');
//Now lookup in the database
if ($mode == 'RAND') {
$pictures = nggdb::find_images_in_list($picids, true, 'RAND');
} else {
$pictures = nggdb::find_images_in_list($picids, true, 'ASC');
}
return $pictures;
}
示例5: find_images_for_tags
/**
* nggTags::find_images_for_tags()
* 20140120: Mode DESC added.
* 20140611:Dropped use of wpdb->prepare since single quotes are scaped.
* @param mixed $taglist
* @param string $sorting could be 'ASC' or 'RAND' or 'DESC'
* @return array of images
*/
static function find_images_for_tags($taglist, $sorting = "ASC")
{
// return the images based on the tag
global $wpdb;
$modes = array('ASC', 'DESC', 'RAND');
//Sanitize & standarize list
$sluglist = self::sanitize_taglist($taglist);
// first get all $term_ids with this tag
//Fix for WP 3.9 . See http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/
$prepared = "SELECT term_id FROM {$wpdb->terms} WHERE slug IN ({$sluglist}) ORDER BY term_id ASC ";
$term_ids = $wpdb->get_col($prepared);
//Get the objects related with the taxonomy defined by NextCellent
$picids = get_objects_in_term($term_ids, 'ngg_tag');
//Now lookup in the database
$sorting = in_array($sorting, $modes) ? $sorting : 'ASC';
$pictures = nggdb::find_images_in_list($picids, true, $sorting);
return $pictures;
}
示例6: get_objects_in_term
<?php
//引入图片插件入口文件
require_once './wp-content/plugins/nextgen-gallery/ngg-config.php';
require_once './inc/php/cfg.php';
if (!empty($_GET['tagid'])) {
$pids = get_objects_in_term($_GET['tagid'], 'ngg_tag');
$tag = get_term($_GET['tagid'], 'ngg_tag');
//var_dump($tag);
$fotos = nggdb::find_images_in_list($pids, false, 'DESC');
if (empty($fotos)) {
header('Location: /tags.php');
}
//页面title
$page_title = empty($_GET['tag']) ? $cfg['sitename'] : $_GET['tag'];
$title = $page_title . $cfg['sitetitle'];
} else {
header('Location: /tags.php');
}
//输出keywords
$keywords = $_GET['tag'] . ',' . $cfg['keywords'];
//输出description
$description = $cfg['description'];
//输出canonical
$canonical = canonical($tag->term_id, $tag->slug);
require_once './inc/html/head.html';
?>
<div id='main'>
<?php
foreach ($fotos as $foto) {
?>