public static function render($module_registry_key, $component, $parameters = null) { $module = ModuleRegistry::module($module_registry_key); $component_source = $module::model()->components->forms; $component_object = FormComponent::fetchObject($component_source, $component, $parameters == null ? array() : !is_array($parameters) ? array($parameters) : $parameters); return FormComponent::render($component_object); }
public static function index() { $console_module = ModuleRegistry::model()['Console']; $file = $console_module::model()->assets->html['page']; header("Content-type: text/html", true); echo file_get_contents($file, true); }
public static function collections($collection = 'collections', $key = null) { $module = static::$module; if ($collection == 'collections' && isset($module::model()->assets->boot_collections)) { $collections = $module::model()->assets->boot_collections; echo '{'; echo "\n"; foreach ($collections as $loop_key => $collection) { if ($loop_key != 0) { echo ",\n"; } echo '"' . $collection . '":'; echo self::collections($collection); } echo "\n"; echo '}'; return; } $modules = ModuleRegistry::modules(); foreach ($modules as $module) { if (!empty($module::model()->collections)) { if (isset($collection) && in_array($collection, ApplicationRoutes::routes($module::model()->collections))) { forward_static_call_array(array($module::model()->collections, ApplicationRoutes::route($module::model()->collections, $collection)), $key != null ? array($key) : array()); return; } } } return; }
public static function login($json = null) { $module = static::$module; $dialogs = $module::model()->components->dialogs; $dialog = forward_static_call_array(array($dialogs, __FUNCTION__), array()); if (!SessionStore::is($dialog->session_store_key)) { return; } $xhr_cards = $module::model()->xhr->cards; $operations_xhr = $module::model()->xhr->operations; $operations = $module::model()->operations; $modeler = $module::model()->modeler; if ($json != null) { $input = json_decode(rawurldecode($json)); if (isset($input->reset)) { SessionStore::set($dialog->session_store_key, $dialog->session_store_setup); return forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } } $dialog_store = SessionStore::get($dialog->session_store_key); $dialog_step = $dialog->steps[$dialog_store->step]; if (isset($dialog_step->prep) && $dialog_step->prep == true) { if (isset($dialog_step->required_members)) { foreach ($dialog_step->required_members as $m) { if (!isset($input->{$m})) { return; } } } switch ($dialog_store->step) { case 0: if (($modeler::exists(rawurldecode($input->login), 'email') || $modeler::exists(rawurldecode($input->login), 'name')) && \Sequode\Application\Modules\Account\Authority::isActive($modeler::model())) { $dialog_store->prep->user_id = $modeler::model()->id; SessionStore::set($dialog->session_store_key, $dialog_store); } else { $error = 1; } break; case 1: if ($modeler::exists($dialog_store->prep->user_id, 'id') && \Sequode\Application\Modules\Account\Authority::isPassword(rawurldecode($input->secret), $modeler::model())) { $_a = array($modeler::model()); } else { $error = 2; } break; } } if (isset($dialog_step->operation) && is_array($_a)) { if (!forward_static_call_array(array($operations, $dialog_step->operation), $_a)) { $error = 3; } } if (!isset($error)) { $dialog_store->step++; SessionStore::set($dialog->session_store_key, $dialog_store); $console_module = ModuleRegistry::model()['Console']; return intval($dialog_store->step) == 2 ? forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false)) : forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } }
public static function logout() { $module = static::$module; $operations = $module::model()->operations; forward_static_call_array(array($operations, __FUNCTION__), array()); $console_module = ModuleRegistry::model()['Console']; forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false)); }
public static function getOwnedModuleModels($module_registry_key, $_model = null, $fields = 'id') { $modeler = static::$modeler; $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model)); $module = ModuleRegistry::module($module_registry_key); $module_modeler = $module::model()->modeler; $where = array(); $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => $modeler::model()->id); $model = new $module_modeler::$model(); $model->getAll($where, $fields); return $model; }
public static function loginAs($_model_id) { $module = static::$module; $modeler = $module::model()->modeler; $operations = $module::model()->operations; $xhr_cards = $module::model()->xhr->cards; $input = json_decode(rawurldecode($json)); if (!(\Sequode\Application\Modules\Account\Authority::isSystemOwner() && $modeler::exists($_model_id, 'id'))) { return; } $operations::login(); $console_module = ModuleRegistry::model()['Console']; return forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false)); }
public static function xhr() { $call = false; $args = array(); if (isset($_POST['sub']) && !empty($_POST['sub'])) { $call = $_POST['sub']; } elseif (isset($_GET['sub']) && !empty($_GET['sub'])) { $call = $_GET['sub']; } $call_pieces = explode('/', $call); if (!isset($call_pieces[1])) { return; } if (!isset($call_pieces[2])) { return; } $context = strtolower($call_pieces[1]); $modules_context = ModuleRegistry::modulesContext(); if (!array_key_exists($context, $modules_context)) { return; } $module_key = $modules_context[$context]; $request_type = $call_pieces[0]; $module = ModuleRegistry::module($module_key); if (!isset($module::model()->xhr->{$request_type})) { return; } $routes_class = $module::model()->xhr->{$request_type}; if (!in_array($call_pieces[2], ApplicationRoutes::routes($routes_class))) { return; } $route = ApplicationRoutes::route($routes_class, $call_pieces[2]); if (isset($_POST['args']) && !empty($_POST['args'])) { if (500000 < strlen(http_build_query($_POST))) { return; } $args = $_POST['args']; } elseif (isset($_GET['args']) && !empty($_GET['args'])) { if (500000 < strlen(http_build_query($_GET))) { return; } $args = $_GET['args']; } echo XHRRequest::call($routes_class, $route, $args); return true; }
public static function menus($dom_id = 'MenusContainer') { $modules = ModuleRegistry::modules(); $html = $js = array(); $i = count($modules); foreach ($modules as $module) { $model = $module::model(); if (isset($model->components->cards)) { if (in_array('menu', get_class_methods($model->components->cards))) { $i--; $card = ModuleCard::render($module::$registry_key, 'menu'); $html[] = CardKitHTML::menuCardHidingContainer($card->html, $i); $js[] = $card->js; } } } return DOMElementKitJS::addIntoDom($dom_id, implode('', $html), 'replace') . implode(' ', $js); }
public static function ownedItemsCollectionTile($module_registry_key, $headline = '', $user_model) { $module = ModuleRegistry::module($module_registry_key); $operations = $module::model()->operations; $context = $module::model()->context; $dom_id = FormInputComponent::uniqueHash('', ''); $html = $js = array(); $models = $operations::getOwnedModels($user_model, 'id,name')->all; $html[] = '<div class="automagic-content-area-xsmall-tile-container">'; $html[] = '<div class="automagic-card-menu-item noSelect" id="' . $dom_id . '">' . $headline . count($models) . '</div>'; $js[] = DOMElementKitJS::onTapEventsXHRCall($dom_id, DOMElementKitJS::xhrCallObject('cards/' . $context . '/my', array($object->id))); foreach ($models as $i => $object) { $html[] = '<div class="automagic-card-menu-item noSelect" id="' . $dom_id . $i . '">'; $html[] = $object->name; $html[] = '</div> '; $js[] = DOMElementKitJS::onTapEventsXHRCall($dom_id . $i, DOMElementKitJS::xhrCallObject('cards/' . $context . '/details', array($object->id))); } $html[] = '</div>'; return (object) array('html' => implode('', $html), 'js' => implode(' ', $js)); }