
<?php

class partialsComponents extends sfComponents {

  public function executeUserPanel() {
    $this->user = $this->getUser();
    if (!$this->user->isAuthenticated()) return sfView::NONE;
  }

  public function executeNavigation() {
    $this->user = $this->getUser();
    if (!$this->user->isAuthenticated()) return sfView::NONE;
  }

  public function executeSearch() {

  }

  public function executeFilmItem() {
    // Process thumb
    $this->thumbWidth = 337;
    $this->thumbHeight = 190;

    if (isset($this->size) && $this->size == 'big') {
      $this->thumbWidth = 720;
      $this->thumbHeight = 405;
    }

    // Get image filename
    $images = $this->film->getImages();
    $this->imageFilename = null;

    if ($images) {
      $image = $images[0];
      $this->imageFilename = $image->getFile();
    }

    // Get Tag cloud
    // Only display 10 tags
    $this->tagCloud = ThdUtil::processTagCloud($this->film->getTagCloud(), 10);

    // Get video filename
    $videos = $this->film->getVideos();
    $this->videoFilename = null;

    if ($videos) {
      $video = $videos[0];
      $this->videoFilename = $video->getFile();
    }

    // Create tag action
    $controller = $this->getController();
    $this->actionUri = $controller->genUrl('@editVideoSegment?film_slug='.$this->film->getSlugUrl());
  }
}
