/**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @return array for further processing
     */

    public static function getAttributeData ( eZContentObjectAttribute $contentObjectAttribute )
    {
        $dataTypeIdentifier = $contentObjectAttribute->attribute( 'data_type_string' );
        $contentClassAttribute = eZContentClassAttribute::fetch( $contentObjectAttribute->attribute( 'contentclassattribute_id' ) );
        $attributeHandler =  $dataTypeIdentifier . 'SolrStorage';
        // prefill the array with generic metadata first
        $target = array (
            'data_type_identifier' => $dataTypeIdentifier,
            'version_format' => self::STORAGE_VERSION_FORMAT,
            'attribute_identifier' => $contentClassAttribute->attribute( 'identifier' ),
            'has_content' => $contentObjectAttribute->hasContent(),

            );
        if ( class_exists( $attributeHandler ) )
        {
            $attributeContent = call_user_func( array( $attributeHandler, 'getAttributeContent' ),
                     $contentObjectAttribute, $contentClassAttribute );
            return array_merge( $target, $attributeContent, array( 'content_method' => self::CONTENT_METHOD_CUSTOM_HANDLER ) );

        }
        else
        {
            $target = array_merge( $target, array(
                'content_method' => self::CONTENT_METHOD_TOSTRING,
                'content' => $contentObjectAttribute->toString(),
                'has_rendered_content' => false,
                'rendered' => null
                ));
            return $target;
        }
    }
 public function buildFetch()
 {
     $filters = array();
     foreach ($this->requestFields as $key => $value) {
         if (strpos($key, OCClassSearchFormAttributeField::NAME_PREFIX) !== false) {
             $contentClassAttributeID = str_replace(OCClassSearchFormAttributeField::NAME_PREFIX, '', $key);
             $contentClassAttribute = eZContentClassAttribute::fetch($contentClassAttributeID);
             if ($contentClassAttribute instanceof eZContentClassAttribute) {
                 $field = OCClassSearchFormAttributeField::instance($contentClassAttribute);
                 $field->buildFetch($this, $key, $value, $filters);
                 $this->isFetch = true;
             }
         } elseif (in_array($key, OCFacetNavgationHelper::$allowedUserParamters)) {
             if (!empty($value)) {
                 $this->currentParameters[$key] = $value;
                 $this->isFetch = true;
             }
         } elseif ($key == 'class_id') {
             $this->currentParameters[$key] = $value;
             $this->addFetchField(array('name' => ezpI18n::tr('extension/ezfind/facets', 'Content type'), 'value' => eZContentClass::fetch($value)->attribute('name'), 'remove_view_parameters' => $this->getViewParametersString(array($key))));
             $this->isFetch = true;
         } elseif ($key == 'publish_date') {
             $publishedField = new OCClassSearchFormPublishedField($this->requestFields['class_id']);
             $publishedField->buildFetch($this, $value, $filters);
             $this->isFetch = true;
         } elseif ($key == 'query') {
             $queryField = new OCClassSearchFormQueryField();
             $queryField->buildFetch($this, $value);
             $this->searchText = $queryField->queryText();
             $this->isFetch = true;
         }
     }
     $this->currentParameters['filter'] = $filters;
     return $this->currentParameters;
 }
 function classAttributeName()
 {
     if ($this->ClassAttributeName === null) {
         $contentClassAttribute = eZContentClassAttribute::fetch($this->attribute('contentclass_attribute_id'));
         $this->ClassAttributeName = $contentClassAttribute->attribute('name');
     }
     return $this->ClassAttributeName;
 }
 function classAttributeName()
 {
     if ($this->ClassAttributeName === null) {
         $contentClassAttribute = eZContentClassAttribute::fetch($this->attribute('contentclass_attribute_id'));
         if (!$contentClassAttribute instanceof eZContentClassAttribute) {
             eZDebug::writeError('Unable to find eZContentClassAttribute #' . $this->attribute('contentclass_attribute_id'), __METHOD__);
             return null;
         }
         $this->ClassAttributeName = $contentClassAttribute->attribute('name');
     }
     return $this->ClassAttributeName;
 }
 function addEntry($contentClassAttributeID, $contentClassID = false)
 {
     if (!isset($contentClassAttributeID)) {
         return;
     }
     if (!$contentClassID) {
         $contentClassAttribute = eZContentClassAttribute::fetch($contentClassAttributeID);
         $contentClassID = $contentClassAttribute->attribute('contentclass_id');
     }
     // Checking if $contentClassAttributeID and $contentClassID already exist (in Entries)
     foreach ($this->Entries as $entrie) {
         if ($entrie->attribute('contentclass_attribute_id') == $contentClassAttributeID and $entrie->attribute('contentclass_id') == $contentClassID) {
             return;
         }
     }
     $waitUntilDateValue = eZWaitUntilDateValue::create($this->WorkflowEventID, $this->WorkflowEventVersion, $contentClassAttributeID, $contentClassID);
     $waitUntilDateValue->store();
     $this->Entries = eZWaitUntilDateValue::fetchAllElements($this->WorkflowEventID, $this->WorkflowEventVersion);
 }
 function validateClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     $typeParam = $base . self::CLASS_TYPE . $classAttribute->attribute('id');
     $fileParam = $base . self::CLASS_FILE . $classAttribute->attribute('id');
     $sectionParam = $base . self::CLASS_SECTION . $classAttribute->attribute('id');
     $parameterParam = $base . self::CLASS_PARAMETER . $classAttribute->attribute('id');
     if ($http->hasPostVariable($fileParam) and $http->hasPostVariable($sectionParam) and $http->hasPostVariable($parameterParam) and $http->hasPostVariable($typeParam) and (int) $http->postVariable($typeParam) > 0 and (int) $http->postVariable($typeParam) <= 6) {
         $liveClassAttribute = eZContentClassAttribute::fetch($classAttribute->attribute('id'));
         if (is_object($liveClassAttribute)) {
             $new_type = (int) $http->postVariable($typeParam);
             $old_type = (int) $liveClassAttribute->attribute(self::CLASS_TYPE_FIELD);
             if ($new_type !== $old_type and ($new_type === ymcDynamicIniSetting::TYPE_ARRAY or $old_type === ymcDynamicIniSetting::TYPE_ARRAY)) {
                 eZDebug::writeNotice('It is not possible to change an existing type from/to the array-type', 'ymcDynamicIniSettingType::validateClassAttributeHTTPInput');
                 return eZInputValidator::STATE_INVALID;
             }
         }
         return eZInputValidator::STATE_ACCEPTED;
     }
     eZDebug::writeNotice('Could not validate parameters: ' . "\n" . $fileParam . ':' . $http->postVariable($fileParam) . "\n" . $sectionParam . ':' . $http->postVariable($sectionParam) . "\n" . $parameterParam . ':' . $http->postVariable($parameterParam) . "\n" . $typeParam . ':' . $http->postVariable($typeParam), 'ymcDynamicIniSettingType::validateClassAttributeHTTPInput');
     return eZInputValidator::STATE_INVALID;
 }
 /**
  * Searches $searchText in the search database.
  *
  * @param string $searchText Search term
  * @param array $params Search parameters
  * @param array $searchTypes Search types
  *
  * @return array
  */
 public function search($searchText, $params = array(), $searchTypes = array())
 {
     $searchText = trim($searchText);
     if (empty($searchText)) {
         return array('SearchResult' => array(), 'SearchCount' => 0, 'StopWordArray' => array());
     }
     $doFullText = true;
     $query = new LocationQuery();
     $criteria = array();
     if (isset($params['SearchDate']) && (int) $params['SearchDate'] > 0) {
         $currentTimestamp = time();
         $dateSearchType = (int) $params['SearchDate'];
         $fromTimestamp = 0;
         if ($dateSearchType === 1) {
             // Last day
             $fromTimestamp = $currentTimestamp - 86400;
         } else {
             if ($dateSearchType === 2) {
                 // Last week
                 $fromTimestamp = $currentTimestamp - 7 * 86400;
             } else {
                 if ($dateSearchType === 3) {
                     // Last month
                     $fromTimestamp = $currentTimestamp - 30 * 86400;
                 } else {
                     if ($dateSearchType === 4) {
                         // Last three months
                         $fromTimestamp = $currentTimestamp - 3 * 30 * 86400;
                     } else {
                         if ($dateSearchType === 5) {
                             // Last year
                             $fromTimestamp = $currentTimestamp - 365 * 86400;
                         }
                     }
                 }
             }
         }
         $criteria[] = new Criterion\DateMetadata(Criterion\DateMetadata::CREATED, Criterion\Operator::GTE, $fromTimestamp);
     }
     if (isset($params['SearchSectionID']) && (int) $params['SearchSectionID'] > 0) {
         $criteria[] = new Criterion\SectionId((int) $params['SearchSectionID']);
     }
     if (isset($params['SearchContentClassID']) && (int) $params['SearchContentClassID'] > 0) {
         $criteria[] = new Criterion\ContentTypeId((int) $params['SearchContentClassID']);
         if (isset($params['SearchContentClassAttributeID']) && (int) $params['SearchContentClassAttributeID'] > 0) {
             $classAttribute = eZContentClassAttribute::fetch($params['SearchContentClassAttributeID']);
             if ($classAttribute instanceof eZContentClassAttribute) {
                 $criteria[] = new Criterion\Field($classAttribute->attribute('identifier'), Criterion\Operator::LIKE, $searchText);
                 $doFullText = false;
             }
         }
     }
     if (isset($params['SearchSubTreeArray']) && !empty($params['SearchSubTreeArray'])) {
         $subTreeArrayCriteria = array();
         foreach ($params['SearchSubTreeArray'] as $nodeId) {
             $node = eZContentObjectTreeNode::fetch($nodeId);
             $subTreeArrayCriteria[] = $node->attribute('path_string');
         }
         $criteria[] = new Criterion\Subtree($subTreeArrayCriteria);
     }
     if ($doFullText) {
         $criteria[] = new Criterion\FullText($searchText);
     }
     $query->query = new Criterion\LogicalAnd($criteria);
     $query->limit = isset($params['SearchLimit']) ? (int) $params['SearchLimit'] : 10;
     $query->offset = isset($params['SearchOffset']) ? (int) $params['SearchOffset'] : 0;
     $useLocationSearch = eZINI::instance('ezplatformsearch.ini')->variable('SearchSettings', 'UseLocationSearch') === 'true';
     if ($useLocationSearch) {
         $searchResult = $this->repository->getSearchService()->findLocations($query);
     } else {
         $searchResult = $this->repository->getSearchService()->findContentInfo($query);
     }
     $nodeIds = array();
     foreach ($searchResult->searchHits as $searchHit) {
         $nodeIds[] = $useLocationSearch ? $searchHit->valueObject->id : $searchHit->valueObject->mainLocationId;
     }
     $nodes = eZContentObjectTreeNode::fetch($nodeIds);
     if ($nodes instanceof eZContentObjectTreeNode) {
         $nodes = array($nodes);
     } else {
         if (!is_array($nodes)) {
             $nodes = array();
         }
     }
     return array('SearchResult' => $nodes, 'SearchCount' => $searchResult->totalCount, 'StopWordArray' => array());
 }
    $attrcnt = count($attributes) + 1;
    $newAttribute->setName(ezpI18n::tr('kernel/class/edit', 'new attribute') . $attrcnt, $EditLanguage);
    $dataType = $newAttribute->dataType();
    $dataType->initializeClassAttribute($newAttribute);
    $newAttribute->store();
    $attributes[] = $newAttribute;
    $lastChangedID = $newAttribute->attribute('id');
} else {
    if ($http->hasPostVariable('MoveUp')) {
        $attribute = eZContentClassAttribute::fetch($http->postVariable('MoveUp'), true, eZContentClass::VERSION_STATUS_TEMPORARY, array('contentclass_id', 'version', 'placement'));
        $attribute->move(false);
        $Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
        return;
    } else {
        if ($http->hasPostVariable('MoveDown')) {
            $attribute = eZContentClassAttribute::fetch($http->postVariable('MoveDown'), true, eZContentClass::VERSION_STATUS_TEMPORARY, array('contentclass_id', 'version', 'placement'));
            $attribute->move(true);
            $Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
            return;
        }
    }
}
$Module->setTitle('Edit class ' . $class->attribute('name'));
// set session to allow current user to store class (to avoid direct post edit actions to this view)
if (!$http->hasSessionVariable('ClassCanStoreTicket')) {
    $http->setSessionVariable('ClassCanStoreTicket', 1);
}
// Fetch updated attributes
$attributes = $class->fetchAttributes();
$validation = array_merge($validation, $datatypeValidation);
// Template handling
$arguments = false;
$useStandardOptions = true;
$options = $script->getOptions($config, $argumentConfig, $optionHelp, $arguments, $useStandardOptions);
$script->initialize();
if (count($options['arguments']) != 1) {
    $script->shutdown(1, 'wrong argument count');
}
$preview = $options['preview'] !== null;
$attributeID = $options['arguments'][0];
if (!is_numeric($attributeID)) {
    $attributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($attributeID);
    if ($attributeID === false) {
        $script->shutdown(2, 'unknown attribute identifier');
    }
}
$classAttribute = eZContentClassAttribute::fetch($attributeID);
if (!is_object($classAttribute)) {
    $script->shutdown(3, 'could not find a class attribute with the specified ID');
}
$enum = $classAttribute->attribute('content');
// both datatypes use data_int1 for the multiple flag, so the following code is not necessary
/*
$isMultiple = $enum->attribute( 'enum_ismultiple' );
$classAttribute->setAttribute( 'data_int1', $isMultiple );
*/
//var_dump( $enum );
$enumValues = $enum->attribute('enum_list');
$oldOptions = array();
$oldToNewIDMap = array();
foreach ($enumValues as $enumValue) {
    $element = $enumValue->attribute('enumelement');
Exemple #10
0
 function contentClassAttributeCanTranslate()
 {
     if ($this->ContentClassAttributeCanTranslate === null) {
         eZDebug::accumulatorStart('class_a_can_translate', 'Sytem overhead', 'Fetch class attribute can translate value');
         $classAttribute = eZContentClassAttribute::fetch($this->ContentClassAttributeID);
         $dataType = $classAttribute->dataType();
         if ($dataType && $dataType->Attributes["properties"]["translation_allowed"] && $classAttribute->attribute('can_translate')) {
             $this->ContentClassAttributeCanTranslate = 1;
         } else {
             $this->ContentClassAttributeCanTranslate = 0;
         }
         eZDebug::accumulatorStop('class_a_can_translate');
     }
     return $this->ContentClassAttributeCanTranslate;
 }
 /**
  * @param $tpl eZTemplate
  * @param $operatorName array
  * @param $operatorParameters array
  * @param $rootNamespace string
  * @param $currentNamespace string
  * @param $operatorValue mixed
  * @param $namedParameters array
  *
  * @return mixed
  */
 function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     $ini = eZINI::instance('ocoperatorscollection.ini');
     $appini = eZINI::instance('app.ini');
     switch ($operatorName) {
         case 'related_attribute_objects':
             $object = $operatorValue;
             $identifier = $namedParameters['identifier'];
             $dataMap = $object instanceof eZContentObject || $object instanceof eZContentObjectTreeNode ? $object->attribute('data_map') : array();
             $data = array();
             if (isset($dataMap[$identifier])) {
                 $ids = $dataMap[$identifier] instanceof eZContentObjectAttribute ? explode('-', $dataMap[$identifier]->toString()) : array();
                 if (!empty($ids)) {
                     $data = eZContentObject::fetchList(true, array("id" => array($ids)));
                 }
             }
             $operatorValue = $data;
             break;
         case 'smart_override':
             $identifier = $namedParameters['identifier'];
             $view = $namedParameters['view'];
             $node = $operatorValue;
             $operatorValue = $this->findSmartTemplate($identifier, $view, $node);
             break;
         case 'parse_link_href':
             $href = $operatorValue;
             $hrefParts = explode(':', $href);
             $hrefFirst = array_shift($hrefParts);
             if (!in_array($hrefFirst, array('http', 'https', 'file', 'mailto', 'ftp'))) {
                 if (!empty($hrefFirst)) {
                     $nodeID = eZURLAliasML::fetchNodeIDByPath('/' . $hrefFirst);
                     if ($nodeID) {
                         $contentNode = eZContentObjectTreeNode::fetch($nodeID);
                         if ($contentNode instanceof eZContentObjectTreeNode) {
                             $keyArray = array(array('node', $contentNode->attribute('node_id')), array('object', $contentNode->attribute('contentobject_id')), array('class_identifier', $contentNode->attribute('class_identifier')), array('class_group', $contentNode->attribute('object')->attribute('content_class')->attribute('match_ingroup_id_list')));
                             $tpl = new eZTemplate();
                             $ini = eZINI::instance();
                             $autoLoadPathList = $ini->variable('TemplateSettings', 'AutoloadPathList');
                             $extensionAutoloadPath = $ini->variable('TemplateSettings', 'ExtensionAutoloadPath');
                             $extensionPathList = eZExtension::expandedPathList($extensionAutoloadPath, 'autoloads/');
                             $autoLoadPathList = array_unique(array_merge($autoLoadPathList, $extensionPathList));
                             $tpl->setAutoloadPathList($autoLoadPathList);
                             $tpl->autoload();
                             $tpl->setVariable('node', $contentNode);
                             $tpl->setVariable('object', $contentNode->attribute('object'));
                             $tpl->setVariable('original_href', $href);
                             $res = new eZTemplateDesignResource();
                             $res->setKeys($keyArray);
                             $tpl->registerResource($res);
                             $result = trim($tpl->fetch('design:link/href.tpl'));
                             if (!empty($result)) {
                                 $href = $result;
                             }
                         }
                     }
                 }
             }
             return $operatorValue = $href;
             break;
         case 'gmap_static_image':
             try {
                 $cacheFileNames = array();
                 //@todo
                 $operatorValue = OCOperatorsCollectionsTools::gmapStaticImage($namedParameters['parameters'], $namedParameters['attribute'], $cacheFileNames);
             } catch (Exception $e) {
                 eZDebug::writeError($e->getMessage(), 'gmap_static_image');
             }
             break;
         case 'fa_class_icon':
             $faIconIni = eZINI::instance('fa_icons.ini');
             $node = $operatorValue;
             $data = $namedParameters['fallback'] != '' ? $namedParameters['fallback'] : $faIconIni->variable('ClassIcons', '_fallback');
             if ($node instanceof eZContentObjectTreeNode) {
                 if ($faIconIni->hasVariable('ClassIcons', $node->attribute('class_identifier'))) {
                     $data = $faIconIni->variable('ClassIcons', $node->attribute('class_identifier'));
                 }
             }
             $operatorValue = $data;
             break;
         case 'fa_object_icon':
             $faIconIni = eZINI::instance('fa_icons.ini');
             $object = $operatorValue;
             $data = $namedParameters['fallback'] != '' ? $namedParameters['fallback'] : '';
             if ($object instanceof eZContentObject) {
                 if ($faIconIni->hasVariable('ObjectIcons', $object->attribute('id'))) {
                     $data = $faIconIni->variable('ObjectIcons', $object->attribute('id'));
                 }
             } else {
                 if ($faIconIni->hasVariable('ObjectIcons', $node)) {
                     $data = $faIconIni->variable('ObjectIcons', $node);
                 }
             }
             $operatorValue = $data;
             break;
         case 'fa_node_icon':
             $faIconIni = eZINI::instance('fa_icons.ini');
             $node = $operatorValue;
             $data = $namedParameters['fallback'] != '' ? $namedParameters['fallback'] : '';
             if ($node instanceof eZContentObjectTreeNode) {
                 if ($faIconIni->hasVariable('NodeIcons', $node->attribute('node_id'))) {
                     $data = $faIconIni->variable('NodeIcons', $node->attribute('node_id'));
                 }
             } else {
                 if ($faIconIni->hasVariable('NodeIcons', $node)) {
                     $data = $faIconIni->variable('NodeIcons', $node);
                 }
             }
             $operatorValue = $data;
             break;
         case 'children_class_identifiers':
             $node = $operatorValue;
             $data = array();
             if ($node instanceof eZContentObjectTreeNode) {
                 $search = eZFunctionHandler::execute('ezfind', 'search', array('subtree_array' => array($node->attribute('node_id')), 'limit' => 1, 'as_objects' => false, 'filter' => array('-meta_id_si:' . $node->attribute('contentobject_id')), 'facet' => array(array('field' => 'meta_class_identifier_ms', 'name' => 'class_identifier', 'limit' => 200))));
                 if (isset($search['SearchExtras'])) {
                     $facets = $search['SearchExtras']->attribute('facet_fields');
                     $data = array_diff(array_values($facets[0]['nameList']), $namedParameters['exclude']);
                 }
             }
             //eZDebug::writeNotice( $data, 'children_class_identifiers'  );
             $operatorValue = $data;
             break;
         case 'json_encode':
             $operatorValue = json_encode($operatorValue);
             break;
         case 'browse_template':
             $identifiers = array('image', 'image2', 'galleria', 'gallery', 'immagini');
             if ($ini->hasVariable('ObjectRelationsMultiupload', 'ClassAttributeIdentifiers')) {
                 $identifiers = $ini->variable('ObjectRelationsMultiupload', 'ClassAttributeIdentifiers');
             }
             if ($operatorValue instanceof eZContentBrowse && $operatorValue->hasAttribute('type') && $operatorValue->attribute('type') == 'AddRelatedObjectListToDataType' && $operatorValue->hasAttribute('action_name')) {
                 $currentAttributeId = str_replace('AddRelatedObject_', '', $operatorValue->attribute('action_name'));
                 $currentAttribute = eZPersistentObject::fetchObject(eZContentObjectAttribute::definition(), null, array("id" => $currentAttributeId), false);
                 if (isset($currentAttribute['contentclassattribute_id'])) {
                     $contentClassAttribute = eZContentClassAttribute::fetch($currentAttribute['contentclassattribute_id']);
                     if ($contentClassAttribute instanceof eZContentClassAttribute && ($contentClassAttribute->attribute('data_type_string') == 'mugoobjectrelationlist' || $contentClassAttribute->attribute('data_type_string') == 'ezobjectrelationlist') && in_array($contentClassAttribute->attribute('identifier'), $identifiers)) {
                         return $operatorValue = 'multiupload.tpl';
                     }
                 }
             } elseif ($operatorValue instanceof eZContentBrowse && $operatorValue->hasAttribute('action_name') && $operatorValue->attribute('action_name') == 'MultiUploadBrowse') {
                 return $operatorValue = 'multiupload.tpl';
             }
             $operatorValue = 'default.tpl';
             break;
         case 'multiupload_file_types_string':
             $availableFileTypes = array();
             $availableFileTypesString = '';
             if (eZINI::instance('ezmultiupload.ini')->hasGroup('FileTypeSettings_' . $operatorValue)) {
                 $availableFileTypes = eZINI::instance('ezmultiupload.ini')->variable('FileTypeSettings_' . $operatorValue, 'FileType');
             }
             if (!empty($availableFileTypes)) {
                 $availableFileTypesString = implode(';', $availableFileTypes);
             }
             $operatorValue = $availableFileTypesString;
             break;
         case 'multiupload_file_types_string_from_attribute':
             $availableFileTypesString = '';
             $attribute = $operatorValue;
             if ($attribute instanceof eZContentObjectAttribute) {
                 $identifiers = array();
                 if ($ini->hasVariable('ObjectRelationsMultiupload', 'ClassAttributeIdentifiers')) {
                     $identifier = $attribute->attribute('contentclass_attribute_identifier');
                     $identifiers = $ini->variable('ObjectRelationsMultiupload', 'ClassAttributeIdentifiers');
                     if (in_array($identifier, $identifiers)) {
                         $availableFileTypes = array();
                         $groups = $ini->group('ObjectRelationsMultiuploadFileTypesGroups');
                         foreach ($groups as $groupName => $fileType) {
                             $groupIdentifiers = $ini->variable('ObjectRelationsMultiuploadFileTypes_' . $groupName, 'Identifiers');
                             if (in_array($identifier, $groupIdentifiers)) {
                                 $availableFileTypesString = $fileType;
                             }
                         }
                     }
                 }
             }
             $operatorValue = $availableFileTypesString;
             break;
         case 'session_id':
             $operatorValue = session_id();
             break;
         case 'session_name':
             $operatorValue = session_name();
             break;
         case 'user_session_hash':
             $operatorValue = '';
             break;
         case 'developer_warning':
             $res = false;
             $user = eZUser::currentUser();
             if ($user->attribute('login') == 'admin') {
                 $templates = $tpl->templateFetchList();
                 $data = array_pop($templates);
                 $res = '<div class="developer-warning alert alert-danger"><strong>Avviso per lo sviluppatore</strong>:<br /><code>' . $data . '</code><br />' . $namedParameters['text'] . '</div>';
             }
             $operatorValue = $res;
             break;
         case 'editor_warning':
             $res = false;
             $user = eZUser::currentUser();
             if ($user->hasAccessTo('content', 'dashboard')) {
                 $res = '<div class="editor-warning alert alert-warning"><strong>Avviso per l\'editor</strong>: ' . $namedParameters['text'] . '</div>';
             }
             $operatorValue = $res;
             break;
         case 'appini':
             if ($appini->hasVariable($namedParameters['block'], $namedParameters['setting'])) {
                 $rs = $appini->variable($namedParameters['block'], $namedParameters['setting']);
             } else {
                 $rs = $namedParameters['default'];
             }
             $operatorValue = $rs;
             break;
         case 'has_attribute':
         case 'attribute':
             if ($operatorName == 'attribute' && $namedParameters['show_values'] == 'show') {
                 $legacy = new eZTemplateAttributeOperator();
                 $parameters = $legacy->namedParameterList();
                 if (isset($parameters['attribute'])) {
                     $parameters = $parameters['attribute'];
                 }
                 $legacyParameters = array();
                 foreach (array_keys($parameters) as $key) {
                     switch ($key) {
                         case "as_html":
                             $legacyParameters[$key] = true;
                             break;
                         default:
                             $legacyParameters[$key] = isset($namedParameters[$key]) ? $namedParameters[$key] : false;
                     }
                 }
                 $legacy->modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, $operatorValue, $legacyParameters, null);
                 return $operatorValue;
             }
             return $operatorValue = $this->hasContentObjectAttribute($operatorValue, $namedParameters['show_values']);
             break;
         case 'set_defaults':
             if (is_array($namedParameters['variables'])) {
                 foreach ($namedParameters['variables'] as $key => $value) {
                     if (!$tpl->hasVariable($key, $currentNamespace)) {
                         $tpl->setLocalVariable($key, $value, $currentNamespace);
                     }
                 }
             }
             break;
         case 'unset_defaults':
             foreach ($namedParameters['variables'] as $key) {
                 $tpl->unsetLocalVariable($key, $currentNamespace);
                 //                    if ( isset( $tpl->Variables[$rootNamespace] ) &&
                 //                         array_key_exists( $key, $tpl->Variables[$rootNamespace] ) )
                 //                    {
                 //                        $tpl->unsetVariable( $key, $rootNamespace );
                 //                    }
             }
             break;
             //@todo add cache!
         //@todo add cache!
         case 'include_cache':
             $tpl = eZTemplate::factory();
             foreach ($namedParameters['variables'] as $key => $value) {
                 $tpl->setVariable($key, $value);
             }
             $operatorValue = $tpl->fetch('design:' . $namedParameters['template']);
             break;
         case 'find_global_layout':
             $result = false;
             $node = $operatorValue;
             if (is_numeric($node)) {
                 $node = eZContentObjectTreeNode::fetch($node);
             }
             if (!$node) {
                 return $operatorValue = $result;
             }
             $pathArray = $node->attribute('path_array');
             $nodesParams = array();
             foreach ($pathArray as $pathNodeID) {
                 if ($pathNodeID < eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode') || $pathNodeID == $node->attribute('node_id')) {
                     continue;
                 } else {
                     $nodesParams[] = array('ParentNodeID' => $pathNodeID, 'ResultID' => 'ezcontentobject_tree.node_id', 'ClassFilterType' => 'include', 'ClassFilterArray' => $ini->variable('GlobalLayout', 'Classes'), 'Depth' => 1, 'DepthOperator' => 'eq', 'AsObject' => false);
                 }
             }
             //eZDebug::writeWarning( var_export($nodesParams,1), __METHOD__);
             $findNodes = eZContentObjectTreeNode::subTreeMultiPaths($nodesParams, array('SortBy' => array('node_id', false)));
             $sortByParentNodeID = array();
             if (!empty($findNodes)) {
                 foreach ($findNodes as $findNode) {
                     $sortByParentNodeID[$findNode['parent_node_id']] = $findNode;
                 }
                 krsort($sortByParentNodeID);
                 $result = array_shift($sortByParentNodeID);
                 $result = eZContentObjectTreeNode::makeObjectsArray(array($result));
                 if (!empty($result)) {
                     $result = $result[0];
                 }
             }
             return $operatorValue = $result;
         case 'redirect':
             $url = $namedParameters['url'];
             header('Location: ' . $url);
             break;
         case 'sort_nodes':
             $sortNodes = array();
             if (!empty($operatorValue) && is_array($operatorValue)) {
                 $nodes = $operatorValue;
                 foreach ($nodes as $node) {
                     if (!$node instanceof eZContentObjectTreeNode) {
                         continue;
                     }
                     $object = $node->object();
                     switch ($namedParameters['by']) {
                         case 'published':
                         default:
                             $sortby = $object->attribute('published');
                             break;
                     }
                     $sortNodes[$sortby] = $node;
                 }
                 ksort($sortNodes);
                 if ($namedParameters['order'] == 'desc') {
                     $sortNodes = array_reverse($sortNodes);
                 }
             }
             return $operatorValue = $sortNodes;
             break;
         case 'to_query_string':
             if (!empty($namedParameters['param'])) {
                 $value = $namedParameters['param'];
             } else {
                 $value = $operatorValue;
             }
             $string = http_build_query($value);
             return $operatorValue = $string;
             break;
         case 'has_abstract':
         case 'abstract':
             $node = $operatorValue;
             if (!$node instanceof eZContentObjectTreeNode && isset($namedParameters['node'])) {
                 $node = $namedParameters['node'];
                 if (is_numeric($node)) {
                     $node = eZContentObjectTreeNode::fetch($node);
                 }
             }
             return $operatorValue = $this->getAbstract($node, $operatorName == 'has_abstract');
             break;
         case 'subsite':
             $path = $this->getPath($tpl);
             $result = false;
             $identifiers = $ini->hasVariable('Subsite', 'Classes') ? $ini->variable('Subsite', 'Classes') : array();
             $root = eZContentObjectTreeNode::fetch(eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode'));
             if (in_array($root->attribute('class_identifier'), $identifiers)) {
                 $result = $root;
             }
             foreach ($path as $item) {
                 if (isset($item['node_id'])) {
                     $node = eZContentObjectTreeNode::fetch($item['node_id']);
                     if (in_array($node->attribute('class_identifier'), $identifiers)) {
                         $result = $node;
                     }
                 }
             }
             return $operatorValue = $result;
             break;
         case 'in_subsite':
             $result = false;
             $identifiers = $ini->hasVariable('Subsite', 'Classes') ? $ini->variable('Subsite', 'Classes') : array();
             $root = eZContentObjectTreeNode::fetch(eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode'));
             if (in_array($root->attribute('class_identifier'), $identifiers)) {
                 $result = $root;
             }
             $node = $operatorValue;
             if (is_numeric($node)) {
                 $node = eZContentObjectTreeNode::fetch($node);
             }
             if (!$node) {
                 return $operatorValue = $result;
             }
             foreach ($node->attribute('path') as $item) {
                 if (in_array($item->attribute('class_identifier'), $identifiers)) {
                     $result = $item;
                     break;
                 }
             }
             return $operatorValue = $result;
             break;
         case 'is_subsite':
             $identifiers = $ini->hasVariable('Subsite', 'Classes') ? $ini->variable('Subsite', 'Classes') : array();
             $inSubsite = false;
             $node = $operatorValue;
             if (is_numeric($node)) {
                 $node = eZContentObjectTreeNode::fetch($node);
             }
             if (!$node instanceof eZContentObjectTreeNode) {
                 $inSubsite = false;
             } elseif (in_array($node->attribute('class_identifier'), $identifiers)) {
                 $inSubsite = true;
             }
             return $operatorValue = $inSubsite;
             break;
         case 'is_in_subsite':
             if ($operatorValue instanceof eZContentObject) {
                 $nodes = $operatorValue->attribute('assigned_nodes');
                 foreach ($nodes as $node) {
                     if ($this->isNodeInCurrentSiteaccess($node)) {
                         return $operatorValue;
                     }
                 }
             } elseif ($operatorValue instanceof eZContentObjectTreeNode) {
                 if ($this->isNodeInCurrentSiteaccess($operatorValue)) {
                     return $operatorValue;
                 }
             }
             return $operatorValue = false;
         case 'section_color':
             $path = $this->getPath($tpl);
             $color = false;
             $attributesIdentifiers = $ini->hasVariable('Color', 'Attributes') ? $ini->variable('Color', 'Attributes') : array();
             foreach ($path as $item) {
                 if (isset($item['node_id'])) {
                     $node = eZContentObjectTreeNode::fetch($item['node_id']);
                     /** @var eZContentObjectAttribute[] $attributes */
                     $attributes = $node->attribute('object')->fetchAttributesByIdentifier($attributesIdentifiers);
                     if (is_array($attributes)) {
                         foreach ($attributes as $attribute) {
                             if ($attribute->hasContent()) {
                                 $color = $attribute->content();
                             }
                         }
                     }
                 }
             }
             return $operatorValue = $color;
             break;
         case 'oc_shorten':
             $search = array('@<script[^>]*?>.*?</script>@si', '@<style[^>]*?>.*?</style>@siU');
             $operatorValue = preg_replace($search, '', $operatorValue);
             $operatorValue = strip_tags($operatorValue, $namedParameters['allowable_tags']);
             $operatorValue = preg_replace('!\\s+!', ' ', $operatorValue);
             $operatorValue = str_replace('&nbsp;', ' ', $operatorValue);
             $strlenFunc = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
             $operatorLength = $strlenFunc($operatorValue);
             if ($operatorLength > $namedParameters['chars_to_keep']) {
                 if ($namedParameters['trim_type'] === 'middle') {
                     $appendedStrLen = $strlenFunc($namedParameters['str_to_append']);
                     if ($namedParameters['chars_to_keep'] > $appendedStrLen) {
                         $chop = $namedParameters['chars_to_keep'] - $appendedStrLen;
                         $middlePos = (int) ($chop / 2);
                         $leftPartLength = $middlePos;
                         $rightPartLength = $chop - $middlePos;
                         $operatorValue = trim($this->custom_substr($operatorValue, 0, $leftPartLength) . $namedParameters['str_to_append'] . $this->custom_substr($operatorValue, $operatorLength - $rightPartLength, $rightPartLength));
                     } else {
                         $operatorValue = $namedParameters['str_to_append'];
                     }
                 } else {
                     $chop = $namedParameters['chars_to_keep'] - $strlenFunc($namedParameters['str_to_append']);
                     $operatorValue = $this->custom_substr($operatorValue, 0, $chop);
                     $operatorValue = trim($operatorValue);
                     if ($operatorLength > $chop) {
                         $operatorValue = $operatorValue . $namedParameters['str_to_append'];
                     }
                 }
             }
             if ($namedParameters['allowable_tags'] !== '') {
                 $operatorValue = $this->force_balance_tags($operatorValue);
             }
             break;
         case 'cookieset':
             $key = isset($namedParameters['cookie_name']) ? $namedParameters['cookie_name'] : false;
             $prefix = $ini->variable('CookiesSettings', 'CookieKeyPrefix');
             $key = "{$prefix}{$key}";
             // Get our parameters:
             $value = $namedParameters['cookie_val'];
             $expire = $namedParameters['expiry_time'];
             // Check and calculate the expiry time:
             if ($expire > 0) {
                 // It is a number of days:
                 $expire = time() + 60 * 60 * 24 * $expire;
             }
             setcookie($key, $value, $expire, '/');
             eZDebug::writeDebug('setcookie(' . $key . ', ' . $value . ', ' . $expire . ', "/")', __METHOD__);
             return $operatorValue = false;
             break;
         case 'cookieget':
             $key = isset($namedParameters['cookie_name']) ? $namedParameters['cookie_name'] : false;
             $prefix = $ini->variable('CookiesSettings', 'CookieKeyPrefix');
             $key = "{$prefix}{$key}";
             $operatorValue = false;
             if (isset($_COOKIE[$key])) {
                 $operatorValue = $_COOKIE[$key];
             }
             return $operatorValue;
             break;
         case 'check_and_set_cookies':
             $prefix = $ini->variable('CookiesSettings', 'CookieKeyPrefix');
             $http = eZHTTPTool::instance();
             $return = array();
             if ($ini->hasVariable('Cookies', 'Cookies')) {
                 $cookies = $ini->variable('Cookies', 'Cookies');
                 foreach ($cookies as $key) {
                     $_key = "{$prefix}{$key}";
                     $default = isset($_COOKIE[$_key]) ? $_COOKIE[$_key] : $ini->variable($key, 'Default');
                     $value = $http->variable($key, $default);
                     setcookie($_key, $value, time() + 60 * 60 * 24 * 365, '/');
                     $return[$key] = $value;
                 }
             }
             $operatorValue = $return;
             break;
         case 'checkbrowser':
             @(require 'extension/ocoperatorscollection/lib/browser_detection.php');
             if (function_exists('browser_detection')) {
                 $full = browser_detection('full_assoc', 2);
                 $operatorValue = $full;
             } else {
                 eZDebug::writeError("function browser_detection not found", __METHOD__);
             }
             break;
         case 'is_deprecated_browser':
             $browser = $namedParameters['browser_array'];
             if ($browser['browser_working'] == 'ie' && $browser['browser_number'] > '7.0') {
                 $operatorValue = true;
             }
             $operatorValue = false;
             break;
         case 'slugize':
             $operatorValue = $this->sanitize_title_with_dashes($operatorValue);
             break;
     }
     return false;
 }
Exemple #12
0
 function exportCollectionObjectHeader(&$attributes_to_export)
 {
     $resultstring = array();
     foreach ($attributes_to_export as $attributeid) {
         if ($attributeid == "contentobjectid") {
             array_push($resultstring, "ID");
         } else {
             if ($attributeid == -1) {
                 array_push($resultstring, "");
             } else {
                 if ($attributeid != -2) {
                     $attribute =& eZContentClassAttribute::fetch($attributeid);
                     $attribute_name = $attribute->name();
                     $attribute_name_escaped = preg_replace("(\r\n|\n|\r)", " ", $attribute_name);
                     $attribute_name_escaped = utf8_decode($attribute_name_escaped);
                     array_push($resultstring, $attribute_name_escaped);
                     // works for 3.8 only
                     // array_push( $resultstring, $attribute->Name );
                 }
             }
         }
     }
     return $resultstring;
 }
<?php 
require "autoload.php";
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => 'Update the datatype ezenhancedselection to the new version', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$script->initialize();
$cli->output('Updating ezenhancedselection to sckenhancedselection...');
$cli->output();
// Find all class attributes based on ezenhancedselection
$db = eZDB::instance();
$IDs = $db->arrayQuery("SELECT id\n    FROM ezcontentclass_attribute\n    WHERE version = 0 AND data_type_string = 'ezenhancedselection'");
$cli->output($cli->stylize('bold', 'Updating class attributes'));
if (is_array($IDs) and count($IDs) > 0) {
    foreach ($IDs as $id) {
        $cli->output('Updating class attribute: ID - ' . $id['id']);
        $classAttribute = eZContentClassAttribute::fetch($id['id']);
        $content = $classAttribute->content();
        $classAttribute->setAttribute('data_type_string', 'sckenhancedselection');
        $classAttribute->DataTypeString = 'sckenhancedselection';
        $classAttribute->setContent($content);
        $classAttribute->store();
        $classAttribute->setAttribute('data_int1', 0);
        $classAttribute->setAttribute('data_text1', '');
        $classAttribute->store();
        unset($classAttribute);
    }
} else {
    $cli->output('No class attributes to update!');
}
$IDs = $db->arrayQuery("SELECT id, version\n    FROM ezcontentobject_attribute\n    WHERE data_type_string = 'ezenhancedselection'");
$cli->output();
 function fetchClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     $startValueName = $base . self::START_VALUE_VARIABLE . $classAttribute->attribute("id");
     $digitsName = $base . self::DIGITS_VARIABLE . $classAttribute->attribute("id");
     $preTextName = $base . self::PRETEXT_VARIABLE . $classAttribute->attribute("id");
     $postTextName = $base . self::POSTTEXT_VARIABLE . $classAttribute->attribute("id");
     if ($http->hasPostVariable($startValueName) and $http->hasPostVariable($digitsName) and $http->hasPostVariable($preTextName) and $http->hasPostVariable($postTextName)) {
         $startValueValue = str_replace(" ", "", $http->postVariable($startValueName));
         $startValueValue = (int) $startValueValue;
         if ($startValueValue < 1) {
             $startValueValue = 1;
         }
         $digitsValue = str_replace(" ", "", $http->postVariable($digitsName));
         $digitsValue = (int) $digitsValue;
         if ($digitsValue < 1) {
             $digitsValue = 1;
         }
         $preTextValue = $http->postVariable($preTextName);
         $postTextValue = $http->postVariable($postTextName);
         $classAttribute->setAttribute(self::DIGITS_FIELD, $digitsValue);
         $classAttribute->setAttribute(self::PRETEXT_FIELD, $preTextValue);
         $classAttribute->setAttribute(self::POSTTEXT_FIELD, $postTextValue);
         $classAttribute->setAttribute(self::START_VALUE_FIELD, $startValueValue);
         $classAttribute->setAttribute(self::IDENTIFIER_FIELD, $classAttribute->attribute(self::START_VALUE_FIELD));
         $originalClassAttribute = eZContentClassAttribute::fetch($classAttribute->attribute('id'), true, 0);
         if ($originalClassAttribute) {
             if ($originalClassAttribute->attribute(self::DIGITS_FIELD) == $digitsValue && $originalClassAttribute->attribute(self::PRETEXT_FIELD) == $preTextValue && $originalClassAttribute->attribute(self::POSTTEXT_FIELD) == $postTextValue && $originalClassAttribute->attribute(self::IDENTIFIER_FIELD) >= $startValueValue) {
                 $classAttribute->setAttribute(self::START_VALUE_FIELD, $originalClassAttribute->attribute(self::START_VALUE_FIELD));
                 $classAttribute->setAttribute(self::IDENTIFIER_FIELD, $originalClassAttribute->attribute(self::IDENTIFIER_FIELD));
             }
         }
     }
     return true;
 }
<?php 
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "Converts ezkeyword datatype content to eztags datatype content.\n" . "Since the script would require as many publish operations as there are translations\n" . "per each object, the script will not republish the objects, but rather update\n" . "the current version of currently published objects. Because of that, you will\n" . "need to take care of clearing relevant caches, reindexing and so on.\n" . "php extension/eztags/bin/php/convertezkeyword.php --from-attr-id=123 --to-attr-id=456 --parent-tag-id=42", 'use-session' => true, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[from-attr-id:][to-attr-id:][parent-tag-id:]", "", array('from-attr-id' => "Specifies source class attribute ID.\n" . "Must be of ezkeyword type", 'to-attr-id' => "Specifies destination class attribute ID.\n" . "Must be of eztags type and located in the same class as from-attr-id", 'parent-tag-id' => "Specifies where in tags tree will new tags be located.\n" . "Cannot be a synonym."));
$script->initialize();
if (!isset($options['from-attr-id']) || !isset($options['to-attr-id']) || !isset($options['parent-tag-id'])) {
    $cli->output("Some of the required parameters are missing.\n" . "Please run the script with --help option to see how to run the script properly.");
    $script->shutdown(1);
}
$sourceClassAttributeID = (int) $options['from-attr-id'];
$destClassAttributeID = (int) $options['to-attr-id'];
$parentTagID = (int) $options['parent-tag-id'];
$sourceClassAttribute = eZContentClassAttribute::fetch($sourceClassAttributeID);
$destClassAttribute = eZContentClassAttribute::fetch($destClassAttributeID);
$parentTag = eZTagsObject::fetch($parentTagID);
if (!$sourceClassAttribute instanceof eZContentClassAttribute || $sourceClassAttribute->attribute('data_type_string') != 'ezkeyword') {
    $cli->output("Invalid source class attribute.");
    $script->shutdown(1);
}
if (!$destClassAttribute instanceof eZContentClassAttribute || $destClassAttribute->attribute('data_type_string') != 'eztags' || $sourceClassAttribute->attribute('contentclass_id') != $destClassAttribute->attribute('contentclass_id')) {
    $cli->output("Invalid destination class attribute.");
    $script->shutdown(1);
}
if (!$parentTag instanceof eZTagsObject || (int) $parentTag->attribute('main_tag_id') != 0) {
    $cli->output("Invalid parent tag.");
    $script->shutdown(1);
}
$cli->warning("This script will NOT republish objects, but rather update the CURRENT");
$cli->warning("version of published objects. If you do not wish to do that, you have");
 function addAttribute($attributeID)
 {
     $status = false;
     if (is_numeric($attributeID)) {
         $classAttribute = eZContentClassAttribute::fetch($attributeID);
         if ($classAttribute instanceof eZContentClassAttribute) {
             if ($classAttribute->attribute('data_type_string') == 'ezisbn') {
                 if ($classAttribute->attribute('data_int1') == 1 or $this->Force === true) {
                     $this->AttributeArray[$classAttribute->attribute('id')] = $classAttribute;
                 } else {
                     $this->Cli->output($this->Cli->stylize('warning', 'Warning:') . ' The attribute id ' . $this->Cli->stylize('strong', $attributeID) . ' is not set to ISBN-13. Use --force to set the ISBN-13 flag');
                 }
             } else {
                 $this->Cli->output($this->Cli->stylize('warning', 'Warning:') . ' The attribute id ' . $this->Cli->stylize('strong', $attributeID) . ' is not an ISBN datatype but of type ' . $this->Cli->stylize('strong', $classAttribute->attribute('data_type_string')) . '.');
             }
         } else {
             $this->Cli->output($this->Cli->stylize('warning', 'Warning:') . ' The attribute id ' . $this->Cli->stylize('strong', $attributeID) . ' does not exist.');
         }
     } else {
         if ($attributeID !== null) {
             $this->Cli->output($this->Cli->stylize('error', 'Error:') . ' the attribute id need to be numeric.');
             $status = true;
         }
     }
     return $status;
 }
Exemple #17
0
    $ini = eZINI::instance('nxc_captcha.ini');
    $params['length'] = $ini->variable('CaptchaSettings', 'Length');
    $params['type'] = $ini->variable('CaptchaSettings', 'Type');
    $params['width'] = $ini->variable('CaptchaSettings', 'Width');
    $params['height'] = $ini->variable('CaptchaSettings', 'Height');
    $params['noise_level'] = $ini->variable('CaptchaSettings', 'NoiseLevel');
    $params['text_tilt_angle'] = $ini->variable('CaptchaSettings', 'TextTiltAngle');
    $params['characters_color'] = $ini->variable('CaptchaSettings', 'CharactersColor');
    $params['background_color'] = $ini->variable('CaptchaSettings', 'BackgroundColor');
    $params['noise_color'] = $ini->variable('CaptchaSettings', 'NoiseColor');
    $params['skip_user_ids'] = $ini->variable('CaptchaSettings', 'SkipUserIds');
    $params['skip_role_ids'] = $ini->variable('CaptchaSettings', 'SkipRoleIds');
    $params['exclude_characters'] = $ini->variable('CaptchaSettings', 'ExcludeCharacters');
} else {
    // Generate from Object Attribute
    $attribute = eZContentClassAttribute::fetch($Params['classAttributeID']);
    if ($attribute instanceof eZContentClassAttribute === false) {
        echo ezpI18n::tr('extension/nxc_captcha', 'Can`t fetch class attribute (ID: %id)', null, array('%id' => htmlspecialchars($Params['classAttributeID'], ENT_QUOTES, 'UTF-8')));
        eZExecution::cleanExit();
    }
    $content = $attribute->attribute('content');
    foreach ($content as $option => $info) {
        if (isset($info['value'])) {
            $params[$option] = $info['value'];
        }
    }
}
if (isset($params['exclude_characters'])) {
    $params['exclude_characters'] = explode(',', $params['exclude_characters']);
}
$captcha = new nxcCaptcha($params, $Params['sessionKey'], (int) $Params['regenerate'] === 1);
 public static function fetchClassAttribute($attributeID, $versionID)
 {
     $attribute = eZContentClassAttribute::fetch($attributeID, true, $versionID);
     if ($attribute === null) {
         $result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
     } else {
         $result = array('result' => $attribute);
     }
     return $result;
 }
    /**
     * Get solr field name, from base name. The base name may either be a
     * meta-data name, or an eZ Publish content class attribute, specified by
     * <class identifier>/<attribute identifier>[/<option>]
     *
     * @param string $baseName Base field name.
     * @param boolean $includingClassID conditions the structure of the answer. See return value explanation.
     * @param $context is introduced in ez find 2.2 to allow for more optimal sorting, faceting, filtering
     *
     * @return mixed Internal base name. Returns null if no valid base name was provided.
     *               If $includingClassID is true, an associative array will be returned, as shown below :
     *               <code>
     *               array( 'fieldName'      => 'attr_title_t',
     *                      'contentClassId' => 16 );
     *               </code>
     */
    static function getFieldName( $baseName, $includingClassID = false, $context = 'search' )
    {
        // If the base name is a meta field, get the correct field name.
        if ( eZSolr::hasMetaAttributeType( $baseName, $context ) )
        {
            return eZSolr::getMetaFieldName( $baseName, $context );
        }
        else
        {
            // Get class and attribute identifiers + optional option.
            $subattribute = null;
            $fieldDef = explode( '/', $baseName );
            // Check if content class attribute ID is provided.
            if ( is_numeric( $fieldDef[0] ) )
            {
                if ( count( $fieldDef ) == 1 )
                {
                    $contentClassAttributeID = $fieldDef[0];
                }
                else if ( count( $fieldDef ) == 2 )
                {
                    list( $contentClassAttributeID, $subattribute ) = $fieldDef;
                }
            }
            else
            {
                switch( count( $fieldDef ) )
                {
                    case 1:
                    {
                        // Return fieldname as is.
                        return $baseName;
                    } break;

                    case 2:
                    {
                        // Field def contains class indentifier and class attribute identifier.
                        list( $classIdentifier, $attributeIdentifier ) = $fieldDef;
                    } break;

                    case 3:
                    {
                        // Field def contains class indentifier, class attribute identifier and optional specification.
                        list( $classIdentifier, $attributeIdentifier, $subattribute ) = $fieldDef;
                    } break;
                }
                $contentClassAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier( $classIdentifier . '/' . $attributeIdentifier );
            }
            if ( !$contentClassAttributeID )
            {
                eZDebug::writeNotice( 'Could not get content class from base name: ' . $baseName, __METHOD__ );
                return null;
            }
            $contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
            $fieldName = ezfSolrDocumentFieldBase::getFieldName( $contentClassAttribute, $subattribute, $context );

            if ( $includingClassID )
            {
                return array( 'fieldName'      => $fieldName,
                              'contentClassId' => $contentClassAttribute->attribute( 'contentclass_id' ) );
            }
            else
                return $fieldName;
        }
    }
 function contentClassAttribute()
 {
     return eZContentClassAttribute::fetch( $this->attribute( 'contentclass_attribute_id' ) );
 }
 function relateExistingObject($http, $action, $objectAttribute, $parameters)
 {
     $assignedNodesIDs = array();
     $module = $GLOBALS['module'];
     $objectID = $objectAttribute->attribute('contentobject_id');
     $contentObjectAttributeID = $objectAttribute->attribute('id');
     $contentClassAttributeID = $objectAttribute->attribute('contentclassattribute_id');
     $version = $objectAttribute->attribute('version');
     $languageCode = $objectAttribute->attribute('language_code');
     $postQuestionID = eZSurveyType::PREFIX_ATTRIBUTE . '_ezsurvey_id_' . $contentObjectAttributeID;
     $contentClassAttribute = eZContentClassAttribute::fetch($contentClassAttributeID);
     $classID = $contentClassAttribute->attribute('contentclass_id');
     $contentClass = eZContentClass::fetch($classID);
     $classIdentifier = $contentClass->attribute('identifier');
     $customActionButton = "CustomActionButton[" . $contentObjectAttributeID . "_ezsurvey_related_object_" . $this->ID . "_relate_existing_node]";
     eZContentBrowse::browse(array('action_name' => 'AddRelatedSurveyObject', 'persistent_data' => array($postQuestionID => $this->ID, 'ContentObjectAttribute_id[]' => $contentObjectAttributeID, 'ClassIdentifier' => $classIdentifier, 'ContentLanguageCode' => $languageCode, $customActionButton => $this->ID, 'HasObjectInput' => false), 'description_template' => 'design:content/browse_related.tpl', 'content' => array(), 'keys' => array(), 'ignore_nodes_select' => $assignedNodesIDs, 'from_page' => $module->redirectionURI('content', 'edit', array($objectID, $version, $languageCode))), $module);
     return eZModule::HOOK_STATUS_CANCEL_RUN;
 }
 /**
  * Get an array of class attribute identifiers based on either a class attribute
  * list, or a content classes list
  *
  * @param array $classIDArray
  *        Classes to search in. Either an array of class ID, class identifiers,
  *        a class ID or a class identifier.
  *        Using numerical attribute/class identifiers for $classIDArray is more efficient.
  * @param array $classAttributeID
  *        Class attributes to search in. Either an array of class attribute id,
  *        or a single class attribute. Literal identifiers are not allowed.
  * @param array $fieldTypeExcludeList
  *        filter list. List of field types to exclude. ( set to empty array by default ).
  *
  * @return array List of solr field names.
  */
 protected function getClassAttributes($classIDArray = false, $classAttributeIDArray = false, $fieldTypeExcludeList = null)
 {
     eZDebug::createAccumulator('Class attribute list', 'eZ Find');
     eZDebug::accumulatorStart('Class attribute list');
     $fieldArray = array();
     $classAttributeArray = array();
     // classAttributeIDArray = simple integer (content class attribute ID)
     if (is_numeric($classAttributeIDArray) and $classAttributeIDArray > 0) {
         $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeIDArray);
     } else {
         if (is_array($classAttributeIDArray)) {
             foreach ($classAttributeIDArray as $classAttributeID) {
                 $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeID);
             }
         }
     }
     // no class attribute list given, we need a class list
     // this block will create the class attribute array based on $classIDArray
     if (empty($classAttributeArray)) {
         // Fetch class list.
         $condArray = array("is_searchable" => 1, "version" => eZContentClass::VERSION_STATUS_DEFINED);
         if (!$classIDArray) {
             $classIDArray = array();
         } else {
             if (!is_array($classIDArray)) {
                 $classIDArray = array($classIDArray);
             }
         }
         // literal class identifiers are converted to numerical ones
         $tmpClassIDArray = $classIDArray;
         $classIDArray = array();
         foreach ($tmpClassIDArray as $key => $classIdentifier) {
             if (!is_numeric($classIdentifier)) {
                 if (!($contentClass = eZContentClass::fetchByIdentifier($classIdentifier, false))) {
                     eZDebug::writeWarning("Unknown content class identifier '{$classIdentifier}'", __METHOD__);
                 } else {
                     $classIDArray[] = $contentClass['id'];
                 }
             } else {
                 $classIDArray[] = $classIdentifier;
             }
         }
         if (!empty($classIDArray)) {
             $condArray['contentclass_id'] = array($classIDArray);
         }
         $classAttributeArray = eZContentClassAttribute::fetchFilteredList($condArray);
     }
     // $classAttributeArray now contains a list of eZContentClassAttribute
     // we can use to construct the list of fields solr should search in
     // @TODO : retrieve sub attributes here. Mind the types !
     foreach ($classAttributeArray as $classAttribute) {
         $fieldArray = array_merge(ezfSolrDocumentFieldBase::getFieldNameList($classAttribute, $fieldTypeExcludeList), $fieldArray);
     }
     // the array is unified + sorted in order to make it consistent
     $fieldArray = array_unique($fieldArray);
     sort($fieldArray);
     eZDebug::accumulatorStop('Class attribute list');
     return $fieldArray;
 }
 public function fetchHTTPInput($http, $base, $event)
 {
     if ($http->hasPostVariable('StoreButton') === false) {
         return true;
     }
     $affectedClassIDs = array();
     $optionNames = array('publish_only_on_create', 'include_url', 'shorten_url', 'shorten_handler', 'message_handler');
     $options = array();
     $var = 'WorkflowEvent_event_nxcsocialnetworkspublish_handler_options';
     if ($http->hasPostVariable($var)) {
         $options = (array) $http->postVariable($var);
     }
     $handlers = $event->attribute('handlers');
     foreach ($handlers as $handler) {
         $handlerOptionNames = $optionNames;
         if ($handler->attribute('has_extra_options')) {
             $handlerOptionNames = array_merge($optionNames, $handler->getExtraOptionNames());
         }
         foreach ($handlerOptionNames as $optionName) {
             $handler->setOptions($optionName, isset($options[$optionName][$handler->attribute('id')]) ? $options[$optionName][$handler->attribute('id')] : 0);
         }
         $handler->store();
         $handlerClassIDs = array();
         foreach ($handler->attribute('classattribute_ids') as $classAttrbitueID) {
             $attribute = eZContentClassAttribute::fetch($classAttrbitueID, false);
             if (is_array($attribute)) {
                 $handlerClassIDs[] = $attribute['contentclass_id'];
             }
             $affectedClassIDs = array_merge($affectedClassIDs, $handlerClassIDs);
         }
         $event->setAttribute('data_text1', serialize(array_unique($affectedClassIDs)));
     }
 }