Blame view

protected/controllers/JobsSectionController.php 2.11 KB
a1684257   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  <?php
  
  class JobsSectionController extends NodeSectionController
  {
      /** @var AboutRoot */
      public $_aboutRoot;
      /** @var JobsSection */
      public $section;
  
      public function init()
      {
          parent::init();
          /** @var $section JobsSection */
          $section = JobsSection::model()->with('i18n')->findByPk($this->getNode()->data_id);
          $this->headerGalleryId = $section->header_gallery_id;
          $this->section = $section;
      }
  
  
      public function actionJobs()
      {
          $section = $this->section;
  
          $this->pageName = $section->i18n->page_name;
          $this->setSEOParams($section->i18n->title, $section->i18n->keywords, $section->i18n->description);
  
          $this->setContacts(explode(',', $section->contacts_data));
          $this->setContacts(explode(',', $this->getAboutRoot()->contacts_data));
  
  
          $jobs = Job::model()->with('i18n')->findAll('not hidden and jobs_section_id = ' . $this->getNode()->data_id);
          $this->render('jobs', array(
              'content1' => $section->i18n->content1,
              'content2' => $section->i18n->content1,
              'jobs' => $jobs,
          ));
      }
  
      public function actionJob($link)
      {
          /** @var $job Job */
          $job = Job::model()->with('i18n')->findByAttributes(array(
              'link' => $link,
          ));
          if (!isset($job))
              throw new CHttpException(404);
  
          $this->pageName = $job->i18n->page_name;
          $this->setSEOParams($job->i18n->title, $job->i18n->keywords, $job->i18n->description);
  
          $this->setContacts(explode(',', $job->contacts_data));
          $this->setContacts(explode(',', $this->aboutRoot->contacts_data));
  
          $jobs = Job::model()->with('i18n')->findAll('jobs_section_id = ' . $this->getNode()->data_id);
          $this->render('job', array(
              'job' => $job,
              'jobs' => $jobs,
          ));
      }
  
  
      /**
       * @return AboutRoot|CActiveRecord
       */
      public function getAboutRoot()
      {
          if (!isset($this->_aboutRoot)) $this->_aboutRoot = AboutRoot::model()->findByPk($this->getRootNode()->data_id);
          return $this->_aboutRoot;
      }
  }