Пример #1
0
 protected function addDateQuery(Doctrine_Query $query, $field, $values)
 {
     if (is_array($values)) {
         parent::addDateQuery($query, $field, $values);
     } else {
         $fieldName = $this->getFieldName($field);
         switch ($values) {
             case null:
             case '':
                 break;
             case 'today':
                 $query->andWhere(sprintf('%s.%s >= ?', $this->getRootAlias($query, $fieldName), $fieldName), date('Y-m-d H:i:s', strtotime('-1 day')));
                 break;
             case 'week':
                 $query->andWhere(sprintf('%s.%s >= ?', $this->getRootAlias($query, $fieldName), $fieldName), date('Y-m-d H:i:s', strtotime('-1 week')));
                 break;
             case 'month':
                 $query->andWhere(sprintf('%s.%s >= ?', $this->getRootAlias($query, $fieldName), $fieldName), date('Y-m-d H:i:s', strtotime('-1 month')));
                 break;
             case 'year':
                 $query->andWhere(sprintf('%s.%s >= ?', $this->getRootAlias($query, $fieldName), $fieldName), date('Y-m-d H:i:s', strtotime('-1 year')));
                 break;
         }
     }
 }
 public function setup()
 {
     $this->widgetSchema['search'] = new sfWidgetFormInputText();
     $this->validatorSchema['search'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setHelp('search', 'Enter keywords to search by. Wildcards (*) are supported.');
     $this->widgetSchema->setNameFormat('search[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     $this->setupInheritance();
     parent::setup();
 }
 /**
  * Override sfFormDoctrine to prepare the
  * values: FORMNAME|FIELDNAME has to be transformed
  * to FORMNAME[FIELDNAME]
  */
 public function updateObject($values = null)
 {
     if (is_null($values)) {
         $values = $this->values;
         foreach ($this->embeddedForms as $name => $form) {
             foreach ($form as $field => $f) {
                 if (isset($values["{$name}|{$field}"])) {
                     // Re-rename the form field and remove
                     // the original field
                     $values[$name][$field] = $values["{$name}|{$field}"];
                     unset($values["{$name}|{$field}"]);
                 }
             }
         }
     }
     // Give the request to the original method
     parent::updateObject($values);
 }
 public function setup()
 {
     $this->setupNestedSet();
     parent::setup();
 }
 public function getJavascripts()
 {
     $javascripts = parent::getJavascripts();
     $javascripts[] = '/js/searchForm.js';
     return $javascripts;
 }