<?php

class catentryBase extends resourceBase {

  public $catentry;

  public function catentryBase(Tblblogcategoryentry $ce) {
    parent::resourceBase();
    $this->catentry = $ce;
  }

  public function getTitleWithLink($options = array()) {
    return link_to($this->catentry->getCeTitle(), '/entry/show?entry_id='.$this->catentry->getCeEntry(), $options);
  }

  public function getThumbWithLink($baselink = '', $morelink = '', $options = array()) {
    return $this->catentry->getTblblogentry()->getObject()->getThumbWithLink($baselink, $morelink, $options);
  }

  public function getEntryIntro() {
    return $this->catentry->getTblblogentry()->getObject()->getEntryIntro();
  }

  public function getThumbnail($options = array()) {
    $thumnailtag = $this->catentry->getCeThumbnail();
    return image_tag($this->thumbRoot.'uploads/thumbnails/'.$thumnailtag, $options);
  }

  public function getSmallThumbnail($options = array()) {
    $thumnailtag = $this->catentry->getCeThumbnail();
    if ($thumnailtag == 'word-logo.jpg') $thumnailtag = 'word-logo-small.gif';
    else if ($thumnailtag == 'pdf.jpg') $thumnailtag = 'pdf-small.gif';
    else if ($thumnailtag == 'xls.jpg') $thumnailtag = 'xls-small.gif';
    else return parent::getSmallThumbnail($options);
    return image_tag($this->thumbRoot.'uploads/thumbnails/'.$thumnailtag, $options);
  }

  public function getGlobalThumb($type = 'thumb') {
    $module = commonData::getModule($this->catentry->getCeType());
    return $this->getHtmlThumb("/$module/show?entry_id=".$this->catentry->getCeEntry(), $type);
  }

  public function getPreview($width = 333, $height = 283) {
    return $this->catentry->getTblblogentry()->getLinkObject()->getPreview($width, $height);
  }

  protected function getName() {
    return trim($this->catentry->getCeTitle(), '"');
  }

  protected function getStatus() {
    return $this->catentry->getCeStatus();
  }

  protected function getModifydate() {
    return $this->catentry->getCeModifydate();
  }

  public function getFileType() {
    return $this->catentry->getCeFiletype();
  }
}
?>
