SuggestReceiver::queryTable()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 42
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 42
rs 8.8571
cc 2
eloc 16
nc 2
nop 2
1
<?php
2
3
/**
4
 * Suggest receiver
5
 */
6
7
namespace HDNET\Tagger\Hooks;
8
9
use TYPO3\CMS\Backend\Form\Wizard\SuggestWizardDefaultReceiver;
10
use TYPO3\CMS\Backend\Utility\IconUtility;
11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12
13
/**
14
 * Suggest receiver
15
 */
16
class SuggestReceiver extends SuggestWizardDefaultReceiver
17
{
18
19
    /**
20
     * Query table
21
     *
22
     * @param array $params
23
     * @param integer $recursionCounter
24
     * @return mixed
25
     */
26
    public function queryTable(&$params, $recursionCounter = 0)
27
    {
28
        $uid = GeneralUtility::_GP('uid');
29
30
        $records = parent::queryTable($params, $recursionCounter);
31
32
        if (count($records) === 0) {
33
            $text = htmlspecialchars($params['value']);
34
            $javaScriptCode = '
35
var value=\'' . $text . '\';
36
37
Ext.Ajax.request({
38
    url : \'ajax.php\' ,
39
    params : { ajaxID : \'Tag::createTag\', item:value, newsid:\'' . $uid . '\' },
40
    success: function ( result, request ) {
41
        var arr = result.responseText.split(\'-\');
42
        setFormValueFromBrowseWin(arr[5], arr[2] +  \'_\' + arr[0], arr[1]);
43
        TBE_EDITOR.fieldChanged(arr[3], arr[6], arr[4], arr[5]);
44
    },
45
    failure: function ( result, request) {
46
        Ext.MessageBox.alert(\'Failed\', result.responseText);
47
    }
48
});
49
';
50
51
            $javaScriptCode = trim(str_replace('"', '\'', $javaScriptCode));
52
            $link = implode(' ', explode(chr(10), $javaScriptCode));
53
54
            $records['tx_tagger_domain_model_tag_' . strlen($text)] = [
55
                'text' => '<div onclick="' . $link . '">
56
                            <span class="suggest-path">
57
                                <a>Kein Tage gefunden. Klicken zum erzeugen</a>
58
                            </span></div>',
59
                'table' => 'tx_tagger_domain_model_tag',
60
                'class' => 'suggest-noresults',
61
                'style' => 'background-color:#E9F1FE !important;background-image:url(' . $this->getDummyIconPath() . ');',
62
            ];
63
            /// sprintf($GLOBALS['LANG']->sL('LLL:EXT:news/Resources/Private/Language/locallang_be.xml:tag_suggest'), $text)
64
        }
65
66
        return $records;
67
    }
68
69
    /**
70
     * Get the icon of this database
71
     *
72
     * @return string
73
     */
74
    private function getDummyIconPath()
75
    {
76
        $icon = IconUtility::getSpriteIconForRecord('tx_tagger_domain_model_tag', []);
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Backend\Utilit...etSpriteIconForRecord() has been deprecated with message: since TYPO3 CMS 7, will be removed with TYPO3 CMS 8

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
77
        return IconUtility::skinImg('', $icon, '', 1);
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Backend\Utility\IconUtility::skinImg() has been deprecated with message: since TYPO3 CMS 7, will be removed with TYPO3 CMS 8

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
78
    }
79
}
80