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


PHP Thumbnail::save方法代码示例

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


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

示例1: handleDirFiles

function handleDirFiles($dir_name, $save_dir)
{
    list($directories, $files) = File_Find::maptree($dir_name);
    $new_dir = $save_dir . basename($dir_name);
    if (!file_exists($new_dir)) {
        mkdir($new_dir, 0777);
    }
    foreach ($files as $image_file) {
        if (ereg("(.*)jpg\$", $image_file)) {
            $new_filename = $new_dir . "/" . basename($image_file, ".jpg") . "_resize.jpg";
            echo $new_filename . "\n";
            $tn_image = new Thumbnail($image_file, 340);
            $tn_image->save($new_filename);
            $Canvas =& Image_Canvas::factory(isset($_GET['canvas']) ? $_GET['canvas'] : 'jpg', array('width' => 340, 'height' => 340));
            $Canvas->image(array('x' => 340, 'y' => 340, 'filename' => $new_filename, 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom')));
            $Canvas->setFont(array('name' => 'Courier New', 'size' => 16, 'color' => '#FF66FF'));
            //#FF0033
            $Canvas->addText(array('x' => 165, 'y' => 200, 'text' => 'arzen1013', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
            $Canvas->setFont(array('name' => 'Courier New', 'size' => 10, 'color' => '#000000'));
            //#FF0033
            $Canvas->addText(array('x' => 165, 'y' => 320, 'text' => 'http://shop33691629.taobao.com/', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
            $Canvas->save(array('filename' => $new_filename));
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:25,代码来源:image_join.php

示例2: attach_file

 public function attach_file($file, $campo)
 {
     global $database;
     // Determine the target_path
     $this->temp_path = $file['tmp_name'];
     switch ($file['type']) {
         case "image/gif":
             $this->foto = $campo . "-" . $this->id . ".gif";
             break;
         case "image/png":
             $this->foto = $campo . "-" . $this->id . ".png";
             break;
         default:
             $this->foto = $campo . "-" . $this->id . ".jpg";
     }
     $target_path = $this->upload_dir . "/" . $this->foto;
     // Attempt to move the file
     if (move_uploaded_file($this->temp_path, $target_path)) {
         // Success
         $tn_image = new Thumbnail($this->upload_dir . "/" . $this->foto, 640, 0, 0);
         $tn_image->save($this->upload_dir . "/" . $this->foto);
         // Save a corresponding entry to the database
         $sql = "UPDATE " . self::$table_name . " SET " . $campo . " = '" . $this->foto . "' WHERE id = '" . $this->id . "'";
         if ($database->query($sql)) {
             // We are done with temp_path, the file isn't there anymore
             unset($this->temp_path);
             return true;
         }
     }
 }
开发者ID:hugodom,项目名称:CamposEstancias,代码行数:30,代码来源:propiedades.php

示例3: createThumb

 protected static function createThumb($image, $target, $size, $quality)
 {
     $source = self::getRealFilename($image);
     //ini_set('memory_limit', '128M');
     $thumb = new Thumbnail($source);
     if ($size) {
         $size_array = explode('x', $size);
         if (is_numeric($size_array[0])) {
             $thumb->size_width($size_array[0]);
         }
         if (is_numeric($size_array[1])) {
             $thumb->size_height($size_array[1]);
         }
     }
     if (is_numeric($quality)) {
         $thumb->quality = $quality;
     }
     $thumb->process();
     if (!$thumb->save($target)) {
         throw new Image_Handler_Exception($image, $thumb->error_msg);
     }
 }
开发者ID:ctiborv,项目名称:spitzen-wein.ch,代码行数:22,代码来源:image_handler.class.php

示例4: manipulate

 /**
  * Perfoms manipulation
  *
  * @param string $from
  * @param string $to
  * @param string $options
  * @return void
  */
 public function manipulate($from, $to, $options)
 {
     if (false === class_exists('Thumbnail')) {
         throw new Yag_Manipulator_Adapter_Exception('Class Thumbnail could not be loaded');
     }
     if (!isset($options['geometry'])) {
         throw new Yag_Manipulator_Adapter_Exception('Thumbnail requires the \'geometry\' option to be set');
     }
     $matches = array();
     preg_match('/(c)?([0-9]+)x([0-9]+)/', $options['geometry'], $matches);
     $crop = empty($matches[1]) ? false : true;
     $width = $matches[2];
     $height = $matches[3];
     if (empty($matches[2])) {
         throw new Yag_Manipulator_Adapter_Exception('Invalid geometry pattern \'' . $options['geometry'] . '\'');
     }
     if (empty($matches[3])) {
         throw new Yag_Manipulator_Adapter_Exception('Invalid geometry pattern \'' . $options['geometry'] . '\'');
     }
     $thumbnail = new Thumbnail($from);
     // TODO: Fix error handling around this...
     $quality = 80;
     if (false == $crop) {
         $thumbnail->resize($width, $height);
         $quality = 100;
     } else {
         if ($width == $height) {
             // Well works for now... the crop for ImageTransform is a bit better
             // but who cares?
             $thumbnail->cropFromCenter($width);
         } else {
             $thumbnail->crop(0, 0, $width, $height);
         }
     }
     $thumbnail->save($to, $quality);
 }
开发者ID:johannilsson,项目名称:yag,代码行数:44,代码来源:Thumbnail.php

示例5: Thumbnail

<?php

//Thumbnail sample: generate thumbnail + watermark and save to a file with a unique filename
include 'Thumbnail.class.php';
$thumb = new Thumbnail("source.jpg");
// Contructor and set source image file
$thumb->img_watermark = 'watermark.png';
// [OPTIONAL] set watermark source file, only PNG format [RECOMENDED ONLY WITH GD 2 ]
$thumb->size(150, 113);
// [OPTIONAL] set the biggest width and height for thumbnail
$thumb->process();
// generate image
$filename = $thumb->unique_filename('.', 'sample.jpg', 'thumb');
// generate unique filename
$status = $thumb->save($filename);
// save your thumbnail to file
if ($status) {
    echo 'Thumbnail save as ' . $filename;
} else {
    echo 'ERROR: ' . $thumb->error_msg;
}
开发者ID:snellcode,项目名称:ARCNA-Animals,代码行数:21,代码来源:Thumbnail_save_sample.php

示例6: test_for_belongs_to_association

 public function test_for_belongs_to_association()
 {
     $Thumbnail = new Thumbnail();
     $Thumbnail = $Thumbnail->findFirstBy('caption', 'Lucky (our pet)');
     $Thumbnail = new Thumbnail($Thumbnail->getId());
     $this->assertEqual($Thumbnail->picture->getType(), 'belongsTo');
     $Thumbnail = $Thumbnail->findFirstBy('caption:has', 'Lucky', array('include' => 'picture'));
     $this->assertEqual($Thumbnail->picture->getType(), 'Picture');
     $this->assertEqual($Thumbnail->picture->title, 'The Akelos Media Team at Carlet');
     $Alicia = $Thumbnail->create('caption->', 'Alicia');
     $this->assertTrue(!$Alicia->isNewRecord());
     $this->assertEqual($Alicia->picture->getType(), 'belongsTo');
     $MyGirl = new Picture(array('title' => 'Alicia Sadurní'));
     $Alicia->picture->assign($MyGirl);
     $this->assertEqual($Alicia->picture->getType(), 'Picture');
     $this->assertReference($Alicia->picture, $MyGirl);
     $this->assertFalse($MyGirl->isNewRecord());
     $this->assertEqual($Alicia->get('photo_id'), $MyGirl->getId());
     $this->assertTrue($Alicia->save());
     $Thumbnail = new Thumbnail();
     $Thumbnail->caption = 'Party 2005';
     $Picture = $Thumbnail->picture->build(array('title' => 'Akelos Party 2005'));
     $this->assertReference($Thumbnail->picture, $Picture);
     $this->assertEqual($Picture->getType(), 'Picture');
     $this->assertTrue($Picture->isNewRecord() && $Thumbnail->isNewRecord());
     $this->assertTrue($Thumbnail->save());
     $this->assertFalse($Picture->isNewRecord());
     $this->assertFalse($Thumbnail->isNewRecord());
     $Thumbnail = new Thumbnail();
     $Thumbnail->caption = 'Party 2006';
     $Picture = $Thumbnail->picture->create(array('title' => 'Akelos Party 2006'));
     $this->assertReference($Thumbnail->picture, $Picture);
     $this->assertEqual($Picture->getType(), 'Picture');
     $this->assertFalse($Picture->isNewRecord());
     $this->assertTrue($Thumbnail->isNewRecord());
     $Thumbnail = new Thumbnail(array('title' => 'Akelos new office'));
     $Thumbnail->loadAssociations();
     $Thumbnail->picture->assign($Picture);
     $this->assertTrue($Thumbnail->save());
     $this->assertEqual($Thumbnail->photo_id, $Picture->id);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:41,代码来源:AkBelongsTo.php

示例7: scalePicture

 protected function scalePicture($file)
 {
     global $eshop_picture_config;
     $t = new Thumbnail(KIWI_DIR_ACTIONS_PIC . $file);
     $t->size($eshop_picture_config['action'][0], $eshop_picture_config['action'][1]);
     $t->quality = 80;
     $t->output_format = 'JPG';
     $t->process();
     $status = $t->save(KIWI_DIR_ACTIONS_PIC . $file);
     if (!$status) {
         throw new Exception('Chyba při ukládání miniatury obrázku');
     }
 }
开发者ID:ctiborv,项目名称:spitzen-wein.ch,代码行数:13,代码来源:kiwi_action_form.class.php

示例8: uploadarticleimage

function uploadarticleimage()
{
	$db =& JFactory::getDBO();
	
	$itemId = AwdwallHelperUser::getComItemId();
	
	$id=$_REQUEST['id'];
	$user = &JFactory::getUser();
		$query = "SELECT image,commenter_id,user_id FROM #__awd_wall_article as ar inner join #__awd_wall as aw on ar.wall_id =aw.id  WHERE `article_id`=".$id."  limit 1";
		$db->setQuery($query);
		$articlerows = $db->loadObjectList();
		$articlerow=$articlerows[0];
		if($articlerow->commenter_id)
		{
			$wuid=$articlerow->commenter_id;
		}
		else
		{
			$wuid=$user->id;
		}	
		
		
	$config 		= &JComponentHelper::getParams('com_awdwall');
	$article_img_height 		= $config->get('article_img_height', '84');
	$article_img_width 		= $config->get('article_img_width', '112');
	$image 	= JRequest::getVar('awd_link_image', null, 'files', 'array');
	$arrExt 	= explode(',', AwdwallHelperUser::getImageExt());
	$article_image 	= JRequest::getVar('awd_article_image', null, 'files', 'array');
		if($article_image['name'] != ''){
		jimport('joomla.filesystem.file');
		jimport('joomla.filesystem.folder');
		$time = time();
		//Clean up filename to get rid of strange characters like spaces etc
		$fileName = $time . '_' . JFile::makeSafe($article_image['name']);
		$fileName = str_replace(' ', '_', $fileName);
		$src 	= $article_image['tmp_name'];
		$dest 	= 'images' . DS . 'awd_articles' . DS . $wuid . DS . 'original' . DS . $fileName; 
		if(in_array(strtolower(JFile::getExt($fileName)), $arrExt)){
			if (JFile::upload($src, $dest)){ 
				require_once(JPATH_COMPONENT . DS . 'libraries' . DS . 'thumbnail.php');
				$thumb = new Thumbnail($dest);
				$thumb->resize($article_img_width, $article_img_height);
				JFolder::create('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb');
				$thumb->save('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb' . DS . $fileName);
				// resize original picture to 600*400
				$thumb = new Thumbnail($dest);
				$thumb->resize(600, 400);					
				$thumb->save($dest);
				$query = "update #__awd_wall_article set image='".$fileName."' where  `article_id`=".$id;
				$db->setQuery($query);
				if (!$db->query()){	
					$this->setRedirect(JRoute::_('index.php?option=com_awdwall&&view=awdwall&layout=main&Itemid='.$itemId,false),$db->getErrorMsg());
				}
				
			}else {						
				//Redirect and throw an error message
				//$this->setRedirect(JRoute::_('index.php?option=com_awdwall&&view=awdwall&layout=mywall&wuid=' . $wuid . '&Itemid=' . $itemId, false));
			}
		}
	}
	if($articlerow->image)
	{
		unlink('images' . DS . 'awd_articles' . DS . $wuid . DS . 'original' . DS . $articlerow->image);
		unlink('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb' . DS . $articlerow->image);
	}
	
	$imagesrc=JURI::base().'images/awd_articles/'. $wuid . '/original/'. $fileName;
	echo '{"imagesrc": "'.$imagesrc.'"}';
	//echo '<img src="'.$imagesrc.'" width="150" />';
	exit;
}	
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:71,代码来源:controller.php

示例9: getThumb

 function getThumb($text, $size = 70, $reflections = false)
 {
     preg_match("/\\<img.+?src=\"(.+?)\".+?\\/>/", $text, $matches);
     $paths = array();
     if (isset($matches[1])) {
         $image_path = $matches[1];
         //joomla 1.5 only
         $full_url = JURI::base();
         //remove any protocol/site info from the image path
         $parsed_url = parse_url($full_url);
         $paths[] = $full_url;
         if (isset($parsed_url['path']) && $parsed_url['path'] != "/") {
             $paths[] = $parsed_url['path'];
         }
         foreach ($paths as $path) {
             if (strpos($image_path, $path) !== false) {
                 $image_path = substr($image_path, strpos($image_path, $path) + strlen($path));
             }
         }
         // remove any / that begins the path
         if (substr($image_path, 0, 1) == '/') {
             $image_path = substr($image_path, 1);
         }
         //if after removing the uri, still has protocol then the image
         //is remote and we don't support thumbs for external images
         if (strpos($image_path, 'http://') !== false || strpos($image_path, 'https://') !== false) {
             return false;
         }
         // create a thumb filename
         $file_div = strrpos($image_path, '.');
         $thumb_ext = substr($image_path, $file_div);
         $thumb_prev = substr($image_path, 0, $file_div);
         $thumb_path = $thumb_prev . "_thumb" . $thumb_ext;
         // check to see if this file exists, if so we don't need to create it
         if (function_exists("gd_info") && !file_exists($thumb_path)) {
             // file doens't exist, so create it and save it
             include_once 'thumbnail.inc.php';
             $thumb = new Thumbnail($image_path);
             if ($thumb->error) {
                 if (MICRONEWS) {
                     echo "ROKMININEWS ERROR: " . $thumb->errmsg . ": " . $image_path;
                 }
                 return false;
             }
             $thumb->resize($size);
             if ($reflections) {
                 $thumb->createReflection(30, 30, 60, false);
             }
             if (!is_writable(dirname($thumb_path))) {
                 $thumb->destruct();
                 return false;
             }
             $thumb->save($thumb_path);
             $thumb->destruct();
         }
         return $thumb_path;
     } else {
         return false;
     }
 }
开发者ID:jnvilo,项目名称:tomasinasanctuary.org,代码行数:60,代码来源:helper.php

示例10: saveVideoInfo

   /**
    * Save editted video details
    */
	function saveVideoInfo()
	{
		global $Itemid, $mainframe;
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$c = hwd_vs_Config::get_instance();
		$app = & JFactory::getApplication();

		$row = new hwdvids_video($db);

		$uid = JRequest::getInt( 'owner', 0, 'post' );
		$rowid = JRequest::getInt( 'id', 0, 'post' );
		$referrer = JRequest::getVar( 'referrer', JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid );

		// check component access settings and deny those without privileges
		if (!hwd_vs_access::allowAccess( $c->gtree_mdrt, $c->gtree_mdrt_child, hwd_vs_access::userGID( $my->id ))) {
			if ($my->id == $uid) {
				if ($my->id == "0") {
					$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
					$app->redirect( $referrer );
				}
				if ($c->allowvidedit == "0") {
					$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
					$app->redirect( $referrer );
				}
				// continue
			} else {
				$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
				$app->redirect( $referrer );
			}
		}

		$row->load( $rowid );
		$old_category = $row->category_id;

		$file_name_org   = $_FILES['thumbnail_file']['name'];
		$file_ext        = substr($file_name_org, strrpos($file_name_org, '.') + 1);

		$thumbnail = '';
		if ($_FILES['thumbnail_file']['tmp_name'] !== "") {

			if ($row->video_type == "local" || $row->video_type == "swf" || $row->video_type == "mp4")
			{
				$videocode = $row->video_id;
				$thumbnail = $file_ext;
			}
			else
			{
				$videocode = "tp-".$row->id;
				$thumbnail = "tp-".$row->id.".".$file_ext;
			}

			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS;
			$upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $videocode, $base_Dir, 2, "jpg,jpeg", 1);

			if ($upload_result[0] == "0")
			{
				$msg = $upload_result[1];
				$app->enqueueMessage($msg);
				$app->redirect( JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvideo&video_id='.$row->id );
			}
			else
			{
				require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php');

				$thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$videocode.'.'.$file_ext;
				$thumb_path_l = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.'l_'.$videocode.'.'.$file_ext;

				$twidth_s = round($c->con_thumb_n);
				$theight_s = round($c->con_thumb_n*$c->tar_fb);
				$twidth_l = round($c->con_thumb_l);
				$theight_l = round($c->con_thumb_l*$c->tar_fb);

				list($width, $height, $type, $attr) = @getimagesize($thumb_path_s);
				$ratio = $width/$height;

				//echo $thumb_path_s."<br />".$ratio."<br />".$width."<br />".$height."<br />".$c->tar_fb."<br />".$twidth_s."<br />".$theight_s;

				if ($ratio > 1)
				{
					$resized_l = new Thumbnail($thumb_path_s);
					$resized_l->resize($twidth_l,$twidth_l);
					$resized_l->cropFromCenter($twidth_l, $theight_l);
					$resized_l->save($thumb_path_l);
					$resized_l->destruct();

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize($twidth_s,$twidth_s);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();
				}
				else
				{
					$resized_l = new Thumbnail($thumb_path_s);
					$resized_l->resize($twidth_l,2000);
					$resized_l->cropFromCenter($twidth_l, $theight_l);
//.........这里部分代码省略.........
开发者ID:rkern21,项目名称:videoeditor,代码行数:101,代码来源:usrfunc.php

示例11: Thumbnail

// Check if the required paths is not included.
if (empty($path) || empty($_GET['filename'])){

}else{

// Does this thumbnail exists, we dont want to overload the CPU with our gallery.
if (file_exists($thum_p.$_GET['filename'])){
	
	// Well if the image that we have.. is newer and same name we must create a new tempalte.
	if(file_exists($path.$_GET['filename']) && filemtime($thum_p.$_GET['filename']) < filemtime($path.$_GET['filename'])){
		unlink($thum_p.$_GET['filename']);
		$thumb = new Thumbnail($path.$_GET['filename']);
		$thumb->resize($_GET['width'],$_GET['height']);
		$thumb->save($thum_p.$_GET['filename']);
		$thumb->show();
	// Ok we just show our thumbnail.
	}else{
		$thumb = new Thumbnail($thum_p.$_GET['filename']);
		$thumb->show();
	}
// We gotta create a thumbnail because our thumbnail does not exist.
}else{
	$thumb = new Thumbnail($path.$_GET['filename']);
	$thumb->resize($_GET['width'],$_GET['height']);
	$thumb->save($thum_p.$_GET['filename']);
	$thumb->show();
}

}
exit;
?>
开发者ID:BACKUPLIB,项目名称:mwenhanced,代码行数:31,代码来源:show_picture.php

示例12: savecategories

	/**
	 * save categories
	 */
	function savecategories()
	{
		global $option;
		$db = & JFactory::getDBO();
		$app = & JFactory::getApplication();
		$c = hwd_vs_Config::get_instance();

		$access_lev_u = Jrequest::getVar( 'access_lev_u', '0' );
		$access_lev_v = Jrequest::getVar( 'access_lev_v', '0' );

		$row = new hwdvids_cats($db);

		if (isset($_FILES['thumbnail_file']['error'])) {

			$file_name_org   = $_FILES['thumbnail_file']['name'];
			$file_ext        = substr($file_name_org, strrpos($file_name_org, '.') + 1);

			$thumbnail_url = JURI::root( true ).'/hwdvideos/thumbs/category'.$_POST['id'].'.'.$file_ext;
			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS;
			$thumbnail_name = 'category'.$_POST['id'];

			$upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $thumbnail_name, $base_Dir, 2, "jpg,jpeg", 1);

			if ($upload_result[0] == "0") {

				$msg = $upload_result[1];
				$app->enqueueMessage($msg);

			} else {

				include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php');
				$thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$thumbnail_name.'.'.$file_ext;
				$twidth_s = round($c->con_thumb_n);
				$theight_s = round($c->con_thumb_n*$c->tar_fb);

				list($width, $height, $type, $attr) = @getimagesize($thumb_path_s);
				$ratio = $height/$width;

				if ($ratio < $c->tar_fb) {

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize(1000, $theight_s);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();

				} else {

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize($twidth_s,1000);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();

				}
			}

			// update db with new thumbnail
			$db->SetQuery("UPDATE #__hwdvidscategories SET thumbnail = '$thumbnail_url' WHERE id = ".intval($_POST['id']));
			$db->Query();
			if ( !$db->query() ) {
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}

			$msg = "Thumbnail was successfully uploaded";
			$app->enqueueMessage($msg);
			$app->redirect( 'index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editcatA&hidemainmenu=1&cid='.$_POST['id'] );

		} else {

			if (intval($_POST['id']) !== 0 && (intval($_POST['id']) == intval($_POST['parent']))) {
				$app->enqueueMessage(_HWDVIDS_ALERT_PARENTNOTSELF);
				$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' );
			}

			$_POST['category_name'] = Jrequest::getVar( 'category_name', 'no name supplied' );
			$_POST['category_description'] = Jrequest::getVar( 'category_description', 'no name supplied' );
			$_POST['access_lev_u'] = @implode(",", $access_lev_u);
			$_POST['access_lev_v'] = @implode(",", $access_lev_v);

		}

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		if(empty($row->category_name)) {
			$app->enqueueMessage(_HWDVIDS_NOTITLE);
			$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' );
		}

		// store it in the db
//.........这里部分代码省略.........
开发者ID:rkern21,项目名称:videoeditor,代码行数:101,代码来源:categories.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     /*
      $input = array('name' => 'r');
     $rules = array('name' => 'min:5');
      dd($coreValidator->messages());
     */
     /* Validation */
     $input = Input::all();
     $rules = array('title' => array('required', 'min:3', 'unique:listings'), 'elevator_pitch' => array('required', 'min:3'), 'extended_desc' => 'max:999999', 'faqs' => array('required', 'min:3'), 'address1' => array('required', 'min:4', 'max:255'), 'city' => array('required', 'alpha_num', 'min:3', 'max:255'), 'suburb' => array('required', 'min:3', 'max:255'), 'state' => array('required', 'min:4', 'max:255'), 'country' => array('required', 'min:4', 'max:255'), 'postcode' => array('required', 'numeric', 'min:0000', 'max:9999'), 'daily_rate' => array('required', 'numeric', 'min:0', 'max:9999'), 'weekly_rate' => array('required', 'numeric', 'min:0', 'max:99999'), 'monthly_rate' => array('required', 'numeric', 'min:0', 'max:99999'), 'space_type' => array('required', 'alpha', 'exists:spacetypes,type'));
     /* Check to see if data is valid */
     $coreValidator = Validator::make($input, $rules);
     if ($coreValidator->fails()) {
         return Redirect::back()->withErrors($coreValidator)->withInput();
     } else {
         //Check if the images are legit
         if (!$this->didPassImageValidation()) {
             return Redirect::back()->with('flash_message_404', 'Sorry, the image(s) you uploaded is not a supported file type');
         }
         //Add new listing to DB.
         $listing = new Listing();
         $listing->owner_id = Auth::user()->id;
         //Key info
         $listing->title = $input['title'];
         $listing->elevator_pitch = $input['elevator_pitch'];
         $listing->extended_desc = $this->sanitizeStringAndParseMarkdown($input['extended_desc']);
         $listing->faqs = $this->sanitizeStringAndParseMarkdown($input['faqs']);
         $listing->space_type = $input['space_type'];
         //Location
         $listing->address1 = $input['address1'];
         $listing->city = $input['city'];
         $listing->suburb = $input['suburb'];
         $listing->state = $input['state'];
         $listing->country = $input['country'];
         $listing->postcode = $input['postcode'];
         //Rates
         $listing->daily_rate = $input['daily_rate'];
         $listing->weekly_rate = $input['weekly_rate'];
         $listing->monthly_rate = $input['monthly_rate'];
         $listing->currency = 'AUD';
         $listing->isPublic = 1;
         //Amenities
         if (isset($input['wifi'])) {
             $listing->wifi = 1;
         } else {
             $listing->wifi = 0;
         }
         if (isset($input['coffee'])) {
             $listing->coffee_machine = 1;
         } else {
             $listing->coffee_machine = 0;
         }
         if (isset($input['heating'])) {
             $listing->heating = 1;
         } else {
             $listing->heating = 0;
         }
         if (isset($input['parking'])) {
             $listing->parking = 1;
         } else {
             $listing->parking = 0;
         }
         if (isset($input['aircon'])) {
             $listing->aircon = 1;
         } else {
             $listing->aircon = 0;
         }
         if (isset($input['couches'])) {
             $listing->couches = 1;
         } else {
             $listing->couches = 0;
         }
         $listing->save();
         /* Image Business */
         //Handle thumbnail upload
         $unique = uniqid("aimg", true);
         $path = 'images/listing_thumbnails/' . $unique . '.jpg';
         $thumb = Input::file('thumbnail')->getRealPath();
         $thumb = Image::make($thumb)->resize(300, 200, true, true);
         $thumb->encode('jpg', 60);
         $thumb->save($path);
         if (isset($thumb)) {
             unset($thumb);
         }
         $thumbnail = new Thumbnail();
         $thumbnail->listing_id = $listing->id;
         $thumbnail->url = $path;
         $thumbnail->alt_text = 'Thumbnail image for ' . $input['title'] . ' space listing';
         $thumbnail->save();
         $counter = 1;
         foreach (Input::file('photos') as $photo) {
             $unique = uniqid("gallery", true);
             $path = 'images/listing_images/' . $unique . '.jpg';
             $photo = $photo->getRealPath();
             $photo = Image::make($photo)->resize(800, 450, true, true);
//.........这里部分代码省略.........
开发者ID:s-matic,项目名称:collab-consumption,代码行数:101,代码来源:ListingController.php

示例14: _subirArchivo

 private function _subirArchivo($imagen)
 {
     if (isset($imagen['name'])) {
         if ($imagen['error'] == 0) {
             $nombre_imagen = time() . $imagen['name'];
             $directorio = "img/productos/";
             if (move_uploaded_file($imagen['tmp_name'], $directorio . $nombre_imagen)) {
                 App::uses('Thumbnail', 'Vendor');
                 $thumbnail = new Thumbnail();
                 $thumbnail->loadImage($directorio . $nombre_imagen);
                 $thumbnail->resize(200, 'width');
                 $thumbnail->save($directorio . 'medianos/' . $nombre_imagen);
                 $thumbnail->resize(70, 'width');
                 $thumbnail->save($directorio . 'chicos/' . $nombre_imagen);
                 return $nombre_imagen;
             }
         }
     }
     $this->Session->setFlash(__('Problemas al subir la imagen.'));
     $this->redirect(array('action' => 'mis_productos'));
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:21,代码来源:ProductosController.php

示例15: edit

 /**
  * @abstract Edits an event recprd
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     template()->addJs('edit.js');
     $form = new Form('contacts', $id, array('contact_languages', 'contact_groups', 'contact_specialties'));
     // proces the form if submitted
     if ($form->isSubmitted()) {
         if ($res_id = $form->save($id)) {
             $id = $id ? $id : $res_id;
             // upload file
             app()->setConfig('upload_server_path', APPLICATION_PATH . DS . 'files' . DS . 'contacts' . DS . $id);
             app()->setConfig('enable_uploads', true);
             // enable uploads
             $uploads = files()->upload('file_path');
             // small thumb
             $thm_width = app()->config('contact_image_thm_maxwidth');
             $thm_height = app()->config('contact_image_thm_maxheight');
             // resized original
             $orig_width = app()->config('contact_image_maxwidth');
             $orig_height = app()->config('contact_image_maxheight');
             if (is_array($uploads) && !empty($uploads[0])) {
                 foreach ($uploads as $file) {
                     // delete previous images
                     $model = model()->open('contact_images');
                     $model->where('contact_id', $id);
                     $images = $model->results();
                     if (is_array($images)) {
                         foreach ($images as $image) {
                             $base = APPLICATION_PATH . DS . 'files' . DS . 'contacts' . DS . $image['contact_id'];
                             files()->delete($base . DS . $image['filename_orig']);
                             files()->delete($base . DS . $image['filename_thumb']);
                             $model->delete('contact_images', $image['id']);
                         }
                     }
                     // get new thumb file name, new path
                     $thm_name = str_replace($file['file_extension'], '_thm' . $file['file_extension'], $file['file_name']);
                     $thm_path = str_replace($file['file_name'], $thm_name, $file['server_file_path']);
                     // get new file name, new path
                     $orig_name = str_replace($file['file_extension'], '_orig' . $file['file_extension'], $file['file_name']);
                     $orig_path = str_replace($file['file_name'], $orig_name, $file['server_file_path']);
                     // load original in thumbnail
                     $thm_create = new Thumbnail($file['server_file_path']);
                     $thm_create->adaptiveResize($thm_width, $thm_height);
                     $thm_create->save($thm_path);
                     $orig_create = new Thumbnail($file['server_file_path']);
                     $orig_create->adaptiveResize($orig_width, $orig_height);
                     $orig_create->save($orig_path);
                     // store image and thumb info to database
                     model()->open('contact_images')->insert(array('contact_id' => $id, 'filename_orig' => $orig_name, 'filename_thumb' => $thm_name, 'width_orig' => $orig_width, 'height_orig' => $orig_height, 'width_thumb' => $thm_width, 'height_thumb' => $thm_height));
                 }
             }
             sml()->say('Contact changes have been saved successfully.');
             router()->redirect('view');
         }
     }
     $data['form'] = $form;
     // get images
     if ($id) {
         $model = model()->open('contact_images');
         $model->where('contact_id', $id);
         $data['images'] = $model->results();
     } else {
         $data['images'] = false;
     }
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:70,代码来源:Contacts_Admin.php


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