function op_smt_diary_get_post_image_form($diaryImages) { $html = array(); if (!sfConfig::get('app_diary_is_upload_images')) { return $html; } $html[] = '<table class="file_list">'; $max = sfConfig::get('app_diary_max_image_file_num', 3); for ($i = 1; $i <= $max; $i++) { $tagName = 'diary_photo_' . $i; $html[] = '<tr>'; $label = label_for(__('Photo') . $i, $tagName); $html[] = content_tag('td', $label, array('class' => 'file_label')); $html[] = '<td>'; if (isset($diaryImages[$i])) { $diaryImage = op_api_diary_image($diaryImages[$i], '48x48'); $html[] = content_tag('p', link_to($diaryImage['imagetag'], $diaryImage['filename'], array('rel' => 'lightbox[image]'))); $html[] = content_tag('input', '', array('type' => 'checkbox', 'name' => $tagName . '_photo_delete', 'id' => $tagName . '_photo_delete')); $html[] = label_for(' ' . __('remove the current photo'), $tagName . '_photo_delete'); } $attr = array('type' => 'file', 'name' => $tagName, 'id' => $tagName); $html[] = content_tag('input', '', $attr); $html[] = '</td></tr>'; } $html[] = '</table>'; return $html; }
function op_api_diary_comment($comment) { if ($comment) { $images = array(); if ($comment->getHasImages()) { foreach ($comment->getDiaryCommentImages() as $image) { $images[] = op_api_diary_image($image); } } return array('id' => $comment->getId(), 'diary_id' => $comment->getDiaryId(), 'number' => $comment->getNumber(), 'member' => op_api_member($comment->getMember()), 'body' => nl2br($comment->getBody()), 'ago' => op_format_activity_time(strtotime($comment->getCreatedAt())), 'created_at' => $comment->getCreatedAt(), 'images' => $images); } }
<?php use_helper('opDiary'); $data = array(); if (isset($diary)) { $data = op_api_diary($diary); $images = $diary->getDiaryImages(); foreach ($images as $image) { $data['images'][] = op_api_diary_image($image); } $nextDiary = $diary->getNext($diary->getMemberId()); $nextDiary != false ? $data['next'] = $nextDiary->getId() : ($data['next'] = null); $prevDiary = $diary->getPrevious($diary->getMemberId()); $prevDiary != false ? $data['prev'] = $prevDiary->getId() : ($data['prev'] = null); $data['editable'] = $diary->isAuthor($memberId); } return array('status' => 'success', 'data' => $data);
for ($i = 1; $i <= 3; $i++) { ?> <tr> <td class="file_label"><label for="diary_photo_<?php echo $i; ?> "><?php echo __('Photo') . $i; ?> </label></td> <td> <?php if (isset($diaryImages[$i])) { ?> <?php $diaryImage = op_api_diary_image($diaryImages[$i]); ?> <p><a href="<?php echo $diaryImage['filename']; ?> "><?php echo $diaryImage['imagetag']; ?> </a></p> <input type="checkbox" name="diary_photo_<?php echo $i; ?> _photo_delete" id="diary_photo_<?php echo $i; ?> _photo_delete" />