Пример #1
0
 public function executeShow(sfWebRequest $request)
 {
     $q = Doctrine_Query::create()->select('d.concept_name, um.*')->from('DomainModel d')->leftJoin('d.Concept um')->where('d.concept_slug = ?', $request->getParameter('concept_slug'))->andWhere('User.id = um.user_id')->andWhere('User.username = ?', $request->getParameter('username'))->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     $domain_model = $q->execute();
     $dumper = userModelDumperFactory::getDumperFor($request->getRequestFormat());
     $this->domain_dump = $dumper->dump($domain_model);
 }
Пример #2
0
 public function executeShow(sfWebRequest $request)
 {
     $this->cluster = $this->getRoute()->getObject();
     $this->forward404Unless($this->cluster);
     switch ($request->getRequestFormat()) {
         case 'yaml':
             $this->setLayout(false);
             $this->getResponse()->setContentType('text/yaml');
             break;
     }
 }
Пример #3
0
 public function executeList(sfWebRequest $request)
 {
     $this->jobs = array();
     foreach ($this->getRoute()->getObjects() as $job) {
         $this->jobs[$this->generateUrl('job_show_user', $job, true)] = $job->asArray($request->getHost());
     }
     switch ($request->getRequestFormat()) {
         case 'yaml':
             $this->setLayout(false);
             $this->getResponse()->setContentType('text/yaml');
             break;
     }
 }
Пример #4
0
 public function executeConvert(sfWebRequest $request)
 {
     // Check for additional get parameters
     if (count(array_diff(array_keys($request->getGetParameters()), sfConfig::get('app_convert_' . $request->getRequestFormat() . '_params')))) {
         return $this->setError(1200);
     }
     // Check for missing parameters
     if (!$request->hasParameter('amnt') || !$request->hasParameter('from') || !$request->hasParameter('to')) {
         return $this->setError(1100);
     }
     $currency = Doctrine::getTable('Currency');
     /* @var $currency Doctrine_Table */
     $this->from = $currency->findOneByCode($request->getParameter('from'));
     $this->to = $currency->findOneByCode($request->getParameter('to'));
     $this->amount = $request->getParameter('amnt');
     // Check for recognised currencies
     if (!$this->from instanceof Currency || !$this->to instanceof Currency) {
         return $this->setError(2000);
     }
     // Check the currencies are not the same
     if ($this->from == $this->to) {
         return $this->setError(1300);
     }
     // Check if amount contains >2 decimal digits.
     if (!is_numeric($this->amount) || strlen(substr(strrchr($this->amount, '.'), 1)) > sfConfig::get('app_convert_decimal_amount')) {
         return $this->setError(2100);
     }
     // Find cached currency rate
     $currency_rate = Doctrine::getTable('CurrencyRate')->getCurrencyRate($this->from, $this->to);
     /* @var $currency_rate CurrencyRate */
     // Check if currency rate needs updating
     if ($currency_rate->isNew() || $currency_rate->isOutdated()) {
         $currency_rate->setRate($this->getMoneyConverterRate());
         if (!$currency_rate->getRate()) {
             // Fallback functionality for rates not surved by themoneyconverter
             $currency_rate->setRate($this->getBloombergRate());
         }
         if ($currency_rate->getRate() > 0) {
             $currency_rate->setUpdatedAt(date('Y-m-d H:i:s'));
             $currency_rate->save();
         } else {
             return $this->setError(3200);
         }
     }
     // We want to be precise for currencies like ZWD where rates are often miniscule, but for other currencies 5 dp is fine
     $this->rate = $currency_rate->getRate() < 1.0E-5 ? number_format($currency_rate->getRate(), sfConfig::get('app_convert_decimal_stored')) : round($currency_rate->getRate(), sfConfig::get('app_convert_decimal_result'));
     $this->result = sprintf('%0.' . sfConfig::get('app_convert_decimal_result') . 'f', $this->amount * $this->rate);
     $this->at = $currency_rate->getDateTimeObject('updated_at')->format('d F Y H:i');
 }
Пример #5
0
 public function executeGenerateAuthToken(sfWebRequest $request)
 {
     $this->auth_token = new AuthToken();
     $this->auth_token->User = $this->getUser()->getGuardUser();
     $pathInfo = $request->getPathInfoArray();
     $this->auth_token->remote_address = $pathInfo['REMOTE_ADDR'];
     $this->auth_token->remote_port = $pathInfo['REMOTE_PORT'];
     $this->auth_token->save();
     $this->user_id = $this->getUser()->getGuardUser()->getId();
     $this->username = $this->getUser()->getGuardUser()->getUsername();
     switch ($request->getRequestFormat()) {
         case 'yaml':
             $this->setLayout(false);
             $this->getResponse()->setContentType('text/yaml');
             break;
     }
 }
Пример #6
0
 public function executeShow(sfWebRequest $request)
 {
     $tree = Doctrine::getTable('DomainModel')->findOneByConceptSlug($request->getParameter('concept_slug'));
     switch ($request->getRequestFormat()) {
         case 'xml':
             $dumper = new domainModelXMLDumper($tree);
             break;
         case 'html':
             $dumper = new domainModelHTMLDumper($tree);
             break;
         case 'json':
             $dumper = new domainModelJsonDumper($tree);
             break;
         case 'dot':
             $dumper = new domainModelGraphvizDumper($tree);
             break;
         default:
             return sfView::NONE;
     }
     $this->domain_dump = $dumper->dump();
     $this->setTemplate('index');
 }