Example #1
0
 /**
  * Список категорий (главная страница)
  * @return void
  */
 public function indexAction()
 {
     if ($this->_authorize('category', 'view')) {
         $objCategories = new Categories();
         $arrCategory = $objCategories->getCategoryList();
         $this->view->arrCategory = $arrCategory;
     }
 }
Example #2
0
				<?php 
}
?>
		
			</div>
			
			<div class="box2">
				<div class="title">
					<h2>Product Categories</h2>
				</div>
				<ul class="style2">
	
				<?php 
$cart = new Categories();
$cart->setCategories();
$categories = $cart->getCategoryList();
if (count($categories) > 0) {
}
?>
						<?php 
foreach ($categories as $ID => $Info) {
    ?>
							<?php 
    echo "<li><a href='" . $config_basedir . "products.php?id=" . $Info['id'] . "' class='icon icon-ok button'>" . $Info['name'] . "</a></li>";
    ?>
						<?php 
}
?>
				</ul>
			</div>
			
Example #3
0
 /**
  * Добавление/обновление теста
  * @return void
  */
 public function editAction()
 {
     if ($this->_authorize('test', 'edit')) {
         $objForm = new Form_Test_Edit();
         $objCategories = new Categories();
         $arrCategory = $objCategories->getCategoryList();
         $objForm->setSelectOptions($arrCategory);
         if ($this->getRequest()->isPost()) {
             if ($objForm->isValid($_POST)) {
                 // Выполняем update (insert/update данных о категории)
                 $objTests = new Tests();
                 $testId = $objForm->testId->getValue();
                 if (!empty($testId)) {
                     $objTest = $objTests->getTestById($testId);
                 } else {
                     $testId = null;
                     $objTest = $objTests->createRow();
                 }
                 $testName = $objForm->testName->getValue();
                 $objTest->setName($testName);
                 $objTest->setCategoryId($objForm->categoryId->getValue());
                 $objTest->setTime($objForm->testTime->getValue());
                 $objTest->setQuestionAmount((int) $objForm->testQuestionAmount->getValue());
                 $objTest->save();
                 if ('questionAdd' == $objForm->formAction->getValue()) {
                     if (!$testId) {
                         $testId = $objTests->getAdapter()->lastInsertId();
                     }
                     $this->_helper->redirector('edit', 'question', null, array('testId' => $testId));
                 } else {
                     $this->_helper->redirector('index', 'test');
                 }
             } else {
                 $testId = $this->getRequest()->getParam('testId');
                 if ($testId != '') {
                     // выбираем из базы данные о редактируемом тесте
                     $objTests = new Tests();
                     $objTest = $objTests->getTestById($testId);
                     if ($objTest) {
                         $arrQuestion = $objTests->getQuestionListByTestId($testId);
                         $arrQuestionCategories = $objTests->getQuestionCategoriesListByTestId($testId);
                         $this->view->arrQuestion = $arrQuestion;
                         $this->view->arrQuestionCategories = $arrQuestionCategories;
                         //                            $this -> view -> testId = $testId;
                     }
                 }
             }
         } else {
             $testId = $this->getRequest()->getParam('testId');
             if ($testId != '') {
                 // выбираем из базы данные о редактируемом тесте
                 $objTests = new Tests();
                 $objTest = $objTests->getTestById($testId);
                 if ($objTest) {
                     $arrQuestion = $objTests->getQuestionListByTestId($testId);
                     $arrQuestionCategories = $objTests->getQuestionCategoriesListByTestId($testId);
                     $this->view->arrQuestion = $arrQuestion;
                     $this->view->arrQuestionCategories = $arrQuestionCategories;
                     $this->view->testId = $testId;
                     $objForm->populate(array('testName' => $objTest->t_name, 'categoryId' => $objTest->cat_id, 'testTime' => $objTest->time, 'testQuestionAmount' => sizeof($arrQuestion), 'testId' => $objTest->t_id));
                 }
             }
         }
         $this->view->objForm = $objForm;
     }
 }