/** * Method to get the field input markup. * * @return string The field input markup. */ public function getInput() { $element = $this->element; $doc = JFactory::getDocument(); $default = JRequest::getVar('field_default'); // is checkbox? $checkbox = (string) $this->element['checkbox']; 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 include_once AKPATH_HTML . '/grid.php'; $grid = new AKGrid(); $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 = JVERSION >= 3 ? '<a class="ak-delete-option btn" onclick="addOption(this);"><i class="icon-save-new"></i></a>' : '<a class="ak-delete-option btn" onclick="addOption(this);"><img src="templates/bluestork/images/admin/icon-16-add.png" alt="delete" /></a>'; $del_btn = JVERSION >= 3 ? '<a class="ak-delete-option btn" onclick="deleteOption(this);"><i class="icon-delete"></i></a>' : '<a class="ak-delete-option btn" onclick="deleteOption(this);"><img src="templates/bluestork/images/admin/publish_r.png" alt="delete" /></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="addAttrRow(this);" onblur="setDefault(this)" />'); $grid->setRowCell('text', '<input type="text" class="attr-text input-medium" name="attrs[options][text][]" value="' . $var['text'] . '" onfocus="addAttrRow(this);" />'); $grid->setRowCell('operate', $add_btn . $del_btn); //$html .= ; //$html .= '<input type="text" name="attrs[options]['.$key.'][text]" value="'.$var['text'].'" />' ; //$html .= '<input type="text" name="attrs[options]['.$key.'][value]" value="'.$var['text'].'" />' ; //$html .= '<div class="clr clearfix"> </div></div>' ; } // Set Javascript $doc->addScriptDeclaration("\n\n var akfields_num = " . (count($vars) - 1) . ' ;'); $this->addScript(count($vars) - 1); return (string) $grid; }
/** * Render table tree array to grid view. * * @param array $table A table tree array. * @param array $option The option for this table. * * @return string Grid HTML. */ public function renderGrid($table, $option = array()) { // Set Grid // ================================================================================= $grid = new AKGrid(); $grid->setTableOptions($option); $grid->setColumns(array_keys($table['thead']['tr'][0]['th'])); // Thead // ================================================================================= $grid->addRow($table['thead']['tr'][0]['option'], 1); foreach ($table['thead']['tr'][0]['th'] as $key => $th) { $grid->setRowCell($key, $th['content'], $th['option']); } // Tbody // ================================================================================= foreach ($table['tbody']['tr'] as $tr) { $grid->addRow($tr['option']); foreach ($tr['td'] as $key2 => $td) { $grid->setRowCell($key2, $td['content'], $td['option']); } } return $grid; }
* @subpackage Install.Script * @author Simon Asika <*****@*****.**> * @copyright Copyright (C) 2013 Asikart. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; $db = JFactory::getDbo(); // Show Installed table // ======================================================================== include_once $path . '/windwalker/html/grid.php'; $grid = new AKGrid(); $option['class'] = 'adminlist table table-striped table-bordered'; $option['style'] = JVERSION >= 3 ? 'width: 750px;' : 'width: 80%; margin: 15px;'; $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; if (JVERSION >= 3) { $tick = '<i class="icon-publish"></i>'; $cross = '<i class="icon-unpublish"></i>'; } else { $tick = '<img src="templates/bluestork/images/admin/tick.png" alt="Success" />'; $cross = '<img src="templates/bluestork/images/admin/publish_y.png" alt="Fail" />';