Skip to content

Commit 007311b

Browse files
author
eike
committedNov 24, 2018
[WIP] 8.7 and composer compatible
1 parent 2fb38c7 commit 007311b

11 files changed

+183
-79
lines changed
 

‎.php_cs

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/*
3+
* This file is part of the TYPO3 CMS project.
4+
*
5+
* It is free software; you can redistribute it and/or modify it under
6+
* the terms of the GNU General Public License, either version 2
7+
* of the License, or any later version.
8+
*
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*
12+
* The TYPO3 project - inspiring people to share!
13+
*/
14+
/**
15+
* This file represents the configuration for Code Sniffing PSR-2-related
16+
* automatic checks of coding guidelines
17+
* Install @fabpot's great php-cs-fixer tool via
18+
*
19+
* $ composer global require friendsofphp/php-cs-fixer
20+
*
21+
* And then simply run
22+
*
23+
* $ php-cs-fixer fix --config ../Build/.php_cs
24+
*
25+
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
26+
*
27+
* For more information read:
28+
* http://www.php-fig.org/psr/psr-2/
29+
* http://cs.sensiolabs.org
30+
*/
31+
if (PHP_SAPI !== 'cli') {
32+
die('This script supports command line usage only. Please check your command.');
33+
}
34+
// Define in which folders to search and which folders to exclude
35+
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
36+
$finder = PhpCsFixer\Finder::create()
37+
->in('.');
38+
// Return a Code Sniffing configuration using
39+
// all sniffers needed for PSR-2
40+
// and additionally:
41+
// - Remove leading slashes in use clauses.
42+
// - PHP single-line arrays should not have trailing comma.
43+
// - Single-line whitespace before closing semicolon are prohibited.
44+
// - Remove unused use statements in the PHP source code
45+
// - Ensure Concatenation to have at least one whitespace around
46+
// - Remove trailing whitespace at the end of blank lines.
47+
return PhpCsFixer\Config::create()
48+
->setRiskyAllowed(true)
49+
->setRules([
50+
'@PSR2' => true,
51+
'no_leading_import_slash' => true,
52+
'no_trailing_comma_in_singleline_array' => true,
53+
'no_singleline_whitespace_before_semicolons' => true,
54+
'no_unused_imports' => true,
55+
'concat_space' => ['spacing' => 'one'],
56+
'no_whitespace_in_blank_line' => true,
57+
'ordered_imports' => true,
58+
'single_quote' => true,
59+
'no_empty_statement' => true,
60+
'no_extra_consecutive_blank_lines' => true,
61+
'phpdoc_no_package' => true,
62+
'phpdoc_scalar' => true,
63+
'no_blank_lines_after_phpdoc' => true,
64+
'array_syntax' => ['syntax' => 'short'],
65+
'whitespace_after_comma_in_array' => true,
66+
'function_typehint_space' => true,
67+
'hash_to_slash_comment' => true,
68+
'no_alias_functions' => true,
69+
'lowercase_cast' => true,
70+
'no_leading_namespace_whitespace' => true,
71+
'native_function_casing' => true,
72+
'self_accessor' => true,
73+
'no_short_bool_cast' => true,
74+
'no_unneeded_control_parentheses' => true,
75+
'phpdoc_no_empty_return' => true,
76+
'phpdoc_trim' => true,
77+
'no_superfluous_elseif' => true,
78+
'no_useless_else' => true,
79+
])
80+
->setFinder($finder);

‎Classes/Controller/SearchController.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
namespace Yacy\Yacy\Controller;
2+
namespace Eike\Yacy\Controller;
33
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
44
/***************************************************************
55
*
66
* Copyright notice
77
*
8-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
8+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
99
*
1010
* All rights reserved
1111
*
@@ -35,11 +35,11 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
3535
/**
3636
* searchResultRepository
3737
*
38-
* @var \Yacy\Yacy\Domain\Repository\SearchRepository
38+
* @var \Eike\Yacy\Domain\Repository\SearchRepository
3939
* @inject
4040
*/
4141
protected $searchRepository = NULL;
42-
42+
4343
/**
4444
* @return void
4545
*/
@@ -60,10 +60,10 @@ public function initializeSearchAction() {
6060
* @return void
6161
*/
6262
public function indexAction() {
63-
/* @var $demand Yacy\Yacy\Domain\Model\Demand */
63+
/* @var $demand Eike\Yacy\Domain\Model\Demand */
64+
65+
$demand = $this->objectManager->get('Eike\Yacy\Domain\Model\Demand');
6466

65-
$demand = $this->objectManager->get('Yacy\Yacy\Domain\Model\Demand');
66-
6767
if($this->settings['domain']&&$this->settings['port']){
6868
$demand->setHost($this->settings['domain']);
6969
$demand->setPort($this->settings['port']);
@@ -76,39 +76,39 @@ public function indexAction() {
7676

7777
/**
7878
* Search Action
79-
* @param \Yacy\Yacy\Domain\Model\Demand $demand
79+
* @param \Eike\Yacy\Domain\Model\Demand $demand
8080
* @param integer $page
8181
*/
82-
public function searchAction(\Yacy\Yacy\Domain\Model\Demand $demand, $page = 1) {
82+
public function searchAction(\Eike\Yacy\Domain\Model\Demand $demand, $page = 1) {
8383
$itemsPerPage = 10;
84-
84+
8585
$demand->setStartRecord($itemsPerPage * ($page - 1));
86-
86+
8787
$results = $this->searchRepository->findDemandedViaYacyRss($demand);
88-
88+
8989
$resultsCount = $this->searchRepository->countAllRequested($demand);
90-
90+
9191
$pagination = $this->buildPagination($itemsPerPage,$page,$demand, $resultsCount);
92-
92+
9393
$this->view->assign('pagination', $pagination);
9494
$this->view->assign('demand', $demand);
9595
$this->view->assign('results', $results);
9696
$this->view->assign('resultsCount', $resultsCount);
9797
}
98-
98+
9999
/**
100-
*
100+
*
101101
* @param integer $itemsPerPage
102102
* @param integer $page
103-
* @param \Yacy\Yacy\Domain\Model\Demand $demand
103+
* @param \Eike\Yacy\Domain\Model\Demand $demand
104104
* @param integer $resultsCount
105105
* @return integer
106106
*/
107-
protected function buildPagination($itemsPerPage = 10, $page = 1 , \Yacy\Yacy\Domain\Model\Demand $demand, $resultsCount){
107+
protected function buildPagination($itemsPerPage = 10, $page = 1 , \Eike\Yacy\Domain\Model\Demand $demand, $resultsCount){
108108

109109
if(!$resultsCount <= $itemsPerPage) {
110110
//build the pagination
111-
111+
112112
//build paginator
113113
$pages = ceil($resultsCount / $itemsPerPage);
114114
//We limit the pagination menu to 11 pages
@@ -150,9 +150,9 @@ protected function buildPagination($itemsPerPage = 10, $page = 1 , \Yacy\Yacy\Do
150150
}
151151
//write the actual page for css
152152
$pagination['current'] = $page;
153-
153+
154154
return $pagination;
155155
}
156-
157156

158-
}
157+
158+
}

‎Classes/Domain/Model/Demand.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Yacy\Yacy\Domain\Model;
2+
namespace Eike\Yacy\Domain\Model;
33

44

55
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
@@ -8,7 +8,7 @@
88
*
99
* Copyright notice
1010
*
11-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
11+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
1212
*
1313
* All rights reserved
1414
*
@@ -117,10 +117,10 @@ class Demand extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject {
117117
* @var integer
118118
*/
119119
protected $port = 0;
120-
120+
121121
/**
122122
* The result page to reffer to
123-
*
123+
*
124124
* @var integer
125125
*/
126126
protected $resultPage = 0;
@@ -352,8 +352,8 @@ public function getPort() {
352352
public function setPort($port) {
353353
$this->port = $port;
354354
}
355-
356-
355+
356+
357357
/*
358358
* No real reason for having this but typo3 needs it in some way
359359
*/
@@ -363,7 +363,7 @@ public function setPort($port) {
363363
*/
364364
public function getUid() {
365365
}
366-
366+
367367
/**
368368
* Sets the port
369369
*
@@ -372,20 +372,20 @@ public function getUid() {
372372
*/
373373
public function setUid($port) {
374374
}
375-
375+
376376
/**
377-
*
377+
*
378378
* @return integer
379379
*/
380380
public function getResultPage(){
381381
return $this->resultPage;
382382
}
383-
383+
384384
/**
385-
*
385+
*
386386
* @param integer $resultPage
387387
*/
388388
public function setResultPage($resultPage){
389389
$this->resultPage = $resultPage;
390390
}
391-
}
391+
}

‎Classes/Domain/Model/SearchResult.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
namespace Yacy\Yacy\Domain\Model;
2+
namespace Eike\Yacy\Domain\Model;
33

44

55
/***************************************************************
66
*
77
* Copyright notice
88
*
9-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
9+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
1010
*
1111
* All rights reserved
1212
*
@@ -370,4 +370,4 @@ public function setGuid($guid) {
370370
$this->guid = $guid;
371371
}
372372

373-
}
373+
}

‎Classes/Domain/Repository/SearchRepository.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
namespace Yacy\Yacy\Domain\Repository;
2+
namespace Eike\Yacy\Domain\Repository;
33
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
44
use TYPO3\CMS\Core\Utility\GeneralUtility;
55
/***************************************************************
66
*
77
* Copyright notice
88
*
9-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
9+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
1010
*
1111
* All rights reserved
1212
*
@@ -31,18 +31,18 @@
3131
* The repository for SearchResults
3232
*/
3333
class SearchRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
34-
35-
36-
37-
public function findDemandedViaYacyRss(\Yacy\Yacy\Domain\Model\Demand $demand, $page = 1){
38-
$xml = $this->getXmlFromYacyViaRss($demand);
39-
34+
35+
36+
37+
public function findDemandedViaYacyRss(\Eike\Yacy\Domain\Model\Demand $demand, $page = 1){
38+
$xml = $this->getXmlFromYacyViaRss($demand);
39+
4040
/* @var $searchResults \TYPO3\CMS\Extbase\Persistence\ObjectStorage */
4141
$searchResults = $this->objectManager->get('\TYPO3\CMS\Extbase\Persistence\ObjectStorage');
42-
42+
4343
foreach ($xml->channel->item as $item){
44-
/* @var $searchResult \Yacy\Yacy\Domain\Model\SearchResult */
45-
$searchResult = $this->objectManager->get('\Yacy\Yacy\Domain\Model\SearchResult');
44+
/* @var $searchResult \Eike\Yacy\Domain\Model\SearchResult */
45+
$searchResult = $this->objectManager->get('\Eike\Yacy\Domain\Model\SearchResult');
4646
$searchResult->setTitle((string)$item->title);
4747
$searchResult->setPubDate((string)$item->pubDate);
4848
$searchResult->setDescription((string)$item->description);
@@ -51,15 +51,15 @@ public function findDemandedViaYacyRss(\Yacy\Yacy\Domain\Model\Demand $demand, $
5151
}
5252
return $searchResults;
5353
}
54-
55-
public function countAllRequested(\Yacy\Yacy\Domain\Model\Demand $demand){
54+
55+
public function countAllRequested(\Eike\Yacy\Domain\Model\Demand $demand){
5656
$xml = $this->getXmlFromYacyViaRss($demand);
5757
return (int)$xml->channel->children("opensearch", true)->totalResults; ;
5858
}
59-
60-
protected function getXmlFromYacyViaRss(\Yacy\Yacy\Domain\Model\Demand $demand){
59+
60+
protected function getXmlFromYacyViaRss(\Eike\Yacy\Domain\Model\Demand $demand){
6161
$interfaceName = "yacysearch.rss";
62-
62+
6363
//Options that needs to be set.
6464
$url = "http://".$demand->getHost().':'.$demand->getPort().'/';
6565
$url = $url.$interfaceName;
@@ -69,8 +69,8 @@ protected function getXmlFromYacyViaRss(\Yacy\Yacy\Domain\Model\Demand $demand){
6969
$url = $url.'&startRecord='.$demand->getStartRecord();
7070
}
7171
return new \SimpleXMLElement($url, $options, TRUE, $ns, $is_prefix);
72-
72+
7373
}
7474

75-
76-
}
75+
76+
}

‎Tests/Unit/Controller/SearchResultControllerTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2-
namespace Yacy\Yacy\Tests\Unit\Controller;
2+
namespace Eike\Yacy\Tests\Unit\Controller;
33
/***************************************************************
44
* Copyright notice
55
*
6-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
7-
*
6+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
7+
*
88
* All rights reserved
99
*
1010
* This script is part of the TYPO3 project. The TYPO3 project is
@@ -25,19 +25,19 @@
2525
***************************************************************/
2626

2727
/**
28-
* Test case for class Yacy\Yacy\Controller\SearchResultController.
28+
* Test case for class Eike\Yacy\Controller\SearchResultController.
2929
*
30-
* @author Eike Starkmann <eikestarkmann@web.de>
30+
* @author Eike Starkmann <eike.starkmann@posteo.de>
3131
*/
3232
class SearchResultControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
3333

3434
/**
35-
* @var \Yacy\Yacy\Controller\SearchResultController
35+
* @var \Eike\Yacy\Controller\SearchResultController
3636
*/
3737
protected $subject = NULL;
3838

3939
protected function setUp() {
40-
$this->subject = $this->getMock('Yacy\\Yacy\\Controller\\SearchResultController', array('redirect', 'forward', 'addFlashMessage'), array(), '', FALSE);
40+
$this->subject = $this->getMock('Eike\\Yacy\\Controller\\SearchResultController', array('redirect', 'forward', 'addFlashMessage'), array(), '', FALSE);
4141
}
4242

4343
protected function tearDown() {

‎Tests/Unit/Domain/Model/DemandTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace Yacy\Yacy\Tests\Unit\Domain\Model;
3+
namespace Eike\Yacy\Tests\Unit\Domain\Model;
44

55
/***************************************************************
66
* Copyright notice
77
*
8-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
8+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
99
*
1010
* All rights reserved
1111
*
@@ -27,21 +27,21 @@
2727
***************************************************************/
2828

2929
/**
30-
* Test case for class \Yacy\Yacy\Domain\Model\Demand.
30+
* Test case for class \Eike\Yacy\Domain\Model\Demand.
3131
*
3232
* @copyright Copyright belongs to the respective authors
3333
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
3434
*
35-
* @author Eike Starkmann <eikestarkmann@web.de>
35+
* @author Eike Starkmann <eike.starkmann@posteo.de>
3636
*/
3737
class DemandTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
3838
/**
39-
* @var \Yacy\Yacy\Domain\Model\Demand
39+
* @var \Eike\Yacy\Domain\Model\Demand
4040
*/
4141
protected $subject = NULL;
4242

4343
protected function setUp() {
44-
$this->subject = new \Yacy\Yacy\Domain\Model\Demand();
44+
$this->subject = new \Eike\Yacy\Domain\Model\Demand();
4545
}
4646

4747
protected function tearDown() {

‎Tests/Unit/Domain/Model/SearchResultTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace Yacy\Yacy\Tests\Unit\Domain\Model;
3+
namespace Eike\Yacy\Tests\Unit\Domain\Model;
44

55
/***************************************************************
66
* Copyright notice
77
*
8-
* (c) 2014 Eike Starkmann <eikestarkmann@web.de>
8+
* (c) 2018 Eike Starkmann <eike.starkmann@posteo.de>
99
*
1010
* All rights reserved
1111
*
@@ -27,21 +27,21 @@
2727
***************************************************************/
2828

2929
/**
30-
* Test case for class \Yacy\Yacy\Domain\Model\SearchResult.
30+
* Test case for class \Eike\Yacy\Domain\Model\SearchResult.
3131
*
3232
* @copyright Copyright belongs to the respective authors
3333
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
3434
*
35-
* @author Eike Starkmann <eikestarkmann@web.de>
35+
* @author Eike Starkmann <eike.starkmann@posteo.de>
3636
*/
3737
class SearchResultTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
3838
/**
39-
* @var \Yacy\Yacy\Domain\Model\SearchResult
39+
* @var \Eike\Yacy\Domain\Model\SearchResult
4040
*/
4141
protected $subject = NULL;
4242

4343
protected function setUp() {
44-
$this->subject = new \Yacy\Yacy\Domain\Model\SearchResult();
44+
$this->subject = new \Eike\Yacy\Domain\Model\SearchResult();
4545
}
4646

4747
protected function tearDown() {

‎composer.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "eike/yacy",
3+
"type": "typo3-cms-extension",
4+
"description": "Integrate yacy",
5+
"license": [
6+
"GPL-2.0+"
7+
],
8+
"keywords": [
9+
"integration",
10+
"yacy",
11+
"search"
12+
],
13+
"require": {
14+
"typo3/cms": "^8.7"
15+
},
16+
"replace": {
17+
"yacy": "self.version"
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"Eike\\Yacy\\": "Classes"
22+
}
23+
}
24+
}

‎ext_localconf.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
}
55

66
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
7-
'Yacy.' . $_EXTKEY,
7+
'Eike.' . $_EXTKEY,
88
'Search',
99
array(
1010
'Search' => 'index, search',
11-
11+
1212
),
1313
// non-cacheable actions
1414
array(
1515
'Search' => 'search',
16-
16+
1717
)
1818
);

‎ext_tables.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
7-
'Yacy.' . $_EXTKEY,
7+
'Eike.' . $_EXTKEY,
88
'Search',
99
'Yacy'
1010
);

0 commit comments

Comments
 (0)
Please sign in to comment.