/**
  * Fetch Average Rating
  * Will create a unstored one if none could be fetched ( it will have rating_avrage and rating_count of 0 )
  *
  * @return ezsrRatingObject
  */
 function getAverageRating()
 {
     $avgRating = ezsrRatingObject::fetchByObjectId($this->attribute('contentobject_id'), $this->attribute('contentobject_attribute_id'));
     if (!$avgRating instanceof ezsrRatingObject) {
         $avgRating = ezsrRatingObject::create(array('contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $this->attribute('contentobject_attribute_id')));
     }
     return $avgRating;
 }
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'fetch_starrating_data':
             $ret = ezsrRatingDataObject::fetchByConds($namedParameters['params']);
             break;
         case 'fetch_starrating_stats':
             $ret = ezsrRatingObject::stats($namedParameters['object_id']);
             break;
         case 'fetch_by_starrating':
             $ret = ezsrRatingObject::fetchNodeByRating($namedParameters['params']);
             break;
     }
     $operatorValue = $ret;
 }
 function objectAttributeContent( $contentObjectAttribute )
 {
     $objectId = $contentObjectAttribute->attribute('contentobject_id');
     $attributeId = $contentObjectAttribute->attribute('id');
     $ratingObj = null;
     if ( $objectId && $attributeId )
     {
         $ratingObj = ezsrRatingObject::fetchByObjectId( $objectId, $attributeId );
 
         // Create empty object if none could be fetched
         if (  !$ratingObj instanceof ezsrRatingObject )
         {
             $ratingObj = ezsrRatingObject::create( array('contentobject_id' => $objectId,
                                                          'contentobject_attribute_id' => $attributeId ) );
         }
     }
     return $ratingObj;
 }