/** * Handles incoming requests. */ public function handle_json($request) { // Loading the widget. if (isset($request->widget)) { $widget_name = (string) $request->widget; } else { return; } $result = []; // Preparing the parameters and calling the function. if (isset($request->params)) { $params = (array) $request->params; foreach ($params as $p) { if (is_object($p) && isset($p->container)) { array_push($result, (array) $p->container); } else { array_push($result, $p); } } } $widgets = Wrapper::getInstance(); $widgets->runWidget($widget_name, (string) $request->func, $result); }
<?php require __DIR__ . '/vendor/autoload.php'; define('DOCUMENT_ROOT', dirname(__FILE__)); gc_enable(); use Movim\Bootstrap; //memprof_enable(); $bootstrap = new Bootstrap(); $booted = $bootstrap->boot(); $loop = React\EventLoop\Factory::create(); $connector = new React\SocketClient\TcpConnector($loop); $stdin = new React\Stream\Stream(STDIN, $loop); fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " widgets before : " . \sizeToCleanSize(memory_get_usage()) . "\n"); // We load and register all the widgets $wrapper = \Movim\Widget\Wrapper::getInstance(); $wrapper->registerAll($bootstrap->getWidgets()); fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " widgets : " . \sizeToCleanSize(memory_get_usage()) . "\n"); $conn = null; $parser = new \Moxl\Parser(); $buffer = ''; $timestamp = time(); function handleSSLErrors($errno, $errstr) { fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " : " . colorize($errstr, 'red') . "\n"); } // Temporary linker killer $loop->addPeriodicTimer(5, function () use(&$conn, &$timestamp) { if ($timestamp < time() - 3600 * 6) { $conn->close(); } });
/** * Loads up a widget and prints it at the current place. */ function widget($name) { $widgets = Wrapper::getInstance(); $widgets->setView($this->_view); echo $widgets->runWidget($name, 'build'); }
function runEvent($key, $data = null) { $widgets = Wrapper::getInstance(); $widgets->iterate($key, $data); }
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * @mainpage * * Movim is an XMPP-based communication platform. It uses a widget-based UI * system. A widget is a combination of server-side and client-side scripts that * interact though a custom xmlrpc protocol. * * Movim's core is designed to ease the implementation of XMPP web-based clients, * using massively asynchronous javascript and abstracting XMPP calls into an * events-based API. */ define('DOCUMENT_ROOT', dirname(__FILE__)); require 'vendor/autoload.php'; use Movim\Bootstrap; use Movim\Controller\Front; use Movim\Widget\Wrapper; try { $bootstrap = new Bootstrap(); $bootstrap->boot(); } catch (Exception $e) { error_log($e->getMessage()); echo 'Oops, something went wrong, please check the log files'; return; } $rqst = new Front(); $rqst->handle(); Wrapper::getInstance(false); // Closing stuff Wrapper::destroyInstance();