*/ /** * Required classes */ GalleryCoreApi::requireOnce('modules/migrate/classes/Gallery1DataParser.class'); GalleryCoreApi::requireOnce('modules/migrate/classes/G1MigrateHelper.class'); /** * @version $Revision: 1.19 $ $Date: 2006/01/10 04:40:41 $ * @package Migrate * @subpackage UserInterface */ class SelectGalleryController 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 = array(); $status = array(); if (isset($form['action']['select'])) { if (empty($form['albumsPath'])) { $error[] = 'form[error][albumsPath][missing]'; } else { $platform =& $gallery->getPlatform(); $slash = $platform->getDirectorySeparator(); $tmp = trim($form['albumsPath']); if ($tmp[strlen($tmp)-1] != $slash) { $tmp .= $slash; } $form['albumsPath'] = trim($tmp); if (!Gallery1DataParser::isValidAlbumsPath($form['albumsPath'])) { $error[] = 'form[error][albumsPath][invalid]'; } } if (empty($error)) { /* Save our albums path in the session */ $session =& $gallery->getSession(); $recentPaths = $session->get('migrate.view.SelectGallery.recentPaths'); if (empty($recentPaths)) { $recentPaths = array(); } if (isset($recentPaths[$form['albumsPath']])) { $recentPaths[$form['albumsPath']]++; } else { $recentPaths[$form['albumsPath']] = 1; } $session->put('migrate.view.SelectGallery.recentPaths', $recentPaths); $redirect['view'] = 'core.SiteAdmin'; $redirect['subView'] = 'migrate.ChooseObjects'; $redirect['albumsPath'] = $form['albumsPath']; } } else if (isset($form['action']['deleteMap'])) { $ret = GalleryCoreApi::removeAllMapEntries('G1MigrateMap'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $redirect['view'] = 'core.SiteAdmin'; $redirect['subView'] = 'migrate.SelectGallery'; $status['mapDeleted'] = 1; } if (!empty($redirect)) { $results['redirect'] = $redirect; } else { $results['delegate']['view'] = 'core.SiteAdmin'; $results['delegate']['subView'] = 'migrate.SelectGallery'; } $results['status'] = $status; $results['error'] = $error; return array(null, $results); } } /** * @version $Revision: 1.19 $ $Date: 2006/01/10 04:40:41 $ * @package Migrate * @subpackage UserInterface */ class SelectGalleryView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { global $gallery; if ($form['formName'] != 'SelectGallery') { $form['formName'] = 'SelectGallery'; $form['albumsPath'] = ''; } /* Load our recent paths from the session */ $session =& $gallery->getSession(); $recentPaths = $session->get('migrate.view.SelectGallery.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; } } list ($ret, $mapCount) = G1MigrateHelper::fetchMapCount(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $SelectGallery = array(); $SelectGallery['recentPaths'] = $recentPaths; $SelectGallery['hasToolkit'] = $hasToolkit; $SelectGallery['mapCount'] = $mapCount; $template->setVariable('controller', 'migrate.SelectGallery'); $template->setVariable('SelectGallery', $SelectGallery); return array(null, array('body' => 'modules/migrate/templates/SelectGallery.tpl')); } } ?>