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


PHP Media::delete方法代码示例

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


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

示例1: getImage

function getImage($img)
{
    try {
        if (strpos($img, 'http://') !== false) {
            $original_url = $img;
            $pos = strrpos($img, ".");
            $ext = substr($img, $pos + 1);
            $media = new Media();
            $media->save();
            $fileName = $media->getId() . "." . $ext;
            $basePath = sfConfig::get('sf_web_dir') . "/media/upload/";
            file_put_contents($basePath . $fileName, file_get_contents($img));
            $mime = explode(";", Media::mime_content_type($basePath . $fileName));
            $mime = $mime[0];
            $media->setFilename($fileName);
            $media->setFiletype($mime);
            $media->setFiledirpath($basePath);
            $media->save(null, $o);
            chmod($basePath . $fileName, 0777);
            $media->resizeImage(null, 450);
            $media->resizeImage(1, 150);
        } elseif (base64_decode($img)) {
            $ext = "jpg";
            $media = new Media();
            $media->save();
            $fileName = $media->getId() . "." . $ext;
            $basePath = sfConfig::get('sf_web_dir') . "/media/upload/";
            file_put_contents($basePath . $fileName, base64_decode($img));
            $mime = explode(";", Media::mime_content_type($basePath . $fileName));
            $mime = $mime[0];
            $media->setFilename($fileName);
            $media->setFiletype($mime);
            $media->setFiledirpath($basePath);
            $media->save(null, $o);
            chmod($basePath . $fileName, 0777);
            $media->resizeImage(null, 450);
            $media->resizeImage(1, 150);
        }
    } catch (Exception $e) {
        $media->delete();
        FileHelper::Log("CRON ERROR >>> Field : " . $k . " on item " . $o->getId() . "(" . $offer['originalid'] . ") is not a valid image. [" . $original_url . "]");
        echo_cms("CRON ERROR >>> Field : " . $k . " on item " . $o->getId() . "(" . $offer['originalid'] . ") is not a valid image. [" . $original_url . "]");
    }
}
开发者ID:kotow,项目名称:work,代码行数:44,代码来源:sfPakeUtils.php

示例2: postRemoveMedia

 public function postRemoveMedia($id)
 {
     $media = Media::find($id);
     $media = new Media();
     $media->delete();
     $media = Media::find($id);
     $owner = $media->mediable_id;
     $ownerType = $media->mediable_type;
     $owner = $ownerType::find($owner);
     $isAjax = Request::ajax();
     // Disasociate this from its parent exhibit
     foreach ($owner->media as $key => $image) {
         if ($image->id == $id) {
             $owner->media[$key]->update(['mediable_id' => 0, 'mediable_type' => null]);
             $mediasave = $owner->media[$key]->save();
         }
     }
     if ($mediasave == true) {
         $outcome = $owner->update(array('cover_image' => ''));
     }
     return json_encode($outcome);
 }
开发者ID:mlauren,项目名称:midway-gallery,代码行数:22,代码来源:NewsController.php

示例3: actionToggleDefaultLogo

	public function actionToggleDefaultLogo() {
		
		$adminProf=ProfileChild::model()->findByAttributes(array('username'=>'admin'));
		$logo=Media::model()->findByAttributes(array('associationId'=>$adminProf->id,'associationType'=>'logo'));
		if(!isset($logo)) {

			$logo=new Media;
			$logo->associationType='logo';
			$name='yourlogohere.png';
			$logo->associationId=$adminProf->id;
			$logo->fileName='uploads/logos/'.$name;

			if($logo->save()) {

			}
		} else {
			$logo->delete();
		}
		$this->redirect(array('index'));
	}
开发者ID:ruchida,项目名称:X2Engine,代码行数:20,代码来源:AdminController.php

示例4: move

 /**
  * Move the asset using the specified from and to paths
  * A shortcut for Media::copy() then Media::delete()
  *
  * @param string $pathfrom The virtual path source
  * @param string $pathto The virtual path destination
  * @return boolean true on success
  */
 public static function move($pathfrom, $pathto)
 {
     if (Media::copy($pathfrom, $pathto)) {
         return Media::delete($pathfrom);
     } else {
         return false;
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:16,代码来源:media.php

示例5: save


//.........这里部分代码省略.........
     curl_setopt($get_location, CURLOPT_RETURNTRANSFER, 1);
     $location = curl_exec($get_location);
     $location = json_decode($location);
     //	import dream
     if ($valid) {
         $date = DateTime::createFromFormat($this->dateFormat, $this->date, new DateTimeZone($this->timezone));
         $this->occur_date = $date->format('Y-m-d');
         if ($location) {
             $this->city = $location->city;
             $this->country = $location->country_name;
             $this->latitude = $location->latitude;
             $this->longitude = $location->longitude;
         } else {
             $this->latitude = "0";
             $this->longitude = "0";
         }
         $success = parent::save();
         if ($success) {
             $this->status = "Dream added!";
         } else {
             if (isset($this->errorMessage)) {
                 $this->status = $this->errorMessage;
             } else {
                 $this->status = "Error updating dream";
             }
             $valid = false;
         }
     }
     if (isset($image)) {
         if (!is_null($this->id) && !empty($this->id)) {
             $image->dream_id = $this->id;
             $image->save();
         } else {
             $image->delete();
         }
         $this->logger->log($image->logger->log);
     }
     if (isset($audio)) {
         if (!is_null($this->id) && !empty($this->id)) {
             $audio->dream_id = $this->id;
             $audio->save();
         } else {
             $audio->delete();
         }
         $this->logger->log($audio->logger->log);
     }
     $tags = array();
     //	add dream tags
     if ($valid && $this->useAlchemy) {
         $kb = strlen($this->description) / 1024;
         if ($kb <= 150) {
             $alchemy = new AlchemyAPI($this->alchemyApiKey);
             $params = array();
             $params['maxRetrieve'] = 20;
             $params['keywordExtractMode'] = 'strict';
             $params['sentiment'] = 1;
             $params['showSourceText'] = 0;
             try {
                 $result = $alchemy->keywords('text', $this->description, $params);
                 $this->logger->log("alchemy " . $result['status'] . ", " . (isset($result['keywords']) ? count($result['keywords']) : 0) . " keywords, " . $this->description);
             } catch (Exception $e) {
                 $this->logger->log("alchemy, " . $result['status'] . ", " . $result['statusInfo']);
             }
             if (isset($result) && $result['status'] == "OK") {
                 foreach ($result['keywords'] as $keyword) {
                     $tag = stripslashes($keyword['text']);
开发者ID:npedrini,项目名称:artefacts,代码行数:67,代码来源:dream.class.php

示例6: isset

<?php

include_once 'config/database.php';
include_once 'repository/Media.php';
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Property id not found.');
$database = new Database();
$db = $database->getConnection();
$media = new Media($db);
$media->id = $id;
$media->readOne();
$imageName = htmlspecialchars($media->newImageName, ENT_QUOTES);
$output_dir = "uploads/";
$dir = opendir($output_dir);
$media->delete();
unlink($output_dir . $imageName);
closedir($dir);
开发者ID:KevinLegara,项目名称:Testing,代码行数:16,代码来源:deleteImage.php

示例7: saveFeedItem


//.........这里部分代码省略.........
				}

				if ($filtered) return false;
			}

			if (preg_match('/\((.[^\)]+)\)$/Ui', trim($item['author']), $_matches)) $item['author'] = $_matches[1];
			$item['author']=$db->escape($db->lessen(UTF8::correct($item['author'])));
			$item['permalink']=$db->escape($db->lessen(UTF8::correct($item['permalink'])));
			$item['description']=$db->escape($db->lessen(UTF8::correct(trim($item['description'])),65535));
			
			$enclosures = array();
			foreach($item['enclosures'] as $en) {
				array_push($enclosures, $en['url']);
			}

			$enclosureString=$db->escape($db->lessen(UTF8::correct(implode('|',$enclosures))));				

			$deadLine=0;
			$feedLife = Settings::get('archivePeriod');
			if ($feedLife > 0) $deadLine=gmmktime()-($feedLife*86400);

			requireComponent('Bloglounge.Data.FeedItems');

			$oldTags = null;
			$id = FeedItem::getIdByURL($item['permalink']);
			if($id === false && isset($item['guid'])) {
				$item['guid']=$db->escape($db->lessen(UTF8::correct($item['guid'])));
				$id = FeedItem::getIdByURL($item['guid']);
			}

			$item['author'] = Feed::getAuthor($item, $feedId, $id);
			$item['title'] = Feed::getTitle($item, $feedId, $id);

			$affected = 0;
			$isRebuildData = false;

			$summarySave = Settings::get('summarySave');
			$description = $item['description'];
			if(Validator::getBool($summarySave)) { // summarySave
				$description = func::stripHTML($item['description'].'>');
				if (substr($description, -1) == '>') $description = substr($description, 0, strlen($description) - 1);
				$description = $db->lessen(func::htmltrim($description), 1000, '');
			}
			
			if (preg_match("/^[0-9]+$/",$id)) {
				$baseItem = FeedItem::getFeedItem($id);
			//	$baseItem['title']=$db->escape(UTF8::correct($baseItem['title']));
			//	$baseItem['description']=$db->escape(UTF8::correct(trim($baseItem['description'])));

				if(($baseItem['title']!=$item['title'])) {
					$isRebuildData = true;
					$tags = FeedItem::get($id, 'tags');
					requireComponent('LZ.PHP.Media');
					Media::delete($id);

					$oldTags = func::array_trim(explode(',', $tags));
					$db->execute("UPDATE {$database['prefix']}FeedItems SET author = '{$item['author']}', title = '{$item['title']}', description = '{$description}', tags = '$tagString', enclosure = '$enclosureString', written = {$item['written']} WHERE id = $id");
				}
			} else {
				if ($item['written']==0)
					$item['written']=gmmktime();
				if ($item['written']>$deadLine) {
					$db->execute("INSERT INTO {$database['prefix']}FeedItems (feed, author, permalink, title, description, tags, enclosure, written, feedVisibility) VALUES ($feedId, '{$item['author']}', '{$item['permalink']}', '{$item['title']}', '{$description}', '$tagString', '$enclosureString', {$item['written']},'{$feedVisibility}')");

					$id =$db->insertId();
					$db->execute('UPDATE '.$database['prefix'].'Feeds SET feedCount=feedCount+1 WHERE id="'.$feedId.'"');
					if (isset($this)) $this->updated++;
				}
				$isRebuildData = true;
			}			

			if(Validator::getBool(Settings::get('saveImages'))) {
				if($description = FeedItem::saveImages($feedId, $id, $item)) {
					$db->execute("UPDATE {$database['prefix']}FeedItems SET description = '{$description}' WHERE id = $id");
				}
			}
			
			$item = $event->on('Add.updateFeedItem', array($feedId, $id, $item));
			if(count($item)==3) $item = $item[2];
	
			$result = false;
			if($isRebuildData) {
				requireComponent('Bloglounge.Data.Groups');
				GroupCategory::buildGroupCategory($id, $feedId, $item['tags']);

				Tag::buildTagIndex($id, $item['tags'], $oldTags);
					

				Category::buildCategoryRelations($id, $item['tags'], $oldTags);
				
				$isSaveThumbnail = FeedItem::cacheThumbnail($id, $item);

				// 썸네일 저장 이벤트
				$event->on('Add.thumbnailSave',array($item, $feedId, $id, $isSaveThumbnail));
				
				$result = true;
			}

			return $result;
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:LZ.PHP.Feeder.php

示例8: deleteByFeedId

		function deleteByFeedId($feedId) {
			global $database, $db;

			$itemIds = array();

			requireComponent('LZ.PHP.Media');
			requireComponent('Bloglounge.Data.Category');
			requireComponent('Bloglounge.Data.Groups');

			$result = $db->queryAll("SELECT id FROM {$database['prefix']}FeedItems WHERE feed='$feedId'");
			if($result) {
				foreach($result as $item) {
					Media::delete($item['id']);
					array_push($itemIds, $item['id']);			
				}

				$itemIds = array_unique($itemIds);
				$categoryIds = array();
				foreach($itemIds as $itemId) {
					$result = $db->queryAll('SELECT category FROM '.$database['prefix'].'Categoryrelations WHERE item = ' . $itemId,MYSQL_ASSOC);
					foreach($result as $item) {
						array_push($categoryIds, $item['category']);
					}				
				}

				$categoryIds = array_unique($categoryIds);

				$itemStr = implode(',', $itemIds);	
				
				
				$db->execute("DELETE FROM {$database['prefix']}CategoryRelations WHERE item IN ($itemStr)"); // clear CategoryRelations

				$db->execute("DELETE FROM {$database['prefix']}TagRelations WHERE item IN ($itemStr)"); // clear TagRelations
				
				if ($db->execute('DELETE FROM '.$database['prefix'].'FeedItems WHERE feed='.$feedId)) {

					foreach($categoryIds as $categoryId) {
						Category::rebuildCount($categoryId);
					}
					return true;
				} else {
					return false;
				}
			}

			return true;
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:47,代码来源:Bloglounge.Data.FeedItems.php

示例9: Session

<?php

require_once '../model/paths.php';
$session = new Session();
if (!$session->isLogin) {
    redirect("../login.php");
}
$database = new Database();
$user = new User();
$post = new Post();
$media = new Media();
// delete media
if (isset($_POST['mediaId'])) {
    $mediaId = $database->escapeString($_POST['mediaId']);
    $media->setMediaId($mediaId);
    if ($media->delete($database)) {
        echo "true";
    } else {
        echo "false";
    }
}
开发者ID:jetmirhaxhisefa,项目名称:rezervime,代码行数:21,代码来源:deleteMedia.php

示例10: actionToggleDefaultLogo

 /**
  * Reverts the logo back to X2Engine.
  */
 public function actionToggleDefaultLogo()
 {
     $adminProf = Yii::app()->params->adminProfile;
     $logo = Media::model()->findByAttributes(array('associationId' => $adminProf->id, 'associationType' => 'logo'));
     if (!isset($logo)) {
         $logo = new Media();
         $logo->associationType = 'logo';
         $name = 'yourlogohere.png';
         $logo->associationId = $adminProf->id;
         $logo->fileName = 'uploads/protected/logos/' . $name;
         if ($logo->save()) {
         }
     } else {
         if ($logo->fileName != 'uploads/protected/logos/yourlogohere.png') {
             $logo->delete();
         }
     }
     $this->redirect(array('index'));
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:22,代码来源:AdminController.php


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