本文整理汇总了PHP中nggdb::update_image方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::update_image方法的具体用法?PHP nggdb::update_image怎么用?PHP nggdb::update_image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::update_image方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move_images
/**
* Move images from one folder to another
*
* @class nggAdmin
* @param array|int $pic_ids ID's of the images
* @param int $dest_gid destination gallery
* @return void
*/
function move_images($pic_ids, $dest_gid)
{
$errors = '';
$count = 0;
if (!is_array($pic_ids)) {
$pic_ids = array($pic_ids);
}
// Get destination gallery
$destination = nggdb::find_gallery($dest_gid);
$dest_abspath = WINABSPATH . $destination->path;
if ($destination == null) {
nggGallery::show_error(__('The destination gallery does not exist', 'nggallery'));
return;
}
// Check for folder permission
if (!is_writeable($dest_abspath)) {
$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), $dest_abspath);
nggGallery::show_error($message);
return;
}
// Get pictures
$images = nggdb::find_images_in_list($pic_ids);
foreach ($images as $image) {
$i = 0;
$tmp_prefix = '';
$destination_file_name = $image->filename;
// check if the filename already exist, then we add a copy_ prefix
while (file_exists($dest_abspath . '/' . $destination_file_name)) {
$tmp_prefix = 'copy_' . $i++ . '_';
$destination_file_name = $tmp_prefix . $image->filename;
}
$destination_path = $dest_abspath . '/' . $destination_file_name;
$destination_thumbnail = $dest_abspath . '/thumbs/thumbs_' . $destination_file_name;
// Move files
if (!@rename($image->imagePath, $destination_path)) {
$errors .= sprintf(__('Failed to move image %1$s to %2$s', 'nggallery'), '<strong>' . $image->filename . '</strong>', $destination_path) . '<br />';
continue;
}
// Move backup file, if possible
@rename($image->imagePath . '_backup', $destination_path . '_backup');
// Move the thumbnail, if possible
@rename($image->thumbPath, $destination_thumbnail);
// Change the gallery id in the database , maybe the filename
if (nggdb::update_image($image->pid, $dest_gid, $destination_file_name)) {
$count++;
}
}
if ($errors != '') {
nggGallery::show_error($errors);
}
$link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
$messages = sprintf(__('Moved %1$s picture(s) to gallery : %2$s .', 'nggallery'), $count, $link);
nggGallery::show_message($messages);
return;
}
示例2: editImage
/**
* Method "ngg.editImage"
* Edit a existing Image
*
* @since 1.7.3
*
* @param array $args Method parameters.
* - int blog_id
* - string username
* - string password
* - int Image ID
* - string alt/title text
* - string description
* - int exclude from gallery (0 or 1)
* @return true if success
*/
function editImage($args)
{
global $ngg;
require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
// admin functions
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
$id = (int) $args[3];
$alttext = $args[4];
$description = $args[5];
$exclude = (int) $args[6];
if (!($user = $this->login($username, $password))) {
return $this->error;
}
if (!($image = nggdb::find_image($id))) {
return new IXR_Error(404, __("Invalid image ID"));
}
if (!current_user_can('NextGEN Manage gallery') && !nggAdmin::can_manage_this_gallery($image->author)) {
return new IXR_Error(401, __('Sorry, you must be able to edit this image'));
}
if (!empty($alttext)) {
$result = nggdb::update_image($id, false, false, $description, $alttext, $exclude);
}
if (!$result) {
return new IXR_Error(500, __('Sorry, could not update the image'));
}
return true;
}