Exemplo n.º 1
0
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
/*! \file
*/
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish datatype sql update\n\n" . "Script can be run as:\n" . "bin/php/ezimportdbafile.php --datatype=\n\n" . "Example: bin/php/ezimportdbafile.php --datatype=ezisbn", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions("[datatype:]", "", array('datatype' => "The name of the datatype where the database should be updated."));
$script->initialize();
$dataTypeName = $options['datatype'];
if ($dataTypeName === null) {
    $cli->output("Error: The option --datatype is required. Add --help for more information.");
}
$allowedDatatypes = eZDataType::allowedTypes();
if ($dataTypeName !== null and in_array($dataTypeName, $allowedDatatypes)) {
    // Inserting data from the dba-data files of the datatypes
    eZDataType::loadAndRegisterAllTypes();
    $registeredDataTypes = eZDataType::registeredDataTypes();
    if (isset($registeredDataTypes[$dataTypeName])) {
        $dataType = $registeredDataTypes[$dataTypeName];
        if ($dataType->importDBDataFromDBAFile()) {
            $cli->output("The database is updated for the datatype: " . $cli->style('emphasize') . $dataType->DataTypeString . $cli->style('emphasize-end') . "\n" . 'dba-data is imported from the file: ' . $cli->style('emphasize') . $dataType->getDBAFilePath() . $cli->style('emphasize-end'));
        } else {
            $activeExtensions = eZExtension::activeExtensions();
            $errorString = "Failed importing datatype related data into database: \n" . '  datatype - ' . $dataType->DataTypeString . ", \n" . '  checked dba-data file - ' . $dataType->getDBAFilePath(false);
            foreach ($activeExtensions as $activeExtension) {
                $fileName = eZExtension::baseDirectory() . '/' . $activeExtension . '/datatypes/' . $dataType->DataTypeString . '/' . $dataType->getDBAFileName();
                $errorString .= "\n" . str_repeat(' ', 23) . ' - ' . $fileName;
                if (file_exists($fileName)) {
Exemplo n.º 2
0
 static function loadAndRegisterAllTypes()
 {
     $allowedTypes = eZDataType::allowedTypes();
     foreach ($allowedTypes as $type) {
         eZDataType::loadAndRegisterType($type);
     }
 }
 protected function addAttribute($originalAttribute)
 {
     $class = $this->currentClass;
     $localeAttributes = $class->fetchAttributes();
     $placement = count($localeAttributes);
     $allowedTypes = eZDataType::allowedTypes();
     if (!$class->fetchAttributeByIdentifier($originalAttribute->Identifier) && in_array($originalAttribute->DataTypeString, $allowedTypes)) {
         /** @var eZContentClassAttribute $localeAttribute */
         $localeAttribute = eZContentClassAttribute::create($class->attribute('id'), $originalAttribute->DataTypeString, array('version' => eZContentClass::VERSION_STATUS_TEMPORARY, 'identifier' => $originalAttribute->Identifier, 'serialized_name_list' => $originalAttribute->SerializedNameList, 'serialized_description_list' => $originalAttribute->SerializedDescriptionList, 'category' => $originalAttribute->Category, 'serialized_data_text' => $originalAttribute->SerializedDataText, 'is_required' => $originalAttribute->IsRequired, 'is_searchable' => $originalAttribute->IsSearchable, 'is_information_collector' => $originalAttribute->IsInformationCollector, 'can_translate' => $originalAttribute->CanTranslate, 'placement' => ++$placement), $this->EditLanguage);
         foreach ($this->fields as $localeIdentifier => $remoteProperty) {
             $localeAttribute->setAttribute($localeIdentifier, $originalAttribute->{$remoteProperty});
         }
         $localeAttribute->store();
         return $localeAttribute;
     }
     return false;
 }