Subversion Repositories starrating

[/] [datatypes/] [starrating/] [starratingtype.php] - Blame information for rev 1

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1 zabbie
<?php
2
 
3
// Include the super class file
4
include_once( "kernel/classes/ezdatatype.php" );
5
include_once( "extension/starrating/classes/starrating.php" );
6
 
7
// Define the name of datatype string
8
define( "EZ_DATATYPESTRING_STARRATING", "starrating" );
9
 
10
 
11
class starratingType extends eZDataType
12
{
13
  /*!
14
   Construction of the class, note that the second parameter in eZDataType
15
   is the actual name showed in the datatype dropdown list.
16
  */
17
  function starratingType()
18
  {
19
    $this->eZDataType( EZ_DATATYPESTRING_STARRATING, "Star Rating" );
20
  }
21
 
22
  /*!
23
    Validates the input and returns true if the input was
24
    valid for this datatype.
25
  */
26
  function validateObjectAttributeHTTPInput( $http, $base,
27
                                               $objectAttribute )
28
  {
29
    return eZInputValidator::STATE_ACCEPTED;
30
  }
31
 
32
  function deleteStoredObjectAttribute( $objectAttribute, $version = null )
33
  {
34
    // Remove all ratings associated with thes objectAttribute;
35
    if ($version == null)
36
    {
37
      starrating::removeAll( $objectAttribute->attribute('id') );
38
    }
39
  }
40
 
41
 /*!
42
 */
43
 
44
   function fetchObjectAttributeHTTPInput( $http, $base, $objectAttribute )
45
   {
46
     return true;
47
   }
48
 
49
  /*!
50
   Store the content. Since the content has been stored in function
51
   fetchObjectAttributeHTTPInput(), this function is with empty code.
52
  */
53
  function storeObjectAttribute( $objectattribute )
54
  {
55
  }
56
 
57
  /*!
58
   Returns the meta data used for storing search indices.
59
  */
60
  function metaData( $contentObjectAttribute )
61
  {
62
    // TODO Should return the rating average...might have to think this through
63
    // as the avgerage changes independant of publishing of item
64
    return 2;
65
  }
66
 
67
  /*!
68
   Returns the text.
69
  */
70
  function title( $objectAttribute, $name = null)
71
  {
72
    return $this->metaData($objectAttribute);
73
  }
74
 
75
  function isIndexable()
76
  {
77
    return true;
78
  }
79
 
80
 
81
 
82
  function sortKey( $objectAttribute )
83
  {
84
    return $this->metaData($objectAttribute);
85
  }
86
 
87
  function sortKeyType()
88
  {
89
    return 'integer';
90
  }
91
 
92
  function hasObjectAttributeContent( $contentObjectAttribute )
93
  {
94
    return true;
95
  }
96
 
97
  /*!
98
   Returns the content.
99
  */
100
  function objectAttributeContent( $objectAttribute )
101
  {
102
    $row = array('contentobject_attribute_id' => $objectAttribute->attribute('id'),
103
                 'version'                    => $objectAttribute->attribute('version'));
104
    $object = starrating::create($row);
105
    return $object;
106
  }
107
}
108
eZDataType::register( EZ_DATATYPESTRING_STARRATING, "starratingType" );