jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Libraries/] [UI/] [Model/] [Workspace.php] - Rev 2

Compare with Previous - Blame - Download


<?php

namespace Phem\Libraries\UI\Model;

use Doctrine\Common\Annotations\AnnotationReader;
use Phem\Core\Collection;
use Phem\Core\Object;
use Phem\ToolSuite;
use ReflectionClass;

/**
 * @author Jakub PetrŞílka <petrzilka@czweb.net>
 */
abstract class Workspace extends Object
{

    protected $backgroundColor;
    protected $changes;
    protected $currentVersion;    
    protected $scope;
    protected $name;
    
    
   /* public static function getInstance()
    {
        $reflectionClass = new ReflectionClass($this);

            $annotationReader = new AnnotationReader();
            $classAnnotations = $annotationReader
                    ->getClassAnnotations($reflectionClass);        
            
            $workspace = null;
            foreach ($classAnnotations as $annotation)
            {
                if ($annotation instanceof \Phem\Libraries\UI\Annotations\Scope)
                {
                    switch (strtolower($annotation->value))
                    {
                        case ScopeType::APPLICATION:
                            
                        case ScopeType::USER:
                        case ScopeType::SESSION:
                        case ScopeType::CONNECTION:
                           
                    }
                    break;
                }
            }

            if ($workspace == null)
            {
                return new self();
            }
    }*/
    
    function __construct()
    {
        $this->currentVersion = 0;        
        $this->changes = new Collection();
    }

        public function getBackgroundColor()
    {
        return $this->backgroundColor;
    }

    public function setBackgroundColor($backgroundColor)
    {
        $this->backgroundColor = $backgroundColor;
    }
    
    public function findControl($name)
    {
        $nameParts = explode("_", $name);
        $superObject = $this;
        foreach ($nameParts as $namePart)
        {
            $getter = "get".ucfirst($namePart);
            $superObject = $superObject->$getter();
        }
        return $superObject;
    }

    public function getWindows()
    {

        $windows = new Collection();

        $methods = get_class_methods($this);
        foreach ($methods as $method)
        {
            if ((ToolSuite::startsWith($method, 'get') !== false) && ($method != "getWindows"))
            {
                $val = $this->$method();
                if (is_a($val, '\Phem\Libraries\UI\Model\Window'))
                {
                    $windows->put(lcfirst(substr($method, 3)), $val);
                }
            }
        }
        return $windows;
    }
    
    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }
    
    public function getScope()
    {
        return $this->scope;
    }

    public function setScope($scope)
    {
        $this->scope = $scope;
    }

    public function getChanges()
    {
        return $this->changes;
    }

    public function getCurrentVersion()
    {
        return $this->currentVersion;
    }

    public function setChanges($changes)
    {
        $this->changes = $changes;
    }

    public function setCurrentVersion($currentVersion)
    {
        $this->currentVersion = $currentVersion;
    }    

}

Powered by WebSVN 2.2.1