Example #1
0
    function displayBody()
    {
        parent::displayBody();
        $translator = new Translator();
        $course = new Course();
        $page = $_GET['page'];
        $offset = intval($page) * ITEMS_IN_PAGE;
        if (isset($_GET['search'])) {
            $search = $_GET['search'];
            unset($_GET['search']);
            unset($_GET['page']);
        } else {
            $search = null;
        }
        $cnt = $course->getCount(array('search' => $search));
        if ($cnt > ITEMS_IN_PAGE) {
            $pagination = $this->addPaginator($cnt, $page);
        }
        echo <<<EOF
<div class="container-fluid">
<div class="col-md-10 col-lg-8 col-lg-offset-2 ">
\t<h4 class="page-header">{$translator->Search_result}: <span class="badge">{$cnt}</span></h4>
\t{$pagination}
EOF;
        $enum = $course->enumerate(array('search' => $search), $offset, ITEMS_IN_PAGE);
        if (isset($enum)) {
            foreach ($enum as $data) {
                echo <<<EOF
\t\t<h4>{$data[name]}</h4>
\t\t<h6>{$data[category_name]}</h6>
\t\t<p>{$data[describe]}</p>
\t\t<p><a href="/course/{$data[id]}">{$translator->Go_to}...</a></p>
EOF;
            }
        } else {
            $search = htmlspecialchars($search);
            echo <<<EOF
\t\t<h4>{$translator->no_results} по "{$search}"</h4>\t\t
EOF;
        }
        echo <<<EOF
\t{$pagination}
\t</div>
</div> <!-- /container -->

EOF;
    }
Example #2
0
    function displayBody()
    {
        parent::displayBody();
        $translator = new Translator();
        $category = new Category();
        $course = new Course();
        $cnt = $course->getCount();
        $enum = $category->enumerate(array('active' => true));
        foreach ($enum as $key => $val) {
            if ($val['id'] != 0) {
                $this->items[$val['parent_id']][] = $val;
            }
        }
        foreach ($this->items as $key => $val) {
            asort($this->items[$key]);
        }
        $enum = $course->enumerate(array('active' => true));
        if (isset($enum)) {
            foreach ($enum as $key => $val) {
                $this->courses[$val['category_id']][] = $val;
            }
        }
        foreach ($this->items as $key => $val) {
            asort($this->items[$key]);
        }
        echo <<<EOF
<h2  class="page-header">{$translator->Courses_header} <span class="badge">{$cnt}</span></h2>
<div class="col-lg-8">
    <ul class="list-group category-list" index="0">

EOF;
        $this->put_list();
        echo <<<EOF
    </ul>
</div>

EOF;
    }
Example #3
0
 function init()
 {
     $this->func = array_shift($this->param);
     switch ($this->func) {
         case 'courses':
             $category_id = array_shift($this->param);
             $course = new Course();
             $data = $course->enumerate(array('category_id' => $category_id), null, null, 'name');
             foreach ($data as $key => $val) {
                 $items[] = array($val['id'], $val['name']);
             }
             echo json_encode($items);
             exit;
             break;
         case 'finduser':
             $id = array_shift($this->param);
             $search = $_GET['search'];
             $user = new User();
             try {
                 foreach ($user->find($search, 5) as $data) {
                     $json[] = array('id' => $data['id'], 'name' => $data['name'], 'email' => $data['email'], 'company' => $data['company'], 'city' => $data['city']);
                 }
                 echo json_encode($json);
             } catch (Exception $e) {
             }
             exit;
             break;
         case 'adduser':
             $plan_id = array_shift($this->param);
             $user_id = array_shift($this->param);
             $user = new User();
             try {
                 $data = $user->get(array('id' => $user_id));
                 $plan = new Plan();
                 $plan->adduser($plan_id, $user_id);
                 $json = array('id' => $data['id'], 'name' => $data['name'], 'email' => $data['email'], 'company' => $data['company'], 'city' => $data['city']);
                 echo json_encode($json);
             } catch (Exception $e) {
                 echo $e;
             }
             exit;
             break;
         case 'removeuser':
             $plan_id = array_shift($this->param);
             $user_id = array_shift($this->param);
             $training = new Training();
             $t_data = $training->get(array('plan_id' => $plan_id, 'user_id' => $user_id));
             $training->delete($t_data['id']);
             try {
                 echo json_encode('');
             } catch (Exception $e) {
                 echo $e;
             }
             exit;
             break;
     }
 }