Get criteria description for displaying to users

@return string
337988
public function get_details($short = '') {
        global $DB, $OUTPUT;
        $output = array();
        foreach ($this->params as $p) {
            $mod = self::get_mod_instance($p['module']);
            if (!$mod) {
                $str = $OUTPUT->error_text(get_string('error:nosuchmod', 'badges'));
            } else {
                $str = html_writer::tag('b', '"' . get_string('modulename', $mod->modname) . ' - ' . $mod->name . '"');
                if (isset($p['bydate'])) {
                    $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig')));
                }
            }
            $output[] = $str;
        }

        if ($short) {
            return implode(', ', $output);
        } else {
            return html_writer::alist($output, array(), 'ul');
        }
    }
611626
public function toString()
    {
        $sb = 'Criteria:';
        try {

            $params = [];
            $sb .= "\nSQL (may not be complete): ".$this->createSelectSql($params);

            $sb .= "\nParams: ";
            $paramstr = [];
            foreach ($params as $param) {
                $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true);
            }
            $sb .= implode(', ', $paramstr);

        } catch (\Exception $exc) {
            $sb .= '(Error: ' . $exc->getMessage() . ')';
        }

        return $sb;
    }
601412
public function get_criteria_badge_class() {
        $badge = new badge($this->_data->id);
        $narrative = $badge->markdown_badge_criteria();
        if (!empty($narrative)) {
            $criteria = array();
            $criteria['id'] = $this->_url->out(false);
            $criteria['narrative'] = $narrative;
            return $criteria;
        } else {
            return $this->_url->out(false);
        }
    }
62381
public function buildCriteria()
    {
        $criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME);

        if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_ID, $this->customer_id);
        if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $this->customer_group_id);

        return $criteria;
    }
663667
public function actionInscription()
    {
        $form = $this->getInscriptionForm();
        if ($form->isValid()) {
            $user = $this->getUserModel()
                ->set('login', $form->login)
                ->set('password', $form->password);
            try {
                $saved = FALSE;
                $saved = $user->save();
            } catch (\PDOException $e) {
            }
            if ($saved) {
                $this->login($user);
                Notif::success(sprintf(static::MSG_INSCRIPTION_VALID, $form->login));
                \Staq\Util::httpRedirectUri($this->getRedirectUri());
            } else {
                Notif::error(static::MSG_INSCRIPTION_KO);
            }
        }
        $view = $this->createView('inscription');
        $view['form'] = $form;
        $view['redirect'] = $this->getRedirectUri();
        return $view;
    }
961757
public function get_completed_criteria_sql() {
        $join = '';
        $where = '';
        $params = array();

        if ($this->method == BADGE_CRITERIA_AGGREGATION_ANY) {
            // User has received ANY of the required badges.
            $join = " LEFT JOIN {badge_issued} bi2 ON bi2.userid = u.id";
            $where = "AND (";
            $i = 0;
            foreach ($this->params as $param) {
                if ($i == 0) {
                    $where .= ' bi2.badgeid = :badgeid'.$i;
                } else {
                    $where .= ' OR bi2.badgeid = :badgeid'.$i;
                }
                $params['badgeid'.$i] = $param['badge'];
                $i++;
            }
            $where .= ") ";
            return array($join, $where, $params);
        } else {
            // User has received ALL of the required badges.
            $join = " LEFT JOIN {badge_issued} bi2 ON bi2.userid = u.id";
            $i = 0;
            foreach ($this->params as $param) {
                $i++;
                $where = ' AND bi2.badgeid = :badgeid'.$i;
                $params['badgeid'.$i] = $param['badge'];
            }
            return array($join, $where, $params);
        }
    }
1084405
protected function getCriteria()
    {
        $result = array();

        if($this->filters){
            $result['filters'] = $this->filters;
        }

        if($this->limit!==null){
            $result['limit'] = $this->limit;
        }

        if($this->order!==null){
            $result['order'] = $this->order;
        }

        if($this->page!==null){
            $result['page'] = $this->page;
        }

        return $result;
    }
285458
public function buildCriteria()
    {
        $criteria = new Criteria(RolePeer::DATABASE_NAME);

        if ($this->isColumnModified(RolePeer::ID)) $criteria->add(RolePeer::ID, $this->id);
        if ($this->isColumnModified(RolePeer::NAME)) $criteria->add(RolePeer::NAME, $this->name);
        if ($this->isColumnModified(RolePeer::ROLE)) $criteria->add(RolePeer::ROLE, $this->role);

        return $criteria;
    }
1265307
public function phpdocDescription()
    {
        $summary = $this->phpdocSummary();
        if (!$summary) {
            return UNDEFINED;
        }
        $description = trim(substr($this->phpdocContent(), strlen($summary)));
        if ($description === '') {
            return UNDEFINED;
        }

        return $description;
    }
878863
public function getSummary()
    {
        $list = ArrayList::create();
        foreach ($this->searchParams as $searchField => $searchValue) {
            if (empty($searchValue)) {
                continue;
            }
            $filter = $this->getFilter($searchField);
            if (!$filter) {
                continue;
            }

            $field = $this->fields->fieldByName($filter->getFullName());
            if (!$field) {
                continue;
            }

            // For dropdowns, checkboxes, etc, get the value that was presented to the user
            // e.g. not an ID
            if ($field instanceof SelectField) {
                $source = $field->getSource();
                if (isset($source[$searchValue])) {
                    $searchValue = $source[$searchValue];
                }
            } else {
                // For checkboxes, it suffices to simply include the field in the list, since it's binary
                if ($field instanceof CheckboxField) {
                    $searchValue = null;
                }
            }

            $list->push(ArrayData::create([
                'Field' => $field->Title(),
                'Value' => $searchValue,
            ]));
        }

        return $list;
    }
441338
public function buildCriteria()
    {
        $criteria = new Criteria(PersonFunctionLinkTableMap::DATABASE_NAME);

        if ($this->isColumnModified(PersonFunctionLinkTableMap::ID)) $criteria->add(PersonFunctionLinkTableMap::ID, $this->id);
        if ($this->isColumnModified(PersonFunctionLinkTableMap::PERSON_ID)) $criteria->add(PersonFunctionLinkTableMap::PERSON_ID, $this->person_id);
        if ($this->isColumnModified(PersonFunctionLinkTableMap::FUNCTION_ID)) $criteria->add(PersonFunctionLinkTableMap::FUNCTION_ID, $this->function_id);
        if ($this->isColumnModified(PersonFunctionLinkTableMap::CREATED_AT)) $criteria->add(PersonFunctionLinkTableMap::CREATED_AT, $this->created_at);
        if ($this->isColumnModified(PersonFunctionLinkTableMap::UPDATED_AT)) $criteria->add(PersonFunctionLinkTableMap::UPDATED_AT, $this->updated_at);

        return $criteria;
    }
382398
public function getDescription()
    {
        if(array_key_exists(self::ITEM_DESCRIPTION, $this->_itemData)) {
            return (string) $this->_itemData[self::ITEM_DESCRIPTION];
        }
        return null;
    }
1100075
private function getCriteriaAsSting(array $criteria): string
    {
        $criteriaString = '';
        foreach ($criteria as $key => $value) {
            $criteriaString .= $key.': '.$value.', ';
        }

        return substr($criteriaString, 0, -2);
    }
333312
private function getMetaDescription(): string {
        $desc = $this->getMetaContent($this->article()->getDoc(), 'name', 'description');

        if (empty($desc)) {
            $desc = $this->getMetaContent($this->article()->getDoc(), 'property', 'og:description');
        }

        if (empty($desc)) {
            $desc = $this->getMetaContent($this->article()->getDoc(), 'name', 'twitter:description');
        }

        return trim($desc);
    }
1370483
public function display()
    {
        if (!$this->isVisible())
            return "";

        $content = \mpf\web\helpers\Html::get()->tag('span', $this->getIcon() . $this->translate($this->label), $this->labelHtmlOptions);
        $submenu = "";
        if (count($this->items)) {
            $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'm-menu-dropdown';
            $anySelected = false;
            $anyVisible = false;
            foreach ($this->items as $item) {
                /* @var $item Label */
                $submenu .= $item->display();
                $anySelected = $anySelected || $item->isSelected();
                $anyVisible = $anyVisible || $item->isVisible();
            }
            if ($anyVisible)
                $submenu = \mpf\web\helpers\Html::get()->tag('ul', $submenu);
            else
                $submenu = "";
            if ($anySelected) {
                if (isset($this->htmlOptions['class'])) {
                    $this->htmlOptions['class'] .= ' selected';
                } else {
                    $this->htmlOptions['class'] = 'selected';
                }
            }
        }
        return \mpf\web\helpers\Html::get()->tag('li', $content . $submenu, $this->htmlOptions);
    }
537230
protected function getSelectionCriteria()
    {
        $options = $this->request->getParameters();
        $payload = $this->getPayloadData();
        $options = array_merge($options, $payload);
        $this->request->setParameters($options);

        $criteria = [
            'params' => []
        ];

        if (null !== ($value = $this->request->getParameter(ApiOptions::FIELDS))) {
            $criteria['select'] = explode(',', $value);
        } else {
            $criteria['select'] = ['*'];
        }

        if (null !== ($value = $this->request->getPayloadData(ApiOptions::PARAMS))) {
            $criteria['params'] = $value;
        }

        if (null !== ($value = $this->request->getParameter(ApiOptions::FILTER))) {
            /** @type TableSchema $schema */
            /** @noinspection PhpUndefinedMethodInspection */
            $schema = $this->getModel()->getTableSchema();
            $native = $this->convertFilterToNative($value, $criteria['params'], [], $schema->getColumns());
            $criteria['condition'] = $native['where'];
            if (is_array($native['params'])) {
                if (is_array($criteria['params'])) {
                    $criteria['params'] = array_merge($criteria['params'], $native['params']);
                } else {
                    $criteria['params'] = $native['params'];
                }
            }
            //	Add current user ID into parameter array if in condition, but not specified.
            if (false !== stripos($value, ':user_id')) {
                if (!isset($criteria['params'][':user_id'])) {
                    $criteria['params'][':user_id'] = SessionUtility::getCurrentUserId();
                }
            }
        }

        $value = intval($this->request->getParameter(ApiOptions::LIMIT));
        $maxAllowed = $this->getMaxRecordsReturnedLimit();
        if (($value < 1) || ($value > $maxAllowed)) {
            // impose a limit to protect server
            $value = $maxAllowed;
        }
        $criteria['limit'] = $value;

        // merge in possible payload options
        $optionNames = [
            ApiOptions::OFFSET,
            ApiOptions::ORDER,
            ApiOptions::GROUP,
        ];

        foreach ($optionNames as $option) {
            if (null !== $value = $this->request->getParameter($option)) {
                $criteria[$option] = $value;
            } elseif (!empty($otherNames = ApiOptions::getAliases($option))) {
                foreach ($otherNames as $other) {
                    if (null !== $value = $this->request->getParameter($other)) {
                        $criteria[$option] = $value;
                    } elseif (null !== $value = $this->request->getPayloadData($other)) {
                        $criteria[$option] = $value;
                    }
                }
            }
            if (!isset($criteria[$option]) && ((null !== $value = $this->request->getPayloadData($option)))) {
                $criteria[$option] = $value;
            }
        }

        return $criteria;
    }
984493
protected function getCriteriaToApply()
    {
        // get the standard criteria
        $criteriaToApply = $this->getCriteria();

        // overrule them with criteria to be applied once
        if ( ! $this->onceCriteria->isEmpty()) {

            foreach ($this->onceCriteria as $onceKey => $onceCriteria) {

                // if there is no key, we can only add the criteria
                if (is_numeric($onceKey)) {

                    $criteriaToApply->push($onceCriteria);
                    continue;
                }

                // if there is a key, override or remove
                // if Null, remove criteria
                if (empty($onceCriteria) || is_a($onceCriteria, NullCriteria::class)) {

                    $criteriaToApply->forget($onceKey);
                    continue;
                }

                // otherwise, overide the criteria
                $criteriaToApply->put($onceKey, $onceCriteria);
            }
        }

        return $criteriaToApply;
    }