예제 #1
0
파일: poll.php 프로젝트: vosaan/ankor.local
 /**
  * @see parent::setPost()
  */
 public function setPost(array $data)
 {
     parent::setPost($data);
     if (isset($data['answer']) && is_array($data['answer'])) {
         $this->setAnswers($data['answer']);
     }
 }
예제 #2
0
 /**
  * @see parent::setPost()
  */
 public function setPost(array $data)
 {
     parent::setPost($data);
     if (isset($data['Project']) && is_array($data['Project'])) {
         $this->Projects = array();
         foreach ($data['Project']['Name'] as $i => $value) {
             if (!$value) {
                 continue;
             }
             $this->Projects[] = new Client_Project($data['Project']['Name'][$i], $data['Project']['URL'][$i]);
         }
     }
 }
예제 #3
0
 protected function initForm(Object $Object, $method = 'edit')
 {
     $error = array();
     if (isset($_POST['submit'])) {
         $Object->setPost($_POST);
         $fields = Locale::translate(Error::test($Object));
         if (count($fields)) {
             $error[] = 'Неверно заполнены поля: ' . implode(', ', Locale::translate($fields));
         } else {
             if ($Object->save()) {
                 return $this->haltForm($Object, $method);
             } else {
                 $error[] = 'Ошибка базы данных: ' . $Object->getError();
             }
         }
     }
     $name = $this->getAliasName($method) ? $this->getAliasName($method) : $this->getModelName($method);
     $Document = new Document();
     $this->getView()->set('Documents', $Document->findList(array(), 'Position asc'));
     $this->getView()->set($name, $Object);
     $this->getView()->set('Error', $error);
     return $this->getView()->render();
 }
예제 #4
0
 /**
  * @see parent::setPost()
  */
 public function setPost(array $data = array())
 {
     parent::setPost($data);
     if (isset($data['Address']) && is_array($data['Address'])) {
         $this->setAddress($data['Address']);
     }
     $this->Pickup = empty($data['Pickup']) ? 0 : 1;
     if ($this->Type != self::STANDARD) {
         $Custom = new Order_Custom();
         $Custom->set($data);
         $this->CustomData = $Custom;
     }
 }
예제 #5
0
 /**
  * @see parent::setPost()
  */
 public function setPost(array $data = array())
 {
     parent::setPost($data);
     if (isset($data['Unit'])) {
         $this->Units = $this->UnitsDelete = array();
         foreach ($data['Unit']['Name'] as $id => $value) {
             $arr = array();
             foreach (array_keys($data['Unit']) as $key) {
                 if (isset($data['Unit'][$key][$id])) {
                     if ($key == 'Delete') {
                         $this->UnitsDelete[] = $data['Unit'][$key][$id];
                     } else {
                         $arr[$key] = $data['Unit'][$key][$id];
                     }
                 }
             }
             $this->Units[] = $arr;
         }
     }
     if (isset($data['Model'])) {
         $this->Models = $this->ModelsDelete = array();
         foreach ($data['Model']['Name'] as $id => $value) {
             $arr = array();
             foreach (array_keys($data['Model']) as $key) {
                 if (isset($data['Model'][$key][$id])) {
                     if ($key == 'Delete') {
                         $this->ModelsDelete[] = $data['Model'][$key][$id];
                     } else {
                         $arr[$key] = $data['Model'][$key][$id];
                     }
                 }
             }
             $this->Models[] = $arr;
         }
     }
     if (isset($data['Design']) && isset($data['Design']['Name'])) {
         $this->Design = array();
         foreach ($data['Design']['Name'] as $id => $value) {
             if (!$value) {
                 continue;
             }
             $arr = array();
             foreach (array_keys($data['Design']) as $key) {
                 $arr[$key] = isset($data['Design'][$key][$id]) ? $data['Design'][$key][$id] : null;
             }
             $this->Design[] = $arr;
         }
     }
     if (isset($data['Frame']) && isset($data['Frame']['Name'])) {
         $this->Frame = array();
         foreach ($data['Frame']['Name'] as $id => $value) {
             if (!$value) {
                 continue;
             }
             $arr = array();
             foreach (array_keys($data['Frame']) as $key) {
                 $arr[$key] = isset($data['Frame'][$key][$id]) ? $data['Frame'][$key][$id] : null;
             }
             $this->Frame[] = $arr;
         }
     }
     $this->IsOwn = empty($data['IsOwn']) ? 0 : 1;
 }
예제 #6
0
 /**
  * The function shows edit form and saves data on submit.
  * 
  * @access protected
  * @param object $Object The object.
  * @return string The HTML code.
  */
 protected function initForm(Object $Object, $method = 'edit')
 {
     $error = array();
     if (isset($_POST['submit'])) {
         $Object->setPost($_POST);
         //$fields = Locale::translate( Error::test( $Object ) );
         if (count($fields)) {
             $error[] = 'Неверно заполнены поля: ' . implode(', ', Locale::translate($fields));
         } else {
             if ($Object->save()) {
                 if (!empty($_FILES['file']['tmp_name'])) {
                     if (File::upload($Object, $_FILES['file'])) {
                         $Object->save();
                     } else {
                         if ($this->dropOnFailedUpload($Object)) {
                             $Object->drop();
                         }
                     }
                 }
                 if (!empty($_POST['detach'])) {
                     if (File::detach($Object)) {
                         $Object->save();
                     }
                 }
                 return $this->haltForm($Object, $method);
             } else {
                 $error[] = 'Ошибка базы данных: ' . $Object->getError();
             }
         }
     }
     $name = $this->getAliasName($method) ? $this->getAliasName($method) : $this->getModelName($method);
     $this->getView()->set($name, $Object);
     $this->getView()->set('Error', $error);
     return $this->getView()->render();
 }
예제 #7
0
 /**
  * @see parent::setPost()
  */
 public function setPost(array $data = array())
 {
     parent::setPost($data);
     if (isset($data['PostedAt'])) {
         $this->PostedAt = strtotime($data['PostedAt']);
     }
     $this->HasVideo = empty($data['HasVideo']) ? 0 : 1;
     if (isset($data['Tags'])) {
         $this->tags = $data['Tags'];
     }
 }
예제 #8
0
 public function setPost(array $data = array())
 {
     parent::setPost($data);
     if (!empty($data['clear_documents'])) {
         $this->Documents = '';
     }
     if (isset($data['document']) && is_array($data['document'])) {
         $this->Documents = implode(':', $data['document']);
     }
 }