protected function runAction()
 {
     global $objPage;
     switch (\Input::get('act')) {
         case WATCHLIST_ACT_DELETE:
             Watchlist::getInstance()->deleteItem(\Input::get('id'));
             break;
         case WATCHLIST_ACT_ADD:
             $objItem = new WatchlistItemModel();
             $objItem->pid = Watchlist::getInstance()->getId();
             $objItem->uuid = \Input::get('id');
             $objItem->pageID = $objPage->id;
             $objItem->cid = \Input::get('cid');
             $objItem->type = \Input::get('type');
             $objItem->title = \Input::get('title');
             $objItem->tstamp = time();
             Watchlist::getInstance()->addItem($objItem);
             break;
         case WATCHLIST_ACT_DELETE_ALL:
             Watchlist::getInstance()->deleteAll();
             break;
         case WATCHLIST_ACT_DOWNLOAD_ALL:
             Watchlist::getInstance()->downloadAll();
             break;
     }
     // if ajax -> return the content of the watchlist
     if (\Environment::get('isAjaxRequest')) {
         die(json_encode(array('action' => \Input::get('act'), 'watchlist' => Watchlist::getInstance()->generate(), 'notification' => Watchlist::getInstance()->generateNotifications(), 'count' => Watchlist::getInstance()->count(), 'cssClass' => Watchlist::getInstance()->count() > 0 ? 'not-empty' : 'empty')));
     }
     // no js support -- redirect and remove GET parameters
     \Controller::redirect(\Controller::generateFrontendUrl($objPage->row()));
 }
 public function generateAddActions($arrData, $id, Watchlist $objWatchlist)
 {
     global $objPage;
     if ($objPage === null) {
         return;
     }
     if (\Validator::isUuid($id)) {
         $objFile = \FilesModel::findByUuid($id);
     } else {
         $objFile = \FilesModel::findBy('path', $id);
     }
     $objItem = new WatchlistItemModel();
     $objItem->pid = Watchlist::getInstance()->getId();
     $objItem->uuid = $objFile->uuid;
     $objItem->pageID = $objPage->id;
     $objItem->cid = $arrData['id'];
     $objItem->type = $arrData['type'];
     $objT = new \FrontendTemplate('watchlist_add_actions');
     $objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle()));
     $objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle'];
     $objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink'];
     $objT->active = $objWatchlist->isInList($strUuid);
     $objT->id = $strUuid;
     return $objT->parse();
 }