private function solrMetaDataExists( $contentObjectID=0, $attributeIdentifier='', $subattr='' ) { try { $contentObject = eZContentObject::fetch( $contentObjectID ); $dataMap = $contentObject->dataMap(); if ( array_key_exists( $attributeIdentifier, $dataMap ) ) { $contentObjectAttribute = $dataMap[$attributeIdentifier]; $eZType = eZDataType::create( solrMetaDataType::DATA_TYPE_STRING ); $value = $eZType->getValue( $contentObjectAttribute->ID, $subattr ); return ( ! empty( $value ) ); } else { eZDebug::writeError( 'Object '.$contentObjectID.' has no attribute '.$attributeIdentifier, 'solrMetaDataExists Error' ); } return false; } catch ( Exception $e ) { eZDebug::writeError( $e, 'solrMetaDataExists Exception' ); return false; } }
public function __construct() { parent::__construct( self::DATA_TYPE_STRING, 'Serialized datas', array( 'translation_allowed' => false, 'serialize_supported' => true ) ); }
/** * @see ezfSolrDocumentFieldBase::getData() */ public function getData() { $returnArray = parent::getData(); $contentClassAttributeIdentifier = $this->ContentObjectAttribute->ContentClassAttributeIdentifier; $eZType = eZDataType::create( $this->ContentObjectAttribute->DataTypeString ); $attributeContent = $eZType->getValues( $this->ContentObjectAttribute->ID ); foreach( $attributeContent as $key => $value ) { if ( $value > 0 ) { $suffix = self::getPostFix( $contentClassAttributeIdentifier ); $attribute = 'attr_'.$contentClassAttributeIdentifier.'_'.$key.$suffix; $returnArray[$attribute] = $value; } } return $returnArray; }
/** * Return content action(s) which can be performed on object containing * the current datatype. Return format is array of arrays with key 'name' * and 'action'. 'action' can be mapped to url in datatype.ini * * @param eZContentClassAttribute $classAttribute * @return array */ function contentActionList($classAttribute) { $actionList = parent::contentActionList($classAttribute); $actionList[] = array('name' => ezpI18n::tr('kernel/classes/datatypes', 'Add to basket'), 'action' => 'ActionAddToBasket'); $actionList[] = array('name' => ezpI18n::tr('kernel/classes/datatypes', 'Add to wish list'), 'action' => 'ActionAddToWishList'); return $actionList; }
$options = $domRoot->getElementsByTagName('options')->item(0); $dom = $attributeParametersNode->ownerDocument; $importedOptionsNode = $dom->importNode($options, true); $attributeParametersNode->appendChild($importedOptionsNode); $isMultiSelectNode = $dom->createElement('is-multiselect'); $isMultiSelectNode->appendChild($dom->createTextNode($isMultipleSelection)); $attributeParametersNode->appendChild($isMultiSelectNode); } function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $options = $attributeParametersNode->getElementsByTagName('options')->item(0); $doc = new DOMDocument('1.0', 'utf-8'); $root = $doc->createElement('ezselection'); $doc->appendChild($root); $importedOptions = $doc->importNode($options, true); $root->appendChild($importedOptions); $xml = $doc->saveXML(); $classAttribute->setAttribute('data_text5', $xml); if ($attributeParametersNode->getElementsByTagName('is-multiselect')->item(0)->textContent == 0) { $classAttribute->setAttribute('data_int1', 0); } else { $classAttribute->setAttribute('data_int1', 1); } } function supportsBatchInitializeObjectAttribute() { return true; } } eZDataType::register(eZSelectionType::DATA_TYPE_STRING, "eZSelectionType");
$content->setAttribute('alternative_text', substr($string, $delimiterPos + 1)); } $content->store($objectAttribute); return true; } function supportsBatchInitializeObjectAttribute() { return true; } /** * Iterates over images referenced in data_text, and adds eZImageFile references * @param eZContentObjectAttribute $objectAttribute */ function postStore($objectAttribute) { $objectAttributeId = $objectAttribute->attribute("id"); if (($doc = simplexml_load_string($objectAttribute->attribute("data_text"))) === false) { return; } // Creates ezimagefile entries foreach ($doc->xpath("//*/@url") as $url) { $url = (string) $url; if ($url === "") { continue; } eZImageFile::appendFilepath($objectAttributeId, $url, true); } } } eZDataType::register(eZImageType::DATA_TYPE_STRING, "eZImageType");
/** * Constructor */ function __construct() { parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'extension/ezgmaplocation/datatype', "GMap Location", 'Datatype name' ), array( 'serialize_supported' => true ) ); }
function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultValue = $classAttribute->attribute('data_text1'); $dom = $attributeParametersNode->ownerDocument; $defaultValueNode = $dom->createElement('default-value'); $defaultValueNode->appendChild($dom->createTextNode($defaultValue)); $attributeParametersNode->appendChild($defaultValueNode); } function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultValue = $attributeParametersNode->getElementsByTagName('default-value')->item(0)->textContent; $classAttribute->setAttribute('data_text1', $defaultValue); } function serializeContentObjectAttribute($package, $objectAttribute) { $node = $this->createContentObjectAttributeDOMNode($objectAttribute); $dom = new DOMDocument('1.0', 'utf-8'); $success = $dom->loadXML($objectAttribute->attribute('data_text')); $importedRoot = $node->ownerDocument->importNode($dom->documentElement, true); $node->appendChild($importedRoot); return $node; } function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode) { $rootNode = $attributeNode->getElementsByTagName('ezmultioption')->item(0); $xmlString = $rootNode ? $rootNode->ownerDocument->saveXML($rootNode) : ''; $objectAttribute->setAttribute('data_text', $xmlString); } } eZDataType::register(eZMultiOptionType::DATA_TYPE_STRING, "eZMultiOptionType");
/** * Sets grouped_input to true for edit view of the datatype * * @param eZContentObjectAttribute $objectAttribute * @param array|bool $mergeInfo * * @return array */ public function objectDisplayInformation($objectAttribute, $mergeInfo = false) { return eZDataType::objectDisplayInformation($objectAttribute, array('edit' => array('grouped_input' => true))); }
function dataType() { $dataType = null; if ($this->DataTypeString !== null) { $dataType = eZDataType::create($this->DataTypeString); } return $dataType; }
/** * Constructor */ public function __construct() { parent::eZDataType(self::DATA_TYPE_STRING, 'AC Color picker'); }
break; case 'current-date': $classAttribute->setAttribute(self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_CURRENT_DATE); break; } } /*! \return the collect information action if enabled */ function contentActionList($classAttribute) { if ($classAttribute->attribute('is_information_collector') == true) { return array(array('name' => 'Send', 'action' => 'ActionCollectInformation')); } else { return array(); } } function isIndexable() { return true; } /*! \reimp */ function isInformationCollector() { return true; } } eZDataType::register(eZBirthdayType::DATA_TYPE_STRING, "ezbirthdaytype");
public function __construct() { parent::eZDataType(self::DATA_TYPE_STRING, ezpi18n::tr('ezdisqus/datatype', 'Disqus comments')); }
function customObjectAttributeHTTPAction($http, $action, $contentObjectAttribute, $parameters) { $contentobjectID = false; if (eZDataType::fetchActionValue($action, 'new_class', $classID) or $action == 'new_class') { if ($action == 'new_class') { $base = $parameters['base_name']; $classVariableName = $base . '_new_class'; if ($http->hasPostVariable($classVariableName)) { $classVariable = $http->postVariable($classVariableName); $classID = $classVariable[$contentObjectAttribute->attribute('id')]; $class = eZContentClass::fetch($classID); } else { return false; } } else { $class = eZContentClass::fetch($classID); } if ($class) { $classAttribute = $contentObjectAttribute->attribute('contentclass_attribute'); $class_content = $classAttribute->content(); $content = $contentObjectAttribute->content(); $priority = 0; for ($i = 0; $i < count($content['relation_list']); ++$i) { if ($content['relation_list'][$i]['priority'] > $priority) { $priority = $content['relation_list'][$i]['priority']; } } $base = $parameters['base_name']; $nodePlacement = false; $nodePlacementName = $base . '_object_initial_node_placement'; if ($http->hasPostVariable($nodePlacementName)) { $nodePlacementMap = $http->postVariable($nodePlacementName); if (isset($nodePlacementMap[$contentObjectAttribute->attribute('id')])) { $nodePlacement = $nodePlacementMap[$contentObjectAttribute->attribute('id')]; } } $relationItem = $this->createInstance($class, $priority + 1, $contentObjectAttribute, $nodePlacement); if ($class_content['default_placement']) { $relationItem['parent_node_id'] = $class_content['default_placement']['node_id']; } $content['relation_list'][] = $relationItem; $hasAttributeInput = false; $attributeInputVariable = $base . '_has_attribute_input'; if ($http->hasPostVariable($attributeInputVariable)) { $attributeInputMap = $http->postVariable($attributeInputVariable); if (isset($attributeInputMap[$contentObjectAttribute->attribute('id')])) { $hasAttributeInput = $attributeInputMap[$contentObjectAttribute->attribute('id')]; } } if ($hasAttributeInput) { $object = $relationItem['object']; $attributes = $object->contentObjectAttributes(); foreach ($attributes as $attribute) { $attributeBase = $base . '_ezorl_init_class_' . $object->attribute('contentclass_id') . '_attr_' . $attribute->attribute('contentclassattribute_id'); $oldAttributeID = $attribute->attribute('id'); $attribute->setAttribute('id', false); if ($attribute->fetchInput($http, $attributeBase)) { $attribute->setAttribute('id', $oldAttributeID); $attribute->store(); } } } $contentObjectAttribute->setContent($content); $contentObjectAttribute->store(); } else { eZDebug::writeError("Unknown class ID {$classID}, cannot instantiate object", __METHOD__); } } else { if (eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID) or $action == 'edit_objects' or $action == 'remove_objects') { $base = $parameters['base_name']; $selectionBase = $base . '_selection'; $selections = array(); $http = eZHTTPTool::instance(); if ($http->hasPostVariable($selectionBase)) { $selectionMap = $http->postVariable($selectionBase); $selections = $selectionMap[$contentObjectAttribute->attribute('id')]; } if ($contentobjectID !== false) { $selections[] = $contentobjectID; } if ($action == 'edit_objects' or eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID)) { $content = $contentObjectAttribute->content(); foreach ($content['relation_list'] as $key => $relationItem) { if (!$relationItem['is_modified'] and in_array($relationItem['contentobject_id'], $selections)) { $object = eZContentObject::fetch($relationItem['contentobject_id']); if ($object->attribute('can_edit')) { $content['relation_list'][$key]['is_modified'] = true; $translationSourceBase = $base . '_translation_source_' . $contentObjectAttribute->attribute('id') . '_' . $relationItem['contentobject_id']; $languageFrom = false; if ($http->hasPostVariable($translationSourceBase) && $http->postVariable($translationSourceBase) !== '') { $languageFrom = $http->postVariable($translationSourceBase); } $version = $object->createNewVersionIn($contentObjectAttribute->attribute('language_code'), $languageFrom); $content['relation_list'][$key]['contentobject_version'] = $version->attribute('version'); } } } $contentObjectAttribute->setContent($content); $contentObjectAttribute->store(); } else { if ($action == 'remove_objects') { $content = $contentObjectAttribute->content(); $relationList = $content['relation_list']; $newRelationList = array(); foreach ($relationList as $relationItem) { if (in_array($relationItem['contentobject_id'], $selections)) { $this->removeRelationObject($contentObjectAttribute, $relationItem); } else { $newRelationList[] = $relationItem; } } $content['relation_list'] = $newRelationList; $contentObjectAttribute->setContent($content); $contentObjectAttribute->store(); } } } else { if ($action == 'browse_objects') { $module = $parameters['module']; $redirectionURI = $parameters['current-redirection-uri']; $ini = eZINI::instance('content.ini'); $browseType = 'AddRelatedObjectListToDataType'; $browseTypeINIVariable = $ini->variable('ObjectRelationDataTypeSettings', 'ClassAttributeStartNode'); foreach ($browseTypeINIVariable as $value) { list($classAttributeID, $type) = explode(';', $value); if (is_numeric($classAttributeID) and $classAttributeID == $contentObjectAttribute->attribute('contentclassattribute_id') and strlen($type) > 0) { $browseType = $type; break; } } // Fetch the list of "allowed" classes . // A user can select objects of only those allowed classes when browsing. $classAttribute = $contentObjectAttribute->attribute('contentclass_attribute'); $classContent = $classAttribute->content(); if (isset($classContent['class_constraint_list'])) { $classConstraintList = $classContent['class_constraint_list']; } else { $classConstraintList = array(); } $browseParameters = array('action_name' => 'AddRelatedObject_' . $contentObjectAttribute->attribute('id'), 'type' => $browseType, 'browse_custom_action' => array('name' => 'CustomActionButton[' . $contentObjectAttribute->attribute('id') . '_set_object_relation_list]', 'value' => $contentObjectAttribute->attribute('id')), 'persistent_data' => array('HasObjectInput' => 0), 'from_page' => $redirectionURI); $base = $parameters['base_name']; $nodePlacementName = $base . '_browse_for_object_start_node'; if ($http->hasPostVariable($nodePlacementName)) { $nodePlacement = $http->postVariable($nodePlacementName); if (isset($nodePlacement[$contentObjectAttribute->attribute('id')])) { $browseParameters['start_node'] = eZContentBrowse::nodeAliasID($nodePlacement[$contentObjectAttribute->attribute('id')]); } } if (count($classConstraintList) > 0) { $browseParameters['class_array'] = $classConstraintList; } eZContentBrowse::browse($browseParameters, $module); } else { if ($action == 'set_object_relation_list') { if (!$http->hasPostVariable('BrowseCancelButton')) { $selectedObjectIDArray = $http->postVariable("SelectedObjectIDArray"); $content = $contentObjectAttribute->content(); $priority = 0; for ($i = 0; $i < count($content['relation_list']); ++$i) { if ($content['relation_list'][$i]['priority'] > $priority) { $priority = $content['relation_list'][$i]['priority']; } } if ($selectedObjectIDArray !== null) { foreach ($selectedObjectIDArray as $objectID) { // Check if the given object ID has a numeric value, if not go to the next object. if (!is_numeric($objectID)) { eZDebug::writeError("Related object ID (objectID): '{$objectID}', is not a numeric value.", __METHOD__); continue; } /* Here we check if current object is already in the related objects list. * If so, we don't add it again. * FIXME: Stupid linear search. Maybe there's some better way? */ $found = false; foreach ($content['relation_list'] as $i) { if ($i['contentobject_id'] == $objectID) { $found = true; break; } } if ($found) { continue; } ++$priority; $content['relation_list'][] = $this->appendObject($objectID, $priority, $contentObjectAttribute); $contentObjectAttribute->setContent($content); $contentObjectAttribute->store(); } } } } else { eZDebug::writeError("Unknown custom HTTP action: " . $action, 'eZObjectRelationListType'); } } } } }
/** * Creates an array with sorting SQL strings to be appended to a query * * @param array|bool $sortList * @param string $treeTableName * @param bool $allowCustomColumns * @return array */ static function createSortingSQLStrings($sortList, $treeTableName = 'ezcontentobject_tree', $allowCustomColumns = false) { $sortingInfo = array('sortCount' => 0, 'sortingFields' => " path_string ASC", 'attributeJoinCount' => 0, 'attributeFromSQL' => "", 'attributeTargetSQL' => "", 'attributeWhereSQL' => ""); if ($sortList and is_array($sortList) and count($sortList) > 0) { if (count($sortList) > 1 and !is_array($sortList[0])) { $sortList = array($sortList); } $sortingFields = ''; $sortCount = 0; $attributeJoinCount = 0; $stateJoinCount = 0; $attributeFromSQL = ""; $attributeWhereSQL = ""; $datatypeSortingTargetSQL = ""; foreach ($sortList as $sortBy) { if (is_array($sortBy) and count($sortBy) > 0) { if ($sortCount > 0) { $sortingFields .= ', '; } $sortField = $sortBy[0]; switch ($sortField) { case 'path': $sortingFields .= 'path_string'; break; case 'path_string': $sortingFields .= 'path_identification_string'; break; case 'published': $sortingFields .= 'ezcontentobject.published'; break; case 'modified': $sortingFields .= 'ezcontentobject.modified'; break; case 'modified_subnode': $sortingFields .= 'modified_subnode'; break; case 'section': $sortingFields .= 'ezcontentobject.section_id'; break; case 'node_id': $sortingFields .= $treeTableName . '.node_id'; break; case 'contentobject_id': $sortingFields .= 'ezcontentobject.id'; break; case 'depth': $sortingFields .= 'depth'; break; case 'class_identifier': $sortingFields .= 'ezcontentclass.identifier'; break; case 'class_name': $classNameFilter = eZContentClassName::sqlFilter(); $sortingFields .= 'contentclass_name'; $datatypeSortingTargetSQL .= ", {$classNameFilter['nameField']} AS contentclass_name"; $attributeFromSQL .= " INNER JOIN {$classNameFilter['from']} ON ({$classNameFilter['where']})"; break; case 'priority': $sortingFields .= $treeTableName . '.priority'; break; case 'name': $sortingFields .= 'ezcontentobject_name.name'; break; case 'attribute': $classAttributeID = $sortBy[2]; if (!is_numeric($classAttributeID)) { $classAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($classAttributeID); } $contentAttributeTableAlias = "a{$attributeJoinCount}"; $datatypeFromSQL = "ezcontentobject_attribute {$contentAttributeTableAlias}"; $datatypeWhereSQL = "\n {$contentAttributeTableAlias}.contentobject_id = ezcontentobject.id AND\n {$contentAttributeTableAlias}.contentclassattribute_id = {$classAttributeID} AND\n {$contentAttributeTableAlias}.version = ezcontentobject.current_version AND"; $datatypeWhereSQL .= eZContentLanguage::sqlFilter($contentAttributeTableAlias, 'ezcontentobject'); $dataType = eZDataType::create(eZContentObjectTreeNode::dataTypeByClassAttributeID($classAttributeID)); if (is_object($dataType) && $dataType->customSorting()) { $params = array(); $params['contentobject_attr_id'] = "{$contentAttributeTableAlias}.id"; $params['contentobject_attr_version'] = "{$contentAttributeTableAlias}.version"; $params['table_alias_suffix'] = "{$attributeJoinCount}"; $sql = $dataType->customSortingSQL($params); $datatypeFromSQL .= " INNER JOIN {$sql['from']} ON ({$sql['where']})"; $datatypeSortingFieldSQL = $sql['sorting_field']; $datatypeSortingTargetSQL .= ', ' . $sql['sorting_field']; } else { // Look up datatype for standard sorting $sortKeyType = eZContentObjectTreeNode::sortKeyByClassAttributeID($classAttributeID); switch ($sortKeyType) { case 'string': $sortKey = 'sort_key_string'; break; case 'int': default: $sortKey = 'sort_key_int'; break; } $datatypeSortingFieldSQL = "a{$attributeJoinCount}.{$sortKey}"; $datatypeSortingTargetSQL .= ', ' . $datatypeSortingFieldSQL; } $sortingFields .= "{$datatypeSortingFieldSQL}"; $attributeFromSQL .= " INNER JOIN {$datatypeFromSQL} ON ({$datatypeWhereSQL})"; $attributeJoinCount++; break; case 'state': $stateGroupID = $sortBy[2]; if (!is_numeric($stateGroupID)) { $stateGroup = eZContentObjectStateGroup::fetchByIdentifier($stateGroupID); if ($stateGroup) { $stateGroupID = $stateGroup->attribute('id'); } else { eZDebug::writeError("Unknown content object state group '{$stateGroupID}'"); continue 2; } } $stateAlias = "s{$stateJoinCount}"; $stateLinkAlias = "sl{$stateJoinCount}"; $sortingFields .= "{$stateAlias}.priority"; $datatypeSortingTargetSQL .= ", {$stateAlias}.priority"; $attributeFromSQL .= " INNER JOIN ezcobj_state {$stateAlias} ON ({$stateAlias}.group_id = {$stateGroupID})" . " INNER JOIN ezcobj_state_link {$stateLinkAlias}" . " ON ({$stateLinkAlias}.contentobject_id = ezcontentobject.id AND {$stateLinkAlias}.contentobject_state_id = {$stateAlias}.id)"; break; default: if ($allowCustomColumns) { $sortingFields .= $sortField; } else { eZDebug::writeWarning('Unknown sort field: ' . $sortField, __METHOD__); continue; } } $sortOrder = true; // true is ascending if (isset($sortBy[1])) { $sortOrder = $sortBy[1]; } $sortingFields .= $sortOrder ? " ASC" : " DESC"; ++$sortCount; } } $sortingInfo['sortCount'] = $sortCount; $sortingInfo['sortingFields'] = $sortingFields; $sortingInfo['attributeTargetSQL'] = $datatypeSortingTargetSQL; $sortingInfo['attributeJoinCount'] = $attributeJoinCount; $sortingInfo['attributeFromSQL'] = $attributeFromSQL; $sortingInfo['attributeWhereSQL'] = $attributeWhereSQL; } else { if ($sortList === array()) { $sortingInfo['sortingFields'] = ''; } } return $sortingInfo; }
$contentObjectAttribute->setAttribute('data_int', $category->attribute('id')); return true; } } return false; } /*! Returns the integer value. */ function title($contentObjectAttribute, $name = null) { $categoryID = $contentObjectAttribute->attribute("data_int"); $category = $categoryID > 0 ? eZProductCategory::fetch($categoryID) : false; return is_object($category) ? $category->attribute('name') : ''; } function diff($old, $new, $options = null) { return null; } function supportsBatchInitializeObjectAttribute() { return true; } function batchInitializeObjectAttributeData($classAttribute) { $default = 0; return array('data_int' => $default, 'sort_key_int' => $default); } } eZDataType::register(eZProductCategoryType::DATA_TYPE_STRING, "eZProductCategoryType");
function initializePackage($siteType, &$accessMap, $charset, &$extraLanguageCodes, &$allLanguages, &$primaryLanguage, &$admin, &$resultArray) { // Time limit #3: // We set the time limit to 5 minutes to ensure we have enough time // to initialize the site. However we only set if the current limit // is too small $maxTime = ini_get('max_execution_time'); if ($maxTime != 0 and $maxTime < 5 * 60) { @set_time_limit(5 * 60); } switch ($siteType['access_type']) { case 'port': $userSiteaccessName = $siteType['identifier'] . '_' . 'user'; $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin'; $accessMap['port'][$siteType['access_type_value']] = $userSiteaccessName; $accessMap['port'][$siteType['admin_access_type_value']] = $adminSiteaccessName; break; case 'hostname': $userSiteaccessName = $siteType['identifier'] . '_' . 'user'; $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin'; $accessMap['hostname'][$siteType['access_type_value']] = $userSiteaccessName; $accessMap['hostname'][$siteType['admin_access_type_value']] = $adminSiteaccessName; break; case 'url': default: $userSiteaccessName = $siteType['access_type_value']; $adminSiteaccessName = $siteType['admin_access_type_value']; $accessMap['url'][$siteType['access_type_value']] = $userSiteaccessName; $accessMap['url'][$siteType['admin_access_type_value']] = $adminSiteaccessName; break; } $accessMap['accesses'][] = $userSiteaccessName; $accessMap['accesses'][] = $adminSiteaccessName; $accessMap['sites'][] = $userSiteaccessName; $userDesignName = $siteType['identifier']; $languageObjects = $allLanguages; $databaseMap = eZSetupDatabaseMap(); $databaseInfo = $this->PersistenceList['database_info']; $databaseInfo['info'] = $databaseMap[$databaseInfo['type']]; $dbServer = $databaseInfo['server']; $dbPort = $databaseInfo['port']; // $dbName = $databaseInfo['dbname']; $dbSocket = $databaseInfo['socket']; $dbUser = $databaseInfo['user']; $dbPwd = $databaseInfo['password']; $dbCharset = $charset; $dbDriver = $databaseInfo['info']['driver']; $dbName = $siteType['database']; $dbParameters = array('server' => $dbServer, 'port' => $dbPort, 'user' => $dbUser, 'password' => $dbPwd, 'socket' => $dbSocket, 'database' => $dbName, 'charset' => $dbCharset); $db = eZDB::instance($dbDriver, $dbParameters, true); if (!$db->isConnected()) { $resultArray['errors'][] = array('code' => 'EZSW-005', 'text' => "Failed connecting to database {$dbName}\n" . $db->errorMessage()); return false; } eZDB::setInstance($db); $result = true; // Initialize the database by inserting schema and data if (!isset($siteType['existing_database'])) { $siteType['existing_database'] = false; } if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_REMOVE) { eZDBTool::cleanup($db); } if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) { $result = true; $schemaArray = eZDbSchema::read('share/db_schema.dba', true); if (!$schemaArray) { $resultArray['errors'][] = array('code' => 'EZSW-001', 'message' => "Failed loading database schema file share/db_schema.dba"); $result = false; } if ($result) { $result = true; $dataArray = eZDbSchema::read('share/db_data.dba', true); if (!$dataArray) { $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed loading database data file share/db_data.dba"); $result = false; } if ($result) { $schemaArray = array_merge($schemaArray, $dataArray); $schemaArray['type'] = strtolower($db->databaseName()); $schemaArray['instance'] = $db; $result = true; $dbSchema = eZDbSchema::instance($schemaArray); if (!$dbSchema) { $resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler"); $result = false; } if ($result) { $result = true; // This will insert the schema, then the data and // run any sequence value correction SQL if required $params = array('schema' => true, 'data' => true); if ($db->databaseName() == 'mysql') { $engines = $db->arrayQuery('SHOW ENGINES'); foreach ($engines as $engine) { if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) { $params['table_type'] = 'innodb'; break; } } } if (!$dbSchema->insertSchema($params)) { $resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage()); $result = false; } } } } if ($result) { // Inserting data from the dba-data files of the datatypes eZDataType::loadAndRegisterAllTypes(); $registeredDataTypes = eZDataType::registeredDataTypes(); foreach ($registeredDataTypes as $dataType) { if (!$dataType->importDBDataFromDBAFile()) { $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath()); } } } } if (!$result) { return false; } // Database initialization done // Prepare languages $primaryLanguageLocaleCode = $primaryLanguage->localeCode(); $primaryLanguageName = $primaryLanguage->languageName(); $prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes); $installParameters = array('path' => '.'); $installParameters['ini'] = array(); $siteINIChanges = array(); $url = $siteType['url']; if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) { $url = $matches[1]; } $siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']); $siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes)); $siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url); $siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false); $siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']); if (trim($dbSocket) != '') { $siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket; } else { $siteINIChanges['DatabaseSettings']['Socket'] = 'disabled'; } if ($admin['email']) { $siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false); $siteINIChanges['UserSettings'] = array('RegistrationEmail' => false); $siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false); } $siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages); if ($primaryLanguage->localeCode() == 'eng-GB') { $siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled'; } else { $siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled'; } $installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges; $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges; $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName); $installParameters['variables']['user_siteaccess'] = $userSiteaccessName; $installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName; $installParameters['variables']['design'] = $userDesignName; $tmpSiteINI = eZINI::create('site.ini'); // Set ReadOnlySettingsCheck to false: towards // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables. $tmpSiteINI->setReadOnlySettingsCheck(false); $tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']); // Change the current translation variables, before other parts start using them $tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']); $tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']); $tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']); $tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}"); /* $typeFunctionality = eZSetupFunctionality( $siteType['identifier'] ); $extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ? $this->PersistenceList['additional_packages'] : array(), $typeFunctionality['required'] ); $extraFunctionality = array_unique( $extraFunctionality ); */ // Add a policy to permit editors using OE eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*')); // Install site package and it's required packages $sitePackageName = $this->chosenSitePackage(); $sitePackage = eZPackage::fetch($sitePackageName); if (!is_object($sitePackage)) { $resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'"); return false; } $dependecies = $sitePackage->attribute('dependencies'); $requires = $dependecies['requires']; $requiredPackages = array(); // Include setting files $settingsFiles = $sitePackage->attribute('settings-files'); foreach ($settingsFiles as $settingsFileName) { if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) { include_once $sitePackage->path() . '/settings/' . $settingsFileName; } } // Call user function for additional setup tasks. if (function_exists('eZSitePreInstall')) { eZSitePreInstall($siteType); } // Make sure objects use the selected main language instead of eng-GB if ($primaryLanguageLocaleCode != 'eng-GB') { $engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB'); $engLanguageID = (int) $engLanguageObj->attribute('id'); $updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}"; $db->query($updateSql); eZContentLanguage::expireCache(); $primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode); // Add it if it is missing (most likely) if (!$primaryLanguageObj) { $primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName); } $primaryLanguageID = (int) $primaryLanguageObj->attribute('id'); // Find objects which are always available if ($db->databaseName() == 'oracle') { $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1"; } else { $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1"; } $objectList = array(); $list = $db->arrayQuery($sql); foreach ($list as $row) { $objectList[] = (int) $row['id']; } $inSql = 'IN ( ' . implode(', ', $objectList) . ')'; // Updates databases that have eng-GB data to the new locale. $updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'"; $db->query($updateSql); // Fix always available $updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}"; $db->query($updateSql); // attributes $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'"; $db->query($updateSql); // Fix always available $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}"; $db->query($updateSql); // version $updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}"; $db->query($updateSql); // Fix always available $updateSql = "UPDATE ezcontentobject_version\nSET\nlanguage_mask=language_mask+1\nWHERE\ncontentobject_id {$inSql}"; $db->query($updateSql); // object $updateSql = "UPDATE ezcontentobject\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}"; $db->query($updateSql); // Fix always available $updateSql = "UPDATE ezcontentobject\nSET\nlanguage_mask=language_mask+1\nWHERE\nid {$inSql}"; $db->query($updateSql); // content object state groups & states $mask = $primaryLanguageID | 1; $db->query("UPDATE ezcobj_state_group\n SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n WHERE default_language_id = {$engLanguageID}"); $db->query("UPDATE ezcobj_state\n SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n WHERE default_language_id = {$engLanguageID}"); $db->query("UPDATE ezcobj_state_group_language\n SET language_id = {$primaryLanguageID}\n WHERE language_id = {$engLanguageID}"); $db->query("UPDATE ezcobj_state_language\n SET language_id = {$primaryLanguageID}\n WHERE language_id = {$engLanguageID}"); // ezcontentclass_name $updateSql = "UPDATE ezcontentclass_name\nSET\nlanguage_locale='{$primaryLanguageLocaleCode}'\nWHERE\nlanguage_locale='eng-GB'"; $db->query($updateSql); // use high-level api, because it's impossible to update serialized names with direct sqls. // use direct access to 'NameList' to avoid unnecessary sql-requests and because // we do 'replacement' of existing language(with some 'id') with another language code. $contentClassList = eZContentClass::fetchList(); foreach ($contentClassList as $contentClass) { $classAttributes = $contentClass->fetchAttributes(); foreach ($classAttributes as $classAttribute) { $classAttribute->NameList->setName($classAttribute->NameList->name('eng-GB'), $primaryLanguageLocaleCode); $classAttribute->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode); $classAttribute->NameList->removeName('eng-GB'); $classAttribute->store(); } $contentClass->NameList->setName($contentClass->NameList->name('eng-GB'), $primaryLanguageLocaleCode); $contentClass->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode); $contentClass->NameList->removeName('eng-GB'); $contentClass->NameList->setHasDirtyData(false); // to not update 'ezcontentclass_name', because we've already updated it. $contentClass->store(); } } // Setup all languages foreach ($allLanguages as $languageObject) { $primaryLanguageObj = eZContentLanguage::fetchByLocale($languageObject->localeCode()); // Add it if it is missing (most likely) if (!$primaryLanguageObj) { $primaryLanguageObj = eZContentLanguage::addLanguage($languageObject->localeCode(), $languageObject->internationalLanguageName()); } } eZContentLanguage::expireCache(); // Make sure priority list is changed to the new chosen languages eZContentLanguage::setPrioritizedLanguages($prioritizedLanguages); if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) { $user = eZUser::instance(14); // Must be initialized to make node assignments work correctly if (!is_object($user)) { $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object"); return false; } // Make sure Admin is the currently logged in user // This makes sure all new/changed objects get this as creator $user->loginCurrent(); // by default(if 'language_map' is not set) create all necessary languages $languageMap = isset($this->PersistenceList['package_info']) && isset($this->PersistenceList['package_info']['language_map']) ? $this->PersistenceList['package_info']['language_map'] : true; if (is_array($languageMap) && count($languageMap) > 0) { // // Create necessary languages and set them as "prioritized languages" to avoid // drawbacks in fetch functions, like eZContentObjectTreeNode::fetch(). // $prioritizedLanguageObjects = eZContentLanguage::prioritizedLanguages(); // returned objects foreach ($languageMap as $fromLanguage => $toLanguage) { if ($toLanguage != 'skip') { $prioritizedLanguageObjects[] = eZContentLanguage::fetchByLocale($toLanguage, true); } } $prioritizedLanguageLocales = array(); foreach ($prioritizedLanguageObjects as $language) { $locale = $language->attribute('locale'); if (!in_array($locale, $prioritizedLanguageLocales)) { $prioritizedLanguageLocales[] = $locale; } } eZContentLanguage::setPrioritizedLanguages($prioritizedLanguageLocales); } foreach ($requires as $require) { if ($require['type'] != 'ezpackage') { continue; } $packageName = $require['name']; $package = eZPackage::fetch($packageName, false, false, false); if (is_object($package)) { $requiredPackages[] = $package; if ($package->attribute('install_type') == 'install') { $installParameters = array('use_dates_from_package' => true, 'site_access_map' => array('*' => $userSiteaccessName), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => $userDesignName), 'language_map' => $languageMap, 'restore_dates' => true, 'user_id' => $user->attribute('contentobject_id'), 'non-interactive' => true); $status = $package->install($installParameters); if (!$status) { $errorText = "Unable to install package '{$packageName}'"; if (isset($installParameters['error']['description'])) { $errorText .= ": " . $installParameters['error']['description']; } $resultArray['errors'][] = array('code' => 'EZSW-051', 'text' => $errorText); return false; } } } else { $resultArray['errors'][] = array('code' => 'EZSW-050', 'text' => "Could not fetch required package: '{$packageName}'"); return false; } unset($package); } } $GLOBALS['eZContentObjectDefaultLanguage'] = $primaryLanguageLocaleCode; $nodeRemoteMap = array(); $rows = $db->arrayQuery("SELECT node_id, remote_id FROM ezcontentobject_tree"); foreach ($rows as $row) { $remoteID = $row['remote_id']; if (strlen(trim($remoteID)) > 0) { $nodeRemoteMap[$remoteID] = $row['node_id']; } } $objectRemoteMap = array(); $rows = $db->arrayQuery("SELECT id, remote_id FROM ezcontentobject"); foreach ($rows as $row) { $remoteID = $row['remote_id']; if (strlen(trim($remoteID)) > 0) { $objectRemoteMap[$remoteID] = $row['id']; } } $classRemoteMap = array(); $rows = $db->arrayQuery("SELECT id, identifier, remote_id FROM ezcontentclass"); foreach ($rows as $row) { $remoteID = $row['remote_id']; if (strlen(trim($remoteID)) > 0) { $classRemoteMap[$remoteID] = array('id' => $row['id'], 'identifier' => $row['identifier']); } } $siteCSS = false; $classesCSS = false; foreach ($requiredPackages as $package) { if ($package->attribute('type') == 'sitestyle') { $fileList = $package->fileList('default'); foreach ($fileList as $file) { $fileIdentifier = $file["variable-name"]; if ($fileIdentifier == 'sitecssfile') { $siteCSS = $package->fileItemPath($file, 'default'); } else { if ($fileIdentifier == 'classescssfile') { $classesCSS = $package->fileItemPath($file, 'default'); } } } } } $parameters = array('node_remote_map' => $nodeRemoteMap, 'object_remote_map' => $objectRemoteMap, 'class_remote_map' => $classRemoteMap, 'preview_design' => $userDesignName, 'design_list' => array($userDesignName, 'admin2', 'admin'), 'user_siteaccess' => $userSiteaccessName, 'admin_siteaccess' => $adminSiteaccessName, 'package_object' => $sitePackage, 'siteaccess_urls' => $this->siteaccessURLs(), 'access_map' => $accessMap, 'site_type' => $siteType, 'all_language_codes' => $prioritizedLanguages); $siteINIStored = false; $siteINIAdminStored = false; $designINIStored = false; if (function_exists('eZSiteINISettings')) { $extraSettings = eZSiteINISettings($parameters); } else { $extraSettings = array(); } if (function_exists('eZSiteAdminINISettings')) { $extraAdminSettings = eZSiteAdminINISettings($parameters); } else { $extraAdminSettings = array(); } if (function_exists('eZSiteCommonINISettings')) { $extraCommonSettings = eZSiteCommonINISettings($parameters); } else { $extraCommonSettings = array(); } $isUntranslatedSettingAdded = false; foreach ($extraAdminSettings as $key => $extraAdminSetting) { if ($extraAdminSetting['name'] == 'site.ini') { $extraAdminSettings[$key]['settings']['RegionalSettings']['ShowUntranslatedObjects'] = 'enabled'; $isUntranslatedSettingAdded = true; break; } } if (!$isUntranslatedSettingAdded) { $extraAdminSettings[] = array('name' => 'site.ini', 'settings' => array('RegionalSettings' => array('ShowUntranslatedObjects' => 'enabled'))); } // Enable OE and ODF extensions by default $extensionsToEnable = array(); // Included in "fat" install, needs to override $extraCommonSettings extensions $extensionsPrepended = array('ezjscore', 'ezoe', 'ezformtoken'); foreach (array('ezie', 'ezodf', 'ezprestapiprovider', 'ezmultiupload', 'eztags', 'ezautosave', 'ez_network', 'ez_network_demo') as $extension) { if (file_exists("extension/{$extension}")) { $extensionsToEnable[] = $extension; } } $settingAdded = false; foreach ($extraCommonSettings as $key => $extraCommonSetting) { if ($extraCommonSetting['name'] == 'site.ini' && isset($extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'])) { $settingAdded = true; $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'] = array_merge($extensionsPrepended, $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'], $extensionsToEnable); break; } } if (!$settingAdded) { $extraCommonSettings[] = array('name' => 'site.ini', 'settings' => array('ExtensionSettings' => array('ActiveExtensions' => array_merge($extensionsPrepended, $extensionsToEnable)))); } // Enable dynamic tree menu for the admin interface by default $enableDynamicTreeMenuAdded = false; foreach ($extraAdminSettings as $key => $extraSetting) { if ($extraSetting['name'] == 'contentstructuremenu.ini') { if (isset($extraSetting['settings']['TreeMenu'])) { $extraAdminSettings[$key]['settings']['TreeMenu']['Dynamic'] = 'enabled'; } else { $extraAdminSettings[$key]['settings'] = array('TreeMenu' => array('Dynamic' => 'enabled')); } $enableDynamicTreeMenuAdded = true; break; } } if (!$enableDynamicTreeMenuAdded) { $extraAdminSettings[] = array('name' => 'contentstructuremenu.ini', 'settings' => array('TreeMenu' => array('Dynamic' => 'enabled'))); } $resultArray['common_settings'] = $extraCommonSettings; foreach ($extraSettings as $extraSetting) { if ($extraSetting === false) { continue; } $iniName = $extraSetting['name']; $settings = $extraSetting['settings']; $resetArray = false; if (isset($extraSetting['reset_arrays'])) { $resetArray = $extraSetting['reset_arrays']; } $tmpINI = eZINI::create($iniName); // Set ReadOnlySettingsCheck to false: towards // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables. $tmpINI->setReadOnlySettingsCheck(false); $tmpINI->setVariables($settings); if ($iniName == 'site.ini') { $siteINIStored = true; $tmpINI->setVariables($siteINIChanges); $tmpINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName); $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base')); } else { if ($iniName == 'design.ini') { if ($siteCSS) { $tmpINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS); } if ($classesCSS) { $tmpINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS); } $designINIStored = true; } } $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", $resetArray); if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) { // setting up appropriate data in look&feel object $templateLookClass = eZContentClass::fetchByIdentifier('template_look', true); if ($templateLookClass) { $objectList = $templateLookClass->objectList(); if ($objectList and count($objectList) > 0) { $templateLookObject = current($objectList); $dataMap = $templateLookObject->fetchDataMap(); if (isset($dataMap['title'])) { $dataMap['title']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteName']); $dataMap['title']->store(); } if (isset($dataMap['siteurl'])) { $dataMap['siteurl']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteURL']); $dataMap['siteurl']->store(); } if (isset($dataMap['email'])) { $dataMap['email']->setAttribute('data_text', $siteINIChanges['MailSettings']['AdminEmail']); $dataMap['email']->store(); } $objectName = $templateLookClass->contentObjectName($templateLookObject); $templateLookObject->setName($objectName); $templateLookObject->store(); } } } } foreach ($extraAdminSettings as $extraSetting) { if ($extraSetting === false) { continue; } $iniName = $extraSetting['name']; $settings = $extraSetting['settings']; $resetArray = false; if (isset($extraSetting['reset_arrays'])) { $resetArray = $extraSetting['reset_arrays']; } $tmpINI = eZINI::create($iniName); $tmpINI->setVariables($settings); if ($iniName == 'site.ini') { $siteINIAdminStored = true; $tmpINI->setVariables($siteINIChanges); $tmpINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true'); $tmpINI->setVariable('DesignSettings', 'SiteDesign', 'admin2'); $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin')); $tmpINI->setVariable('SiteSettings', 'LoginPage', 'custom'); $tmpINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard'); } $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$adminSiteaccessName}", $resetArray); } if (!$siteINIAdminStored) { $siteINI = eZINI::create('site.ini'); // Set ReadOnlySettingsCheck to false: towards // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables. $siteINI->setReadOnlySettingsCheck(false); $siteINI->setVariables($siteINIChanges); $siteINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true'); $siteINI->setVariable('DesignSettings', 'SiteDesign', 'admin2'); $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin')); $siteINI->setVariable('SiteSettings', 'LoginPage', 'custom'); $siteINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard'); $siteINI->save(false, '.append.php', false, false, "settings/siteaccess/{$adminSiteaccessName}", true); } if (!$siteINIStored) { $siteINI = eZINI::create('site.ini'); // Set ReadOnlySettingsCheck to false: towards // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables. $siteINI->setReadOnlySettingsCheck(false); $siteINI->setVariables($siteINIChanges); $siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName); $siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base')); $siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true); } if (!$designINIStored) { $designINI = eZINI::create('design.ini'); // Set ReadOnlySettingsCheck to false: towards // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables. $designINI->setReadOnlySettingsCheck(false); if ($siteCSS) { $designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS); } if ($classesCSS) { $designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS); } $designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}"); } eZDir::mkdir("design/" . $userDesignName); eZDir::mkdir("design/" . $userDesignName . "/templates"); eZDir::mkdir("design/" . $userDesignName . "/stylesheets"); eZDir::mkdir("design/" . $userDesignName . "/images"); eZDir::mkdir("design/" . $userDesignName . "/override"); eZDir::mkdir("design/" . $userDesignName . "/override/templates"); if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) { return true; } // Try and remove user/login without limitation from the anonymous user $anonRole = eZRole::fetchByName('Anonymous'); if (is_object($anonRole)) { $anonPolicies = $anonRole->policyList(); foreach ($anonPolicies as $anonPolicy) { if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') { $anonPolicy->removeThis(); break; } } } // Setup all roles according to site chosen and addons if (function_exists('eZSiteRoles')) { $extraRoles = eZSiteRoles($parameters); foreach ($extraRoles as $extraRole) { if (!$extraRole) { continue; } $extraRoleName = $extraRole['name']; $role = eZRole::fetchByName($extraRoleName); if (!is_object($role)) { $role = eZRole::create($extraRoleName); $role->store(); } $roleID = $role->attribute('id'); if (isset($extraRole['policies'])) { $extraPolicies = $extraRole['policies']; foreach ($extraPolicies as $extraPolicy) { if (isset($extraPolicy['limitation'])) { $role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']); } else { $role->appendPolicy($extraPolicy['module'], $extraPolicy['function']); } } } if (isset($extraRole['assignments'])) { $roleAssignments = $extraRole['assignments']; foreach ($roleAssignments as $roleAssignment) { $assignmentIdentifier = false; $assignmentValue = false; if (isset($roleAssignment['limitation'])) { $assignmentIdentifier = $roleAssignment['limitation']['identifier']; $assignmentValue = $roleAssignment['limitation']['value']; } $role->assignToUser($roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue); } } } } // Setup user preferences based on the site chosen and addons if (function_exists('eZSitePreferences')) { $prefs = eZSitePreferences($parameters); foreach ($prefs as $prefEntry) { if (!$prefEntry) { continue; } $prefUserID = $prefEntry['user_id']; foreach ($prefEntry['preferences'] as $pref) { $prefName = $pref['name']; $prefValue = $pref['value']; if (!eZPreferences::setValue($prefName, $prefValue, $prefUserID)) { $resultArray['errors'][] = array('code' => 'EZSW-070', 'text' => "Could not create ezpreference '{$prefValue}' for {$prefUserID}"); return false; } } } } $publishAdmin = false; $userAccount = eZUser::fetch(14); if (!is_object($userAccount)) { $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object"); return false; } $userObject = $userAccount->attribute('contentobject'); if (!is_object($userObject)) { $resultArray['errors'][] = array('code' => 'EZSW-021', 'text' => "Could not fetch administrator content object"); return false; } $newUserObject = $userObject->createNewVersion(false, false); if (!is_object($newUserObject)) { $resultArray['errors'][] = array('code' => 'EZSW-022', 'text' => "Could not create new version of administrator content object"); return false; } $dataMap = $newUserObject->attribute('data_map'); $error = false; if (trim($admin['email'])) { if (!isset($dataMap['user_account'])) { $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'user_account' attribute"); return false; } $userAccount->setInformation(14, 'admin', $admin['email'], $admin['password'], $admin['password']); $dataMap['user_account']->setContent($userAccount); $dataMap['user_account']->store(); $publishAdmin = true; $userAccount->store(); } if (trim($admin['first_name']) or trim($admin['last_name'])) { if (!isset($dataMap['first_name'])) { $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'first_name' field"); $error = true; } if (!isset($dataMap['last_name'])) { $resultArray['errors'][] = array('code' => 'EZSW-024', 'text' => "Administrator content object does not have a 'last_name' field"); $error = true; } if ($error) { return false; } $dataMap['first_name']->setAttribute('data_text', $admin['first_name']); $dataMap['first_name']->store(); $dataMap['last_name']->setAttribute('data_text', $admin['last_name']); $dataMap['last_name']->store(); $newUserObject->store(); $publishAdmin = true; } if ($publishAdmin) { $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newUserObject->attribute('contentobject_id'), 'version' => $newUserObject->attribute('version'))); if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) { $resultArray['errors'][] = array('code' => 'EZSW-025', 'text' => "Failed to properly publish the administrator object"); return false; } } // Call user function for additional setup tasks. if (function_exists('eZSitePostInstall')) { eZSitePostInstall($parameters); } // get all siteaccesses. do it via 'RelatedSiteAccessesList' settings. $adminSiteINI = eZINI::instance('site.ini' . '.append.php', "settings/siteaccess/{$adminSiteaccessName}"); $relatedSiteAccessList = $adminSiteINI->variable('SiteAccessSettings', 'RelatedSiteAccessList'); // Adding override for 'tiny_image' view for 'multi-option2' datatype foreach ($relatedSiteAccessList as $siteAccess) { $tmpOverrideINI = new eZINI('override.ini' . '.append.php', "settings/siteaccess/{$siteAccess}", null, null, null, true, true); $tmpOverrideINI->setVariable('tiny_image', 'Source', 'content/view/tiny.tpl'); $tmpOverrideINI->setVariable('tiny_image', 'MatchFile', 'tiny_image.tpl'); $tmpOverrideINI->setVariable('tiny_image', 'Subdir', 'templates'); $tmpOverrideINI->setVariable('tiny_image', 'Match', array('class_identifier' => 'image')); $tmpOverrideINI->save(); } $accessMap = $parameters['access_map']; // Call user function for some text which will be displayed at 'Finish' screen if (function_exists('eZSiteFinalText')) { $text = eZSiteFinalText($parameters); if (!isset($this->PersistenceList['final_text'])) { $this->PersistenceList['final_text'] = array(); } $this->PersistenceList['final_text'][] = $text; } // ensure that evaluated policy wildcards in the user info cache // will be up to date with the currently activated modules eZCache::clearByID('user_info_cache'); return true; }
function objectDisplayInformation($objectAttribute, $mergeInfo = false) { $classAttribute = $objectAttribute->contentClassAttribute(); $isOption = $classAttribute->attribute('data_int2'); $editGrouped = $isOption == false; $info = array('edit' => array('grouped_input' => $editGrouped), 'collection' => array('grouped_input' => $editGrouped)); return eZDataType::objectDisplayInformation($objectAttribute, $info); }
return $contentObjectAttribute->attribute("data_int"); } function hasObjectAttributeContent($contentObjectAttribute) { return true; } function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultValue = $classAttribute->attribute('data_int3'); $dom = $attributeParametersNode->ownerDocument; $defaultValueNode = $dom->createElement('default-value'); $defaultValueNode->setAttribute('is-set', $defaultValue ? 'true' : 'false'); $attributeParametersNode->appendChild($defaultValueNode); } function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultValue = strtolower($attributeParametersNode->getElementsByTagName('default-value')->item(0)->getAttribute('is-set')) == 'true'; $classAttribute->setAttribute('data_int3', $defaultValue); } function supportsBatchInitializeObjectAttribute() { return true; } function batchInitializeObjectAttributeData($classAttribute) { $default = $classAttribute->attribute("data_int3"); return array('data_int' => $default, 'sort_key_int' => $default); } } eZDataType::register(eZBooleanType::DATA_TYPE_STRING, "eZBooleanType");
function &generateOverrideSettingsArray( $siteAccessArray, $minimalTemplateSet ) { $datatypeHash = array(); $simpleMatchList = array(); $regexpMatchList = array(); foreach ( $siteAccessArray as $siteAccess ) { $overrideINI = eZINI::instance( 'override.ini', 'settings', null, null, true ); $overrideINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' ); $overrideINI->loadCache(); $matchBlock = false; $blockMatchArray = array(); foreach( array_keys( $this->NodeObjectArray ) as $nodeID ) { // Extract some information that will be used unset( $contentNode, $contentObject, $contentClass ); $contentNode = $this->NodeObjectArray[$nodeID]; $contentObject = $contentNode->attribute( 'object' ); $contentClass = $contentObject->attribute( 'content_class' ); $attributeList = $contentClass->fetchAttributes( false, false, false ); $datatypeList = array(); foreach ( $attributeList as $attribute ) { $datatypeList[] = $attribute['data_type_string']; if ( !isset( $datatypeHash[$attribute['data_type_string']] ) ) { $datatype = eZDataType::create( $attribute['data_type_string'] ); $datatypeHash[$attribute['data_type_string']] = $datatype; if ( !method_exists( $datatype, 'templateList' ) ) continue; $templateList = $datatype->templateList(); if ( $templateList === false ) continue; foreach ( $templateList as $templateMatch ) { if ( is_string( $templateMatch ) ) { $simpleMatchList[] = $templateMatch; } else if ( is_array( $templateMatch ) ) { if ( $templateMatch[0] == 'regexp' ) { $regexpMatchList[] = $templateMatch[1]; } } } } } $datatypeText = implode( '|', array_unique( $datatypeList ) ); foreach( array_keys( $overrideINI->groups() ) as $blockName ) { if ( isset( $blockMatchArray[$blockName] ) ) { continue; } $blockData = $overrideINI->group( $blockName ); $sourceName = $blockData['Source']; $matchSettings = false; if ( isset( $blockData['Match'] ) ) $matchSettings = $blockData['Match']; $matchValue = array(); $validMatch = true; $hasMatchType = false; if ( $matchSettings ) { foreach( array_keys( $matchSettings ) as $matchType ) { switch( $matchType ) { case 'object': { $hasMatchType = true; if ( $contentNode->attribute( 'contentobject_id' ) != $matchSettings[$matchType] ) { $validMatch = false; } else { $matchValue[$this->OverrideObjectRemoteID] = $contentObject->attribute( 'remote_id' ); } } break; case 'node': { $hasMatchType = true; if ( $nodeID != $matchSettings[$matchType] ) { $validMatch = false; } else { $matchValue[$this->OverrideNodeRemoteID] = $contentNode->attribute( 'remote_id' ); } } break; case 'parent_node': { $hasMatchType = true; if ( $contentNode->attribute( 'parent_node_id' ) != $matchSettings[$matchType] ) { $validMatch = false; } else { $parentNode = $contentNode->attribute( 'parent' ); $matchValue[$this->OverrideParentNodeRemoteID] = $parentNode->attribute( 'remote_id' ); } } break; case 'class': { $hasMatchType = true; if ( $contentObject->attribute( 'contentclass_id' ) != $matchSettings[$matchType] ) { $validMatch = false; } else { $matchValue[$this->OverrideClassRemoteID] = $contentClass->attribute( 'remote_id' ); } } break; case 'class_identifier': { $hasMatchType = true; if ( $contentObject->attribute( 'class_identifier' ) != $matchSettings[$matchType] ) { $validMatch = false; } } break; case 'section': { $hasMatchType = true; if ( $contentObject->attribute( 'section_id' ) != $matchSettings[$matchType] ) { $validMatch = false; } } break; case 'depth': { $hasMatchType = true; if ( $contentNode->attribute( 'depth' ) != $matchSettings[$matchType] ) { $validMatch = false; } } break; } if ( !$validMatch ) { break; } } } else { $validMatch = false; } if ( !$hasMatchType ) { // Datatype match, we include overrides for datatype templates if ( preg_match( "#^content/datatype/[a-zA-Z]+/(" . $datatypeText . ")\\.tpl$#", $sourceName ) ) { $validMatch = true; $hasMatchType = true; } else if ( in_array( $sourceName, $simpleMatchList ) ) { $validMatch = true; $hasMatchType = true; } else { foreach ( $regexpMatchList as $regexpMatch ) { if ( preg_match( $regexpMatch, $sourceName ) ) { $validMatch = true; $hasMatchType = true; } } } } if ( $validMatch ) { if ( !$minimalTemplateSet or $hasMatchType ) { $blockMatchArray[$blockName] = array_merge( $blockData, $matchValue ); } } } } $this->OverrideSettingsArray[$siteAccess] = $blockMatchArray; } $dom = new DOMDocument( '1.0', 'utf-8' ); $overrideSettingsListDOMNode = $dom->createElement( 'override-list' ); $dom->appendChild( $overrideSettingsListDOMNode ); foreach ( $this->OverrideSettingsArray as $siteAccess => $blockMatchArray ) { foreach( $blockMatchArray as $blockName => $iniGroup ) { unset( $blockMatchNode ); $blockMatchNode = $dom->createElement( 'block' ); $blockMatchNode->setAttribute( 'name', $blockName ); $blockMatchNode->setAttribute( 'site-access', $siteAccess ); $importedNode = $dom->importNode( eZContentObjectPackageHandler::createElementNodeFromArray( $blockName, $iniGroup ), true ); $blockMatchNode->appendChild( $importedNode ); $overrideSettingsListDOMNode->appendChild( $blockMatchNode ); } } return $overrideSettingsListDOMNode; }
function __construct() { parent::__construct(self::DATA_TYPE_STRING, ezpI18n::tr('kernel/classes/datatypes', "Selection", 'Datatype name'), array('serialize_supported' => true)); }
$subscriptionDataArr['list_array'] = $http->postVariable('Subscription_ListArray'); } foreach ($subscriptionDataArr['id_array'] as $listId) { if ($http->hasPostVariable("Subscription_OutputFormatArray_{$listId}")) { $subscriptionDataArr['list_output_format_array'][$listId] = $http->postVariable("Subscription_OutputFormatArray_{$listId}"); } else { $defaultOutputFormatId = 0; $subscriptionDataArr['list_output_format_array'][$listId] = array($defaultOutputFormatId); } } if ($isNewObjectDraft === true) { $existingNewsletterUser = false; } elseif ($subscriptionDataArr['ez_user_id'] > 0) { $existingNewsletterUser = CjwNewsletterUser::fetchByEzUserId($subscriptionDataArr['ez_user_id']); if (is_object($existingNewsletterUser) === false) { if ($subscriptionDataArr['email'] != '') { $existingNewsletterUser = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']); } } } elseif ($subscriptionDataArr['email'] != '') { $existingNewsletterUser = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']); } else { $existingNewsletterUser = false; } $returnArray = array('is_new_object_draft' => $isNewObjectDraft, 'subscription_data_array' => $subscriptionDataArr, 'existing_newsletter_user' => $existingNewsletterUser); // var_dump( $returnArray ); return $returnArray; } } eZDataType::register(CjwNewsletterSubscriptionType::DATA_TYPE_STRING, 'CjwNewsletterSubscriptionType');
static function isUserObject($contentObject) { if (!$contentObject) { return false; } eZDataType::loadAndRegisterType('ezuser'); $contentClass = $contentObject->attribute('content_class'); $classAttributeList = $contentClass->fetchAttributes(); foreach ($classAttributeList as $classAttribute) { if ($classAttribute->attribute('data_type_string') == eZUserType::DATA_TYPE_STRING) { return true; } } return false; }
{ return true; } function fromString($contentObjectAttribute, $string) { return $contentObjectAttribute->setAttribute('data_text', $string); } function title($contentObjectAttribute, $name = null) { $content = $contentObjectAttribute->content(); // Exit if the input is empty if ($content == '') { return $content; } else { return $this->stripTags($contentObjectAttribute, $content); } } function metaData($contentObjectAttribute) { return $contentObjectAttribute->attribute('data_text'); } /*! \return string representation of an contentobjectattribute data for simplified export */ function toString($contentObjectAttribute) { return $contentObjectAttribute->attribute('data_text'); } } eZDataType::register(BbanType::DATATYPE_STRING, "BbanType");
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if (!$LanguageCode) { $LanguageCode = $class->attribute('top_priority_language_locale'); } if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) { eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group')); } if ($http->hasPostVariable('RemoveGroupButton') && $http->hasPostVariable('group_id_checked')) { if (!eZClassFunctions::removeGroup($ClassID, $ClassVersion, $http->postVariable('group_id_checked'))) { $validation['groups'][] = array('text' => ezpI18n::tr('kernel/class', 'You have to have at least one group that the class belongs to!')); $validation['processed'] = true; } } $attributes = $class->fetchAttributes(); $datatypes = eZDataType::registeredDataTypes(); $mainGroupID = false; $mainGroupName = false; $groupList = $class->fetchGroupList(); if (count($groupList) > 0) { $mainGroupID = $groupList[0]->attribute('group_id'); $mainGroupName = $groupList[0]->attribute('group_name'); } $Module->setTitle("Edit class " . $class->attribute("name")); $tpl = eZTemplate::factory(); $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('class', $class->attribute("id")), array('class_identifier', $class->attribute('identifier')))); $tpl->setVariable('module', $Module); $tpl->setVariable('language_code', $LanguageCode); $tpl->setVariable('class', $class); $tpl->setVariable('attributes', $attributes);
if ( $imploded == '' ) $imploded = $countryName; else $imploded .= ',' . $countryName; } $content['value'] = $imploded; } return $trans->transformByGroup( $content['value'], 'lowercase' ); } function sortKeyType() { return 'string'; } function diff( $old, $new, $options = false ) { return null; } function supportsBatchInitializeObjectAttribute() { return true; } } eZDataType::register( eZCountryType::DATA_TYPE_STRING, 'ezcountrytype' ); ?>
} else { if (strlen($maxValue) > 0) { $minMaxState = self::HAS_MAX_VALUE; } else { $minMaxState = self::NO_MIN_MAX_VALUE; } } } $classAttribute->setAttribute(self::DEFAULT_FIELD, $defaultValue); $classAttribute->setAttribute(self::MIN_FIELD, $minValue); $classAttribute->setAttribute(self::MAX_FIELD, $maxValue); $classAttribute->setAttribute(self::INPUT_STATE_FIELD, $minMaxState); } function supportsBatchInitializeObjectAttribute() { return true; } function batchInitializeObjectAttributeData($classAttribute) { $default = $classAttribute->attribute('data_float3'); if ($default !== 0) { return array('data_float' => $default); } return array(); } /// \privatesection /// The float value validator public $FloatValidator; } eZDataType::register(eZFloatType::DATA_TYPE_STRING, "eZFloatType");
/** * Ctor. * */ public function __construct() { parent::__construct(self::DATATYPE_STRING, 'ymc' . ezi18n('kernel/classes/datatypes', "Domain", 'Datatype name'), array('serialize_supported' => true, 'object_serialize_map' => array('data_text' => 'value'), "translation_allowed" => false)); $this->IntegerValidator = new eZIntegerValidator(); }
static function loadAndRegisterAllTypes() { $allowedTypes = eZDataType::allowedTypes(); foreach ($allowedTypes as $type) { eZDataType::loadAndRegisterType($type); } }
function __construct() { parent::__construct(self::DATA_TYPE_STRING, ezpI18n::tr('kernel/classes/datatypes', 'URL', 'Datatype name'), array('serialize_supported' => true)); $this->MaxLenValidator = new eZIntegerValidator(); }