Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 50 additions & 46 deletions Classes/Hook/BackendControllerHook.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Tutorboy\ServerClock\Hook;

/*
Expand All @@ -20,52 +21,53 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Hook for backend controller
* Hook for backend controller.
*
* @package ServerClock
* @subpackage Hook
* @copyright (c) 2016 Midhun Devasia, Tutorboy.org
* @author Midhun Devasia <[email protected]>
*/
class BackendControllerHook {

/**
* Insert clock widget content
* @param array $configuration Configuration
* @param BackendController $backendController Backend controller
* @return void
*/
public function insertClockWidget(array $configuration, BackendController $backendController) {
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
/** @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility */
$configurationUtility = $this->objectManager->get('TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility');
$extensionConfiguration = $configurationUtility->getCurrentConfiguration('server_clock');
if (version_compare(TYPO3_branch, '8.0', '>=')) {
$queryElement = '.scaffold-toolbar.t3js-scaffold-toolbar .toolbar.t3js-topbar-toolbar ul';
}
if (version_compare(TYPO3_branch, '7.0', '>=') && version_compare(TYPO3_branch, '8.0', '<')) {
$queryElement = '#typo3-topbar-navigation .typo3-topbar-navigation-items';
}
if (version_compare(TYPO3_branch, '6.0', '>=') && version_compare(TYPO3_branch, '7.0', '<')) {
$queryElement = 'typo3-toolbar';
}
$this->getPageRenderer()->addJsInlineCode('ServerClock', '
class BackendControllerHook
{
/**
* Insert clock widget content.
*
* @param array $configuration Configuration
* @param BackendController $backendController Backend controller
*
* @return void
*/
public function insertClockWidget(array $configuration, BackendController $backendController)
{
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
/** @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility */
$configurationUtility = $this->objectManager->get('TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility');
$extensionConfiguration = $configurationUtility->getCurrentConfiguration('server_clock');
if (version_compare(TYPO3_branch, '8.0', '>=')) {
$queryElement = '.scaffold-toolbar.t3js-scaffold-toolbar .toolbar.t3js-topbar-toolbar ul';
}
if (version_compare(TYPO3_branch, '7.0', '>=') && version_compare(TYPO3_branch, '8.0', '<')) {
$queryElement = '#typo3-topbar-navigation .typo3-topbar-navigation-items';
}
if (version_compare(TYPO3_branch, '6.0', '>=') && version_compare(TYPO3_branch, '7.0', '<')) {
$queryElement = 'typo3-toolbar';
}
$this->getPageRenderer()->addJsInlineCode('ServerClock', '
var ClockWidget = ClockWidget || {};
ClockWidget.serverClockTimeZone = "' . date_default_timezone_get() . '";
ClockWidget.serverClockStartTime = "' . date('Y-m-d H:i:s') . '";
ClockWidget.serverClockDateTimeFormat = "' . $extensionConfiguration['datetimeFormat']['value'] . '";
ClockWidget.queryElement = "' . $queryElement . '";
ClockWidget.serverClockTimeZone = "'.date_default_timezone_get().'";
ClockWidget.serverClockStartTime = "'.date('Y-m-d H:i:s').'";
ClockWidget.serverClockDateTimeFormat = "'.$extensionConfiguration['datetimeFormat']['value'].'";
ClockWidget.queryElement = "'.$queryElement.'";
');

// TYPO3 6 Compactibility
if ($queryElement == 'typo3-toolbar') {
$path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('server_clock');
$this->getPageRenderer()->addJsFile($path . 'Resources/Public/JavaScript/ClockWidget-T36Compact.js');
} else {
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/ServerClock/ClockWidget');
}
// TYPO3 6 Compactibility
if ($queryElement == 'typo3-toolbar') {
$path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('server_clock');
$this->getPageRenderer()->addJsFile($path.'Resources/Public/JavaScript/ClockWidget-T36Compact.js');
} else {
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/ServerClock/ClockWidget');
}

$this->getPageRenderer()->addCssInlineBlock('ServerClockCss', '
$this->getPageRenderer()->addCssInlineBlock('ServerClockCss', '
#tutorboy-serverclock {
display: inline;
padding: 4px 15px;
Expand All @@ -83,13 +85,15 @@ public function insertClockWidget(array $configuration, BackendController $backe
margin-top: -7px;
}
');
}
}

/**
* PageRenderer object
* @return PageRenderer
*/
protected function getPageRenderer() {
return GeneralUtility::makeInstance(PageRenderer::class);
}
/**
* PageRenderer object.
*
* @return PageRenderer
*/
protected function getPageRenderer()
{
return GeneralUtility::makeInstance(PageRenderer::class);
}
}
40 changes: 20 additions & 20 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
*
* ServerClock - Shows server clock
*/
$EM_CONF[$_EXTKEY] = array(
'title' => 'Server Clock: Server Time and Timezone',
'description' => 'A Clock which shows server time and timezone in the backend. The clock widget is simple and based on Javascript, and appears in the top right toolbar area. You set the DateTime format in the extension configuration wizard.',
'category' => 'be',
'author' => 'Midhun Devasia',
'author_email' => '[email protected]',
'state' => 'stable',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '1.0.2',
'constraints' => array(
'depends' => array(
'typo3' => '6.2.0-8.9.99',
),
'conflicts' => array(),
'suggests' => array(),
),
);
$EM_CONF[$_EXTKEY] = [
'title' => 'Server Clock: Server Time and Timezone',
'description' => 'A Clock which shows server time and timezone in the backend. The clock widget is simple and based on Javascript, and appears in the top right toolbar area. You set the DateTime format in the extension configuration wizard.',
'category' => 'be',
'author' => 'Midhun Devasia',
'author_email' => '[email protected]',
'state' => 'stable',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '1.0.2',
'constraints' => [
'depends' => [
'typo3' => '6.2.0-8.9.99',
],
'conflicts' => [],
'suggests' => [],
],
];
1 change: 1 addition & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

defined('TYPO3_MODE') or die();
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php']['constructPostProcess'][] = 'Tutorboy\\ServerClock\\Hook\\BackendControllerHook->insertClockWidget';