/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get parameters $charset = $this->getContainer()->getParameter('kernel.charset'); $searchTerm = \SpoonFilter::getPostValue('term', null, ''); $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm); $limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10); // validate if ($term == '') { $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.'); } else { // get matches $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit); // get search url $url = FrontendNavigation::getURLForBlock('Search'); // loop items and set search url foreach ($matches as &$match) { $match['url'] = $url . '?form=search&q=' . $match['term']; } // output $this->output(self::OK, $matches); } }
/** * Execute the action */ public function execute() { parent::execute(); $this->getData(); $this->loadTemplate(); $this->display(); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $charset = $this->getContainer()->getParameter('kernel.charset'); $searchTerm = \SpoonFilter::getPostValue('term', null, ''); $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm); // validate search term if ($term == '') { $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.'); } else { // previous search result $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : ''; \SpoonSession::set('searchTerm', ''); // save this term? if ($previousTerm != $term) { // format data $this->statistics = array(); $this->statistics['term'] = $term; $this->statistics['language'] = LANGUAGE; $this->statistics['time'] = FrontendModel::getUTCDate(); $this->statistics['data'] = serialize(array('server' => $_SERVER)); $this->statistics['num_results'] = FrontendSearchModel::getTotal($term); // save data FrontendSearchModel::save($this->statistics); } // save current search term in cookie \SpoonSession::set('searchTerm', $term); // output $this->output(self::OK); } }
/** * Execute the action */ public function execute() { parent::execute(); $this->getData(); $this->validateForm(); $this->makeSubscription(); }
/** * @param KernelInterface $kernel * @param string $action The action that should be executed. * @param string $module The module that wherein the action is available. */ public function __construct(KernelInterface $kernel, $action, $module) { parent::__construct($kernel, $action, $module); // set properties $this->setModule($module); $this->setAction($action); // load the config file for the required module $this->loadConfig(); }
/** * Execute the action */ public function execute() { parent::execute(); // Get POST parameters $userId = \SpoonFilter::getPostValue('userId', null, ''); // Get count settings $this->recentCount = FrontendModel::get('fork.settings')->get('Instagram', 'num_recent_items', 10); // Get the images from the Instagram API $this->images = FrontendInstagramModel::getRecentMedia($userId, $this->recentCount); // Output the result $this->output(self::OK, $this->images); }
/** * Execute the order save */ public function execute() { parent::execute(); // get order values $this->orderValues['product_id'] = \SpoonFilter::getPostValue('productId', null, ''); $this->orderValues['amount'] = \SpoonFilter::getPostValue('productAmount', null, ''); $action = \SpoonFilter::getPostValue('action', null, ''); // get cookie $cookieOrderId = Cookie::get('order_id'); // check if cookies are enabled $cookiesEnabled = Cookie::set('enabled', 'true'); $cookieExists = Cookie::exists('enabled'); // check if cookies are set, when true update the order if (isset($cookieOrderId) && FrontendCatalogModel::existsOrder($cookieOrderId) == true) { $this->orderValues['order_id'] = $cookieOrderId; // action add or update if ($action == 'add-update') { if (FrontendCatalogModel::existsOrderValue($this->orderValues['product_id'], $this->orderValues['order_id']) == true) { // update the order values FrontendCatalogModel::updateOrderValue($this->orderValues, $this->orderValues['order_id'], $this->orderValues['product_id']); $this->output(self::OK, null, 'Order values updated.'); } else { // insert order values FrontendCatalogModel::insertOrderValue($this->orderValues); $this->output(self::OK, null, 'Order values inserted.'); } } elseif ($action == 'delete') { if (FrontendCatalogModel::existsOrderValue($this->orderValues['product_id'], $this->orderValues['order_id']) == true) { // delete the order values FrontendCatalogModel::deleteOrderValue($this->orderValues['order_id'], $this->orderValues['product_id']); $this->output(self::OK, null, 'Order values deleted.'); } } } else { // when no cookies are set, create new cookie and insert order $orderId = FrontendCatalogModel::insertOrder(); if ($orderId != '') { // set order id $this->orderValues['order_id'] = $orderId; // set cookie Cookie::set('order_id', $orderId); // insert order values FrontendCatalogModel::insertOrderValue($this->orderValues); $this->output(self::OK, null, 'Order imported.'); } } }
/** * Execute the action */ public function execute() { parent::execute(); $room['room_id'] = \SpoonFilter::getPostValue('room_id', null, 0); $room['arrival'] = \SpoonFilter::getPostValue('arrival', null, ''); $room['departure'] = \SpoonFilter::getPostValue('departure', null, ''); $room['client_name'] = \SpoonFilter::getPostValue('client_name', null, ''); $room['client_email'] = \SpoonFilter::getPostValue('client_email', null, ''); if (!$room['arrival'] || !$room['departure'] || !$room['room_id'] || !$room['room_id']) { $this->output(self::ERROR, 'Missing values'); } $sent = FrontendBookingsModel::reserveRoom($room); if ($sent) { // output $this->output(self::OK, 'Booking sent'); } else { // output $this->output(self::ERROR, 'Error sending'); } }
/** * Execute the action */ public function execute() { parent::execute(); $hotelId = \SpoonFilter::getPostValue('hotel_id', null, 0); if (!$hotelId) { $this->output(self::ERROR, 'Missing values'); } $hotel = FrontendBookingsModel::getHotel($hotelId); if ($hotel) { $museums = FrontendBookingsModel::getMuseums($hotel['country'], $hotel['city']); $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Museums.tpl'; $museumsTpl = new Template(false); $museumsTpl->assign('hotel', $hotel); $museumsTpl->assign('museums', $museums); $html = $museumsTpl->getContent($tpl, true, true); } else { $html = ''; } // output $this->output(self::OK, $html); }
/** * Execute the action */ public function execute() { parent::execute(); $hotelId = \SpoonFilter::getPostValue('hotel_id', null, 0); $arrival = \SpoonFilter::getPostValue('arrival', null, 0); $departure = \SpoonFilter::getPostValue('departure', null, 0); if (!$hotelId && !$arrival && !$departure) { $this->output(self::ERROR, 'Missing values'); } $rooms = FrontendBookingsModel::getRooms($hotelId, $arrival, $departure); foreach ($rooms as &$room) { if ($room['available_rooms'] < 1) { $room['disabled'] = true; } } $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Rooms.tpl'; $roomsTpl = new Template(false); $roomsTpl->assign('rooms', $rooms); $html = $roomsTpl->getContent($tpl, true, true); // output $this->output(self::OK, $html); }
/** * Execute the action */ public function execute() { parent::execute(); $roomId = \SpoonFilter::getPostValue('room_id', null, 0); $room = FrontendBookingsModel::getRoom($roomId); $room['arrival'] = \SpoonFilter::getPostValue('arrival', null, ''); $room['departure'] = \SpoonFilter::getPostValue('departure', null, ''); if (!$room['arrival'] || !$room['departure'] || !$roomId) { $this->output(self::ERROR, 'Missing values'); } if (empty($room)) { $this->output(self::ERROR, 'Room not found'); } $room['stay_duration'] = floor((strtotime($room['departure']) - strtotime($room['arrival'])) / (60 * 60 * 24)); $room['total_price'] = $room['stay_duration'] * $room['price']; $tpl = FRONTEND_MODULES_PATH . '/Bookings/Layout/Templates/Room.tpl'; $roomTpl = new Template(false); $roomTpl->assign('room', $room); $html = $roomTpl->getContent($tpl, true, true); // output $this->output(self::OK, $html); }
/** * Execute the action */ public function execute() { parent::execute(); $this->loadTemplate(); $this->validateForm(); $this->display(); }
/** * Set module * * @param string $value The module, wherefore an action will be executed. */ public function setModule($value) { // get the possible modules $possibleModules = Model::getModules(); // validate if (!in_array($value, $possibleModules)) { // create fake action $fakeAction = new FrontendBaseAJAXAction($this->getKernel(), '', ''); // output error $fakeAction->output(FrontendBaseAJAXAction::BAD_REQUEST, null, 'Module not correct.'); } // set property $this->module = (string) $value; }