Html::getCriterionForMassiveCheckboxes PHP Method

getCriterionForMassiveCheckboxes() static public method

Get the jquery criterion for massive checkbox update We can filter checkboxes by a container or by a tag. We can also select checkboxes that have a given tag and that are contained inside a container
static public getCriterionForMassiveCheckboxes ( array $options ) : the
$options array array of parameters: - tag_for_massive tag of the checkboxes to update - container_id if of the container of the checkboxes
return the javascript code for jquery criterion or empty string if it is not a massive update checkbox
    static function getCriterionForMassiveCheckboxes(array $options)
    {
        $params = array();
        $params['tag_for_massive'] = '';
        $params['container_id'] = '';
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                $params[$key] = $val;
            }
        }
        if (!empty($params['tag_for_massive']) || !empty($params['container_id'])) {
            // Filtering on the container !
            if (!empty($params['container_id'])) {
                $criterion = '#' . $params['container_id'] . ' ';
            } else {
                $criterion = '';
            }
            // We only want the checkbox input
            $criterion .= 'input[type="checkbox"]';
            // Only the given massive tag !
            if (!empty($params['tag_for_massive'])) {
                $criterion .= '[data-glpicore-cb-massive-tags~="' . $params['tag_for_massive'] . '"]';
            }
            // Only enabled checkbox
            $criterion .= ':enabled';
            return addslashes($criterion);
        }
        return '';
    }
Html