本文整理汇总了PHP中nggGallery::show_message方法的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery::show_message方法的具体用法?PHP nggGallery::show_message怎么用?PHP nggGallery::show_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggGallery
的用法示例。
在下文中一共展示了nggGallery::show_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processor
/**
* Save/Load options and add a new hook for plugins
*
* @return void
*/
function processor()
{
global $ngg, $nggRewrite;
$old_state = $ngg->options['usePermalinks'];
if (isset($_POST['irDetect'])) {
check_admin_referer('ngg_settings');
$ngg->options['irURL'] = ngg_search_imagerotator();
update_option('ngg_options', $ngg->options);
}
if (isset($_POST['updateoption'])) {
check_admin_referer('ngg_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 = isset($_POST[$option]) ? trim($_POST[$option]) : false;
// $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']);
$ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
// the custom sortorder must be ascending
$ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
}
// Save options
update_option('ngg_options', $ngg->options);
// Flush Rewrite rules
if ($old_state != $ngg->options['usePermalinks']) {
$nggRewrite->flush();
}
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
if (isset($_POST['clearcache'])) {
check_admin_referer('ngg_settings');
$path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
if (is_dir($path)) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
@unlink($path . '/' . $file);
}
}
closedir($handle);
}
}
nggGallery::show_message(__('Cache cleared', 'nggallery'));
}
if (isset($_POST['createslugs'])) {
check_admin_referer('ngg_settings');
include_once dirname(__FILE__) . '/upgrade.php';
ngg_rebuild_unique_slugs::start_rebuild();
}
do_action('ngg_update_options_page');
}
示例2: nggallery_admin_options
function nggallery_admin_options()
{
global $wpdb, $ngg, $nggRewrite;
$old_state = $ngg->options['usePermalinks'];
// same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
$filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
if (isset($_POST['updateoption'])) {
check_admin_referer('ngg_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 = trim($_POST[$option]);
// $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']);
$ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
// the custom sortorder must be ascending
$ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
}
// Save options
update_option('ngg_options', $ngg->options);
// Flush ReWrite rules
if ($old_state != $ngg->options['usePermalinks']) {
$nggRewrite->flush();
}
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
if (isset($_POST['clearcache'])) {
$path = WINABSPATH . $ngg->options['gallerypath'] . "cache/";
if (is_dir($path)) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
@unlink($path . '/' . $file);
}
}
closedir($handle);
}
}
nggGallery::show_message(__('Cache cleared', 'nggallery'));
}
// message windows
if (!empty($messagetext)) {
echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>';
}
?>
<script type="text/javascript">
jQuery(function() {
jQuery('#slider > ul').tabs({ fxFade: true, fxSpeed: 'fast' });
});
function insertcode(value) {
var effectcode;
switch (value) {
case "none":
effectcode = "";
jQuery('#tbImage').hide("slow");
break;
case "thickbox":
effectcode = 'class="thickbox" rel="%GALLERY_NAME%"';
jQuery('#tbImage').show("slow");
break;
case "lightbox":
effectcode = 'rel="lightbox[%GALLERY_NAME%]"';
jQuery('#tbImage').hide("slow");
break;
case "highslide":
effectcode = 'class="highslide" onclick="return hs.expand(this, { slideshowGroup: %GALLERY_NAME% })"';
jQuery('#tbImage').hide("slow");
break;
case "shutter":
effectcode = 'class="shutterset_%GALLERY_NAME%"';
jQuery('#tbImage').hide("slow");
break;
default:
break;
}
jQuery("#thumbCode").val(effectcode);
};
function setcolor(fileid,color) {
jQuery(fileid).css("background", color );
};
</script>
<div id="slider" class="wrap">
<ul id="tabs">
<li><a href="#generaloptions"><?php
_e('General Options', 'nggallery');
?>
</a></li>
<li><a href="#thumbnails"><?php
_e('Thumbnails', 'nggallery');
//.........这里部分代码省略.........
示例3: nggallery_sortorder
/**
* @author Alex Rabe
*
*/
function nggallery_sortorder($galleryID = 0){
global $wpdb, $ngg, $nggdb;
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++;
}
do_action('ngg_gallery_sort', $galleryID);
nggGallery::show_message(__('Sort order changed','nggallery'));
}
}
// look for presort args
$presort = isset($_GET['presort']) ? $_GET['presort'] : false;
$dir = ( isset($_GET['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 = $nggdb->get_gallery($galleryID, $presort, $dir, false);
else
$picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
//this is the url without any presort variable
$clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID;
//if we go back , then the mode should be edit
$back_url = 'admin.php?page=nggallery-manage-gallery&mode=edit&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">
// seralize the ImageOrder
function saveImageOrder()
{
var serial = "";
var objects = document.getElementsByTagName('div');
for(var no=0;no<objects.length;no++){
if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted'){
if (serial.length > 0) serial = serial + '&'
serial = serial + "sortArray[]=" + objects[no].id;
}
}
jQuery('input[name=sortorder]').val(serial);
// debug( 'This is the new order of the images(IDs) : <br>' + orderString );
}
jQuery(document).ready(function($) {
$(".jqui-sortable").sortable({items: 'div.imageBox'});
});
</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">
<a href="<?php echo esc_url( $back_url ); ?>" class="button"><?php _e('Back to gallery', 'nggallery'); ?></a>
</div>
</div>
<input name="sortorder" type="hidden" />
<ul class="subsubsub">
<li><?php _e('Presort', 'nggallery') ?> :</li>
<li><a href="<?php echo esc_attr(remove_query_arg('presort', $base_url)); ?>" <?php if ($presort == '') echo 'class="current"'; ?>><?php _e('Unsorted', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('presort', 'pid', $base_url)); ?>" <?php if ($presort == 'pid') echo 'class="current"'; ?>><?php _e('Image ID', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('presort', 'filename', $base_url)); ?>" <?php if ($presort == 'filename') echo 'class="current"'; ?>><?php _e('Filename', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('presort', 'alttext', $base_url)); ?>" <?php if ($presort == 'alttext') echo 'class="current"'; ?>><?php _e('Alt/Title text', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('presort', 'imagedate', $base_url)); ?>" <?php if ($presort == 'imagedate') echo 'class="current"'; ?>><?php _e('Date/Time', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('dir', 'ASC', $base_url)); ?>" <?php if ($dir == 'ASC') echo 'class="current"'; ?>><?php _e('Ascending', 'nggallery') ?></a> |</li>
<li><a href="<?php echo esc_attr(add_query_arg('dir', 'DESC', $base_url)); ?>" <?php if ($dir == 'DESC') echo 'class="current"'; ?>><?php _e('Descending', 'nggallery') ?></a></li>
</ul>
</form>
//.........这里部分代码省略.........
示例4: nggallery_admin_setup
function nggallery_admin_setup()
{
global $wpdb, $ngg;
if (isset($_POST['resetdefault'])) {
check_admin_referer('ngg_uninstall');
include_once dirname(__FILE__) . '/install.php';
ngg_default_options();
$ngg->load_options();
nggGallery::show_message(__('Reset all settings to default parameter', 'nggallery'));
}
if (isset($_POST['uninstall'])) {
check_admin_referer('ngg_uninstall');
include_once dirname(__FILE__) . '/install.php';
nggallery_uninstall();
nggGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !', 'nggallery'));
}
?>
<div class="wrap">
<h2><?php
_e('Reset options', 'nggallery');
?>
</h2>
<form name="resetsettings" method="post">
<?php
wp_nonce_field('ngg_uninstall');
?>
<p><?php
_e('Reset all options/settings to the default installation.', 'nggallery');
?>
</p>
<div align="center"><input type="submit" class="button" name="resetdefault" value="<?php
_e('Reset settings', 'nggallery');
?>
" onclick="javascript:check=confirm('<?php
_e('Reset all options to default settings ?\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'nggallery');
?>
');if(check==false) return false;" /></div>
</form>
</div>
<?php
if (!is_multisite() || is_super_admin()) {
?>
<div class="wrap">
<h2><?php
_e('Uninstall plugin tables', 'nggallery');
?>
</h2>
<form name="resetsettings" method="post">
<div>
<?php
wp_nonce_field('ngg_uninstall');
?>
<p><?php
_e('You don\'t like NextCellent Gallery ?', 'nggallery');
?>
</p>
<p><?php
_e('No problem, before you deactivate this plugin press the Uninstall Button, because deactivating NextCellent Gallery does not remove any data that may have been created. ', 'nggallery');
?>
</div>
<p><font color="red"><strong><?php
_e('WARNING:', 'nggallery');
?>
</strong><br />
<?php
_e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to backup all the tables first. NextCellent gallery is stored in the tables', 'nggallery');
?>
<strong><?php
echo $wpdb->nggpictures;
?>
</strong>, <strong><?php
echo $wpdb->nggalbum;
?>
</strong> <?php
_e('and', 'nggallery');
?>
<strong><?php
echo $wpdb->nggalbum;
?>
</strong>.</font></p>
<div align="center">
<input type="submit" name="uninstall" class="button delete" value="<?php
_e('Uninstall plugin', 'nggallery');
?>
" onclick="javascript:check=confirm('<?php
_e('You are about to Uninstall this plugin from WordPress.\\nThis action is not reversible.\\n\\nChoose [Cancel] to Stop, [OK] to Uninstall.\\n', 'nggallery');
?>
');if(check==false) return false;"/>
</div>
</form>
</div>
<?php
}
?>
<?php
}
示例5: nggallery_sortorder
/**
* @author Alex Rabe
* @copyright 2008-2011
*/
function nggallery_sortorder($galleryID = 0)
{
global $wpdb, $ngg, $nggdb;
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++;
}
do_action('ngg_gallery_sort', $galleryID);
nggGallery::show_message(__('Sort order changed', 'nggallery'));
}
}
// look for presort args
$presort = isset($_GET['presort']) ? $_GET['presort'] : false;
$dir = isset($_GET['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 = $nggdb->get_gallery($galleryID, $presort, $dir, false);
} else {
$picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
}
//this is the url without any presort variable
$clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID;
//if we go back , then the mode should be edit
$back_url = 'admin.php?page=nggallery-manage-gallery&mode=edit&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">
<a href="<?php
echo esc_url($back_url);
?>
" class="button"><?php
_e('Back to gallery', 'nggallery');
?>
</a>
</div>
</div>
<input name="sortorder" type="hidden" />
<ul class="subsubsub">
<li><?php
_e('Presort', 'nggallery');
?>
:</li>
<li><a href="<?php
echo esc_attr(remove_query_arg('presort', $base_url));
?>
" <?php
if ($presort == '') {
echo 'class="current"';
}
?>
><?php
//.........这里部分代码省略.........
示例6: processor
/**
* Save/Load options and add a new hook for plugins
*/
public function processor()
{
global $ngg, $nggRewrite;
$old_state = $ngg->options['usePermalinks'];
$old_slug = $ngg->options['permalinkSlug'];
if (isset($_POST['updateoption'])) {
check_admin_referer('ngg_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;
}
}
$ngg->options[$option] = $value;
}
// do not allow a empty string
if (empty($ngg->options['permalinkSlug'])) {
$ngg->options['permalinkSlug'] = 'nggallery';
}
// the path should always end with a slash
$ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
$ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
// the custom sortorder must be ascending
$ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
}
// Save options
update_option('ngg_options', $ngg->options);
// Flush Rewrite rules
if ($old_state != $ngg->options['usePermalinks'] || $old_slug != $ngg->options['permalinkSlug']) {
$nggRewrite->flush();
}
nggGallery::show_message(__('Settings updated successfully', 'nggallery'));
}
if (isset($_POST['clearcache'])) {
check_admin_referer('ngg_settings');
$path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
if (is_dir($path)) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
@unlink($path . '/' . $file);
}
}
closedir($handle);
}
}
nggGallery::show_message(__('Cache cleared', 'nggallery'));
}
if (isset($_POST['createslugs'])) {
check_admin_referer('ngg_settings');
ngg_rebuild_unique_slugs::start_rebuild();
}
do_action('ngg_update_options_page');
}
示例7: update_album
function update_album()
{
check_admin_referer('ngg_thickbox_form');
if (!nggGallery::current_user_can('NextGEN Edit album settings')) {
wp_die(__('Cheatin’ uh?'));
}
$this->currentID = $_REQUEST['act_album'];
$album = $this->_get_album($this->currentID);
$album->name = stripslashes($_POST['album_name']);
$album->albumdesc = stripslashes($_POST['album_desc']);
$album->previewpic = (int) $_POST['previewpic'];
$album->pageid = (int) $_POST['pageid'];
$result = C_Album_Mapper::get_instance()->save($album);
//hook for other plugin to update the fields
do_action('ngg_update_album', $this->currentID, $_POST);
if ($result) {
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
}
示例8: nggallery_admin_roles
function nggallery_admin_roles()
{
if (isset($_POST['update_cap'])) {
check_admin_referer('ngg_addroles');
// now set or remove the capability
ngg_set_capability($_POST['general'], "NextGEN Gallery overview");
ngg_set_capability($_POST['tinymce'], "NextGEN Use TinyMCE");
ngg_set_capability($_POST['add_gallery'], "NextGEN Upload images");
ngg_set_capability($_POST['manage_gallery'], "NextGEN Manage gallery");
ngg_set_capability($_POST['manage_others'], "NextGEN Manage others gallery");
ngg_set_capability($_POST['manage_tags'], "NextGEN Manage tags");
ngg_set_capability($_POST['edit_album'], "NextGEN Edit album");
ngg_set_capability($_POST['change_style'], "NextGEN Change style");
ngg_set_capability($_POST['change_options'], "NextGEN Change options");
nggGallery::show_message(__('Updated capabilities', "nggallery"));
}
?>
<div class="wrap">
<?php
screen_icon('nextgen-gallery');
?>
<h2><?php
_e('Roles / capabilities', 'nggallery');
?>
</h2>
<p><?php
_e('Select the lowest role which should be able to access the following capabilities. NextCellent Gallery supports the standard roles from WordPress.', 'nggallery');
?>
<br />
<?php
_e('For a more flexible user management you can use the', 'nggallery');
?>
<a href="http://wordpress.org/extend/plugins/capsman/" target="_blank">Capability Manager</a>.</p>
<form name="addroles" id="addroles" method="POST" accept-charset="utf-8" >
<?php
wp_nonce_field('ngg_addroles');
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="general"><?php
_e('NextCellent Gallery overview', 'nggallery');
?>
</label></th>
<td><select name="general" id="general"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Gallery overview'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="tinymce"><?php
_e('Use TinyMCE Button / Add Media', 'nggallery');
?>
</label></th>
<td><select name="tinymce" id="tinymce"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Use TinyMCE'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="add_gallery"><?php
_e('Add gallery / Upload images', 'nggallery');
?>
</label></th>
<td><select name="add_gallery" id="add_gallery"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Upload images'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="manage_gallery"><?php
_e('Manage gallery', 'nggallery');
?>
</label></th>
<td><select name="manage_gallery" id="manage_gallery"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Manage gallery'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="manage_others"><?php
_e('Manage others gallery', 'nggallery');
?>
</label></th>
<td><select name="manage_others" id="manage_others"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Manage others gallery'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="manage_tags"><?php
_e('Manage tags', 'nggallery');
?>
</label></th>
<td><select name="manage_tags" id="manage_tags"><?php
wp_dropdown_roles(ngg_get_role('NextGEN Manage tags'));
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><label for="edit_album"><?php
//.........这里部分代码省略.........
示例9: update_album
function update_album()
{
global $wpdb;
check_admin_referer('ngg_thickbox_form');
$name = esc_attr($_POST['album_name']);
$desc = esc_attr($_POST['album_desc']);
$prev = (int) $_POST['previewpic'];
$link = (int) $_POST['pageid'];
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggalbum} SET name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '{$this->currentID}'", $name, $desc, $prev, $link));
if ($result) {
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
}
示例10: processor
/**
* Save, change and move the css files and options.
*
* @since 1.9.22
*
*/
function processor()
{
global $ngg;
$i = 0;
if (isset($_POST['activate'])) {
check_admin_referer('ngg_style');
$file = $_POST['css'];
$activate = $_POST['activateCSS'];
// save option now
$ngg->options['activateCSS'] = $activate;
$ngg->options['CSSfile'] = $file;
update_option('ngg_options', $ngg->options);
if (isset($activate)) {
nggGallery::show_message(__('Successfully selected CSS file.', 'nggallery'));
} else {
nggGallery::show_message(__('No CSS file will be used.', 'nggallery'));
}
}
if (isset($_POST['updatecss'])) {
check_admin_referer('ngg_style');
if (!current_user_can('edit_themes')) {
wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
}
$newcontent = stripslashes($_POST['newcontent']);
$old_path = $_POST['file'];
$folder = $_POST['folder'];
//if the file is in the css folder, copy it.
if ($folder === 'css') {
$filename = basename($old_path, '.css');
$new_path = NGG_CONTENT_DIR . "/ngg_styles/" . $filename . ".css";
//check for duplicate files
while (file_exists($new_path)) {
$i++;
$new_path = NGG_CONTENT_DIR . "/ngg_styles/" . $filename . "-" . $i . ".css";
}
//check if ngg_styles exist or not
if (!file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
wp_mkdir_p(NGG_CONTENT_DIR . "/ngg_styles");
}
//copy the file
if (copy($old_path, $new_path)) {
//set option to new file
$ngg->options['CSSfile'] = $new_path;
update_option('ngg_options', $ngg->options);
} else {
nggGallery::show_error(__('Could not move file.', 'nggallery'));
return;
}
}
if (file_put_contents($old_path, $newcontent)) {
nggGallery::show_message(__('CSS file successfully updated.', 'nggallery'));
} else {
nggGallery::show_error(__('Could not save file.', 'nggallery'));
}
}
if (isset($_POST['movecss'])) {
if (!current_user_can('edit_themes')) {
wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
}
$old_path = $_POST['oldpath'];
$new_path = NGG_CONTENT_DIR . "/ngg_styles/nggallery.css";
//check for duplicate files
while (file_exists($new_path)) {
$i++;
$new_path = NGG_CONTENT_DIR . "/ngg_styles/nggallery-" . $i . ".css";
}
//move file
if (rename($old_path, $new_path)) {
nggGallery::show_message(__('CSS file successfully moved.', 'nggallery'));
//set option to new file
$ngg->options['CSSfile'] = $new_path;
update_option('ngg_options', $ngg->options);
} else {
nggGallery::show_error(__('Could not move the CSS file.', 'nggallery'));
}
}
}
示例11: 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
//.........这里部分代码省略.........
示例12: nggallery_admin_style
function nggallery_admin_style()
{
global $ngg;
if ($theme_css_exists = file_exists(TEMPLATEPATH . "/nggallery.css")) {
$real_file = TEMPLATEPATH . "/nggallery.css";
$file_show = 'nggallery.css ' . __('(From the theme folder)', 'nggallery');
} else {
if (isset($_POST['css'])) {
check_admin_referer('ngg_style');
$act_cssfile = $_POST['css'];
if (isset($_POST['activate'])) {
// save option now
$ngg->options['activateCSS'] = $_POST['activateCSS'];
$ngg->options['CSSfile'] = $act_cssfile;
update_option('ngg_options', $ngg->options);
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
} else {
// get the options
if (isset($_POST['file'])) {
$act_cssfile = $_POST['file'];
} else {
$act_cssfile = $ngg->options['CSSfile'];
}
}
// set the path
$real_file = NGGALLERY_ABSPATH . "css/" . $act_cssfile;
}
if (isset($_POST['updatecss'])) {
check_admin_referer('ngg_style');
if (!current_user_can('edit_themes')) {
wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
}
$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
nggGallery::show_message(__('CSS file successfully updated', 'nggallery'));
}
}
// get the content of the file
//TODO: BUG : Read failed after write a file, maybe a Cache problem
$error = !is_file($real_file);
if (!$error && filesize($real_file) > 0) {
$f = fopen($real_file, 'r');
$content = fread($f, filesize($real_file));
$content = htmlspecialchars($content);
}
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#colorSelector').ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
jQuery(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
jQuery(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
}
});
});
</script>
<div class="wrap">
<div class="bordertitle">
<?php
screen_icon('nextgen-gallery');
?>
<h2><?php
_e('Style Editor', 'nggallery');
?>
</h2>
<?php
if (!$theme_css_exists) {
?>
<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;" onchange="this.form.submit();">
<?php
$csslist = ngg_get_cssfiles();
foreach ($csslist as $key => $a_cssfile) {
$css_name = $a_cssfile['Name'];
if ($key == $act_cssfile) {
$file_show = $key;
//.........这里部分代码省略.........
示例13: 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':
//.........这里部分代码省略.........
示例14: update_album
function update_album()
{
global $wpdb, $nggdb;
check_admin_referer('ngg_thickbox_form');
if (!nggGallery::current_user_can('NextGEN Edit album settings')) {
wp_die(__('Cheatin’ uh?'));
}
$name = $_POST['album_name'];
$desc = $_POST['album_desc'];
$prev = (int) $_POST['previewpic'];
$link = (int) $_POST['pageid'];
// slug must be unique, we use the title for that
$slug = nggdb::get_unique_slug(sanitize_title($name), 'album', $this->currentID);
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggalbum} SET slug= '%s', name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '%d'", $slug, $name, $desc, $prev, $link, $this->currentID));
//hook for other plugin to update the fields
do_action('ngg_update_album', $this->currentID, $_POST);
if ($result) {
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
}
示例15: upload_images
/**
* Function for uploading of images via the upload form
*
* @class nggAdmin
* @return void
*/
function upload_images()
{
global $nggdb;
// WPMU action
if (nggWPMU::check_quota()) {
return;
}
// Images must be an array
$imageslist = array();
// get selected gallery
$galleryID = (int) $_POST['galleryselect'];
if ($galleryID == 0) {
nggGallery::show_error(__('No gallery selected !', 'nggallery'));
return;
}
// get the path to the gallery
$gallery = $nggdb->find_gallery($galleryID);
if (empty($gallery->path)) {
nggGallery::show_error(__('Failure in database, no gallery path set !', 'nggallery'));
return;
}
// read list of images
$dirlist = nggAdmin::scandir($gallery->abspath);
$imagefiles = $_FILES['imagefiles'];
if (is_array($imagefiles)) {
foreach ($imagefiles['name'] as $key => $value) {
// look only for uploded files
if ($imagefiles['error'][$key] == 0) {
$temp_file = $imagefiles['tmp_name'][$key];
//clean filename and extract extension
$filepart = nggGallery::fileinfo($imagefiles['name'][$key]);
$filename = $filepart['basename'];
// check for allowed extension and if it's an image file
$ext = array('jpg', 'png', 'gif');
if (!in_array($filepart['extension'], $ext) || !@getimagesize($temp_file)) {
nggGallery::show_error('<strong>' . esc_html($imagefiles['name'][$key]) . ' </strong>' . __('is no valid image file!', 'nggallery'));
continue;
}
// check if this filename already exist in the folder
$i = 0;
while (in_array($filename, $dirlist)) {
$filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
}
$dest_file = $gallery->abspath . '/' . $filename;
//check for folder permission
if (!is_writeable($gallery->abspath)) {
$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html($gallery->abspath));
nggGallery::show_error($message);
return;
}
// save temp file to gallery
if (!@move_uploaded_file($temp_file, $dest_file)) {
nggGallery::show_error(__('Error, the file could not be moved to : ', 'nggallery') . esc_html($dest_file));
nggAdmin::check_safemode($gallery->abspath);
continue;
}
if (!nggAdmin::chmod($dest_file)) {
nggGallery::show_error(__('Error, the file permissions could not be set', 'nggallery'));
continue;
}
// add to imagelist & dirlist
$imageslist[] = $filename;
$dirlist[] = $filename;
}
}
}
if (count($imageslist) > 0) {
// add images to database
$image_ids = nggAdmin::add_Images($galleryID, $imageslist);
//create thumbnails
nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
//add the preview image if needed
nggAdmin::set_gallery_preview($galleryID);
nggGallery::show_message(count($image_ids) . __(' Image(s) successfully added', 'nggallery'));
}
return;
}