当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObjectAttribute::validateIsRequired方法代码示例

本文整理汇总了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;
 }
开发者ID:oki34,项目名称:eztags,代码行数:43,代码来源:eztagstype.php

示例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;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:39,代码来源:ezgmaplocationtype.php

示例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;
 }
开发者ID:netbliss,项目名称:eztags,代码行数:47,代码来源:eztagstype.php

示例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;
 }
开发者ID:netgen,项目名称:ngclasslist,代码行数:33,代码来源:ngclasslisttype.php

示例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;
 }
开发者ID:netgen,项目名称:ngoib,代码行数:30,代码来源:ngoibtype.php

示例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;
 }
开发者ID:netgen,项目名称:enhancedselection2,代码行数:42,代码来源:sckenhancedselectiontype.php

示例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;
 }
开发者ID:jsc-dev,项目名称:fmcolorpicker,代码行数:30,代码来源:fmcolorpickertype.php


注:本文中的eZContentObjectAttribute::validateIsRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。