?
Path : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/system/ |
Current File : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/system/jatoggler.php |
<?php defined( '_JEXEC' ) or die( 'Restricted access' ); jimport( 'joomla.plugin.plugin' ); class plgSystemJatoggler extends JPlugin { function plgSystemJatoggler(& $subject, $config) { global $mainframe; parent::__construct($subject, $config); $jat = $mainframe->getUserStateFromRequest('jatoggler', 'jatoggler', 0); $task = $mainframe->getUserStateFromRequest('jatoggler_task', 'jatoggler_task', ''); if (!$jat) $mainframe->setUserState('jatoggler', JRequest::getCmd('jatoggler')); if (!$task) $mainframe->setUserState('jatoggler_task', JRequest::getCmd('task')); } function onAfterRoute() { global $mainframe; if(!$mainframe->isAdmin() || JRequest::getInt('nojatoggler')) { return; } JHtml::script('jatoggler.js', JUri::root().'plugins/system/jatoggler/', true); $js = "var jmrat_Public = '".JText::_('Public')."'; var jmrat_Registered = '".JText::_('Registered')."'; var jmrat_Special = '".JText::_('Special')."';\n"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); } function onAfterDispatch() { global $mainframe; if(!$mainframe->isAdmin()) { return; } $jat = $mainframe->getUserStateFromRequest('jatoggler', 'jatoggler', 0); $task = $mainframe->getUserStateFromRequest('jatoggler_task', 'jatoggler_task', ''); $mainframe->setUserState('jatoggler', ''); $mainframe->setUserState('jatoggler_task', ''); if ($jat) { switch($task) { case 'publish': case 'unpublish': case 'block': case 'unblock': case 'toggle_frontpage': case 'accessregistered': case 'accessspecial': case 'accesspublic': plgSystemJatoggler::clearMessages(); while (@ob_end_clean()); echo 'JAT OK'; die(); break; case 'orderup': case 'orderdown': case 'saveorder': default: $buf = plgSystemJatoggler::getTable($task); plgSystemJatoggler::clearMessages(); while (@ob_end_clean()); echo $buf; die(); break; } } } function getTable($task) { $doc =& JFactory::getDocument(); $buf = $doc->getBuffer('component'); $c = JString::strlen($buf); $s = JString::strpos($buf, 'return listItemTask'); $e = $s; while(JString::substr($buf, $s, 6) != '<table' || $s == 0) { $s--; } while(JString::substr($buf, $e, 7) != '</table' || $e == $c) { $e++; } $buf = JString::substr($buf, $s, ($e-$s+8)); $buf = JString::str_ireplace("\r", '', $buf); $buf = JString::str_ireplace("\n", '', $buf); $buf = JString::str_ireplace("\t", '', $buf); return $buf; } function clearMessages() { $session =& JFactory::getSession(); $session->set('application.queue', null); } }