moved Libs out of core folder
This commit is contained in:
		
							
								
								
									
										157
									
								
								application/libs/FML/Components/CheckBox.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										157
									
								
								application/libs/FML/Components/CheckBox.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,157 @@ | ||||
| <?php | ||||
|  | ||||
| namespace FML\Components; | ||||
|  | ||||
| use FML\Controls\Entry; | ||||
| use FML\Controls\Frame; | ||||
| use FML\Controls\Quad; | ||||
| use FML\Models\CheckBoxDesign; | ||||
| use FML\Script\Features\CheckBoxFeature; | ||||
| use FML\Script\Features\ScriptFeature; | ||||
| use FML\Types\Renderable; | ||||
| use FML\Types\ScriptFeatureable; | ||||
|  | ||||
| /** | ||||
|  * CheckBox Component | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| class CheckBox implements Renderable, ScriptFeatureable { | ||||
| 	/* | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $name = null; | ||||
| 	protected $feature = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new CheckBox Component | ||||
| 	 * | ||||
| 	 * @param string $name    (optional) CheckBox name | ||||
| 	 * @param bool   $default (optional) Default value | ||||
| 	 * @param Quad   $quad    (optional) CheckBox quad | ||||
| 	 */ | ||||
| 	public function __construct($name = null, $default = null, Quad $quad = null) { | ||||
| 		$this->feature = new CheckBoxFeature(); | ||||
| 		$this->setName($name); | ||||
| 		$this->setDefault($default); | ||||
| 		$this->setQuad($quad); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the name | ||||
| 	 * | ||||
| 	 * @param string $name CheckBox name | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setName($name) { | ||||
| 		$this->name = (string)$name; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default value | ||||
| 	 * | ||||
| 	 * @param bool $default Default value | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->feature->setDefault($default); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the enabled Design | ||||
| 	 * | ||||
| 	 * @param string $style    Style name or image url | ||||
| 	 * @param string $subStyle SubStyle name | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setEnabledDesign($style, $subStyle = null) { | ||||
| 		if (is_object($style) && ($style instanceof CheckBoxDesign)) { | ||||
| 			$this->feature->setEnabledDesign($style); | ||||
| 		} else { | ||||
| 			$checkBoxDesign = new CheckBoxDesign($style, $subStyle); | ||||
| 			$this->feature->setEnabledDesign($checkBoxDesign); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the disabled Design | ||||
| 	 * | ||||
| 	 * @param string $style    Style name or image url | ||||
| 	 * @param string $subStyle SubStyle name | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setDisabledDesign($style, $subStyle = null) { | ||||
| 		if (is_object($style) && ($style instanceof CheckBoxDesign)) { | ||||
| 			$this->feature->setDisabledDesign($style); | ||||
| 		} else { | ||||
| 			$checkBoxDesign = new CheckBoxDesign($style, $subStyle); | ||||
| 			$this->feature->setDisabledDesign($checkBoxDesign); | ||||
| 		} | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the CheckBox Quad | ||||
| 	 * | ||||
| 	 * @param Quad $quad CheckBox Quad | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setQuad(Quad $quad = null) { | ||||
| 		$this->feature->setQuad($quad); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Types\ScriptFeatureable::getScriptFeatures() | ||||
| 	 */ | ||||
| 	public function getScriptFeatures() { | ||||
| 		return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry()); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the CheckBox Quad | ||||
| 	 * | ||||
| 	 * @param bool $createIfEmpty (optional) Create the Quad if it's not set | ||||
| 	 * @return \FML\Controls\Quad | ||||
| 	 */ | ||||
| 	public function getQuad($createIfEmpty = true) { | ||||
| 		if (!$this->feature->getQuad() && $createIfEmpty) { | ||||
| 			$quad = new Quad(); | ||||
| 			$quad->setSize(10, 10); | ||||
| 			$this->setQuad($quad); | ||||
| 		} | ||||
| 		return $this->feature->getQuad(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Types\Renderable::render() | ||||
| 	 */ | ||||
| 	public function render(\DOMDocument $domDocument) { | ||||
| 		$frame = new Frame(); | ||||
|  | ||||
| 		$quad = $this->getQuad(); | ||||
| 		$frame->add($quad); | ||||
|  | ||||
| 		$entry = $this->buildEntry(); | ||||
| 		$frame->add($entry); | ||||
| 		$this->feature->setEntry($entry); | ||||
|  | ||||
| 		return $frame->render($domDocument); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the hidden Entry | ||||
| 	 * | ||||
| 	 * @return \FML\Controls\Entry | ||||
| 	 */ | ||||
| 	protected function buildEntry() { | ||||
| 		$entry = new Entry(); | ||||
| 		$entry->setVisible(false)->setName($this->name); | ||||
| 		return $entry; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										134
									
								
								application/libs/FML/Components/ValuePicker.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								application/libs/FML/Components/ValuePicker.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
| <?php | ||||
|  | ||||
| namespace FML\Components; | ||||
|  | ||||
| use FML\Controls\Entry; | ||||
| use FML\Controls\Frame; | ||||
| use FML\Controls\Label; | ||||
| use FML\Script\Features\ScriptFeature; | ||||
| use FML\Script\Features\ValuePickerFeature; | ||||
| use FML\Types\Renderable; | ||||
| use FML\Types\ScriptFeatureable; | ||||
|  | ||||
| /** | ||||
|  * ValuePicker Component | ||||
|  * | ||||
|  * @author    steeffeen <mail@steeffeen.com> | ||||
|  * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| class ValuePicker implements Renderable, ScriptFeatureable { | ||||
| 	/* | ||||
| 	 * Protected properties | ||||
| 	 */ | ||||
| 	protected $name = null; | ||||
| 	protected $feature = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new ValuePicker Component | ||||
| 	 * | ||||
| 	 * @param string $name    (optional) CheckBox name | ||||
| 	 * @param array  $values  (optional) Possible values | ||||
| 	 * @param bool   $default (optional) Default value | ||||
| 	 * @param Label  $label   (optional) ValuePicker label | ||||
| 	 */ | ||||
| 	public function __construct($name = null, array $values = array(), $default = null, Label $label = null) { | ||||
| 		$this->feature = new ValuePickerFeature(); | ||||
| 		$this->setName($name); | ||||
| 		$this->setValues($values); | ||||
| 		$this->setDefault($default); | ||||
| 		$this->setLabel($label); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set Name | ||||
| 	 * | ||||
| 	 * @param string $name ValuePicker name | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setName($name) { | ||||
| 		$this->name = (string)$name; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the possible values | ||||
| 	 * | ||||
| 	 * @param array $values Possible values | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setValues(array $values) { | ||||
| 		$this->feature->setValues($values); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default value | ||||
| 	 * | ||||
| 	 * @param bool $default Default value | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setDefault($default) { | ||||
| 		$this->feature->setDefault($default); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the ValuePicker Label | ||||
| 	 * | ||||
| 	 * @param Label $label ValuePicker Label | ||||
| 	 * @return static | ||||
| 	 */ | ||||
| 	public function setLabel(Label $label = null) { | ||||
| 		$this->feature->setLabel($label); | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the ValuePicker Label | ||||
| 	 * | ||||
| 	 * @param bool $createIfEmpty (optional) Create the Label if it's not set | ||||
| 	 * @return \FML\Controls\Label | ||||
| 	 */ | ||||
| 	public function getLabel($createIfEmpty = true) { | ||||
| 		if (!$this->feature->getLabel() && $createIfEmpty) { | ||||
| 			$label = new Label(); | ||||
| 			$this->setLabel($label); | ||||
| 		} | ||||
| 		return $this->feature->getLabel(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Types\ScriptFeatureable::getScriptFeatures() | ||||
| 	 */ | ||||
| 	public function getScriptFeatures() { | ||||
| 		return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry()); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @see \FML\Types\Renderable::render() | ||||
| 	 */ | ||||
| 	public function render(\DOMDocument $domDocument) { | ||||
| 		$frame = new Frame(); | ||||
|  | ||||
| 		$label = $this->getLabel(); | ||||
| 		$frame->add($label); | ||||
|  | ||||
| 		$entry = $this->buildEntry(); | ||||
| 		$frame->add($entry); | ||||
| 		$this->feature->setEntry($entry); | ||||
|  | ||||
| 		return $frame->render($domDocument); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Build the hidden Entry | ||||
| 	 * | ||||
| 	 * @return \FML\Controls\Entry | ||||
| 	 */ | ||||
| 	protected function buildEntry() { | ||||
| 		$entry = new Entry(); | ||||
| 		$entry->setVisible(false)->setName($this->name); | ||||
| 		return $entry; | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user