Dotclear

source: plugins/pixearch/index.php @ 656

Revision 656, 5.7 KB checked in by hadrien, 14 years ago (diff)

Ajout du plugin Pixearch

Line 
1<?php
2# ***** BEGIN LICENSE BLOCK *****
3# This file is part of DotClear.
4# Copyright (c) 2007 Olivier Meunier and contributors.
5# All rights reserved.
6#
7# DotClear is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# DotClear is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with DotClear; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20#
21# ***** END LICENSE BLOCK *****
22# This file is part of Pixearch
23# Hadrien Lanneau http://www.alti.info/
24#
25global $core;
26
27include_once dirname(__FILE__).'/inc/Pixearch.class.php';
28
29//------------------------------------------------------------------------------
30// Global datas
31//------------------------------------------------------------------------------
32$core->blog->settings->setNamespace('pixearch');
33
34//------------------------------------------------------------------------------
35// Set config
36//------------------------------------------------------------------------------
37if (!empty($_POST['pixearch_default_search']))
38{
39     $flickrApiKey       = $_POST['pixearch_flickr_apikey'];
40     $photobucketApiKey  = $_POST['pixearch_photobucket_apikey'];
41     $photobucketSecret  = $_POST['pixearch_photobucket_secret'];
42     $defaultSearch      = $_POST['pixearch_default_search'];
43     
44     try
45     {
46          $core->blog->settings->put(
47               'pixearch_flickr_apikey',
48               $flickrApiKey,
49               'string',
50               __('Flickr API Key'),
51               true,
52               false
53          );
54          $core->blog->settings->put(
55               'pixearch_photobucket_apikey',
56               $photobucketApiKey,
57               'string',
58               __('PhotoBucket API Key'),
59               true,
60               false
61          );
62          $core->blog->settings->put(
63               'pixearch_photobucket_secret',
64               $photobucketSecret,
65               'string',
66               __('PhotoBucket Secret Key'),
67               true,
68               false
69          );
70          $core->blog->settings->put(
71               'pixearch_default_search',
72               $defaultSearch,
73               'string',
74               __('Default search engine'),
75               true,
76               false
77          );
78          $msg = __('Configuration updated');
79     }
80     catch (Exception $e)
81     {
82          $core->error->add($e->getMessage());
83     }
84}
85
86//------------------------------------------------------------------------------
87// Get config
88//------------------------------------------------------------------------------
89if (is_null($flickrApiKey))
90{
91     try
92     {
93          $flickrApiKey = $core->blog->settings->get(
94               'pixearch_flickr_apikey'
95          );
96     }
97     catch (Exception $e)
98     {
99          $core->error->add($e->getMessage());
100     }
101}
102if (is_null($photobucketApiKey))
103{
104     try
105     {
106          $photobucketApiKey = $core->blog->settings->get(
107               'pixearch_photobucket_apikey'
108          );
109          $photobucketSecret = $core->blog->settings->get(
110               'pixearch_photobucket_secret'
111          );
112     }
113     catch (Exception $e)
114     {
115          $core->error->add($e->getMessage());
116     }
117}
118if (is_null($defaultSearch))
119{
120     try
121     {
122          $defaultSearch = $core->blog->settings->get(
123               'pixearch_default_search'
124          );
125     }
126     catch (Exception $e)
127     {
128          $core->error->add($e->getMessage());
129     }
130}
131$deviantartApiKey = true;
132$picasaApiKey = true;
133
134
135$query = !empty($_POST['pixearch_query']) ?
136     $_POST['pixearch_query'] :
137     $_GET['query'];
138//------------------------------------------------------------------------------
139// Common headers
140//------------------------------------------------------------------------------
141?>
142<html>
143<head>
144     <title><?php echo __('Pixearch') ?></title>
145     <script type="text/javascript" src="index.php?pf=pixearch/js/popup.js"></script>
146     <link rel="stylesheet" type="text/css" href="index.php?pf=pixearch/styles/style.css" />
147     
148     <?php if ($query) { ?>
149     <!-- Coverflow -->
150     <script type="text/javascript" src="index.php?pf=pixearch/js/coverflow.js"></script>
151     <?php } ?>
152</head>
153
154<body>
155<?php
156//------------------------------------------------------------------------------
157// Popup Window
158//------------------------------------------------------------------------------
159
160if (!empty($_GET['popup']) and
161     !isset($_GET['config']))
162{
163     // Popup
164     echo dcPage::jsPageTabs(
165               (
166                    empty($_POST['saveconfig']) and
167                    !empty($_GET['picture_id'])
168               ) ?
169          'insert' :
170          'search'
171     );
172     $source = $_POST['source'];
173     if (empty($source))
174     {
175          $source = $_GET['source'];
176     }
177     if (empty($source))
178     {
179          $source = $defaultSearch;
180     }
181//------------------------------------------------------------------------------
182// Search form
183//------------------------------------------------------------------------------
184     include(dirname(__FILE__) . '/tpl/popup_search.html');
185
186//------------------------------------------------------------------------------
187// Display selected image
188//------------------------------------------------------------------------------
189
190     if (!empty($_GET['picture_id']))
191     {
192          switch ($source)
193          {
194               case 'photobucket':
195                    $pictureClass = 'PxSPhotoBucketPicture';
196                    break;
197               case 'deviantart':
198                    $pictureClass = 'PxSDeviantArtPicture';
199                    break;
200               case 'picasa':
201                    $pictureClass = 'PxSPicasaPicture';
202                    break;
203               case 'flickr':
204               default:
205                    $pictureClass = 'PxSFlickrPicture';
206          }
207         
208          include(dirname(__FILE__) . '/tpl/popup_insert.html');
209     }
210?>
211</form>
212<?php
213}
214
215//------------------------------------------------------------------------------
216// Admin configuration
217//------------------------------------------------------------------------------
218
219else
220{
221     include(dirname(__FILE__) . '/tpl/config.html');
222}
223
224//------------------------------------------------------------------------------
225// Footer
226//------------------------------------------------------------------------------
227
228include(dirname(__FILE__) . '/tpl/footer.html');
229?>
230     
231     
232</body>
233</html>
Note: See TracBrowser for help on using the repository browser.

Sites map