We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 19 |
| Paths | 28 |
| Total Lines | 126 |
| Code Lines | 89 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 38 | public function main($content, $conf) { |
||
| 39 | $this->init($conf); |
||
| 40 | // Don't cache the output. |
||
| 41 | $this->setCache(FALSE); |
||
| 42 | // Create XML document. |
||
| 43 | $rss = new \DOMDocument('1.0', 'utf-8'); |
||
| 44 | // Add mandatory root element. |
||
| 45 | $root = $rss->createElement('rss'); |
||
| 46 | $root->setAttribute('version', '2.0'); |
||
| 47 | // Add channel element. |
||
| 48 | $channel = $rss->createElement('channel'); |
||
| 49 | $channel->appendChild($rss->createElement('title', htmlspecialchars($this->conf['title'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 50 | $channel->appendChild($rss->createElement('link', htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->pi_linkTP_keepPIvars_url()), ENT_NOQUOTES, 'UTF-8'))); |
||
| 51 | if (!empty($this->conf['description'])) { |
||
| 52 | $channel->appendChild($rss->createElement('description', htmlspecialchars($this->conf['description'], ENT_QUOTES, 'UTF-8'))); |
||
| 53 | } |
||
| 54 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 55 | 'tx_dlf_libraries.label AS label', |
||
| 56 | 'tx_dlf_libraries', |
||
| 57 | 'tx_dlf_libraries.pid='.intval($this->conf['pages']) |
||
| 58 | .' AND tx_dlf_libraries.uid='.intval($this->conf['library']) |
||
| 59 | .Helper::whereClause('tx_dlf_libraries'), |
||
| 60 | '', |
||
| 61 | '', |
||
| 62 | '1' |
||
| 63 | ); |
||
| 64 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 65 | $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
||
| 66 | $channel->appendChild($rss->createElement('copyright', htmlspecialchars($resArray['label'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 67 | } |
||
| 68 | $channel->appendChild($rss->createElement('pubDate', date('r', $GLOBALS['EXEC_TIME']))); |
||
| 69 | $channel->appendChild($rss->createElement('generator', htmlspecialchars($this->conf['useragent'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 70 | // Add item elements. |
||
| 71 | if (!$this->conf['excludeOther'] |
||
| 72 | || empty($this->piVars['collection']) |
||
| 73 | || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->conf['collections'], $this->piVars['collection'])) { |
||
| 74 | $additionalWhere = ''; |
||
| 75 | // Check for pre-selected collections. |
||
| 76 | if (!empty($this->piVars['collection'])) { |
||
| 77 | $additionalWhere = ' AND tx_dlf_collections.uid='.intval($this->piVars['collection']); |
||
| 78 | } elseif (!empty($this->conf['collections'])) { |
||
| 79 | $additionalWhere = ' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')'; |
||
| 80 | } |
||
| 81 | $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
||
| 82 | 'tx_dlf_documents.uid AS uid,tx_dlf_documents.partof AS partof,tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_documents.author AS author,tx_dlf_documents.record_id AS guid,tx_dlf_documents.tstamp AS tstamp,tx_dlf_documents.crdate AS crdate', |
||
| 83 | 'tx_dlf_documents', |
||
| 84 | 'tx_dlf_relations', |
||
| 85 | 'tx_dlf_collections', |
||
| 86 | 'AND tx_dlf_documents.pid='.intval($this->conf['pages']) |
||
| 87 | .' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') |
||
| 88 | .' AND tx_dlf_collections.pid='.intval($this->conf['pages']) |
||
| 89 | .$additionalWhere |
||
| 90 | .Helper::whereClause('tx_dlf_documents') |
||
| 91 | .Helper::whereClause('tx_dlf_collections'), |
||
| 92 | 'tx_dlf_documents.uid', |
||
| 93 | 'tx_dlf_documents.tstamp DESC', |
||
| 94 | intval($this->conf['limit']) |
||
| 95 | ); |
||
| 96 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 97 | // Add each record as item element. |
||
| 98 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
||
| 99 | $item = $rss->createElement('item'); |
||
| 100 | $title = ''; |
||
| 101 | // Get title of superior document. |
||
| 102 | if ((empty($resArray['title']) || !empty($this->conf['prependSuperiorTitle'])) |
||
| 103 | && !empty($resArray['partof'])) { |
||
| 104 | $superiorTitle = Document::getTitle($resArray['partof'], TRUE); |
||
| 105 | if (!empty($superiorTitle)) { |
||
| 106 | $title .= '['.$superiorTitle.']'; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | // Get title of document. |
||
| 110 | if (!empty($resArray['title'])) { |
||
| 111 | $title .= ' '.$resArray['title']; |
||
| 112 | } |
||
| 113 | // Set default title if empty. |
||
| 114 | if (empty($title)) { |
||
| 115 | $title = $this->pi_getLL('noTitle'); |
||
| 116 | } |
||
| 117 | // Append volume information. |
||
| 118 | if (!empty($resArray['volume'])) { |
||
| 119 | $title .= ', '.$this->pi_getLL('volume').' '.$resArray['volume']; |
||
| 120 | } |
||
| 121 | // Is this document new or updated? |
||
| 122 | if ($resArray['crdate'] == $resArray['tstamp']) { |
||
| 123 | $title = $this->pi_getLL('new').' '.trim($title); |
||
| 124 | } else { |
||
| 125 | $title = $this->pi_getLL('update').' '.trim($title); |
||
| 126 | } |
||
| 127 | $item->appendChild($rss->createElement('title', htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'))); |
||
| 128 | // Add link. |
||
| 129 | $linkConf = [ |
||
| 130 | 'parameter' => $this->conf['targetPid'], |
||
| 131 | 'forceAbsoluteUrl' => 1, |
||
| 132 | 'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, ['id' => $resArray['uid']], '', TRUE, FALSE) |
||
| 133 | ]; |
||
| 134 | $item->appendChild($rss->createElement('link', htmlspecialchars($this->cObj->typoLink_URL($linkConf), ENT_NOQUOTES, 'UTF-8'))); |
||
| 135 | // Add author if applicable. |
||
| 136 | if (!empty($resArray['author'])) { |
||
| 137 | $item->appendChild($rss->createElement('author', htmlspecialchars($resArray['author'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 138 | } |
||
| 139 | // Add online publication date. |
||
| 140 | $item->appendChild($rss->createElement('pubDate', date('r', $resArray['crdate']))); |
||
| 141 | // Add internal record identifier. |
||
| 142 | $item->appendChild($rss->createElement('guid', htmlspecialchars($resArray['guid'], ENT_NOQUOTES, 'UTF-8'))); |
||
| 143 | $channel->appendChild($item); |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 | $root->appendChild($channel); |
||
| 148 | // Build XML output. |
||
| 149 | $rss->appendChild($root); |
||
| 150 | $content = $rss->saveXML(); |
||
| 151 | // Clean output buffer. |
||
| 152 | \TYPO3\CMS\Core\Utility\GeneralUtility::cleanOutputBuffers(); |
||
|
|
|||
| 153 | // Send headers. |
||
| 154 | header('HTTP/1.1 200 OK'); |
||
| 155 | header('Cache-Control: no-cache'); |
||
| 156 | header('Content-Length: '.strlen($content)); |
||
| 157 | header('Content-Type: application/rss+xml; charset=utf-8'); |
||
| 158 | header('Date: '.date('r', $GLOBALS['EXEC_TIME'])); |
||
| 159 | header('Expires: '.date('r', $GLOBALS['EXEC_TIME'])); |
||
| 160 | echo $content; |
||
| 161 | // Flush output buffer and end script processing. |
||
| 162 | ob_end_flush(); |
||
| 163 | exit; |
||
| 164 | } |
||
| 166 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.