Пример #1
0
<?php

/**
 * @author Denny
 * @copyright 2015
 */
ini_set('display_errors', 'On');
// настраиваем базу
define('MP', true);
define('SERVER_PATH', $_SERVER['DOCUMENT_ROOT'] . '/');
include_once 'db.php';
$db = new DB('localhost', 'tree_u', 'R2vPL51e', 'tree_db');
include_once 'controller/TreeController.php';
$Tree = new TreeController($db);
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'load_items':
            return $Tree->loadItems($_POST['type_id'], $_POST['item_id']);
            break;
    }
}
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Тестовое задание</title>
        <link rel="shortcut icon" href="view/image/icon.gif" type="image/x-icon" />
        <link href="view/site.css" rel="stylesheet">
        <script src="view/jquery.min.js"></script>
Пример #2
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     Yii::import('application.controllers.back.TreeController');
     $id = !isset($_GET['tr_id']) ? 0 : intval($_GET['tr_id']);
     $dataProvider = new CActiveDataProvider('Article', array('criteria' => array('condition' => 'tree_id=' . $id)));
     $trees = Tree::model()->buildTreeArray(Tree::model()->findAll(array('order' => 'parent_id ASC')));
     $this->render('index', array('dataProvider' => $dataProvider, 'trees' => TreeController::createTreeView($trees, 0)));
 }