Menu

[r152]: / trunk / cli / importSlideFile.php  Maximize  Restore  History

Download this file

124 lines (96 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?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();
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.