[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/gallery/dao/ -> galleryalbum.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
   4  
   5      /**
   6       * \ingroup Gallery
   7       *
   8       * Models an album, that holds resources. Every album has also several other fields
   9       * such as id, date of last modification, and the identifier of the parent album
  10       * to which it belongs (if any) 
  11       *
  12       * Albums can also be nested therefore every album can have a parent and one or more than
  13       * one set of child albums.
  14       */
  15      class GalleryAlbum extends DbObject
  16      {
  17          var $_ownerId;
  18          var $_name;
  19          var $_description;
  20          var $_flags;
  21          var $_parentId;
  22          var $_parent;
  23          var $_date;
  24          var $_id;
  25          var $_numResources;
  26          var $_numChildren;
  27          var $_children;
  28          var $_resources;
  29          var $_properties;
  30          var $_showAlbum;
  31          var $_mangledName;
  32          var $_normalizedName;
  33          var $_normalizedDescription;
  34          
  35          /**
  36           * Constructor of the class.
  37           *
  38           * @param ownerId A valid user identifier
  39           * @param name A string representing a valid name for the album. Maximum 255 characters
  40           * @param description A string representing a valid description for the album. Maximum 65k characters.
  41           * @param flags An integer value resulting or binary OR'ing the following constants: 
  42           *  - GALLERY_RESOURCE_PREVIEW_AVAILABLE
  43           * (no more as of plog 0.3)
  44           * @param parentId A valid and existing album identifier. If none, then set this to '0'
  45           * @param date A valid date in TIMESTAMP(14) format
  46           * @param properties A serialized array of pairs key=>value
  47           * @param showAlbum Whether to show this album in the main page or not.
  48           * @param id An identifier for this album. It is recommended not to set it.
  49           */
  50      	function GalleryAlbum( $ownerId, $name, $description = '', $flags, $parentId, $date, $properties, $showAlbum, $id = -1 )
  51          {
  52              $this->DbObject();
  53              $this->_ownerId = $ownerId;
  54              $this->_name = $name;
  55              $this->_description = $description;
  56              $this->_flags = $flags;
  57              $this->_parentId = $parentId;
  58              $this->_parent = null;
  59              $this->_date = $date;
  60              $this->_id = $id;
  61              $this->_numResources = 0;
  62              $this->_numChildren  = 0;
  63              $this->_showAlbum = $showAlbum;
  64              $this->_properties = $properties;
  65              $this->_children = null;
  66              $this->_resources = null;
  67              $this->_mangledName = "";
  68              $this->_normalizedName = "";
  69              $this->_normalizedDescription = "";
  70              
  71              $this->_pk = "id";
  72              $this->_fields = Array(
  73                  "owner_id" => "getOwnerId",
  74                  "description" => "getDescription",
  75                  "name" => "getName",
  76                  "flags" => "getFlags",
  77                  "parent_id" => "getParentId",
  78                  "date" => "getDate",
  79                  "properties" => "getProperties",
  80                  "show_album" => "getShowAlbum",
  81                  "mangled_name" => "getMangledName",
  82                  "num_resources" => "getNumResources",
  83                  "num_children" => "getNumChildren",
  84                  "normalized_name" => "getNormalizedName",
  85                  "normalized_description" => "getNormalizedDescription"
  86              );
  87          }
  88          
  89          function setId( $id )
  90          {
  91              $this->_id = $id;
  92          }
  93  
  94          /**
  95           * Returns the owner id
  96           *
  97           * @return A valid user id
  98           */
  99          function getOwnerId()
 100          {
 101              return $this->_ownerId;
 102          }
 103  
 104          /**
 105           * Returns the album name
 106           *
 107           * @return A string containing the name of the album
 108           */
 109          function getName()
 110          {
 111              return $this->_name;
 112          }
 113          
 114          /**
 115           * Sets the album name
 116           *
 117           * @param name New name for the album.
 118           * @return Always true.
 119           */
 120          function setName( $name )
 121          {
 122              $this->_name = $name;
 123              
 124              return true;
 125          }
 126  
 127          /**
 128           * Returns the description of the album.
 129           *
 130           * @return A string with the description.
 131           */
 132          function getDescription()
 133          {
 134              return $this->_description;
 135          }
 136  
 137          /**
 138           * Sets the description of the album.
 139           *
 140           * @param description The new description
 141           * @return Always true.
 142           */
 143          function setDescription( $description )
 144          {
 145              $this->_description = $description;
 146              
 147              return true;
 148          }
 149  
 150          /**
 151           * Returns the identifier of the parent album, or '0' if there is no parent album
 152           *
 153           * @return An integer >0
 154           */
 155          function getParentId()
 156          {
 157              return $this->_parentId;
 158          }
 159          
 160          /**
 161           * Returns the parent album, or null if there is no parent album
 162           *
 163           * @return A GalleryAlbum object or null if there is no parent
 164           */
 165          function getParent()
 166          {
 167              if( $this->_parent == null ) {
 168                  lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
 169                  $albums = new GalleryAlbums();
 170                  $this->_parent = $albums->getAlbum( $this->getParentId(), $this->getOwnerId());
 171              }
 172              
 173              return( $this->_parent );
 174          }
 175  
 176          /**
 177           * Sets the parent id of the album. It is important that it is a valid 
 178           * parent id, otherwise reading this album will generate unexpected errors
 179           * since it won't be possible to find its parent id!
 180           *
 181           * @param parentId The identifier of the new parent album.
 182           * @return Always true.
 183           */
 184          function setParentId( $parentId )
 185          {
 186              $this->_parentId = $parentId;
 187              
 188              return true;
 189          }
 190          /**
 191           * Returns a Timestamp object representing the date in which this album
 192           * was created
 193           *
 194           * @return A Timestamp object
 195           */
 196          function getTimestamp()
 197          {
 198              lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );        
 199              return new Timestamp($this->_date);
 200          }
 201  
 202          /**
 203           * Returns the timestamp of the album as it comes from the database, formatted
 204           * as a TIMESTAMP(14) value
 205           *
 206           * @return A String representing a TIMESTAMP(14) date.
 207           */
 208          function getDate()
 209          {
 210              return $this->_date;
 211          }
 212  
 213          /**
 214           * Returns the identifier of this album
 215           *
 216           * @return Returns a valid identifier or -1 if none has been set yet.
 217           */
 218          function getId()
 219          {
 220              return $this->_id;
 221          }
 222          
 223          /**
 224           * Returns the flags that have been set for this album
 225           *
 226           * @return An integer value containing the OR'ed flags.
 227           */
 228          function getFlags()
 229          {
 230              return $this->_flags;
 231          }
 232  
 233          /**
 234           * Returns an array of GalleryAlbum objects representing all the child
 235           * albums that this album has. 
 236           *
 237           * @return an array of GalleryAlbum objects.
 238           */
 239          function getChildren()
 240          {
 241              if( $this->_children == null ) {
 242                  $albums = new GalleryAlbums();
 243                  $this->_children = $albums->getChildAlbums( $this->getId(), $this->getOwnerId());
 244              }
 245              
 246              return $this->_children;
 247          }
 248  
 249          /**
 250           * Sets the children albums of this album.
 251           *
 252           * @param children An array of GalleryAlbum objects containing information about the
 253           * children albums of this album.
 254           * @return Always true.
 255           */
 256          function setChildren( $children )
 257          {
 258              $this->_children = $children;
 259              
 260              return true;
 261          }
 262          
 263          /**
 264           * Returns the number of resources that this album has.
 265           *
 266           * @return An integer value, or '0' if it has none.
 267           */
 268          function getNumResources()
 269          {
 270              return $this->_numResources;
 271          }
 272          
 273          /**
 274           * Returns the number of children that this album has.
 275           *
 276           * @return An integer value, or '0' if it has none.
 277           */
 278          function getNumChildren()
 279          {
 280              return $this->_numChildren;
 281          }        
 282  
 283          /**
 284           * Sets number of children of this album.
 285           *
 286           * @param numChildren An integer representing the number of children that this
 287           * album has.
 288           * @return Always true.
 289           */
 290          function setNumChildren( $numChildren )
 291          {
 292              $this->_numChildren = $numChildren;
 293          }
 294          
 295          /**
 296           * Returns the number of resoruces that have been categorized under this album.
 297           *
 298           * @return An integer value, or '0' if it has none.
 299           */
 300          function setNumResources( $numResources )
 301          {
 302              $this->_numResources = $numResources;
 303          }
 304  
 305          /**
 306           * this breaks our rule big time (remember: this little objects resulting
 307           * of dao/ classes should _never_ do any database access by themselves... 
 308           * all the information they need has already been fetched. However, 
 309           * this proved to be here a great performance improvement in the sense that
 310           * fetching a single album did not trigger fetchign the whole shebang
 311           * and whatnot from the database of albums and resources...
 312           * Sometimes, breaking the rules is a good thing :)
 313           */
 314          function getResources()
 315          {
 316              if( $this->_resources == null ) {
 317                  $res = new GalleryResources();
 318                  $this->_resources = $res->getUserResources( $this->getOwnerId(), $this->getId());
 319              }
 320              
 321              return $this->_resources;
 322          }
 323  
 324          /**
 325           * Sets the resources of the album.
 326           *
 327           * @param resources An array of GalleryResource objects that represents the
 328           * resources that have been categorized under this album.
 329           * @return Always true.
 330           */
 331          function setResources( $resources )
 332          {
 333              $this->_resources = $resources;
 334              
 335              return true;
 336          }
 337  
 338          /**
 339           * Returns an array with the properties.
 340           *
 341           * @return A valid PHP array.
 342           */
 343          function getProperties()
 344          {
 345              return $this->_properties;
 346          }
 347  
 348          /**
 349           * Sets the value of the 'properties' field of this album.
 350           *
 351           * @param properties A valid PHP array containing a list of
 352           * pairs $key=>$value
 353           * @return Always true.
 354           */
 355          function setProperties( $properties )
 356          {
 357              $this->_properties = $properties;
 358              
 359              return true;
 360          }
 361  
 362          /**
 363           * Returns whether this album has to be shown in the main page or not.
 364           *
 365           * @return A boolean value.
 366           */
 367          function getShowAlbum()
 368          {
 369              return $this->_showAlbum;
 370          }
 371  
 372          /**
 373           * Sets whether this album has to be shown in the main page or not.
 374           *
 375           * @param showAlbum A boolean value
 376           * @return Always true.
 377           */
 378          function setShowAlbum( $showAlbum )
 379          {
 380              $this->_showAlbum = $showAlbum;
 381              
 382              return true;
 383          }
 384          
 385          function getMangledName()
 386          {
 387              if( $this->_mangledName == "" ) {
 388                  lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
 389                  $this->_mangledName = Textfilter::urlize( $this->getName());
 390              }
 391              
 392              return( $this->_mangledName );
 393          }
 394          
 395  		function setMangledName( $mangledName )
 396          {
 397              $this->_mangledName = $mangledName;
 398          }
 399  
 400          /**
 401           * Returns the normailzied name for full text search
 402           *
 403           * @return A normailzied name
 404           */
 405          function getNormalizedName()
 406          {
 407              if( $this->_normalizedName == "" ) {
 408                  lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
 409                  $this->_normalizedName = Textfilter::normalizeText( $this->getName());
 410              }
 411              
 412              return( $this->_normalizedName );
 413          }
 414  
 415          /**
 416           * Sets the normailzied name of the album.
 417           *
 418           * @param normalized name
 419           */
 420          function setNormalizedName( $normalizedName )
 421          {
 422              $this->_normalizedName = $normalizedName;
 423          }
 424  
 425          /**
 426           * Returns the normailzied description for full text search
 427           *
 428           * @return A normailzied description
 429           */
 430          function getNormalizedDescription()
 431          {
 432              if( $this->_normalizedDescription == "" ) {
 433                  lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
 434                  $this->_normalizedDescription = Textfilter::normalizeText( $this->getDescription());
 435              }
 436              
 437              return( $this->_normalizedDescription );
 438          }
 439  
 440          /**
 441           * Sets the normailzied description of the album.
 442           *
 443           * @param normalized description
 444           */
 445          function setNormalizedDescription( $normalizedDescription )
 446          {
 447              $this->_normalizedDescription = $normalizedDescription;
 448          }
 449      }
 450  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics