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

Changeset 13560


Ignore:
Timestamp:
Jul 13, 2010, 11:49:21 PM (12 years ago)
Author:
shingo
Message:

refs #158:コミュニティ画像投稿機能開発の差分の取り込み(opCommunityTopicPlugin-100628[git diff fc81fbb569d1a5f12a43.])

Location:
OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/apps/pc_frontend/modules/communityTopic/templates/editSuccess.php

    r10557 r13560  
    33$options['title'] = __('Edit the topic');
    44$options['url'] = url_for('communityTopic_update', $communityTopic);
     5$options['isMultipart'] = true;
    56op_include_form('formCommunityTopic', $form, $options);
    67?>
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/apps/pc_frontend/modules/communityTopic/templates/newSuccess.php

    r10557 r13560  
    33$options['title'] = __('Create a new topic');
    44$options['url'] = url_for('communityTopic_create', $community);
     5$options['isMultipart'] = true;
    56op_include_form('formCommunityTopic', $form, $options);
    67?>
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/apps/pc_frontend/modules/communityTopic/templates/showSuccess.php

    r13534 r13560  
    1616</div>
    1717<div class="body">
     18<?php if (count($images = $communityTopic->getImages()) != 0): ?>
     19<ul class="photo">
     20<?php foreach ($images as $image): ?>
     21<li><a href="<?php echo sf_image_path($image->File) ?>" target="_blank"><?php echo image_tag_sf_image($image->File, array('size' => '120x120')) ?></a></li>
     22<?php endforeach; ?>
     23</ul>
     24<?php endif; ?>
    1825<p class="text">
    1926<?php echo op_url_cmd(nl2br($communityTopic->getBody())) ?>
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/config/doctrine/schema.yml

    r12351 r13560  
    11options:
    22  charset: utf8
    3 actAs: [Timestampable]
    43
    54CommunityTopic:
     5  actAs:
     6    opCommunityTopicPluginImagesBehavior:
     7    Timestampable:
    68  columns:
    79    id: { type: integer(4), primary: true, autoincrement: true }
     
    1820
    1921CommunityTopicComment:
     22  actAs:
     23    opCommunityTopicPluginImagesBehavior:
     24    Timestampable:
    2025  columns:
    2126    id: { type: integer(4), primary: true, autoincrement: true }
     
    3136
    3237CommunityEvent:
     38  actAs:
     39    opCommunityTopicPluginImagesBehavior:
     40    Timestampable:
    3341  columns:
    3442    id: { type: integer(4), primary: true, autoincrement: true }
     
    5058
    5159CommunityEventComment:
     60  actAs:
     61    opCommunityTopicPluginImagesBehavior:
     62    Timestampable:
    5263  columns:
    5364    id: { type: integer(4), primary: true, autoincrement: true }
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/lib/action/opCommunityTopicPluginTopicActions.class.php

    r12519 r13560  
    236236  {
    237237    $form->bind(
    238       $request->getParameter($form->getName())
     238      $request->getParameter($form->getName()),
     239      $request->getFiles($form->getName())
    239240    );
    240241
     
    242243    {
    243244      $communityTopic = $form->save();
    244 
    245245      $this->redirect('@communityTopic_show?id='.$communityTopic->getId());
    246246    }
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/lib/form/doctrine/PluginCommunityTopicForm.class.php

    r11642 r13560  
    3131    unset($this['topic_updated_at']);
    3232
     33    if (sfConfig::get('app_community_topic_is_upload_images', true))
     34    {
     35      $images = array();
     36      if (!$this->isNew())
     37      {
     38        $images = $this->getObject()->getImagesWithNumber();
     39      }
     40
     41      $max = (int)sfConfig::get('app_community_topic_max_image_file_num', 3);
     42      for ($i = 1; $i <= $max; $i++)
     43      {
     44        $key = 'photo_'.$i;
     45
     46        if (isset($images[$i]))
     47        {
     48          $image = $images[$i];
     49        }
     50        else
     51        {
     52          $image = new CommunityTopicImage();
     53          $image->setCommunityTopic($this->getObject());
     54          $image->setNumber($i); 
     55        }
     56        $imageForm = new CommunityTopicImageForm($image);
     57        $imageForm->getWidgetSchema()->setFormFormatterName('list');
     58        $this->embedForm($key, $imageForm, '<ul id="community_topic_'.$key.'">%content%</ul>');
     59      }
     60    }
    3361    $this->setWidget('name', new sfWidgetFormInput());
    3462    $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('community_topic_form');
    3563  }
     64
     65  public function updateObject($values = null)
     66  {
     67    $object = parent::updateObject($values);
     68
     69    foreach ($this->embeddedForms as $key => $form)
     70    {
     71      if (!($form->getObject() && $form->getObject()->File != null))
     72      {
     73        unset($this->embeddedForms[$key]);
     74      }
     75    }
     76
     77    return $object;
     78  }
    3679}
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/shingo_uploader/lib/model/doctrine/PluginCommunityTopic.class.php

    r13486 r13560  
    5353    $this->getCommunity()->getImageFilename();
    5454  }
     55
     56  public function getImagesWithNumber()
     57  {
     58    $images = $this->getImages();
     59    $result = array();
     60    foreach ($images as $image)
     61    {
     62      $result[$image->number] = $image;
     63    }
     64
     65    return $result;
     66  }
    5567}
Note: See TracChangeset for help on using the changeset viewer.