/**
  * 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);
     }
 }
 /**
  * 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);
 }
 /**
  * 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 '';
 }
    /**
     * 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);
    }
 /**
  * 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;
 }
    /**
     * Method to get the field input markup.
     *
     * @return  string  The field input markup.
     */
    public function getInput()
    {
        // Load the modal behavior script.
        WindwalkerScript::modal('.hasFinderModal');
        if (!static::$initialised) {
            $this->setScript();
        }
        // Setup variables for display.
        // ================================================================
        $html = array();
        $disabled = XmlHelper::getBool($this->element, 'disabled');
        $readonly = XmlHelper::getBool($this->element, 'readonly');
        $link = $this->getLink();
        $title = $this->getTitle();
        // Set Title
        // ================================================================
        if (empty($title)) {
            $title = \JText::_(XmlHelper::get($this->element, 'select_label', 'LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE'));
        }
        $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
        // The text field.
        // ================================================================
        $preview = $this->getPreview();
        // The current user display field.
        $html[] = '<span class="' . (!$disabled && !$readonly ? 'input-append' : '') . '">';
        $html[] = '<input type="text" class="finder-item-name ' . (!$disabled && !$readonly ? 'input-medium ' . $this->element['class'] : $this->element['class']) . '" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
        if (!$disabled && !$readonly) {
            $html[] = '<a class="hasFinderModal btn btn-primary" title="' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1">
							<i class="icon-picture"></i> ' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '</a>';
        }
        $html[] = '</span>';
        // The  class='required' for client side validation
        // ================================================================
        $class = '';
        if ($this->required) {
            $class = ' class="required modal-value"';
        }
        // Velue store input
        $disabled_attr = $disabled ? ' disabled="true" ' : '';
        $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $this->value . '" ' . $disabled_attr . ' />';
        $html = implode("\n", $html);
        $options = array('text' => array('clear_title' => JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE')));
        $this->initScript('#' . $this->id, $options);
        if (!$disabled && !$readonly) {
            $html .= '<a class="btn btn-danger hasTooltip clear-button" title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="javascript: void(0)">';
            $html .= '<i class="icon-remove"></i></a>';
        }
        // Image Preview
        // ================================================================
        $html = $html . $preview;
        return $html;
    }
Exemple #7
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);
 }
Exemple #8
0
    /**
     * Method to get the field input markup.
     *
     * @return  string  The field input markup.
     */
    public function getInput()
    {
        // Load the modal behavior script.
        JHtmlBehavior::modal('a.modal');
        if (!self::$initialised) {
            $this->setScript();
        }
        // Setup variables for display.
        // ================================================================
        $html = array();
        $disabled = XmlHelper::getBool($this->element, 'disabled');
        $readonly = XmlHelper::getBool($this->element, 'readonly');
        $link = $this->getLink();
        $title = $this->getTitle();
        // Set Title
        // ================================================================
        if (empty($title)) {
            $title = \JText::_(XmlHelper::get($this->element, 'select_label', 'LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE'));
        }
        $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
        // The text field.
        // ================================================================
        $preview = $this->getPreview();
        // The current user display field.
        $html[] = '<span class="' . (!$disabled && !$readonly ? 'input-append' : '') . '">';
        $html[] = '<input type="text" class="' . (!$disabled && !$readonly ? 'input-medium ' . $this->element['class'] : $this->element['class']) . '" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
        if (!$disabled && !$readonly) {
            $html[] = '<a class="modal btn btn-primary" title="' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 920, y: 450}}">
							<i class="icon-picture"></i> ' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '</a>';
        }
        $html[] = '</span>';
        // The  class='required' for client side validation
        // ================================================================
        $class = '';
        if ($this->required) {
            $class = ' class="required modal-value"';
        }
        // Velue store input
        $disabled_attr = $disabled ? ' disabled="true" ' : '';
        $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $this->value . '" ' . $disabled_attr . ' />';
        $html = implode("\n", $html);
        // Tooltip Preview
        // ================================================================
        if ($this->showAsTooltip) {
            $html = $preview . $html;
            $html = '<div class="input-prepend input-append" style="margin-right: 7px;">' . $html . '</div>';
        }
        // Clear Button
        // ================================================================
        $clear_title = JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE');
        if (!$disabled && !$readonly) {
            $html .= '<a class="btn btn-danger delicious light red fltlft hasTooltip" title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="';
            $html .= "AKFinderClear('{$this->id}', '{$clear_title}');";
            $html .= 'return false;';
            $html .= '">';
            $html .= '<i class="icon-remove"></i></a>';
        }
        // Image Preview
        // ================================================================
        if (!$this->showAsTooltip) {
            $html = $html . $preview;
        }
        return $html;
    }
 /**
  * testBoolForFalse
  *
  * @param \SimpleXMLElement $element
  * @param string            $attr
  * @param string            $expected
  *
  * @return  void
  *
  * @dataProvider elementForFalseProvider
  *
  * @covers \Windwalker\Helper\XmlHelper::getBool
  */
 public function testBoolForFalse($element, $attr, $expected)
 {
     $testForFalse = XmlHelper::getBool($element->batman, $attr);
     $this->assertEquals($testForFalse, $expected);
 }