Example #1
0
 public function getDepartment($pathToProduct)
 {
     for ($i = count($pathToProduct) - 1; $i >= 0; $i--) {
         $product = $pathToProduct[$i];
         if (intval($product['departmentId']) != 0) {
             return DepartmentModel::getInstance()->getDepartmentById($product['departmentId']);
         }
     }
     return null;
 }
 public function show($laboratoryUrl)
 {
     $currentLaboratory = DepartmentModel::getInstance()->getBaseLaboratoryByUrl($laboratoryUrl);
     if (empty($currentLaboratory)) {
         $this->redirect('404');
     }
     $products = ProductModel::getInstance()->getByDepartmentId($currentLaboratory['id']);
     $this->setViewVariable('currentLaboratory', $currentLaboratory);
     $this->setViewVariable('products', $products);
     $this->render();
 }
Example #3
0
 public function index()
 {
     // получение всех научных центров(department)
     // получение всех подлабораторий
     $childDepartments = DepartmentModel::getInstance()->getMainDepartments();
     DepartmentModel::getInstance()->calculateChildrenFullUrl(null, $childDepartments);
     if (!empty($childDepartments)) {
         for ($i = 0; $i < count($childDepartments); $i++) {
             $children = DepartmentModel::getInstance()->getDepartmentChildren($childDepartments[$i]['id']);
             if (!empty($children)) {
                 $childDepartments[$i]['children'] = $children;
                 DepartmentModel::getInstance()->calculateChildrenFullUrl($childDepartments[$i], $childDepartments[$i]['children']);
             }
         }
     }
     $this->setViewVariable('departmentList', $childDepartments);
     //----------------------------------------------------------------------------------------
     // получение всех независимых лабораторий
     $this->setViewVariable('baseLaboratories', DepartmentModel::getInstance()->getBaseLaboratories());
     $this->render(['layout' => 'index']);
 }
 public function show($departmentUrlList)
 {
     $currentDepartment = null;
     if (empty($departmentUrlList)) {
         $currentDepartmentId = 0;
     } else {
         $departmentUrl = $departmentUrlList[count($departmentUrlList) - 1];
         $currentDepartment = DepartmentModel::getInstance()->getDepartmentByUrl($departmentUrl);
         if (empty($currentDepartment)) {
             $this->redirect('404');
         }
         $currentDepartmentId = $currentDepartment['id'];
     }
     if (!empty($currentDepartment)) {
         $pathToDepartment = DepartmentModel::getInstance()->getPathToDepartment($currentDepartment);
         DepartmentModel::getInstance()->calculateFullPathUrl($pathToDepartment);
         $products = ProductModel::getInstance()->getByDepartmentId($currentDepartment['id']);
     } else {
         $pathToDepartment = [DepartmentModel::getInstance()->gerRootDepartment()];
     }
     $childDepartments = DepartmentModel::getInstance()->getDepartmentChildren($currentDepartmentId);
     DepartmentModel::getInstance()->calculateChildrenFullUrl($currentDepartment, $childDepartments);
     if (!empty($childDepartments)) {
         for ($i = 0; $i < count($childDepartments); $i++) {
             $children = DepartmentModel::getInstance()->getDepartmentChildren($childDepartments[$i]['id']);
             if (!empty($children)) {
                 $childDepartments[$i]['children'] = $children;
                 DepartmentModel::getInstance()->calculateChildrenFullUrl($childDepartments[$i], $childDepartments[$i]['children']);
             }
         }
     }
     $this->setViewVariable('currentDepartment', $currentDepartment);
     $this->setViewVariable('pathToDepartment', $pathToDepartment);
     $this->setViewVariable('departmentList', $childDepartments);
     $this->setViewVariable('products', isset($products) ? $products : []);
     $this->render();
 }
Example #5
0
    <div class="container">
        <div class="progress progress-striped active" style="margin-bottom: 0">
            <div class="progress-bar progress-bar-success" style="width: 100%"></div>
        </div>
        <div class="row">
            <div class="col-md-4">
                <h3><?php 
echo $ph->lang->Label_Departments;
?>
</h3>
                <p>
                    <?php 
// чтобы не создавать отдельные контроллеры для статических страниц, где будут получаться департаменты,
// будем проверять здесь их наличие. Если их нет - тянем из базы
if (empty($mainDepartments)) {
    $mainDepartments = DepartmentModel::getInstance()->getMainDepartments();
}
foreach ($mainDepartments as $mainDepartment) {
    $ph->link($ph->localisedField($mainDepartment, 'name'), "/department/{$mainDepartment['url']}")->single_tag('br');
}
?>
                </p>
            </div>
            <div class="col-md-2">
                <h3> <?php 
echo $ph->lang->Label_News;
?>
 </li></h3>
                <p>
                    <?php 
$ph->link('Мобильная версия сайта', '/news');