Completed
Push — master ( e35e6f...5d201a )
by Fabien
53:19
created
Classes/Converter/Field.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
     {
59 59
         // Resolve the table name.
60 60
         self::$currentTable = $tableNameOrContentObject instanceof Content ?
61
-            $tableNameOrContentObject->getDataType() :
62
-            $tableNameOrContentObject;
61
+            $tableNameOrContentObject->getDataType() : $tableNameOrContentObject;
63 62
         return $this;
64 63
     }
65 64
 
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -18,98 +18,98 @@
 block discarded – undo
18 18
 class Field implements SingletonInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    static protected $currentField;
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    static protected $currentTable;
30
-
31
-    /**
32
-     * @var array
33
-     */
34
-    protected $storage = [];
35
-
36
-    /**
37
-     * @param string $fieldName
38
-     * @return $this
39
-     * @throws \InvalidArgumentException
40
-     */
41
-    static public function name($fieldName)
42
-    {
43
-        self::$currentField = $fieldName;
44
-        self::$currentTable = ''; // reset the table name value.
45
-        return GeneralUtility::makeInstance(self::class);
46
-    }
47
-
48
-    /**
49
-     * @param string|Content $tableNameOrContentObject
50
-     * @return $this
51
-     */
52
-    public function of($tableNameOrContentObject)
53
-    {
54
-        // Resolve the table name.
55
-        self::$currentTable = $tableNameOrContentObject instanceof Content ?
56
-            $tableNameOrContentObject->getDataType() :
57
-            $tableNameOrContentObject;
58
-        return $this;
59
-    }
60
-
61
-    /**
62
-     * @return string
63
-     * @throws \RuntimeException
64
-     */
65
-    public function toPropertyName()
66
-    {
67
-
68
-        $fieldName = $this->getFieldName();
69
-        $tableName = $this->getTableName();
70
-
71
-        if (empty($this->storage[$tableName][$fieldName])) {
72
-            if ($this->storage[$tableName]) {
73
-                $this->storage[$tableName] = [];
74
-            }
75
-
76
-            // Special case when the field name does not follow the conventions "field_name" => "fieldName".
77
-            // Rely on mapping for those cases.
78
-            if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
79
-                $propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
80
-            } else {
81
-                $propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
82
-            }
83
-
84
-            $this->storage[$tableName][$fieldName] = $propertyName;
85
-        }
86
-
87
-        return $this->storage[$tableName][$fieldName];
88
-    }
89
-
90
-    /**
91
-     * @return string
92
-     * @throws \RuntimeException
93
-     */
94
-    protected function getFieldName()
95
-    {
96
-        $fieldName = self::$currentField;
97
-        if (empty($fieldName)) {
98
-            throw new \RuntimeException('I could not find a field name value.', 1403203290);
99
-        }
100
-        return $fieldName;
101
-    }
102
-
103
-    /**
104
-     * @return string
105
-     */
106
-    protected function getTableName()
107
-    {
108
-        $tableName = self::$currentTable;
109
-        if (empty($tableName)) {
110
-            throw new \RuntimeException('I could not find a table name value.', 1403203291);
111
-        }
112
-        return $tableName;
113
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	static protected $currentField;
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	static protected $currentTable;
30
+
31
+	/**
32
+	 * @var array
33
+	 */
34
+	protected $storage = [];
35
+
36
+	/**
37
+	 * @param string $fieldName
38
+	 * @return $this
39
+	 * @throws \InvalidArgumentException
40
+	 */
41
+	static public function name($fieldName)
42
+	{
43
+		self::$currentField = $fieldName;
44
+		self::$currentTable = ''; // reset the table name value.
45
+		return GeneralUtility::makeInstance(self::class);
46
+	}
47
+
48
+	/**
49
+	 * @param string|Content $tableNameOrContentObject
50
+	 * @return $this
51
+	 */
52
+	public function of($tableNameOrContentObject)
53
+	{
54
+		// Resolve the table name.
55
+		self::$currentTable = $tableNameOrContentObject instanceof Content ?
56
+			$tableNameOrContentObject->getDataType() :
57
+			$tableNameOrContentObject;
58
+		return $this;
59
+	}
60
+
61
+	/**
62
+	 * @return string
63
+	 * @throws \RuntimeException
64
+	 */
65
+	public function toPropertyName()
66
+	{
67
+
68
+		$fieldName = $this->getFieldName();
69
+		$tableName = $this->getTableName();
70
+
71
+		if (empty($this->storage[$tableName][$fieldName])) {
72
+			if ($this->storage[$tableName]) {
73
+				$this->storage[$tableName] = [];
74
+			}
75
+
76
+			// Special case when the field name does not follow the conventions "field_name" => "fieldName".
77
+			// Rely on mapping for those cases.
78
+			if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
79
+				$propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
80
+			} else {
81
+				$propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
82
+			}
83
+
84
+			$this->storage[$tableName][$fieldName] = $propertyName;
85
+		}
86
+
87
+		return $this->storage[$tableName][$fieldName];
88
+	}
89
+
90
+	/**
91
+	 * @return string
92
+	 * @throws \RuntimeException
93
+	 */
94
+	protected function getFieldName()
95
+	{
96
+		$fieldName = self::$currentField;
97
+		if (empty($fieldName)) {
98
+			throw new \RuntimeException('I could not find a field name value.', 1403203290);
99
+		}
100
+		return $fieldName;
101
+	}
102
+
103
+	/**
104
+	 * @return string
105
+	 */
106
+	protected function getTableName()
107
+	{
108
+		$tableName = self::$currentTable;
109
+		if (empty($tableName)) {
110
+			throw new \RuntimeException('I could not find a table name value.', 1403203291);
111
+		}
112
+		return $tableName;
113
+	}
114 114
 
115 115
 }
Please login to merge, or discard this patch.
Classes/View/Button/ToolButton.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,32 +26,32 @@
 block discarded – undo
26 26
 class ToolButton extends AbstractComponentView
27 27
 {
28 28
 
29
-    /**
30
-     * Renders a dropdown menu for storage.
31
-     *
32
-     * @return string
33
-     */
34
-    public function render()
35
-    {
36
-        $result = '';
37
-
38
-        // Compute the additional parameters.
39
-        $additionalParameters = array(
40
-            $this->getModuleLoader()->getParameterPrefix() => array('controller' => 'Tool', 'action' => 'welcome'),
41
-        );
42
-
43
-        // Get current data type and tell whether there are registered tools.
44
-        $dataType = $this->getModuleLoader()->getDataType();
45
-
46
-        if (ToolRegistry::getInstance()->hasAnyTools($dataType)) {
47
-            $result = sprintf(
48
-                '<a href="%s&returnUrl=%s" class="btn btn-default btn-sm btn-doc-header" title="%s"><span class="t3-icon fa fa-cog" aria-hidden="true"></span></a>',
49
-                $this->getModuleLoader()->getModuleUrl($additionalParameters),
50
-                urlencode($this->getModuleLoader()->getModuleUrl()),
51
-                $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:open_tools')
52
-            );
53
-        }
54
-        return $result;
55
-    }
29
+	/**
30
+	 * Renders a dropdown menu for storage.
31
+	 *
32
+	 * @return string
33
+	 */
34
+	public function render()
35
+	{
36
+		$result = '';
37
+
38
+		// Compute the additional parameters.
39
+		$additionalParameters = array(
40
+			$this->getModuleLoader()->getParameterPrefix() => array('controller' => 'Tool', 'action' => 'welcome'),
41
+		);
42
+
43
+		// Get current data type and tell whether there are registered tools.
44
+		$dataType = $this->getModuleLoader()->getDataType();
45
+
46
+		if (ToolRegistry::getInstance()->hasAnyTools($dataType)) {
47
+			$result = sprintf(
48
+				'<a href="%s&returnUrl=%s" class="btn btn-default btn-sm btn-doc-header" title="%s"><span class="t3-icon fa fa-cog" aria-hidden="true"></span></a>',
49
+				$this->getModuleLoader()->getModuleUrl($additionalParameters),
50
+				urlencode($this->getModuleLoader()->getModuleUrl()),
51
+				$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:open_tools')
52
+			);
53
+		}
54
+		return $result;
55
+	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Classes/View/ViewComponentInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 interface ViewComponentInterface
21 21
 {
22 22
 
23
-    /**
24
-     * Renders something to be printed out to the browser.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render();
23
+	/**
24
+	 * Renders something to be printed out to the browser.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render();
29 29
 
30 30
 }
Please login to merge, or discard this patch.
Classes/DataHandler/ProcessAction.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
 class ProcessAction extends Enumeration
23 23
 {
24 24
 
25
-    const REMOVE = 'remove';
25
+	const REMOVE = 'remove';
26 26
 
27
-    const UPDATE = 'update';
27
+	const UPDATE = 'update';
28 28
 
29
-    const COPY = 'copy';
29
+	const COPY = 'copy';
30 30
 
31
-    const MOVE = 'move';
31
+	const MOVE = 'move';
32 32
 
33
-    const LOCALIZE = 'localize';
33
+	const LOCALIZE = 'localize';
34 34
 
35 35
 }
Please login to merge, or discard this patch.
Classes/DataHandler/DataHandlerInterface.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -22,54 +22,54 @@
 block discarded – undo
22 22
 interface DataHandlerInterface
23 23
 {
24 24
 
25
-    /**
26
-     * Process Content with action "update".
27
-     *
28
-     * @param Content $content
29
-     * @return bool
30
-     */
31
-    public function processUpdate(Content $content);
25
+	/**
26
+	 * Process Content with action "update".
27
+	 *
28
+	 * @param Content $content
29
+	 * @return bool
30
+	 */
31
+	public function processUpdate(Content $content);
32 32
 
33
-    /**
34
-     * Process Content with action "remove".
35
-     *
36
-     * @param Content $content
37
-     * @return bool
38
-     */
39
-    public function processRemove(Content $content);
33
+	/**
34
+	 * Process Content with action "remove".
35
+	 *
36
+	 * @param Content $content
37
+	 * @return bool
38
+	 */
39
+	public function processRemove(Content $content);
40 40
 
41
-    /**
42
-     * Process Content with action "copy".
43
-     *
44
-     * @param Content $content
45
-     * @param string $target
46
-     * @return bool
47
-     */
48
-    public function processCopy(Content $content, $target);
41
+	/**
42
+	 * Process Content with action "copy".
43
+	 *
44
+	 * @param Content $content
45
+	 * @param string $target
46
+	 * @return bool
47
+	 */
48
+	public function processCopy(Content $content, $target);
49 49
 
50
-    /**
51
-     * Process Content with action "move".
52
-     *
53
-     * @param Content $content
54
-     * @param mixed $target
55
-     * @return bool
56
-     */
57
-    public function processMove(Content $content, $target);
50
+	/**
51
+	 * Process Content with action "move".
52
+	 *
53
+	 * @param Content $content
54
+	 * @param mixed $target
55
+	 * @return bool
56
+	 */
57
+	public function processMove(Content $content, $target);
58 58
 
59
-    /**
60
-     * Process Content with action "localize".
61
-     *
62
-     * @param Content $content
63
-     * @param int $language
64
-     * @return bool
65
-     */
66
-    public function processLocalize(Content $content, $language);
59
+	/**
60
+	 * Process Content with action "localize".
61
+	 *
62
+	 * @param Content $content
63
+	 * @param int $language
64
+	 * @return bool
65
+	 */
66
+	public function processLocalize(Content $content, $language);
67 67
 
68
-    /**
69
-     * Return error that have occurred while processing the data.
70
-     *
71
-     * @return array
72
-     */
73
-    public function getErrorMessages();
68
+	/**
69
+	 * Return error that have occurred while processing the data.
70
+	 *
71
+	 * @return array
72
+	 */
73
+	public function getErrorMessages();
74 74
 
75 75
 }
Please login to merge, or discard this patch.
Classes/DataHandler/DataHandlerFactory.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -23,70 +23,70 @@
 block discarded – undo
23 23
 class DataHandlerFactory implements SingletonInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $actionName = '';
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $actionName = '';
30 30
 
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $dataType = '';
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $dataType = '';
35 35
 
36
-    /**
37
-     * Default is CoreDataHandler which wraps the Core DataHandler.
38
-     *
39
-     * @var string
40
-     */
41
-    protected $defaultDataHandler = 'Fab\Vidi\DataHandler\CoreDataHandler';
36
+	/**
37
+	 * Default is CoreDataHandler which wraps the Core DataHandler.
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $defaultDataHandler = 'Fab\Vidi\DataHandler\CoreDataHandler';
42 42
 
43
-    /**
44
-     * @param string $actionName
45
-     * @return $this
46
-     */
47
-    public function action($actionName)
48
-    {
49
-        $this->actionName = $actionName;
50
-        return $this;
51
-    }
43
+	/**
44
+	 * @param string $actionName
45
+	 * @return $this
46
+	 */
47
+	public function action($actionName)
48
+	{
49
+		$this->actionName = $actionName;
50
+		return $this;
51
+	}
52 52
 
53
-    /**
54
-     * @param string $dataType
55
-     * @return $this
56
-     */
57
-    public function forType($dataType)
58
-    {
59
-        $this->dataType = $dataType;
60
-        return $this;
61
-    }
53
+	/**
54
+	 * @param string $dataType
55
+	 * @return $this
56
+	 */
57
+	public function forType($dataType)
58
+	{
59
+		$this->dataType = $dataType;
60
+		return $this;
61
+	}
62 62
 
63
-    /**
64
-     * Returns a Data Handler instance.
65
-     *
66
-     * @throws \Exception
67
-     * @return DataHandlerInterface
68
-     */
69
-    public function getDataHandler()
70
-    {
63
+	/**
64
+	 * Returns a Data Handler instance.
65
+	 *
66
+	 * @throws \Exception
67
+	 * @return DataHandlerInterface
68
+	 */
69
+	public function getDataHandler()
70
+	{
71 71
 
72
-        if (empty($this->dataType)) {
73
-            throw new \Exception('Attribute $this->dataType can not be empty', 1410001035);
74
-        }
72
+		if (empty($this->dataType)) {
73
+			throw new \Exception('Attribute $this->dataType can not be empty', 1410001035);
74
+		}
75 75
 
76
-        if (empty($this->actionName)) {
77
-            throw new \Exception('Attribute $this->actionName can not be empty', 1410001036);
78
-        }
76
+		if (empty($this->actionName)) {
77
+			throw new \Exception('Attribute $this->actionName can not be empty', 1410001036);
78
+		}
79 79
 
80
-        if (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName])) {
81
-            $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName];
82
-        } elseif (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'])) {
83
-            $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'];
84
-        } else {
85
-            $className = $this->defaultDataHandler;
86
-        }
80
+		if (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName])) {
81
+			$className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName];
82
+		} elseif (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'])) {
83
+			$className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'];
84
+		} else {
85
+			$className = $this->defaultDataHandler;
86
+		}
87 87
 
88
-        $dataHandler = GeneralUtility::makeInstance($className);
89
-        return $dataHandler;
90
-    }
88
+		$dataHandler = GeneralUtility::makeInstance($className);
89
+		return $dataHandler;
90
+	}
91 91
 
92 92
 }
Please login to merge, or discard this patch.
Classes/Service/SpreadSheetService.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -27,147 +27,147 @@
 block discarded – undo
27 27
 class SpreadSheetService
28 28
 {
29 29
 
30
-    const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
31
-    const XmlFooter = "</Workbook>";
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $encoding = 'UTF-8'; // encoding type to specify in file.
37
-    // Note that you're on your own for making sure your data is actually encoded to this encoding
38
-
39
-    /**
40
-     * @var string
41
-     */
42
-    protected $title = 'Sheet1'; // title for Worksheet
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    protected $buffer = '';
48
-
49
-
50
-    /**
51
-     * Constructor
52
-     */
53
-    public function __construct()
54
-    {
55
-        $this->addToBuffer($this->generateHeader());
56
-    }
57
-
58
-    /**
59
-     * @param array $row
60
-     */
61
-    public function addRow($row)
62
-    {
63
-        $this->addToBuffer($this->generateRow($row));
64
-    }
65
-
66
-    /**
67
-     * @return mixed
68
-     */
69
-    public function toString()
70
-    {
71
-        $this->addToBuffer($this->generateFooter());
72
-        return $this->buffer;
73
-    }
74
-
75
-    /**
76
-     * @param $data
77
-     */
78
-    protected function addToBuffer($data)
79
-    {
80
-        $this->buffer .= $data;
81
-    }
82
-
83
-    /**
84
-     * @return string
85
-     */
86
-    protected function generateHeader()
87
-    {
88
-
89
-        // workbook header
90
-        $output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
91
-
92
-        // Set up styles
93
-        $output .= "<Styles>\n";
94
-        $output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
95
-        $output .= "</Styles>\n";
96
-
97
-        // worksheet header
98
-        $output .= sprintf("<Worksheet ss:Name=\"%s\">\n    <Table>\n", htmlentities($this->title));
99
-
100
-        return $output;
101
-    }
102
-
103
-    protected function generateFooter()
104
-    {
105
-        $output = '';
106
-
107
-        // worksheet footer
108
-        $output .= "    </Table>\n</Worksheet>\n";
109
-
110
-        // workbook footer
111
-        $output .= self::XmlFooter;
112
-
113
-        return $output;
114
-    }
115
-
116
-    /**
117
-     * @param $row
118
-     * @return string
119
-     */
120
-    protected function generateRow($row)
121
-    {
122
-        $output = '';
123
-        $output .= "        <Row>\n";
124
-        foreach ($row as $v) {
125
-            $output .= $this->generateCell($v);
126
-        }
127
-        $output .= "        </Row>\n";
128
-        return $output;
129
-    }
130
-
131
-    /**
132
-     * @param $item
133
-     * @return string
134
-     */
135
-    protected function generateCell($item)
136
-    {
137
-        $output = '';
138
-        $style = '';
139
-
140
-        // Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
141
-        // as text if number is longer than that.
142
-        if (preg_match("/^-?\d+(?:[.,]\d+)?$/", $item) && (strlen($item) < 15)) {
143
-            $type = 'Number';
144
-        }
145
-        // Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
146
-        // also have an optional time after the date.
147
-        //
148
-        // Note we want to be very strict in what we consider a date. There is the possibility
149
-        // of really screwing up the data if we try to reformat a string that was not actually
150
-        // intended to represent a date.
151
-        elseif (preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item) &&
152
-            ($timestamp = strtotime($item)) &&
153
-            ($timestamp > 0) &&
154
-            ($timestamp < strtotime('+500 years'))
155
-        ) {
156
-            $type = 'DateTime';
157
-            $item = strftime("%Y-%m-%dT%H:%M:%S", $timestamp);
158
-            $style = 'sDT'; // defined in header; tells excel to format date for display
159
-        } else {
160
-            $type = 'String';
161
-        }
162
-
163
-        $item = str_replace('&#039;', '&apos;', htmlspecialchars($item, ENT_QUOTES));
164
-        $item = str_replace("\n", '&#13;', $item);
165
-        $output .= "            ";
166
-        $output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
167
-        $output .= sprintf("<Data ss:Type=\"%s\">%s</Data>", $type, $item);
168
-        $output .= "</Cell>\n";
169
-
170
-        return $output;
171
-    }
30
+	const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
31
+	const XmlFooter = "</Workbook>";
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $encoding = 'UTF-8'; // encoding type to specify in file.
37
+	// Note that you're on your own for making sure your data is actually encoded to this encoding
38
+
39
+	/**
40
+	 * @var string
41
+	 */
42
+	protected $title = 'Sheet1'; // title for Worksheet
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	protected $buffer = '';
48
+
49
+
50
+	/**
51
+	 * Constructor
52
+	 */
53
+	public function __construct()
54
+	{
55
+		$this->addToBuffer($this->generateHeader());
56
+	}
57
+
58
+	/**
59
+	 * @param array $row
60
+	 */
61
+	public function addRow($row)
62
+	{
63
+		$this->addToBuffer($this->generateRow($row));
64
+	}
65
+
66
+	/**
67
+	 * @return mixed
68
+	 */
69
+	public function toString()
70
+	{
71
+		$this->addToBuffer($this->generateFooter());
72
+		return $this->buffer;
73
+	}
74
+
75
+	/**
76
+	 * @param $data
77
+	 */
78
+	protected function addToBuffer($data)
79
+	{
80
+		$this->buffer .= $data;
81
+	}
82
+
83
+	/**
84
+	 * @return string
85
+	 */
86
+	protected function generateHeader()
87
+	{
88
+
89
+		// workbook header
90
+		$output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
91
+
92
+		// Set up styles
93
+		$output .= "<Styles>\n";
94
+		$output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
95
+		$output .= "</Styles>\n";
96
+
97
+		// worksheet header
98
+		$output .= sprintf("<Worksheet ss:Name=\"%s\">\n    <Table>\n", htmlentities($this->title));
99
+
100
+		return $output;
101
+	}
102
+
103
+	protected function generateFooter()
104
+	{
105
+		$output = '';
106
+
107
+		// worksheet footer
108
+		$output .= "    </Table>\n</Worksheet>\n";
109
+
110
+		// workbook footer
111
+		$output .= self::XmlFooter;
112
+
113
+		return $output;
114
+	}
115
+
116
+	/**
117
+	 * @param $row
118
+	 * @return string
119
+	 */
120
+	protected function generateRow($row)
121
+	{
122
+		$output = '';
123
+		$output .= "        <Row>\n";
124
+		foreach ($row as $v) {
125
+			$output .= $this->generateCell($v);
126
+		}
127
+		$output .= "        </Row>\n";
128
+		return $output;
129
+	}
130
+
131
+	/**
132
+	 * @param $item
133
+	 * @return string
134
+	 */
135
+	protected function generateCell($item)
136
+	{
137
+		$output = '';
138
+		$style = '';
139
+
140
+		// Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
141
+		// as text if number is longer than that.
142
+		if (preg_match("/^-?\d+(?:[.,]\d+)?$/", $item) && (strlen($item) < 15)) {
143
+			$type = 'Number';
144
+		}
145
+		// Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
146
+		// also have an optional time after the date.
147
+		//
148
+		// Note we want to be very strict in what we consider a date. There is the possibility
149
+		// of really screwing up the data if we try to reformat a string that was not actually
150
+		// intended to represent a date.
151
+		elseif (preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item) &&
152
+			($timestamp = strtotime($item)) &&
153
+			($timestamp > 0) &&
154
+			($timestamp < strtotime('+500 years'))
155
+		) {
156
+			$type = 'DateTime';
157
+			$item = strftime("%Y-%m-%dT%H:%M:%S", $timestamp);
158
+			$style = 'sDT'; // defined in header; tells excel to format date for display
159
+		} else {
160
+			$type = 'String';
161
+		}
162
+
163
+		$item = str_replace('&#039;', '&apos;', htmlspecialchars($item, ENT_QUOTES));
164
+		$item = str_replace("\n", '&#13;', $item);
165
+		$output .= "            ";
166
+		$output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
167
+		$output .= sprintf("<Data ss:Type=\"%s\">%s</Data>", $type, $item);
168
+		$output .= "</Cell>\n";
169
+
170
+		return $output;
171
+	}
172 172
 
173 173
 }
174 174
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
     {
88 88
 
89 89
         // workbook header
90
-        $output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
90
+        $output = stripslashes(sprintf(self::XmlHeader, $this->encoding))."\n";
91 91
 
92 92
         // Set up styles
93 93
         $output .= "<Styles>\n";
Please login to merge, or discard this patch.
Classes/Domain/Model/Selection.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -22,146 +22,146 @@
 block discarded – undo
22 22
 class Selection extends AbstractEntity
23 23
 {
24 24
 
25
-    const VISIBILITY_EVERYONE = 0;
26
-    const VISIBILITY_PRIVATE = 1;
27
-    const VISIBILITY_ADMIN_ONLY = 2;
28
-
29
-    /**
30
-     * @var int
31
-     */
32
-    protected $visibility;
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    protected $name;
38
-
39
-    /**
40
-     * @var string
41
-     */
42
-    protected $dataType;
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    protected $query;
48
-
49
-    /**
50
-     * @var string
51
-     */
52
-    protected $speakingQuery;
53
-
54
-    /**
55
-     * @var int
56
-     */
57
-    protected $owner;
58
-
59
-    /**
60
-     * @param string $dataType
61
-     * @return $this
62
-     */
63
-    public function setDataType($dataType)
64
-    {
65
-        $this->dataType = $dataType;
66
-        return $this;
67
-    }
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    public function getDataType()
73
-    {
74
-        return $this->dataType;
75
-    }
76
-
77
-    /**
78
-     * @param string $query
79
-     * @return $this
80
-     */
81
-    public function setQuery($query)
82
-    {
83
-        $this->query = $query;
84
-        return $this;
85
-    }
86
-
87
-    /**
88
-     * @return string
89
-     */
90
-    public function getQuery()
91
-    {
92
-        return $this->query;
93
-    }
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getSpeakingQuery()
99
-    {
100
-        return $this->speakingQuery;
101
-    }
102
-
103
-    /**
104
-     * @param string $speakingQuery
105
-     * @return $this
106
-     */
107
-    public function setSpeakingQuery($speakingQuery)
108
-    {
109
-        $this->speakingQuery = $speakingQuery;
110
-        return $this;
111
-    }
112
-
113
-    /**
114
-     * @param string $name
115
-     * @return $this
116
-     */
117
-    public function setName($name)
118
-    {
119
-        $this->name = $name;
120
-        return $this;
121
-    }
122
-
123
-    /**
124
-     * @return string
125
-     */
126
-    public function getName()
127
-    {
128
-        return $this->name;
129
-    }
130
-
131
-    /**
132
-     * @param int $visibility
133
-     * @return $this
134
-     */
135
-    public function setVisibility($visibility)
136
-    {
137
-        $this->visibility = $visibility;
138
-        return $this;
139
-    }
140
-
141
-    /**
142
-     * @return int
143
-     */
144
-    public function getVisibility()
145
-    {
146
-        return $this->visibility;
147
-    }
148
-
149
-    /**
150
-     * @return int
151
-     */
152
-    public function getOwner()
153
-    {
154
-        return $this->owner;
155
-    }
156
-
157
-    /**
158
-     * @param int $owner
159
-     * @return $this
160
-     */
161
-    public function setOwner($owner)
162
-    {
163
-        $this->owner = $owner;
164
-        return $this;
165
-    }
25
+	const VISIBILITY_EVERYONE = 0;
26
+	const VISIBILITY_PRIVATE = 1;
27
+	const VISIBILITY_ADMIN_ONLY = 2;
28
+
29
+	/**
30
+	 * @var int
31
+	 */
32
+	protected $visibility;
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	protected $name;
38
+
39
+	/**
40
+	 * @var string
41
+	 */
42
+	protected $dataType;
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	protected $query;
48
+
49
+	/**
50
+	 * @var string
51
+	 */
52
+	protected $speakingQuery;
53
+
54
+	/**
55
+	 * @var int
56
+	 */
57
+	protected $owner;
58
+
59
+	/**
60
+	 * @param string $dataType
61
+	 * @return $this
62
+	 */
63
+	public function setDataType($dataType)
64
+	{
65
+		$this->dataType = $dataType;
66
+		return $this;
67
+	}
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	public function getDataType()
73
+	{
74
+		return $this->dataType;
75
+	}
76
+
77
+	/**
78
+	 * @param string $query
79
+	 * @return $this
80
+	 */
81
+	public function setQuery($query)
82
+	{
83
+		$this->query = $query;
84
+		return $this;
85
+	}
86
+
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function getQuery()
91
+	{
92
+		return $this->query;
93
+	}
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getSpeakingQuery()
99
+	{
100
+		return $this->speakingQuery;
101
+	}
102
+
103
+	/**
104
+	 * @param string $speakingQuery
105
+	 * @return $this
106
+	 */
107
+	public function setSpeakingQuery($speakingQuery)
108
+	{
109
+		$this->speakingQuery = $speakingQuery;
110
+		return $this;
111
+	}
112
+
113
+	/**
114
+	 * @param string $name
115
+	 * @return $this
116
+	 */
117
+	public function setName($name)
118
+	{
119
+		$this->name = $name;
120
+		return $this;
121
+	}
122
+
123
+	/**
124
+	 * @return string
125
+	 */
126
+	public function getName()
127
+	{
128
+		return $this->name;
129
+	}
130
+
131
+	/**
132
+	 * @param int $visibility
133
+	 * @return $this
134
+	 */
135
+	public function setVisibility($visibility)
136
+	{
137
+		$this->visibility = $visibility;
138
+		return $this;
139
+	}
140
+
141
+	/**
142
+	 * @return int
143
+	 */
144
+	public function getVisibility()
145
+	{
146
+		return $this->visibility;
147
+	}
148
+
149
+	/**
150
+	 * @return int
151
+	 */
152
+	public function getOwner()
153
+	{
154
+		return $this->owner;
155
+	}
156
+
157
+	/**
158
+	 * @param int $owner
159
+	 * @return $this
160
+	 */
161
+	public function setOwner($owner)
162
+	{
163
+		$this->owner = $owner;
164
+		return $this;
165
+	}
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Classes/Domain/Validator/ContentValidator.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@
 block discarded – undo
23 23
 class ContentValidator
24 24
 {
25 25
 
26
-    /**
27
-     * Check whether $Content object is valid.
28
-     *
29
-     * @param Content $content
30
-     * @throws \Exception
31
-     * @return void
32
-     */
33
-    public function validate(Content $content)
34
-    {
26
+	/**
27
+	 * Check whether $Content object is valid.
28
+	 *
29
+	 * @param Content $content
30
+	 * @throws \Exception
31
+	 * @return void
32
+	 */
33
+	public function validate(Content $content)
34
+	{
35 35
 
36
-        // Security check.
37
-        if ($content->getUid() <= 0) {
38
-            throw new MissingIdentifierException('Missing identifier for Content Object', 1351605542);
39
-        }
40
-    }
36
+		// Security check.
37
+		if ($content->getUid() <= 0) {
38
+			throw new MissingIdentifierException('Missing identifier for Content Object', 1351605542);
39
+		}
40
+	}
41 41
 
42 42
 }
Please login to merge, or discard this patch.