function add_menu() { add_menu_page(_n('Gallery', 'Galleries', 1, 'nggallery'), _n('Gallery', 'Galleries', 1, 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array(&$this, 'show_menu'), 'div'); add_submenu_page(NGGFOLDER, __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Manage Gallery', 'nggallery'), __('Manage Gallery', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, _n('Album', 'Albums', 1, 'nggallery'), _n('Album', 'Albums', 1, 'nggallery'), 'NextGEN Edit album', 'nggallery-manage-album', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Options', 'nggallery'), __('Options', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array(&$this, 'show_menu')); if (wpmu_enable_function('wpmuStyle')) { add_submenu_page(NGGFOLDER, __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array(&$this, 'show_menu')); } if (wpmu_enable_function('wpmuRoles') || wpmu_site_admin()) { add_submenu_page(NGGFOLDER, __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array(&$this, 'show_menu')); } add_submenu_page(NGGFOLDER, __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array(&$this, 'show_menu')); //TODO: Remove after WP 3.1 release, not longer needed if (is_multisite() && wpmu_site_admin()) { add_submenu_page('ms-admin.php', __('NextGEN Gallery', 'nggallery'), __('NextGEN Gallery', 'nggallery'), 'activate_plugins', 'nggallery-wpmu', array(&$this, 'show_menu')); } if (!is_multisite() || wpmu_site_admin()) { add_submenu_page(NGGFOLDER, __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array(&$this, 'show_menu')); } //register the column fields $this->register_columns(); }
function add_menu() { add_menu_page(__ngettext('Gallery', 'Galleries', 1, 'nggallery'), __ngettext('Gallery', 'Galleries', 1, 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array(&$this, 'show_menu'), NGGALLERY_URLPATH . 'admin/images/nextgen.png'); add_submenu_page(NGGFOLDER, __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Manage Gallery', 'nggallery'), __('Manage Gallery', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __ngettext('Album', 'Albums', 1, 'nggallery'), __ngettext('Album', 'Albums', 1, 'nggallery'), 'NextGEN Edit album', 'nggallery-manage-album', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array(&$this, 'show_menu')); add_submenu_page(NGGFOLDER, __('Options', 'nggallery'), __('Options', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array(&$this, 'show_menu')); if (wpmu_enable_function('wpmuStyle')) { add_submenu_page(NGGFOLDER, __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array(&$this, 'show_menu')); } add_submenu_page(NGGFOLDER, __('Setup Gallery', 'nggallery'), __('Setup', 'nggallery'), 'activate_plugins', 'nggallery-setup', array(&$this, 'show_menu')); if (wpmu_enable_function('wpmuRoles')) { add_submenu_page(NGGFOLDER, __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array(&$this, 'show_menu')); } add_submenu_page(NGGFOLDER, __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array(&$this, 'show_menu')); if (wpmu_site_admin()) { add_submenu_page('wpmu-admin.php', __('NextGEN Gallery', 'nggallery'), __('NextGEN Gallery', 'nggallery'), 'activate_plugins', 'nggallery-wpmu', array(&$this, 'show_menu')); } }
function add_menu() { add_menu_page( _n( 'Gallery', 'Galleries', 1, 'nggallery' ), _n( 'Gallery', 'Galleries', 1, 'nggallery' ), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') ); add_submenu_page( NGGFOLDER , __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , __('Manage Gallery', 'nggallery'), __('Manage Gallery', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , _n( 'Album', 'Albums', 1, 'nggallery' ), _n( 'Album', 'Albums', 1, 'nggallery' ), 'NextGEN Edit album', 'nggallery-manage-album', array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , __('Options', 'nggallery'), __('Options', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array (&$this, 'show_menu')); if ( wpmu_enable_function('wpmuStyle') ) add_submenu_page( NGGFOLDER , __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array (&$this, 'show_menu')); if ( wpmu_enable_function('wpmuRoles') || wpmu_site_admin() ) add_submenu_page( NGGFOLDER , __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array (&$this, 'show_menu')); add_submenu_page( NGGFOLDER , __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array (&$this, 'show_menu')); if ( !is_multisite() || wpmu_site_admin() ) add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu')); //register the column fields $this->register_columns(); }
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() || wpmu_site_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 NextGEN Gallery ?', 'nggallery'); ?> </p> <p><?php _e('No problem, before you deactivate this plugin press the Uninstall Button, because deactivating NextGEN 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. NextGEN 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 }
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; $selected = " selected='selected'"; $act_css_description = $a_cssfile['Description']; $act_css_author = $a_cssfile['Author']; $act_css_version = $a_cssfile['Version']; } else { $selected = ''; } $css_name = esc_attr($css_name); echo "\n\t<option value=\"{$key}\" {$selected}>{$css_name}</option>"; } ?> </select> <input class="button" type="submit" name="activate" value="<?php _e('Activate', 'nggallery'); ?> »" class="button" /> </form> <?php } ?> </div> <br style="clear: both;"/> <?php if (!is_multisite() || wpmu_site_admin()) { ?> <div class="tablenav"> <?php if (is_writeable($real_file)) { echo '<big>' . sprintf(__('Editing <strong>%s</strong>', 'nggallery'), $file_show) . '</big>'; } else { echo '<big>' . sprintf(__('Browsing <strong>%s</strong>', 'nggallery'), $file_show) . '</big>'; } ?> </div> <br style="clear: both;"/> <div id="templateside"> <?php if (!$theme_css_exists) { ?> <ul> <li><strong><?php _e('Author', 'nggallery'); ?> :</strong> <?php echo $act_css_author; ?> </li> <li><strong><?php _e('Version', 'nggallery'); ?> :</strong> <?php echo $act_css_version; ?> </li> <li><strong><?php _e('Description', 'nggallery'); ?> :<br /></strong> <?php echo $act_css_description; ?> </li> </ul> <p><?php _e('Tip : Copy your stylesheet (nggallery.css) to your theme folder, so it will be not lost during a upgrade', 'nggallery'); ?> </p> <?php } else { ?> <p><?php _e('Your theme contain a NextGEN Gallery stylesheet (nggallery.css), this file will be used', 'nggallery'); ?> </p> <?php } ?> <p><?php _e('Tip No. 2: Use the color picker below to help you find the right color scheme for your gallery!', 'nggallery'); ?> </p> <div id="colorSelector"> <div></div> </div> </div> <?php if (!$error) { ?> <form name="template" id="template" method="post"> <?php wp_nonce_field('ngg_style'); ?> <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress css"><?php echo $content; ?> </textarea> <input type="hidden" name="updatecss" value="updatecss" /> <input type="hidden" name="file" value="<?php echo $file_show; ?> " /> </div> <?php if (is_writeable($real_file)) { ?> <p class="submit"> <input class="button-primary action" type="submit" name="submit" value="<?php _e('Update File', 'nggallery'); ?> " tabindex="2" /> </p> <?php } else { ?> <p><em><?php _e('If this file were writable you could edit it.', 'nggallery'); ?> </em></p> <?php } ?> </form> <?php } else { echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.', 'nggallery') . '</p></div>'; } ?> <div class="clear"> </div> </div> <!-- wrap--> <?php } }