当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::insert方法代码示例

本文整理汇总了PHP中Image::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::insert方法的具体用法?PHP Image::insert怎么用?PHP Image::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 public function store()
 {
     Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
     TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
     $input = Input::all();
     for ($i = 0; $i < count($input); $i++) {
         if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
             if (Input::get("link{$i}") != "") {
                 Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
             }
         }
     }
     if (Input::hasFile('photo')) {
         $count = Image::where('email', Auth::user()->email)->count();
         if ($count >= 4) {
             echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
             return Redirect::back();
         }
         $extension = Input::file('photo')->getClientOriginalExtension();
         if ($extension == "gif" || $extension == "jpeg") {
             Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
         } else {
             echo "CAN ONLY DO GIF OR JPEG";
         }
     }
     $imageCount = Image::where('email', Auth::user()->email)->count();
     for ($i = 0; $i < $imageCount - 1; $i++) {
         if (Input::get("delete{$i}") != null) {
             $imageTable = Image::where('email', Auth::user()->email)->get();
             //echo $imageTable[$i+1]["id"];
             Image::where('id', $imageTable[$i]["id"])->delete();
         }
     }
     return Redirect::to('profile');
 }
开发者ID:Ycasas-Jan,项目名称:NoteToMyself,代码行数:35,代码来源:profileController.php

示例2: store

 public function store()
 {
     if (!Input::has('email', 'password', 'confirmPassword')) {
         $this->failure("Must fill in the values");
     }
     if (Input::get('password') != Input::get('confirmPassword')) {
         $this->failure("PASSWORDS NOT THE SAME");
     }
     $rules = array('email' => 'unique:users,email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $this->failure('That email address is already registered. You sure you don\'t have an account?');
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
         $this->failure("username must be an email");
     }
     $verificationCode = md5(time());
     User::insert(array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'verification' => $verificationCode));
     Image::insert(array('email' => Input::get('email'), 'image' => ''));
     Notes::insert(array('email' => Input::get('email'), 'notes' => ''));
     TBD::insert(array('email' => Input::get('email'), 'tbd' => ''));
     Links::insert(array('email' => Input::get('email'), 'links' => ''));
     Mail::send('emails.emailMessage', array('code' => $verificationCode, 'email' => Input::get('email')), function ($message) {
         $message->to('ycasas.jan@gmail.com', 'Jan Ycasas')->subject('Welcome!');
     });
     echo "Go Log In";
     return Redirect::to('/');
 }
开发者ID:Ycasas-Jan,项目名称:NoteToMyself,代码行数:28,代码来源:registerController.php

示例3: setProfilePic

 public function setProfilePic(&$file)
 {
     if ($file->isUploadedFile()) {
         $image = new Image();
         $imageID = $image->insert($file->getValue());
         $this->profile_picture = $imageID;
         $file->moveUploadedFile('/tmp/');
     }
 }
开发者ID:swat30,项目名称:safeballot,代码行数:9,代码来源:User_Profile.php

示例4: getAddEditFormSaveHook

 public function getAddEditFormSaveHook($form)
 {
     if (@$_REQUEST[$this->quickformPrefix() . "no_image"]) {
         $this->setImage(0);
     } else {
         $newImage = $form->addElement('file', $this->quickformPrefix() . "image_upload", 'Image');
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($id);
         }
     }
     $this->setLastModified(date('Y-m-d G:i:s'));
 }
开发者ID:anas,项目名称:feedstore,代码行数:14,代码来源:Supplier.php

示例5: create

 /**
  * Upload new Images
  *
  * Also updates Category & Album modification times
  *
  * @param int $categoryId
  * @param int $albumId
  */
 public function create($categoryId, $albumId)
 {
     $category = $this->getCategoryFinder()->findOneBy('id', $categoryId);
     $album = $this->getAlbumFinder()->findOneBy('id', $albumId);
     if ($this->slim->request->isGet()) {
         $this->slim->render('image/create.html.twig', ['category' => $category, 'album' => $album, 'sessionUser' => $this->getSessionUser(), 'allowedExtensions' => Image::getAllowedExtensions(true)]);
     } elseif ($this->slim->request->isPost()) {
         $uploadHandler = new CustomUploadHandler(['upload_dir' => ROOT . '/files/', 'upload_url' => null, 'access_control_allow_methods' => ['POST'], 'accept_file_types' => '/\\.(' . Image::getAllowedExtensions(true) . ')$/i', 'image_library' => 0, 'image_versions' => ['' => ['auto_orient' => false], 'thumb' => ['upload_dir' => ROOT . '/files/thumbs/', 'upload_url' => null, 'crop' => true, 'max_width' => 252, 'max_height' => 252]]]);
         $newImage = new Image($this->slim->db);
         $newImage->setAlbumId($album->getId());
         $newImage->setName($uploadHandler->getUploadedFileName());
         $newImage->insert();
         $album->update();
         $category->update();
     }
 }
开发者ID:lagut-in,项目名称:Slim-Image-Archive,代码行数:24,代码来源:ImageController.php

示例6: adminHookAfterSave

 public function adminHookAfterSave(&$product, &$form)
 {
     if (!$product->getId()) {
         return "";
     }
     $alternativePics = AlternativeImage::getAll($product->getId());
     foreach ($alternativePics as $image) {
         if (@$_REQUEST["product_delete_altimage_" . $image->getImage()]) {
             $image->delete();
         }
     }
     $newAltImage = $form->addElement('file', 'product_alternativepic_upload', 'New Alternate Product Image');
     if ($newAltImage->isUploadedFile()) {
         $im = new Image();
         $imageId = $im->insert($newAltImage->getValue());
         $obj = new AlternativeImage();
         $obj->setProduct($product->getId());
         $obj->setImage($imageId);
         $obj->save();
     }
 }
开发者ID:anas,项目名称:feedstore,代码行数:21,代码来源:AlternativePics.php

示例7: addImage

 static function addImage($fields)
 {
     extract($fields);
     $image = new Image();
     $image->portfolio_id = $portfolio_id;
     $image->width = $width;
     $image->height = $height;
     $image->mediatype = $type;
     $image->filename = $filename;
     $image->server_url = $image->setServer();
     $image->created = common_sql_now();
     $image->modified = common_sql_now();
     $result = $image->insert();
     if (!$result) {
         common_log_db_error($user, 'INSERT', __FILE__);
         return false;
     }
     $dir = common_config('img', 'dir');
     $subdir = str_pad($image->id, 8, '0', STR_PAD_LEFT);
     $subdir = str_split($subdir, 3);
     $image->filepath = $dir . $subdir[0] . "/" . $subdir[1] . "/";
     return $image;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:23,代码来源:Image.php

示例8: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartCategory_addedit', 'post', $target);
     $form->setConstants(array('section' => 'categories'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartcategory_categories_id' => $this->getId()));
         $form->addElement('hidden', 'cartcategory_categories_id');
         $defaultValues['cartcategory_name'] = $this->getName();
         $defaultValues['cartcategory_description'] = $this->getDescription();
         $defaultValues['cartcategory_image'] = $this->getImage();
         $defaultValues['cartcategory_parent_id'] = $this->getParent_id();
         $defaultValues['cartcategory_date_added'] = $this->getDate_added();
         $defaultValues['cartcategory_last_modified'] = $this->getLast_modified();
         $defaultValues['cartcategory_status'] = $this->getStatus();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartcategory_name', 'Name');
     $description = $form->addElement('textarea', 'cartcategory_description', 'Description');
     $description->setCols(80);
     $description->setRows(10);
     $newImage = $form->addElement('file', 'cartcategory_image_upload', 'Category Image');
     $curImage = $form->addElement('dbimage', 'cartcategory_image', $this->getImage());
     $form->addElement('select', 'cartcategory_parent_id', 'Parent Category', self::toArray());
     $added = $form->addElement('text', 'cartcategory_date_added', 'Date Added');
     $added->freeze();
     $modified = $form->addElement('text', 'cartcategory_last_modified', 'Date Last Modified');
     $modified->freeze();
     $form->addElement('select', 'cartcategory_status', 'Status', Form::statusArray());
     $form->addElement('submit', 'cartcategory_submit', 'Submit');
     if (isset($_REQUEST['cartcategory_submit']) && $form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('cartcategory_name'));
         $this->setDescription($form->exportValue('cartcategory_description'));
         $this->setImage($form->exportValue('cartcategory_image'));
         $this->setParent_id($form->exportValue('cartcategory_parent_id'));
         $this->setDate_added($form->exportValue('cartcategory_date_added'));
         $this->setLast_modified($form->exportValue('cartcategory_last_modified'));
         $this->setStatus($form->exportValue('cartcategory_status'));
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($im);
             $curImage->setSource($this->getImage()->getId());
         }
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:55,代码来源:CartCategory.php

示例9: updateAction

 public function updateAction()
 {
     $this->logger->entering();
     $this->logger->info('Loading the item by id');
     $items = new Item();
     $item = $items->find($this->_getParam('id'))->current();
     $this->logger->info('Setting item from params');
     $item->setFromArray($this->_getParam('item'));
     if (isset($_FILES) && isset($_FILES['image']) && $_FILES['image']['error'] == UPLOAD_ERR_OK) {
         $this->logger->notice('Item image has changed');
         $this->logger->info("Reading image data from temporary storage '{$_FILES['image']['tmp_name']}'");
         $image_data = file_get_contents($_FILES['image']['tmp_name']);
         $this->logger->info('Building row data from image');
         $imageRow = array('name' => $_FILES['image']['name'], 'content_type' => $_FILES['image']['type'], 'data' => $image_data);
         $this->logger->info('Inserting Image');
         $images = new Image();
         $images->insert($imageRow);
         $this->logger->info('Getting the id of the image');
         $item->image_id = $this->db->lastInsertId();
     }
     switch ($_FILES['image']['error']) {
         case UPLOAD_ERR_OK:
             $this->logger->info('Image uploaded without complication');
             break;
         case UPLOAD_ERR_INI_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_PARTIAL:
             $this->logger->warn('Image failed to upload');
             $this->flash->notice = "Image failed to upload, could you try again please?";
             break;
         case UPLOAD_ERR_NO_FILE:
             $this->logger->info('No image uploaded');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->logger->err('File upload directory is missing');
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $this->logger->err('File upload directory is not writable');
             break;
         case UPLOAD_ERR_EXTENSION:
             $this->logger->warn('Unacceptable file extension on uploaded file');
             $this->flash->notice = "Invalid file format. Upload an image please.";
             break;
         default:
             $this->logger->crit("Unknown image upload error '{$_FILES['image']['error']}'");
     }
     $this->logger->info('Saving item');
     $item->save();
     $this->logger->info('Inserting item tags');
     $tags = Tag::parseTags($this->_getParam('tags'));
     $items->updateTags($item->id, $tags);
     $this->logger->info('Adding items to search index');
     ItemIndex::update($item, $this->_getParam('tags'));
     $this->logger->info('Redirecting to show the item');
     $this->_redirect("items/show/{$item->id}");
     $this->logger->exiting();
 }
开发者ID:josephholsten,项目名称:swaplady,代码行数:63,代码来源:ItemsController.php

示例10: testGetImageByImageText

 /**
  * Test grabbing an image by image text
  **/
 public function testGetImageByImageText()
 {
     //Count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("image");
     //Create new image and insert into database
     $image = new Image(null, $this->profile->getProfileId(), $this->VALID_IMAGETYPE, $this->VALID_IMAGEFILENAME, $this->VALID_IMAGETEXT, $this->VALID_IMAGEDATE);
     $image->insert($this->getPDO());
     //Get data from database and ensure the fields match our expectations
     $results = Image::getImageByImageText($this->getPDO(), $image->getImageText());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("image"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Jpegery\\Image", $results);
     //Grabs results from array and validate it
     $pdoImage = $results[0];
     $this->assertEquals($pdoImage->getImageProfileId(), $this->profile->getProfileId());
     $this->assertEquals($pdoImage->getImageType(), $this->VALID_IMAGETYPE);
     $this->assertEquals($pdoImage->getImageFileName(), $this->VALID_IMAGEFILENAME);
     $this->assertEquals($pdoImage->getImageText(), $this->VALID_IMAGETEXT);
     $this->assertEquals($pdoImage->getImageDate(), $this->VALID_IMAGEDATE);
 }
开发者ID:davidmancini,项目名称:jpegery,代码行数:23,代码来源:ImageTest.php

示例11: uploadImage

function uploadImage($imageName, $imageLocation, $type, $typeId)
{
    if (!isset($results)) {
        $results = array();
    }
    if ($_FILES[$imageName]['error'] === UPLOAD_ERR_OK) {
        $imageData = array();
        $imageData['imageName'] = $_FILES[$imageName]["name"];
        $imageData['type'] = $type;
        $imageData['typeId'] = $typeId;
        if (is_dir($imageLocation) == false) {
            mkdir($imageLocation, 0777);
            // Create directory if it does not exist
        }
        if (is_file($imageLocation . '/' . $imageData['imageName']) == false) {
            move_uploaded_file($_FILES[$imageName]["tmp_name"], $imageLocation . '/' . $imageData['imageName']);
        } else {
            //rename the image if another one exist
            $temp = explode(".", $_FILES[$imageName]["name"]);
            $imageData['imageName'] = $temp[0] . time() . "." . $temp[1];
            move_uploaded_file($_FILES[$imageName]["tmp_name"], $imageLocation . '/' . $imageData['imageName']);
        }
        $imageData['imageType'] = $_FILES[$imageName]["type"];
        $imageData['imageLocation'] = $imageLocation . '/' . $imageData['imageName'];
        //to add later (the location of the image)
        $image = new Image($imageData);
        if ($imageName === "image") {
            if ($image->insert()) {
                $results['successMessage'] = "image upload successful. Thank you";
                //header('Location: ' . $_SERVER['HTTP_REFERER']);
                return $imageData['imageLocation'];
            }
        }
    } else {
        switch ($_FILES[$imageName]['error']) {
            case UPLOAD_ERR_INI_SIZE:
                $results['errorMessage'] = "The uploaded image exceeds the upload_max_imagesize directive in php.ini";
                break;
            case UPLOAD_ERR_FORM_SIZE:
                $results['errorMessage'] = "The uploaded image exceeds the MAX_image_SIZE directive that was specified in the HTML form";
                break;
            case UPLOAD_ERR_PARTIAL:
                $results['errorMessage'] = "The uploaded image was only partially uploaded";
                break;
            case UPLOAD_ERR_NO_IMAGE:
                $results['errorMessage'] = "No image was uploaded";
                break;
            case UPLOAD_ERR_NO_TMP_DIR:
                $results['errorMessage'] = "Missing a temporary folder";
                break;
            case UPLOAD_ERR_CANT_WRITE:
                $results['errorMessage'] = "Failed to write image to disk";
                break;
            case UPLOAD_ERR_EXTENSION:
                $results['errorMessage'] = "image upload stopped by extension";
                break;
            default:
                $results['errorMessage'] = "Unknown upload error";
                break;
        }
        echo $results['errorMessage'];
    }
}
开发者ID:naval777,项目名称:Websites,代码行数:63,代码来源:main.php

示例12: fileBrowser

 public static function fileBrowser($type)
 {
     $tinyMCE = new TinyMCE();
     global $smarty;
     $smarty->assign('type', $type);
     if (@(!is_null($_POST['uploadsubmit']))) {
         if (!empty($_FILES['filebrowser_uploadedfile']['name'])) {
             if ($_POST['uploadtype'] == 'image') {
                 $newFile = new Image();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $smarty->assign('type', 'image');
             } else {
                 $newFile = new DataStorage();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $newFile->save();
             }
         }
     }
     $smarty->template_dir = SITE_ROOT . '/cms/templates';
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/tiny_mce_popup.js');
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/utils/mctabs.js');
     $smarty->addCSS($tinyMCE->basepath . '/tiny_mce/themes/advanced/skins/default/dialog.css');
     $smarty->addCSS('/css/tiny_mce_filebrowser.css');
     switch ($type) {
         case 'file':
             $smarty->assign('files', DataStorage::search());
             break;
         default:
             $smarty->assign('images', DataStorage::getImagesList());
             break;
     }
     return $smarty->render('filebrowser.tpl');
 }
开发者ID:swat30,项目名称:safeballot,代码行数:33,代码来源:DataStorage.php

示例13: getAddEditForm


//.........这里部分代码省略.........
            $form->addElement('header', 'product_options_' . $option->getId(), 'Product Options: ' . $option->getOptionsId()->getName());
            $form->addElement('static', 'value_' . $option->getId(), $option->getOptionsId()->getName(), $option->getValue()->getName());
            $form->addElement('text', 'attprice[' . $option->getId() . ']', 'Additional Price');
            $form->addElement('text', 'inventory[' . $option->getId() . ']', 'Inventory');
            $form->addElement('html', '
				<div style="float: right;">
					<input type="image" src="/images/admin/cross.gif" name="delete_att" onclick="return !deleteAtt(' . $option->getId() . ');" />
				</div>
			');
            $defaultValues['attprice[' . $option->getId() . ']'] = $option->getValuesPrice();
            $defaultValues['inventory[' . $option->getId() . ']'] = $option->getInventory();
        }
        $form->addElement('header', 'new_product_options', 'New Product Option');
        $form->addElement('select', 'newoption', 'Option', CartProductOption::toArray(), array('onclick' => 'getValues(this);'));
        $form->addElement('select', 'newvalue', 'Value', array());
        $form->addElement('text', 'newattprice', 'Additional Price');
        $form->addElement('text', 'newinventory', 'Inventory');
        $form->setDefaults($defaultValues);
        if (isset($_REQUEST['cartproduct_submit']) && $form->validate() && $form->isSubmitted()) {
            $this->setName($form->exportValue('cartproduct_name'));
            $this->setDescription($form->exportValue('cartproduct_description'));
            //$this->setUrl($form->exportValue('cartproduct_url'));
            $this->setType($form->exportValue('cartproduct_type'));
            $this->setQuantity($form->exportValue('cartproduct_quantity'));
            $this->setPalletCount($form->exportValue('cartproduct_pallet_count'));
            //$this->setModel($form->exportValue('cartproduct_model'));
            $this->setImage($form->exportValue('cartproduct_image_upload'));
            $this->setPrice($form->exportValue('cartproduct_price'));
            //$this->setVirtual($form->exportValue('cartproduct_virtual'));
            $this->setDate_added($form->exportValue('cartproduct_date_added'));
            $this->setLastModified(date('Y-m-d H:i:s'));
            $this->setDateAvailable($form->exportValue('cartproduct_dateAvailable'));
            $this->setWeight($form->exportValue('cartproduct_weight'));
            $this->setWeightUnit($form->exportValue('cartproduct_weight_unit'));
            $this->setStatus($form->exportValue('cartproduct_status'));
            $this->setTaxClass($form->exportValue('cartproduct_taxClass'));
            $this->setManufacturer($form->exportValue('cartproduct_manufacturer'));
            //$this->setAccessoryOf($form->exportValue('cartproduct_accessoryof'));
            //$this->setOrdered($form->exportValue('cartproduct_ordered'));
            if ($form->exportValue('cartproduct_orderMin') <= 0) {
                $this->setOrderMin(1);
            } else {
                $this->setOrderMin($form->exportValue('cartproduct_orderMin'));
            }
            $this->setCategory($form->exportValue('cartproduct_category'));
            /*
            $this->setOrderUnits($form->exportValue('cartproduct_orderUnits'));
            $this->setPricedByAttribute($form->exportValue('cartproduct_pricedByAttribute'));
            $this->setIsFree($form->exportValue('cartproduct_isFree'));
            $this->setIsCall($form->exportValue('cartproduct_isCall'));
            $this->setQuantityMixed($form->exportValue('cartproduct_quantityMixed'));
            $this->setIsAlwaysFreeShipping($form->exportValue('cartproduct_isAlwaysFreeShipping'));
            $this->setQtyBoxStatus($form->exportValue('cartproduct_qtyBoxStatus'));
            $this->setQtyOrderMax($form->exportValue('cartproduct_qtyOrderMax'));
            $this->setSortOrder($form->exportValue('cartproduct_sortOrder'));
            $this->setDiscountType($form->exportValue('cartproduct_discountType'));
            $this->setDiscountTypeFrom($form->exportValue('cartproduct_discountTypeFrom'));
            $this->setPriceSorter($form->exportValue('cartproduct_priceSorter'));
            $this->setMixedDiscountQty($form->exportValue('cartproduct_mixedDiscountQty'));
            $this->setTitleStatus($form->exportValue('cartproduct_titleStatus'));
            $this->setNameStatus($form->exportValue('cartproduct_nameStatus'));
            $this->setModelStatus($form->exportValue('cartproduct_modelStatus'));
            $this->setPriceStatus($form->exportValue('cartproduct_priceStatus'));
            $this->setTaglineStatus($form->exportValue('cartproduct_taglineStatus'));
            */
            if ($newImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newImage->getValue());
                $this->setImage($id);
                //$curImage->setSource($this->getImage()->getId());
            }
            $this->save();
            if ($newAltImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newAltImage->getValue());
                $sql = 'insert into cart_products_images set product_id=' . $this->getId() . ', image_id=' . $id;
                Database::singleton()->query($sql);
            }
            if (is_array(@$_REQUEST['attprice'])) {
                foreach (@$_REQUEST['attprice'] as $key => $value) {
                    $att = new CartProductAttribute($key);
                    $att->setValuesPrice($value);
                    $att->setInventory($_REQUEST['inventory'][$key]);
                    $att->save();
                }
            }
            if (isset($_REQUEST['newvalue']) && isset($_REQUEST['newoption']) && isset($_REQUEST['newattprice'])) {
                $a = new CartProductAttribute();
                $a->setProductid($this->getId());
                $a->setOptionsId($_REQUEST['newoption']);
                $a->setValue($_REQUEST['newvalue']);
                $a->setValuesPrice($_REQUEST['newattprice']);
                $a->setInventory($_REQUEST['newinventory']);
                $a->save();
            }
        }
        $form->addElement('header', 'product_submit', 'Save Product');
        $form->addElement('submit', 'cartproduct_submit', 'Submit');
        return $form;
    }
开发者ID:anas,项目名称:feedstore,代码行数:101,代码来源:CartProduct.php

示例14: getAddEditForm

 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartManufacturer_addedit', 'post', $target);
     $form->setConstants(array('section' => 'manufacturers'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartmanufacturer_manufacturers_id' => $this->getId()));
         $form->addElement('hidden', 'cartmanufacturer_manufacturers_id');
         $defaultValues['cartmanufacturer_name'] = $this->getName();
         $defaultValues['cartmanufacturer_image'] = $this->getImage()->getId();
         //$defaultValues ['cartmanufacturer_date_added'] = $this->getDate_added();
         //$defaultValues ['cartmanufacturer_last_modified'] = $this->getLast_modified();
         $form->setDefaults($defaultValues);
     }
     if (@$this->getImage() && @$this->getImage()->getId()) {
         $form->addElement('dbimage', 'cartmanufacturer_image', $this->getImage()->getId());
     }
     $form->addElement('text', 'cartmanufacturer_name', 'Name');
     $newImage = $form->addElement('file', 'cartmanufacturer_image_upload', 'Image');
     //$form->addElement('text', 'cartmanufacturer_date_added', 'date_added');
     //$form->addElement('text', 'cartmanufacturer_last_modified', 'last_modified');
     $form->addElement('submit', 'cartmanufacturer_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['cartmanufacturer_submit'])) {
         $this->setName($form->exportValue('cartmanufacturer_name'));
         $this->setDescription($form->exportValue('cartmanufacturer_description'));
         //$this->setImage($form->exportValue('cartmanufacturer_image'));
         //$this->setDate_added($form->exportValue('cartmanufacturer_date_added'));
         //$this->setLast_modified($form->exportValue('cartmanufacturer_last_modified'));
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($id);
         }
         $this->save();
     }
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:44,代码来源:CartManufacturer.php

示例15: submitPage

 public function submitPage()
 {
     $timeDiff = round(abs(time() - $_SESSION["time"]) / 60, 2) . " minute";
     if ($timeDiff >= 20) {
         exit("LOGGED OUT OF INACTIVE. <a href='home'>Log In</a>");
     }
     $userID = $_POST["userID"];
     $result = Image::where('userID', $userID)->count();
     if (file_exists($_FILES['photo']['tmp_name']) || is_uploaded_file($_FILES['photo']['tmp_name'])) {
         $result++;
     }
     if ($result >= 4) {
         echo $result;
         exit("CAN ONLY HAVE 4 IMAGES GO BACK");
     }
     $id = Image::select('id')->where('userID', $userID)->get()->toArray();
     for ($i = 0; $i < $result; $i++) {
         if (isset($_POST["delete{$i}"])) {
             Image::where('id', $id[$i]["id"])->delete();
         }
     }
     Notes::where('userID', $_POST["userID"])->update(array('notes' => $_POST["notes"]));
     TBD::where('userID', $_POST["userID"])->update(array('tbd' => $_POST["tbd"]));
     $emailArray = array();
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["website{$i}"]) && $_POST["website{$i}"] != "") {
             array_push($emailArray, $_POST["website{$i}"]);
         }
     }
     for ($i = 0; $i < count($emailArray); $i++) {
         $result = Website::select('website')->where('website', $emailArray[$i])->get();
         if ($result == "[]") {
             Website::insert(array('userID' => $userID, 'website' => $emailArray[$i]));
         }
     }
     if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {
         if ($_FILES['photo']['type'] == "image/jpeg" || $_FILES['photo']['type'] == "image/jpg" || $_FILES['photo']['type'] == "image/gif") {
             Image::insert(array('userID' => $userID, 'image' => file_get_contents($_FILES['photo']['tmp_name'])));
         }
     }
     $profile = $this->returnProfile($_POST["userID"]);
     return View::make('profile')->with('userProfile', $profile);
 }
开发者ID:rshen3p,项目名称:PHP-Laravel.NoteToMyself,代码行数:43,代码来源:PagesController.php


注:本文中的Image::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。