Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Removed the dependence on Regular Labs Sourcerer.
  • Loading branch information
bascherz authored Oct 30, 2022
1 parent 0157b3c commit 49fe68b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
4 changes: 2 additions & 2 deletions j4/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<client>site</client>
<infourl title="Table Dump Module">https://github.com/bascherz/Table-Dump-Module/releases/tag/2.0</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/bascherz/Table-Dump-Module/releases/download/2.0/mod_tabledump_2.0.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/bascherz/Table-Dump-Module/releases/download/j4/mod_tabledump_2.0.zip</downloadurl>
</downloads>
<targetplatform name="joomla" version="4.[0123456789]" />
</update>
</updates>
</updates>
5 changes: 3 additions & 2 deletions j4/mod_tabledump.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<extension type="module" version="4.0" client="site" method="upgrade">
<name>Table Dump</name>
<author>Bruce Scherzinger</author>
<creationDate>2022-10-23</creationDate>
<version>2.0</version>
<description>Extracts rows of data from the database and replaces field data in an HTML table structure. A special tag {tablerows} can be placed in either the header or footer and is replaced by the total rows returned by the query.</description>
<namespace path="src">Joomla\Module\TableDump</namespace>
Expand Down Expand Up @@ -136,6 +137,6 @@
<uninstall>
</uninstall>
<updateservers>
<server type="extension" name="Table Dump Module Update Site">https://raw.githubusercontent.com/bascherz/Table-Dump-Module/master/j4/manifest.xml</server>
<server type="extension" name="Table Dump Module Update Site">https://raw.githubusercontent.com/bascherz/Table-Dump-Module/master/manifest.xml</server>
</updateservers>
</extension>
</extension>
53 changes: 47 additions & 6 deletions j4/src/Helper/TableDumpHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,49 @@
*/
namespace Joomla\Module\TableDump\Site\Helper;

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\Registry\Registry;

class TableDumpHelper
{
/*
* $html = string containing PHP code between two delimiters. code is expected to produce output.
* $start = the starting delimiter
* $stop = the ending delimiter
* $count = code strings to replace (0=all)
* returns $html with strings generated by
*/
public static function executePHP($html,$start="{php}",$stop="{/php}",$count=0)
{
// Repeat the following until no more $start delimiters are found.
$done = false;
while (!$done)
{
$locStart = strpos($html,$start);
if ($locStart === false)
{
// starting delimiter not found. we are done.
$done = true;
}
else
{
// found a starting delimiter. now look for the ending one.
$locStop = strpos($html,$stop);
if ($locStop === false || $locStop < $locStart)
{
// ending delimiter not found. we are done. should report an error, but something else will.
$done = true;
}
else
{
$phpstring = substr($html,$locStart,($locStop+strlen($stop))-$locStart);
$myPHP = str_replace(array($start,$stop),"",$phpstring);
$output = eval($myPHP);
$html = str_replace($phpstring,$output,$html);
}
}
}
return $html;
}
/**
* Retrieves one row of record column data and outputs a table with the column data filled into the user template
*
Expand All @@ -35,7 +69,7 @@ public static function getTableDump($params)
$db = Factory::getDbo();

// Retrieve the various parameters
$fieldnames = explode(",",preg_replace("/\s+/",",",$params->get('fieldnames')));
$fieldnames = explode(",",preg_replace("/\,+/",",",preg_replace("/\s+/",",",$params->get('fieldnames'))));
$tablequery = $params->get('tablequery');
$errormessage = $params->get('errormessage');
$tableprefix = $params->get('tableprefix','<table>');
Expand All @@ -54,6 +88,7 @@ public static function getTableDump($params)
try
{
$records = $db->loadObjectList();
$tablehtml = "";
}
catch (Exception $e)
{
Expand Down Expand Up @@ -99,6 +134,12 @@ public static function getTableDump($params)
$tablehtml .= $thisgrouphead.$thisrow;
}
}
// Execute any embedded PHP code.
if ($params->get('prepare_content'))
{
$tablehtml = TableDumpHelper::executePHP($tablehtml);
}

// Replace the special tags.
if (!$groupby)
$tableprefix = html_entity_decode(str_replace("{tablerows}",count($records),$tableprefix),ENT_QUOTES);
Expand Down

0 comments on commit 49fe68b

Please sign in to comment.