ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 9862


Ignore:
Timestamp:
Jan 3, 2009, 7:17:55 PM (11 years ago)
Author:
ogawa
Message:

#3346:added support for uploading images to a diary comment

Location:
OpenPNE3/plugins/opDiaryPlugin/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/showSuccess.php

    r9859 r9862  
    2929<?php echo link_to($comment->getMember()->getName(), 'member/show?id='.$comment->getMemberId()) ?><br>
    3030<?php echo nl2br($comment->getBody()) ?><br>
     31<?php foreach ($comment->getDiaryCommentImages() as $image): ?>
     32View Image<br>
     33<?php endforeach; ?>
    3134<?php endforeach; ?>
    3235<?php endif; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/showSuccess.php

    r9859 r9862  
    4242<dt><?php echo format_datetime($comment->getCreatedAt(), 'f') ?></dt>
    4343<dd><p><?php echo $comment->getMember()->getName() ?></p></dd>
     44<?php $images = $comment->getDiaryCommentImages() ?>
     45<?php if (count($images)): ?>
     46<dd>
     47<ul class="photo">
     48<?php foreach ($images as $image): ?>
     49<li><?php echo image_tag_sf_image($image->getFile(), array('size' => '120x120')) ?></li>
     50<?php endforeach; ?>
     51</ul>
     52</dd>
     53<?php endif; ?>
    4454<dd><p><?php echo nl2br($comment->getBody()) ?></p></dd>
    4555<?php if ($diary->getMemberId() === $sf_user->getMemberId() || $comment->getMemberId() === $sf_user->getMemberId()): ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/form/DiaryCommentForm.class.php

    r9731 r9862  
    1818    unset($this['created_at']);
    1919    unset($this['updated_at']);
     20
     21    for ($i = 1; $i <= 3; $i++)
     22    {
     23      $key = 'photo_'.$i;
     24      $this->setWidget($key, new sfWidgetFormInputFile());
     25      $this->setValidator($key, new opValidatorImageFile(array('required' => false)));
     26    }
     27  }
     28
     29  public function save($con = null)
     30  {
     31    $comment = parent::save();
     32
     33    for ($i = 1; $i <= 3; $i++)
     34    {
     35      $key = 'photo_'.$i;
     36      if ($this->getValue($key))
     37      {
     38        $file = new File();
     39        $file->setFromValidatedFile($this->getValue($key));
     40        $file->setName('dc_'.$comment->getId().'_'.$file->getName());
     41
     42        $image = new DiaryCommentImage();
     43        $image->setDiaryComment($comment);
     44        $image->setFile($file);
     45        $image->save();
     46      }
     47    }
     48
     49    return $comment;
    2050  }
    2151}
Note: See TracChangeset for help on using the changeset viewer.