source: extensions/piwigopress/piwigopress.php @ 18869

Last change on this file since 18869 was 4314, checked in by vdigital, 15 years ago

[PiwigoPress]

  • NEW (Admin Post) Media Piwigo icon
  • NEW (Admin Post) Media Piwigo white logo
  • NEW (Admin Post) Media CSS style.css (need a full review)
  • NEW Include the Admin part (Not operational)
  • MOD Minor code review on Widget code
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1<?php
2/*
3Plugin Name: PiwigoPress
4Plugin URI: http://piwigo.org/ext/extension_view.php?eid=316
5Description: PiwigoPress is a WordPress 2.8 widget, it links a public picture in your Piwigo gallery (<a href="http://piwigo.org/">Piwigo</a>). In other words, it's a WordPress Sidebar Widget with some available public pictures in your Piwigo gallery as a prereq.
6Version: 1.04
7Author: vpiwigo ( for The Piwigo Team )
8Author URI: http://www.vdigital.org/sharing/
9*/
10if (defined('PHPWG_ROOT_PATH')) return; /* Avoid Automatic install under Piwigo */
11/*  Copyright 2009  VDigital  (email : vpiwigo[at]gmail[dot]com)
12
13    This program is free software; you can redistribute it and/or modify
14    it under the terms of the GNU General Public License as published by
15    the Free Software Foundation; either version 2 of the License, or
16    (at your option) any later version.
17
18    This program is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21    GNU General Public License for more details.
22
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26*/
27if (!defined('PWGP_NAME')) define('PWGP_NAME','PiwigoPress');
28if (!defined('PWGA_PATH')) define('PWGA_PATH', '../wp-content/plugins/piwigopress/'); // Path from /wp-admin/
29
30load_plugin_textdomain('pwg', 'wp-content/plugins/piwigopress', 'piwigopress' );
31
32class PiwigoPress extends WP_Widget
33{
34        function PiwigoPress(){
35                $widget_ops = array('classname' => PWGP_NAME,
36                        'description' => __( "Adds a thumbnail and its link (to the picture) inside your blog sidebar.",'pwg') );
37                $control_ops = array('width' => 300, 'height' => 300);
38                $this->WP_Widget(PWGP_NAME, PWGP_NAME, $widget_ops, $control_ops);
39        }
40        // Code generator
41        function widget($args, $gallery){
42                include 'PiwigoPress_code.php';
43        }
44        function update($new_gallery, $old_gallery){
45                $gallery = $old_gallery;
46                $gallery['title'] = strip_tags(stripslashes($new_gallery['title']));
47                $gallery['thumbnail'] = (strip_tags(stripslashes($new_gallery['thumbnail'])) == 'true') ? 'true':'false';
48                $gallery['piwigo'] = strip_tags(stripslashes($new_gallery['piwigo']));
49                $gallery['external'] = strip_tags(stripslashes($new_gallery['external']));
50                $gallery['number'] = intval(strip_tags(stripslashes($new_gallery['number'])));
51                $gallery['category'] = intval(strip_tags(stripslashes($new_gallery['category'])));
52                $gallery['from'] = intval(strip_tags(stripslashes($new_gallery['from'])));
53                $gallery['divclass'] = strip_tags(stripslashes($new_gallery['divclass']));
54                $gallery['class'] = strip_tags(stripslashes($new_gallery['class']));
55                $gallery['most_visited'] = (strip_tags(stripslashes($new_gallery['most_visited'])) == 'true') ? 'true':'false';
56                $gallery['best_rated'] = (strip_tags(stripslashes($new_gallery['best_rated'])) == 'true') ? 'true':'false';
57                $gallery['most_commented'] = (strip_tags(stripslashes($new_gallery['most_commented'])) == 'true') ? 'true':'false';
58                $gallery['random'] = (strip_tags(stripslashes($new_gallery['random'])) == 'true') ? 'true':'false';
59                $gallery['recent_pics'] = (strip_tags(stripslashes($new_gallery['recent_pics'])) == 'true') ? 'true':'false';
60                $gallery['calendar'] = (strip_tags(stripslashes($new_gallery['calendar'])) == 'true') ? 'true':'false';
61                $gallery['tags'] = (strip_tags(stripslashes($new_gallery['tags'])) == 'true') ? 'true':'false';
62                $gallery['comments'] = (strip_tags(stripslashes($new_gallery['comments'])) == 'true') ? 'true':'false';
63                $gallery['mbcategories'] = (strip_tags(stripslashes($new_gallery['mbcategories'])) == 'true') ? 'true':'false';
64                return $gallery;
65        }
66        function form($gallery){
67                // Options
68                include 'PiwigoPress_options.php';
69        }
70}
71
72// Register
73function PiwigoPress_Init() {
74                        register_widget('PiwigoPress');
75}
76
77add_action('widgets_init', PWGP_NAME . '_Init');
78
79// Admin code only if distributed and in Admin
80if (strpos($_SERVER['REQUEST_URI'], "/wp-admin/") !== false) {
81  if (file_exists(PWGA_PATH.'PiwigoPress_Admin.php')) // Not commited currently.
82                include 'PiwigoPress_Admin.php';
83}
84
85?>
Note: See TracBrowser for help on using the repository browser.