Jeg har et spørgsmål vedrørende hvorhenne jeg retter i koden, så jeg ikke får et link til "full size" (vist på billedeksemplet med en rød ring) Jeg vil gerne have man skal blive på siden og ikke få vist billedet i et nyt vindue.
ex. nedenfor:
http://Billedeupload.dk/showpic-181.jpg
Jeg bruger et plug-in der hedder "nextGEN gallery". Er ellers fuldt ud tilfreds med det.
Lægger hermed nggallery.php med så en forhåbentlig en venlig sjæl kan sige mig hvor jeg skal rette henne og evt. til hvad.
<?php
/*
Plugin Name: NextGEN Gallery
Plugin URI: http://alexrabe.boelinger.com/?page_id=80
Description: A NextGENeration Photo gallery for the WEB2.0(beta).
Author: NextGEN DEV-Team
Version: 0.74
Author URI: http://alexrabe.boelinger.com/
Copyright 2007 by Alex Rabe & NextGEN DEV-Team
The NextGEN button is taken from the Silk set of FamFamFam. See more at
http://www.famfamfam.com/lab/icons/silk/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//#################################################################
// Stop direct call
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
//#################################################################
// Let's Go
global $wpdb, $wp_version;
// ini_set('display_errors', '1');
// ini_set('error_reporting', E_ALL);
//This works only in WP2.1 or higher
if (version_compare($wp_version, '2.1', '>=')) {
// Permission settings ############################################
define('NGGFOLDER_PERMISSION', 0777);
define('NGGFILE_PERMISSION', 0666);
// ################################################################
// Version and path to check version
define('NGGVERSION', "0.74");
define('NGGURL', "http://nextgen.boelinger.com/version.php");
// define URL
$myabspath = str_replace("\\","/",ABSPATH); // required for Windows & XAMPP
define('WINABSPATH', $myabspath);
define('NGGFOLDER', dirname(plugin_basename(__FILE__)));
define('NGGALLERY_ABSPATH', $myabspath.'wp-content/plugins/' . NGGFOLDER .'/');
define('NGGALLERY_URLPATH', get_option('siteurl').'/wp-content/plugins/' . NGGFOLDER.'/');
// look for imagerotator
define('NGGALLERY_IREXIST', file_exists(NGGALLERY_ABSPATH.'imagerotator.swf'));
// get value for safe mode
if ((gettype(ini_get('safe_mode')) == 'string')) {
// if sever did in in a other way
if (ini_get('safe_mode') == 'off') define('SAFE_MODE', FALSE);
else define('SAFE_MODE', ini_get('safe_mode'));
} else
define('SAFE_MODE', ini_get('safe_mode'));
//read the options
$ngg_options = get_option('ngg_options');
// add database pointer
$wpdb->nggpictures = $wpdb->prefix . 'ngg_pictures';
$wpdb->nggallery = $wpdb->prefix . 'ngg_gallery';
$wpdb->nggalbum = $wpdb->prefix . 'ngg_album';
$wpdb->nggtags = $wpdb->prefix . 'ngg_tags';
$wpdb->nggpic2tags = $wpdb->prefix . 'ngg_pic2tags';
// Load language
function nggallery_init ()
{
load_plugin_textdomain('nggallery','wp-content/plugins/' . NGGFOLDER.'/lang');
}
// Load admin panel
include_once (dirname (__FILE__)."/ngginstall.php");
include_once (dirname (__FILE__)."/nggfunctions.php");
include_once (dirname (__FILE__)."/admin/admin.php");
// load gallery class
require_once (dirname (__FILE__).'/lib/nggallery.lib.php');
$nggallery = new nggallery();
// add javascript to header
add_action('wp_head', 'ngg_addjs', 1);
function ngg_addjs() {
global $wp_version, $ngg_options;
echo "<meta name='NextGEN' content='".NGGVERSION."' />\n";
if ($ngg_options['activateCSS'])
echo "\n".'<style type="text/css" media="screen">@import "'.NGGALLERY_URLPATH.'css/'.$ngg_options[CSSfile].'";</style>';
if ($ngg_options['thumbEffect'] == "thickbox") {
echo "\n".'<script type="text/javascript"> var tb_pathToImage = "'.NGGALLERY_URLPATH.'thickbox/'.$ngg_options[thickboxImage].'";</script>';
echo "\n".'<style type="text/css" media="screen">@import "'.NGGALLERY_URLPATH.'thickbox/thickbox.css";</style>'."\n";
if ($wp_version < "2.3") {
if ($wp_version > "2.1.3") wp_deregister_script('jquery');
wp_enqueue_script('jquery', NGGALLERY_URLPATH .'admin/js/jquery.js', FALSE, '1.1.3.1');
}
wp_enqueue_script('thickbox', NGGALLERY_URLPATH .'thickbox/thickbox-pack.js', array('jquery'), '3.1.1');
// add NextGEN jQuery Plugin
if ($ngg_options['galUsejQuery'])
wp_enqueue_script('nextgen', NGGALLERY_URLPATH .'admin/js/jquery.nextgen.pack.js', array('jquery'), '0.5');
//TODO: NEW AJAX Version
// wp_enqueue_script('nextgen-ajax', NGGALLERY_URLPATH .'admin/js/jquery.nextgen.ajax.js', array('jquery'), '0.1');
// wp_enqueue_script('blockui', NGGALLERY_URLPATH .'admin/js/jquery.blockUI.js', array('jquery'), '0.1');
}
// test for wordTube function
if (!function_exists('integrate_swfobject')) {
wp_enqueue_script('swfobject', NGGALLERY_URLPATH .'js/swfobject.js', FALSE, '1.5');
}
}
// load language file
add_action('init', 'nggallery_init');
add_action('activate_' . NGGFOLDER.'/nggallery.php', 'ngg_install');
// init tables in wp-database if plugin is activated
function ngg_install() {
nggallery_install();
}
// Action calls for all functions
add_filter('the_content', 'searchnggallerytags');
add_filter('the_excerpt', 'searchnggallerytags');
//#################################################################
// add action/filter for the upload tab
add_action('upload_files_ngg_gallery', 'ngg_action_upload_Tab');
add_filter('wp_upload_tabs', 'ngg_wp_upload_tabs');
function ngg_action_upload_Tab() {
// execute when click on the tab
global $style;
if ( 'inline' == $style )
wp_enqueue_script('nggadmintab', NGGALLERY_URLPATH .'js/nggadmintab-js.php', array('prototype'), '0.6');
}
function ngg_wp_upload_tabs ($array) {
global $wpdb;
/*
0 => tab display name,
1 => required cap / role,
2 => function that produces tab content,
3 => total number objects OR array(total, objects per page),
4 => add_query_args
*/
include_once (dirname (__FILE__)."/nggadmintab.php");
// Create navigation
$total = 1;
if ($_GET['select_gal']){
$galleryID = $_GET['select_gal'];
$total = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = '$galleryID'");
}
$tab = array(
'ngg_gallery' => array(__('Gallery','nggallery'), 'NextGEN Use TinyMCE', 'ngg_upload_tab_content', array($total, 10))
);
return array_merge($array,$tab);
}
//#################################################################
// TinyMCE Button Integration
// Load the Script for the Button
function insert_nextgen_script() {
//TODO: Do with WP2.1 Script Loader
// Thanks for this idea to http://www.jovelstefan.de
echo "\n"."
<script type='text/javascript'>
function ngg_buttonscript() {
if(window.tinyMCE) {
var template = new Array();
template['file'] = '".NGGALLERY_URLPATH."nggbutton.php';
template['width'] = 360;
template['height'] = 210;
args = {
resizable : 'no',
scrollbars : 'no',
inline : 'yes'
};
tinyMCE.openWindow(template, args);
return true;
}
}
</script>";
return;
}
function ngg_addbuttons() {
global $wp_db_version;
// Don't bother doing this stuff if the current user lacks permissions
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) return;
// Check for NextGEN capability
if ( !current_user_can('NextGEN Use TinyMCE') ) return;
// Add only in Rich Editor mode
if ( get_user_option('rich_editing') == 'true') {
// add the button for wp21 in a new way
add_filter("mce_plugins", "nextgen_button_plugin", 5);
add_filter('mce_buttons', 'nextgen_button', 5);
add_action('tinymce_before_init','nextgen_button_script');
}
}
// used to insert button in wordpress 2.1x editor
function nextgen_button($buttons) {
array_push($buttons, "separator", "NextGEN");
return $buttons;
}
// Tell TinyMCE that there is a plugin (wp2.1)
function nextgen_button_plugin($plugins) {
array_push($plugins, "-NextGEN");
return $plugins;
}
// Load the TinyMCE plugin : editor_plugin.js (wp2.1)
function nextgen_button_script() {
$pluginURL = NGGALLERY_URLPATH.'js/';
echo 'tinyMCE.loadPlugin("NextGEN", "'.$pluginURL.'");' . "\n";
return;
}
// init process for button control
add_action('init', 'ngg_addbuttons');
add_action('edit_page_form', 'insert_nextgen_script');
add_action('edit_form_advanced', 'insert_nextgen_script');
//#################################################################
} else {
add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error fade"><p>' . __('Sorry, NextGEN Gallery works only under WordPress 2.1 or higher',"nggallery") . '</p></div>\';'));
}// End Check for WP 2.1
?>
Der er også en widget-del... den kommer hermed her, hvis det er her jeg skal rette noget:
<?php
/*
Plugin Name: NextGEN Gallery Widget
Description: Adds a sidebar widget support to your NextGEN Gallery
Author: KeViN
Version: 1.12
Author URI: http://www.kev.hu
Plugin URI: http://www.kev.hu
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function nggGetCSVValues($string,$separator=",")
{
$string = str_replace('""', "'", $string);
// split the string at double quotes "
$bits = explode('"',$string);
$elements = array();
for ( $i=0; $i < count($bits) ; $i++ ) {
/*
odd numbered elements would have been
enclosed by double quotes
even numbered elements would not have been
*/
if (($i%2) == 1) {
/* if the element number is odd add the
whole string to the output array */
$elements[] = $bits[$i];
} else
{
/* otherwise split the unquoted stuff at commas
and add the elements to the array */
$rest = $bits[$i];
$rest = preg_replace("/^".$separator."/","",$rest);
$rest = preg_replace("/".$separator."$/","",$rest);
$elements = array_merge($elements,explode($separator,$rest));
}
}
return $elements;
}
/**********************************************************/
/* Slidehow widget function
/**********************************************************/
function nggSlideshowWidget($galleryID,$irWidth,$irHeight) {
// Check for NextGEN Gallery
if ( !function_exists('nggShowSlideshow') )
return;
global $wpdb;
$ngg_options = get_option('ngg_options');
if (empty($irWidth) ) $irWidth = $ngg_options[irWidth];
if (empty($irHeight)) $irHeight = $ngg_options[irHeight];
$replace .= "\n".'<div class="ngg-widget-slideshow" id="ngg_widget_slideshow'.$galleryID.'">';
$replace .= 'Get the Flash Player to see the slideshow.</div>';
$replace .= "\n\t".'<script type="text/javascript" defer="defer">';
$replace .= "\n\t".'<!--';
$replace .= "\n\t".'//<![CDATA[';
$replace .= "\n\t\t".'var so = new SWFObject("'.NGGALLERY_URLPATH.'imagerotator.swf", "ngg_slideshow'.$galleryID.'", "'.$irWidth.'", "'.$irHeight.'", "7", "#'.$ngg_options[irBackcolor].'");';
$replace .= "\n\t\t".'so.addParam("wmode", "opaque");';
$replace .= "\n\t\t".'so.addVariable("file", "'.NGGALLERY_URLPATH.'nggextractXML.php?gid='.$galleryID.'");';
if (!$ngg_options[irShuffle]) $replace .= "\n\t\t".'so.addVariable("shuffle", "false");';
// if ($ngg_options[irLinkfromdisplay]) $replace .= "\n\t\t".'so.addVariable("linkfromdisplay", "false");';
// if ($ngg_options[irShownavigation]) $replace .= "\n\t\t".'so.addVariable("shownavigation", "true");';
if ($ngg_options[irShowicons]) $replace .= "\n\t\t".'so.addVariable("showicons", "true");';
$replace .= "\n\t\t".'so.addVariable("overstretch", "'.$ngg_options[irOverstretch].'");';
$replace .= "\n\t\t".'so.addVariable("backcolor", "0x'.$ngg_options[irBackcolor].'");';
$replace .= "\n\t\t".'so.addVariable("frontcolor", "0x'.$ngg_options[irFrontcolor].'");';
$replace .= "\n\t\t".'so.addVariable("lightcolor", "0x'.$ngg_options[irLightcolor].'");';
$replace .= "\n\t\t".'so.addVariable("rotatetime", "'.$ngg_options[irRotatetime].'");';
$replace .= "\n\t\t".'so.addVariable("transition", "'.$ngg_options[irTransition].'");';
$replace .= "\n\t\t".'so.addVariable("width", "'.$irWidth.'");';
$replace .= "\n\t\t".'so.addVariable("height", "'.$irHeight.'");';
$replace .= "\n\t\t".'so.write("ngg_widget_slideshow'.$galleryID.'");';
$replace .= "\n\t".'//]]>';
$replace .= "\n\t".'-->';
$replace .= "\n\t".'</script>';
echo $replace;
}
/**********************************************************/
/* Slidehow widget control
/**********************************************************/
function widget_ngg_slideshow() {
// Check for the required plugin functions.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !function_exists('nggShowSlideshow') )
return;
function widget_show_ngg_slideshow($args) {
extract($args);
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_nggslideshow');
// These lines generate our output.
echo $before_widget . $before_title . $options['title'] . $after_title;
$url_parts = parse_url(get_bloginfo('home'));
nggSlideshowWidget($options['galleryid'] , $options['width'] , $options['height']);
echo $after_widget;
}
// Admin section
function widget_control_ngg_slideshow() {
global $wpdb;
$options = get_option('widget_nggslideshow');
if ( !is_array($options) )
$options = array('title'=>'Slideshow', 'galleryid'=>'0','height'=>'120','width'=>'160',);
if ( $_POST['ngg-submit'] ) {
$options['title'] = strip_tags(stripslashes($_POST['ngg-title']));
$options['galleryid'] = $_POST['ngg-galleryid'];
$options['height'] = $_POST['ngg-height'];
$options['width'] = $_POST['ngg-width'];
update_option('widget_nggslideshow', $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
$height = $options['height'];
$width = $options['width'];
// The Box content
echo '<p style="text-align:right;"><label for="ngg-title">' . __('Title:', 'nggallery') . ' <input style="width: 200px;" id="ngg-title" name="ngg-title" type="text" value="'.$title.'" /></label></p>';
echo '<p style="text-align:right;"><label for="ngg-galleryid">' . __('Select Gallery:', 'nggallery'). ' </label>';
echo '<select size="1" name="ngg-galleryid" id="ngg-galleryid">';
echo '<option value="0" ';
if ($table->gid == $options['galleryid']) echo "selected='selected' ";
echo '>'.__('All images', 'nggallery').'</option>'."\n\t";
$tables = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY 'name' ASC ");
if($tables) {
foreach($tables as $table) {
echo '<option value="'.$table->gid.'" ';
if ($table->gid == $options['galleryid']) echo "selected='selected' ";
echo '>'.$table->name.'</option>'."\n\t";
}
}
echo '</select></p>';
echo '<p style="text-align:right;"><label for="ngg-height">' . __('Height:', 'nggallery') . ' <input style="width: 50px;" id="ngg-height" name="ngg-height" type="text" value="'.$height.'" /></label></p>';
echo '<p style="text-align:right;"><label for="ngg-width">' . __('Width:', 'nggallery') . ' <input style="width: 50px;" id="ngg-width" name="ngg-width" type="text" value="'.$width.'" /></label></p>';
echo '<input type="hidden" id="ngg-submit" name="ngg-submit" value="1" />';
}
register_sidebar_widget(array('NextGEN Slideshow', 'widgets'), 'widget_show_ngg_slideshow');
register_widget_control(array('NextGEN Slideshow', 'widgets'), 'widget_control_ngg_slideshow', 300, 200);
}
/*******************************************************/
/* DISPLAY FUNCTION TO THE RECENT & RANDOM IMAGES
/*******************************************************/
function nggDisplayImagesWidget($thumb,$number,$sizeX,$sizeY,$mode,$imgtype) {
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
global $wpdb;
//get ngg options
$ngg_options = get_option('ngg_options');
// get the effect code
$thumbcode = nggallery::get_thumbcode("sidebar_".$imgtype);
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE exclude != 1 ");
if ($count < $number)
$number = $count;
if ($imgtype == "random")
$imageList = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE exclude != 1 ORDER by rand() limit $number");
else
$imageList = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE exclude != 1 ORDER by pid DESC limit 0,$number");
if (is_array($imageList)){
foreach($imageList as $image) {
echo $out . ''."\n";
}
}
}
/**********************************************************/
/* SIMPLE INSERT TAGS
/**********************************************************/
function nggDisplayRandomImages($number,$width,$height) {
echo "\n".'<div class="ngg-widget">'."\n";
nggDisplayImagesWidget("true",$number,$width,$height,"","random");
echo '</div>'."\n";
}
function nggDisplayRecentImages($number,$width,$height) {
echo "\n".'<div class="ngg-widget">'."\n";
nggDisplayImagesWidget("true",$number,$width,$height,"","recent");
echo '</div>'."\n";
}
/**********************************************************/
/* Recent widget
/**********************************************************/
function widget_ngg_recentimage() {
// Check for the required plugin functions. This will prevent fatal
// errors occurring when you deactivate the dynamic-sidebar plugin.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
function widget_nextgenrecentimage($args) {
extract($args);
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_NextGenrecentimage');
$title = $options['title'];
$thumb = $options['thumb'];
$number = $options['number'];
$sizeX = $options['sizeX'];
$sizeY = $options['sizeY'];
$mode = $options['mode'];
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
$imgtype = "recent";
$show_widget = false; // checking display status (category or home)
$categorieslist = nggGetCSVValues($categorylist,','); // Make array for checking the categories
if (($showcategory == "denied")) { // Denied list -> enable everywhere and make false if found!
$show_widget = true;
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = false;
}
}
if (($showcategory == "allow")) // Allow list -> false is the default -> enable if found
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = true;
}
if (($showcategory == "all")) // All categories -> if it's not the home -> enable
if ((is_home() != true))
$show_widget = true;
if (($showinhome == "yes")) // Home page -> If yes -> enable
if ((is_home()))
$show_widget = true;
$url_parts = parse_url(get_bloginfo('home'));
// Null parameters check
if ( ($number == '') ) $number = 1;
if ( ($sizeX == '') ) $sizeX = 190;
if ( ($sizeY == '') ) $sizeY = 190;
if ($show_widget) {
echo $before_widget . $before_title . $title . $after_title;
echo "\n".'<div class="ngg-widget">'."\n";
nggDisplayImagesWidget($thumb,$number,$sizeX,$sizeY,$mode,$imgtype);
echo '</div>'."\n";
echo $after_widget;
}
}
/**
* @desc Output of plugin�s editform in the adminarea
* @author KeViN
*/
function widget_nextgenrecentimage_control($number=1) {
$options = get_option('widget_NextGenrecentimage');
if ( !is_array($options) )
$options = array('title'=>'Recent Images', 'buttontext'=>__('NextGEN Recent Image','nggallery'));
if ( $_POST['nextgen-recentsubmit'] ) {
// Remember to sanitize and format use input appropriately.
$options = "";
$options['title'] = strip_tags(stripslashes($_POST['nextgen-recenttitle']));
$options['thumb'] = strip_tags(stripslashes($_POST['nextgen-recentthumb']));
$options['number'] = strip_tags(stripslashes($_POST['nextgen-recentnumber']));
$options['sizeX'] = strip_tags(stripslashes($_POST['nextgen-recentsizeX']));
$options['sizeY'] = strip_tags(stripslashes($_POST['nextgen-recentsizeY']));
// [0.80] [new functiions and newvariables] -> Category controll
$options['showinhome'] = strip_tags(stripslashes($_POST['nextgen-recentshowinhome']));
$options['showcategory']= strip_tags(stripslashes($_POST['nextgen-recentshowcategory']));
$options['categorylist']= strip_tags(stripslashes($_POST['nextgen-recentcategorylist']));
// [0.95] [new variable] -> (random / recent)
$options['imgtype'] = strip_tags(stripslashes($_POST['nextgen-recentimgtype']));
update_option('widget_NextGenrecentimage', $options);
}
// Be sure you format your options to be valid HTML attributes.
$title = htmlspecialchars($options['title'], ENT_QUOTES);
$thumb = htmlspecialchars($options['thumb'], ENT_QUOTES);
$number = htmlspecialchars($options['number'], ENT_QUOTES);
$sizeX = htmlspecialchars($options['sizeX'], ENT_QUOTES);
$sizeY = htmlspecialchars($options['sizeY'], ENT_QUOTES);
$mode = htmlspecialchars($options['mode'], ENT_QUOTES);
// [0.80] [new functiions and newvariables] -> Category controll
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
// [0.95] [new variable] -> (random / recent)
$mode = htmlspecialchars($options['imgtype'], ENT_QUOTES);
// Here comes the form
echo'<p style="text-align:right;"><label for="nextgen-recenttitle">' . __('Title','nggallery') . ': <input style="width: 150px;" id="nextgen-recenttitle" name="nextgen-recenttitle" type="text" value="'.$title.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentthumb">' . __('Display type','nggallery').':';
echo ' <select name="nextgen-recentthumb" size="1">';
echo ' <option id="1" ';if (($thumb == "true")) echo 'selected="selected"'; echo ' value="true">' . __('Thumbnail','nggallery') . '</option>';
echo ' <option id="2" ';if (($thumb == "false")) echo 'selected="selected"'; echo ' value="false">' . __('Orginal','nggallery') . '</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentnumber">' . __('Number of pics','nggallery').':';
echo ' <select name="nextgen-recentnumber" size="1">';
echo ' <option id="1" ';if (($number == 1)) echo 'selected="selected"'; echo ' value="1">1</option>';
echo ' <option id="2" ';if (($number == 2)) echo 'selected="selected"'; echo ' value="2">2</option>';
echo ' <option id="3" ';if (($number == 3)) echo 'selected="selected"'; echo ' value="3">3</option>';
echo ' <option id="4" ';if (($number == 4)) echo 'selected="selected"'; echo ' value="4">4</option>';
echo ' <option id="6" ';if (($number == 6)) echo 'selected="selected"'; echo ' value="6">6</option>';
echo ' <option id="8" ';if (($number == 8)) echo 'selected="selected"'; echo ' value="8">8</option>';
echo ' <option id="10" ';if (($number == 10)) echo 'selected="selected"'; echo ' value="10">10</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentsizeX">' . __('Width (px)','nggallery') . ': <input style="width: 50px;" id="nextgen-recentsizeX" name="nextgen-recentsizeX" type="text" value="'.$sizeX.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentsizeY">' . __('Height (px)','nggallery') . ': <input style="width: 50px;" id="nextgen-recentsizeY" name="nextgen-recentsizeY" type="text" value="'.$sizeY.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentnumber">' . __('Mode','nggallery').':';
echo ' <select name="nextgen-recentmode" size="1">';
echo ' <option id="none" ';if (($mode == "")) echo 'selected="selected"'; echo ' value="">'. __('none','nggallery').'</option>';
echo ' <option id="web20" ';if (($mode == "web20")) echo 'selected="selected"'; echo ' value="web20">'. __('web2.0','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentshowinhome">' . __('Show in the main page','nggallery').':';
echo ' <select name="nextgen-recentshowinhome" size="1">';
echo ' <option id="1" ';if ($showinhome == "yes") echo 'selected="selected"'; echo ' value="yes" >'. __('yes','nggallery').'</option>';
echo ' <option id="2" ';if ($showinhome == "no") echo 'selected="selected"'; echo ' value="no" >'. __('no','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentshowcategory">' . __('Show in','nggallery').':';
echo ' <select name="nextgen-recentshowcategory" size="1">';
echo ' <option id="1" ';if (($showcategory == "all")) echo 'selected="selected"'; echo ' value="all" >'. __('All categories','nggallery').'</option>';
echo ' <option id="2" ';if (($showcategory == "denied")) echo 'selected="selected"'; echo ' value="denied" >'. __('Only which are not listed','nggallery').'</option>';
echo ' <option id="3" ';if (($showcategory == "allow")) echo 'selected="selected"'; echo ' value="allow" >'. __('Only which are listed','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-recentcategorylist">' . __('Categories (id (use , to seperate)','nggallery') . ': <input style="width: 150px;" id="nextgen-recentcategorylist" name="nextgen-recentcategorylist" type="text" value="'.$categorylist.'" /></label></p>';
echo '<input type="hidden" id="nextgen-recentsubmit" name="nextgen-recentsubmit" value="1" />';
}
// This registers our widget so it appears with the other available
// widgets and can be dragged and dropped into any active sidebars.
register_sidebar_widget(array('NextGEN Recent Image', 'widgets'), 'widget_nextgenrecentimage');
register_widget_control(array('NextGEN Recent Image', 'widgets'), 'widget_nextgenrecentimage_control', 300, 400);
}
/**********************************************************/
/* Random widget
/**********************************************************/
function widget_ngg_randomimage() {
// Check for the required plugin functions. This will prevent fatal
// errors occurring when you deactivate the dynamic-sidebar plugin.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
function widget_nextgenimage($args) {
extract($args);
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_NextGenimage');
$title = $options['title'];
$thumb = $options['thumb'];
$number = $options['number'];
$sizeX = $options['sizeX'];
$sizeY = $options['sizeY'];
$mode = $options['mode'];
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
$imgtype = "random";
//origy ngg options
$ngg_options = get_option('ngg_options');
// get the effect code
$thumbcode = nggallery::get_thumbcode("sidebar");
$show_widget = false; // checking display status (category or home)
$categorieslist = nggGetCSVValues($categorylist,','); // Make array for checking the categories
if (($showcategory == "denied")) { // Denied list -> enable everywhere and make false if found!
$show_widget = true;
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = false;
}
}
if (($showcategory == "allow")) // Allow list -> false is the default -> enable if found
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = true;
}
if (($showcategory == "all")) // All categories -> if it's not the home -> enable
if ((is_home() != true))
$show_widget = true;
if (($showinhome == "yes")) // Home page -> If yes -> enable
if ((is_home()))
$show_widget = true;
$url_parts = parse_url(get_bloginfo('home'));
// Null parameters check
if ( ($number == '') ) $number = 1;
if ( ($sizeX == '') ) $sizeX = 190;
if ( ($sizeY == '') ) $sizeY = 190;
if ($show_widget) {
echo $before_widget . $before_title . $title . $after_title;
echo "\n".'<div class="ngg-widget">'."\n";
nggDisplayImagesWidget($thumb,$number,$sizeX,$sizeY,$mode,$imgtype,$thumbcode);
echo '</div>'."\n";
echo $after_widget;
}
}
/**
* @desc Output of plugin�s editform in the adminarea
* @author KeViN
*/
function widget_nextgenimage_control($number=1) {
$options = get_option('widget_NextGenimage');
if ( !is_array($options) )
$options = array('title'=>'', 'buttontext'=>__('NextGEN Random Image','nggallery'));
if ( $_POST['nextgen-submit'] ) {
// Remember to sanitize and format use input appropriately.
$options = "";
$options['title'] = strip_tags(stripslashes($_POST['nextgen-title']));
$options['thumb'] = strip_tags(stripslashes($_POST['nextgen-thumb']));
$options['number'] = strip_tags(stripslashes($_POST['nextgen-number']));
$options['sizeX'] = strip_tags(stripslashes($_POST['nextgen-sizeX']));
$options['sizeY'] = strip_tags(stripslashes($_POST['nextgen-sizeY']));
$options['mode'] = strip_tags(stripslashes($_POST['nextgen-mode']));
// [0.80] [new functiions and newvariables] -> Category controll
$options['showinhome'] = strip_tags(stripslashes($_POST['nextgen-showinhome']));
$options['showcategory']= strip_tags(stripslashes($_POST['nextgen-showcategory']));
$options['categorylist']= strip_tags(stripslashes($_POST['nextgen-categorylist']));
// [0.95] [new variable] -> (random / recent)
$options['imgtype'] = strip_tags(stripslashes($_POST['nextgen-imgtype']));
update_option('widget_NextGenimage', $options);
}
// Be sure you format your options to be valid HTML attributes.
$title = htmlspecialchars($options['title'], ENT_QUOTES);
$thumb = htmlspecialchars($options['thumb'], ENT_QUOTES);
$number = htmlspecialchars($options['number'], ENT_QUOTES);
$sizeX = htmlspecialchars($options['sizeX'], ENT_QUOTES);
$sizeY = htmlspecialchars($options['sizeY'], ENT_QUOTES);
//$mode = htmlspecialchars($options['mode'], ENT_QUOTES);
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
$mode = htmlspecialchars($options['imgtype'], ENT_QUOTES);
// Here comes the form
echo'<p style="text-align:right;"><label for="nextgen-title">' . __('Title','nggallery') . ': <input style="width: 150px;" id="nextgen-title" name="nextgen-title" type="text" value="'.$title.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-thumb">' . __('Display type','nggallery').':';
echo ' <select name="nextgen-thumb" size="1">';
echo ' <option id="1" ';if (($thumb == "true")) echo 'selected="selected"'; echo ' value="true">' . __('Thumbnail','nggallery') . '</option>';
echo ' <option id="2" ';if (($thumb == "false")) echo 'selected="selected"'; echo ' value="false">' . __('Orginal','nggallery') . '</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-number">' . __('Number of pics','nggallery').':';
echo ' <select name="nextgen-number" size="1">';
echo ' <option id="1" ';if (($number == 1)) echo 'selected="selected"'; echo ' value="1">1</option>';
echo ' <option id="2" ';if (($number == 2)) echo 'selected="selected"'; echo ' value="2">2</option>';
echo ' <option id="3" ';if (($number == 3)) echo 'selected="selected"'; echo ' value="3">3</option>';
echo ' <option id="4" ';if (($number == 4)) echo 'selected="selected"'; echo ' value="4">4</option>';
echo ' <option id="6" ';if (($number == 6)) echo 'selected="selected"'; echo ' value="6">6</option>';
echo ' <option id="8" ';if (($number == 8)) echo 'selected="selected"'; echo ' value="8">8</option>';
echo ' <option id="10" ';if (($number == 10)) echo 'selected="selected"'; echo ' value="10">10</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-sizeX">' . __('Width (px)','nggallery') . ': <input style="width: 50px;" id="nextgen-sizeX" name="nextgen-sizeX" type="text" value="'.$sizeX.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-sizeY">' . __('Height (px)','nggallery') . ': <input style="width: 50px;" id="nextgen-sizeY" name="nextgen-sizeY" type="text" value="'.$sizeY.'" /></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-number">' . __('Mode','nggallery').':';
echo ' <select name="nextgen-mode" size="1">';
echo ' <option id="none" ';if (($mode == "")) echo 'selected="selected"'; echo ' value="">'. __('none','nggallery').'</option>';
echo ' <option id="web20" ';if (($mode == "web20")) echo 'selected="selected"'; echo ' value="web20">'. __('web2.0','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-showinhome">' . __('Show in the main page','nggallery').':';
echo ' <select name="nextgen-showinhome" size="1">';
echo ' <option id="1" ';if ($showinhome == "yes") echo 'selected="selected"'; echo ' value="yes" >'. __('yes','nggallery').'</option>';
echo ' <option id="2" ';if ($showinhome == "no") echo 'selected="selected"'; echo ' value="no" >'. __('no','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-showcategory">' . __('Show in','nggallery').':';
echo ' <select name="nextgen-showcategory" size="1">';
echo ' <option id="1" ';if (($showcategory == "all")) echo 'selected="selected"'; echo ' value="all" >'. __('All categories','nggallery').'</option>';
echo ' <option id="2" ';if (($showcategory == "denied")) echo 'selected="selected"'; echo ' value="denied" >'. __('Only which are not listed','nggallery').'</option>';
echo ' <option id="3" ';if (($showcategory == "allow")) echo 'selected="selected"'; echo ' value="allow" >'. __('Only which are listed','nggallery').'</option>';
echo ' </select></label></p>';
echo '<p style="text-align:right;"><label for="nextgen-categorylist">' . __('Categories (id (use , to seperate)','nggallery') . ': <input style="width: 150px;" id="nextgen-categorylist" name="nextgen-categorylist" type="text" value="'.$categorylist.'" /></label></p>';
echo '<input type="hidden" id="nextgen-submit" name="nextgen-submit" value="1" />';
}
// This registers our widget so it appears with the other available
// widgets and can be dragged and dropped into any active sidebars.
register_sidebar_widget(array('NextGEN Random Image', 'widgets'), 'widget_nextgenimage');
register_widget_control(array('NextGEN Random Image', 'widgets'), 'widget_nextgenimage_control', 300, 400);
}
// Run our code later in case this loads prior to any required plugins.
add_action('widgets_init', 'widget_ngg_randomimage');
add_action('widgets_init', 'widget_ngg_slideshow');
add_action('widgets_init', 'widget_ngg_recentimage');
?>
med mange venlige hilsner Longkyle
not a support question