function updateContentObjectAttribute($contentObjectAttribute)
 {
     $isbnNumber = $contentObjectAttribute->attribute('data_text');
     $isbnValue = trim($isbnNumber);
     $error = false;
     // If the number only consists of hyphen, it should be emty.
     if (preg_match("/^\\-+\$/", $isbnValue)) {
         $emtyValue = '';
         $this->updateContentISBNNumber($contentObjectAttribute, $emtyValue);
         return true;
     }
     // Validate the ISBN number.
     $digits = preg_replace("/\\-/", "", $isbnValue);
     if (trim($digits) != "") {
         // If the length of the number is 10, it is an ISBN-10 number and need
         // to be converted to ISBN-13.
         if (strlen($digits) == 10) {
             $ean = eZISBNType::convertISBN10toISBN13($digits);
         } else {
             if (strlen($digits) == 13) {
                 $ean = $digits;
             } else {
                 $error = true;
             }
         }
         if ($error === false) {
             $isbn13 = new eZISBN13();
             $formatedISBN13Value = $isbn13->formatedISBNValue($ean, $error);
         }
         if ($error === false) {
             $this->updateContentISBNNumber($contentObjectAttribute, $formatedISBN13Value);
         } else {
             $this->Cli->output($this->Cli->stylize('warning', 'Warning:') . ' ISBN: ' . $this->Cli->stylize('strong', $isbnNumber) . ' is not valid. You need to update contentobject: ' . $this->Cli->stylize('strong', $contentObjectAttribute->attribute('contentobject_id')) . ' version: ' . $this->Cli->stylize('strong', $contentObjectAttribute->attribute('version')) . ' manually.');
         }
     }
 }
Exemplo n.º 2
0
 function preStoreClassAttribute($classAttribute, $version)
 {
     return eZISBNType::storeClassAttributeContent($classAttribute, $classAttribute->content());
 }