Skip to content

Instantly share code, notes, and snippets.

@nielsnuebel
Created August 10, 2016 08:04
Show Gist options
  • Save nielsnuebel/9d8746ecc65716ee9ab4b28f913a5895 to your computer and use it in GitHub Desktop.
Save nielsnuebel/9d8746ecc65716ee9ab4b28f913a5895 to your computer and use it in GitHub Desktop.
<?php
/**
* @package Joomla.Site
* @subpackage mod_kickintro
*
* @author Niels Nübel <[email protected]>
* @copyright Copyright (c) 2013-2016 niels-nuebel.de
* @license GNU General Public License version 2 or later
*/
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* Helper for mod_feed
*
* @package Joomla.Site
* @subpackage mod_kickintro
* @since 3.6
*/
class ModKickIntroHelper
{
private static $jsPath = 'media/mod_kickintro/js';
private static $jsFilePrefix = '/kickintro-';
public static function addScript($module_id, $params)
{
if (!file_exists(self::$jsPath))
{
JFolder::create(self::$jsPath, 0755);
}
$doc = JFactory::getDocument();
$script = array();
$script[] = 'alert("bla");';
$filename = self::$jsPath . self::$jsFilePrefix . $module_id . '.js';
$filecontent = file_get_contents($filename);
$javascriptText = implode("\n", $script);
if($filecontent != $javascriptText)
{
if (!JFile::write($filename, $javascriptText))
{
return false;
}
}
$doc->addScriptVersion($filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment