public function indexAction(Request $request)
 {
     $session = $request->getSession();
     //get the login error if there is one
     if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
         $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
     } elseif (null !== $session && $session->has(SecurityContext::AUTHENTICATION_ERROR)) {
         $error = $session->get(SecurityContext::AUTHENTICATION_ERROR)->getMessage();
         $session->remove(SecurityContext::AUTHENTICATION_ERROR);
     } else {
         $error = '';
     }
     //last username entered by the user
     $lastUsername = null === $session ? '' : $session->get(SecurityContext::LAST_USERNAME);
     $parameters = array('last_username' => $lastUsername, 'error' => $error);
     $parameters['page'] = $this->get('renovate.pages')->getPageForUrl($this->getRequest()->getUri());
     $em = $this->getDoctrine()->getManager();
     $parameters['lastNews'] = News::getNews($em, array('offset' => 0, 'limit' => 3));
     $parameters['lastNews1'] = News::getNews($em, array('offset' => 3, 'limit' => 3));
     $jobs = Job::getJobs($em, array('onhomepage' => 1));
     foreach ($jobs as $job) {
         $job->setDescription(strip_tags($job->getDescription()));
         $job->setShortDescription(strip_tags($job->getShortDescription()));
     }
     $parameters['jobs'] = $jobs;
     $parameters['results'] = Result::getResults($em, array('onhomepage' => 1));
     $parameters['news'] = News::getNews($em, array('onhomepage' => 1));
     $parameters['articles'] = Article::getArticles($em, array('onhomepage' => 1));
     $parameters['shares'] = Share::getShares($em, array('onhomepage' => 1));
     $parameters['vacancies'] = Vacancy::getVacancies($em, array('onhomepage' => 1));
     $parameters['results'] = $this->getDoctrine()->getRepository('RenovateMainBundle:Result')->findBy(array('onhomepage' => true));
     return $this->render('RenovateMainBundle:Index:index.html.twig', $parameters);
 }
 public function editJobNgAction($job_id)
 {
     $em = $this->getDoctrine()->getManager();
     $data = json_decode(file_get_contents("php://input"));
     $parameters = (object) $data;
     $transliterater = $this->get('renovate.transliterater');
     $job = Job::editJobById($em, $transliterater, $job_id, $parameters);
     $response = new Response(json_encode(array("result" => $job->getInArray())));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 public function indexAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $parameters = array();
     if ($request->isMethod('POST')) {
         if ($request->request->get('search')) {
             $articles = Article::searchArticles($em, $request->request->get('search'));
             $parameters['articles'] = $articles;
             $jobs = Job::searchJobs($em, $request->request->get('search'));
             $parameters['jobs'] = $jobs;
             $news = News::searchNews($em, $request->request->get('search'));
             $parameters['news'] = $news;
             $results = Result::searchResults($em, $request->request->get('search'));
             $parameters['results'] = $results;
             $shares = Share::searchShares($em, $request->request->get('search'));
             $parameters['shares'] = $shares;
             $vacancies = Vacancy::searchVacancies($em, $request->request->get('search'));
             $parameters['vacancies'] = $vacancies;
         }
         $parameters['search'] = $request->request->get('search');
     }
     return $this->render('RenovateMainBundle:Search:index.html.twig', $parameters);
 }
Example #4
0
 public static function addJob($em, $transliterater, $parameters)
 {
     $document = $em->getRepository("RenovateMainBundle:Document")->find($parameters->documentid);
     $job = new Job();
     $job->setName($parameters->name);
     $job->setNameTranslit($transliterater->transliterate($parameters->name));
     $job->setDocumentid($parameters->documentid);
     $job->setDocument($document);
     if (isset($parameters->labelid) && $parameters->labelid != NULL) {
         $label = $em->getRepository("RenovateMainBundle:Document")->find($parameters->labelid);
         $job->setLabelid($parameters->labelid);
         $job->setLabel($label);
     }
     $job->setDescription($parameters->description);
     $job->setCreated(new \DateTime());
     $job->setOnhomepage($parameters->onhomepage);
     $em->persist($job);
     $em->flush();
     return $job;
 }