Plugin Directory

Changeset 1515807


Ignore:
Timestamp:
10/16/2016 09:47:57 AM (9 years ago)
Author:
AeonOfTime
Message:

Added the possibility to select ships by mass.

Location:
eve-shipinfo/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • eve-shipinfo/trunk/classes/EVEShipInfo/Collection.php

    r1515539 r1515807  
    420420        return '';
    421421    }
     422
     423    protected $propertyColumns = array(
     424        'mass',
     425        'volume',
     426        'capacity',
     427    );
     428   
     429   /**
     430    * Gets the minimum and maximum values for the specified ship property
     431    * from the database.
     432    *
     433    * @param string $name
     434    * @return NULL|array An array with two keys, "min" and "max"
     435    */
     436    public function getPropertyValueRange($name)
     437    {
     438        if(!in_array($name, $this->propertyColumns)) {
     439            return null;
     440        }
     441       
     442        $entry = $this->plugin->dbFetch(
     443            "SELECT
     444                MAX(".$name.") AS maximum,
     445                MIN(".$name.") AS minimum
     446            FROM
     447                ".$this->plugin->getTableName('ships').""   
     448        );
     449       
     450        if(is_array($entry) && isset($entry['maximum'])) {
     451            return array(
     452                'min' => $entry['minimum'],
     453                'max' => $entry['maximum']
     454            );
     455        }
     456       
     457        return null;
     458    }
    422459}
  • eve-shipinfo/trunk/classes/EVEShipInfo/Collection/Filter.php

    r1515539 r1515807  
    872872    public function selectLauncherSlots($expression) { return $this->selectAttribute('launcherSlotsLeft', 'numeric', $expression); }
    873873    public function selectTechLevel($expression) { return $this->selectAttribute('techLevel', 'numeric', $expression); }
     874    public function selectMass($expression) { return $this->selectProperty('mass', 'numeric', $expression); }
    874875   
    875876    protected $search;
  • eve-shipinfo/trunk/classes/EVEShipInfo/Shortcode/ShipList.php

    r1515539 r1515807  
    7272            'turrets' => '',
    7373            'techlevel' => '',
    74             'ships' => ''
     74            'ships' => '',
     75            'mass' => ''
    7576        );
    7677    }
     
    8081        $filter = $this->collection->createFilter();
    8182        $list = $this->collection->createList($filter);
    82          
     83
     84        $massRange = $this->collection->getPropertyValueRange('mass');
     85       
    8386        $attribs = array(
    8487            'settings' => array(
     
    315318                        'type' => 'text',
    316319                        'values' => $this->describeNumericExpressions()
    317                     )
     320                    ),
     321                    'mass' => array(
     322                        'descr' => __('The ship\'s mass to limit the list to.', 'eve-shipinfo').' '.
     323                                   sprintf(
     324                                        __('The values range from %1$s to %2$s according to the current database.', 'eve-shipinfo'),
     325                                        number_format($massRange['min'], 0, ' ', ' '),
     326                                        number_format($massRange['max'], 0, ' ', ' ')
     327                                    ).' '.
     328                                   __('This allows complex selections using expressions.', 'eve-shipinfo'),
     329                        'optional' => true,
     330                        'type' => 'text',
     331                        'values' => $this->describeNumericExpressions()
     332                    ),
    318333                )
    319334            )
     
    520535            $this->filter->selectTechLevel($techlevel);
    521536        }
     537       
     538        $mass = trim($this->getAttribute('mass'));
     539        if(!empty($mass)) {
     540            $this->filter->selectMass($mass);
     541        }
    522542    }
    523543   
  • eve-shipinfo/trunk/readme.txt

    r1515539 r1515807  
    5555= 2.1 =
    5656* Added the "ships" filter to the list shortcodes to display specific ships by name or id
     57* Added the "mass" filter to the list shortcodes to limit the list by ship mass
    5758
    5859= 2.0 =
Note: See TracChangeset for help on using the changeset viewer.