10 defined(
'JPATH_PLATFORM') or die;
57 public function __construct($config = array())
59 parent::__construct($config);
64 $this->registerTask(
'unpublish',
'publish');
67 $this->registerTask(
'archive',
'publish');
70 $this->registerTask(
'trash',
'publish');
73 $this->registerTask(
'report',
'publish');
74 $this->registerTask(
'orderup',
'reorder');
75 $this->registerTask(
'orderdown',
'reorder');
78 if (empty($this->option))
80 $this->option =
'com_' . strtolower($this->getName());
84 if (empty($this->text_prefix))
86 $this->text_prefix = strtoupper($this->option);
90 if (empty($this->view_list))
93 if (!preg_match(
'/(.*)Controller(.*)/i', get_class($this), $r))
95 throw new Exception(
JText::_(
'JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
97 $this->view_list = strtolower($r[2]);
108 public function delete()
116 if (!is_array($cid) || count($cid) < 1)
123 $model = $this->getModel();
126 jimport(
'joomla.utilities.arrayhelper');
130 if ($model->delete($cid))
132 $this->setMessage(
JText::plural($this->text_prefix .
'_N_ITEMS_DELETED', count($cid)));
136 $this->setMessage($model->getError());
140 $this->postDeleteHook($model, $cid);
142 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false));
170 public function display($cachable =
false, $urlparams = array())
182 public function publish()
189 $data = array(
'publish' => 1,
'unpublish' => 0,
'archive' => 2,
'trash' => -2,
'report' => -3);
190 $task = $this->getTask();
200 $model = $this->getModel();
208 $model->publish($cid, $value);
212 $ntext = $this->text_prefix .
'_N_ITEMS_PUBLISHED';
216 $ntext = $this->text_prefix .
'_N_ITEMS_UNPUBLISHED';
220 $ntext = $this->text_prefix .
'_N_ITEMS_ARCHIVED';
224 $ntext = $this->text_prefix .
'_N_ITEMS_TRASHED';
230 $this->setMessage(
JText::_(
'JLIB_DATABASE_ERROR_ANCESTOR_NODES_LOWER_STATE'),
'error');
234 $extension = $this->input->get(
'extension');
235 $extensionURL = ($extension) ?
'&extension=' . $extension :
'';
236 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list . $extensionURL,
false));
246 public function reorder()
252 $inc = ($this->getTask() ==
'orderup') ? -1 : 1;
254 $model = $this->getModel();
255 $return = $model->reorder($ids, $inc);
256 if ($return ===
false)
259 $message =
JText::sprintf(
'JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError());
260 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false), $message,
'error');
266 $message =
JText::_(
'JLIB_APPLICATION_SUCCESS_ITEM_REORDERED');
267 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false), $message);
279 public function saveorder()
285 $pks = $this->input->post->get(
'cid', array(),
'array');
286 $order = $this->input->post->get(
'order', array(),
'array');
293 $model = $this->getModel();
296 $return = $model->saveorder($pks, $order);
298 if ($return ===
false)
301 $message =
JText::sprintf(
'JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError());
302 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false), $message,
'error');
308 $this->setMessage(
JText::_(
'JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'));
309 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false));
321 public function checkin()
328 $model = $this->getModel();
329 $return = $model->checkin($ids);
330 if ($return ===
false)
333 $message =
JText::sprintf(
'JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError());
334 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false), $message,
'error');
340 $message =
JText::plural($this->text_prefix .
'_N_ITEMS_CHECKED_IN', count($ids));
341 $this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option .
'&view=' . $this->view_list,
false), $message);
353 public function saveOrderAjax()
356 $pks = $this->input->post->get(
'cid', array(),
'array');
357 $order = $this->input->post->get(
'order', array(),
'array');
364 $model = $this->getModel();
367 $return = $model->saveorder($pks, $order);