Пример #1
0
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();
}
 /**
  * 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;
 }
Пример #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();
}