本文整理汇总了PHP中Picture::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Picture::create方法的具体用法?PHP Picture::create怎么用?PHP Picture::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Picture
的用法示例。
在下文中一共展示了Picture::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']);
Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']);
Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']);
Picture::create(['album_id' => 1, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png']);
Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 5, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 9, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
Picture::create(['album_id' => 13, 'title' => '戏剧人生', 'picture' => 'http://7xk6xh.com1.z0.glb.clouddn.com/album_05.png']);
}
示例2: compile
protected function compile()
{
if ($this->defineRoot) {
$objPage = \PageModel::findByPk($this->rootPage);
} else {
global $objPage;
}
if (null === $objPage) {
return;
}
$intOffset = (int) $this->levelOffset;
// Random image
if ($this->randomPageImage) {
$intOffset = -1;
}
$arrImage = PageImage::getOne($objPage, $intOffset, (bool) $this->inheritPageImage);
if (null === $arrImage) {
return;
}
$arrSize = deserialize($this->imgSize);
$arrImage['src'] = $this->getImage($arrImage['path'], $arrSize[0], $arrSize[1], $arrSize[2]);
$this->Template->setData($arrImage);
$picture = \Picture::create($arrImage['path'], $arrSize)->getTemplateData();
$picture['alt'] = specialchars($arrImage['alt']);
$this->Template->picture = $picture;
if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrImage['src']))) !== false) {
$this->Template->size = ' ' . $imgSize[3];
}
// Add page information to template
global $objPage;
$this->Template->currentPage = $objPage->row();
}
示例3: post5_submit
public function post5_submit()
{
$pic = $this->input_post('pic', true, true);
$picture = Picture::create(array('file_name' => ''));
$picture->file_name->put($pic);
echo '<meta http-equiv="Content-type" content="text/html; charset=utf-8" /><pre>';
var_dump($picture->file_name->url());
echo "</pre><hr/><a href='" . base_url(array($this->get_class())) . "'>back</a>";
}
示例4: test_custom_attributes
function test_custom_attributes()
{
$element = Picture::create('element', $this->attachment, array('sizes' => array('thumbnail', 'medium', 'large'), 'attributes' => array('picture' => array('id' => 'custom-id', 'class' => 'picture-element'), 'source' => array('data-foo' => 'bar'), 'img' => array('id' => 'responsive-image'))));
$expected = '<picture id="custom-id" class="picture-element">';
$expected .= '<source data-foo="bar" srcset="http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg" media="(min-width: 600px)">';
$expected .= '<source data-foo="bar" srcset="http://example.org/wp-content/uploads/IMG_2089-600x800.jpg" media="(min-width: 480px)">';
$expected .= '<img src="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" id="responsive-image">';
$expected .= '</picture>';
$this->assertEquals($expected, $element);
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if (!is_null($request->file('thumbnail'))) {
$im = $request->file('thumbnail');
// estension de l'image
$ext = $im->getClientOriginalExtension();
$uri = str_random(12) . '.' . $ext;
$im->move(env('UPLOAD_PATH', './uploads'), $uri);
Picture::create(['uri' => $uri, 'size' => $im->getSize(), 'type' => $ext, 'product_id' => $product->id]);
}
}
示例6: test_custom_media_queries
function test_custom_media_queries()
{
$element = Picture::create('element', $this->attachment, array('sizes' => array('thumbnail', 'medium', 'large'), 'media_queries' => array('medium' => 'min-width: 500px', 'large' => 'min-width: 1024px')));
$expected = '<picture >';
$expected .= '<!--[if IE 9]><video style="display: none;"><![endif]-->';
$expected .= '<source srcset="http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg" media="(min-width: 1024px)">';
$expected .= '<source srcset="http://example.org/wp-content/uploads/IMG_2089-600x800.jpg" media="(min-width: 500px)">';
$expected .= '<!--[if IE 9]></video><![endif]-->';
$expected .= '<img srcset="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" >';
$expected .= '</picture>';
$this->assertEquals($expected, $element);
}
示例7: test_custom_media_queries
function test_custom_media_queries()
{
$style = Picture::create('style', $this->attachment, array('selector' => '#hero', 'sizes' => array('medium', 'large'), 'media_queries' => array('large' => 'min-width: 800px')));
$expected = '<style>';
$expected .= '#hero {';
$expected .= 'background-image: url("http://example.org/wp-content/uploads/IMG_2089-600x800.jpg");';
$expected .= '}';
$expected .= '@media screen and (min-width: 800px) {';
$expected .= '#hero{background-image: url("http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg");}';
$expected .= '}';
$expected .= '</style>';
$this->assertEquals($expected, $style);
}
示例8: test_custom_media_queries
function test_custom_media_queries()
{
$element = Picture::create('span', $this->attachment, array('sizes' => array('thumbnail', 'medium', 'large'), 'media_queries' => array('medium' => 'min-width: 500px', 'large' => 'min-width: 1024px')));
$expected = '<span data-picture data-alt="">';
$expected .= '<span data-src="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" ></span>';
$expected .= '<span data-src="http://example.org/wp-content/uploads/IMG_2089-600x800.jpg" data-media="(min-width: 500px)" ></span>';
$expected .= '<span data-src="http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg" data-media="(min-width: 1024px)" ></span>';
$expected .= '<noscript>';
$expected .= '<img src="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" alt="">';
$expected .= '</noscript>';
$expected .= '</span>';
$this->assertEquals($expected, $element);
}
示例9: test_array_with_density
function test_array_with_density()
{
$element = Picture::create('element', $this->attachment, array('retina' => array('1.5x')));
$expected = '<picture >';
$expected .= '<!--[if IE 9]><video style="display: none;"><![endif]-->';
$expected .= '<source srcset="http://example.org/wp-content/uploads/retina.jpg" media="(min-width: 1024px)">';
$expected .= '<source srcset="http://example.org/wp-content/uploads/retina-1024x1365.jpg, http://example.org/wp-content/uploads/retina-1536x2047.jpg 1.5x" media="(min-width: 600px)">';
$expected .= '<source srcset="http://example.org/wp-content/uploads/retina-600x800.jpg, http://example.org/wp-content/uploads/retina-900x1200.jpg 1.5x" media="(min-width: 480px)">';
$expected .= '<!--[if IE 9]></video><![endif]-->';
$expected .= '<img srcset="http://example.org/wp-content/uploads/retina-480x640.jpg, http://example.org/wp-content/uploads/retina-720x960.jpg 1.5x" >';
$expected .= '</picture>';
$this->assertEquals($expected, $element);
}
示例10: test_default
function test_default()
{
$img = Picture::create('img', $this->attachment, array('retina' => true));
$expected = '<img ';
$expected .= 'src="http://example.org/wp-content/uploads/retina-480x640.jpg" ';
$expected .= 'srcset="http://example.org/wp-content/uploads/retina-480x640.jpg 480w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-720x960.jpg 720w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-960x1280.jpg 960w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-600x800.jpg 600w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-900x1200.jpg 900w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1200x1600.jpg 1200w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1024x1365.jpg 1024w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1536x2047.jpg 1536w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-2048x2730.jpg 2048w, ';
$expected .= 'http://example.org/wp-content/uploads/retina.jpg 2448w" ';
$expected .= 'sizes="(min-width: 1024px) 2448px, (min-width: 600px) 1024px, (min-width: 480px) 600px, 480px"';
$expected .= '>';
$this->assertEquals($expected, $img);
}
示例11: test_array_of_multiple_densities_and_selected_sizes
function test_array_of_multiple_densities_and_selected_sizes()
{
$img = Picture::create('img', $this->attachment, array('retina' => array('1.5x', '2x'), 'sizes' => array('thumbnail', 'medium', 'large')));
$expected = '<img ';
$expected .= 'srcset="http://example.org/wp-content/uploads/retina-480x640.jpg 480w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-720x960.jpg 720w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-960x1280.jpg 960w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-600x800.jpg 600w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-900x1200.jpg 900w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1200x1600.jpg 1200w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1024x1365.jpg 1024w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-1536x2047.jpg 1536w, ';
$expected .= 'http://example.org/wp-content/uploads/retina-2048x2730.jpg 2048w" ';
$expected .= 'sizes="(min-width: 600px) 1024px, (min-width: 480px) 600px, 480px"';
$expected .= '>';
$this->assertEquals($expected, $img);
}
示例12: test_custom_attributes
function test_custom_attributes()
{
$img = Picture::create('img', $this->attachment, array('attributes' => array('id' => 'custom-id')));
$expected = '<img src="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg" srcset="http://example.org/wp-content/uploads/IMG_2089-480x640.jpg 480w, http://example.org/wp-content/uploads/IMG_2089-600x800.jpg 600w, http://example.org/wp-content/uploads/IMG_2089-1024x1365.jpg 1024w, http://example.org/wp-content/uploads/IMG_2089.jpg 2448w" sizes="(min-width: 1024px) 2448px, (min-width: 600px) 1024px, (min-width: 480px) 600px, 480px" id="custom-id">';
$this->assertEquals($expected, $img);
}
示例13: doReplace
//.........这里部分代码省略.........
}
if (\Validator::isUuid($strFile)) {
// Handle UUIDs
$objFile = \FilesModel::findByUuid($strFile);
if ($objFile === null) {
$arrCache[$strTag] = '';
break;
}
$strFile = $objFile->path;
} elseif (is_numeric($strFile)) {
// Handle numeric IDs (see #4805)
$objFile = \FilesModel::findByPk($strFile);
if ($objFile === null) {
$arrCache[$strTag] = '';
break;
}
$strFile = $objFile->path;
} else {
// Check the path
if (\Validator::isInsecurePath($strFile)) {
throw new \RuntimeException('Invalid path ' . $strFile);
}
}
// Check the maximum image width
if (\Config::get('maxImageWidth') > 0 && $width > \Config::get('maxImageWidth')) {
$width = \Config::get('maxImageWidth');
$height = null;
}
// Generate the thumbnail image
try {
// Image
if (strtolower($elements[0]) == 'image') {
$dimensions = '';
$imageObj = \Image::create($strFile, array($width, $height, $mode));
$src = $imageObj->executeResize()->getResizedPath();
$objFile = new \File(rawurldecode($src));
// Add the image dimensions
if (($imgSize = $objFile->imageSize) !== false) {
$dimensions = ' width="' . $imgSize[0] . '" height="' . $imgSize[1] . '"';
}
$arrCache[$strTag] = '<img src="' . TL_FILES_URL . $src . '" ' . $dimensions . ' alt="' . $alt . '"' . ($class != '' ? ' class="' . $class . '"' : '') . '>';
} else {
$picture = \Picture::create($strFile, array(0, 0, $size))->getTemplateData();
$picture['alt'] = $alt;
$picture['class'] = $class;
$pictureTemplate = new \FrontendTemplate($strTemplate);
$pictureTemplate->setData($picture);
$arrCache[$strTag] = $pictureTemplate->parse();
}
// Add a lightbox link
if ($rel != '') {
if (strncmp($rel, 'lightbox', 8) !== 0) {
$attribute = ' rel="' . $rel . '"';
} else {
$attribute = ' data-lightbox="' . substr($rel, 8) . '"';
}
$arrCache[$strTag] = '<a href="' . TL_FILES_URL . $strFile . '"' . ($alt != '' ? ' title="' . $alt . '"' : '') . $attribute . '>' . $arrCache[$strTag] . '</a>';
}
} catch (\Exception $e) {
$arrCache[$strTag] = '';
}
break;
// Files (UUID or template path)
// Files (UUID or template path)
case 'file':
if (\Validator::isUuid($elements[1])) {
示例14: addImageToTemplate
/**
* Add an image to a template
*
* @param object $objTemplate The template object to add the image to
* @param array $arrItem The element or module as array
* @param integer $intMaxWidth An optional maximum width of the image
* @param string $strLightboxId An optional lightbox ID
*/
public static function addImageToTemplate($objTemplate, $arrItem, $intMaxWidth = null, $strLightboxId = null)
{
/** @var \PageModel $objPage */
global $objPage;
try {
$objFile = new \File($arrItem['singleSRC'], true);
} catch (\Exception $e) {
$objFile = new \stdClass();
$objFile->imageSize = false;
}
$imgSize = $objFile->imageSize;
// Store the original dimensions
if ($imgSize !== false) {
$objTemplate->width = $imgSize[0];
$objTemplate->height = $imgSize[1];
}
$size = deserialize($arrItem['size']);
$arrMargin = TL_MODE == 'BE' ? array() : deserialize($arrItem['imagemargin']);
if (is_array($size)) {
if ($intMaxWidth === null) {
$intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth');
}
// Adjust the image size
if ($intMaxWidth > 0 && $imgSize !== false) {
// Subtract the margins before deciding whether to resize (see #6018)
if (is_array($arrMargin) && $arrMargin['unit'] == 'px') {
$intMargin = $arrMargin['left'] + $arrMargin['right'];
// Reset the margin if it exceeds the maximum width (see #7245)
if ($intMaxWidth - $intMargin < 1) {
$arrMargin['left'] = '';
$arrMargin['right'] = '';
} else {
$intMaxWidth = $intMaxWidth - $intMargin;
}
}
if ($size[0] > $intMaxWidth || !$size[0] && !$size[1] && $imgSize[0] > $intMaxWidth) {
// See #2268 (thanks to Thyon)
$ratio = $size[0] && $size[1] ? $size[1] / $size[0] : $imgSize[1] / $imgSize[0];
$size[0] = $intMaxWidth;
$size[1] = floor($intMaxWidth * $ratio);
}
}
// Disable responsive images in the back end (see #7875)
if (TL_MODE == 'BE') {
unset($size[2]);
}
}
try {
$src = \Image::create($arrItem['singleSRC'], $size)->executeResize()->getResizedPath();
$picture = \Picture::create($arrItem['singleSRC'], $size)->getTemplateData();
if ($src !== $arrItem['singleSRC']) {
$objFile = new \File(rawurldecode($src), true);
}
} catch (\Exception $e) {
\System::log('Image "' . $arrItem['singleSRC'] . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);
$src = '';
$picture = array('img' => array('src' => '', 'srcset' => ''), 'sources' => array());
}
// Image dimensions
if (($imgSize = $objFile->imageSize) !== false) {
$objTemplate->arrSize = $imgSize;
$objTemplate->imgSize = ' width="' . $imgSize[0] . '" height="' . $imgSize[1] . '"';
}
$picture['alt'] = specialchars($arrItem['alt']);
$picture['title'] = specialchars($arrItem['title']);
$objTemplate->picture = $picture;
// Provide an ID for single lightbox images in HTML5 (see #3742)
if ($strLightboxId === null && $arrItem['fullsize']) {
if ($objPage->outputFormat == 'xhtml') {
$strLightboxId = 'lightbox';
} else {
$strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $arrItem['id']), 0, 6) . ']';
}
}
// Float image
if ($arrItem['floating'] != '') {
$objTemplate->floatClass = ' float_' . $arrItem['floating'];
}
// Do not override the "href" key (see #6468)
$strHrefKey = $objTemplate->href != '' ? 'imageHref' : 'href';
// Image link
if ($arrItem['imageUrl'] != '' && TL_MODE == 'FE') {
$objTemplate->{$strHrefKey} = $arrItem['imageUrl'];
$objTemplate->attributes = '';
if ($arrItem['fullsize']) {
// Open images in the lightbox
if (preg_match('/\\.(jpe?g|gif|png)$/', $arrItem['imageUrl'])) {
// Do not add the TL_FILES_URL to external URLs (see #4923)
if (strncmp($arrItem['imageUrl'], 'http://', 7) !== 0 && strncmp($arrItem['imageUrl'], 'https://', 8) !== 0) {
$objTemplate->{$strHrefKey} = TL_FILES_URL . \System::urlEncode($arrItem['imageUrl']);
}
$objTemplate->attributes = $objPage->outputFormat == 'xhtml' ? ' rel="' . $strLightboxId . '"' : ' data-lightbox="' . substr($strLightboxId, 9, -1) . '"';
//.........这里部分代码省略.........
示例15: test_for_has_many
public function test_for_has_many()
{
$Property = new Property();
$this->assertEqual($Property->picture->getType(), 'hasMany');
$this->assertTrue(is_array($Property->pictures) && count($Property->pictures) === 0);
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 0);
$SeaViews = new Picture(array('title' => 'Sea views'));
$Property->picture->add($SeaViews);
$this->assertEqual($Property->picture->count(), 1);
$this->assertReference($Property->pictures[0], $SeaViews);
$Property->picture->add($SeaViews);
$this->assertEqual($Property->picture->count(), 1);
$this->assertNull($Property->pictures[0]->get('property_id'));
$MountainViews = new Picture(array('title' => 'Mountain views'));
$this->assertTrue($MountainViews->isNewRecord());
$Property->picture->add($MountainViews);
$this->assertEqual($Property->picture->count(), 2);
$this->assertTrue($Property->save());
$this->assertFalse($SeaViews->isNewRecord());
$this->assertFalse($MountainViews->isNewRecord());
$this->assertEqual($SeaViews->get('property_id'), $Property->getId());
$this->assertEqual($MountainViews->get('property_id'), $Property->getId());
$this->assertReference($SeaViews, $Property->pictures[0]);
$this->assertReference($MountainViews, $Property->pictures[1]);
$Property = new Property($Property->getId());
$Property->picture->load();
$this->assertEqual($Property->picture->association_id, 'pictures');
$this->assertEqual($Property->picture->count(), 2);
$Property->pictures = array();
$this->assertEqual($Property->picture->count(), 0);
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 0);
$Property->picture->load(true);
$this->assertEqual($Property->picture->count(), 2);
$this->assertEqual($Property->pictures[1]->getType(), 'Picture');
$Property->picture->delete($Property->pictures[1]);
$this->assertEqual($Property->picture->count(), 1);
$Property->picture->load(true);
$this->assertEqual($Property->picture->count(), 1);
$Property = $Property->find('first');
$Picture = new Picture();
$Pictures = $Picture->find();
$Property->picture->set($Pictures);
$this->assertEqual($Property->picture->count(), count($Pictures));
$Property = $Property->find('first');
$Property->picture->load();
$this->assertEqual($Property->picture->count(), count($Pictures));
$Picture = $Picture->find('first');
$Property->picture->set($Picture);
$this->assertEqual($Property->picture->count(), 1);
$this->assertTrue(in_array('pictures', $Property->getAssociatedIds()));
$Property = $Property->find('first', array('include' => 'pictures'));
$this->assertIdentical($Property->picture->count(), 1);
$this->assertEqual($Property->pictures[0]->getId(), $Picture->getId());
$this->assertTrue($Property->picture->delete($Property->pictures[0]));
$this->assertIdentical($Property->picture->count(), 0);
$Property =& $Property->find('first');
$this->assertIdentical($Property->picture->count(), 0);
//$this->assertTrue($Property =& $Property->find('first', array('include'=>'pictures')));
//$this->assertIdentical($Property->picture->count(), 0);
$Picture = new Picture();
$Alicia =& $Picture->create(array('title' => 'Alicia'));
$Bermi =& $Picture->create(array('title' => 'Bermi'));
$Hilario =& $Picture->create(array('title' => 'Hilario'));
$Property->picture->setByIds(array($Alicia->getId(), $Bermi->getId(), $Hilario->getId()));
$Property->set('description', 'Cool house');
$this->assertTrue($Property->save());
$this->assertTrue($Property =& $Property->findFirstBy('description', 'Cool house'));
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 3);
$FoundAlicia = $Property->picture->find('first', array('conditions' => array('title = ?', "Alicia")));
$this->assertEqual($Alicia->get('title') . $Alicia->getId(), $FoundAlicia->get('title') . $FoundAlicia->getId());
$FoundPals = $Property->picture->find();
$this->assertEqual(count($FoundPals), $Property->picture->count());
$titles = array();
foreach ($FoundPals as $FoundPal) {
$titles[] = $FoundPal->get('title');
}
sort($titles);
$this->assertEqual($titles, array('Alicia', 'Bermi', 'Hilario'));
$this->assertFalse($Property->picture->isEmpty());
$this->assertEqual($Property->picture->getSize(), 3);
$this->assertTrue($Property->picture->clear());
$this->assertTrue($Property->picture->isEmpty());
$this->assertEqual($Property->picture->getSize(), 0);
$Property = new Property();
$PoolPicture =& $Property->picture->build(array('title' => 'Pool'));
$this->assertReference($PoolPicture, $Property->pictures[0]);
$this->assertTrue($Property->pictures[0]->isNewRecord());
$this->assertEqual($PoolPicture->getType(), 'Picture');
$Property->set('description', 'Maui Estate');
$this->assertTrue($Property->save());
$this->assertTrue($MauiEstate = $Property->findFirstBy('description', 'Maui Estate', array('include' => 'pictures')));
$this->assertEqual($MauiEstate->pictures[0]->get('title'), 'Pool');
$Property = new Property(array('description' => 'Villa Altea'));
$GardenPicture =& $Property->picture->create(array('title' => 'Garden'));
$this->assertReference($GardenPicture, $Property->pictures[0]);
$this->assertTrue($GardenPicture->isNewRecord());
$Property = new Property(array('description' => 'Villa Altea'));
//.........这里部分代码省略.........