0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.2-08
/
htdocs
/
modules
/
migrate
/
classes
/
[
Home
]
File: G1MigrateHelper.class
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2007 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /** * A helper class for the Migrate module. * @package Migrate * @subpackage Classes * @author Alan Harder <alan.harder@sun.com> * @version $Revision: 15513 $ * @static */ class G1MigrateHelper { /** * Count number of mappings in migration table * * @return array GalleryStatus a status code * int count */ function fetchMapCount() { global $gallery; $query = 'SELECT COUNT(*) FROM [G1MigrateMap]'; list ($ret, $searchResults) = $gallery->search($query, array(), array()); if ($ret) { return array($ret, null); } $count = 0; if ($result = $searchResults->nextResult()) { $count = (int)$result[0]; } return array(null, $count); } /** * Get mapping for given G1 album/item * * @param string $g1album G1 album name * @param string $g1item (optional) G1 item name * @return array object GalleryStatus a status code * int id of G2 item or null if not found */ function fetchMapping($g1album, $g1item=null) { global $gallery; $query = 'SELECT [G1MigrateMap::itemId] FROM [G1MigrateMap] WHERE [G1MigrateMap::g1album]=? AND [G1MigrateMap::g1item]'; $data = array($g1album); if (isset($g1item)) { $query .= '=?'; $data[] = $g1item; } else { $query .= ' IS NULL'; } list ($ret, $searchResults) = $gallery->search($query, $data); if ($ret) { return array($ret, null); } $id = null; if ($result = $searchResults->nextResult()) { $id = (int)$result[0]; } return array(null, $id); } } ?>