/** * 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; }
/** * Part of Windwalker project. * * @copyright Copyright (C) 2011 - 2014 SMS Taiwan, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ // No direct access defined('_JEXEC') or die; $db = JFactory::getDbo(); // Show Installed table // ======================================================================== $grid = new \JGrid(); $option['class'] = 'adminlist table table-striped table-bordered'; $option['style'] = 'width: 750px;'; $grid->setTableOptions($option); $grid->setColumns(array('num', 'type', 'name', 'version', 'state', 'info')); $grid->addRow(array(), 1); $grid->setRowCell('num', '#', array()); $grid->setRowCell('type', JText::_('COM_INSTALLER_HEADING_TYPE'), array()); $grid->setRowCell('name', JText::_('COM_INSTALLER_HEADING_NAME'), array()); $grid->setRowCell('version', JText::_('JVERSION'), array()); $grid->setRowCell('state', JText::_('JSTATUS'), array()); $grid->setRowCell('info', JText::_('COM_INSTALLER_MSG_DATABASE_INFO'), array()); // Set cells $i = 0; $tick = '<i class="icon-publish"></i>'; $cross = '<i class="icon-unpublish"></i>'; $td_class = array('style' => 'text-align:center;'); // Set Extension install success info // ======================================================================== include __DIR__ . '/installscript/' . $manifest['type'] . '.php';