~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Helper/LayoutUploadHandler.php

  • Committer: Dan Garner
  • Date: 2016-02-04 14:13:07 UTC
  • mto: (454.4.101)
  • mto: This revision was merged to the branch mainline in revision 483.
  • Revision ID: git-v1:f9078f575b16a62a51e2f3d7bc15581058fb0747
Problem with DataSet form putting a 0 in library image references (should be empty)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
namespace Xibo\Helper;
4
4
 
5
5
use Exception;
6
 
use Xibo\Entity\Layout;
7
 
use Xibo\Exception\LibraryFullException;
 
6
use Xibo\Factory\LayoutFactory;
8
7
 
9
 
/**
10
 
 * Class LayoutUploadHandler
11
 
 * @package Xibo\Helper
12
 
 */
13
8
class LayoutUploadHandler extends BlueImpUploadHandler
14
9
{
15
 
    /**
16
 
     * @param $file
17
 
     * @param $index
18
 
     * @throws \Xibo\Exception\ConfigurationException
19
 
     */
20
10
    protected function handle_form_data($file, $index)
21
11
    {
22
 
        $controller = $this->options['controller'];
23
 
        /* @var \Xibo\Controller\Layout $controller */
24
 
 
25
12
        // Handle form data, e.g. $_REQUEST['description'][$index]
26
13
        $fileName = $file->name;
27
14
 
28
 
        $controller->getLog()->debug('Upload complete for ' . $fileName . '.');
 
15
        Log::debug('Upload complete for ' . $fileName . '.');
29
16
 
30
17
        // Upload and Save
31
18
        try {
32
 
            // Check Library
33
 
            if ($this->options['libraryQuotaFull'])
34
 
                throw new LibraryFullException(sprintf(__('Your library is full. Library Limit: %s K'), $this->options['libraryLimit']));
35
 
 
36
 
            // Check for a user quota
37
 
            $controller->getUser()->isQuotaFullByUser();
38
 
 
39
 
            // Parse parameters
40
19
            $name = isset($_REQUEST['name']) ? $_REQUEST['name'][$index] : '';
41
20
            $template = isset($_REQUEST['template']) ? $_REQUEST['template'][$index] : 0;
42
21
            $replaceExisting = isset($_REQUEST['replaceExisting']) ? $_REQUEST['replaceExisting'][$index] : 0;
43
22
            $importTags = isset($_REQUEST['importTags']) ? $_REQUEST['importTags'][$index] : 0;
44
 
            $useExistingDataSets = isset($_REQUEST['useExistingDataSets']) ? $_REQUEST['useExistingDataSets'][$index] : 0;
45
 
            $importDataSetData = isset($_REQUEST['importDataSetData']) ? $_REQUEST['importDataSetData'][$index] : 0;
46
23
 
47
 
            /* @var Layout $layout */
48
 
            $layout = $controller->getLayoutFactory()->createFromZip(
49
 
                $controller->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/' . $fileName,
 
24
            $layout = LayoutFactory::createFromZip(
 
25
                Config::GetSetting('LIBRARY_LOCATION') . 'temp/' . $fileName,
50
26
                $name,
51
27
                $this->options['userId'],
52
28
                $template,
53
29
                $replaceExisting,
54
 
                $importTags,
55
 
                $useExistingDataSets,
56
 
                $importDataSetData,
57
 
                $this->options['libraryController']
 
30
                $importTags
58
31
            );
59
32
 
60
33
            $layout->save();
61
34
 
62
 
            @unlink($controller->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/' . $fileName);
 
35
            @unlink(Config::GetSetting('LIBRARY_LOCATION') . 'temp/' . $fileName);
63
36
 
64
37
            // Set the name for the return
65
38
            $file->name = $layout->layout;
66
39
 
67
40
        } catch (Exception $e) {
68
 
            $controller->getLog()->error('Error importing Layout: %s', $e->getMessage());
69
 
            $controller->getLog()->debug($e->getTraceAsString());
 
41
            Log::error('Error uploading media: %s', $e->getMessage());
 
42
            Log::debug($e->getTraceAsString());
70
43
 
71
44
            $file->error = $e->getMessage();
72
45
 
73
 
            $controller->getApp()->commit = false;
 
46
            $this->options['controller']->getApp()->commit = false;
74
47
        }
75
48
    }
76
49
}
 
 
b'\\ No newline at end of file'