Commit a2b79ee5 authored by speedprogs_de's avatar speedprogs_de

added documentation service, added more functionality to chart view helper

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51644 735d13b6-9817-0410-8766-e36946ffe9aa
parent a8867d65
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project 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.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Service to handle documentations
*/
class Tx_TerFe2_Service_Documentation implements t3lib_Singleton {
/**
* Get documentation url
*
* @param string $extension Extension key
* @param string $version Version string
* @return string Url to documentation
*/
public function getDocumentationUrl($extension, $version) {
if (empty($extension) || empty($version)) {
throw new Exception('Extension key and version string are required to build a documentation url');
}
// TODO: Get url from ter_doc extension
return '';
}
}
?>
\ No newline at end of file
......@@ -88,6 +88,11 @@
*/
protected $authorRepository;
/**
* @var Tx_TerFe2_Service_Documentation
*/
protected $documentationService;
/**
* Initialize task
......@@ -120,6 +125,9 @@
// Load repositories
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
// Load documentation service
$this->documentationService = $this->objectManager->get('Tx_TerFe2_Service_Documentation');
}
......@@ -202,6 +210,10 @@
$version->setExtensionProvider($this->providerName);
$modified = TRUE;
// Online documentation
$documentationUrl = $this->documentationService->getDocumentationUrl($extensionRow['ext_key'], $versionRow['version_string']);
$version->setManual($documentationUrl);
// Relations
foreach ($versionRow['relations'] as $relationRow) {
$relation = $this->objectBuilder->create('Tx_TerFe2_Domain_Model_Relation', $relationRow);
......
......@@ -25,6 +25,8 @@
/**
* Chart view helper
*
* For documentation and examples visit http://www.jqplot.com
*/
class Tx_TerFe2_ViewHelpers_ChartViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
......@@ -36,22 +38,38 @@
/**
* @var string
*/
protected $scriptTag = '<script type="text/javascript">|</script>';
protected $chart = '
<div id="%1$s" style="height:%2$s;width:%3$s;"></div>
<script type="text/javascript">$.jqplot("%1$s", %4$s, {%5$s});</script>
';
/**
* Renders a jqPlot chart
*
* @param array $points Array of points on chart
* @param integer $height Height of the chart
* @param integer $width Width of the chart
* @param string $color Color of the line
* @return string Chart
*/
public function render($points = NULL) {
public function render($points = NULL, $height = 300, $width = 400, $color = '#FFA500') {
if ($points === NULL) {
$points = $this->renderChildren();
}
$script = '$.jqplot("chartdiv", [[[1,2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);';
return str_replace('|', $script, $this->scriptTag);
if (!is_array($points)) {
throw new Exception('Chart points have no valid format');
}
$id = uniqid('chart_');
$height = (int) $height . 'px';
$width = (int) $width . 'px';
$points = json_encode(array(array($points)));
$options = 'series:[{color:"' . $color . '"}]';
return sprintf($this->chart, $id, $height, $width, $points, $options);
}
}
......
......@@ -28,12 +28,13 @@
'tx_terfe2_persistence_persistenceinterface' => $extensionClassesPath . 'Persistence/PersistenceInterface.php',
'tx_terfe2_persistence_registry' => $extensionClassesPath . 'Persistence/Registry.php',
'tx_terfe2_persistence_session' => $extensionClassesPath . 'Persistence/Session.php',
'tx_terfe2_service_documentation' => $extensionClassesPath . 'Service/Documentation.php',
'tx_terfe2_service_mirror' => $extensionClassesPath . 'Service/Mirror.php',
'tx_terfe2_service_soap' => $extensionClassesPath . 'Service/Soap.php',
'tx_terfe2_task_updateextensionlisttask' => $extensionClassesPath . 'Task/UpdateExtensionListTask.php',
'tx_terfe2_task_updateextensionlisttaskadditionalfieldprovider' => $extensionClassesPath . 'Task/UpdateExtensionListTaskAdditionalFieldProvider.php',
'tx_terfe2_utility_archive' => $extensionClassesPath . 'Utility/Archive.php',
'tx_terfe2_utility_file' => $extensionClassesPath . 'Utility/File.php',
'tx_terfe2_utility_soap' => $extensionClassesPath . 'Utility/Soap.php',
'tx_terfe2_utility_typoscript' => $extensionClassesPath . 'Utility/TypoScript.php',
'tx_terfe2_viewhelpers_cdataviewhelper' => $extensionClassesPath . 'ViewHelpers/CdataViewHelper.php',
'tx_terfe2_viewhelpers_chartviewhelper' => $extensionClassesPath . 'ViewHelpers/ChartViewHelper.php',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment