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

source: OpenPNE3/trunk/apps/pc_backend/modules/design/actions/actions.class.php @ 10208

Last change on this file since 10208 was 10208, checked in by ebihara, 12 years ago

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

File size: 5.1 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * design actions.
13 *
14 * @package    OpenPNE
15 * @subpackage design
16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
17 */
18class designActions extends sfActions
19{
20 /**
21  * Executes index action
22  *
23  * @param sfRequest $request A request object
24  */
25  public function executeIndex(sfWebRequest $request)
26  {
27    $this->forward('design', 'homeLayout');
28  }
29
30 /**
31  * Executes home layout action
32  *
33  * @param sfRequest $request A request object
34  */
35  public function executeHomeLayout(sfWebRequest $request)
36  {
37    $this->form = new PickHomeLayoutForm();
38
39    if ($request->isMethod(sfRequest::POST))
40    {
41      $this->form->bind($request->getParameter('pick_home_layout'));
42      $this->redirectIf($this->form->save(), 'design/homeLayout');
43    }
44
45    return sfView::SUCCESS;
46  }
47
48 /**
49  * Executes widget action
50  *
51  * @param sfRequest $request A request object
52  */
53  public function executeWidget(sfWebRequest $request)
54  {
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    }
72
73    $this->sortForm = new WidgetSortForm(array(), array('current_widgets' => $this->widgets));
74    $this->addForm = new WidgetAddForm(array(), array('current_widgets' => $this->widgets));
75
76    if ($request->isMethod(sfRequest::POST))
77    {
78      $this->sortForm->bind($request->getParameter('widget'));
79      $this->addForm->bind($request->getParameter('new'));
80      if ($this->sortForm->isValid() && $this->addForm->isValid())
81      {
82        $this->sortForm->save();
83        $this->addForm->save();
84        $this->redirect('design/widget?type='.$this->type);
85      }
86    }
87  }
88
89 /**
90  * Executes home widget plot action
91  *
92  * @param sfRequest $request A request object
93  */
94  public function executeHomeWidgetPlot(sfWebRequest $request)
95  {
96    $this->layoutPattern = 'layoutA';
97    $this->topWidgets = HomeWidgetPeer::retrieveTopWidgets();
98    $this->sideMenuWidgets = HomeWidgetPeer::retrieveSideMenuWidgets();
99    $this->contentsWidgets = HomeWidgetPeer::retrieveContentsWidgets();
100    $this->widgetConfig = sfConfig::get('op_widget_list');
101
102    $layout = SnsConfigPeer::retrieveByName('home_layout');
103    if ($layout)
104    {
105      $this->layoutPattern = $layout->getValue();
106    }
107
108    return sfView::SUCCESS;
109  }
110
111 /**
112  * Executes home add widget action
113  *
114  * @param sfRequest $request A request object
115  */
116  public function executeHomeAddWidget(sfWebRequest $request)
117  {
118    $validTypes = array('top', 'sideMenu', 'contents', 'mobileTop', 'mobileContents', 'mobileBottom');
119    $mobileTypes = array('mobileTop', 'mobileContents', 'mobileBottom');
120
121    $this->config = sfConfig::get('op_widget_list', array());
122    $this->type = 'top';
123    if (in_array($request->getParameter('type'), $validTypes))
124    {
125      $this->type = $request->getParameter('type');
126    }
127
128    if (in_array($this->type, $mobileTypes))
129    {
130      $this->config = sfConfig::get('op_mobile_widget_list', array());
131    }
132
133    return sfView::SUCCESS;
134  }
135
136 /**
137  * Executes home edit widget action
138  *
139  * @param sfRequest $request A request object
140  */
141  public function executeHomeEditWidget(sfWebRequest $request)
142  {
143    $this->widget = HomeWidgetPeer::retrieveByPK($request->getParameter('id'));
144    $config = sfConfig::get('op_widget_list', array());
145    $this->forward404Unless($this->widget && $config);
146
147    $this->config = $config[$this->widget->getName()];
148
149    if (!empty($this->config['config']))
150    {
151      $this->form = new HomeWidgetConfigForm($this->widget);
152
153      if ($request->isMethod(sfRequest::POST))
154      {
155        $this->form->bind($request->getParameter('home_widget_config'));
156        if ($this->form->isValid())
157        {
158          $this->form->save();
159          $this->redirect('design/homeEditWidget?id='.$this->widget->getId());
160        }
161      }
162    }
163
164    return sfView::SUCCESS;
165  }
166
167 /**
168  * Executes mobile home widget plot action
169  *
170  * @param sfRequest $request A request object
171  */
172  public function executeMobileHomeWidgetPlot(sfWebRequest $request)
173  {
174    $this->mobileTopWidgets = (array)HomeWidgetPeer::retrieveMobileTopWidgets();
175    $this->mobileContentsWidgets = (array)HomeWidgetPeer::retrieveMobileContentsWidgets();
176    $this->mobileBottomWidgets = (array)HomeWidgetPeer::retrieveMobileBottomWidgets();
177    $this->widgetConfig = sfConfig::get('op_mobile_widget_list');
178
179    return sfView::SUCCESS;
180  }
181}
Note: See TracBrowser for help on using the repository browser.