本文整理汇总了PHP中eZContentObjectAttribute::validateIsRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectAttribute::validateIsRequired方法的具体用法?PHP eZContentObjectAttribute::validateIsRequired怎么用?PHP eZContentObjectAttribute::validateIsRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectAttribute
的用法示例。
在下文中一共展示了eZContentObjectAttribute::validateIsRequired方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateObjectAttribute
/**
* Validates the data structure and returns true if it is valid for this datatype
*
* @param eZContentObjectAttribute $contentObjectAttribute
* @param string $idString
* @param string $keywordString
* @param string $parentString
* @param string $localeString
*
* @return bool
*/
private function validateObjectAttribute($contentObjectAttribute, $idString, $keywordString, $parentString, $localeString)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
// we cannot use empty() here as there can be cases where $parentString or $idString can be "0",
// which evaluates to false with empty(), which is wrong for our use case
if (strlen($keywordString) == 0 && strlen($parentString) == 0 && strlen($idString) == 0 && strlen($localeString) == 0) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'At least one tag is required to be added.'));
return eZInputValidator::STATE_INVALID;
}
} else {
if (strlen($keywordString) == 0 || strlen($parentString) == 0 || strlen($idString) == 0 || strlen($localeString) == 0) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Attribute contains invalid data.'));
return eZInputValidator::STATE_INVALID;
} else {
$idArray = explode('|#', $idString);
$keywordArray = explode('|#', $keywordString);
$parentArray = explode('|#', $parentString);
$localeArray = explode('|#', $localeString);
if (count($keywordArray) != count($idArray) || count($parentArray) != count($idArray) || count($localeArray) != count($idArray)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Attribute contains invalid data.'));
return eZInputValidator::STATE_INVALID;
}
$maxTags = (int) $classAttribute->attribute(self::MAX_TAGS_FIELD);
if ($maxTags > 0 && (count($idArray) > $maxTags || count($keywordArray) > $maxTags || count($parentArray) > $maxTags || count($localeArray) > $maxTags)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Up to %1 tags are allowed to be added.', null, array('%1' => $maxTags)));
return eZInputValidator::STATE_INVALID;
}
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例2: validateObjectAttributeHTTPInput
/**
* Validate post data, these are then used by
* {@link eZGmapLocationType::fetchObjectAttributeHTTPInput()}
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*/
function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$latitude = '';
$longitude = '';
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ( $http->hasPostVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) ) &&
$http->hasPostVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) ) )
{
$latitude = $http->postVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) );
$longitude = $http->postVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) );
}
if ( $latitude === '' || $longitude === '' )
{
if ( !$classAttribute->attribute( 'is_information_collector' ) && $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
'Missing Latitude/Longitude input.' ) );
return eZInputValidator::STATE_INVALID;
}
}
else if ( !is_numeric( $latitude ) || !is_numeric( $longitude ) )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
'Invalid Latitude/Longitude input.' ) );
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例3: validateObjectAttributeHTTPInput
/**
* Validates the input and returns true if the input was valid for this datatype
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
* @return bool
*/
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ($http->hasPostVariable($base . '_eztags_data_text_' . $contentObjectAttribute->attribute('id')) && $http->hasPostVariable($base . '_eztags_data_text2_' . $contentObjectAttribute->attribute('id')) && $http->hasPostVariable($base . '_eztags_data_text3_' . $contentObjectAttribute->attribute('id'))) {
$data = trim($http->postVariable($base . '_eztags_data_text_' . $contentObjectAttribute->attribute('id')));
$data2 = trim($http->postVariable($base . '_eztags_data_text2_' . $contentObjectAttribute->attribute('id')));
$data3 = trim($http->postVariable($base . '_eztags_data_text3_' . $contentObjectAttribute->attribute('id')));
if (strlen($data) == 0 && strlen($data2) == 0 && strlen($data3) == 0) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!(strlen($data) > 0 && strlen($data2) > 0 && strlen($data3) > 0)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
} else {
$dataArray = explode('|#', $data);
$data2Array = explode('|#', $data2);
$data3Array = explode('|#', $data3);
if (count($data2Array) != count($dataArray) || count($data3Array) != count($dataArray)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
$maxTags = (int) $classAttribute->attribute(self::MAX_TAGS_FIELD);
if ($maxTags > 0 && (count($dataArray) > $maxTags || count($data2Array) > $maxTags || count($data3Array) > $maxTags)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
}
}
} else {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例4: validateObjectAttributeHTTPInput
/**
* Validates the input and returns the validity status code
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return int
*/
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classList = $http->postVariable($base . self::CLASS_LIST_VARIABLE . $contentObjectAttribute->attribute("id"), array());
$classList = !is_array($classList) ? array() : $classList;
if (empty($classList) && $contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
$invalidClassIdentifiers = array();
foreach ($classList as $classIdentifier) {
if (!eZContentClass::exists($classIdentifier, eZContentClass::VERSION_STATUS_DEFINED, false, true)) {
$invalidClassIdentifiers[] = $classIdentifier;
}
}
if (!empty($invalidClassIdentifiers)) {
if (count($invalidClassIdentifiers) == 1) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("extension/ngclasslist/datatypes", "Class with identifier '%identifier%' does not exist", null, array("%identifier%" => $invalidClassIdentifiers[0])));
} else {
$contentObjectAttribute->setValidationError(ezpI18n::tr("extension/ngclasslist/datatypes", "Classes with '%identifiers%' identifiers do not exist", null, array("%identifiers%" => implode(", ", $invalidClassIdentifiers))));
}
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例5: validateCollectionAttributeHTTPInput
/**
* Validates the input for collection attribute and returns the validity status code
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return int
*/
function validateCollectionAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
if ($http->hasPostVariable($base . self::OIB_VARIABLE . $contentObjectAttribute->attribute("id"))) {
$data = trim($http->postVariable($base . self::OIB_VARIABLE . $contentObjectAttribute->attribute("id")));
if (empty($data)) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!$this->validateOib($data)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("extension/ngoib/datatypes", "Personal identification number is not valid."));
return eZInputValidator::STATE_INVALID;
}
}
} else {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例6: validateAttributeHTTPInput
/**
* Validates content object attribute HTTP input
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
* @param bool $isInformationCollection
*
* @return int
*/
protected function validateAttributeHTTPInput($http, $base, $contentObjectAttribute, $isInformationCollection = false)
{
/** @var eZContentClassAttribute $classAttribute */
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$classContent = $classAttribute->content();
$infoCollectionCheck = $isInformationCollection == $classAttribute->attribute('is_information_collector');
$isRequired = $contentObjectAttribute->validateIsRequired();
$selectionName = join('_', array($base, 'sckenhancedselection_selection', $contentObjectAttribute->attribute('id')));
if ($http->hasPostVariable($selectionName)) {
$selection = $http->postVariable($selectionName);
if ($infoCollectionCheck) {
switch (true) {
case $isRequired === true && count($selection) == 0:
case $isRequired === true && count($selection) == 1 && empty($selection[0]):
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'This is a required field.'));
return eZInputValidator::STATE_INVALID;
}
}
} else {
if ($infoCollectionCheck && $isRequired && $classContent['is_multiselect'] == 1) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'This is a required field.'));
} else {
if ($infoCollectionCheck && $isRequired) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'No POST variable. Please check your configuration.'));
} else {
return eZInputValidator::STATE_ACCEPTED;
}
}
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例7: validateCollectionAttributeHTTPInput
/**
* Validates the input for collection attribute and returns the validity status code
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return int
*/
function validateCollectionAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
if ($http->hasPostVariable($base . self::FMCP_VAR . $contentObjectAttribute->attribute("id"))) {
$data = trim($http->postVariable($base . self::FMCP_VAR . $contentObjectAttribute->attribute("id")));
if (empty($data)) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!$this->validateColor($data)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("extension/fmColorpicker/datatypes", "the color code is not valid."));
return eZInputValidator::STATE_INVALID;
}
}
} else {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}