예제 #1
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     if (!isset($data->view->colSpan)) {
         throw new \LogicException('Please put "column" tags in "row" tag.');
     }
     $span = XmlHelper::get($element, 'span');
     $fill = XmlHelper::getBool($element, 'fill', !(bool) $span);
     if (!$span) {
         $span = 12;
     }
     if ($fill) {
         $span = $data->view->colSpan ?: 12;
     } else {
         $data->view->colSpan -= $span;
     }
     if ((int) $span <= 0) {
         $span = 12;
     }
     if ($data->view->colSpan <= 0) {
         $data->view->colSpan = 12 + $data->view->colSpan;
     }
     $colClass = 'span' . $span;
     $element['class'] = isset($element['class']) ? $colClass . ' ' . $element['class'] : $colClass;
     return HtmlRenderer::render('div', $engine, $element, $data);
 }
예제 #2
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     // Handle title
     $title = XmlHelper::get($element, 'title', (string) static::renderChildren($engine, $element, $data));
     $element['title'] = trim($title);
     return $element;
 }
예제 #3
0
 /**
  * addFramework
  *
  * @param $element
  * @param $data
  *
  * @return  void
  */
 protected static function addFramework($element, $data)
 {
     $framework = XmlHelper::get($element, 'framework');
     $debug = XmlHelper::getBool($element, 'debug');
     $asset = $data->asset;
     if (!$framework) {
         return;
     }
     $names = explode(',', strtolower($framework));
     if (in_array('mootools', $names)) {
         $asset->mootools($debug);
     }
     if (in_array('jquery', $names)) {
         $asset->jquery($debug);
     }
     if (in_array('jquery-ui', $names)) {
         $asset->jqueryUI($debug);
     }
     if (in_array('windwalker', $names)) {
         $asset->windwalker($debug);
     }
     if (in_array('bootstrap', $names)) {
         $asset->bootstrap($debug);
     }
 }
예제 #4
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $html = static::renderChildren($engine, $element, $data);
     if (XmlHelper::getBool($element, 'display', true)) {
         return $html;
     }
     return '';
 }
예제 #5
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  */
 public function getInput()
 {
     $input = $this->container->get('input');
     $element = $this->element;
     $doc = JFactory::getDocument();
     $default = $input->get('field_default');
     // Is checkbox?
     $checkbox = \Windwalker\Helper\XmlHelper::get($this->element, 'ckeckbox');
     if ($checkbox == 'true' || $checkbox == '1') {
         $checkbox = true;
         $default = explode(',', $default);
     } else {
         $checkbox = false;
     }
     // Set Default Vars
     $vars = $this->value ? $this->value : array();
     $vars[] = array('text' => '', 'value' => '');
     // Prepare Grid
     $grid = new JGrid();
     $grid->setTableOptions(array('class' => 'adminlist table table-striped', 'id' => 'ak-attr-table'));
     $grid->setColumns(array('default', 'value', 'text', 'operate'));
     // Set TH
     $grid->addRow(array('class' => 'row1'));
     $grid->setRowCell('default', JText::_('LIB_WINDWALKER_ATTR_DEFAULT'));
     $grid->setRowCell('value', JText::_('LIB_WINDWALKER_ATTR_VALUE'));
     $grid->setRowCell('text', JText::_('LIB_WINDWALKER_ATTR_TEXT'));
     $grid->setRowCell('operate', JText::_('LIB_WINDWALKER_ATTR_OPERATE'));
     foreach ($vars as $key => $var) {
         $checked = '';
         if ($checkbox) {
             if (in_array($var['value'], $default)) {
                 $checked = 'checked';
             }
         } else {
             if ($var['value'] === $default) {
                 $checked = 'checked';
             }
         }
         //Set Operate buttons
         $add_btn = '<a class="ak-delete-option btn" onclick="WindwalkerCCKList.addOption(this);"><i class="icon-save-new"></i></a>';
         $del_btn = '<a class="ak-delete-option btn" onclick="WindwalkerCCKList.deleteOption(this);"><i class="icon-delete"></i></a>';
         // Set TR
         $grid->addRow(array('class' => 'row' . $key % 2));
         // Set TDs
         if ($checkbox) {
             $grid->setRowCell('default', '<input type="checkbox" class="attr-default" id="option-' . $key . '" name="attrs[default][]" value="' . $var['value'] . '" ' . $checked . '/>');
         } else {
             $grid->setRowCell('default', '<input type="radio" class="attr-default" id="option-' . $key . '" name="attrs[default]" value="' . $var['value'] . '" ' . $checked . '/>');
         }
         $grid->setRowCell('value', '<input type="text" class="attr-value input-medium" name="attrs[options][value][]" value="' . $var['value'] . '" onfocus="WindwalkerCCKList.addAttrRow(this);" onblur="WindwalkerCCKList.setDefault(this)" />');
         $grid->setRowCell('text', '<input type="text" class="attr-text input-medium" name="attrs[options][text][]" value="' . $var['text'] . '" onfocus="WindwalkerCCKList.addAttrRow(this);" />');
         $grid->setRowCell('operate', $add_btn . $del_btn);
     }
     // Set Javascript
     $doc->addScriptDeclaration("\n\n var akfields_num = " . (count($vars) - 1) . ' ;');
     $this->addScript(count($vars) - 1);
     return (string) $grid;
 }
예제 #6
0
 /**
  * executeInstance
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @return  mixed
  */
 protected static function executeInstance($name, $element, $data)
 {
     $method = XmlHelper::get($element, 'method');
     $instance = ArrayHelper::getByPath($data, $name);
     if (!is_callable(array($instance, $method))) {
         throw new \InvalidArgumentException(sprintf('Object or method: $data->%s->%s() not exists.', $name, $method));
     }
     return call_user_func_array(array($instance, $method), static::getArguments($element, $data));
 }
예제 #7
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $tabsetName = XmlHelper::get($element, 'name', 'myTab');
     $data->tabSetName = $tabsetName;
     $html = JHtmlBootstrap::startTabSet($tabsetName, array('active' => XmlHelper::get($element, 'active')));
     $html .= $e = static::renderChildren($engine, $element, $data);
     $html .= JHtmlBootstrap::endTabSet();
     return $html;
 }
예제 #8
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $tabName = XmlHelper::get($element, 'name');
     $label = $element['label'] ? (string) $element['label'] : $data->view->option . '_EDIT_FIELDS_' . $tabName;
     $html = JHtmlBootstrap::addTab($data->tabSetName, $tabName, \JText::_($label));
     $html .= static::renderChildren($engine, $element, $data);
     $html .= JHtmlBootstrap::endTab();
     return $html;
 }
예제 #9
0
    /**
     * Method to get the user field input markup.
     *
     * @return  string  The field input markup.
     */
    protected function getInput()
    {
        $html = array();
        $groups = $this->getGroups();
        $excluded = $this->getExcluded();
        $link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;field=' . $this->id . (isset($groups) ? '&amp;groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&amp;excluded=' . base64_encode(json_encode($excluded)) : '');
        // Initialize some field attributes.
        $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
        // Initialize JavaScript field attributes.
        $onchange = (string) $this->element['onchange'];
        // Load the modal behavior script.
        WindwalkerScript::modal('.hasUserModal');
        JQueryScript::ui(array('effect'));
        // Build the script.
        $js = <<<JS
function jSelectUser_{$this->id}(id, title) {
\tvar input = jQuery('#{$this->id}_id');
\tvar oldId = input.val();

\tif (oldId != id) {
\t\tinput.val(id);
\t\tjQuery('#{$this->id}_name').val(title).removeClass('invalid').delay(300).effect('highlight');
\t}

\t{$onchange};

\tWindwalker.Modal.hide();
};
JS;
        // Add the script to the document head.
        $asset = Container::getInstance()->get('helper.asset');
        $asset->internalJS($js);
        // Load the current username if available.
        $table = JTable::getInstance('user');
        if ($this->value) {
            $table->load($this->value);
        } elseif (strtoupper($this->value) == 'CURRENT') {
            // 'CURRENT' is not a reasonable value to be placed in the html
            $this->value = JFactory::getUser()->id;
            $table->load($this->value);
        } else {
            $table->name = JText::_('JLIB_FORM_SELECT_USER');
        }
        // Create a dummy text field with the user name.
        $html[] = '<div class="input-append">';
        $html[] = '	<input type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />';
        // Create the user select button.
        if (!XmlHelper::getBool($this->element, 'readonly', false)) {
            $html[] = '		<a class="btn btn-primary hasUserModal modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
            $html[] = '<i class="icon-user"></i></a>';
        }
        $html[] = '</div>';
        // Create the real field, hidden, that stored the user id.
        $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $this->value . '" />';
        return implode("\n", $html);
    }
예제 #10
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $tableOption = XmlHelper::getAttributes($element);
     $data->xulControl->columnNum = 0;
     $data->xulControl->column = array();
     $data->xulControl->grid = $grid = new JGrid($tableOption);
     $data->xulControl->classPrefix = 'Grid';
     $html = static::renderChildren($engine, $element, $data);
     return $grid;
 }
예제 #11
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $element['static'] = $handler = XmlHelper::get($element, 'handler', 'print_r');
     $element->addChild('argument')->addAttribute('data', XmlHelper::get($element, 'data'));
     $element->addChild('argument', 1);
     if ($handler == 'print_r') {
         return new HtmlElement('pre', parent::doRender($name, $element, $data));
     } else {
         return parent::doRender($name, $element, $data);
     }
 }
예제 #12
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $rowClass = XmlHelper::getBool($element, 'fluid', true) ? 'row-fluid' : 'row';
     $element['class'] = isset($element['class']) ? $rowClass . ' ' . $element['class'] : $rowClass;
     if (empty($data->view)) {
         $data->view = new Data();
     }
     $data->view->colSpan = 12;
     $html = HtmlRenderer::render('div', $engine, $element, $data);
     unset($data->view->colSpan);
     return $html;
 }
예제 #13
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $layoutName = XmlHelper::get($element, 'name');
     if (!$layoutName) {
         throw new \InvalidArgumentException('Please add "name" to <layout> tag.');
     }
     $layout = new FileLayout($layoutName);
     $displayData = array('view' => $data);
     $args = static::getArguments($element, $data, 'data');
     $displayData = array_merge($displayData, $args);
     return $layout->render($displayData);
 }
예제 #14
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $grid = $data->xulControl->grid;
     $cells = static::renderChildren($engine, $element, $data);
     $grid->addRow(XmlHelper::getAttributes($element));
     foreach ($cells as $key => $cell) {
         $content = String::parseVariable($cell, $data);
         $attribs = XmlHelper::getAttributes($element);
         $grid->setRowCell($key, $content, $attribs);
     }
     reset($element);
     return $cells;
 }
예제 #15
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $cols = static::renderChildren($engine, $element, $data);
     $gridHelper = $data->grid;
     $grid = $data->xulControl->grid;
     $grid->addRow(array(), 1);
     foreach ($cols as $key => $value) {
         $attribs = XmlHelper::getAttributes($element);
         $title = XmlHelper::get($value, 'title');
         unset($attribs['title']);
         $grid->addColumn($key, $attribs);
         $grid->setRowCell($key, $title, $attribs);
     }
 }
예제 #16
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $field = XmlHelper::get($element, 'field');
     $ele = new \SimpleXMLElement('<root></root>');
     $attrs = $element->attributes();
     foreach ($attrs as $key => $attr) {
         $ele[$key] = $attr;
     }
     if (!$field) {
         $ele[0] = (string) static::renderChildren($engine, $element, $data);
         return $ele;
     }
     $ele[0] = $data->xulControl->currentItem->{$field};
     return $ele;
 }
예제 #17
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $itemsKey = XmlHelper::get($element, 'data', 'items');
     $items = (array) ArrayHelper::getByPath($data, $itemsKey);
     $rows = new HtmlElements();
     foreach ($items as $i => $item) {
         // Prepare data
         $item = new Data($item);
         $data->xulControl->currentItem = $item;
         // Prepare item for GridHelper
         $data->grid->setItem($item, $i);
         $rows[] = RowRenderer::render('row', $engine, $element, $data);
     }
     return $rows;
 }
예제 #18
0
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $dataKey = XmlHelper::get($element, 'data');
     $sidebar = $dataKey ? ArrayHelper::getByPath($data, $dataKey) : $data->sidebar;
     if (empty($sidebar)) {
         return '';
     }
     $html = new HtmlElements();
     $html[] = new HtmlElement('h4', JText::_(XmlHelper::get($element, 'title', 'JOPTION_MENUS')));
     $html[] = $sidebar;
     $element->addChild('block', $html);
     if (!isset($data->view->colSpan)) {
         throw new \LogicException('Please put "sidebar" tag in "row" tag.');
     }
     return parent::doRender($name, $engine, $element, $data);
 }
예제 #19
0
 /**
  * Method to get the user field input markup.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     $html = array();
     $groups = $this->getGroups();
     $excluded = $this->getExcluded();
     $link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;field=' . $this->id . (isset($groups) ? '&amp;groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&amp;excluded=' . base64_encode(json_encode($excluded)) : '');
     // Initialize some field attributes.
     $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     // Initialize JavaScript field attributes.
     $onchange = (string) $this->element['onchange'];
     // Load the modal behavior script.
     JHtml::_('behavior.modal', 'a.modal_' . $this->id);
     // Build the script.
     $script = array();
     $script[] = '	function jSelectUser_' . $this->id . '(id, title) {';
     $script[] = '		var old_id = document.getElementById("' . $this->id . '_id").value;';
     $script[] = '		if (old_id != id) {';
     $script[] = '			document.getElementById("' . $this->id . '_id").value = id;';
     $script[] = '			document.getElementById("' . $this->id . '_name").value = title;';
     $script[] = '			' . $onchange;
     $script[] = '		}';
     $script[] = '		SqueezeBox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     $asset = Container::getInstance()->get('helper.asset');
     $asset->internalJS(implode("\n", $script));
     // Load the current username if available.
     $table = JTable::getInstance('user');
     if ($this->value) {
         $table->load($this->value);
     } else {
         $table->name = JText::_('JLIB_FORM_SELECT_USER');
     }
     // Create a dummy text field with the user name.
     $html[] = '<div class="input-append">';
     $html[] = '	<input type="text" id="' . $this->id . '" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />';
     // Create the user select button.
     if (!XmlHelper::getBool($this->element, 'readonly', false)) {
         $html[] = '		<a class="btn btn-primary modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
         $html[] = '<i class="icon-user"></i></a>';
     }
     $html[] = '</div>';
     // Create the real field, hidden, that stored the user id.
     $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $this->value . '" />';
     return implode("\n", $html);
 }
예제 #20
0
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \UnexpectedValueException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $formVar = XmlHelper::get($element, 'form', 'form');
     $fieldset = XmlHelper::get($element, 'name');
     if (!$fieldset) {
         throw new \UnexpectedValueException('Need "name" attribute in XUL <fieldset> element.');
     }
     $form = $data->{$formVar};
     if (!$form instanceof \JForm) {
         throw new \UnexpectedValueException(sprintf('No form data found in $data->%s.', $formVar));
     }
     $option = $data->view->option ?: 'LIB_WINDWALKER';
     $label = XmlHelper::get($element, 'label', $option . '_EDIT_FIELDSET_' . $fieldset);
     $label = String::parseVariable($label, $data);
     $html = '<legend>' . \JText::_(strtoupper($label)) . '</legend>';
     foreach ($form->getFieldset($fieldset) as $field) {
         $html .= $field->getControlGroup() . "\n\n";
     }
     $html = HtmlBuilder::create('fieldset', $html, XmlHelper::getAttributes($element));
     return $html;
 }
예제 #21
0
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \UnexpectedValueException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     XmlHelper::def($element, 'action', $data->uri->path);
     XmlHelper::def($element, 'method', 'post');
     XmlHelper::def($element, 'id', $data->view->name . '-form');
     XmlHelper::def($element, 'name', 'adminForm');
     XmlHelper::def($element, 'class', 'form-validate');
     XmlHelper::def($element, 'enctype', 'multipart/form-data');
     $attributes = XmlHelper::getAttributes($element);
     $footerHandler = XmlHelper::get($element, 'type', 'default');
     $footerHandler = array(__CLASS__, 'render' . ucfirst($footerHandler) . 'Footer');
     // Build hidden inputs
     $footer = HtmlBuilder::create('input', null, array('type' => 'hidden', 'name' => 'option', 'value' => $data->view->option));
     $footer .= HtmlBuilder::create('input', null, array('type' => 'hidden', 'name' => 'task', 'value' => ''));
     $footer .= is_callable($footerHandler) ? call_user_func_array($footerHandler, array()) : '';
     $footer .= JHtml::_('form.token');
     // Wrap inputs
     $children = static::renderChildren($engine, $element, $data);
     $children .= HtmlBuilder::create('div', $footer, array('id' => 'hidden-inputs'));
     return HtmlBuilder::create($name, $children, $attributes);
 }
예제 #22
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  */
 public function getOptions()
 {
     if ($this->value) {
         $this->value = XmlHelper::get($this->element, 'default');
     }
     $element = $this->element;
     $types = array('raw', 'int', 'uint', 'float', 'bool', 'word', 'alnum', 'base64', 'string', 'safehtml', 'array', 'url', 'path', 'username', 'tel');
     // Includes
     $includes = $element['include'];
     if ($includes) {
         $includes = explode(',', $includes);
         foreach ($includes as &$include) {
             $include = trim($include);
         }
         $types = $includes;
     }
     // Excludes
     $excludes = (string) $element['exclude'];
     if ($excludes) {
         $excludes = explode(',', $excludes);
         foreach ($excludes as &$exclude) {
             $exclude = trim($exclude);
         }
     } else {
         $excludes = array();
     }
     // Set Options
     $options = array();
     foreach ($types as $type) {
         $type = str_replace('.xml', '', $type);
         // Excludes
         if (in_array($type, $excludes)) {
             continue;
         }
         $options[] = JHtml::_('select.option', (string) $type, JText::_('LIB_WINDWALKER_FILTERLIST_' . strtoupper($type)));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
예제 #23
0
    /**
     * Method to get the field input markup.
     *
     * @return  string  The field input markup.
     */
    protected function getInput()
    {
        $plugin = JPluginHelper::isEnabled('system', 'ezset');
        if (!$plugin) {
            return print_r($plugin, 1) . '需要先啟動外掛!';
        }
        $this->loadScript();
        $editor = \JEditor::getInstance('codemirror');
        $client = \Windwalker\Helper\XmlHelper::get($this->element, 'client', 'site');
        $content = $this->getContent($client);
        $params['linenumbers'] = 1;
        $params['tabmode'] = 'shift';
        $params['width'] = 400;
        $params['height'] = 300;
        $params['syntax'] = 'css';
        $doc = \JFactory::getDocument();
        $doc->addStyleDeclaration(<<<CSS
.custom-css-field .CodeMirror
{
\tw/idth: 700px;
\theight: 400px;
}
CSS
);
        $save = JText::_('PLG_SYSTEM_EZSET_SAVE');
        $output = $editor->display($this->name, $content, '400px', '400px', 400, 400, false, null, null, null, $params);
        $output = <<<HTML
<fieldset class="adminform custom-css-field">
\t<div style="margin-bottom: 25px;" class="custom-css-toolbar">
\t\t<button class="btn btn-default" type="button" data-client="{$client}"
\t\t\tonclick="EzsetCustomCSS.save('#{$this->id}', '{$this->name}', this, event);"><i class="icon-save"></i> {$save}</button>
\t</div>
\t<div style="height: 400px; margin-bottom: 30px;">{$output}</div>
</fieldset>
HTML;
        return $output;
    }
예제 #24
0
 /**
  * Method to get the field input markup.
  *
  * @return    string    The field input markup.
  */
 public function getOptions()
 {
     //$this->value = JRequest::getVar('field_type') ;
     $this->setFieldData();
     $input = $this->container->get('input');
     if (!$this->value) {
         $this->value = XmlHelper::get($this->element, 'default');
     }
     $input->set('field_type', $this->value, 'method', true);
     $element = $this->element;
     $types = JFolder::files(__DIR__ . '/../Resource/Form');
     JFactory::getApplication()->triggerEvent('onCCKEnginePrepareFieldtypes', array(&$types, &$this, &$element));
     $options = array();
     foreach ($types as $type) {
         $type = str_replace('.xml', '', $type);
         if ($type == 'index.html') {
             continue;
         }
         $options[] = JHtml::_('select.option', (string) $type, JText::_('LIB_WINDWALKER_FIELDTYPE_' . strtoupper($type)));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
예제 #25
0
 /**
  * getParsedAttributes
  *
  * @param \SimpleXmlElement $element
  * @param Data              $data
  *
  * @return  mixed
  */
 protected static function getParsedAttributes($element, $data)
 {
     $attributes = XmlHelper::getAttributes($element);
     return static::replaceVariable($attributes, $data);
 }
예제 #26
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $attributes = XmlHelper::getAttributes($element);
     return new HtmlElement($name, static::renderChildren($engine, $element, $data), $attributes);
 }
예제 #27
0
 /**
  * Get Finder link.
  *
  * @return string The link string.
  */
 public function getLink()
 {
     $input = Container::getInstance()->get('input');
     $handler = $this->element['handler'] ? (string) $this->element['handler'] : $input->get('option');
     $root = XmlHelper::get($this->element, 'root', '/');
     $start_path = XmlHelper::get($this->element, 'start_path', '/');
     $onlymimes = XmlHelper::get($this->element, 'onlymimes', '');
     $root = $this->convertPath($root);
     $start_path = $this->convertPath($start_path);
     $link = "index.php?option={$handler}&task=finder.elfinder.display&tmpl=component&finder_id={$this->id}&root={$root}&start_path={$start_path}&onlymimes={$onlymimes}";
     return $link;
 }
    /**
     * testGetAttributes
     *
     * @return  void
     *
     * @covers \Windwalker\Helper\XmlHelper::getAttributes
     */
    public function testGetAttributes()
    {
        $document = '<xml>
					   <nikon type="camera" price="40000" store="20" color="black">D850</nikon>
					</xml>';
        $element = new \SimpleXMLElement($document);
        $getAttributes = XmlHelper::getAttributes($element->nikon);
        $result = array('type' => 'camera', 'price' => '40000', 'store' => '20', 'color' => 'black');
        $this->assertEquals($getAttributes, $result);
    }
예제 #29
0
 /**
  * getLink
  *
  * @return  string
  */
 public function getLink()
 {
     $input = JFactory::getApplication()->input;
     // Avoid self
     $id = $input->get('id');
     $option = $input->get('option');
     $view = $input->get('view');
     $layout = $input->get('layout');
     $select = \Windwalker\Helper\XmlHelper::get($this->element, 'select');
     return 'index.php?option=' . $this->extension . '&view=' . $select . '&layout=modal&tmpl=component&function=jSelect' . ucfirst($this->component) . '_' . $this->id;
 }