PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/Mage/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php

https://github.com/JackoPlane/magento2
PHP | 105 lines | 45 code | 8 blank | 52 comment | 9 complexity | d430ef5092de064469f775e11112c40e MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_DesignEditor
  23. * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Color-picker form element renderer
  28. */
  29. class Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_ColorPicker
  30. extends Mage_DesignEditor_Block_Adminhtml_Editor_Form_Renderer_Recursive
  31. {
  32. /**
  33. * Set of templates to render
  34. *
  35. * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?>
  36. * Templates used are based fieldset/element.phtml but split into several templates
  37. *
  38. * @var array
  39. */
  40. protected $_templates = array(
  41. 'Mage_DesignEditor::editor/form/renderer/element/input.phtml',
  42. 'Mage_DesignEditor::editor/form/renderer/color-picker.phtml',
  43. 'Mage_DesignEditor::editor/form/renderer/element/wrapper.phtml',
  44. 'Mage_DesignEditor::editor/form/renderer/simple.phtml'
  45. );
  46. /**
  47. * Get HTMl class of a field
  48. *
  49. * Actually it will be added to a field wrapper
  50. *
  51. * @return array
  52. */
  53. public function getFieldClass()
  54. {
  55. /** @var $element Mage_DesignEditor_Block_Adminhtml_Editor_Form_Element_ColorPicker */
  56. $element = $this->getElement();
  57. $elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio';
  58. $addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml();
  59. //@TODO add class that show the control type 'color-picker' for this one
  60. $classes = array();
  61. $classes[] = 'field';
  62. $classes[] = 'field-' . $element->getId();
  63. $classes[] = $element->getCssClass();
  64. if ($elementBeforeLabel) {
  65. $classes[] = 'choice';
  66. }
  67. if ($addOn) {
  68. $classes[] = 'with-addon';
  69. }
  70. if ($element->getRequired()) {
  71. $classes[] = 'required';
  72. }
  73. if ($element->getNote()) {
  74. $classes[] = 'with-note';
  75. }
  76. return $classes;
  77. }
  78. /**
  79. * Get field attributes string
  80. *
  81. * Actually it will be added to a field wrapper
  82. *
  83. * @see Mage_DesignEditor::editor/form/renderer/simple.phtml
  84. * @return string
  85. */
  86. public function getFieldAttributes()
  87. {
  88. $element = $this->getElement();
  89. $fieldAttributes = array();
  90. if ($element->getHtmlContainerId()) {
  91. $fieldAttributes[] = sprintf('id="%s"', $element->getHtmlContainerId());
  92. }
  93. $fieldAttributes[] = sprintf('class="%s"', join(' ', $this->getFieldClass()));
  94. $fieldAttributes[] = $this->getUiId('form-field', $element->getId());
  95. return join(' ', $fieldAttributes);
  96. }
  97. }