Example #1
0
 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 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;
 }
Example #3
0
 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;
 }
Example #4
0
 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));
 }