Commit 0a8d3d61 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Remove obsolete files and views (listSorted and show)

parent 71615b8d
......@@ -61,15 +61,4 @@ class ListingController extends ActionController
]
);
}
/**
* action show
*
* @param User $user
* @return void
*/
public function showAction(User $user)
{
$this->view->assign('certUser', $user);
}
}
<?php
declare(strict_types=1);
namespace T3o\Certifications\ViewHelpers;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use stdClass;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
/**
* Resizes a given image (if required) and renders the respective img tag
*
* = Examples =
*
* <code title="Default">
* <f:image src="EXT:myext/Resources/Public/typo3_logo.png" alt="alt text" />
* </code>
* <output>
* <img alt="alt text" src="typo3conf/ext/myext/Resources/Public/typo3_logo.png" width="396" height="375" />
* or (in BE mode):
* <img alt="alt text" src="../typo3conf/ext/viewhelpertest/Resources/Public/typo3_logo.png" width="396" height="375" />
* </output>
*
* <code title="Inline notation">
* {f:image(src: 'EXT:viewhelpertest/Resources/Public/typo3_logo.png', alt: 'alt text', minWidth: 30, maxWidth: 40)}
* </code>
* <output>
* <img alt="alt text" src="../typo3temp/pics/f13d79a526.png" width="40" height="38" />
* (depending on your TYPO3s encryption key)
* </output>
*
* <code title="non existing image">
* <f:image src="NonExistingImage.png" alt="foo" />
* </code>
* <output>
* Could not get image resource for "NonExistingImage.png".
* </output>
*/
class GrayImageViewHelper extends AbstractTagBasedViewHelper
{
/**
* @var ContentObjectRenderer
*/
protected $contentObject;
/**
* @var string
*/
protected $tagName = 'img';
/**
* @var TypoScriptFrontendController contains a backup of the current $GLOBALS['TSFE'] if used in BE mode
*/
protected $tsfeBackup;
/**
* @var string
*/
protected $workingDirectoryBackup;
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @param ConfigurationManagerInterface $configurationManager
* @return void
*/
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
$this->contentObject = $this->configurationManager->getContentObject();
}
/**
* Initialize arguments.
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('alt', 'string', 'Specifies an alternate text for an image', true);
$this->registerTagAttribute('ismap', 'string', 'Specifies an image as a server-side image-map. Rarely used. Look at usemap instead');
$this->registerTagAttribute('longdesc', 'string', 'Specifies the URL to a document that contains a long description of an image');
$this->registerTagAttribute('usemap', 'string', 'Specifies an image as a client-side image-map');
}
/**
* Resizes a given image (if required) and renders the respective img tag
*
* @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4164427
*
* @param string $src
* @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
* @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
* @param integer $minWidth minimum width of the image
* @param integer $minHeight minimum height of the image
* @param integer $maxWidth maximum width of the image
* @param integer $maxHeight maximum height of the image
*
* @return string rendered tag.
* @author Sebastian Böttger <sboettger@cross-content.com>
* @author Bastian Waidelich <bastian@typo3.org>
*/
public function render(
string $src,
string $width = null,
string $height = null,
int $minWidth = null,
int $minHeight = null,
int $maxWidth = null,
int $maxHeight = null
) {
if (TYPO3_MODE === 'BE') {
$this->simulateFrontendEnvironment();
}
$setup = [
'width' => $width,
'height' => $height,
'minW' => $minWidth,
'minH' => $minHeight,
'maxW' => $maxWidth,
'maxH' => $maxHeight
];
if (TYPO3_MODE === 'BE' && substr($src, 0, 3) === '../') {
$src = substr($src, 3);
}
$imageInfo = $this->contentObject->getImgResource($src, $setup);
$GLOBALS['TSFE']->lastImageInfo = $imageInfo;
if (!is_array($imageInfo)) {
if (TYPO3_MODE === 'BE') {
$this->resetFrontendEnvironment();
}
throw new Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
}
$imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
//Convert to grey
$newFile = substr($imageInfo[3], 0, -4) . '.jpg';
$cmd = CommandUtility::imageMagickCommand('convert', '"' . $imageInfo[3] . '" -colorspace Gray "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
CommandUtility::exec($cmd);
$imageInfo[3] = $newFile;
if (@is_file($newFile)) {
GeneralUtility::fixPermissions($newFile);
}
$GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
$imageSource = $GLOBALS['TSFE']->absRefPrefix . rawUrlEncodeFP($imageInfo[3]);
if (TYPO3_MODE === 'BE') {
$imageSource = '../' . $imageSource;
$this->resetFrontendEnvironment();
}
$this->tag->addAttribute('src', $imageSource);
$this->tag->addAttribute('width', $imageInfo[0]);
$this->tag->addAttribute('height', $imageInfo[1]);
//the alt-attribute is mandatory to have valid html-code, therefore add it even if it is empty
if (empty($this->arguments['alt'])) {
$this->tag->addAttribute('alt', '');
}
if (empty($this->arguments['title']) && !empty($this->arguments['alt'])) {
$this->tag->addAttribute('title', $this->arguments['alt']);
}
return $this->tag->render();
}
/**
* Prepares $GLOBALS['TSFE'] for Backend mode
* This somewhat hacky work around is currently needed because the getImgResource() function of tslib_cObj relies on those
* variables to be set
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
*/
protected function simulateFrontendEnvironment()
{
$this->tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : null;
// set the working directory to the site root
$this->workingDirectoryBackup = getcwd();
chdir(Environment::getPublicPath() . '/');
$typoScriptSetup = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$GLOBALS['TSFE'] = new stdClass();
$template = GeneralUtility::makeInstance('t3lib_TStemplate');
$template->tt_track = 0;
$template->init();
$template->getFileName_backPath = Environment::getPublicPath() . '/';
$GLOBALS['TSFE']->tmpl = $template;
$GLOBALS['TSFE']->tmpl->setup = $typoScriptSetup;
$GLOBALS['TSFE']->config = $typoScriptSetup;
}
/**
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
* @see simulateFrontendEnvironment()
*/
protected function resetFrontendEnvironment()
{
$GLOBALS['TSFE'] = $this->tsfeBackup;
chdir($this->workingDirectoryBackup);
}
}
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Views</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>View</label>
<config>
<type>select</type>
<items>
<numIndex index="0">
<numIndex index="0">List</numIndex>
<numIndex index="1">Listing->list;Listing->listSorted;Listing->show</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">Detail</numIndex>
<numIndex index="1">Listing->show</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.singlePid>
<TCEforms>
<label>PID for Detail-Page</label>
<config>
<type>input</type>
<renderType>inputLink</renderType>
<eval>trim</eval>
<wizards type="array">
<_PADDING>2</_PADDING>
<link type="array">
<type>popup</type>
<title>Link</title>
<icon>link_popup.gif</icon>
<fieldControl>
<linkPopup>
<options>
<blindLinkOptions>mail,spec,file,folder,url</blindLinkOptions>
</options>
</linkPopup>
</fieldControl>
</link>
</wizards>
</config>
</TCEforms>
</settings.singlePid>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
\ No newline at end of file
......@@ -6,11 +6,3 @@
'Certlist',
'Certification List'
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['certifications_certlist'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
'certifications_certlist',
'FILE:EXT:certifications/Configuration/FlexForms/Certlist.xml'
);
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'_DEFAULT' =>
array (
'postVarSets' => array (
'_DEFAULT' => array (
'certification' => array(
array(
'GETvar' => 'tx_certifications_certlist[action]',
'valueMap' => array(
'list' => 'list',
'sorted-list' => 'listSorted',
),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_certifications_certlist[controller]',
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_certifications_certlist[sortby]',
'valueMap' => array(
'country' => 'country',
'certificate' => 'certificate'
),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_certifications_certlist[sorting]',
'valueMap' => array(
'asc' => 'asc',
'desc' => 'desc'
),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_certifications_certlist[feUsers]',
'lookUpTable' => array (
'table' => 'fe_users',
'id_field' => 'uid',
'alias_field' => 'name',
'addWhereClause' => ' AND NOT deleted AND NOT disable',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array (
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
)
)
),
),
),
);
<?php
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* convert a CSV file of certified users into SQL statements
*/
$fp = fopen("certs.csv", "r");
$userId = 1;
$storagePid = 774;
while (!feof($fp)) {
$zeile = fgetcsv($fp, NULL, ";");
if (count($zeile) < 4) {
continue;
}
$query = sprintf(
'INSERT INTO tx_certifications_domain_model_user(uid,pid,first_name,last_name,email,public_email_address,country,certificates)' .
'VALUES(%d, %d, "%s", "%s", "%s", %d, "%s", %d);',
$userId, //uid
$storagePid, //pid
addslashes(trim($zeile[2])), // last_name
addslashes(trim($zeile[1])), // first_name
addslashes(trim($zeile[0])), // email
0, //public_email_address
addslashes(trim($zeile[3])), // country
1 //certificates
);
echo $query . "\n";
$certificationDate = date("U", strtotime($zeile[4]));
$expirationDate = strtotime('+3 years', $certificationDate);
if ($zeile[6] == 'Version 4.x') {
$version_four = TRUE;
} else {
$version_four = FALSE;
}
$query = sprintf(
'INSERT INTO tx_certifications_domain_model_certificate (pid,user,certification_date,allow_listing,version_four,certificate_type,expiration_date) ' .
'VALUES(%d, %d, %d, %d, %d, %d, %d);',
$storagePid, //pid
$userId, //user
$certificationDate, //certification_date
1, //allow_listing
(int)$version_four, // version_four
1, // certificate_type
$expirationDate // expiration_date
);
echo $query . "\n";
$userId++;
}
fclose($fp);
<f:layout name="Default"/>
<f:section name="main">
<div class="tx_certifications">
<div class="cert-panel">
<table>
<thead>
<tr>
<th>
<f:link.action action="list" arguments="{sorting : sorto}">
<f:translate key="tx_certifications_domain_model_user.name"/>
</f:link.action>
</th>
<th>
<f:link.action action="listSorted" arguments="{sortby : 'country', sorting : sort}">
<f:translate key="tx_certifications_domain_model_user.country"/>
</f:link.action>
</th>
<th>
<f:link.action action="listSorted" arguments="{sortby : 'certificate', sorting : sort}">
<f:translate key="tx_certifications_domain_model_user.certificate"/>
</f:link.action>
</th>
</tr>
</thead>
<f:for each="{feUserss}" as="feUsers">
<tr>
<f:if condition="{settings.singlePid}">
<f:then>
<td>
<h5>
<f:link.action action="show" arguments="{user : feUser}">{feUser.lastName},
{feUser.firstName}
</f:link.action>
</h5>
</td>
</f:then>
<f:else>
<td>
<h5>
<f:link.action action="show" arguments="{user : feUser}">{feUser.lastName},
{feUser.firstName}
</f:link.action>
</h5>
</td>
</f:else>
</f:if>
<td>{feUsers.country}</td>
<td>
<ul>
<f:for each="{feUsers.certificates}" as="certificate">
<f:if condition="{0:certificate.allowListing} == {0:'1'}">
<li>{certificate.certificateType.title}
(
<f:if condition="{certificate.expired}">
<f:then>
<f:translate
key="tx_certifications_domain_model_user.no_expiration"/>
</f:then>
<f:else>
<f:format.date format="d.m.Y">{certificate.certificationDate}
</f:format.date>
-
<f:format.date format="d.m.Y">{certificate.expirationDate}
</f:format.date>
</f:else>
</f:if>
)
</li>
</f:if>
</f:for>
</ul>
</td>
</tr>
</f:for>
</table>
</div>
</div>
</f:section>
\ No newline at end of file
{namespace cert=T3o\Certifications\ViewHelpers}
<f:layout name="Default"/>
<f:section name="main">
<h1 class="csc-firstHeader cert-head">{certUser.firstName} {certUser.lastName}</h1>
<f:if condition="{certUser.feUser.image}">
<div class="cert-user-image">
<cert:GrayImage src="uploads/pics/{certUser.feUser.image}" width="340m"
alt="{certUser.firstName} {certUser.lastName}"/>
<f:if condition="{certUser.certReason}">
<span class="cert-reason">"{certUser.certReason}" <span class="cert-name">{certUser.firstName} {certUser.lastName}</span></span>
</f:if>
</div>
</f:if>
<span class="cert-country">{certUser.country}</span>
<div class="certificates">
<h3>
<f:translate key="tx_certifications_domain_model_user.myCertificates"/>
</h3>
<ul>
<f:for each="{certUser.certificates}" as="certificate">
<f:if condition="{0:certificate.allowListing} == {0:'1'}">
<li>{certificate.certificateType.title}:
<f:if condition="{certificate.versionFour}">
<f:then>
<f:translate key="tx_certifications_domain_model_user.no_expiration"/>
</f:then>
<f:else>
<f:format.date format="d.m.Y">{certificate.certificationDate}</f:format.date>
-
<f:format.date format="d.m.Y">{certificate.expirationDate}</f:format.date>
</f:else>
</f:if>
</li>
</f:if>
</f:for>
</ul>
</div>
<f:if condition="{certUser.publicInformationAvailable}">
<div class="cert-contact">
<h3>
<f:translate key="tx_certifications_domain_model_user.contact"/>
</h3>
<f:if condition="{certUser.publicEmailAddress}">
<p>
<f:link.email email="{certUser.email}"/>
</p>
</f:if>
<f:if condition="{certUser.publicTwitter}">
<p>
<f:link.external uri="https://www.twitter.com/{certUser.twitter}" target="_blank">
@{certUser.twitter}
</f:link.external>
</p>
</f:if>
</div>
</f:if>
</f:section>
......@@ -7,6 +7,6 @@ if (!defined('TYPO3_MODE')) {
'certifications',
'Certlist',
[
\T3o\Certifications\Controller\ListingController::class => 'list, show',
\T3o\Certifications\Controller\ListingController::class => 'list',
]
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment