Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_tabs_with_usage_count()

Description

Get tabs (paged) based on some criteria (currently only order by and limit).

Parameters

ColumnTypeDefaultDescription
$criteria array Array holding criteria information (order_by and limit).

Return

array {@see sql_limit_with_total_count()}

Location

include/tab_functions.php lines 43 to 66

Definition

 
function get_tabs_with_usage_count(array $criteria)
    {
    
$order_by = isset($criteria['order_by'][0]) && in_array($criteria['order_by'][0], ['order_by''ref'])
                ? 
$criteria['order_by'][0]
                : 
'order_by';
    
$sort = isset($criteria['order_by'][1]) && validate_sort_value($criteria['order_by'][1])
            ? 
$criteria['order_by'][1]
            : 
'ASC';

    
$per_page $criteria['limit']['per_page'] ?? null;
    
$offset $criteria['limit']['offset'] ?? null;

    
$query = new PreparedStatementQuery(
        
"SELECT t.ref,
                t.`name`,
                t.order_by,
                (SELECT count(ref) FROM resource_type_field WHERE tab = t.ref) AS usage_rtf,
                (SELECT count(ref) FROM resource_type WHERE tab = t.ref) AS usage_rt
           FROM tab AS t
           ORDER BY 
{$order_by} {$sort}"
    
);

    return 
sql_limit_with_total_count($query$per_page$offset);
    }

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 16th May 2024 18:10 Europe/London time.