public static function ui($name) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $document->addStyleSheet(JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . '/elements/jbetolo.css'); return ''; }
public static function ui($name) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . '/elements/clearcache.js'); $document->addScriptDeclaration("\n var _jbetoloclearcache;\n\n window.addEvent('domready', function() {\n _jbetoloclearcache = new jbetoloclearcache({\n base: '" . JURI::base() . "',\n prefix: '" . (jbetoloHelper::isJ16() ? 'jform_params_' : 'params') . "',\n j16: " . (jbetoloHelper::isJ16() ? 'true' : 'false') . ",\n PLG_SYSTEM_JBETOLO_CACHE_CLEARED: '" . JText::_('PLG_SYSTEM_JBETOLO_CACHE_CLEARED') . "',\n });\n });\n "); $ui = "\n <div class='fieldContainer'>\n <ul class='btns'>\n <li><a id='clearSiteCacheBtn' title='" . JText::_('PLG_SYSTEM_JBETOLO_CACHE_CLEAR_SITE') . "' href='#'>" . JText::_('PLG_SYSTEM_JBETOLO_CACHE_CLEAR_SITE') . "</a></li>\n <li><a id='clearAdministratorCacheBtn' title='" . JText::_('PLG_SYSTEM_JBETOLO_CACHE_CLEAR_ADMINISTRATOR') . "' href='#'>" . JText::_('PLG_SYSTEM_JBETOLO_CACHE_CLEAR_ADMINISTRATOR') . "</a></li>\n </ul>\n </div>\n "; return $ui; }
public static function ui($name) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . '/elements/htaccess.js'); $document->addScriptDeclaration("\n window.addEvent('domready', function() {\n new jbetolohtaccess({base: '" . JURI::base() . "'});\n });\n "); $ui = "\n <div class='fieldContainer'>\n <button type='button' id='htaccessBtn'>" . JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_PATCH_BTN') . "</button>\n </div>\n "; return $ui; }
public static function ui($name) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . '/elements/cdnpurge.js'); $document->addScriptDeclaration("\n window.addEvent('domready', function() {\n new jbetolocdnpurge({base: '" . JURI::base() . "'});\n });\n "); $ui = "\n <div class='fieldContainer'>\n <div style='clear:both;'><label for='cdnpurgeCDN'>CDN</label><select id='cdnpurgeCDN'><option>maxcdn</option><option>cloudfront</option></select></div>\n <div style='clear:both;'><label for='cdnpurgePurge'>File to purge</label><input id='cdnpurgePurge' type='text' size='90' /></div>\n <div style='clear:both;'><label for='cdnpurgeKeys'>Keys</label><input id='cdnpurgeKeys' type='text' size='90' /><ul style='clear:both;'><li>maxcdn = APIKEY::APIID</li><li>cloudfront = ACCESSKEYID::SECRETKEYID::DISTRIBUTIONID</li></ul></div>\n <div style='clear:both;'><button type='button' id='cdnpurgeBtn'>" . JText::_('PLG_SYSTEM_JBETOLO_CDNPURGE_BTN') . "</button></div>\n </div>\n "; return $ui; }
public static function ui($name, $fileList) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . '/elements/jbetolosettings.js'); $document->addScriptDeclaration("\n var _jbetolosettings;\n\n window.addEvent('domready', function() {\n _jbetolosettings = new jbetolosettings({\n base: '" . JURI::base() . "',\n settingsSelectorID: '" . $name . "',\n prefix: '" . (jbetoloHelper::isJ16() ? 'jform_params_' : 'params') . "',\n j16: " . (jbetoloHelper::isJ16() ? 'true' : 'false') . ",\n PLG_JBETOLO_PREDEFINED_SUCCESS: '" . JText::_('PLG_JBETOLO_PREDEFINED_SUCCESS') . "',\n PLG_JBETOLO_PREDEFINED_CONFIRM: '" . JText::_('PLG_JBETOLO_PREDEFINED_CONFIRM') . "',\n PLG_JBETOLO_PREDEFINED_SAVENAME: '" . JText::_('PLG_JBETOLO_PREDEFINED_SAVENAME') . "',\n PLG_JBETOLO_PREDEFINED_SAVEAUTHOR: '" . JText::_('PLG_JBETOLO_PREDEFINED_SAVEAUTHOR') . "',\n PLG_JBETOLO_PREDEFINED_SAVEFAILURE: '" . JText::_('PLG_JBETOLO_PREDEFINED_SAVEFAILURE') . "',\n PLG_JBETOLO_PREDEFINED_SAVESUCCESS: '" . JText::_('PLG_JBETOLO_PREDEFINED_SAVESUCCESS') . "',\n PLG_JBETOLO_PREDEFINED_NAMEEXISTS: '" . JText::_('PLG_JBETOLO_PREDEFINED_NAMEEXISTS') . "'\n });\n });\n "); $ui = "\n <div class='fieldContainer'>\n <ul class='btns'>\n <li>" . $fileList . "</li>\n <li><a id='saveSettingBtn' title='" . JText::_('PLG_JBETOLO_PREDEFINED_SAVE') . "' href='#'>" . JText::_('PLG_JBETOLO_PREDEFINED_SAVE') . "</a></li>\n <li><a id='readSettingBtn' title='" . JText::_('PLG_JBETOLO_PREDEFINED_READ') . "' href='#'>" . JText::_('PLG_JBETOLO_PREDEFINED_READ') . "</a></li>\n <li><a id='pingBtn' title='" . JText::_('PLG_JBETOLO_PING') . "' href='#'>" . JText::_('PLG_JBETOLO_PING') . "</a></li>\n </ul>\n </div>\n "; JHTML::_('behavior.modal'); return $ui; }
public static function ui($name) { if (jbetoloHelper::isJ16()) { $name = str_replace('-', '_', $name); } $document = JFactory::getDocument(); $loc = JURI::root(true) . '/plugins/system/jbetolo/' . (jbetoloHelper::isJ16() ? 'jbetolo/' : '') . 'elements/'; $document->addScript($loc . 'smushit.js'); $document->addScriptDeclaration("\n var _jbetolosmushit;\n\n window.addEvent('domready', function() {\n _jbetolosmushit = new jbetolosmushit({\n base: '" . JURI::base() . "',\n smushitDir: '" . $name . "',\n j16: " . (jbetoloHelper::isJ16() ? 'true' : 'false') . ",\n PLG_JBETOLO_SMUSHIT_DIRECTORY: '" . JText::_('PLG_JBETOLO_SMUSHIT_DIRECTORY') . "'\n });\n });\n "); $ui = '<div class="fieldContainer"> <ul> <li><img id="smushitprogress" src="' . $loc . 'progress.gif" style="visibility:hidden;" /><input type="text" name="' . $name . '" id="' . $name . '" value="" size="50" /><button type="button" id="smushItBtn">' . JText::_('PLG_JBETOLO_SMUSHIT_BTN') . '</button></li> <li><input type="checkbox" name="' . $name . '_replace" id="' . $name . '_replace" />' . JText::_('PLG_JBETOLO_SMUSHIT_REPLACE') . '</li> <li><input type="checkbox" name="' . $name . '_recursive" id="' . $name . '_recursive" />' . JText::_('PLG_JBETOLO_SMUSHIT_RECURSIVE') . '</li> <li><input type="text" name="' . $name . '_fix" id="' . $name . '_fix" value="_smush" />' . JText::_('PLG_JBETOLO_SMUSHIT_FIX') . '</li> </ul> </div> '; return $ui; }
<?php //$Copyright$ defined('_JEXEC') or die('Restricted access'); if (jbetoloHelper::isJ16()) { class JFormFieldCDNJS extends JFormFieldList { public $type = 'CDNJS'; protected function getOptions() { $options = array(); require_once dirname(__FILE__) . '/../assets/cdnjs.php'; foreach ($cdnjs as $key => $option) { // Create a new option object based on the <option /> element. $tmp = JHtml::_('select.option', $option, JText::alt(trim($key), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', false); // Add the option object to the result set. $options[] = $tmp; } reset($options); return $options; } } } else { class JElementCDNJS extends JElement { public function fetchElement($name, $value, &$node, $control_name) { return 'CDNJS'; } } }
public static function htaccess() { require_once self::pluginLocation(); if (jbetoloHelper::isNginx()) { return JText::_('PLG_SYSTEM_JBETOLO_CACHE_STATIC_NGINX'); } $htaccessFile = JPATH_SITE . '/.htaccess'; if (!JFile::exists($htaccessFile)) { return JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_FILE_NOT_EXIST'); } $htaccess = JFile::read($htaccessFile); $patchFile = self::pluginLocation(true) . 'jbetolo/assets/htaccess_cache_static.txt'; if (!JFile::exists($htaccessFile)) { return JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_PATCH_MISSING'); } $patch = JFile::read($patchFile); if (strpos($htaccess, $patch) !== false) { return JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_ALREADY_PATCHED'); } $time = JHtml::_('date', 'now', '%Y-%m-%d %H:%M:%s'); $htaccess = '# Patched on: ' . $time . "\n" . $patch . "\n" . $htaccess; if (JFile::write($htaccessFile, $htaccess)) { return JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_PATCH_SUCCESS'); } return JText::_('PLG_SYSTEM_JBETOLO_HTACCESS_PATCH_FAILED'); }
public static function writeToFile($to_file, $data, $type, $overrideGZ = false) { if (!$to_file) { return false; } $to_file = JBETOLO_CACHE_DIR . '/' . str_replace(JBETOLO_CACHE_DIR . '/', '', $to_file); if (JFile::exists($to_file)) { return true; } if ($type == 'css' || $type == 'js') { $minify = JBETOLO_IS_MINIFY && plgSystemJBetolo::param($type . '_minify'); $exclMinify = plgSystemJBetolo::param('minify_exclude'); if (is_array($data)) { if ($minify && $exclMinify && count($exclMinify) > 0) { $exclMinify = explode(',', $exclMinify); foreach ($data as $d => $content) { if (jbetoloFileHelper::isFileExcluded($content['file'], $exclMinify)) { $data[$d] = $content['content']; } else { $data[$d] = jbetoloFileHelper::minify($type, $content['content']); } } $data = implode("\n", $data); } else { $data = jbetoloHelper::getArrayValues($data, 'content'); $data = implode("\n", $data); if ($minify) { $data = jbetoloFileHelper::minify($type, $data); } } } else { if ($minify) { $data = jbetoloFileHelper::minify($type, $data); } else { $data = jbetoloHelper::eatWhiteSpace($data); } } } if (JBETOLO_IS_GZ && (plgSystemJBetolo::param($type . '_gzip') || $overrideGZ)) { $data = gzencode($data); JFile::write($to_file, $data); } else { JFile::write($to_file, $data); } return true; }
/** * both getter and setter of plugin parameters * (de)serializes indicated params before getting resp. setting */ public static function param($name, $value = '', $dir = 'get') { static $plg, $params, $_params; if (!isset($params)) { $plg = JPluginHelper::getPlugin('system', 'jbetolo'); if (!$plg) { return; } if (version_compare(JVERSION, '2.5', 'ge')) { $params = new JRegistry($plg->params); } else { jimport('joomla.html.parameter'); $params = new JParameter($plg->params); } } if ($dir == 'set') { static $plgT, $db, $plgId, $j16; if (!isset($db)) { $j16 = jbetoloHelper::isJ16(); $db = JFactory::getDBO(); JTable::addIncludePath(JPATH_SITE . '/libraries/joomla/database/table/'); $plgT = JTable::getInstance(!$j16 ? 'plugin' : 'extension'); if ($j16) { $query = "SELECT extension_id FROM #__extensions WHERE type = 'plugin' AND folder = 'system' AND element = 'jbetolo' LIMIT 1"; } else { $query = "SELECT id FROM #__plugins WHERE folder = 'system' AND element = 'jbetolo' LIMIT 1"; } $db = JFactory::getDBO(); $db->setQuery($query); $plgId = $db->loadResult(); } $files = ''; if ($value instanceof JRegistry || $value instanceof JParameter) { $params = $value; $files = $params->get('files'); } else { if (in_array($name, self::$serializableParams)) { $value = serialize($value); } if ($name == 'files') { $files = $value; } else { $params->set($name, $value); } } if ($files) { JFile::write(JBETOLO_FILES_CACHE, $files); } $params->set('files', null); $plgT->bind(array($j16 ? 'extension_id' : 'id' => $plgId, 'params' => $params->toString($j16 ? 'JSON' : 'INI'))); if (!$plgT->store()) { return JError::raiseWarning(500, $db->getError()); } if (!empty($name)) { unset($_params[$name]); } } else { if (!isset($_params[$name]) || in_array($name, self::$serializableParams) && !is_array($_params[$name])) { if ($name == 'files') { $files = JFile::exists(JBETOLO_FILES_CACHE) ? JFile::read(JBETOLO_FILES_CACHE) : ''; $params->set('files', $files); $files = null; } $_params[$name] = $params->get($name); if (is_string($_params[$name])) { $_params[$name] = trim($_params[$name]); } if (!isset($_params[$name])) { $_params[$name] = $value; } if (in_array($name, self::$serializableParams)) { if (isset($_params[$name]) && !empty($_params[$name])) { $_params[$name] = @unserialize($_params[$name]); } if (empty($_params[$name])) { $_params[$name] = array(); } } } return $_params[$name]; } }