Commit f4cdaca5 authored by Jeroen's avatar Jeroen

Changed protected functions to private and $this-> to self::

parent 766edae2
Pipeline #1353 passed with stage
in 1 second
......@@ -8,7 +8,7 @@ class Search{
* @param array $operators Array of all the specifiers to look for
* @return string $return The operator, if it's found (else False)
*/
protected function parseOperator ( $searchterm , $operators ) {
private function parseOperator ( $searchterm , $operators ) {
$return = false;
foreach ( $operators as $o ) {
if ( strpos ( $searchterm , $o ) ) {
......@@ -29,7 +29,7 @@ class Search{
* @param string $searchterm The user's search query
* @return string $category If the category is filtered out, return it.
*/
protected function filtercategory ( $searchterm ) {
private function filtercategory ( $searchterm ) {
$arr = false;
$searchterm = strtolower ( $searchterm ) ;
......@@ -59,7 +59,7 @@ class Search{
* @param string $searchterm The user's search query
* @return string $specifier If the category category is filtered out, return it.
*/
protected function filterSpecifier ( $searchterm ) {
private function filterSpecifier ( $searchterm ) {
$arr = false;
$searchterm = strtolower ( $searchterm ) ;
......@@ -84,7 +84,7 @@ class Search{
* @param string $category The filtered out category
* @return string $result If a column matches the category, return the column name, else return false
*/
protected function searchForCategory ( $category , $db ) {
private function searchForCategory ( $category , $db ) {
$table_columns = array();
$result = false;
......@@ -115,7 +115,7 @@ class Search{
* @param int $expertise The id of the row in Expertise
* @return Array $orgs An array with the ids of organisations that match the criterea
*/
protected function getExpertiseOrganisation ( $expertise ) {
private function getExpertiseOrganisation ( $expertise ) {
$employees = array();
$stmt = DB::conn()->prepare( 'SELECT employee FROM ExpertiseEmployee WHERE expertise=?' );
$stmt->bind_param( 'i' , $expertise );
......@@ -181,7 +181,7 @@ class Search{
$stmt->close();
if ( !empty ( $countries ) ) {
$result = array_diff( $this->getCountryIds(), $countries );
$result = array_diff( self::getCountryIds(), $countries );
return $result;
} else {
return false;
......@@ -197,7 +197,7 @@ class Search{
* @param int $expertise The parsed 'translation' of the expertise
* @return array $orgs || $countries Array of organisation id's or country id's
*/
protected function getExpertiseOrganisationCountry ( $expertise ) {
private function getExpertiseOrganisationCountry ( $expertise ) {
$employees = array();
$stmt = DB::conn()->prepare( 'SELECT employee FROM ExpertiseEmployee WHERE expertise=?' );
$stmt->bind_param( 'i' , $expertise );
......@@ -299,15 +299,15 @@ class Search{
* @param string $operator The operator that the user used in the search query (like '=', '>' or '<')
* @return array $organisations Array of the id's from organisation that match the demands (could be empty if none qualify)
*/
protected function getcategoryContent ( $category , $value , $operator ) {
private function getcategoryContent ( $category , $value , $operator ) {
// Define the organisations array
$organisations = array();
if ( $category == 'expertiseDescription' ) {
return $this->getExpertiseOrganisation( $value );
return self::getExpertiseOrganisation( $value );
} else if ( $category == 'council_of_europe' ) {
return $this->getOrganisationsInCouncil( $value );
return self::getOrganisationsInCouncil( $value );
} else {
// Use a switch to use different SQL query's, depending on the operator
// The operator can't be 'dynamicly' specified in the query, so this is a workaround
......@@ -387,7 +387,7 @@ class Search{
* Put it in the $results array and return it.
* @return array $results Array with country-id's of countries that only have non-EDRi-member organisations
*/
protected function getCountriesWithoutEdriMembers(){
private function getCountriesWithoutEdriMembers(){
$results = array();
$countryWithout = array();
$countryWith = array();
......@@ -432,16 +432,16 @@ class Search{
* @param string $operator The operator that the user used in the search query (like '=', '>' or '<')
* @return array $countries Array of the id's of countries in which organisations are based in that match the demands (could be empty if none qualify)
*/
protected function getOrganisationCountry ( $category , $value , $operator ) {
private function getOrganisationCountry ( $category , $value , $operator ) {
$countries = array();
if ( $category == 'expertiseDescription' ) {
return $this->getExpertiseOrganisationCountry($value);
return self::getExpertiseOrganisationCountry($value);
} else if ( $category == 'id' && $value == 'none' ) {
return $this->getCountriesWithoutOrganisations();
return self::getCountriesWithoutOrganisations();
} else if ( $category == 'edri_status' && $value == 'none' ){
return $this->getCountriesWithoutEdriMembers();
return self::getCountriesWithoutEdriMembers();
} else if ( $category == 'council_of_europe' ) {
return $this->getCountriesInCouncil( $value );
return self::getCountriesInCouncil( $value );
} else if ( $category != 'show' ) {
// Use a switch to use different SQL query's, depending on the operator
......@@ -539,31 +539,31 @@ class Search{
// If an operator is used in the search query, do a special search.
// Otherwise just search for a match between the search query and a organisation name
if ( $this->parseOperator( $searchterm , $operatorArray ) !== false ) {
if ( self::parseOperator( $searchterm , $operatorArray ) !== false ) {
$searchterm = str_replace(' ' , '' , $searchterm );
$operator = $this->parseOperator( $searchterm , $operatorArray );
$operator = self::parseOperator( $searchterm , $operatorArray );
if ( $operator !== false ) {
$categoryFilter = $this->filtercategory( $searchterm );
$categoryFilter = self::filtercategory( $searchterm );
if ( $categoryFilter !== false ) {
$column = $this->searchForCategory( $syn->parseSynonym( $categoryFilter) , $database );
$column = self::searchForCategory( $syn->parseSynonym( $categoryFilter) , $database );
if ( $column !== false ) {
if ( $column == 'expertiseDescription' ) {
$parameter = $syn->parseSynonymWildcard( $this->filterSpecifier( $searchterm ) );
$parameter = $syn->parseSynonymWildcard( self::filterSpecifier( $searchterm ) );
} else {
$parameter = $syn->parseSynonym( $this->filterSpecifier( $searchterm ) );
$parameter = $syn->parseSynonym( self::filterSpecifier( $searchterm ) );
}
if ( $parameter !== false ) {
return $this->getcategoryContent( $column , $parameter , $operator );
return self::getcategoryContent( $column , $parameter , $operator );
} else {
return false;
......@@ -629,35 +629,35 @@ class Search{
$database = DB::getDatabaseName();
if ( $this->parseOperator( $searchterm , $operatorArray ) !== false ) {
if ( self::parseOperator( $searchterm , $operatorArray ) !== false ) {
$searchterm = str_replace( ' ' , '' , $searchterm );
$operator = $this->parseOperator( $searchterm , $operatorArray );
$operator = self::parseOperator( $searchterm , $operatorArray );
if ( $operator !== false ) {
$categoryFilter = $this->filtercategory( $searchterm );
$categoryFilter = self::filtercategory( $searchterm );
if ( $categoryFilter !== false ) {
if ( $categoryFilter === 'show' ) {
$column = 'show';
} else {
$column = $this->searchForCategory( $syn->parseSynonym( $categoryFilter ) , $database );
$column = self::searchForCategory( $syn->parseSynonym( $categoryFilter ) , $database );
}
if ( $column !== false ) {
if ( $column == 'expertiseDescription' ) {
$parameter = $syn->parseSynonymWildcard( $this->filterSpecifier( $searchterm ) );
$parameter = $syn->parseSynonymWildcard( self::filterSpecifier( $searchterm ) );
} else {
$parameter = $syn->parseSynonym( $this->filterSpecifier( $searchterm ) );
$parameter = $syn->parseSynonym( self::filterSpecifier( $searchterm ) );
}
if ( $parameter !== false ) {
return $this->getOrganisationCountry( $column , $parameter , $operator );
return self::getOrganisationCountry( $column , $parameter , $operator );
} else {
return false;
......
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