Skip to content
This repository was archived by the owner on Nov 19, 2017. It is now read-only.

Commit 2cb5965

Browse files
author
tolleiv
committed
CGL cleanups
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/imagemap_wizard/trunk@39728 735d13b6-9817-0410-8766-e36946ffe9aa
1 parent 7c951a3 commit 2cb5965

10 files changed

+388
-361
lines changed

classes/class.tx_imagemapwizard_parser.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,37 @@
2727
* @author Tolleiv Nietsch <info@tolleiv.de>
2828
*/
2929

30-
require_once(t3lib_extMgm::extPath('imagemap_wizard').'classes/model/class.tx_imagemapwizard_model_mapper.php');
30+
require_once(t3lib_extMgm::extPath('imagemap_wizard') . 'classes/model/class.tx_imagemapwizard_model_mapper.php');
3131

3232
class tx_imagemapwizard_parser extends tslib_pibase {
3333

34-
public function applyImageMap($content,$conf) {
35-
$xhtml = preg_match('/^xhtml/',$GLOBALS['TSFE']->config['config']['doctype']);
36-
$attrlist = explode(',','shape,coords,href,target,nohref,alt,title,accesskey,tabindex,onfocus,onblur,id,class,style,lang,dir,onclick,ondblclick,onmousedown,onmouseup,onmouseover,onmousemove,onmouseout,onkeypressonkeydown,onkeyup');
37-
// remove target attribute to have xhtml-strict output
38-
if(strcmp($GLOBALS['TSFE']->config['config']['doctype'],'xhtml_strict')===0) {
39-
$attrlist = array_diff($attrlist, array('target'));
34+
public function applyImageMap($content, $conf) {
35+
$xhtml = preg_match('/^xhtml/', $GLOBALS['TSFE']->config['config']['doctype']);
36+
$attrlist = explode(',', 'shape,coords,href,target,nohref,alt,title,accesskey,tabindex,onfocus,onblur,id,class,style,lang,dir,onclick,ondblclick,onmousedown,onmouseup,onmouseover,onmousemove,onmouseout,onkeypressonkeydown,onkeyup');
37+
// remove target attribute to have xhtml-strict output
38+
if (strcmp($GLOBALS['TSFE']->config['config']['doctype'], 'xhtml_strict')===0) {
39+
$attrlist = array_diff($attrlist, array('target'));
4040
}
4141

42-
$mapname = $this->cObj->stdWrap(preg_replace('/\s/','-',$this->cObj->getData($conf['map.']['name'],$this->cObj->data)),$conf['map.']['name.']);
42+
$mapname = $this->cObj->stdWrap(preg_replace('/\s/', '-', $this->cObj->getData($conf['map.']['name'], $this->cObj->data)), $conf['map.']['name.']);
4343

44-
// checking which image this is - using registers I guess these won't change in later versions (global vars might)
45-
$num = $this->cObj->getData('register:IMAGE_NUM_CURRENT',$this->cObj->data);
46-
if($num==0) {
47-
/* @var $converter tx_imagemapwizard_model_mapper */
44+
// checking which image this is - using registers I guess these won't change in later versions (global vars might)
45+
$num = $this->cObj->getData('register:IMAGE_NUM_CURRENT', $this->cObj->data);
46+
if ($num == 0) {
47+
/* @var $converter tx_imagemapwizard_model_mapper */
4848
$converter = t3lib_div::makeInstance('tx_imagemapwizard_model_mapper');
4949
$mapname = $converter->createValidNameAttribute($mapname);
50-
$map = $converter->generateMap($this->cObj,$mapname,$this->cObj->getData($conf['map.']['data'],$this->cObj->data),$attrlist,$xhtml,$conf,$num);
51-
if(!$converter->isEmptyMap($map) || $this->cObj->getData('register:keepUsemapMarker', $this->cObj->data)) {
52-
return str_replace('###IMAGEMAP_USEMAP###',$mapname,$content).$map;
50+
$map = $converter->generateMap($this->cObj, $mapname, $this->cObj->getData($conf['map.']['data'], $this->cObj->data), $attrlist, $xhtml, $conf, $num);
51+
if (!$converter->isEmptyMap($map) || $this->cObj->getData('register:keepUsemapMarker', $this->cObj->data)) {
52+
return str_replace('###IMAGEMAP_USEMAP###', $mapname, $content) . $map;
5353
}
5454
}
55-
return str_replace(' usemap="####IMAGEMAP_USEMAP###"','',$content);
55+
return str_replace(' usemap="####IMAGEMAP_USEMAP###"', '', $content);
5656
}
5757
}
5858

5959

60-
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_parser.php']) {
60+
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_parser.php']) {
6161
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_parser.php']);
6262
}
6363

classes/class.tx_imagemapwizard_softrefproc.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
* @author Tolleiv Nietsch <info@tolleiv.de>
2929
*/
3030

31-
require_once(PATH_t3lib."class.t3lib_softrefproc.php");
32-
require_once(t3lib_extMgm::extPath('imagemap_wizard').'classes/model/class.tx_imagemapwizard_model_mapper.php');
31+
require_once(PATH_t3lib . "class.t3lib_softrefproc.php");
32+
require_once(t3lib_extMgm::extPath('imagemap_wizard') . 'classes/model/class.tx_imagemapwizard_model_mapper.php');
3333

3434

3535
class tx_imagemapwizard_softrefproc extends t3lib_softrefproc {
@@ -48,34 +48,34 @@ class tx_imagemapwizard_softrefproc extends t3lib_softrefproc {
4848
* @return Array the Array which describes what references we found and where ...
4949
*/
5050

51-
function findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath='') {
51+
function findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath = '') {
5252
$conv = t3lib_div::makeInstance("tx_imagemapwizard_model_mapper");
5353
$data = $conv->map2array($content);
54-
$idx=0;
54+
$idx = 0;
5555

56-
$zeroToken = $this->makeTokenID('setTypoLinkPartsElement:'.$idx).':0';
56+
$zeroToken = $this->makeTokenID('setTypoLinkPartsElement:' . $idx) . ':0';
5757
$elements = array();
5858
$links = array();
59-
if(is_array($data['#'])) {
60-
foreach($data['#'] as $key=>$value) {
61-
$tmp = $this->findRef_typolink($value['value'],$spParams);
59+
if (is_array($data['#'])) {
60+
foreach ($data['#'] as $key => $value) {
61+
$tmp = $this->findRef_typolink($value['value'], $spParams);
6262
$linkData = $tmp['elements'][$zeroToken];
6363

64-
$newToken = $this->makeTokenID('setTypoLinkPartsElement:'.$idx);
65-
$data['#'][$key]['value'] = str_replace($linkData['subst']['tokenID'],$newToken,$tmp['content']);
66-
$linkData['subst']['tokenID']=$newToken;
67-
$elements[$newToken.':'.$idx] = $linkData;
64+
$newToken = $this->makeTokenID('setTypoLinkPartsElement:' . $idx);
65+
$data['#'][$key]['value'] = str_replace($linkData['subst']['tokenID'], $newToken, $tmp['content']);
66+
$linkData['subst']['tokenID'] = $newToken;
67+
$elements[$newToken . ':' . $idx] = $linkData;
6868
$idx++;
6969
}
7070
reset($elements);
7171
reset($data['#']);
7272
}
73-
return array("content"=>$conv->array2map($data),"elements"=>$elements);
73+
return array("content" => $conv->array2map($data), "elements" => $elements);
7474
}
7575
}
7676

7777

78-
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_softrefproc.php']) {
78+
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_softrefproc.php']) {
7979
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_softrefproc.php']);
8080
}
8181

classes/class.tx_imagemapwizard_wizicon.php

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,41 @@ class tx_imagemapwizard_wizicon {
2727
/**
2828
* Adds wizard icon
2929
*
30-
* @param array Input array with wizard items for plugins
31-
* @return array Modified input array, having the item added.
30+
* @param array Input array with wizard items for plugins
31+
* @return array Modified input array, having the item added.
3232
*/
33-
function proc($wizardItems) {
33+
function proc($wizardItems) {
3434

3535
$LL = $this->includeLocalLang();
3636

3737
$newWizardItem['common_imagemap'] = array(
38-
'icon' => t3lib_extMgm::extRelPath('imagemap_wizard').'tt_content_imagemap.gif',
39-
'title' => $GLOBALS['LANG']->getLLL('imagemap.title',$LL),
40-
'description' => $GLOBALS['LANG']->getLLL('imagemap.description',$LL),
38+
'icon' => t3lib_extMgm::extRelPath('imagemap_wizard') . 'tt_content_imagemap.gif',
39+
'title' => $GLOBALS['LANG']->getLLL('imagemap.title', $LL),
40+
'description' => $GLOBALS['LANG']->getLLL('imagemap.description', $LL),
4141
'tt_content_defValues.' => array(
4242
'CType' => 'imagemap_wizard'
4343
)
4444
);
4545

46-
$specialPart = is_array($wizardItems)?$wizardItems:array();
47-
$commonPart = array_splice($specialPart,0,$this->getCommonItemCount($wizardItems));
46+
$specialPart = is_array($wizardItems) ? $wizardItems : array();
47+
$commonPart = array_splice($specialPart, 0, $this->getCommonItemCount($wizardItems));
4848

49-
return array_merge($commonPart,$newWizardItem,$specialPart);
49+
return array_merge($commonPart, $newWizardItem, $specialPart);
5050
}
5151

5252
/**
5353
* [Describe function...]
5454
*
55-
* @param [type] $list: ...
56-
* @return [type] ...
55+
* @param [type] $list: ...
56+
* @return [type] ...
5757
*/
5858
function getCommonItemCount($list) {
59-
if(!is_array($list)) return;
59+
if (!is_array($list)) {
60+
return;
61+
}
6062
reset($list);
61-
$num =0;
62-
while(preg_match('/^common/',key($list)) && next($list)) {
63+
$num = 0;
64+
while (preg_match('/^common/', key($list)) && next($list)) {
6365
$num++;
6466
}
6567
return $num;
@@ -69,17 +71,17 @@ function getCommonItemCount($list) {
6971
/**
7072
* Includes the locallang file
7173
*
72-
* @return array The LOCAL_LANG array
74+
* @return array The LOCAL_LANG array
7375
*/
74-
function includeLocalLang() {
75-
$llFile = t3lib_extMgm::extPath('imagemap_wizard').'locallang.xml';
76+
function includeLocalLang() {
77+
$llFile = t3lib_extMgm::extPath('imagemap_wizard') . 'locallang.xml';
7678
$LOCAL_LANG = t3lib_div::readLLXMLfile($llFile, $GLOBALS['LANG']->lang);
7779
return $LOCAL_LANG;
7880
}
7981
}
8082

8183

82-
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_wizicon.php']) {
84+
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_wizicon.php']) {
8385
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/class.tx_imagemapwizard_wizicon.php']);
8486
}
8587

classes/controller/class.tx_imagemapwizard_controller_wizard.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
* @author Tolleiv Nietsch <info@tolleiv.de>
2828
*/
2929

30-
require_once(t3lib_extMgm::extPath('imagemap_wizard').'classes/model/class.tx_imagemapwizard_model_dataObject.php');
30+
require_once(t3lib_extMgm::extPath('imagemap_wizard') . 'classes/model/class.tx_imagemapwizard_model_dataObject.php');
3131

3232
class tx_imagemapwizard_controller_wizard {
3333
protected $view;
3434
protected $context = 'wizard';
3535
protected $ajax = false;
3636
protected $params;
3737
protected $forceValue;
38+
3839
/**
3940
* Initialize Context and required View
4041
*/
@@ -48,9 +49,9 @@ public function __construct() {
4849
*/
4950
protected function wizardAction() {
5051
$params = t3lib_div::_GP('P');
51-
$currentValue = $GLOBALS['BE_USER']->getSessionData ('imagemap_wizard.value');
52-
//TODO: use-Flex-DataObject if needed
53-
$this->view->setData($this->makeDataObj($params['table'],$params['field'],$params['uid'],$currentValue));
52+
$currentValue = $GLOBALS['BE_USER']->getSessionData('imagemap_wizard.value');
53+
//TODO: use-Flex-DataObject if needed
54+
$this->view->setData($this->makeDataObj($params['table'], $params['field'], $params['uid'], $currentValue));
5455
$this->view->renderContent();
5556
}
5657

@@ -60,11 +61,12 @@ protected function wizardAction() {
6061
*/
6162
protected function tceformAction() {
6263

63-
$data = $this->makeDataObj($this->params['table'],$this->params['field'],$this->params['uid'],$this->forceValue);
64+
$data = $this->makeDataObj($this->params['table'], $this->params['field'], $this->params['uid'], $this->forceValue);
6465
$data->setFieldConf($this->params['fieldConf']);
6566

6667
$this->view->setData($data);
67-
$this->view->setTCEForm($this->params['pObj']);;
68+
$this->view->setTCEForm($this->params['pObj']);
69+
6870
$this->view->setFormName($this->params['itemFormElName']);
6971
$this->view->setWizardConf($this->params['fieldConf']['config']['wizards']);
7072
t3lib_div::loadTCA($this->params['table']);
@@ -80,38 +82,37 @@ protected function tceformAjaxAction() {
8082
$this->params['field'] = t3lib_div::_GP('field');
8183
$this->params['uid'] = t3lib_div::_GP('uid');
8284
$this->params['fieldConf'] = unserialize(stripslashes((t3lib_div::_GP('config'))));
83-
require_once(PATH_t3lib."class.t3lib_tceforms.php");
85+
require_once(PATH_t3lib . "class.t3lib_tceforms.php");
8486
$this->params['pObj'] = t3lib_div::makeInstance('t3lib_TCEforms');
8587
$this->params['pObj']->initDefaultBEMode();
8688
$this->params['itemFormElName'] = t3lib_div::_GP('formField');
8789

8890
$this->forceValue = t3lib_div::_GP('value');
89-
$GLOBALS['BE_USER']->setAndSaveSessionData('imagemap_wizard.value',$this->forceValue);
91+
$GLOBALS['BE_USER']->setAndSaveSessionData('imagemap_wizard.value', $this->forceValue);
9092
echo $this->tceformAction();
9193
}
9294

9395

94-
9596
/**
9697
* Execute required action which is determined by the given context
9798
*/
9899
public function triggerAction() {
99-
$action = $this->context.($this->ajax?'Ajax':'').'Action';
100-
return call_user_func_array(array($this, $action),array());
100+
$action = $this->context . ($this->ajax ? 'Ajax' : '') . 'Action';
101+
return call_user_func_array(array($this, $action), array());
101102
}
102103

103104
/**
104105
* Determine context
105106
*/
106-
protected function initContext($forceContext=NULL) {
107+
protected function initContext($forceContext = NULL) {
107108
$reqContext = $forceContext ? $forceContext : t3lib_div::_GP('context');
108109
$this->context = ($reqContext == 'tceform') ? 'tceform' : 'wizard';
109-
$this->ajax = (t3lib_div::_GP('ajax') == '1' );
110+
$this->ajax = (t3lib_div::_GP('ajax') == '1');
110111
}
111112

112113
protected function initView() {
113-
require_once(t3lib_extMgm::extPath('imagemap_wizard').'classes/view/class.tx_imagemapwizard_view_'.$this->context.'.php');
114-
$this->view = t3lib_div::makeInstance('tx_imagemapwizard_view_'.$this->context);
114+
require_once(t3lib_extMgm::extPath('imagemap_wizard') . 'classes/view/class.tx_imagemapwizard_view_' . $this->context . '.php');
115+
$this->view = t3lib_div::makeInstance('tx_imagemapwizard_view_' . $this->context);
115116
$this->view->init($this->context);
116117
}
117118

@@ -124,12 +125,12 @@ protected function initView() {
124125
* @return String HTMLCode with form-field
125126
*/
126127
public function renderForm($PA, t3lib_TCEforms $fobj) {
127-
$GLOBALS['BE_USER']->setAndSaveSessionData('imagemap_wizard.value',NULL);
128+
$GLOBALS['BE_USER']->setAndSaveSessionData('imagemap_wizard.value', NULL);
128129
$this->params['table'] = $PA['table'];
129-
if($GLOBALS['TCA'][$PA['table']]['columns'][$PA['field']]['config']['type'] == 'flex') {
130-
$parts = array_slice(explode('][',$PA['itemFormElName']),3);
131-
$field = substr(implode('/',$parts),0,-1);
132-
$this->params['field'] = sprintf('%s:%d:%s:%s',$PA['table'],$PA['row']['uid'],$PA['field'],$field);
130+
if ($GLOBALS['TCA'][$PA['table']]['columns'][$PA['field']]['config']['type'] == 'flex') {
131+
$parts = array_slice(explode('][', $PA['itemFormElName']), 3);
132+
$field = substr(implode('/', $parts), 0, -1);
133+
$this->params['field'] = sprintf('%s:%d:%s:%s', $PA['table'], $PA['row']['uid'], $PA['field'], $field);
133134
} else {
134135
$this->params['field'] = $PA['field'];
135136
}
@@ -154,7 +155,7 @@ public function renderForm($PA, t3lib_TCEforms $fobj) {
154155
* @return tx_imagemapwizard_model_dataObject
155156
*/
156157
protected function makeDataObj($table, $field, $uid, $value) {
157-
if(version_compare(TYPO3_version,'4.3.0','<')) {
158+
if (version_compare(TYPO3_version, '4.3.0', '<')) {
158159
$dataClass = t3lib_div::makeInstanceClassName('tx_imagemapwizard_model_dataObject');
159160
$data = new $dataClass($table, $field, $uid, $value);
160161
} else {
@@ -164,7 +165,7 @@ protected function makeDataObj($table, $field, $uid, $value) {
164165
}
165166
}
166167

167-
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/controller/class.tx_imagemapwizard_controller_wizard.php']) {
168+
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/controller/class.tx_imagemapwizard_controller_wizard.php']) {
168169
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/imagemap_wizard/classes/controller/class.tx_imagemapwizard_controller_wizard.php']);
169170
}
170171

0 commit comments

Comments
 (0)