public function contact() { $this->setPageTitle('Контактная информация'); $content = $this->_getContent(Model_Info::CONTENT_CONTACT); $text = isset($content[0]) ? $content[0] : ''; $this->view->set('content', $text); $error = false; $postRawData = $this->input->post(); if ($postRawData) { if ($postRawData['email'] or $postRawData['text']) { $message = view::factory('layout/email', array('email' => $postRawData['email'], 'text' => $postRawData['text'])); $avalibleEmails = array('*****@*****.**', '*****@*****.**', '*****@*****.**'); $subject = 'contact from Brusnichka'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf8' . "\r\n"; foreach ($avalibleEmails as $to) { if (mail($to, $subject, $message, $headers)) { $error = 'Успешно отправлено'; } } } else { $error = 'Заполните форму'; } } $this->view->set('status', $error); $this->view->set('sections', Model_Section::instance()->getAll()); }
public function getRouteArray($inputUrlRaw) { $config = array(); $inputUrl = rawurldecode(str_replace('_', ' ', $inputUrlRaw)); $arrayUrl = explode('/', $inputUrl, 2); if ($project = Model_Project::instance()->getBy('title', $arrayUrl[0])) { $config[] = array('/^(' . $project[0]['title'] . ')(.*)/iu', 'index/project/$1$2'); } elseif ($section = Model_Section::instance()->getBy('title', $arrayUrl[0])) { $config[] = array('/^(' . $section[0]['title'] . ')(.*)/iu', 'index/section/$1$2'); } //echo '1'; exit(); $pattern = array(); $replacement = array(); foreach ($config as $regexpArr) { $pattern[] = $regexpArr[0]; $replacement[] = $regexpArr[1]; } $url = preg_replace($pattern, $replacement, $inputUrl); $arrayUrl = explode('/', $url); if (isset($arrayUrl[0]) and $arrayUrl[0]) { $this->_route['controller'] = strtolower($arrayUrl[0]); } if (isset($arrayUrl[1]) and $arrayUrl[1]) { $this->_route['action'] = strtolower($arrayUrl[1]); } if (isset($arrayUrl[2]) and $arrayUrl[2]) { $this->_route['param1'] = $arrayUrl[2]; } if (isset($arrayUrl[3]) and $arrayUrl[3]) { $this->_route['param2'] = $arrayUrl[3]; } return $this->_route; }
/** * Singleton pattern */ static function instance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
private function _getModelByType($type) { switch ($type) { case self::TYPE_SAMPLE: $model = Model_Sample::instance(); break; case self::TYPE_SECTION: $model = Model_Section::instance(); break; case self::TYPE_PROJECT: $model = Model_Project::instance(); break; case self::TYPE_STATIC: $model = Model_Info::instance(); break; default: $model = false; } return $model; }
public function project($projectC, $sample_id = '') { $projectCurr = Model_Project::instance()->getAll(array('LEFT JOIN sections ON (projects.section_id = sections.id)', 'where' => 'projects.title ="' . $projectC . '" AND sections.status=' . Model_Section::STATUS_ON)); if (!isset($projectCurr[0])) { throw new AbstractException('Project‚ ' . $projectC . ' is not found'); } $projectC = $projectCurr[0]['title']; $sectionCurr = array('section_id' => $projectCurr[0]['section_id'], 'title' => $projectCurr[0]['section_title']); $projects = Model_Project::instance()->getAll(array('where' => 'sections.id =' . $sectionCurr['section_id'])); foreach ($projects as $project) { if ($project['title'] == $projectC) { $projectCurr = $project; } } $conditions = array('where' => 'project_id = ' . $projectCurr['id'], 'orderby' => 'id DESC'); if ($sample_id) { //$conditions['orderby']="FIELD(samples.id,".$sample_id.") desc"; } $samples = Model_Sample::instance()->getAll($conditions); if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { echo View::factory('element/project', array('samples' => $samples, 'sample_id' => $sample_id, 'projectCurr' => $projectCurr)); exit; } if (Helper_Js::isEnabledJs()) { header('Location: ' . Helper_Html::link(array('controller' => 'index', 'action' => 'section', 'param1' => $sectionCurr['title'], '#' => '/' . $projectC . '/' . $sample_id))); } $samplesCountMod = $this->_getSamplesCount($sectionCurr['section_id']); foreach ($projects as $projectKey => $project) { $projects[$projectKey]['count'] = isset($samplesCountMod[$project['id']]) ? $samplesCountMod[$project['id']] : '0'; } $pagination = array('prev' => Model_Project::instance()->getPagin($projectCurr['id'], $projectCurr['section_id'], 'prev'), 'next' => Model_Project::instance()->getPagin($projectCurr['id'], $projectCurr['section_id'], 'next')); $this->view->set('pagination', $pagination); //return View::factory('element/project',array('samples'=>$samples,'sample_id'=>$sample_id)); $this->view->setPageDescription($projectCurr['text']); $this->view->setPageTitle($sectionCurr['title'] . ' - ' . $projectCurr['title']); $this->view->set('sections', Model_Section::instance()->getAll()); $sapmlesCurrentArrayId = 0; if ($sample_id) { foreach ($samples as $arrayKey => $sample) { if ($sample['id'] == $sample_id) { $sapmlesCurrentArrayId = $arrayKey; } } } $this->view->set('sapmlesCurrentArrayId', $sapmlesCurrentArrayId); $this->view->set('samples', $samples); // $this->view->set('sectionCurr', $sectionCurr); $this->view->set('projectCurr', $projectCurr); // $this->view->set('projects', $projects); // }
/** * Отображение доступных учебных материалов. */ public function action_show(array $params = array()) { $a = Model_Test::create(); $a->test(); $links = Resources::getInstance()->links; if (!isset($params['discipline_id']) || is_int($params['discipline_id'])) { $this->flash('Не указан идентификатор дисциплины', $links->get('student.programs')); } $discipline_id = intval($params['discipline_id']); $user = Model_User::create(); $udata = (object) $user->getAuth(); $session = Resources_Abstract::getInstance()->session; // если данных о доступных дисциплинах нет - вычислить if (!isset($session->availDisciplines)) { $student = Model_Education_Students::create(); $avail_programs = $student->getAvailDisciplinesForPrograms($udata->user_id); $avail_disciplines = $student->getAvailDisciplinesSeparate($udata->user_id); } $discipline_open = in_array($discipline_id, $session->availDisciplines); if ($discipline_open) { // дисциплина доступна $disc = Model_Discipline::create(); $discipline_data = $disc->get($discipline_id); $section = Model_Section::create(); $sections = $section->getAllByDiscipline($discipline_id); $modelApps = Model_Application::create(); $statuses = $modelApps->getAppsStatus($discipline_id, $udata->user_id); //== Model_Application::STATUS_FINISHED; $statusFinished = array_key_exists(Model_Application::STATUS_FINISHED, $statuses); $material = Model_Educational_Materials::create(); $materials = $material->getAllByDiscipline($discipline_id, $statusFinished); $control_work = Model_ControlWork::create(); $tests = $control_work->getTestsByDiscipline($discipline_id); $this->set('discipline', $discipline_data); $this->set('sections', $sections); $this->set('materials', $materials); $this->set('tests', $tests); $this->set('user_id', $udata->user_id); //print_r($materials); $this->render(); } else { $this->flash('Данная дисциплина на данный Вам недоступна. Возможно Вы не полностью оплатили заявку по данной дисциплине или программе, содержащей данную дисциплину, либо вообще не подавали заявку на ее изучение.', $links->get('student.programs'), 5); } }