3
* $RCSfile: LinkItemOption.inc,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2006 Bharat Mediratta
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or (at
11
* your option) any later version.
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
24
* @version $Revision: 1.2 $ $Date: 2006/01/10 04:40:35 $
26
* @subpackage UserInterface
27
* @author Alan Harder <alan.harder@sun.com>
31
* ItemEditOption for editing the target of a LinkItem
34
* @subpackage UserInterface
37
class LinkItemOption extends ItemEditOption {
40
* @see ItemEditOption::isAppropriate
42
function isAppropriate($item, $thumbnail) {
44
GalleryUtilities::isA($item, 'GalleryLinkItem') && !is_numeric($item->getLink()));
48
* @see ItemEditOption::loadTemplate
50
function loadTemplate(&$template, &$form, $item, $thumbnail) {
51
if (!isset($form['LinkItemOption'])) {
52
$form['LinkItemOption']['link'] = $item->getLink();
56
'modules/linkitem/templates/LinkItemOption.tpl',
61
* @see ItemEditOption::handleRequestAfterEdit
63
function handleRequestAfterEdit($form, &$item, &$preferred) {
64
$error = $warning = array();
65
if (empty($form['LinkItemOption']['link'])) {
66
$error[] = 'form[LinkItemOption][error][link][missing]';
68
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock(array($item->getId()));
70
return array($ret->wrap(__FILE__, __LINE__), null, null);
73
$item->setLink($form['LinkItemOption']['link']);
76
GalleryCoreApi::releaseLocks($lockId);
77
return array($ret->wrap(__FILE__, __LINE__), null, null);
80
$ret = GalleryCoreApi::releaseLocks($lockId);
82
return array($ret->wrap(__FILE__, __LINE__), null, null);
86
return array(null, $error, $warning);