PHP JGrid Code Examples

PHP JGrid - 5 examples found. These are the top rated real world PHP examples of JGrid extracted from open source projects. You can rate examples to help us improve the quality of examples
Frequently Used Methods
Example #1
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;
 }
 /**
  * The first stage in preparing the content for output
  *
  * @param $context
  * @param $article
  * @param $params
  * @param $page
  *
  * @return string
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     if (!isset($article->testimonial) || !count($article->testimonial)) {
         return;
     }
     // add extra css for table
     $doc = JFactory::getDocument();
     //$doc->addStyleSheet(JURI::base(true).'/plugins/content/ksextras/extras/ksextras.css');
     // construct a result table on the fly
     jimport('joomla.html.grid');
     $table = new JGrid();
     // Create columns
     $table->addColumn('attr')->addColumn('value');
     // populate
     $rownr = 0;
     foreach ($article->testimonial as $attr => $value) {
         $table->addRow(array('class' => 'row' . $rownr % 2));
         $table->setRowCell('attr', $attr);
         $table->setRowCell('value', $value);
         $rownr++;
     }
     // wrap table in a classed <div>
     $suffix = $this->params->get('testimonialclass_sfx', 'testimonial');
     $html = '<div class="' . $suffix . '">' . (string) $table . '</div>';
     $article->text = $html . $article->text;
 }
Example #3
0
function show_links()
{
    $NEW_VALUE_FORM = 'catlinksnew';
    if (isset($_GET['result'])) {
        $result_field = $_GET['result'];
    } else {
        $result_field = "tablelinks";
    }
    $options = array();
    $options["border"] = "1";
    $options["cellpadding"] = "3";
    $options["bgcolor"] = "#CCCCCC";
    $colNum = 'TitleNum';
    $colName = 'TitleName';
    $colParent = 'TitleParent';
    $colSyn = 'TitleSynonym';
    $colDel = 'Delete';
    //	$name = 'TitleDesc';
    //	$grid->addColumn($name);
    //	$grid->setRowCell($name, 'Описание');
    $db = new Dbprocess();
    $db->connectToDb();
    $table_prefix = $db->getTablePrefix();
    $grid = new JGrid($options);
    $grid->addRow($options = array());
    $grid->addColumn($colNum);
    $grid->setRowCell($colNum, 'ID');
    $grid->addColumn($colName);
    $grid->setRowCell($colName, 'Наименование');
    $grid->addColumn($colParent);
    $grid->setRowCell($colParent, 'Родитель');
    $grid->addColumn($colSyn);
    $grid->setRowCell($colSyn, 'Синоним');
    $grid->addColumn($colDel);
    $grid->setRowCell($colDel, 'Добавить');
    $grid->addRow($options = array());
    $max_result = $db->select($table_prefix . "virtuemart_category_links", "category_links_ID", "", 'max');
    //include_once("fb.php");
    //fb($max_result, "max_result");
    $html .= $max_result['html'];
    $max = $max_result['value'] + 1;
    $grid->setRowCell($colNum, "<input name='category_links_ID' id='category_links_ID' value='" . $max . "' type='input' />");
    $grid->setRowCell($colName, "<input name='category_name' value='' type='input' />");
    $grid->setRowCell($colParent, "<input name='parent_name' value='' type='input' />");
    $grid->setRowCell($colSyn, "<input name='synonym_name' value='' type='input' />");
    $grid->setRowCell($colDel, '<a onclick="return onClickAjax_input(\'' . $NEW_VALUE_FORM . '\', \'' . $table_prefix . "virtuemart_category_links" . '\',\'' . "/components/com_import/make_input_request.php" . '\', \'' . $result_field . '\')"" href="">добавить</a>');
    echo "<form name='" . $NEW_VALUE_FORM . "' id='" . $NEW_VALUE_FORM . "'>";
    echo "<h4>Введите новое значение:</h4>";
    echo $grid->toString();
    echo "</form>";
    $options = array();
    $options["border"] = "1";
    $options["cellpadding"] = "7";
    $grid = new JGrid($options);
    $grid->addRow($options = array());
    $grid->addColumn($colNum);
    $grid->setRowCell($colNum, 'ID');
    $grid->addColumn($colName);
    $grid->setRowCell($colName, 'Наименование');
    $grid->addColumn($colParent);
    $grid->setRowCell($colParent, 'Родитель');
    $grid->addColumn($colSyn);
    $grid->setRowCell($colSyn, 'Синоним');
    $grid->addColumn($colDel);
    $grid->setRowCell($colDel, 'Удалить');
    $where = "parent_name IS NULL";
    $result = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'");
    $i = 1;
    if ($result['rows'] > 0) {
        foreach ($result["value"] as $row) {
            $grid->addRow($options = array());
            $grid->setRowCell($colNum, $row["category_links_ID"]);
            $grid->setRowCell($colName, $row["category_name"]);
            $grid->setRowCell($colParent, $row["parent_name"]);
            $grid->setRowCell($colSyn, $row["synonym_name"]);
            $grid->setRowCell($colDel, '');
            $where = "parent_name='" . $row['category_name'] . "'";
            $result_childs = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'");
            if ($result_childs['rows'] > 0) {
                foreach ($result_childs["value"] as $row_childs) {
                    $grid->addRow($options = array());
                    $grid->setRowCell($colNum, $row_childs["category_links_ID"]);
                    $grid->setRowCell($colName, $row_childs["category_name"]);
                    $grid->setRowCell($colParent, $row_childs["parent_name"]);
                    $grid->setRowCell($colSyn, $row_childs["synonym_name"]);
                    $query = "category_links_ID = " . $row_childs["category_links_ID"];
                    $grid->setRowCell($colDel, '<a onclick="return onClickAjax(' . "'" . $query . "'" . ', ' . "'" . "/components/com_import/delete_links.php" . "'" . ', ' . "'" . $result_field . "'" . ')"" href="">удалить</a>');
                }
            }
            $i++;
        }
    }
    echo "<h4>Текущая таблица:</h4>";
    echo $grid->toString();
}
function show_links()
{
    $options = array();
    $options["border"] = "1";
    $grid = new JGrid($options);
    $grid->addRow($options = array());
    $colNum = 'TitleNum';
    $grid->addColumn($colNum);
    $grid->setRowCell($colNum, 'ID');
    $colName = 'TitleName';
    $grid->addColumn($colName);
    $grid->setRowCell($colName, 'Наименование');
    $colParent = 'TitleParent';
    $grid->addColumn($colParent);
    $grid->setRowCell($colParent, 'Родитель');
    $colSyn = 'TitleSynonym';
    $grid->addColumn($colSyn);
    $grid->setRowCell($colSyn, 'Синоним');
    $colDel = 'Delete';
    $grid->addColumn($colDel);
    $grid->setRowCell($colDel, 'Удалить');
    //	$name = 'TitleDesc';
    //	$grid->addColumn($name);
    //	$grid->setRowCell($name, 'Описание');
    $db = new Dbprocess();
    $db->connectToDb();
    $table_prefix = $db->getTablePrefix();
    $where = "parent_name IS NULL";
    $result = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'");
    $i = 1;
    if ($result['rows'] > 0) {
        foreach ($result["value"] as $row) {
            $grid->addRow($options = array());
            $grid->setRowCell($colNum, $row["category_links_ID"]);
            $grid->setRowCell($colName, $row["category_name"]);
            $grid->setRowCell($colParent, $row["parent_name"]);
            $grid->setRowCell($colSyn, $row["synonym_name"]);
            $grid->setRowCell($colDel, '');
            $where = "parent_name='" . $row['category_name'] . "'";
            $result_childs = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'");
            if ($result_childs['rows'] > 0) {
                foreach ($result_childs["value"] as $row_childs) {
                    $grid->addRow($options = array());
                    $grid->setRowCell($colNum, $row_childs["category_links_ID"]);
                    $grid->setRowCell($colName, $row_childs["category_name"]);
                    $grid->setRowCell($colParent, $row_childs["parent_name"]);
                    $grid->setRowCell($colSyn, $row_childs["synonym_name"]);
                    $query = "DELETE FROM" . "" . "WHERE category_links_ID = " . $row_childs["category_links_ID"];
                    $grid->setRowCell($colDel, '<a onclick="return onClickAjax(' . "'" . $query . "'" . ', ' . "'" . "delete_link.php" . "'" . ', ' . "'" . $_GET['result'] . "'" . ')"" href="">удалить</a>');
                }
            }
            $i++;
        }
    }
    echo $grid->toString();
}
 * 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';
// Install plugins
// ========================================================================