public function __construct(array $params) { parent::__construct($params); if (!$this->params) { return; } switch ($this->params[0]) { case 'link': case 'unlink': $this->handler = 'handleLink'; // always returns null break; case 'pin': case 'unpin': $this->handler = 'handlePin'; // always returns null break; case 'public': case 'private': $this->handler = 'handlePrivacy'; // always returns null break; case 'avatar': $this->handler = 'handleAvatar'; // sets an image header break; // so it has to die here or another header will be set // so it has to die here or another header will be set case 'resync': case 'status': $this->handler = 'handleResync'; break; case 'save': $this->handler = 'handleSave'; break; case 'delete': $this->handler = 'handleDelete'; break; case 'purge': $this->handler = 'handlePurge'; break; case 'summary': // page is generated by jScript die; // just be empty // just be empty case 'load': $this->handler = 'handleLoad'; break; } }
public function action_ajax_block(AjaxHandler $handler) { if (!isset($_SESSION['ajax_blocks'][$_GET['_b']])) { die; } $block = $_SESSION['ajax_blocks'][$_GET['_b']]; $context = null; $handler->setup_theme(); $theme = $handler->theme; $blocks = $theme->get_blocks($block->_area, $block->_scope_id, $theme); $blocks = array_filter($blocks, function ($b) use($block) { return $b->id == $block->id; }); $rebuildblock = reset($blocks); $rebuildblock->_area = $block->_area; $rebuildblock->_instance_id = $block->_instance_id; $rebuildblock->_area_index = $block->_area_index; $hook = 'block_content_' . $rebuildblock->type; Plugins::act($hook, $rebuildblock, $theme); Plugins::act('block_content', $rebuildblock, $theme); $rebuildblock->_content = $theme->content($rebuildblock, $context); $rebuildblock->_first = $block->_first; $rebuildblock->_last = $block->_last; // Set up the theme for the wrapper $theme->block = $rebuildblock; $theme->content = $rebuildblock->_content; // This is the block wrapper fallback template list $fallback = array($block->area . '.blockwrapper', 'blockwrapper', 'content'); if (!is_null($context)) { array_unshift($fallback, $context . '.blockwrapper'); array_unshift($fallback, $context . '.' . $block->area . '.blockwrapper'); } $output = $theme->display_fallback($fallback, 'fetch'); echo $output; }
public function __construct(array $params) { parent::__construct($params); // always this one $this->handler = 'handleLocale'; $this->doRedirect = true; }
public function __construct(array $params) { parent::__construct($params); // requires 'action' parameter in any case if (!$this->_get['action'] || !$this->params) { return; } if ($this->params[0] == 'screenshots') { if (!User::isInGroup(U_GROUP_STAFF | U_GROUP_SCREENSHOT)) { // comment_mod, handleSSmod, vi_mod ? return; } if ($this->_get['action'] == 'list') { $this->handler = 'ssList'; } else { if ($this->_get['action'] == 'manage') { $this->handler = 'ssManage'; } else { if ($this->_get['action'] == 'editalt') { $this->handler = 'ssEditAlt'; } else { if ($this->_get['action'] == 'approve') { $this->handler = 'ssApprove'; } else { if ($this->_get['action'] == 'sticky') { $this->handler = 'ssSticky'; } else { if ($this->_get['action'] == 'delete') { $this->handler = 'ssDelete'; } else { if ($this->_get['action'] == 'relocate') { $this->handler = 'ssRelocate'; } } } } } } } } else { if ($this->params[0] == 'siteconfig') { if (!User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN)) { return; } if ($this->_get['action'] == 'add') { $this->handler = 'confAdd'; } else { if ($this->_get['action'] == 'remove') { $this->handler = 'confRemove'; } else { if ($this->_get['action'] == 'update') { $this->handler = 'confUpdate'; } } } } } }
public static function init() { // Setup headers header('Content-Type: application/json'); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // Setup handler $handler = new AjaxHandler(); $handler->registerMethod('items.get', array('LilinaAPI', 'items_get')); $handler->registerMethod('items.getList', array('LilinaAPI', 'items_getList')); $handler->registerMethod('feeds.get', array('LilinaAPI', 'feeds_get')); $handler->registerMethod('feeds.getList', array('LilinaAPI', 'feeds_getList')); $handler->registerMethod('update.single', array('LilinaAPI', 'update_single')); do_action_ref_array('LilinaAPI-register', array(&$handler)); // Dispatch $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; try { $output = $handler->handle($action, $_REQUEST); echo json_encode($output); } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); echo json_encode(array('error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode())); } }
public function __construct(array $params) { parent::__construct($params); if (is_numeric($this->_get['locale'])) { User::useLocale($this->_get['locale']); } // always this one $this->handler = 'handleData'; }
public function __construct(array $params) { parent::__construct($params); if (is_numeric($this->_get['locale'])) { User::useLocale($this->_get['locale']); } if (!$this->params || !User::$id) { return; } // select handler if ($this->params[0] == 'exclude') { $this->handler = 'handleExclude'; } else { if ($this->params[0] == 'weightscales') { $this->handler = 'handleWeightscales'; } } }
/** * Initialise the Ajax interface */ public static function init() { $handler = new AjaxHandler(); $handler->registerMethod('feeds.add', array('AdminAjax', 'feeds_add')); $handler->registerMethod('feeds.change', array('AdminAjax', 'feeds_change')); $handler->registerMethod('feeds.remove', array('AdminAjax', 'feeds_remove')); $handler->registerMethod('feeds.list', array('AdminAjax', 'feeds_list')); $handler->registerMethod('feeds.get', array('AdminAjax', 'feeds_get')); $method = isset($_REQUEST['method']) ? $_REQUEST['method'] : null; try { $output = $handler->handle($method, $_REQUEST); echo json_encode($output); } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); echo json_encode(array('error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode())); } }
public function __construct(array $params) { parent::__construct($params); if (!$this->params || count($this->params) != 1) { return; } // note: return values must be formated as STRICT json! // select handler if ($this->params[0] == 'add') { $this->handler = 'handleCommentAdd'; } else { if ($this->params[0] == 'edit') { $this->handler = 'handleCommentEdit'; } else { if ($this->params[0] == 'delete') { $this->handler = 'handleCommentDelete'; } else { if ($this->params[0] == 'undelete') { $this->handler = 'handleCommentUndelete'; } else { if ($this->params[0] == 'rating') { // up/down - distribution $this->handler = 'handleCommentRating'; } else { if ($this->params[0] == 'vote') { // up, down and remove $this->handler = 'handleCommentVote'; } else { if ($this->params[0] == 'sticky') { // toggle flag $this->handler = 'handleCommentSticky'; } else { if ($this->params[0] == 'out-of-date') { // toggle flag $this->handler = 'handleCommentOutOfDate'; } else { if ($this->params[0] == 'show-replies') { $this->handler = 'handleCommentShowReplies'; } else { if ($this->params[0] == 'add-reply') { // also returns all replies on success $this->handler = 'handleReplyAdd'; } else { if ($this->params[0] == 'edit-reply') { // also returns all replies on success $this->handler = 'handleReplyEdit'; } else { if ($this->params[0] == 'detach-reply') { $this->handler = 'handleReplyDetach'; } else { if ($this->params[0] == 'delete-reply') { $this->handler = 'handleReplyDelete'; } else { if ($this->params[0] == 'flag-reply') { $this->handler = 'handleReplyFlag'; } else { if ($this->params[0] == 'upvote-reply') { $this->handler = 'handleReplyUpvote'; } else { if ($this->params[0] == 'downvote-reply') { $this->handler = 'handleReplyDownvote'; } } } } } } } } } } } } } } } } }
public function __construct(array $params) { parent::__construct($params); // always this one $this->handler = 'handleContactUs'; }
public static function init() { AjaxHandler::beginAjaxRequest(); if (!isset(self::$_AJAX_HELPER)) { $c = __CLASS__; self::$_AJAX_HELPER = new $c(); } return self::$_AJAX_HELPER; }