@param bool $selected_for_export (optional)

@return int
336348
static function wordCount( $selected_for_export = false ) {
		$wc = 0;
		$wc_selected_for_export = 0;
		foreach ( static::getBookStructure() as $key => $section ) {
			if ( $key === 'front-matter' || $key === 'back-matter' ) {
				foreach ( $section as $val ) {
					$wc += $val['word_count'];
					if ( $val['export'] ) {
						$wc_selected_for_export += $val['word_count'];
					}
				}
			}
			if ( $key === 'part' ) {
				foreach ( $section as $part ) {
					foreach ( $part['chapters'] as $val ) {
						$wc += $val['word_count'];
						if ( $val['export'] ) {
							$wc_selected_for_export += $val['word_count'];
						}
					}
				}
			}
		}

		return $selected_for_export ? $wc_selected_for_export : $wc;
	}
832244
public function actionIndex(): int
    {
        $this->disableLogging();

        $configurations = [];
        foreach ($this->getDataTypes() as $dataTypeHandle) {
            $dataType = $this->module->getDataType($dataTypeHandle);
            if (null == $dataType) {
                continue;
            }

            $mapper = $dataType->getMapperHandle();
            if (!$this->module->checkMapper($mapper)) {
                continue;
            }

            $records = $dataType->getRecords();
            $configurations[$dataTypeHandle] = $this->module->$mapper->export($records);
        }

        // Load override file.
        $overrideData = [];
        if (file_exists($this->overrideFile)) {
            // Parse data in the overrideFile if available.
            $overrideData = Data::parseYamlFile($this->overrideFile);
        }

        // Export the configuration to a single file.
        if ($this->getStorageType() === self::SINGLE_FILE) {
            $this->exportToSingle($configurations, $overrideData);
        }

        // Export the configuration to multiple yaml files.
        if ($this->getStorageType() === self::MULTIPLE_FILES) {
            $this->exportToMultiple($configurations, $overrideData);
        }

        return 0;
    }
60653
public function getCount() {
		$options = $this->getOptions();
		$options['count'] = true;
		return (int) call_user_func($this->getter, $options);
	}
1157635
public int execSelectCount(Class<? extends D6Model> modelClazz) {

    final D6CrudSelectHelper d6CrudSelectHelper = new D6CrudSelectHelper(modelClazz);
    final String sqlForSelectCount = d6CrudSelectHelper.getSQLForSelectCount();

    return execSelectCount(sqlForSelectCount);
  }
505206
protected function _getSelect() {
        $fields = $this->_entity->fields();

        switch ($this->_type) {
            case self::QUERY_SELECT :
                $this->_query .= 'SELECT ';

                $nFields = count($fields);
                $i = 0;

                //We add all fields to the select
                foreach ($fields as $value) {
                    //We mustn't add fields which don't exist in the SQL table
                    if ($value->foreign == null || in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= $this->_entity->name() . '.' . $value->name . ' AS ' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation ONE TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::ONE_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $value->foreign->field();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $referenceEntity . ' WHERE ' . $referenceEntity . '.' . $referenceField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_one_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation MANY TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::MANY_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $this->_entity->primary();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();
                        $current = strtolower($currentEntity . $currentField);
                        $reference = strtolower($referenceEntity . $referenceField);
                        $table = [$current, $reference];
                        sort($table, SORT_STRING);
                        $table = ucfirst($table[0] . $table[1]);

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $table . ' WHERE ' . $table . '.' . $currentEntity . '_' . $currentField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_many_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }

                    $i++;
                }

                $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);

                //if some fields have a relation one to one or many to one, we had a join
                foreach ($fields as $value) {
                    if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= ', ';

                        $class = $this->_getTableEntity($value->foreign->referenceEntity());

                        $fieldsRelation = $class->fields();
                        $nFieldsRelation = count($fieldsRelation);
                        $i = 0;

                        foreach ($fieldsRelation as $relation) {
                            if ($relation->foreign == null || in_array($relation->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                                $this->_query .= $value->name . '_' . $class->name() . '.' . $relation->name . ' AS ' . $value->name . '_' . $class->name() . '_' . $relation->name;

                                if ($i < $nFieldsRelation - 1) {
                                    $this->_query .= ', ';
                                }
                            }

                            $i++;
                        }

                        $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);
                    }
                }
                break;

            case self::QUERY_DISTINCT :
                $primaryColumn = $this->_entity->name() . '.' . $this->_entity->fields()[$this->_entity->primary()]->name;

                if (preg_match('(' . $primaryColumn . ')', $this->_distinct)) {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ' ';
                }
                else {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ', ' . $primaryColumn . ' ';
                }
                break;

            case self::QUERY_COUNT :
                $this->_query .= 'SELECT COUNT(*) ';
                break;
        }

        $this->_query .= ' FROM ' . $this->_entity->name();

        /** If there are relations like one to one, many to one or many to many */
        foreach ($fields as $value) {
            if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                $entity = $value->foreign->entity();
                $field = $value->foreign->field();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();
                $this->join($value->foreign->join(), $referenceEntity, $entity . '.' . $field . ' = ' . $field . '_' . $referenceEntity . '.' . $referenceField, $field);
            }
            else if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::MANY_TO_MANY])) {
                //We add here two join (relation table and table linked)
                $currentEntity = $value->foreign->entity();
                $currentField = $this->_entity->primary();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();

                $current = strtolower($currentEntity . $currentField);
                $reference = strtolower($referenceEntity . $referenceField);
                $table = [$current, $reference];
                sort($table, SORT_STRING);
                $table = ucfirst($table[0] . $table[1]);

                $this->join($value->foreign->join(), $table, $table . '.' . $this->_entity->name() . '_' . $currentField . ' = ' . $this->_entity->name() . '.' . $currentField);
                $this->join($value->foreign->join(), $value->foreign->referenceEntity(), $table . '.' . $referenceEntity . '_' . $referenceField . ' = ' . $referenceEntity . '.' . $referenceField);
            }
        }
    }
346880
public function getMaximumAmount()
    {
        if (!isset($this->_issuerData))
            throw new Exception("Issuer must be selected first");
        if (!isset($this->_country))
            throw new Exception("Country must be selected first");
        foreach ($this->_issuerData["Countries"] as $country) {
            if ($this->_country == $country["CountryCode"]) {
                return intval($country["MaximumAmount"]);
            }
        }
    }
1266563
public function countResult($wheres = [], $selectField = '*')
    {
        if (!is_array($selectField)) {
            $selectField = [$selectField];
        }
        $db = $this->db->select($selectField)->from($this->table);
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $field => $value) {
                if (is_array($value)) {
                    $db->whereIn($field, $value);
                } else {
                    $db->where($field, self::OPERATOR_EQUAL_TO, $value);
                }
            }
        } else {
            $db->where($this->primaryKey, self::OPERATOR_EQUAL_TO, $wheres);
        }
        $totalItem = $db->execute()->rowCount();
        $this->debug->debug(__FUNCTION__, 'Total Item Result => ' . json_encode($totalItem));

        return $totalItem;
    }
278882
public function getExportDocumentClass_v2() {
		$class = new StdClass;

		// Standard-Export-Stuff
		if($this->getInvoiceNumber() !== null)
			$class->invoiceNumber = $this->getInvoiceNumber();

		$class->exportType = $this->getExportType();

		if($this->getExportTypeDescription() !== null)
			$class->exportTypeDescription = $this->getExportTypeDescription();
		else if($this->getExportType() === self::EXPORT_TYPE_OTHER)
			throw new Exception('ExportTypeDescription must filled out if Export-Type is OTHER! - ' .
				'Export-Class will not generated now');

		if($this->getTermsOfTrade() !== null)
			$class->termsOfTrade = $this->getTermsOfTrade();

		$class->placeOfCommital = $this->getPlaceOfCommittal();
		$class->additionalFee = $this->getAdditionalFee();

		if($this->getPermitNumber() !== null)
			$class->permitNumber = $this->getPermitNumber();

		if($this->getAttestationNumber() !== null)
			$class->attestationNumber = $this->getAttestationNumber();

		// Add rest (Elements)
		if($this->getWithElectronicExportNotification() !== null) {
			$class->WithElectronicExportNtfctn = new StdClass;
			$class->WithElectronicExportNtfctn->active = (int) $this->getWithElectronicExportNotification();
		}

		// Check if child-class is being used
		if($this->getExportDocPosition() !== null) {
			// Handle non-arrays... (Backward compatibility)
			if(! is_array($this->getExportDocPosition()))
				$class->ExportDocPosition = $this->getExportDocPosition()->getExportDocPositionClass_v2();
			else {
				$pos = $this->getExportDocPosition();
				foreach($pos as $key => &$exportDoc)
					$class->ExportDocPosition[$key] = $exportDoc->getExportDocPositionClass_v2();
			}
		}

		return $class;
	}
274894
public function getTotalSelectedRowsWithoutLimit(): int
    {
        if (!$this->require_to_count_total_rows) {
            dump('You need to call setRequireCountRowsWithoutLimits(true) before requesting result');
        }

        $this->collectObjects();

        return (int)$this->total_count_rows;
    }
1269615
public function compare($selected, $result)
    {
        $compare = array_intersect($selected, $result);

        return ($compare == $selected ? true : false);
    }
1176194
function exportValue(&$submitValues, $assoc = false) {
        if ($this->ajax || $this->tags) {
            // When this was an ajax request, we do not know the allowed list of values.
            $value = $this->_findValue($submitValues);
            if (null === $value) {
                $value = $this->getValue();
            }
            // Quickforms inserts a duplicate element in the form with
            // this value so that a value is always submitted for this form element.
            // Normally this is cleaned as a side effect of it not being a valid option,
            // but in this case we need to detect and skip it manually.
            if ($value === '_qf__force_multiselect_submission' || $value === null) {
                $value = $this->getMultiple() ? [] : '';
            }
            return $this->_prepareValue($value, $assoc);
        } else {
            return parent::exportValue($submitValues, $assoc);
        }
    }
614012
def is_selected(self, model):
        
        if model is None:
            return len(self._selected) == 0
        return model in self._selected
240497
function exportValue(&$submitValues, $assoc = false)
    {
        $value = $this->_findValue($submitValues);
        if (is_null($value)) {
            $value = $this->getValue();
        } elseif(!is_array($value)) {
            $value = array($value);
        }
        if (is_array($value) && !empty($this->_options)) {
            $cleanValue = null;
            foreach ($value as $v) {
                for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
                    if ($v == $this->_options[$i]['attr']['value']) {
                        $cleanValue[] = $v;
                        break;
                    }
                }
            }
        } else {
            $cleanValue = $value;
        }
        if (is_array($cleanValue) && !$this->getMultiple()) {
            return $this->_prepareValue($cleanValue[0], $assoc);
        } else {
            return $this->_prepareValue($cleanValue, $assoc);
        }
    }
1346577
public function processExportListJob($list, $report_email = false, $postback_url = false, array $options = [ ]) {
        $data = [ 'list' => $list ];
        return $this->processJob('export_list_data', $data, $report_email, $postback_url, [ ], $options);
    }
690518
function getValueCount( $val )
    {
        $val_cnt = false;

        if ( $val === null )
        {
            $val_cnt = 0;
        }
        else if ( $val === true || $val === false )
        {
            $val_cnt = (int)$val;
        }
        else if ( is_array( $val ) )
        {
            $val_cnt = count( $val );
        }
        else if ( is_object( $val ) and
                  method_exists( $val, "attributes" ) )
        {
            $val_cnt = count( $val->attributes() );
        }
        else if ( is_numeric( $val ) )
        {
            $val_cnt = $val;
        }
        else if ( is_string( $val ) )
        {
            $val_cnt = strlen( $val );
        }
        return $val_cnt;
    }
749156
public function export_for_download() {

        if (count($this->versions) == 1) {
            if ($this->accepted) {
                if ($this->onbehalf) {
                    return get_string('acceptancestatusacceptedbehalf', 'tool_policy');
                } else {
                    return get_string('acceptancestatusaccepted', 'tool_policy');
                }

            } else if ($this->declined) {
                if ($this->onbehalf) {
                    return get_string('acceptancestatusdeclinedbehalf', 'tool_policy');
                } else {
                    return get_string('acceptancestatusdeclined', 'tool_policy');
                }

            } else {
                return get_string('acceptancestatuspending', 'tool_policy');
            }

        } else if (count($this->versions) > 1) {
            if (count($this->accepted) == count($this->versions)) {
                return get_string('acceptancestatusaccepted', 'tool_policy');

            } else if (count($this->declined) == count($this->versions)) {
                return get_string('acceptancestatusdeclined', 'tool_policy');

            } else if (count($this->accepted) > 0 || count($this->declined) > 0) {
                return get_string('acceptancestatuspartial', 'tool_policy');

            } else {
                return get_string('acceptancestatuspending', 'tool_policy');
            }
        }
    }
1297422
private function isValidSelectionMethod($selectionMethod)
    {
        return in_array($selectionMethod, [
            self::SELECTION_BROWSE,
            self::SELECTION_DROPDOWN,
            self::SELECTION_LIST_WITH_RADIO_BUTTONS,
            self::SELECTION_LIST_WITH_CHECKBOXES,
            self::SELECTION_MULTIPLE_SELECTION_LIST,
            self::SELECTION_TEMPLATE_BASED_MULTIPLE,
            self::SELECTION_TEMPLATE_BASED_SINGLE,
        ], true);
    }