本文整理汇总了PHP中nggGallery::show_error方法的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery::show_error方法的具体用法?PHP nggGallery::show_error怎么用?PHP nggGallery::show_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggGallery
的用法示例。
在下文中一共展示了nggGallery::show_error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_quota
/**
* Check the Quota under WPMU. Only needed for this case
*
* @class nggWPMU
* @return bool $result
*/
function check_quota()
{
if (get_site_option('upload_space_check_disabled')) {
return false;
}
if (is_multisite() && nggWPMU::wpmu_enable_function('wpmuQuotaCheck')) {
if ($error = upload_is_user_over_quota(false)) {
nggGallery::show_error(__('Sorry, you have used your space allocation. Please delete some files to upload more files.', 'nggallery'));
return true;
}
}
return false;
}
示例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: nggallery_picturelist
function nggallery_picturelist()
{
// *** show picture list
global $wpdb, $nggdb, $user_ID, $ngg;
// Look if its a search result
$is_search = isset($_GET['s']) ? true : false;
$counter = 0;
$wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
if ($is_search) {
// fetch the imagelist
$picturelist = $ngg->manage_page->search_result;
// we didn't set a gallery or a pagination
$act_gid = 0;
$_GET['paged'] = 1;
$page_links = false;
} else {
// GET variables
$act_gid = $ngg->manage_page->gid;
// Load the gallery metadata
$gallery = $nggdb->find_gallery($act_gid);
if (!$gallery) {
nggGallery::show_error(__('Gallery not found.', 'nggallery'));
return;
}
// Check if you have the correct capability
if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
return;
}
// look for pagination
$_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
$start = ($_GET['paged'] - 1) * 50;
// get picture values
$picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start);
// get the current author
$act_author_user = get_userdata((int) $gallery->author);
}
// list all galleries
$gallerylist = $nggdb->find_all_galleries();
//get the columns
$image_columns = $wp_list_table->get_columns();
$hidden_columns = get_hidden_columns('nggallery-manage-images');
$num_columns = count($image_columns) - count($hidden_columns);
$attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"';
?>
<script type="text/javascript">
<!--
function showDialog( windowId, title ) {
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);
// now show the dialog
jQuery( "#" + windowId ).dialog({
width: 640,
resizable : false,
modal: true,
title: title,
position: {
my: 'center',
at: 'center',
of: window.parent
}
});
jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
}
jQuery(function (){
jQuery('span.tooltip, label.tooltip').tooltip();
// load a content via ajax
jQuery('a.ngg-dialog').click(function() {
var dialogs = jQuery('.ngg-overlay-dialog:visible');
if (dialogs.size() > 0) {
return false;
}
if ( jQuery( "#spinner" ).length == 0) {
jQuery("body").append('<div id="spinner"></div>');
}
var $this = jQuery(this);
var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
var width = ( results ) ? results[1] : 600;
var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
var height = ( results ) ? results[1] : 440;
var container = window;
if (window.parent) {
//.........这里部分代码省略.........
示例4: nggallery_picturelist
function nggallery_picturelist($controller)
{
// *** show picture list
global $wpdb, $nggdb, $user_ID, $ngg;
// Look if its a search result
$is_search = isset($_GET['s']) ? true : false;
$counter = 0;
$wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
if ($is_search) {
// fetch the imagelist
$picturelist = $ngg->manage_page->search_result;
// we didn't set a gallery or a pagination
$act_gid = 0;
$_GET['paged'] = 1;
$page_links = false;
} else {
// GET variables
$act_gid = $ngg->manage_page->gid;
// Load the gallery metadata
$mapper = C_Gallery_Mapper::get_instance();
$gallery = $mapper->find($act_gid);
if (!$gallery) {
nggGallery::show_error(__('Gallery not found.', 'nggallery'));
return;
}
// Check if you have the correct capability
if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
return;
}
// look for pagination
$_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
$items_per_page = 50;
$start = ($_GET['paged'] - 1) * $items_per_page;
// get picture values
$image_mapper = C_Image_Mapper::get_instance();
$total_number_of_images = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $act_gid))->run_query(FALSE, TRUE));
$picturelist = $image_mapper->select()->where(array("galleryid = %d", $act_gid))->order_by($ngg->options['galSort'], $ngg->options['galSortDir'])->limit($items_per_page, $start)->run_query();
// get the current author
$act_author_user = get_userdata((int) $gallery->author);
}
// list all galleries
$gallerylist = $nggdb->find_all_galleries();
//get the columns
$image_columns = $wp_list_table->get_columns();
$hidden_columns = get_hidden_columns('nggallery-manage-images');
$num_columns = count($image_columns) - count($hidden_columns);
$attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"';
?>
<script type="text/javascript">
<!--
function showDialog( windowId, title ) {
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);
// now show the dialog
jQuery( "#" + windowId ).dialog({
width: 640,
resizable : false,
modal: true,
title: title,
position: {
my: 'center',
at: 'center',
of: window.parent
}
});
jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
}
jQuery(function (){
jQuery('span.tooltip, label.tooltip').tooltip();
// load a content via ajax
jQuery('a.ngg-dialog').click(function() {
var dialogs = jQuery('.ngg-overlay-dialog:visible');
if (dialogs.size() > 0) {
return false;
}
if ( jQuery( "#spinner" ).length == 0) {
jQuery("body").append('<div id="spinner"></div>');
}
var $this = jQuery(this);
var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
var width = ( results ) ? results[1] : 600;
var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
//.........这里部分代码省略.........
示例5: 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
*/
static function import_gallery($galleryfolder, $gallery_id = NULL)
{
global $wpdb, $user_ID;
// get the current user ID
wp_get_current_user();
$created_msg = '';
// remove trailing slash at the end, if somebody use it
$galleryfolder = untrailingslashit($galleryfolder);
$fs = C_Fs::get_instance();
if (is_null($gallery_id)) {
$gallerypath = $fs->join_paths($fs->get_document_root('content'), $galleryfolder);
} else {
$storage = C_Gallery_Storage::get_instance();
$gallerypath = $storage->get_gallery_abspath($gallery_id);
}
if (!is_dir($gallerypath)) {
nggGallery::show_error(sprintf(__("Directory <strong>%s</strong> doesn`t exist!", 'nggallery'), esc_html($gallerypath)));
return;
}
// read list of images
$new_imageslist = nggAdmin::scandir($gallerypath);
if (empty($new_imageslist)) {
nggGallery::show_message(sprintf(__("Directory <strong>%s</strong> contains no pictures", 'nggallery'), esc_html($gallerypath)));
return;
}
// take folder name as gallery name
$galleryname = basename($galleryfolder);
$galleryname = apply_filters('ngg_gallery_name', $galleryname);
// check for existing gallery folder
if (is_null($gallery_id)) {
$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 = sprintf(_n("Gallery <strong>%s</strong> successfully created!", 'Galleries <strong>%s</strong> successfully created!', 1, 'nggallery'), esc_html($galleryname));
}
// 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 . sprintf(_n('%s picture successfully added', '%s pictures successfully added', count($image_ids), 'nggallery'), count($image_ids));
$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;
}
示例6: check_safemode
/**
* Check UID in folder and Script
* Read http://www.php.net/manual/en/features.safe-mode.php to understand safe_mode
*
* @class nggAdmin
* @param string $foldername
* @return bool $result
*/
function check_safemode($foldername)
{
if (SAFE_MODE) {
$script_uid = ini_get('safe_mode_gid') ? getmygid() : getmyuid();
$folder_uid = fileowner($foldername);
if ($script_uid != $folder_uid) {
$message = sprintf(__('SAFE MODE Restriction in effect! You need to create the folder <strong>%s</strong> manually', 'nggallery'), esc_html($foldername));
$message .= '<br />' . sprintf(__('When safe_mode is on, PHP checks to see if the owner (%s) of the current script matches the owner (%s) of the file to be operated on by a file function or its directory', 'nggallery'), $script_uid, $folder_uid);
nggGallery::show_error($message);
return false;
}
}
return true;
}
示例7: controller
/**
* Render the page content.
*
* @since 1.9.22
*
*/
function controller()
{
global $ngg;
//the directions containing the css files
if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
$dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles");
} else {
$dir = array(NGGALLERY_ABSPATH . "css");
}
//support for legacy location (in theme folder)
if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) {
$act_cssfile = get_stylesheet_directory() . "/nggallery.css";
}
//if someone uses the filter, don't display this page.
if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) {
nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file);
return;
}
//load all files
if (!isset($act_cssfile)) {
$csslist = NGG_Style::ngg_get_cssfiles($dir);
$act_cssfile = $ngg->options['CSSfile'];
}
//get the data from the file
$act_css_data = NGG_Style::ngg_get_cssfiles_data($act_cssfile);
$act_css_name = $act_css_data['Name'];
$act_css_description = $act_css_data['Description'];
$act_css_author = $act_css_data['Author'];
$act_css_version = $act_css_data['Version'];
$act_css_folder = $act_css_data['Folder'];
// get the content of the file
$error = !is_file($act_cssfile);
if (!$error && filesize($act_cssfile) > 0) {
$f = fopen($act_cssfile, 'r');
$content = fread($f, filesize($act_cssfile));
$content = htmlspecialchars($content);
}
?>
<div class="wrap">
<div class="bordertitle">
<?php
screen_icon('nextgen-gallery');
?>
<h2><?php
_e('Style Editor', 'nggallery');
?>
</h2>
<div class="fileedit-sub">
<?php
if (!$theme_css_exists) {
//no need if there is a theme css
?>
<div class="alignright">
<form id="themeselector" name="cssfiles" method="post">
<?php
wp_nonce_field('ngg_style');
?>
<strong><?php
_e('Activate and use style sheet:', 'nggallery');
?>
</strong>
<input type="checkbox" name="activateCSS" value="1" <?php
checked('1', $ngg->options['activateCSS']);
?>
/>
<select name="css" id="theme" style="margin: 0pt; padding: 0pt;">
<?php
self::output_css_files_dropdown($csslist, $act_cssfile);
?>
</select>
<input class="button" type="submit" name="activate" value="<?php
_e('Activate', 'nggallery');
?>
»" class="button" />
</form>
</div>
<?php
}
?>
<?php
if (!is_multisite() || is_super_admin()) {
?>
<div class="alignleft">
<?php
$title = '<h3>';
if (is_writeable($act_cssfile)) {
$title .= sprintf(__('Editing %s', 'nggallery'), $act_css_name);
} else {
$title .= sprintf(__('Browsing %s', 'nggallery'), $act_css_name);
}
if ($theme_css_exists) {
$title .= ' ' . __('(from the theme folder)', 'nggallery');
}
$title .= '</h3>';
//.........这里部分代码省略.........
示例8: 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 + '");
?>
');
}
//.........这里部分代码省略.........
示例9: substr
$filepart['filename'] = substr($filepart["basename"], 0, strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1));
$filename = time() . sanitize_title($filepart['filename']) . '.' . $filepart['extension'];
// check for allowed extension
$ext = array('jpeg', 'jpg', 'png', 'gif');
if (!in_array($filepart['extension'], $ext)) {
$display = 'block';
$errormsg = 'sorry,the file is no valid image file!';
} else {
$dest_file = WINABSPATH . $gallerypath . '/' . $filename;
// save temp file to gallery
if (!@move_uploaded_file($_FILES['image']['tmp_name'], $dest_file)) {
nggGallery::show_error(__('Error, the file could not moved to : ', 'nggallery') . $dest_file);
continue;
}
if (!foto_chmod($dest_file)) {
nggGallery::show_error(__('Error, the file permissions could not set', 'nggallery'));
continue;
}
$pid = nggdb::insert_image($gid, $filename, $title, $description, 1);
$tags = explode(",", $tags);
wp_set_object_terms($pid, $tags, 'ngg_tag');
$wpdb->query("UPDATE {$wpdb->nggpictures} SET imagedate = now() WHERE pid = {$pid}");
$display = 'block';
$errormsg = 'your upload is successful,it will be reviewed.you can continue';
}
}
}
}
//输出页头keywords
$keywords = $cfg['keywords'];
//输出页面description
示例10: show_error
public static function show_error($msg)
{
if (is_user_logged_in() && apply_filters('uploader_ngg_admin_show_error', true)) {
nggGallery::show_error($msg);
}
}
示例11: nggallery_picturelist
function nggallery_picturelist()
{
// *** show picture list
global $wpdb, $nggdb, $user_ID, $ngg;
// Look if its a search result
$is_search = isset($_GET['s']) ? true : false;
if ($is_search) {
// fetch the imagelist
$picturelist = $ngg->manage_page->search_result;
// we didn't set a gallery or a pagination
$act_gid = 0;
$_GET['paged'] = 1;
$page_links = false;
} else {
// GET variables
$act_gid = $ngg->manage_page->gid;
// Load the gallery metadata
$gallery = $nggdb->find_gallery($act_gid);
if (!$gallery) {
nggGallery::show_error(__('Gallery not found.', 'nggallery'));
return;
}
// Check if you have the correct capability
if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
return;
}
// look for pagination
if (!isset($_GET['paged']) || $_GET['paged'] < 1) {
$_GET['paged'] = 1;
}
$start = ($_GET['paged'] - 1) * 50;
// get picture values
$picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start);
// build pagination
$page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged']));
// get the current author
$act_author_user = get_userdata((int) $gallery->author);
}
// list all galleries
$gallerylist = $nggdb->find_all_galleries();
//get the columns
$gallery_columns = ngg_manage_gallery_columns();
$hidden_columns = get_hidden_columns('nggallery-manage-images');
$num_columns = count($gallery_columns) - count($hidden_columns);
?>
<!--[if IE]>
<style type="text/css">
.custom_thumb {
display : none;
}
</style>
<![endif]-->
<script type="text/javascript">
<!--
function showDialog( windowId, height ) {
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=" + height + "&inlineId=" + windowId + "&modal=true", false);
}
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++;
}
}
//.........这里部分代码省略.........
示例12: nggallery_wpmu_setup
function nggallery_wpmu_setup()
{
//to be sure
if (!is_super_admin()) {
die('You are not allowed to call this page.');
}
$messagetext = '';
// get the options
$ngg_options = get_site_option('ngg_options');
if (isset($_POST['updateoption'])) {
check_admin_referer('ngg_wpmu_settings');
// get the hidden option fields, taken from WP core
if ($_POST['page_options']) {
$options = explode(',', stripslashes($_POST['page_options']));
}
if ($options) {
foreach ($options as $option) {
$option = trim($option);
$value = false;
if (isset($_POST[$option])) {
$value = trim($_POST[$option]);
if ($value === "true") {
$value = true;
}
if (is_numeric($value)) {
$value = (int) $value;
}
}
// $value = sanitize_option($option, $value); // This does stripslashes on those that need it
$ngg_options[$option] = $value;
}
}
// the path should always end with a slash
$ngg_options['gallerypath'] = trailingslashit($ngg_options['gallerypath']);
update_site_option('ngg_options', $ngg_options);
var_dump($ngg_options);
$messagetext = __('Update successfully', 'nggallery');
}
global $ngg;
//the directions containing the css files
if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
$dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles");
} else {
$dir = array(NGGALLERY_ABSPATH . "css");
}
//support for legacy location (in theme folder)
if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) {
$act_cssfile = get_stylesheet_directory() . "/nggallery.css";
}
//if someone uses the filter, don't display this page.
if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) {
nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file);
return;
}
//load all files
if (!isset($act_cssfile)) {
$csslist = NGG_Style::ngg_get_cssfiles($dir);
$act_cssfile = $ngg->options['CSSfile'];
}
// message windows
if (!empty($messagetext)) {
echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>';
}
?>
<div class="wrap">
<h2><?php
_e('Network Options', 'nggallery');
?>
</h2>
<form name="generaloptions" method="post">
<?php
wp_nonce_field('ngg_wpmu_settings');
?>
<input type="hidden" name="page_options" value="silentUpgrade,gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" />
<table class="form-table">
<tr>
<th><label for="gallerypath"><?php
_e('Gallery path', 'nggallery');
?>
</label></th>
<td>
<input type="text" size="50" name="gallerypath" id="gallerypath" value="<?php
echo $ngg_options['gallerypath'];
?>
">
<p class="description">
<?php
_e('This is the default path for all blogs. With the placeholder %BLOG_ID% you can organize the folder structure better.', 'nggallery');
?>
<?php
echo sprintf(__('The default setting should be %s.', 'nggallery'), '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>');
?>
</p>
</td>
</tr>
<tr>
<th><?php
_e('Silent database upgrade', 'nggallery');
?>
//.........这里部分代码省略.........
示例13: upload_images
/**
* Function for uploading of images via the upload form
*
* @class nggAdmin
* @return void
*/
function upload_images($galleryID, $image, $desc, $title)
{
global $wpdb;
$gallery = $wpdb->prefix . "spf_gallery";
$pictures = $wpdb->prefix . "spf_pictures";
if ($galleryID == 0) {
show_error(__('No gallery selected !', 'nggallery'));
return;
}
$gid = $galleryID;
$query = "SELECT * FROM " . $gallery . " WHERE gid='" . $gid . "'";
$results = mysql_query($query);
$count = mysql_num_rows($results);
while ($data = mysql_fetch_array($results)) {
//$id = $data['gid'];
$fullpath = ABSPATH . stripslashes($data['path']);
///$quote = stripslashes($data['description']);
}
$fullpath = str_replace("\\", "/", $fullpath);
if (empty($fullpath)) {
nggGallery::show_error(__('Failure in database, no gallery path set !', 'nggallery'));
return;
}
// read list of images
//$dirlist = scandir($fullpath);
$imagefiles = $image;
// look only for uploded files
if ($imagefiles['error'] == 0) {
$temp_file = $imagefiles['tmp_name'];
//clean filename and extract extension
$filepart = fileinfo($imagefiles['name']);
print_r($filepart);
echo $filename = $filepart['basename'];
// check for allowed extension and if it's an image file
$ext = array('jpg', 'png', 'gif', 'bmp', 'jpeg');
if (!in_array($filepart['extension'], $ext)) {
show_error('<strong>' . $imagefiles['name'] . ' </strong>' . __('is no valid image file!', 'nggallery'));
//continue;
}
// check if this filename already exist in the folder
if (file_exists($fullpath . $filename)) {
$txt = "File ({$filename}) already exists.";
show_error($txt);
return false;
} else {
echo $filename = $filepart['filename'] . '.' . $filepart['extension'];
}
echo $dest_file = $fullpath . $filename;
//check for folder permission
if (!is_writeable($fullpath)) {
echo "<br>" . $fullpath;
chmod($fullpath, 0777);
//$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?'), $fullpath);
// show_error($message);
// return;
}
// save temp file to gallery
if (!@move_uploaded_file($temp_file, $dest_file)) {
show_error(__('Error, the file could not moved to : ') . $dest_file);
//continue;
} else {
$insert = "INSERT INTO " . $pictures . " (pid, gid, filename, description, title) \t \t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t" . "VALUES ('', '" . $gid . "', " . $file_name . "', '" . $desc . "', '" . $title . "')";
$results = $wpdb->query($insert);
if ($results) {
?>
<div class="updated" id="message" style="background-color: rgb(255, 251, 204);"><p> <?php
echo 'New Gallery added successfully!';
?>
</p></div>
<?php
}
}
//if ( !chmod($dest_file) )
// {
// show_error(__('Error, the file permissions could not set'));
// continue;
// }
}
return;
}
示例14: create_thumbnail_folder
/**
* nggGallery::get_thumbnail_folder()
*
* @param mixed $gallerypath
* @param bool $include_Abspath
* @return string $foldername
*/
static function create_thumbnail_folder($gallerypath, $include_Abspath = TRUE)
{
if (!$include_Abspath) {
$gallerypath = ABSPATH . $gallerypath;
}
if (!file_exists($gallerypath)) {
return FALSE;
}
if (is_dir($gallerypath . '/thumbs/')) {
return '/thumbs/';
}
if (is_admin()) {
if (!is_dir($gallerypath . '/thumbs/')) {
if (!wp_mkdir_p($gallerypath . '/thumbs/')) {
if (SAFE_MODE) {
nggAdmin::check_safemode($gallerypath . '/thumbs/');
} else {
nggGallery::show_error(__('Unable to create directory ', 'nggallery') . $gallerypath . '/thumbs !');
}
return FALSE;
}
return '/thumbs/';
}
}
return FALSE;
}
示例15: nggallery_admin_add_gallery
function nggallery_admin_add_gallery()
{
global $wpdb, $ngg;
// same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
$filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
// link for the flash file
$swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php';
$swf_upload_link = wp_nonce_url($swf_upload_link, 'ngg_swfupload');
//flash doesn't seem to like encoded ampersands, so convert them back here
$swf_upload_link = str_replace('&', '&', $swf_upload_link);
$defaultpath = $ngg->options['gallerypath'];
if ($_POST['addgallery']) {
check_admin_referer('ngg_addgallery');
$newgallery = attribute_escape($_POST['galleryname']);
if (!empty($newgallery)) {
nggAdmin::create_gallery($newgallery, $defaultpath);
}
}
if ($_POST['zipupload']) {
check_admin_referer('ngg_addgallery');
if ($_FILES['zipfile']['error'] == 0) {
$messagetext = nggAdmin::import_zipfile(intval($_POST['zipgalselect']));
} else {
nggGallery::show_error(__('Upload failed!', 'nggallery'));
}
}
if ($_POST['importfolder']) {
check_admin_referer('ngg_addgallery');
$galleryfolder = $_POST['galleryfolder'];
if (!empty($galleryfolder) and $defaultpath != $galleryfolder) {
nggAdmin::import_gallery($galleryfolder);
}
}
if ($_POST['uploadimage']) {
check_admin_referer('ngg_addgallery');
if ($_FILES['MF__F_0_0']['error'] == 0) {
$messagetext = nggAdmin::upload_images();
} else {
nggGallery::show_error(__('Upload failed!', 'nggallery'));
}
}
if (isset($_POST['swf_callback'])) {
if ($_POST['galleryselect'] == "0") {
nggGallery::show_error(__('No gallery selected !', 'nggallery'));
} else {
// get the path to the gallery
$galleryID = (int) $_POST['galleryselect'];
$gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
nggAdmin::import_gallery($gallerypath);
}
}
if (isset($_POST['disable_flash'])) {
check_admin_referer('ngg_addgallery');
$ngg->options['swfUpload'] = false;
update_option('ngg_options', $ngg->options);
}
if (isset($_POST['enable_flash'])) {
check_admin_referer('ngg_addgallery');
$ngg->options['swfUpload'] = true;
update_option('ngg_options', $ngg->options);
}
//get all galleries (after we added new ones)
$gallerylist = nggdb::find_all_galleries();
?>
<?php
if ($ngg->options['swfUpload']) {
?>
<!-- SWFUpload script -->
<script type="text/javascript">
var ngg_swf_upload;
window.onload = function () {
ngg_swf_upload = new SWFUpload({
// Backend settings
upload_url : "<?php
echo $swf_upload_link;
?>
",
flash_url : "<?php
echo NGGALLERY_URLPATH;
?>
admin/js/swfupload.swf",
// Button Settings
button_placeholder_id : "spanButtonPlaceholder",
button_width: 300,
button_height: 27,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
// File Upload Settings
file_size_limit : "<?php
echo wp_max_upload_size();
?>
b",
file_types : "*.jpg;*.gif;*.png",
file_types_description : "<?php
_e('Image Files', 'nggallery');
?>
//.........这里部分代码省略.........