*/ GalleryCoreApi::requireOnce('modules/nokiaupload/classes/ImageUploadHelper.class'); /** * This controller implements the Nokia Image Uploader API's 'Retrieve Directory Listing' command. * * @package NokiaUpload */ class DirectoryListingController extends GalleryController { /** * @see GalleryController::handleRequest() */ function handleRequest($form) { ImageUploadHelper::logRequest('DirectoryListingController'); $results['delegate'] = array('view' => 'nokiaupload.DirectoryListing'); $results['status'] = ImageUploadHelper::getDirectoryListing(); $results['error'] = array(); return array(null, $results); } } /** * This view implements the Nokia Image Uploader API's 'Retrieve Directory Listing' command. * * @package NokiaUpload */ class DirectoryListingView extends GalleryView { /** * @see GalleryView::renderImmediate() */ function isImmediate() { return true; } /** * API defines the output very specifically so we can't allow any global * templating to be used. * * @see GalleryView::renderImmediate() */ function renderImmediate($status, $error) { global $gallery; $gallery->debug("##### DirectoryListingView #####\n\$status = "); $gallery->debug_r($status); if ($status['success'] == NOKIAUPLOAD_ERR_NOERR && !isset($status['albums'])) { $status['success'] = NOKIAUPLOAD_ERR_UNKNOWN; } $reply = array($status['success'] . "\r\n"); if ($status['success'] == NOKIAUPLOAD_ERR_NOERR) { $dirNum = count($status['albums']); $reply[] = $dirNum . "\r\n"; $reply[] = "3\r\n"; // Lines per directory (id, parent id and name). foreach ($status['albums'] as $album) { $reply[] = 'DId=' . $album['id'] . "\r\n"; $reply[] = 'PId=' . $album['parentid'] . "\r\n"; $reply[] = 'DirName='. $album['name'] . "\r\n"; } } else { list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'nokiaupload'); if ($ret) { $reply[] = "Couldn't fetch directory list.\r\n"; } else { $reply[] = $module->translate("Couldn't fetch directory list.") . "\r\n"; } } $reply = implode('', $reply); $gallery->debug("Sending:\n$reply"); header("Content-type: text/plain; charset=UTF-8"); header('Content-Length: ' . strlen($reply)); print $reply; return null; } } ?>