public function processform() { litepublisher::$urlmap->clearcache(); switch ($this->name) { case 'widgets': $idwidget = (int) tadminhtml::getparam('idwidget', 0); $widgets = twidgets::i(); if ($widgets->itemexists($idwidget)) { $widget = $widgets->getwidget($idwidget); return $widget->admin->processform(); } else { if (isset($_POST['action'])) { self::setsidebars(); } return $this->html->h2->success; } case 'addcustom': $widget = tcustomwidget::i(); return $widget->admin->processform(); } }
function migratewidgets() { global $data; //links if ($data->loadfile('linkswidget')) { $widget = tlinkswidget::instance(); $widget->redir = $data->redir; $widget->items = array(); foreach ($data->data['items'] as $id => $item) { $widget->items[++$widget->autoid] = array('url' => $item['url'], 'title' => $item['title'], 'anchor' => $item['text']); } $widget->save(); } if ($data->loadfile('customwidget')) { $widgets = twidgets::instance(); $widgets->lock(); $widget = tcustomwidget::instance(); $widget->lock(); foreach ($widget->items as $id => $item) { $widget->delete($id); } foreach ($data->data['items'] as $id => $item) { $widget->add($item['title'], $item['content'], 'widget'); } $widget->unlock(); $widgets->unlock(); } }