/** * eyeDocs program entrypoint * * @author Jordi Rubio * @access public * @package eyeDocs * @param AppExecutionContext $context * @param MMapResponse $response * @since 1.0 */ public static function __run(AppExecutionContext $context, MMapResponse $response) { self::singleInstanceCheck(); if ($context->getIncludeBody()) { self::insertNeededJS($response); } //ExecModule::registerCallback('changesOnFile', $_SERVER['SCRIPT_NAME']); $myCometManager = new CometManager(); $myCometManager->registerCallback('DocumentsApplication::reciveMessagesFromNetSync', __FILE__); }
public static function __run(AppExecutionContext $context, MMapResponse $response) { $currentUser = $context->getProcess()->getLoginContext()->getEyeosUser(); $files = EyeosApplicationExecutable::__callModule('FileSystem', 'browsePath', array('home:///Desktop/', null, null)); $context->getArgs()->offsetSet(0, $currentUser->getName()); $context->getArgs()->offsetSet(1, $files); if ($context->getIncludeBody()) { $buffer = ''; $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/desktop/'; $buffer .= file_get_contents($itemsPath . '/desktop.WidgetManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.SelectionManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.actionManager.js'); $buffer .= file_get_contents($itemsPath . '/desktop.chatManager.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.events.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.favorites.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.files.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.groups.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.notes.js'); $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.desktop.js'); $response->appendToBody($buffer); } }
public function executeJavascript(AppExecutionContext $context, MMapResponse $response) { if (!is_readable($this->getJavascriptPath())) { throw new EyeIOException('Unable to read applications\'s Javascript file at ' . $this->getJavascriptPath()); } $response->getHeaders()->append('Content-type: text/plain'); // Avoid cache $response->getHeaders()->append('Last-Modified: ' . gmdate('D, j M Y H:i:s') . ' GMT'); $response->getHeaders()->append('Expires: ' . gmdate('D, j M Y H:i:s') . ' GMT'); $response->getHeaders()->append('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 $response->getHeaders()->append('Pragma: no-cache'); // HTTP/1.0 //IMPORTANT: this was fixed twice. If you don't knwo what you are doing, don't touch anything. if ($context->getIncludeBody()) { $buffer = $this->loadTranslations($context, $response) . "\n"; $response->appendToBody($buffer); } $buffer = ""; // 2nd step: call MyApplication::__run() if (class_exists($this->getApplicationClassName())) { call_user_func(array($this->getApplicationClassName(), '__run'), $context, $response); } $buffer .= "\n"; // 3rd step: include the main javascript file of the application if ($context->getIncludeBody()) { $buffer .= file_get_contents($this->getJavascriptPath()); } // 4th and final step: add a call to myapplication_application() to the returned JS buffer // that will execute the application code on the client side once loaded if ($context->getExecuteJavascript()) { // We need to pass an _Array_ (numerically-indexed) as argument, and not a JSON object $jsArgs = $context->getArgs()->getArrayCopy(); self::checkArgsValidity($jsArgs); $jsArgs = json_encode(array_values($jsArgs)); // Append $buffer .= "\n" . $this->getName() . '_application(' . $context->getProcess()->getChecknum() . ', ' . $context->getProcess()->getPid() . ', ' . $jsArgs . ');'; } $response->appendToBody($buffer); }