diff --git a/README.md b/README.md index 37cdf9a..9e6ada3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,85 @@ -# plg_content_jtcsv2html -Contentlugin um CSV-Dateien als Tabelle in einem Beitrag darzustelen. +# JT - Csv2Html +Content-Plugin für [Joomla!™](https://joomla.org) um CSV-Dateien als Tabelle in einem Beitrag darzustellen. + +## Aufruf +```php +{jtcsv2html string $filename[,string $templatename = 'default'[, string $filter]]} +``` + ++ **$filename:** +Dateiname der CSV ohne Endung +**_testfile_** = images/jtcsv2html/testfile.csv + ++ **$templatename:** +Dieses Plugin bringt zwei Vorlagen mit: +**_default_**: eine einfache Tabelle +**_responsive_**: eine responsive Tabelle +**_eigene_**: eine eigene Vorlage kann in einem der jeweiligen [Override-Ordner](#overrides) erstellt werden + ++ **$filter:** +Der Filter wird global in den Plugin-Einstellungen konfiguriert und kann an dieser Stelle überschrieben werden. +**_on_**: aktiviert den Filter +**_off_**: deaktiviert den Filter + +### Overrides +Reihenfolge, in der nach Overrides von Ausgabe und CSS gesucht wird. Es wir jeweils die erste Übereinstimmung genommen. + ++ **Plugin-Ausgabe:** +```php +// Templatespezifische Ausgabe +- [templates/YOUR_TEMPLATE/html/plg_content_jtcsv2html/{$templatemname}.php] + +// Templateübergreifende Ausgabe +- [images/jtcsv2html/{$templatemname}.php] + +// Standardausgabe +- [plugins/content/jtcsv2html/tmpl/{$templatename}.php + +// Fallback - templatespezifische Ausgabe +- [templates/YOUR_TEMPLATE/html/plg_content_jtcsv2html/default.php] + +// Fallback - templateübergreifende Ausgabe +- [images/jtcsv2html/default.php] + +// Fallback - Standardausgabe +- [plugins/content/jtcsv2html/tmpl/default.php +``` + ++ **CSS:** +```php +// Templatespezifische Formatierung für nur diese Datei +- [templates/YOUR_TEMPLATE/html/plg_content_jtcsv2html/{$filename}.css] + +// Templateübergreifende Formatierung für nur diese Datei +- [images/jtcsv2html/{$filename}.php] + +// Templatespezifische Formatierung für die Ausgabevorlage +- [templates/YOUR_TEMPLATE/html/plg_content_jtcsv2html/{$templatemname}.css] + +// Templateübergreifende Formatierung für die Ausgabevorlage +- [images/jtcsv2html/{$templatemname}.css] + +// Standardformatierung für die Ausgabevorlage +- [plugins/content/jtcsv2html/tmpl/{$templatename}.css + +// Fallback - templatespezifische Formatierung für die Ausgabevorlage +- [templates/YOUR_TEMPLATE/html/plg_content_jtcsv2html/default.css] + +// Fallback - templateübergreifende Formatierung für die Ausgabevorlage +- [images/jtcsv2html/default.css] + +// Fallback - Standardformatierung für die Ausgabevorlage +- [plugins/content/jtcsv2html/tmpl/default.css +``` + +### Danke für die Unterstützung +[@astridx](https://github.com/astridx) - für die Implementierung der Filterfunktion + + +## Plugin für die Suche +(https://github.com/JoomTools/plg_search_jtcsv2html/tree/dev) + + + + + diff --git a/assets/index.html b/assets/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/assets/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/plg_jtcsv2html_search.js b/assets/plg_jtcsv2html_search.js new file mode 100644 index 0000000..a551d48 --- /dev/null +++ b/assets/plg_jtcsv2html_search.js @@ -0,0 +1,21 @@ +(function ($) { + $(document).ready(function () + { + { + $('.jtcsv2html_wrapper').each(function () { + + var $search = $(this).find('.search'); + var $rows = $(this).find('tbody > tr'); + + $search.keyup(function () { + var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase(); + + $rows.show().filter(function () { + var text = $(this).text().replace(/\s+/g, ' ').toLowerCase(); + return !~text.indexOf(val); + }).hide(); + }); + }); + } + }); +})(jQuery); diff --git a/jtcsv2html.php b/jtcsv2html.php index 6955b17..ea1fa81 100644 --- a/jtcsv2html.php +++ b/jtcsv2html.php @@ -1,11 +1,11 @@ + * @license GNU/GPL v3 * 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 3 of the License, or @@ -26,14 +26,26 @@ class plgContentJtcsv2html extends JPlugin private $pattern = '@(<[^>]+>|){jtcsv2html (.*)}(]+>|)@Usi'; private $old_pattern = '@(<[^>]+>|){csv2html (.*)}(]+>|)@Usi'; - private $delimiter = NULL; - private $enclosure = NULL; + private $delimiter = null; + private $enclosure = null; + private $filter = null; private $cssFiles = array(); - private $_error = NULL; + private $_error = null; private $_matches = false; private $_csv = array(); private $_html = ''; - private $FB = false; + + private static $articleId; + + private static function getArticleId($id = null) + { + if (!empty($id)) + { + self::$articleId = $id; + } + + return self::$articleId; + } public function __construct(&$subject, $params) { @@ -44,371 +56,328 @@ public function __construct(&$subject, $params) $this->loadLanguage('plg_content_jtcsv2html'); $app = JFactory::getApplication(); - if (version_compare(phpversion(), '5.3', '<')) { + if (version_compare(phpversion(), '5.3', '<')) + { $app->enqueueMessage(JText::_('PLG_CONTENT_JTCSV2HTML_PHP_VERSION'), 'warning'); + return; } $this->delimiter = trim($this->params->get('delimiter', ',')); $this->enclosure = trim($this->params->get('enclosure', '"')); + $this->filter = trim($this->params->get('filter', 0)); - if(defined('JFIREPHP') && $this->params->get('debug', 0)) { - $this->FB = FirePHP::getInstance(true); - } else { - $this->FB = false; + if ($this->params->get('clearDB', 0)) + { + $this->_dbClearAll(); } + } - if($this->params->get('clearDB', 0)) { - if($this->FB) $this->FB->group(__FUNCTION__ . '()', array('Collapsed' => true, 'Color' => '#6699CC')); - $this->_dbClearAll(); - if($this->FB) $this->FB->groupEnd(); + protected function _dbClearAll() + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); - } + // Zuruecksetzen des Parameters + $this->params->set('clearDB', 0); + $params = $this->params->toString(); + //$plgName = $this->_name; + + $query->clear(); + $query->update('#__extensions'); + $query->set('params=' . $db->quote($params)); + $query->where('name=' . $db->quote('PLG_CONTENT_JTCSV2HTML')); + + $db->setQuery($query); + $db->execute(); + + // Loeschen aller Daten aus der Datenbank + $query->clear(); + $db->setQuery('TRUNCATE #__jtcsv2html'); + $db->execute(); + + $query->clear(); + $db->setQuery('OPTIMIZE TABLE #__jtcsv2html'); + $db->execute(); } - public function onContentPrepare($context, &$article, &$params, $limitstart) + public function onContentPrepare($context, &$article, &$params, $limitstart = 0) { - if(!JFactory::getApplication()->isSite()) return; + if (!JFactory::getApplication()->isSite()) + { + return; + } + $app = JFactory::getApplication(); - if (version_compare(phpversion(), '5.3', '<')) { + if (version_compare(phpversion(), '5.3', '<')) + { return; } - /* Prüfen ob Plugin-Platzhalter im Text ist */ -// if(!preg_match($this->pattern, $article->text) && !preg_match($this->old_pattern, $article->text)) return; - - $FB = $this->FB; - $_error = ($context == 'com_content.search') ? false : true; - $cache = $this->params->get('cache', 1); + $_error = ($context == 'com_content.search') ? false : true; + $cache = $this->params->get('cache', 1); $this->_error = $_error; - $timestart = microtime(true); - - if($FB) $FB->group('Plugin - JT - Csv2Html', array('Collapsed' => false, 'Color' => '#6699CC')); - if($FB) $FB->log($context, '$context'); - if($FB) $FB->log($article, '$article'); - if($FB) $FB->log($params, '$params'); - if($FB) $FB->log($limitstart, '$limitstart'); - if($FB) $FB->log($_error, '$_error'); /* Pluginaufruf auslesen */ - if($this->_patterns($article->text) === false) { - if($FB) $FB->groupEnd(); - return ; + if ($this->_patterns($article->text) === false) + { + return; } - while($matches = each($this->_matches)) + while ($matches = each($this->_matches)) { - foreach($matches[1] as $_matches) + foreach ($matches[1] as $_matches) { - $timestamp1 = microtime(true); $file = JPATH_SITE . '/images/jtcsv2html/' . $_matches['fileName'] . '.csv'; - if($FB) { - $FB->group('Aufruf der Datei ' . $_matches['fileName'] . '.csv', array('Collapsed' => true, - 'Color' => '#6699CC')); - $FB->log($file, 'Dateipfad'); - } + $articleId = !empty($article->id) ? $article->id : null; - $this->_csv['cid'] = $article->id; - $this->_csv['file'] = $file; + $this->_csv['cid'] = self::getArticleId($articleId); + $this->_csv['file'] = $file; $this->_csv['filename'] = $_matches['fileName']; - $this->_csv['tplname'] = $_matches['tplName']; + $this->_csv['tplname'] = $_matches['tplName']; + $this->_csv['filter'] = $_matches['filter']; $this->_csv['filetime'] = (file_exists($file)) ? filemtime($file) : -1; $this->_setTplPath(); - if($this->_csv['filetime'] != -1) + if ($this->_csv['filetime'] != -1) { - if($cache) + if ($cache) { $setOutput = $this->_dbChkCache(); } else { $setOutput = $this->_readCsv(); - if($setOutput) $this->_buildHtml(); + if ($setOutput) $this->_buildHtml(); } /* Plugin-Aufruf durch HTML-Ausgabe ersetzen */ - if($setOutput) + if ($setOutput) { - $article->text = str_replace($_matches['replacement'], $this->_html, $article->text); + $output = '
'; + + if ($this->_csv['filter']) + { + $output .= ''; + JHtml::_('jquery.framework'); + JHtml::script('plugins/content/jtcsv2html/assets/plg_jtcsv2html_search.js', false, false); + } + $output .= $this->_html; + $output .= '
'; + + if (!class_exists('Minify_HTML')) + { + require_once 'assets/minifyHTML.inc'; + } + $output = Minify_HTML::minify($output); + + $article->text = str_replace($_matches['replacement'], $output, $article->text); } else { - if($_error) + if ($_error) { - if($FB) $FB->warn('Fehler trotz CSV-Datei.'); - $app->enqueueMessage( - JText::sprintf('PLG_CONTENT_JTCSV2HTML_NOCSV', $_matches['fileName'].'.csv') - , 'warning' + JText::sprintf('PLG_CONTENT_JTCSV2HTML_NOCSV', $_matches['fileName'] . '.csv') + , 'warning' ); } } } else { - if($FB) $FB->warn('CSV-Datei nicht gefunden.'); - - if($_error) { + if ($_error) + { $app->enqueueMessage( - JText::sprintf('PLG_CONTENT_JTCSV2HTML_NOCSV', $_matches['fileName'].'.csv') - , 'warning' + JText::sprintf('PLG_CONTENT_JTCSV2HTML_NOCSV', $_matches['fileName'] . '.csv') + , 'warning' ); } + $this->_dbClearCache(); } unset($this->_csv, $this->_html); - $timestamp2 = microtime(true); - $timestamp = $timestamp2-$timestamp1; - - if($FB) $FB->info($timestamp, 'verbrauchte Zeit in Sek.'); - - if($FB) $FB->groupEnd(); } //endforeach } - if(count($this->cssFiles) > 0) $this->_loadCSS(); - - $timeend = microtime(true); - $timetotal = $timeend-$timestart; - - if($FB) $FB->info($timetotal, 'verbrauchte Zeit in Sek.'); - if($FB) $FB->groupEnd(); - } - - public function onContentAfterSave($context, $article, $isNew) - { - $this->_onContentEvent($context, $article, $isNew); - } - - public function onContentBeforeDelete($context, $data) - { - $this->_onContentEvent($context, $data); - } - - protected function _onContentEvent($context, $article, $isNew=false) - { - if (version_compare(phpversion(), '5.3', '<') || $isNew) { - return; - } - - $FB = $this->FB; - $this->_csv['cid'] = $article->id; - - if($FB) $FB->group( - 'Plugin - JT - Csv2Html => ' . __FUNCTION__ . '()' - , array('Collapsed' => false, 'Color' => '#6699CC') - ); - - if($FB) $FB->log($context, '$context'); - if($FB) $FB->log($article, '$article'); - if($FB) $FB->log($isNew, '$isNew'); - - $dbClearCache = $this->_dbClearCache(true); - - if($FB) $FB->log($dbClearCache, '$dbClearCache'); - - if($FB) $FB->groupEnd(); + if (count($this->cssFiles) > 0) $this->_loadCSS(); } /** * Wertet die Pluginaufrufe aus * - * @param string $article der Artikeltext + * @param string $article der Artikeltext * * @return boolean */ protected function _patterns($article) { - $FB = $this->FB; $return = false; $_match = array(); - if($FB) $FB->group( - __FUNCTION__ . '()' - , array('Collapsed' => true, 'Color' => '#6699CC') - ); - - if($FB) $FB->log($article, '$article'); - $p1 = preg_match_all($this->pattern, $article, $matches1, PREG_SET_ORDER); $p2 = preg_match_all($this->old_pattern, $article, $matches2, PREG_SET_ORDER); - switch(true) + switch (true) { case $p1 && $p2: $matches[] = $matches1; $matches[] = $matches2; - if($FB) $FB->log($matches1, 'Aufruf -> jtcsv2html'); - if($FB) $FB->log($matches2, 'Aufruf -> csv2html'); break; case $p1: $matches[] = $matches1; - if($FB) $FB->log($matches1, 'Aufruf -> jtcsv2html'); break; case $p2: $matches[] = $matches2; - if($FB) $FB->log($matches2, 'Aufruf -> csv2html'); break; default: $matches = false; break; } - if($FB) $FB->log($matches, '$matches'); - - if($matches) + if ($matches) { - while($match = each($matches)) + while ($match = each($matches)) { - foreach($match[1] as $key => $value) + foreach ($match[1] as $key => $value) { - if($FB) $FB->log($value, '$value'); - $tplname = null; + $filter = (boolean) $this->filter; + $tplname = 'default'; $_match[$key]['replacement'] = $value[0]; - if(strpos($value[2], ',')) + + if (strpos($value[2], ',')) { - list($filename, $_rest) = explode(',', $value[2], 2); - if(strpos($_rest, ',')) + $parameter = explode(',', $value[2], 3); + $filename = trim(strtolower($parameter[0])); + $count = count($parameter); + + if ($count >= 2) { - list($tplname, $rest) = explode(',', $_rest); + $tplname = trim(strtolower($parameter[1])); } - elseif ($_rest != "") + + if ($count == 3) { - $tplname = $_rest; + if (trim(strtolower($parameter[2])) == 'on') + { + $filter = true; + } + elseif (trim(strtolower($parameter[2])) == 'off') + { + $filter = false; + } } } else { $filename = $value[2]; } - $_match[$key]['fileName'] = trim($filename); - $_match[$key]['tplName'] = ($tplname) ? trim($tplname) : trim($filename); + + $_match[$key]['fileName'] = $filename; + $_match[$key]['tplName'] = $tplname; + $_match[$key]['filter'] = $filter; } $this->_matches[] = $_match; - $return = true; - } - } - - if($FB) { - $FB->log($this->_matches, '$this->_matches'); - $FB->log($return, '$return'); - - if($return) { - $FB->info(__FUNCTION__ . '() => wurde ordnungsgemäß ausgeführt'); - } - else { - $FB->warn('Probleme beim Identifizieren des Pluginaufrufes in der Methode "_patterns"'); + $return = true; } - - $FB->groupEnd(); } return $return; - } protected function _setTplPath() { - $FB = $this->FB; - if($FB) $FB->group(__FUNCTION__.'()', array('Collapsed' => true, 'Color' => '#6699CC')); - - $plgName = $this->_name; - $plgType = $this->_type; + $plgName = $this->_name; + $plgType = $this->_type; $template = JFactory::getApplication()->getTemplate(); - $tpl['tpl'] = 'images/jtcsv2html/'; - $tpl['tplPlg'] = 'templates/'.$template.'/html/plg_'.$plgType.'_'.$plgName.'/'; - $tpl['plg'] = 'plugins/'.$plgType.'/'.$plgName.'/tmpl/'; - $tpl['tplDefault'] = 'images/jtcsv2html/default'; - $tpl['tplPlgDefault'] = 'templates/'.$template.'/html/plg_'.$plgType.'_'.$plgName.'/default'; - $tpl['default'] = 'plugins/'.$plgType.'/'.$plgName.'/tmpl/default'; - - if($FB) $FB->info($tpl, '$theme'); + $tpl['tpl'] = 'images/jtcsv2html/'; + $tpl['tplPlg'] = 'templates/' . $template . '/html/plg_' . $plgType . '_' . $plgName . '/'; + $tpl['plg'] = 'plugins/' . $plgType . '/' . $plgName . '/tmpl/'; + $tpl['tplDefault'] = 'images/jtcsv2html/default'; + $tpl['tplPlgDefault'] = 'templates/' . $template . '/html/plg_' . $plgType . '_' . $plgName . '/default'; + $tpl['default'] = 'plugins/' . $plgType . '/' . $plgName . '/tmpl/default'; - switch(true) + switch (true) { - case file_exists(JPATH_SITE.'/'.$tpl['tpl'].$this->_csv['tplname'].'.php'): - $tplPath = JPATH_SITE.'/'.$tpl['tpl'].$this->_csv['tplname'].'.php'; + case file_exists(JPATH_SITE . '/' . $tpl['tplPlg'] . $this->_csv['tplname'] . '.php'): + $tplPath = JPATH_SITE . '/' . $tpl['tplPlg'] . $this->_csv['tplname'] . '.php'; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplPlg'].$this->_csv['tplname'].'.php'): - $tplPath = JPATH_SITE.'/'.$tpl['tplPlg'].$this->_csv['tplname'].'.php'; + case file_exists(JPATH_SITE . '/' . $tpl['tpl'] . $this->_csv['tplname'] . '.php'): + $tplPath = JPATH_SITE . '/' . $tpl['tpl'] . $this->_csv['tplname'] . '.php'; break; - case file_exists(JPATH_SITE.'/'.$tpl['plg'].$this->_csv['tplname'].'.php'): - $tplPath = JPATH_SITE.'/'.$tpl['plg'].$this->_csv['tplname'].'.php'; + case file_exists(JPATH_SITE . '/' . $tpl['plg'] . $this->_csv['tplname'] . '.php'): + $tplPath = JPATH_SITE . '/' . $tpl['plg'] . $this->_csv['tplname'] . '.php'; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplDefault'].'.php'): - $tplPath = JPATH_SITE.'/'.$tpl['tplDefault'].'.php'; + case file_exists(JPATH_SITE . '/' . $tpl['tplPlgDefault'] . '.php'): + $tplPath = JPATH_SITE . '/' . $tpl['tplPlgDefault'] . '.php'; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplPlgDefault'].'.php'): - $tplPath = JPATH_SITE.'/'.$tpl['tplPlgDefault'].'.php'; + case file_exists(JPATH_SITE . '/' . $tpl['tplDefault'] . '.php'): + $tplPath = JPATH_SITE . '/' . $tpl['tplDefault'] . '.php'; break; default: - $tplPath = JPATH_SITE.'/'.$tpl['default'].'.php'; + $tplPath = JPATH_SITE . '/' . $tpl['default'] . '.php'; break; } - if($FB) $FB->log($tplPath, '$tplPath'); - $cssFile = 'default'; - switch(true) + switch (true) { - case file_exists(JPATH_SITE.'/'.$tpl['tpl'].$this->_csv['filename'].'.css'): - $cssPath = JURI::root().$tpl['tpl'].$this->_csv['filename'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['tplPlg'] . $this->_csv['filename'] . '.css'): + $cssPath = JURI::root() . $tpl['tplPlg'] . $this->_csv['filename'] . '.css'; $cssFile = $this->_csv['filename']; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplPlg'].$this->_csv['filename'].'.css'): - $cssPath = JURI::root().$tpl['tplPlg'].$this->_csv['filename'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['tpl'] . $this->_csv['filename'] . '.css'): + $cssPath = JURI::root() . $tpl['tpl'] . $this->_csv['filename'] . '.css'; $cssFile = $this->_csv['filename']; break; - case file_exists(JPATH_SITE.'/'.$tpl['plg'].$this->_csv['tplname'].'.css'): - $cssPath = JURI::root().$tpl['plg'].$this->_csv['tplname'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['tplPlg'] . $this->_csv['tplname'] . '.css'): + $cssPath = JURI::root() . $tpl['tplPlg'] . $this->_csv['tplname'] . '.css'; + $cssFile = $this->_csv['tplname']; + break; + case file_exists(JPATH_SITE . '/' . $tpl['tpl'] . $this->_csv['tplname'] . '.css'): + $cssPath = JURI::root() . $tpl['tpl'] . $this->_csv['tplname'] . '.css'; $cssFile = $this->_csv['tplname']; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplPlg'].$this->_csv['tplname'].'.css'): - $cssPath = JURI::root().$tpl['tplPlg'].$this->_csv['tplname'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['plg'] . $this->_csv['tplname'] . '.css'): + $cssPath = JURI::root() . $tpl['plg'] . $this->_csv['tplname'] . '.css'; $cssFile = $this->_csv['tplname']; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplDefault'].'.css'): - $cssPath = JURI::root().$tpl['tplDefault'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['tplPlgDefault'] . '.css'): + $cssPath = JURI::root() . $tpl['tplPlgDefault'] . '.css'; break; - case file_exists(JPATH_SITE.'/'.$tpl['tplPlgDefault'].'.css'): - $cssPath = JURI::root().$tpl['tplPlgDefault'].'.css'; + case file_exists(JPATH_SITE . '/' . $tpl['tplDefault'] . '.css'): + $cssPath = JURI::root() . $tpl['tplDefault'] . '.css'; break; default: - $cssPath = JURI::root().$tpl['default'].'.css'; + $cssPath = JURI::root() . $tpl['default'] . '.css'; break; } - $this->_csv['tplPath'] = $tplPath; + $this->_csv['tplPath'] = $tplPath; $this->cssFiles[$cssFile] = $cssPath; - - if($FB) $FB->log($cssPath, '$cssPath'); - if($FB) $FB->log($this->cssFiles, '$this->cssFiles'); - - if($FB) { - $FB->info(__FUNCTION__.'() => wurde ordnungsgemäß ausgeführt'); - $FB->groupEnd(); - } } protected function _dbChkCache() { - $FB = $this->FB; $db = JFactory::getDBO(); $cid = $this->_csv['cid']; + + if (empty($cid)) + { + return; + } + $filename = $this->_csv['filename']; - $tplname = $this->_csv['tplname']; + $tplname = $this->_csv['tplname']; $filetime = $this->_csv['filetime']; $dbAction = null; - $query = $db->getQuery(true); - - if($FB) $FB->group(__FUNCTION__ . '()', array('Collapsed' => false, 'Color' => '#6699CC')); + $query = $db->getQuery(true); $query->clear(); $query->select('filetime, id'); @@ -418,18 +387,16 @@ protected function _dbChkCache() $query->where('tplname=' . $db->quote($tplname)); $db->setQuery($query); - $result = $db->loadAssoc(); + $result = $db->loadAssoc(); $dbFiletime = $result['filetime']; - $id = $result['id']; + $id = $result['id']; - if($FB) $FB->info($dbFiletime, '$dbFiletime'); - if($FB) $FB->info($id, '$id'); - - if($dbFiletime !== NULL) $dbAction = (($filetime - $dbFiletime) <= 0) ? 'load' : 'update'; - - if($FB) $FB->info($dbAction, '$dbAction'); + if ($dbFiletime !== null) + { + $dbAction = (($filetime - $dbFiletime) <= 0) ? 'load' : 'update'; + } - switch(true) + switch (true) { case ($dbAction == 'load'): $return = $this->_dbLoadCache(); @@ -439,13 +406,7 @@ protected function _dbChkCache() break; default: $return = $this->_dbSaveCache(); - } - - - if($FB) { - $FB->log($return, '$return'); - $FB->info(__FUNCTION__ . '() => wurde ordnungsgemäß ausgeführt'); - $FB->groupEnd(); + break; } return $return; @@ -453,16 +414,19 @@ protected function _dbChkCache() protected function _dbLoadCache() { - $FB = $this->FB; $return = false; $cid = $this->_csv['cid']; - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - if($FB) $FB->group(__FUNCTION__ . '()', array('Collapsed' => false, 'Color' => '#6699CC')); + if (empty($cid)) + { + return; + } + + $db = JFactory::getDBO(); + $query = $db->getQuery(true); $filename = $this->_csv['filename']; - $tplname = $this->_csv['tplname']; + $tplname = $this->_csv['tplname']; $query->clear(); $query->select('datas'); @@ -474,24 +438,10 @@ protected function _dbLoadCache() $db->setQuery($query); $result = $db->loadResult(); - if($FB) $FB->log($result, '$result'); - - if($result !== NULL) { + if ($result !== null) + { $this->_html = $result; - $return = TRUE; - } - - if($FB) { - $FB->log($return, '$return'); - - if($return) { - $FB->info(__FUNCTION__.'() => wurde ordnungsgemäß ausgeführt.'); - } - else { - $FB->warn(__FUNCTION__.'() => Daten konnten nicht gelesen werden.'); - } - - $FB->groupEnd(); + $return = true; } return $return; @@ -499,20 +449,22 @@ protected function _dbLoadCache() protected function _dbUpdateCache($id) { - $FB = $this->FB; $return = false; $cid = $this->_csv['cid']; - $filename = $this->_csv['filename']; - $tplname = $this->_csv['tplname']; - $filetime = $this->_csv['filetime']; - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - if($FB) { - $FB->group(__FUNCTION__ . '()', array('Collapsed' => true, 'Color' => '#6699CC')); + if (empty($cid)) + { + return; } - if($this->_readCsv()) { + $filename = $this->_csv['filename']; + $tplname = $this->_csv['tplname']; + $filetime = $this->_csv['filetime']; + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + if ($this->_readCsv()) + { $this->_buildHtml(); $query->update('#__jtcsv2html'); @@ -529,291 +481,195 @@ protected function _dbUpdateCache($id) $return = ($dbFile) ? true : false; } - if($FB) { - $FB->log($return, '$return'); - - if($return) { - $FB->info(__FUNCTION__ . '() => wurde ordnungsgemäß ausgeführt.'); - } - else { - $FB->warn(__FUNCTION__ . '() => Datenbank konnte nicht aktualisiert werden.'); - } - - $FB->groupEnd(); - } - return $return; } - protected function _dbSaveCache() + protected function _readCsv() { - $FB = $this->FB; $return = false; - $cid = $this->_csv['cid']; - $filename = $this->_csv['filename']; - $tplname = $this->_csv['tplname']; - $filetime = $this->_csv['filetime']; - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - - if($FB) $FB->group(__FUNCTION__ . '()', array('Collapsed' => true, 'Color' => '#6699CC')); + $csv = &$this->_csv; + $file = $csv['file']; - if($this->_readCsv()) + if ($this->delimiter == 'null') { - $this->_buildHtml(); - $query->clear(); - $columns = 'cid, filename, tplname, filetime, datas'; - $values = $db->quote($cid) - . ',' . $db->quote($filename) - . ',' . $db->quote($tplname) - . ',' . $db->quote($filetime) - . ',' . $db->quote($this->_html); - - $query->insert($db->quoteName('#__jtcsv2html')); - $query->columns($columns); - $query->values($values); - $db->setQuery($query); - - if($FB) $FB->log((string)$db->getQuery(), '$db->getQuery()'); - - $return = $db->execute(); - } - - if($FB) { - $FB->log($return, '$return'); - - if($return) { - $FB->info(__FUNCTION__ . '() => wurde ordnungsgemäß ausgeführt.'); - } else { - $FB->warn(__FUNCTION__ . '() => fehler beim Speichern in der Datenbank.'); - } - - $FB->groupEnd(); + $this->delimiter = ' '; } - return $return; - } - - protected function _dbClearCache($onSave=false) - { - $FB = $this->FB; - $db = JFactory::getDBO(); - $cid = $this->_csv['cid']; - $filename = $this->_csv['filename']; - $tplname = $this->_csv['tplname']; - $query = $db->getQuery(true); - - if($FB) $FB->group(__FUNCTION__ . '()', array('Collapsed' => false, 'Color' => '#6699CC')); - - $query->clear(); - $query->delete('#__jtcsv2html'); - if(!$onSave) + if ($this->delimiter == '\t') { - $query->where('filename=' . $db->quote($filename)); -// $query->where('tplname=' . $db->quote($tplname)); - } - else - { - $query->where('cid=' . $db->quote($cid)); - } - - $db->setQuery($query); - $return = $db->execute(); - - if($FB) $FB->log((string)$db->getQuery(), '$query'); - - - $query->clear(); - $db->setQuery('OPTIMIZE TABLE #__jtcsv2html_data'); - $optimize = $db->execute(); - - if($FB) { - $FB->info($return, 'Datenbank bereinigt'); - $FB->info($optimize, 'Datenbank optimiert'); - $FB->groupEnd(); - } - - return $return; - } - - protected function _loadCSS() - { - $FB = $this->FB; - $cssFiles = $this->cssFiles; - if($FB) $FB->group(__FUNCTION__.'()', array('Collapsed' => true, 'Color' => '#6699CC')); - - foreach($cssFiles as $cssFile) { - $document = JFactory::getDocument(); - $document->addStyleSheet($cssFile, 'text/css'); - if($FB) $FB->log($cssFile, '$cssFile'); - } - - if($FB) { - $FB->info(__FUNCTION__.'() => wurde ordnungsgemäß ausgeführt'); - $FB->groupEnd(); - } - } - - protected function _readCsv() - { - $FB = $this->FB; - $return = false; - $csv = &$this->_csv; - $file = $csv['file']; - if($this->delimiter == 'null') $this->delimiter = ' '; - if($this->delimiter == '\t') $this->delimiter = "\t"; - - if($FB) { - $FB->group(__FUNCTION__.'()', array('Collapsed' => true, 'Color' => '#6699CC')); - $FB->info($this->delimiter, '$this->delimiter'); - $FB->info($this->enclosure, '$this->enclosure'); + $this->delimiter = "\t"; } if (version_compare(phpversion(), '5.3', '<')) { - if($FB) $FB->info('CSV-Daten aufbereiten in PHP-Version < 5.3'); - - if(file_exists($file) || is_readable($file)) + if (file_exists($file) || is_readable($file)) { $data = array(); - if(($handle = fopen($file, 'r')) !== false) + if (($handle = fopen($file, 'r')) !== false) { $filesize = filesize($file); - while(($row = fgetcsv($handle, $filesize, $this->delimiter, $this->enclosure)) !== false) + while (($row = fgetcsv($handle, $filesize, $this->delimiter, $this->enclosure)) !== false) { array_walk($row, - function (&$entry) { - $enc = mb_detect_encoding($entry, "UTF-8,ISO-8859-1,WINDOWS-1252"); - $entry = ($enc == 'UTF-8') ? trim($entry) : trim(iconv($enc, 'UTF-8', $entry)); - } + function (&$entry) + { + $enc = mb_detect_encoding($entry, "UTF-8,ISO-8859-1,WINDOWS-1252"); + $entry = ($enc == 'UTF-8') ? trim($entry) : trim(iconv($enc, 'UTF-8', $entry)); + } ); $setDatas = false; - foreach($row as $value) { - if($value != '') $setDatas = true; + foreach ($row as $value) + { + if ($value != '') $setDatas = true; } - if($setDatas) $data[] = $row; + if ($setDatas) $data[] = $row; } //endwhile fclose($handle); $csv['datas'] = $data; - $return = true; - - if($FB) $FB->log($csv['datas'], '$csv["datas"]'); + $return = true; } //endfopen } //end file_exist } else { - if($FB) $FB->info('CSV-Daten aufbereiten in PHP-Version >= 5.3'); - - if(file_exists($file) || is_readable($file)) + if (file_exists($file) || is_readable($file)) { $csvArray = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - if($FB) $FB->log($csvArray, '$csvArray'); - - foreach($csvArray as &$row) + foreach ($csvArray as &$row) { $row = str_getcsv($row, $this->delimiter, "$this->enclosure"); array_walk($row, - function (&$entry) { - $enc = mb_detect_encoding($entry, "UTF-8,ISO-8859-1,WINDOWS-1252"); - $entry = ($enc == 'UTF-8') ? trim($entry) : trim(iconv($enc, 'UTF-8', $entry)); - } + function (&$entry) + { + $enc = mb_detect_encoding($entry, "UTF-8,ISO-8859-1,WINDOWS-1252"); + $entry = ($enc == 'UTF-8') ? trim($entry) : trim(iconv($enc, 'UTF-8', $entry)); + } ); } //endforeach $csv['datas'] = $csvArray; - $return = true; - - if($FB) $FB->log($csv['datas'], '$csv["datas"]'); + $return = true; } //end file_exist } //endif phpversion - if($FB) { - $FB->log($return, '$return'); - - if($return) { - $FB->info(__FUNCTION__ . '() => wurde ordnungsgemäß ausgeführt.'); - } - else { - $FB->warn(__FUNCTION__ . '() => Datei konnte nicht gefunden werden, oder war nicht lesbar.'); - } - - $FB->groupEnd(); - } - return $return; } protected function _buildHtml() { - $FB = $this->FB; - if($FB) $FB->group(__FUNCTION__.'()', array('Collapsed' => true, 'Color' => '#6699CC')); - ob_start(); require $this->_csv['tplPath']; - $output = ob_get_clean(); + $this->_html = ob_get_clean(); + } - if($FB) $FB->log($output, '$output'); + protected function _dbSaveCache() + { + $return = false; + $cid = $this->_csv['cid']; - if(!class_exists('Minify_HTML')) { - require_once 'assets/minifyHTML.inc'; + if (empty($cid)) + { + return; } - $this->_html = Minify_HTML::minify($output); - if($FB) { - $FB->info(__FUNCTION__.'() => wurde ordnungsgemäß ausgeführt'); - $FB->groupEnd(); + $filename = $this->_csv['filename']; + $tplname = $this->_csv['tplname']; + $filetime = $this->_csv['filetime']; + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + if ($this->_readCsv()) + { + $this->_buildHtml(); + $query->clear(); + $columns = 'cid, filename, tplname, filetime, datas'; + $values = $db->quote($cid) + . ',' . $db->quote($filename) + . ',' . $db->quote($tplname) + . ',' . $db->quote($filetime) + . ',' . $db->quote($this->_html); + + $query->insert($db->quoteName('#__jtcsv2html')); + $query->columns($columns); + $query->values($values); + $db->setQuery($query); + + $return = $db->execute(); } + + return $return; } - protected function _dbClearAll() + protected function _dbClearCache($onSave = false) { - $FB = $this->FB; - $db = JFactory::getDBO(); + $db = JFactory::getDBO(); + $cid = $this->_csv['cid']; + $filename = $this->_csv['filename']; +// $tplname = $this->_csv['tplname']; $query = $db->getQuery(true); - // Zuruecksetzen des Parameters - $this->params->set('clearDB', 0); - $params = $this->params->toString(); - $plgName = $this->_name; + $query->clear(); + $query->delete('#__jtcsv2html'); - if($FB) { - $FB->log($plgName, '$plgName'); - $FB->log($params, '$params'); + if (!$onSave) + { + $query->where('filename=' . $db->quote($filename)); +// $query->where('tplname=' . $db->quote($tplname)); + } + else + { + $query->where('cid=' . $db->quote($cid)); } - - $query->clear(); - $query->update('#__extensions'); - $query->set('params=' . $db->quote($params)); - $query->where('name=' . $db->quote('PLG_CONTENT_JTCSV2HTML')); $db->setQuery($query); - $q1 = $db->execute(); + $return = $db->execute(); - // Loeschen aller Daten aus der Datenbank $query->clear(); - $db->setQuery('TRUNCATE #__jtcsv2html'); - $q2 = $db->execute(); + $db->setQuery('OPTIMIZE TABLE #__jtcsv2html_data'); + $db->execute(); - $query->clear(); - $db->setQuery('OPTIMIZE TABLE #__jtcsv2html'); - if($FB) $FB->info((string)$db->getQuery(), '$db->getQuery()'); - $q3 = $db->execute(); + return $return; + } + + protected function _loadCSS() + { + $cssFiles = $this->cssFiles; + + foreach ($cssFiles as $cssFile) + { + $document = JFactory::getDocument(); + $document->addStyleSheet($cssFile, 'text/css'); + } + } + + public function onContentAfterSave($context, $article, $isNew) + { + $this->_onContentEvent($context, $article, $isNew); + } - if($FB) { - $FB->log($q1, 'Plugin-Einstellung zurückgesetzt'); - $FB->log($q2, 'Datenbank bereinigt'); - $FB->log($q3, 'Datenbank optimiert'); + protected function _onContentEvent($context, $article, $isNew = false) + { + if (version_compare(phpversion(), '5.3', '<') || $isNew) + { + return; } + + $this->_csv['cid'] = $article->id; + $this->_dbClearCache(true); + } + + public function onContentBeforeDelete($context, $data) + { + $this->_onContentEvent($context, $data); } } diff --git a/jtcsv2html.scriptfile.php b/jtcsv2html.scriptfile.php index 3d6e7e7..a9e764e 100644 --- a/jtcsv2html.scriptfile.php +++ b/jtcsv2html.scriptfile.php @@ -1,24 +1,20 @@ + * 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 3 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, see . */ defined('_JEXEC') or die('Restricted access'); diff --git a/jtcsv2html.xml b/jtcsv2html.xml index 8d139b9..500f995 100644 --- a/jtcsv2html.xml +++ b/jtcsv2html.xml @@ -1,26 +1,37 @@ - + PLG_CONTENT_JTCSV2HTML - 2014 - 2.5.4 + 2017-02-03 Guido De Gobbis - (C) JoomTools.de. All rights reserved. - GNU General Public License version 3 or later. - guido.de.gobbis@joomtools.de + support@joomtools.de + www.joomtools.de + Copyright (C) 2016 JoomTools.de. All rights reserved. + GPL v3 + 3.0.0.2-dev PLG_CONTENT_JTCSV2HTML_XML_DESCRIPTION - jtcsv2html.php - jtcsv2html.scriptfile.php - language assets - sql + testfile tmpl + sql + jtcsv2html.php + jtcsv2html.scriptfile.php + LICENSE + README.md + jtcsv2html.xml + + de-DE/de-DE.plg_content_jtcsv2html.ini + de-DE/de-DE.plg_content_jtcsv2html.sys.ini + en-GB/en-GB.plg_content_jtcsv2html.ini + en-GB/en-GB.plg_content_jtcsv2html.sys.ini + + - sql/install.mysql.utf8.sql + sql/install.mysql.utf8mb4.sql @@ -41,7 +52,7 @@ size="1" default="," label="PLG_CONTENT_JTCSV2HTML_DELIMITER" - description="PLG_CONTENT_JTCSV2HTML_DELIMITER_DESC" > + description="PLG_CONTENT_JTCSV2HTML_DELIMITER_DESC"> @@ -52,31 +63,31 @@ size="1" default='"' label="PLG_CONTENT_JTCSV2HTML_ENCLOSURE" - description="PLG_CONTENT_JTCSV2HTML_ENCLOSURE_DESC" /> - + + label="PLG_CONTENT_JTCSV2HTML_FILTER" + description="PLG_CONTENT_JTCSV2HTML_FILTER_DESC"> - + label="PLG_CONTENT_JTCSV2HTML_CACHE" + description="PLG_CONTENT_JTCSV2HTML_CACHE_DESC"> - + label="PLG_CONTENT_JTCSV2HTML_CHKDB" + description="PLG_CONTENT_JTCSV2HTML_CHKDB_DESC"> @@ -86,7 +97,7 @@ - http://updateserver.joomtools.de/extensions.xml + https://raw.githubusercontent.com/JoomTools/updateserver/master/plg_content_jtcsv2html.xml diff --git a/language/de-DE/de-DE.plg_content_jtcsv2html.ini b/language/de-DE/de-DE.plg_content_jtcsv2html.ini index c2c50da..0aef320 100644 --- a/language/de-DE/de-DE.plg_content_jtcsv2html.ini +++ b/language/de-DE/de-DE.plg_content_jtcsv2html.ini @@ -1,9 +1,4 @@ -; @Copyright JoomTools -; @package JT - Csv2Html - Plugin for Joomla! 2.5.x - 3.x -; @author Guido De Gobbis -; @link http://www.joomtools.de -; @license GNU/GPL -; Note : All ini files need to be saved as UTF-8 - No BOM +; @author Guido De Gobbis PLG_CONTENT_JTCSV2HTML="Inhalt - JT - Csv2Html" PLG_CONTENT_JTCSV2HTML_XML_DESCRIPTION="JT - Csv2Html ist ein Plugin, um CSV-Dateien in ein HTML-Tabellenformat umzusetzen.
Das Verzeichnis, in welches nach den Dateien gesucht wird, ist JOOMLA_ROOT/images/jtcsv2html/." @@ -17,6 +12,8 @@ PLG_CONTENT_JTCSV2HTML_DELIMITER_SEMICOLON="Semicolon (;)" PLG_CONTENT_JTCSV2HTML_DELIMITER_KOMMATA="Kommata (,)" PLG_CONTENT_JTCSV2HTML_ENCLOSURE="Textmarkierungszeichen" PLG_CONTENT_JTCSV2HTML_ENCLOSURE_DESC="Bestimmt das Textmarkierungszeichen (nur ein Zeichen). Standart ist das Anführungszeichen ( "_QQ_" )." +PLG_CONTENT_JTCSV2HTML_FILTER="Ausgabefilter" +PLG_CONTENT_JTCSV2HTML_FILTER_DESC="Erweiter die Ausgabe mit einem Filterfeld, welches die Ausgabe, zeilenweise auf das Suchwort begrenzt." PLG_CONTENT_JTCSV2HTML_CACHE="Datenbank-Cache aktivieren" PLG_CONTENT_JTCSV2HTML_CACHE_DESC="Speichert die Ausgabe in der Datenbank ab. Wird benötigt, damit das eigene "_QQ_"Suchen - Plugin"_QQ_" darauf zugreifen kann." PLG_CONTENT_JTCSV2HTML_CHKDB="Datenbank-Cache bereinigen" diff --git a/language/de-DE/de-DE.plg_content_jtcsv2html.sys.ini b/language/de-DE/de-DE.plg_content_jtcsv2html.sys.ini index f5f8d07..e76d69b 100644 --- a/language/de-DE/de-DE.plg_content_jtcsv2html.sys.ini +++ b/language/de-DE/de-DE.plg_content_jtcsv2html.sys.ini @@ -1,9 +1,4 @@ -; @Copyright JoomTools -; @package JT - Csv2Html - Plugin for Joomla! 2.5.x - 3.x -; @author Guido De Gobbis -; @link http://www.joomtools.de -; @license GNU/GPL -; Note : All ini files need to be saved as UTF-8 - No BOM +; @author Guido De Gobbis PLG_CONTENT_JTCSV2HTML="Inhalt - JT - Csv2Html" PLG_CONTENT_JTCSV2HTML_XML_DESCRIPTION="JT - Csv2Html ist ein Plugin, um CSV-Dateien in ein HTML-Tabellenformat umzusetzen.
Das Verzeichnis, in welches nach den Dateien gesucht wird, ist JOOMLA_ROOT/images/jtcsv2html/." \ No newline at end of file diff --git a/language/de-DE/index.html b/language/de-DE/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/language/de-DE/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/language/en-GB/en-GB.plg_content_jtcsv2html.ini b/language/en-GB/en-GB.plg_content_jtcsv2html.ini new file mode 100644 index 0000000..50490ca --- /dev/null +++ b/language/en-GB/en-GB.plg_content_jtcsv2html.ini @@ -0,0 +1,25 @@ +; @author Guido De Gobbis + +PLG_CONTENT_JTCSV2HTML="Content - JT - Csv2Html" +PLG_CONTENT_JTCSV2HTML_XML_DESCRIPTION="JT - Csv2Html ist ein Plugin, um CSV-Dateien in ein HTML-Tabellenformat umzusetzen.
Das Verzeichnis, in welches nach den Dateien gesucht wird, ist JOOMLA_ROOT/images/jtcsv2html/." +PLG_CONTENT_JTCSV2HTML_CSVPATH="CSV-Verzeichnispfad" +PLG_CONTENT_JTCSV2HTML_CSVPATH_DESC="Pfad zum Verzeichnis in dem die CSV-Dateien abgelegt werden. Wir empfehlen ein Verzeichnis innerhalb von 'images', z.B. '/images/jtcsv2html'." +PLG_CONTENT_JTCSV2HTML_DELIMITER="Trennzeichen" +PLG_CONTENT_JTCSV2HTML_DELIMITER_DESC="Bestimmt das Feldtrennzeichen, durch welches die Werte jeder Zeile getrennt werden (nur ein Zeichen). Standart ist das Semikolon ( ; )." +PLG_CONTENT_JTCSV2HTML_DELIMITER_SPACE="Leerzeichen" +PLG_CONTENT_JTCSV2HTML_DELIMITER_TAB="Tabulator" +PLG_CONTENT_JTCSV2HTML_DELIMITER_SEMICOLON="Semicolon (;)" +PLG_CONTENT_JTCSV2HTML_DELIMITER_KOMMATA="Kommata (,)" +PLG_CONTENT_JTCSV2HTML_ENCLOSURE="Textmarkierungszeichen" +PLG_CONTENT_JTCSV2HTML_ENCLOSURE_DESC="Bestimmt das Textmarkierungszeichen (nur ein Zeichen). Standart ist das Anführungszeichen ( "_QQ_" )." +PLG_CONTENT_JTCSV2HTML_FILTER="Ausgabefilter" +PLG_CONTENT_JTCSV2HTML_FILTER_DESC="Erweiter die Ausgabe mit einem Filterfeld, welches die Ausgabe, zeilenweise auf das Suchwort begrenzt." +PLG_CONTENT_JTCSV2HTML_CACHE="Datenbank-Cache aktivieren" +PLG_CONTENT_JTCSV2HTML_CACHE_DESC="Speichert die Ausgabe in der Datenbank ab. Wird benötigt, damit das eigene "_QQ_"Suchen - Plugin"_QQ_" darauf zugreifen kann." +PLG_CONTENT_JTCSV2HTML_CHKDB="Datenbank-Cache bereinigen" +PLG_CONTENT_JTCSV2HTML_CHKDB_DESC="Wird hier Ja gewählt, so wird der Datenbank-Cache komplett geleert. Dieser Wert stellt sich automatisch nach dem "_QQ_"Speichern & Schließen"_QQ_" wieder auf "_QQ_"Nein"_QQ_" zurück." +PLG_CONTENT_JTCSV2HTML_DEBUG="Debug" +PLG_CONTENT_JTCSV2HTML_DEBUGDESC="Debug-Ausgabe. Hierfür werden JFirePHP und die zugehörigen Erweiterungen für den Browser benötigt." +PLG_CONTENT_JTCSV2HTML_CSVEMPTY="Derzeit keine Inhalte vorhanden." +PLG_CONTENT_JTCSV2HTML_PHP_VERSION="Die Mindestanforderung für JT - Csv2Html ist PHP 5 >= 5.3.0!" +PLG_CONTENT_JTCSV2HTML_NOCSV="Konnte die Datei '%s' nicht finden!" \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_content_jtcsv2html.sys.ini b/language/en-GB/en-GB.plg_content_jtcsv2html.sys.ini new file mode 100644 index 0000000..812d987 --- /dev/null +++ b/language/en-GB/en-GB.plg_content_jtcsv2html.sys.ini @@ -0,0 +1,4 @@ +; @author Guido De Gobbis + +PLG_CONTENT_JTCSV2HTML="Content - JT - Csv2Html" +PLG_CONTENT_JTCSV2HTML_XML_DESCRIPTION="JT - Csv2Html ist ein Plugin, um CSV-Dateien in ein HTML-Tabellenformat umzusetzen.
Das Verzeichnis, in welches nach den Dateien gesucht wird, ist JOOMLA_ROOT/images/jtcsv2html/." \ No newline at end of file diff --git a/language/index.html b/language/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/language/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sql/index.html b/sql/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/sql/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sql/install.mysql.utf8.sql b/sql/install.mysql.utf8.sql index 4552f21..f21eb71 100644 --- a/sql/install.mysql.utf8.sql +++ b/sql/install.mysql.utf8.sql @@ -10,4 +10,4 @@ CREATE TABLE IF NOT EXISTS `#__jtcsv2html` ( `filetime` varchar(255) NOT NULL COMMENT 'Dateidatum im UNIX-Format', `datas` longtext NOT NULL COMMENT 'Ausgabe der CSV-Datei als Tabelle (Template-HTML)', PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tabelle das Plugins jtcsv2html' AUTO_INCREMENT=0; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tabelle das Plugins jtcsv2html' AUTO_INCREMENT=0; diff --git a/sql/install.mysql.utf8mb4.sql b/sql/install.mysql.utf8mb4.sql new file mode 100644 index 0000000..6b1923c --- /dev/null +++ b/sql/install.mysql.utf8mb4.sql @@ -0,0 +1,13 @@ +-- +-- Tabellenstruktur für Tabelle `#__csv2html` +-- + +CREATE TABLE IF NOT EXISTS `#__jtcsv2html` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `cid` int(10) NOT NULL COMMENT 'Content-ID', + `filename` varchar(255) NOT NULL COMMENT 'Dateiname ohne Endung', + `tplname` varchar(255) NOT NULL COMMENT 'Templatename ohne Endung', + `filetime` varchar(255) NOT NULL COMMENT 'Dateidatum im UNIX-Format', + `datas` longtext NOT NULL COMMENT 'Ausgabe der CSV-Datei als Tabelle (Template-HTML)', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci COMMENT='Tabelle das Plugins jtcsv2html' AUTO_INCREMENT=0; diff --git a/sql/uninstall.mysql.utf8.sql b/sql/uninstall.mysql.utf8.sql index 4ca46cd..4014066 100644 --- a/sql/uninstall.mysql.utf8.sql +++ b/sql/uninstall.mysql.utf8.sql @@ -2,4 +2,4 @@ -- Lösche Tabelle `#__jtcsv2html` -- -DROP TABLE `#__jtcsv2html`; +DROP TABLE IF EXISTS `#__jtcsv2html`; diff --git a/tmpl/default.css b/tmpl/default.css index b1214fb..535bf12 100644 --- a/tmpl/default.css +++ b/tmpl/default.css @@ -17,28 +17,32 @@ * GNU General Public License for more details. */ +.jtcsv2html_wrapper { + margin: 2em 0; +} -.jtcsv2html_wrapper table { +.jtcsv2html_wrapper table.default { background-color: #ebf2fa; border-bottom: 2px solid #f3d9c2; - width: 100%; } -.jtcsv2html_wrapper thead th.csvcol1 { +.jtcsv2html_wrapper table.default th, +.jtcsv2html_wrapper table.default th a { text-align: left; -} - -.jtcsv2html_wrapper tbody th, -.jtcsv2html_wrapper thead th, -.jtcsv2html_wrapper tbody th a, -.jtcsv2html_wrapper thead th a { background-color: #f3d9c2; color: #6c6c6c; } -.jtcsv2html_wrapper tbody tr:hover th[scope="row"], -.jtcsv2html_wrapper tbody tr:hover { background: #6699cc; } -.jtcsv2html_wrapper tbody tr:hover td { background: #6699cc; color: #ffffff; } +.jtcsv2html_wrapper table.default tbody tr:hover th[scope="row"], +.jtcsv2html_wrapper table.default tbody tr:hover { + background: #6699cc; +} -.jtcsv2html_wrapper tbody td { border-bottom: 1px solid #ffffff; } +.jtcsv2html_wrapper table.default tbody tr:hover td { + color: #ffffff; +} + +.jtcsv2html_wrapper table.default tbody td { + border-bottom: 1px solid #ffffff; +} diff --git a/tmpl/default.php b/tmpl/default.php index a6e1706..32c3f97 100644 --- a/tmpl/default.php +++ b/tmpl/default.php @@ -1,11 +1,11 @@ + * @license GNU/GPL * 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 3 of the License, or @@ -21,46 +21,46 @@ // no direct access defined('_JEXEC') or die; ?> -
- - - - _csv['datas'][0] as $hKey => $headline) : ?> - - - - - - _csv['datas']) === FALSE) { - $this->_csv['datas'][0] = array(FALSE); - } +
+ + + _csv['datas'][0] as $hKey => $headline) : ?> + + + + + + _csv['datas']) === false) + { + $this->_csv['datas'][0] = array(false); + } - // erstellen der Datenzeilen - foreach ($this->_csv['datas'] as $dKey => $datas) : - if ($dKey == 0) { - $datasCount = count($datas); - continue; - } - ?> - - - - - - - - - -
- -
-
+ // erstellen der Datenzeilen + foreach ($this->_csv['datas'] as $dKey => $datas) : + if ($dKey == 0) + { + $datasCount = count($datas); + continue; + } + ?> + + + + + + + + + + + + diff --git a/tmpl/responsive.css b/tmpl/responsive.css index e24e73a..199e048 100644 --- a/tmpl/responsive.css +++ b/tmpl/responsive.css @@ -17,65 +17,88 @@ * GNU General Public License for more details. */ - -.jtcsv2html_wrapper .responsive-table { - margin: 1em 0; - min-width: 300px; +.jtcsv2html_wrapper { + margin: 2em 0; } -.jtcsv2html_wrapper .responsive-table tr { - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; +.jtcsv2html_wrapper table.responsive tr { + border-top: 1px solid #46627f; + border-bottom: 1px solid #46627f; } -.jtcsv2html_wrapper .responsive-table th { - display: none; + +.jtcsv2html_wrapper table.responsive tr:first-child, +.jtcsv2html_wrapper table.responsive tbody tr:last-child { + border: none; } -.jtcsv2html_wrapper .responsive-table td { - display: block; + +.jtcsv2html_wrapper table.responsive th { + display: none; } -.jtcsv2html_wrapper .responsive-table td:first-child { - padding-top: .5em; + +.jtcsv2html_wrapper table.responsive td { + display: block; } -.jtcsv2html_wrapper .responsive-table td:last-child { - padding-bottom: .5em; + +.jtcsv2html_wrapper table.responsive td:first-child { + padding-top: .5em; } -.jtcsv2html_wrapper .responsive-table td:before { - content: attr(data-th) ": "; - font-weight: bold; - width: 6.5em; - display: inline-block; + +.jtcsv2html_wrapper table.responsive td:last-child { + padding-bottom: .5em; } -.jtcsv2html_wrapper .responsive-table th, .jtcsv2html_wrapper .responsive-table td { - text-align: left; + +.jtcsv2html_wrapper table.responsive td:before { + content: attr(data-th) ": "; + font-weight: bold; + width: 6.5em; + display: inline-block; } -.jtcsv2html_wrapper .responsive-table { - background: #34495E; - color: #fff; - border-radius: .4em; - overflow: hidden; + +.jtcsv2html_wrapper table.responsive th, +.jtcsv2html_wrapper table.responsive td { + text-align: left; } -.jtcsv2html_wrapper .responsive-table tr { - border-color: #46627f; + +.jtcsv2html_wrapper table.responsive { + background: #34495E; + color: #fff; + border-radius: .4em; + overflow: hidden; } -.jtcsv2html_wrapper .responsive-table th, .jtcsv2html_wrapper .responsive-table td { - margin: .5em 1em; + + +.jtcsv2html_wrapper table.responsive th, +.jtcsv2html_wrapper table.responsive td { + margin: .5em 1em; } -.jtcsv2html_wrapper .responsive-table th, .jtcsv2html_wrapper .responsive-table td:before { - color: #dd5; + +.jtcsv2html_wrapper table.responsive th, +.jtcsv2html_wrapper table.responsive td:before { + color: #dd5; } @media (min-width: 480px) { - .jtcsv2html_wrapper .responsive-table td:before { - display: none; - } - .jtcsv2html_wrapper .responsive-table th, .jtcsv2html_wrapper .responsive-table td { - display: table-cell; - /*padding: .25em .5em;*/ - padding: 1em !important; - } - .jtcsv2html_wrapper .responsive-table th:first-child, .jtcsv2html_wrapper .responsive-table td:first-child { - padding-left: 0; - } - .jtcsv2html_wrapper .responsive-table th:last-child, .jtcsv2html_wrapper .responsive-table td:last-child { - padding-right: 0; - } + .jtcsv2html_wrapper table.responsive td:before { + display: none; + } + + .jtcsv2html_wrapper table.responsive tbody tr:first-child { + border-top: 1px solid #46627f; + } + + .jtcsv2html_wrapper table.responsive th, + .jtcsv2html_wrapper table.responsive td { + display: table-cell; + /*padding: .25em .5em;*/ + padding: 1em !important; + } + + .jtcsv2html_wrapper table.responsive th:first-child, + .jtcsv2html_wrapper table.responsive td:first-child { + padding-left: 0; + } + + .jtcsv2html_wrapper table.responsive th:last-child, + .jtcsv2html_wrapper table.responsive td:last-child { + padding-right: 0; + } } diff --git a/tmpl/responsive.php b/tmpl/responsive.php index 41ba62f..021132a 100644 --- a/tmpl/responsive.php +++ b/tmpl/responsive.php @@ -1,11 +1,11 @@ + * @license GNU/GPL * 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 3 of the License, or @@ -21,48 +21,49 @@ // no direct access defined('_JEXEC') or die; ?> -
- - - - _csv['datas'][0] as $hKey => $headline) : - $data_th[$hKey]= $headline; - ?> - - - - - - _csv['datas']) === FALSE) { - $this->_csv['datas'][0] = array(FALSE); - } +
+ + + _csv['datas'][0] as $hKey => $headline) : + $data_th[$hKey] = $headline; + ?> + + + + + + _csv['datas']) === false) + { + $this->_csv['datas'][0] = array(false); + } - // erstellen der Datenzeilen - foreach ($this->_csv['datas'] as $dKey => $datas) : - if ($dKey == 0) { - $datasCount = count($datas); - continue; - } - ?> - - - - - - - - - -
- -
-
+ // erstellen der Datenzeilen + foreach ($this->_csv['datas'] as $dKey => $datas) : + if ($dKey == 0) + { + $datasCount = count($datas); + continue; + } + ?> + + + + + + + + + + + +