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

Changeset 12099


Ignore:
Timestamp:
Jul 2, 2009, 5:46:02 PM (11 years ago)
Author:
fukamachi
Message:

#4019 add 'search target' parameter of topic search on pc_frontend. and renamed form class.

Location:
OpenPNE/branches/work/fukamachi/topic_search
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/fukamachi/topic_search/apps/pc_frontend/i18n/form_community.ja.xml

    r12066 r12099  
    2323        <target>検索対象</target>
    2424      </trans-unit>
     25      <trans-unit id="6">
     26        <source>Type</source>
     27        <target>種類</target>
     28      </trans-unit>
     29      <trans-unit id="7">
     30        <source>In Community</source>
     31        <target>コミュニティ内</target>
     32      </trans-unit>
     33      <trans-unit id="8">
     34        <source>All Community</source>
     35        <target>すべてのコミュニティ</target>
     36      </trans-unit>
    2537    </body>
    2638  </file>
  • OpenPNE/branches/work/fukamachi/topic_search/apps/pc_frontend/modules/communityTopic/templates/searchSuccess.php

    r12066 r12099  
    77  'method'   => 'get'
    88);
     9if (!$communityId)
     10{
     11  unset($form['target']);
     12  unset($form['id']);
     13}
    914
    10 op_include_form('searchCommunityTopic', $filters, $options);
     15op_include_form('searchCommunityTopic', $form, $options);
    1116?>
    1217
     
    2934  'link_to_page'   => 'communityTopic/search?page=%d',
    3035  'list'           => $list,
     36  'link_to_detail' => $link_to_detail,
    3137);
    32 if ('topic' === $type)
    33 {
    34   $options['link_to_detail'] = 'communityTopic/show?id=%id';
    35 }
    36 else if ('event' === $type)
    37 {
    38   $options['link_to_detail'] = 'communityEvent/show?id=%id';
    39 }
    4038
    4139include_partial('partsSearchResultList', $options);
  • OpenPNE/branches/work/fukamachi/topic_search/lib/action/opCommunityTopicPluginTopicActions.class.php

    r12066 r12099  
    197197  public function executeSearch($request)
    198198  {
    199     $params = array();
    200     if ($request->hasParameter('keyword'))
    201     {
    202       $params['keyword'] = $request->getParameter('keyword');
    203     }
    204     $params['type'] = $request->getParameter('type', 'topic');
    205 
    206     $this->filters = new PluginCommunityTopicFormFilter();
    207     $this->filters->bind($params);
     199    $params = array(
     200      'keyword' => $request->getParameter('keyword'),
     201      'target' => $request->getParameter('target', 'in_community'),
     202      'type' => $request->getParameter('type', 'topic'),
     203      'id' => $request->getParameter('id'),
     204    );
     205
     206    $this->form = new PluginCommunityTopicSearchForm();
     207    $this->form->bind($params);
    208208
    209209    if ('event' === $request->getParameter('type'))
    210210    {
    211       $this->pager = Doctrine::getTable('CommunityEvent')->getResultEventListPager($request->getParameter('id'), $request->getParameter('keyword'));
     211      $table = Doctrine::getTable('CommunityEvent');
    212212      $this->link_to_detail = 'communityEvent/show?id=%d';
    213213      $this->type = 'event';
     
    215215    else
    216216    {
    217       $this->pager = Doctrine::getTable('CommunityTopic')->getResultTopicListPager($request->getParameter('id'), $request->getParameter('keyword'));
     217      $table = Doctrine::getTable('CommunityTopic');
    218218      $this->link_to_detail = 'communityTopic/show?id=%d';
    219219      $this->type = 'topic';
    220220    }
     221    $this->communityId = $request->getParameter('id');
     222
     223    $q = $table->getSearchQuery($request->getParameter('id'), $request->getParameter('target'), $request->getParameter('keyword'));
     224    $this->pager = $table->getResultListPager($q);
    221225
    222226    return sfView::SUCCESS;
  • OpenPNE/branches/work/fukamachi/topic_search/lib/filter/doctrine/PluginCommunityTopicFormFilter.class.php

    r12089 r12099  
    22
    33/**
    4  * CommunityTopic filter form.
     4 * PluginCommunityTopic form.
    55 *
    6  * @package    OpenPNE
    7  * @subpackage filter
    8  * @author     Eitarow Fukamachi <fukamachi@tejimaya.net>
     6 * @package    filter
     7 * @subpackage CommunityTopic *
     8 * @version    SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
    99 */
    10 class PluginCommunityTopicFormFilter extends BaseCommunityTopicFormFilter
     10abstract class PluginCommunityTopicFormFilter extends BaseCommunityTopicFormFilter
    1111{
    12   public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
    13   {
    14     return parent::__construct($defaults, $options, false);
    15   }
    16 
    17   public function configure()
    18   {
    19     $i18n = sfContext::getInstance()->getI18N();
    20     $types = array(
    21       'topic' => $i18n->__('Topic'),
    22       'event' => $i18n->__('Event'),
    23     );
    24 
    25     $widgets = array(
    26       'keyword' => new sfWidgetFormInput(array(
    27         'label' => $i18n->__('Keyword', array(), 'form_community'),
    28       )),
    29       'type' => new sfWIdgetFormChoice(array(
    30         'choices' => $types,
    31         'label' => $i18n->__('Target', array(), 'form_community'),
    32       )),
    33     );
    34 
    35     $validators = array(
    36       'keyword' => new opValidatorSearchQueryString(array('required' => false)),
    37       'type' => new sfValidatorChoice(array('choices' => array_keys($types), 'required' => false)),
    38     );
    39 
    40     $this->setWidgets($widgets);
    41     $this->setValidators($validators);
    42   }
    4312}
  • OpenPNE/branches/work/fukamachi/topic_search/lib/model/doctrine/PluginCommunityEventTable.class.php

    r12066 r12099  
    8686  }
    8787
    88   protected function getSearchQuery($communityId, $keyword = null)
     88  public function getSearchQuery($communityId = null, $target = 'all', $keyword = null)
    8989  {
    9090    $q = $this->createQuery();
    9191
    92     if ($communityId)
     92    if ('in_community' === $target && $communityId)
    9393    {
    9494      $q->where('community_id = ?', $communityId);
     
    109109  }
    110110
    111   public function getResultEventListPager($communityId, $keyword = null, $page = 1, $size = 20)
     111  public function getResultListPager(Doctrine_Query $query, $page = 1, $size = 20)
    112112  {
    113113    $pager = new sfDoctrinePager('CommunityEvent', $size);
    114     $pager->setQuery($this->getSearchQuery($communityId, $keyword));
     114    $pager->setQuery($query);
    115115    $pager->setPage($page);
    116116    $pager->init();
  • OpenPNE/branches/work/fukamachi/topic_search/lib/model/doctrine/PluginCommunityTopicTable.class.php

    r12066 r12099  
    7373  }
    7474
    75   protected function getSearchQuery($communityId, $keyword = null)
     75  public function getSearchQuery($communityId = null, $target = 'all', $keyword = null)
    7676  {
    7777    $q = $this->createQuery();
    7878
    79     if ($communityId)
     79    if ('in_community' === $target && $communityId)
    8080    {
    8181      $q->where('community_id = ?', $communityId);
     
    9696  }
    9797
    98   public function getResultTopicListPager($communityId, $keyword = null, $page = 1, $size = 20)
     98  public function getResultListPager(Doctrine_Query $query, $page = 1, $size = 20)
    9999  {
    100100    $pager = new sfDoctrinePager('CommunityTopic', $size);
    101     $pager->setQuery($this->getSearchQuery($communityId, $keyword));
     101    $pager->setQuery($query);
    102102    $pager->setPage($page);
    103103    $pager->init();
Note: See TracChangeset for help on using the changeset viewer.