Exemple #1
0
 /**
  * The upload form handler.
  * 
  * @access public
  * @param int $id The Gallery id.
  * @return string The HTML code.
  */
 public function upload($id = null)
 {
     $error = array();
     $Gallery = new Gallery();
     $Gallery = $Gallery->findItem(array('Id = ' . $id));
     if (!$Gallery->Id) {
         return $this->halt();
     }
     if (isset($_POST['submit'])) {
         if (isset($_FILES['file'])) {
             foreach ($_FILES['file']['name'] as $id => $value) {
                 $file = array('name' => $_FILES['file']['name'][$id], 'type' => $_FILES['file']['type'][$id], 'tmp_name' => $_FILES['file']['tmp_name'][$id], 'error' => $_FILES['file']['error'][$id], 'size' => $_FILES['file']['size'][$id]);
                 $Item = new Gallery_Item();
                 $Item->GalleryId = $Gallery->Id;
                 if ($Item->save()) {
                     if (File::upload($Item, $file)) {
                         $Item->save();
                     }
                 }
             }
         }
         return $this->halt('items/' . $Gallery->Id);
     }
     $this->getView()->set('Gallery', $Gallery);
     $this->getView()->set('Error', $error);
     return $this->getView()->render();
 }