-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from deanblackborough/preset-tools
Preset tools
- Loading branch information
Showing
27 changed files
with
866 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
library/Dlayer/DesignerTool/FormBuilder/PresetAddress/Form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
/** | ||
* Form for the preset address tool | ||
* | ||
* @author Dean Blackborough | ||
* @copyright G3D Development Limited | ||
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE | ||
*/ | ||
class Dlayer_DesignerTool_FormBuilder_PresetAddress_Form extends Dlayer_Form_Tool_Form | ||
{ | ||
/** | ||
* Set the properties for the form | ||
* | ||
* @param array $tool Tool and environment data array | ||
* @param array $data Current data for content item | ||
* @param array $element_data | ||
* @param array|NULL $options Zend form options | ||
*/ | ||
public function __construct(array $tool, array $data, array $element_data, $options=NULL) | ||
{ | ||
$tool['name'] = 'Textarea'; // Override the tool | ||
$this->field_type = 'Textarea'; | ||
$this->preset = 1; | ||
|
||
parent::__construct($tool, $data, $element_data, $options); | ||
} | ||
|
||
/** | ||
* Initialise the form, sets the action and method and then calls the elements to build the form | ||
* | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
$this->setAction('/form/process/tool'); | ||
|
||
$this->setMethod('post'); | ||
|
||
$this->generateFormElements(); | ||
|
||
$this->addElementsToForm('address', 'Address element', $this->elements); | ||
|
||
$this->addDefaultElementDecorators(); | ||
|
||
$this->addCustomElementDecorators(); | ||
} | ||
|
||
protected function generateUserElements() | ||
{ | ||
$label = new Zend_Form_Element_Hidden('label'); | ||
$label->setBelongsTo('params'); | ||
$label->setDescription('Click <mark>save</mark> to quickly add an address element to your form, all | ||
the options and values have been preset for you, if necessary, you can alter them by editing the element.'); | ||
if (array_key_exists('label', $this->data) && $this->data['label'] !== false) { | ||
$label->setValue($this->data['label']); | ||
} | ||
|
||
$this->elements['label'] = $label; | ||
|
||
$description = new Zend_Form_Element_Hidden('description'); | ||
$description->setBelongsTo('params'); | ||
if (array_key_exists('description', $this->data) && $this->data['description'] !== false) { | ||
$description->setValue($this->data['description']); | ||
} | ||
|
||
$this->elements['description'] = $description; | ||
|
||
$placeHolder = new Zend_Form_Element_Hidden('placeholder'); | ||
$placeHolder->setBelongsTo('params'); | ||
if (array_key_exists('placeholder', $this->data) && $this->data['placeholder'] !== false) { | ||
$placeHolder->setValue($this->data['placeholder']); | ||
} | ||
|
||
$this->elements['placeholder'] = $placeHolder; | ||
|
||
$rows = new Zend_Form_Element_Hidden('rows'); | ||
$rows->setBelongsTo('params'); | ||
if (array_key_exists('rows', $this->data) && $this->data['rows'] !== false) { | ||
$rows->setValue($this->data['rows']); | ||
} | ||
|
||
$this->elements['rows'] = $rows; | ||
|
||
$cols = new Zend_Form_Element_Hidden('cols'); | ||
$cols->setBelongsTo('params'); | ||
if (array_key_exists('cols', $this->data) && $this->data['cols'] !== false) { | ||
$cols->setValue($this->data['cols']); | ||
} | ||
|
||
$this->elements['cols'] = $cols; | ||
} | ||
|
||
protected function addCustomElementDecorators() | ||
{ | ||
parent::addCustomElementDecorators(); | ||
|
||
$this->elements['label']->getDecorator('Description')->setOption('escape', false); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
library/Dlayer/DesignerTool/FormBuilder/PresetAddress/Ribbon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/** | ||
* Preset address element tool ribbon class | ||
* | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright G3D Development Limited | ||
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE | ||
*/ | ||
class Dlayer_DesignerTool_FormBuilder_PresetAddress_Ribbon extends Dlayer_Ribbon_Form | ||
{ | ||
/** | ||
* Fetch the view data for the tool tab, contains an index with the form (pre filled if necessary) and another | ||
* with the data required by the live preview functions | ||
* | ||
* @param array $tool Tool and environment data array | ||
* @return array Data array for view | ||
*/ | ||
public function viewData(array $tool) | ||
{ | ||
$this->tool = $tool; | ||
|
||
$this->fieldData(); | ||
|
||
return array( | ||
'form' => new Dlayer_DesignerTool_FormBuilder_PresetAddress_Form( | ||
$tool, | ||
$this->field_data, | ||
array() | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Fetch any existing field data, always return an array, values are false if noting exists | ||
* | ||
* @return void | ||
*/ | ||
protected function fieldData() | ||
{ | ||
if ($this->field_data_fetched === false) { | ||
$this->field_data = array( | ||
'label' => 'Your address', | ||
'description' => 'Please enter your address', | ||
'placeholder' => 'e.g., 1, The Street, The Town, AA1 BB2', | ||
'rows' => 4, | ||
'cols' => 40 | ||
); | ||
|
||
$this->field_data_fetched = true; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
library/Dlayer/DesignerTool/FormBuilder/PresetAddress/scripts/help.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php /** @var $this Dlayer_View_Codehinting */?> | ||
|
||
<div class="col-md-12 col-sm-12"> | ||
<h3>Help <small>TODO</small></h3> | ||
|
||
<p>@TODO - Add help page content.</p> | ||
</div> | ||
|
||
<div class="col-md-12 col-sm-12 further-reading"> | ||
<?php echo $this->furtherReading(null, true); ?> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
library/Dlayer/DesignerTool/FormBuilder/PresetAddress/scripts/preset-address.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php /** @var $this Dlayer_View_Codehinting */?> | ||
|
||
<div class="col-md-12 col-sm-12"> | ||
<?php | ||
if($this->data !== false) { | ||
echo $this->data['form']; | ||
} | ||
?> | ||
</div> |
Oops, something went wrong.