based on the migrate module by * Jesse Mullan */ GalleryCoreApi::requireOnce('modules/picasa/classes/Picasa2DataParser.class'); /** * @version $Revision: 1.2 $ $Date: 2006/01/10 04:41:32 $ * @package Picasa * @subpackage UserInterface */ class SelectPicasaExportPathController extends GalleryController { /** * @see GalleryController::handleRequest() */ function handleRequest($form) { global $gallery; /* Verify that active user is an admin */ $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $error = $status = array(); if (isset($form['action']['select'])) { if (empty($form['picasaXmlPath'])) { $error[] = 'form[error][picasaXmlPath][missing]'; } else { $platform =& $gallery->getPlatform(); $slash = $platform->getDirectorySeparator(); $tmp = trim($form['picasaXmlPath']); if ($tmp[strlen($tmp)-1] != $slash) { $tmp .= $slash; } $form['picasaXmlPath'] = trim(GalleryUtilities::htmlEntityDecode($tmp)); if (!Picasa2DataParser::isValidPicasaXmlPath($form['picasaXmlPath'])) { $error[] = 'form[error][picasaXmlPath][invalid]'; } } if (empty($error)) { $session =& $gallery->getSession(); $recentPaths = $session->get('picasa.view.SelectPicasaExportPath.recentPaths'); if (empty($recentPaths)) { $recentPaths = array(); } if (isset($recentPaths[$form['picasaXmlPath']])) { $recentPaths[$form['picasaXmlPath']]++; } else { $recentPaths[$form['picasaXmlPath']] = 1; } $session->put('picasa.view.SelectPicasaExportPath.recentPaths', $recentPaths); $redirect['view'] = 'core.SiteAdmin'; $redirect['subView'] = 'picasa.ConfirmPicasaImport'; $redirect['picasaXmlPath'] = $form['picasaXmlPath']; $redirect['destinationAlbumId'] = $form['destinationAlbumId']; } } if (!empty($redirect)) { $results['redirect'] = $redirect; } else { $results['delegate']['view'] = 'core.SiteAdmin'; $results['delegate']['subView'] = 'picasa.SelectPicasaExportPath'; } $results['status'] = $status; $results['error'] = $error; return array(null, $results); } } /** * @version $Revision: 1.2 $ $Date: 2006/01/10 04:41:32 $ * @package Picasa * @subpackage UserInterface */ class SelectPicasaExportPathView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { global $gallery; if ($form['formName'] != 'SelectPicasaExportPath') { $form['formName'] = 'SelectPicasaExportPath'; $form['picasaXmlPath'] = ''; $form['destinationAlbumId'] = ''; } /* Load our recent paths from the session */ $session =& $gallery->getSession(); $recentPaths = $session->get('picasa.view.SelectPicasaExportPath.recentPaths'); if (empty($recentPaths)) { $recentPaths = array(); } list ($ret, $operations) = GalleryCoreApi::getToolkitOperations('image/jpeg'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $hasToolkit = false; for ($i = 0; $i < sizeof($operations); $i++) { if ($operations[$i]['name'] == 'thumbnail') { $hasToolkit = true; break; } } /* Get ids of all all albums where we can add new album items */ list ($ret, $albumIds) = GalleryCoreApi::fetchAllItemIds('GalleryAlbumItem', 'core.addAlbumItem'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Load all the album entities */ list ($ret, $albums) = GalleryCoreApi::loadEntitiesById($albumIds); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $albumTree = GalleryUtilities::createAlbumTree($albums); $SelectPicasaExportPath = array(); $SelectPicasaExportPath['recentPaths'] = $recentPaths; $SelectPicasaExportPath['hasToolkit'] = $hasToolkit; $SelectPicasaExportPath['g2AlbumTree'] = $albumTree; $template->setVariable('controller', 'picasa.SelectPicasaExportPath'); $template->setVariable('SelectPicasaExportPath', $SelectPicasaExportPath); return array(null, array('body' => 'modules/picasa/templates/SelectPicasaExportPath.tpl')); } } ?>