Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2c41d50084
Fetching contributors…

Cannot retrieve contributors at this time

file 81 lines (61 sloc) 2.116 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php

namespace Echo511\Plupload\Components\JQueryUIWidget;

/**
* This file is a part of Plupload component for Nette Framework.
*
* @author Nikolas Tsiongas
* @package Plupload component
* @license New BSD License
*/
class JQueryUIWidget extends \Nette\Application\UI\Control
{

    // Rooftop
    private $rooftop;

    // Template
    private $template;

    // Component for magic loading of Js and Css
    private $libsComponent;


    /*********** Init ***********/
    public function __construct(\Echo511\Plupload\Rooftop $rooftop)
    {
        $this->rooftop = $rooftop;
        $this->_createTemplate();

        if($this->rooftop->isMagical())
            $this->monitor('Nette\Application\UI\Presenter');
    }


    /*********** Only magic loading purposes ***********/
    public function attached($presenter)
    {
        $components = $presenter->getComponents(true, 'Echo511\Plupload\Components\Libs\Libs');
        foreach($components as $component) {
            $this->libsComponent = $component;
            break;
        }

        if($this->libsComponent === null) {
            $this->libsComponent = new \Echo511\Plupload\Components\Libs\Libs($this, 'libs');
            $this->libsComponent->setTempLibsDir($this->rooftop->tempLibsDir);
        }
    }


    /*********** Rendering ***********/
    private function _createTemplate()
    {
        $template = $this->createTemplate();
        $template->registerFilter(new \Nette\Latte\Engine);

        $template->tempLibsDir = $this->rooftop->tempLibsDir;
        $template->pluploadSettings = $this->rooftop->pluploadSettings;

        $template->isMagical = $this->rooftop->isMagical();

        $template->setFile(__DIR__ . '/templates/default.latte');
        $this->template = $template;
    }

    public function render($token = 'test')
    {
        $this->template->token = $token;
        $this->template->libsComponent = $this->libsComponent;
        $this->template->render();
    }


    /*********** Upload ***********/
    public function handleUpload()
    {
        $this->rooftop->upload();
    }

}
Something went wrong with that request. Please try again.