<?php
/*
This file is part of slidePresenter: real-time slideshow presentations via web browser
Copyright (C) 2006 Allen Shaw
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.
$Id$
*/
$title = "slidePresenter: importSlideFile";
require 'slp_cli_prepend.php';
echo getLangText('ready to import slides select the presentation into which to import');
while (!isset($presentations[$number])) {
foreach ($slp->data->getExistingPresentations() as $id => $props) {
$id++;
$name = (!$props['name'] ? '[unnamed]' : $props['name']);
$presentations[$id]['name'] = $name;
$presentations[$id]['id'] = $props['id'];
echo " $id: $name\n";
}
if ($tried) {
echo getLangText('not a valid presentation number choose a number from the list above');
}
$number = getInput(getLangText('presentation number'), true);
$tried = true;
}
while ($importNextFile !== false) {
echo getLangText('please enter the path for the file to import either the full system path or relative to slp_dir x you may start the path with x to indicate the current working directory', SLP_DIR, '.'.DELIM);
while (!$filePath) {
$filePath = getInput(getLangText('file to import'), true);
if (substr($filePath, 0, 2) == '.'. DELIM) {
// If the path starts with ./, append no path
$filePath = $cwd . DELIM . $filePath;
} elseif (substr($filePath, 0, 1) <> DELIM) {
// prepend full SLP_DIR to path unless it's a full path
$filePath = SLP_DIR . $filePath;
}
// confirm file exists
if (!is_file($filePath) || !is_readable($filePath)) {
echo getLangText('the file x was not found please try again',$filePath);
unset($filePath);
}
}
echo getLangText('are you sure -- import the file x to presentation x', $filePath, $presentations[$number]['name']);
if (getConfirm()) {
$result = importSlides($filePath, 'auto', $presentations[$number]['id'], true, true);
if ($result['status'] <> 1) {
echo getLangText('the operation failed x', $result['error']);
cli_exit();
} else {
if ($result['newFiles']) {
echo getLangText('the following files were added');
foreach ($result['newFiles'] as $file) {
echo " {$file['file']}\n";
}
}
if ($result['newFiles'] && ($result['changedFileNames'] || $result['disallowedFiles'])) {
echo getLangText('note also');
}
if ($result['changedFileNames']) {
echo getLangText('some files had names that were already in use and were renamed as follows');
foreach ($result['changedFileNames'] as $file) {
echo getLangText(' x renamed to x', $file['originalName'], $file['newName']);
}
}
if ($result['disallowedFiles']) {
echo "\n". getLangText('the following files were disallowed based on their file extension') ."\n";
foreach ($result['disallowedFiles'] as $file) {
echo " $file\n";
}
}
echo getLangText('the imported slides were added to the end of the presentation you can change their order in the slidepresenter web interface, using the edit link for the presentation');
}
} else {
echo getLangText('the import was not confirmed');
explainNoConfirm();
echo "\n";
}
echo getLangText('import another file');
if (getConfirm()) {
unset($filePath);
$importNextFile = true;
} else {
echo getLangText('exiting');
$importNextFile = false;
}
}
cli_exit();