/**
  * Check if given attribute exists.
  * All "classic" attributes can be used (See {@link eZContentObjectTreeNode::definition()}).
  * @param $name
  */
 public function __isset($name)
 {
     $this->getNode();
     return $this->node->hasAttribute($name);
 }
Beispiel #2
0
 function hasAttribute($attr)
 {
     return in_array($attr, $this->LocalAttributeNameList) || eZContentObjectTreeNode::hasAttribute($attr);
 }
 /**
  * @param eZContentObjectTreeNode $node
  * @param bool $check
  *
  * @return bool|string
  */
 public function getAbstract($node, $check = false)
 {
     $has_content = false;
     $text = false;
     $strLenFunc = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
     $ini = eZINI::instance('ocoperatorscollection.ini');
     if ($node instanceof eZContentObjectTreeNode) {
         if ($node->hasAttribute('highlight')) {
             $text = $node->attribute('highlight');
             $text = str_replace(' ', ' ', $text);
             $text = str_replace(' ', ' ', $text);
             if ($strLenFunc($text) > 0) {
                 $has_content = true;
             }
         }
         if (!$has_content) {
             $attributes = $ini->hasVariable('Abstract', 'Attributes') ? $ini->variable('Abstract', 'Attributes') : array();
             if (!empty($attributes)) {
                 /** @var eZContentObjectAttribute[] $dataMap */
                 $dataMap = $node->dataMap();
                 foreach ($attributes as $attr) {
                     if (isset($dataMap[$attr])) {
                         if ($dataMap[$attr]->hasContent()) {
                             $tpl = eZTemplate::factory();
                             $tpl->setVariable('attribute', $dataMap[$attr]);
                             $designPath = "design:content/datatype/view/" . $dataMap[$attr]->attribute('data_type_string') . ".tpl";
                             $text = $tpl->fetch($designPath);
                             $text = str_replace(' ', ' ', $text);
                             if ($strLenFunc(strip_tags($text)) > 0) {
                                 $has_content = true;
                             }
                             break;
                         }
                     }
                 }
             }
         }
     }
     if ($check) {
         return $has_content;
     } else {
         return $text;
     }
 }