Skip to content

Commit

Permalink
Update the code
Browse files Browse the repository at this point in the history
- Remove old contao code
- Make the code sweet and nice
  • Loading branch information
stefanheimes committed Mar 18, 2016
1 parent 664a66b commit add57f9
Showing 1 changed file with 24 additions and 39 deletions.
63 changes: 24 additions & 39 deletions system/modules/x-editors/mawExtendedInsertTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright MEN AT WORK 2014
* @package extendedEditors
* @license GNU/LGPL
* @license GNU/LGPL
* @filesource
*/

Expand All @@ -15,92 +15,77 @@
* @copyright MEN AT WORK 2014
* @package Frontend
*/
class mawExtendedInsertTags extends Controller
class mawExtendedInsertTags
{

public function mawReplaceInsertTags($strTag)
{
$arrSplit = explode('::', $strTag);

// Replace tag
switch (strtolower($arrSplit[0]))
{
switch (strtolower($arrSplit[0])) {
case 'http':
case 'cache_http':
case 'https':
case 'cache_https':
if (isset($arrSplit[1]))
{
if (isset($arrSplit[1])) {
$strReturn = '<a ';
$strReturn .= ($arrSplit[2] == 'blank') ? "onclick='window.open(this.href); return false;' " : "";
$strReturn .= 'href="' . (str_replace('cache_', '', $arrSplit[0])) . '://' . $arrSplit[1] . '">';
if (isset($arrSplit[3]))
{
if (isset($arrSplit[3])) {
$strReturn .= $arrSplit[3];
}
elseif (isset($arrSplit[2]))
{
} elseif (isset($arrSplit[2])) {
$strReturn .= ($arrSplit[2] == 'blank') ? $arrSplit[1] : $arrSplit[2];
}
else
{
} else {
$strReturn .= $arrSplit[1];
}
$strReturn .= '</a>';

return $strReturn;
}
else
{
} else {
return false;
}
break;

case 'anchor':
return '<a href="'.$this->Environment->request.'#'.$arrSplit[1].'">'.$arrSplit[2].'</a>';
break;
return '<a href="' . \Environment::get('request') . '#' . $arrSplit[1] . '">' . $arrSplit[2] . '</a>';

case 'anchor_open':
return '<a href="'.$this->Environment->request.'#'.$arrSplit[1].'">';
break;
return '<a href="' . \Environment::get('request') . '#' . $arrSplit[1] . '">';

case 'anchor_close':
return '</a>';
break;

case 'comments':
return $this->countComments($arrSplit[1], $arrSplit[2]);
break;

case 'download':
$objFile = \FilesModel::findByUuid($arrSplit[1]);

return '<a title="' . $arrSplit[2] . '" href="' . $objFile->path . '" >' . $arrSplit[2] . '</a>';
break;
}


return false;
}

protected function countComments($strParentTable, $intParentId)
{
if (empty($strParentTable) || empty($intParentId))
{
if (empty($strParentTable) || empty($intParentId)) {
return false;
}

$objResult = \Database::getInstance()
->prepare('SELECT COUNT(*) as mycount FROM tl_comments WHERE source=? AND parent=?')
->execute($strParentTable, $intParentId);
->prepare('SELECT COUNT(*) as mycount FROM tl_comments WHERE source=? AND parent=?')
->execute($strParentTable, $intParentId);

return $objResult->mycount;
}

public function mawReplaceLanguageTags($strTag)
{
if ($strTag == 'actlang')
{
if ($strTag == 'actlang') {
return $GLOBALS['TL_LANGUAGE'];
}
else
{
} else {
return false;
}
}

}
}

0 comments on commit add57f9

Please sign in to comment.