PluginProbe
Slideshow Gallery LITE / 1.0
Slideshow Gallery LITE v1.0
trunk 1.0 1.0.3 1.0.4 1.0.5 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.2.1 1.2.3 1.2.3.2 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.4.1 1.4.4.2 1.4.4.3 1.4.5 1.4.6 All 67 releases
slideshow-gallery / slideshow-gallery.php

slideshow-gallery.php in Slideshow Gallery LITE 1.0, at slideshow-gallery.php

161 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: Slideshow Gallery
5 Plugin URI: http://wpgallery.tribulant.net
6 Author: Antonie Potgieter
7 Author URI: http://tribulant.com
8 Description: Feature content in a JavaScript powered slideshow gallery showcase on your WordPress website. The slideshow is flexible and all aspects can easily be configured. Embedding or hardcoding the slideshow gallery is a breeze. To embed into a post/page, simply insert <code>[slideshow]</code> into its content. To hardcode into your theme, simply use <code>&lt;?php $Gallery -> slideshow(); ?&gt;</code>.
9 Version: 1.0
10 */
11
12 //include the GalleryPlugin class file
13 require_once(dirname(__FILE__) . '/slideshow-gallery-plugin.php');
14
15 class Gallery extends GalleryPlugin {
16
17 function Gallery() {
18 $url = explode("&", $_SERVER['REQUEST_URI']);
19 $this -> url = $url[0];
20
21 $this -> register_plugin('slideshow-gallery', __FILE__);
22
23 //WordPress action hooks
24 $this -> add_action('admin_menu');
25 $this -> add_action('admin_head');
26 $this -> add_action('admin_notices');
27
28 add_shortcode('slideshow', array($this, 'embed'));
29 }
30
31 function admin_menu() {
32 add_menu_page(__('Slideshow', $this -> plugin_name), __('Slideshow', $this -> plugin_name), 10, basename(__FILE__), array($this, 'admin_slides'), $this -> url() . '/images/icon.png');
33 add_submenu_page(basename(__FILE__), __('Configuration', $this -> plugin_name), __('Configuration', $this -> plugin_name), 10, $this -> plugin_name . '-settings', array($this, 'admin_settings'));
34 }
35
36 function admin_head() {
37 $this -> render('head', false, true, 'admin');
38 }
39
40 function admin_notices() {
41 $this -> check_uploaddir();
42
43 if (!empty($_GET[$this -> pre . 'message'])) {
44 $msg_type = (!empty($_GET[$this -> pre . 'updated'])) ? 'msg' : 'err';
45 call_user_method('render_' . $msg_type, $this, $_GET[$this -> pre . 'message']);
46 }
47 }
48
49 function slideshow($output = true) {
50 if ($slides = $this -> Slide -> find_all(null, null, array('order', "ASC"))) {
51 if ($output) {
52 $this -> render('gallery', array('slides' => $slides), true, 'default');
53 } else {
54 $content = $this -> render('gallery', array('slides' => $slides), false, 'default');
55 return $content;
56 }
57 }
58
59 return false;
60 }
61
62 function embed($atts = array()) {
63 $defaults = array();
64 extract(shortcode_atts($defaults, $atts));
65
66 if ($slides = $this -> Slide -> find_all(null, null, array('order', "ASC"))) {
67 $content = $this -> render('gallery', array('slides' => $slides), false, 'default');
68 }
69
70 return $content;
71 }
72
73 function admin_slides() {
74 switch ($_GET['method']) {
75 case 'save' :
76 if (!empty($_POST)) {
77 if ($this -> Slide -> save($_POST, true)) {
78 $message = __('Slide has been saved', $this -> plugin_name);
79 $this -> redirect($this -> url, "message", $message);
80 } else {
81 $this -> render('slides/save', false, true, 'admin');
82 }
83 } else {
84 $this -> Db -> model = $this -> Slide -> model;
85 $this -> Slide -> find(array('id' => $_GET['id']));
86 $this -> render('slides/save', false, true, 'admin');
87 }
88 break;
89 case 'mass' :
90 if (!empty($_POST['action'])) {
91 if (!empty($_POST['Slide']['checklist'])) {
92 switch ($_POST['action']) {
93 case 'delete' :
94 $this -> debug($_POST);
95
96 foreach ($_POST['Slide']['checklist'] as $slide_id) {
97 $this -> Slide -> delete($slide_id);
98 }
99
100 $message = __('Selected slides have been removed', $this -> plugin_name);
101 $this -> redirect($this -> url, 'message', $message);
102 break;
103 }
104 } else {
105 $message = __('No slides were selected', $this -> plugin_name);
106 $this -> redirect($this -> url, "error", $message);
107 }
108 } else {
109 $message = __('No action was specified', $this -> plugin_name);
110 $this -> redirect($this -> url, "error", $message);
111 }
112 break;
113 case 'order' :
114 $slides = $this -> Slide -> find_all(null, null, array('order', "ASC"));
115 $this -> render('slides/order', array('slides' => $slides), true, 'admin');
116 break;
117 default :
118 $data = $this -> paginate('Slide');
119 $this -> render('slides/index', array('slides' => $data[$this -> Slide -> model], 'paginate' => $data['Paginate']), true, 'admin');
120 break;
121 }
122 }
123
124 function admin_settings() {
125 switch ($_GET['method']) {
126 case 'reset' :
127 global $wpdb;
128 $query = "DELETE FROM `" . $wpdb -> prefix . "options` WHERE `option_name` LIKE '" . $this -> pre . "%';";
129
130 if ($wpdb -> query($query)) {
131 $message = __('All configuration settings have been reset to their defaults', $this -> plugin_name);
132 $msg_type = 'message';
133 $this -> render_msg($message);
134 } else {
135 $message = __('Configuration settings could not be reset', $this -> plugin_name);
136 $msg_type = 'error';
137 $this -> render_err($message);
138 }
139
140 $this -> redirect($this -> url, $msg_type, $message);
141 break;
142 default :
143 if (!empty($_POST)) {
144 foreach ($_POST as $pkey => $pval) {
145 $this -> update_option($pkey, $pval);
146 }
147
148 $message = __('Configuration has been saved', $this -> plugin_name);
149 $this -> render_msg($message);
150 }
151 break;
152 }
153
154 $this -> render('settings', false, true, 'admin');
155 }
156 }
157
158 //initialize a Gallery object
159 $Gallery = new Gallery();
160
161 ?>