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

Changeset 10208


Ignore:
Timestamp:
Jan 18, 2009, 9:23:00 PM (11 years ago)
Author:
ebihara
Message:

#3451:unified the design/homeWidget action and the design/mobileHomeWidget action

Location:
OpenPNE3/trunk/apps/pc_backend/modules/design
Files:
3 added
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_backend/modules/design/actions/actions.class.php

    r10141 r10208  
    4747
    4848 /**
    49   * Executes home widget action
     49  * Executes widget action
    5050  *
    5151  * @param sfRequest $request A request object
    5252  */
    53   public function executeHomeWidget(sfWebRequest $request)
     53  public function executeWidget(sfWebRequest $request)
    5454  {
    55     $this->topWidgets = HomeWidgetPeer::retrieveTopWidgets();
    56     $this->sideMenuWidgets = HomeWidgetPeer::retrieveSideMenuWidgets();
    57     $this->contentsWidgets = HomeWidgetPeer::retrieveContentsWidgets();
    58     $this->widgetConfig = sfConfig::get('op_widget_list');
     55    $this->type = $request->getParameter('type', 'home');
     56    switch ($this->type)
     57    {
     58      case 'mobileHome':
     59        $this->widgets = array(
     60          'mobileTop'      => HomeWidgetPeer::retrieveMobileTopWidgets(),
     61          'mobileContents' => HomeWidgetPeer::retrieveMobileContentsWidgets(),
     62          'mobileBottom'   => HomeWidgetPeer::retrieveMobileBottomWidgets(),
     63        );
     64        break;
     65      default:
     66        $this->widgets = array(
     67          'top'      => HomeWidgetPeer::retrieveTopWidgets(),
     68          'sideMenu'     => HomeWidgetPeer::retrieveSideMenuWidgets(),
     69          'contents' => HomeWidgetPeer::retrieveContentsWidgets(),
     70        );
     71    }
    5972
    60     $this->sortForm = new HomeWidgetSortForm();
    61     $this->addForm = new HomeWidgetAddForm();
     73    $this->sortForm = new WidgetSortForm(array(), array('current_widgets' => $this->widgets));
     74    $this->addForm = new WidgetAddForm(array(), array('current_widgets' => $this->widgets));
     75
    6276    if ($request->isMethod(sfRequest::POST))
    6377    {
     
    6882        $this->sortForm->save();
    6983        $this->addForm->save();
    70         $this->redirect('design/homeWidget');
     84        $this->redirect('design/widget?type='.$this->type);
    7185      }
    7286    }
    73     return sfView::SUCCESS;
    7487  }
    7588
     
    153166
    154167 /**
    155   * Executes mobile home widget action
    156   *
    157   * @param sfRequest $request A request object
    158   */
    159   public function executeMobileHomeWidget(sfWebRequest $request)
    160   {
    161     $this->mobileTopWidgets = (array)HomeWidgetPeer::retrieveMobileTopWidgets();
    162     $this->mobileContentsWidgets = (array)HomeWidgetPeer::retrieveMobileContentsWidgets();
    163     $this->mobileBottomWidgets = (array)HomeWidgetPeer::retrieveMobileBottomWidgets();
    164     $this->widgetConfig = sfConfig::get('op_mobile_widget_list');
    165 
    166     $this->sortForm = new HomeWidgetSortForm(array(), array('is_mobile' => true));
    167     $this->addForm = new HomeWidgetAddForm();
    168     if ($request->isMethod(sfRequest::POST))
    169     {
    170       $this->sortForm->bind($request->getParameter('widget'));
    171       $this->addForm->bind($request->getParameter('new'));
    172       if ($this->sortForm->isValid() && $this->addForm->isValid())
    173       {
    174         $this->sortForm->save();
    175         $this->addForm->save();
    176         $this->redirect('design/mobileHomeWidget');
    177       }
    178     }
    179     return sfView::SUCCESS;
    180   }
    181 
    182  /**
    183168  * Executes mobile home widget plot action
    184169  *
  • OpenPNE3/trunk/apps/pc_backend/modules/design/config/view.yml

    r10179 r10208  
     1widgetSuccess:
     2  javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype]
     3
    14homeWidgetSuccess: &homeWidgetSuccess
    25  javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype]
  • OpenPNE3/trunk/apps/pc_backend/modules/design/lib/WidgetAddForm.class.php

    r10202 r10208  
    1010
    1111/**
    12  * Home Widget Add Form.
     12 * Widget Add Form.
    1313 *
    1414 * @package    OpenPNE
     
    1616 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    1717 */
    18 class HomeWidgetAddForm extends sfForm
     18class WidgetAddForm extends sfForm
    1919{
    2020  public function configure()
    2121  {
    22     $this->setValidator('top', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    23     $this->setValidator('sideMenu', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    24     $this->setValidator('contents', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
     22    $widgets = $this->getOption('current_widgets', array());
    2523
    26     $this->setValidator('mobileTop', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    27     $this->setValidator('mobileContents', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    28     $this->setValidator('mobileBottom', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
     24    foreach ($widgets as $key => $value)
     25    {
     26      $this->setValidator($key, new sfValidatorCallback(array('callback' => array($this, 'validate'))));
     27    }
    2928
    3029    $this->getWidgetSchema()->setNameFormat('new[%s]');
  • OpenPNE3/trunk/apps/pc_backend/modules/design/lib/WidgetSortForm.class.php

    r10202 r10208  
    1010
    1111/**
    12  * Home Widget Sort Form.
     12 * Widget Sort Form.
    1313 *
    1414 * @package    OpenPNE
     
    1616 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    1717 */
    18 class HomeWidgetSortForm extends sfForm
     18class WidgetSortForm extends sfForm
    1919{
    2020  public function configure()
    2121  {
    22     if ($this->getOption('is_mobile', false))
     22    $widgets = $this->getOption('current_widgets', array());
     23
     24    foreach ($widgets as $key => $value)
    2325    {
    24       $this->setValidator('mobileTop', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    25       $this->setValidator('mobileContents', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    26       $this->setValidator('mobileBottom', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    27     }
    28     else
    29     {
    30       $this->setValidator('top', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    31       $this->setValidator('sideMenu', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    32       $this->setValidator('contents', new sfValidatorCallback(array('callback' => array($this, 'validate'))));
     26      $this->setValidator($key, new sfValidatorCallback(array('callback' => array($this, 'validate'))));
    3327    }
    3428
  • OpenPNE3/trunk/apps/pc_backend/modules/design/templates/_submenu.php

    r10141 r10208  
    11<li><?php echo link_to(__('ホーム画面レイアウト設定'), 'design/homeLayout') ?></li>
    2 <li><?php echo link_to(__('ホーム画面ウィジェット設定'), 'design/homeWidget') ?></li>
    3 <li><?php echo link_to(__('携帯版ホーム画面ウィジェット設定'), 'design/mobileHomeWidget') ?></li>
     2<li><?php echo link_to(__('ウィジェット設定'), 'design/widget') ?></li>
    43<li><?php echo link_to(__('ナビ設定'), 'navi/index') ?></li>
    54<li><?php echo link_to(__('携帯版ナビ設定'), 'navi/index?app=mobile') ?></li>
  • OpenPNE3/trunk/apps/pc_backend/modules/design/templates/homeWidgetPlotSuccess.php

    r9582 r10208  
    1 <?php use_helper('Javascript') ?>
    2 
    3 <?php echo javascript_tag("
    4 function showModalOnParent(url)
    5 {
    6   var modal = parent.document.getElementById('modal');
    7   var modalContents = parent.document.getElementById('modal_contents');
    8   var modalIframe = modalContents.getElementsByTagName('iframe')[0];
    9   modalIframe.src = url;
    10   new Effect.Appear(modal, {from:0, to:0.7});
    11   new Effect.Appear(modalContents, {from:0, to:1.0});
    12 }
    13 
    14 function insertHiddenTags(type, ids)
    15 {
    16   var form = parent.document.getElementById('widgetForm');
    17   var hiddens = form.getElementsByClassName(type + 'Widget');
    18 
    19   while (hiddens.length)
    20   {
    21     Element.remove(hiddens[0]);
    22   }
    23 
    24   for (var i = 0; i < ids.length; i++)
    25   {
    26     if (!ids[i])
    27     {
    28       continue;
    29     }
    30 
    31     var obj = document.createElement('input');
    32     obj.setAttribute('class', type + 'Widget');
    33     obj.setAttribute('type', 'hidden');
    34     obj.setAttribute('name', 'widget[' + type + '][' + i + ']');
    35     obj.setAttribute('value', ids[i]);
    36     new Insertion.Bottom(form, obj);
    37   }
    38 }
    39 
    40 function dropNewWidget(type, name, obj)
    41 {
    42   var form = parent.document.getElementById('widgetForm');
    43   var hiddens = form.getElementsByClassName(type + 'New');
    44   for (var i = 0; i < hiddens.length; i++)
    45   {
    46     if (hiddens[i].value == name)
    47     {
    48       Element.remove(hiddens[i]);
    49       break;
    50     }
    51   }
    52   Element.remove(obj);
    53 }
    54 
    55 ");
    56 ?>
     1<?php include_partial('plotHeader') ?>
    572
    583<div id="plotBody" class="<?php echo $layoutPattern ?>">
     
    605
    616<?php if ($layoutPattern === 'layoutA') : ?>
    62 <div id="plotTop">
    63 <?php foreach ($topWidgets as $widget) : ?>
    64 <div class="widget" id="plotTop_widget_<?php echo $widget->getId() ?>">
    65 <?php
    66 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    67 ?>
    68 </div>
    69 <?php endforeach; ?>
    70 <div class="emptyWidget">
    71 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=top').'\')') ?>
    72 </div>
    73 </div>
    74 <?php echo sortable_element('plotTop', array(
    75   'only' => 'widget',
    76   'tag'  => 'div',
    77   'onUpdate' => 'function(s){insertHiddenTags(\'top\', Sortable.sequence(s, s.id))}',
    78 )) ?>
     7<?php include_partial('plotWidget', array('type' => 'top', 'widgets' => $topWidgets, 'widgetConfig' => $widgetConfig)); ?>
    798<?php endif; ?>
    809
    8110<?php if ($layoutPattern === 'layoutA' || $layoutPattern === 'layoutB') : ?>
    82 <div id="plotSideMenu">
    83 <?php foreach ($sideMenuWidgets as $widget) : ?>
    84 <div class="widget" id="plotSideMenu_widget_<?php echo $widget->getId() ?>">
    85 <?php
    86 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    87 ?>
    88 </div>
    89 <?php endforeach; ?>
    90 <div class="emptyWidget">
    91 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=sideMenu').'\')') ?>
    92 </div>
    93 </div>
    94 <?php echo sortable_element('plotSideMenu', array(
    95   'only' => 'widget',
    96   'tag'  => 'div',
    97   'onUpdate' => 'function(s){insertHiddenTags(\'sideMenu\', Sortable.sequence(s, s.id))}',
    98 )) ?>
     11<?php include_partial('plotWidget', array('type' => 'sideMenu', 'widgets' => $sideMenuWidgets, 'widgetConfig' => $widgetConfig)); ?>
    9912<?php endif; ?>
    10013
    101 <div id="plotContents">
    102 <?php foreach ($contentsWidgets as $widget) : ?>
    103 <div class="widget" id="plotContents_widget_<?php echo $widget->getId() ?>">
    104 <?php
    105 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    106 ?>
    107 </div>
    108 <?php endforeach; ?>
    109 <div class="emptyWidget">
    110 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=contents').'\')') ?>
    111 </div>
    112 </div>
    113 <?php echo sortable_element('plotContents', array(
    114   'only' => 'widget',
    115   'tag'  => 'div',
    116   'onUpdate' => 'function(s){insertHiddenTags(\'contents\', Sortable.sequence(s, s.id))}',
    117 )) ?>
     14<?php include_partial('plotWidget', array('type' => 'contents', 'widgets' => $contentsWidgets, 'widgetConfig' => $widgetConfig)); ?>
    11815
    11916</div>
  • OpenPNE3/trunk/apps/pc_backend/modules/design/templates/mobileHomeWidgetPlotSuccess.php

    r10205 r10208  
    1 <?php use_helper('Javascript') ?>
    2 
    3 <?php echo javascript_tag("
    4 function showModalOnParent(url)
    5 {
    6   var modal = parent.document.getElementById('modal');
    7   var modalContents = parent.document.getElementById('modal_contents');
    8   var modalIframe = modalContents.getElementsByTagName('iframe')[0];
    9   modalIframe.src = url;
    10   new Effect.Appear(modal, {from:0, to:0.7});
    11   new Effect.Appear(modalContents, {from:0, to:1.0});
    12 }
    13 
    14 function insertHiddenTags(type, ids)
    15 {
    16   var form = parent.document.getElementById('widgetForm');
    17   var hiddens = form.getElementsByClassName(type + 'Widget');
    18 
    19   while (hiddens.length)
    20   {
    21     Element.remove(hiddens[0]);
    22   }
    23 
    24   for (var i = 0; i < ids.length; i++)
    25   {
    26     if (!ids[i])
    27     {
    28       continue;
    29     }
    30 
    31     var obj = document.createElement('input');
    32     obj.setAttribute('class', type + 'Widget');
    33     obj.setAttribute('type', 'hidden');
    34     obj.setAttribute('name', 'widget[' + type + '][' + i + ']');
    35     obj.setAttribute('value', ids[i]);
    36     new Insertion.Bottom(form, obj);
    37   }
    38 }
    39 
    40 function dropNewWidget(type, name, obj)
    41 {
    42   var form = parent.document.getElementById('widgetForm');
    43   var hiddens = form.getElementsByClassName(type + 'New');
    44   for (var i = 0; i < hiddens.length; i++)
    45   {
    46     if (hiddens[i].value == name)
    47     {
    48       Element.remove(hiddens[i]);
    49       break;
    50     }
    51   }
    52   Element.remove(obj);
    53 }
    54 
    55 ");
    56 ?>
     1<?php include_partial('plotHeader') ?>
    572
    583<div id="plotBody">
    594<div id="container">
    605
    61 <div id="plotMobileTop">
    62 <?php foreach ($mobileTopWidgets as $widget) : ?>
    63 <div class="widget" id="plotMobileTop_widget_<?php echo $widget->getId() ?>">
    64 <?php
    65 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    66 ?>
    67 </div>
    68 <?php endforeach; ?>
    69 <div class="emptyWidget">
    70 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=mobileTop').'\')') ?>
    71 </div>
    72 </div>
    73 <?php echo sortable_element('plotMobileTop', array(
    74   'only' => 'widget',
    75   'tag'  => 'div',
    76   'onUpdate' => 'function(s){insertHiddenTags(\'mobileTop\', Sortable.sequence(s, s.id))}',
    77 )) ?>
     6<?php include_partial('plotWidget', array('type' => 'mobileTop', 'widgets' => $mobileTopWidgets, 'widgetConfig' => $widgetConfig)); ?>
    787
    798<div class="fixedWidget">
    80 <?php echo __('メニュー') ?>
     9<?php echo __('メニュー(変更不可)') ?>
    8110</div>
    8211
    83 <div id="plotMobileContents">
    84 <?php foreach ($mobileContentsWidgets as $widget) : ?>
    85 <div class="widget" id="plotMobileContents_widget_<?php echo $widget->getId() ?>">
    86 <?php
    87 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    88 ?>
    89 </div>
    90 <?php endforeach; ?>
    91 <div class="emptyWidget">
    92 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=mobileContents').'\')') ?>
    93 </div>
    94 </div>
    95 <?php echo sortable_element('plotMobileContents', array(
    96   'only' => 'widget',
    97   'tag'  => 'div',
    98   'onUpdate' => 'function(s){insertHiddenTags(\'mobileContents\', Sortable.sequence(s, s.id))}',
    99 )) ?>
     12<?php include_partial('plotWidget', array('type' => 'mobileContents', 'widgets' => $mobileContentsWidgets, 'widgetConfig' => $widgetConfig)); ?>
    10013
    10114<div class="fixedWidget">
    102 <?php echo __('設定変更') ?>
     15<?php echo __('設定変更(変更不可)') ?>
    10316</div>
    10417
    105 <div id="plotMobileBottom">
    106 <?php foreach ($mobileBottomWidgets as $widget) : ?>
    107 <div class="widget" id="plotMobileBottom_widget_<?php echo $widget->getId() ?>">
    108 <?php
    109 echo link_to_function($widgetConfig[$widget->getName()]['caption']['ja_JP'], 'showModalOnParent(\''.url_for('design/homeEditWidget?id='.$widget->getId()).'\')');
    110 ?>
    111 </div>
    112 <?php endforeach; ?>
    113 <div class="emptyWidget">
    114 <?php echo link_to_function(__('ウィジェットを追加'), 'showModalOnParent(\''.url_for('design/homeAddWidget?type=mobileBottom').'\')') ?>
    115 </div>
    116 </div>
    117 <?php echo sortable_element('plotMobileBottom', array(
    118   'only' => 'widget',
    119   'tag'  => 'div',
    120   'onUpdate' => 'function(s){insertHiddenTags(\'mobileBottom\', Sortable.sequence(s, s.id))}',
    121 )) ?>
     18<?php include_partial('plotWidget', array('type' => 'mobileBottom', 'widgets' => $mobileBottomWidgets, 'widgetConfig' => $widgetConfig)); ?>
    12219
    12320</div>
Note: See TracChangeset for help on using the changeset viewer.