ArticleImage::ProcessListOrder PHP Method

ProcessListOrder() private static method

Processes an order directive coming from template tags.
private static ProcessListOrder ( array $p_order ) : array
$p_order array The array of order directives in the format: array('field'=>field_name, 'dir'=>order_direction) field_name can take one of the following values: bynumber, byname, bydate, bycreationdate, bypublishdate, bypublication, byissue, bysection, bylanguage, bysectionorder, bypopularity, bycomments order_direction can take one of the following values: asc, desc
return array The array containing processed values of the condition
    private static function ProcessListOrder(array $p_order)
    {
        $order = array();
        foreach ($p_order as $orderDesc) {
            $field = $orderDesc['field'];
            $direction = $orderDesc['dir'];
            $dbField = null;
            switch (strtolower($field)) {
                case 'default':
                case 'bynumber':
                    $dbField = 'ArticleImages.Number';
                    break;
                case 'bydescription':
                    $dbField = 'Images.Description';
                    break;
                case 'byphotographer':
                    $dbField = 'Images.Photographer';
                    break;
                case 'bydate':
                    $dbField = 'Images.Date';
                    break;
                case 'bylastupdate':
                    $dbField = 'Images.LastModified';
                    break;
            }
            if (!is_null($dbField)) {
                $direction = !empty($direction) ? $direction : 'asc';
                $order[] = array('field' => $dbField, 'dir' => $direction);
            }
        }
        return $order;
    }