/**
  * Test to check fix for "object name limit does not support multibyte charset"
  *
  * @link https://jira.ez.no/browse/EZP-21410
  * @dataProvider providerForTestNamePatternResolver
  */
 public function testNamePatternResolver($name, $limit, $sequence, $namePattern, $identifier, $expects)
 {
     $contentObjectMock = $this->getMock("eZContentObject", array(), array(), '', false, false);
     $contentObjectAttributeMock = $this->getMock("eZContentObjectAttribute", array(), array(), '', false, false);
     $contentObjectMock->expects($this->once())->method("fetchAttributesByIdentifier")->with(array($identifier), false, array(false))->will($this->returnValue(array($contentObjectAttributeMock)));
     $contentObjectAttributeMock->expects($this->once())->method("contentClassAttributeIdentifier")->will($this->returnValue($identifier));
     $contentObjectAttributeMock->expects($this->once())->method('title')->will($this->returnValue($name));
     $resolver = new eZNamePatternResolver($namePattern, $contentObjectMock);
     $result = $resolver->resolveNamePattern($limit, $sequence);
     $this->assertEquals($expects, $result);
 }
 function runOperation(&$node)
 {
     $content_object = $node->attribute('object');
     $class_id = $content_object->attribute('contentclass_id');
     // Find class pattern, if not cached
     if (!isset($this->pattern_array[$class_id])) {
         $class = $content_object->attribute('content_class');
         if ($class) {
             $this->pattern_array[$class_id] = $class->attribute('contentobject_name');
         } else {
             echo "Error: Class with id {$class_id} not found.\n";
             return false;
         }
     }
     // Generate new name, and update if changed
     $name_object = new eZNamePatternResolver($this->pattern_array[$class_id], $content_object);
     $old_name = $content_object->attribute('name');
     $new_name = $name_object->resolveNamePattern();
     if ($old_name != $new_name) {
         echo "Updating object name from '{$old_name}' to '{$new_name}'\n";
         $content_object->setName($new_name);
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Will generate a name for the url alias based on the class
  * settings for content object limited by site.ini\[URLTranslator]\UrlAliasNameLimit
  *
  * @param eZContentObject $contentObject
  * @param int|false $version
  * @param string|false $translation
  * @return string
  */
 function urlAliasName(eZContentObject $contentObject, $version = false, $translation = false)
 {
     if ($this->URLAliasName) {
         $urlAliasNamePattern = $this->URLAliasName;
     } else {
         $urlAliasNamePattern = $this->ContentObjectName;
     }
     $length = (int) eZINI::instance()->variable('URLTranslator', 'UrlAliasNameLimit');
     $nameResolver = new eZNamePatternResolver($urlAliasNamePattern, $contentObject, $version, $translation);
     $urlAliasName = $nameResolver->resolveNamePattern($length);
     return $urlAliasName;
 }
Esempio n. 4
0
 function urlAliasName($contentObject, $version = false, $translation = false)
 {
     if ($this->URLAliasName) {
         $urlAliasNamePattern = $this->URLAliasName;
     } else {
         $urlAliasNamePattern = $this->ContentObjectName;
     }
     $nameResolver = new eZNamePatternResolver($urlAliasNamePattern, $contentObject, $version, $translation);
     $urlAliasName = $nameResolver->resolveNamePattern();
     return $urlAliasName;
 }