/** * Retorna url formatada * @param type $Controller_Action * @param array $Variables * @param type $Modulo * @param array $VariaveisGet * @param boolean $secure * @return string */ function url($Controller_Action = '', array $Variables = null, $Modulo = null, array $VariaveisGet = null, $secure = false) { # Base $url = base_url(); # Modulo if ($Modulo === null) { $Modulo = APP::getCurrentModule(); } if ($Modulo != APP::getDefaultModule() or $Controller_Action and APP::getModules(explode('/', $Controller_Action)[0])) { $url .= '/' . $Modulo; } # Controller/Action if (!empty($Controller_Action)) { if ($Variables) { if (count($ex = explode('/', $Controller_Action)) == 1) { if (controller_exists($ex[0])) { $url .= "/{$ex[0]}/index"; } else { $url .= '/index/' . $ex[0]; } } else { $url .= '/' . $Controller_Action; } } else { $url .= '/' . $Controller_Action; } } else { if ($Variables) { $url .= 'index/index'; } } # Variaveis if ($Variables) { # Chaves númericas if (key($Variables) === 0) { foreach ($Variables as $key => $value) { $url .= '/' . url_paranformat($value); } } else { foreach ($Variables as $key => $value) { $url .= '/' . url_paranformat($key) . '/' . url_paranformat($value); } } } # Retornando a URL if ($VariaveisGet) { $url .= '?' . http_build_query($VariaveisGet); } # HTTPS if ($secure) { $url = str_replace('http:', 'https:', $url); } return $url; }
function iframe($class, $method) { $parameters = CL_Router::get_instance()->fetch_parameters(); if (!controller_exists($class)) { header('HTTP/1.0 404 Not Found'); exit; } require_once APPPATH . 'controllers/' . $class . '.php'; $controller = new $class(); try { $res = call_user_func_array(array($controller, $method), array_slice($parameters, 2)); } catch (CL_Exception $e) { echo json_encode(array('type' => 'error', 'data' => array('errstr' => strip_tags($e->get_message()), 'errtype' => ''))); exit; } return_iframe($res); }
function quick_add_form() { $this->setLayout('empty'); if ($dimension_id = array_var($_GET, 'dimension_id')) { $dimension = Dimensions::instance()->findById($dimension_id); $dimensionOptions = $dimension->getOptions(true); $object_Types = array(); $parent_member_id = array_var($_GET, 'parent_member_id'); if ($parent_member_id) { $parent_member = Members::instance()->findById($parent_member_id); $object_types = DimensionObjectTypes::getChildObjectTypes($parent_member_id); } else { $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "dimension_id = {$dimension_id} AND is_root = 1 ")); } if (count($object_types)) { if (count($object_types) == 1) { // Input Hidden tpl_assign('object_type', $object_types[0]); tpl_assign('object_type_name', ObjectTypes::instance()->findById($object_types[0]->getObjectTypeId())->getName()); } else { // Input combo tpl_assign('object_types', $object_types); } } else { tpl_assign("error_msg", $parent_member->getName() . " does not accept child nodes "); } $editUrls = array(); foreach ($object_types as $object_type) { /* @var $object_type DimensionObjectType */ if (ObjectTypes::instance()->findById($object_type->getObjectTypeId())->getType() != 'dimension_object') { continue; } $options = $object_type->getOptions(1); if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") { $editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add'); } else { $t = ObjectTypes::instance()->findById($object_type->getObjectTypeId()); /* @var $t ObjectType */ $class_name = ucfirst($t->getName()) . "Controller"; if ($t && controller_exists($t->getName(), $t->getPluginId())) { $editUrls[$object_type->getObjectTypeId()] = get_url($t->getName(), 'add'); } else { $editUrls[$object_type->getObjectTypeId()] = get_url('member', 'add', array("dim_id" => $dimension_id)); } } } tpl_assign('editUrls', $editUrls); tpl_assign('parent_member_id', $parent_member_id); tpl_assign('dimension_id', $dimension_id); if (is_object($dimensionOptions) && is_object($dimensionOptions->quickAdd) && $dimensionOptions->quickAdd->formAction) { tpl_assign('form_action', ROOT_URL . "/" . $dimensionOptions->quickAdd->formAction); } else { tpl_assign('form_action', get_url('member', 'add', array('quick' => '1'))); } } else { die("SORRY. Invalid dimension"); } }
function controller_execute(&$framework) { $controller_path = CONTROLLER_PATH . strtolower("{$framework->controller}.php"); controller_exists($controller_path); // Проверка существования Контроллера require_once $controller_path; $controller = new $framework->controller(&$framework); // Создание контроллера $action = $framework->action; action_exists($controller, $action); // Проверка на существование действия в контроллере $controller->{$action}(); // Вызов действия контроллера $controller->delete_flash(); unset($controller); // Удаление объекта контроллера (вызов деструктора + запуск after фильтров) exit; }
function quick_add_form() { ajx_current("empty"); $this->setLayout('empty'); $dimension_id = array_var($_GET, 'dimension_id'); $dimension = is_numeric($dimension_id) ? Dimensions::instance()->findById($dimension_id) : null; if ($dimension instanceof Dimension) { $object_Types = array(); $parent_member_id = array_var($_GET, 'parent_member_id'); $parent_member = Members::instance()->findById($parent_member_id); if ($parent_member instanceof Member) { $object_types = DimensionObjectTypes::getChildObjectTypes($parent_member); if (count($object_types) == 0) { $parent_member = null; $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')")); } } else { $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')")); } $obj_types = array(); $editUrls = array(); foreach ($object_types as $object_type) { $options = $object_type->getOptions(1); if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") { $editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add'); } else { $t = ObjectTypes::instance()->findById($object_type->getObjectTypeId()); $obj_types[$t->getId()] = $t; $class_name = ucfirst($t->getName()) . "Controller"; $controller_exists = controller_exists($t->getName(), $t->getPluginId()); if ($controller_exists) { Env::useController(ucfirst($t->getName())); eval('$controller = new ' . $class_name . '();'); } if ($t && controller_exists($t->getName(), $t->getPluginId()) && $t->getHandlerClass() != '' && $controller_exists && method_exists($controller, 'add')) { $params = array("type" => $t->getId()); if ($parent_member instanceof Member) { $params['parent'] = $parent_member->getId(); } $editUrls[$t->getId()] = get_url($t->getName(), 'add', $params); } else { $params = array("dim_id" => $dimension_id, "type" => $t->getId()); if ($parent_member instanceof Member) { $params['parent'] = $parent_member->getId(); } $editUrls[$t->getId()] = get_url('member', 'add', $params); } } } $urls = array(); foreach ($editUrls as $ot_id => $url) { $ot = array_var($obj_types, $ot_id); if ($ot instanceof ObjectType) { $link_text = ucfirst(strtolower(lang('new ' . $ot->getName()))); $iconcls = $ot->getIconClass(); } else { $link_text = lang('new'); $iconcls = ""; } $urls[] = array('link_text' => $link_text, 'url' => $url, 'iconcls' => $iconcls); } Hook::fire('member_quick_add_urls', array('dimension' => $dimension, 'object_types' => $object_types, 'parent_member' => $parent_member), $urls); if (count($urls) > 1) { ajx_extra_data(array('draw_menu' => 1, 'urls' => $urls)); } else { ajx_extra_data(array('urls' => $urls)); } } else { Logger::log("Invalid dimension: {$dimension_id}"); } }
* Load the Common functions file */ require_once SYSPATH . 'codelite/Common.php'; set_error_handler('error_handler'); set_exception_handler('exception_handler'); /* * *************************************************************** * Load some classes */ $router = CL_Router::get_instance(); $out = CL_Output::get_instance(); /* * *************************************************************** * Retrieve class and method */ $class = $router->fetch_class(); $method = $router->fetch_method(); $parameters = $router->fetch_parameters(); if (!controller_exists($class)) { header('HTTP/1.0 404 Not Found'); show_error("Controller {$class} not found.", 'Controller Error'); } require_once APPPATH . 'controllers/' . $class . '.php'; if (!controller_is_callable($class, $method)) { header('HTTP/1.0 404 Not Found'); show_error("Requested controller {$class}/{$method} is not callable. Does the method <b>{$method}</b> exist?", "Controller Error"); } $controller = new $class(); call_user_func_array(array($controller, $method), $parameters); $controller->end(); $out->display(); //echo "exec " . (microtime(TRUE) - $start); exit;
/** * Method : load_controller * will include the specified Controller class in the API , if it exist in the Controllers folder */ function load_controller($endpoint) { if (controller_exists($endpoint)) { $filename = str_replace("/Functions", "", dirname(__FILE__)); $filename .= '/Controllers/' . $endpoint . '.php'; include_once $filename; } else { new Error(1); } }
/** * Inicia a aplicação * @param array $APPConfig * @param string $PublicPath */ static function Initialize(array $APPConfig, $PublicPath = 'public_html') { APP::setGlobal('public_path', $PublicPath); $Action = $Controller = null; self::$APP_CONFIG = $APPConfig; self::$Modules = isset(self::$APP_CONFIG['modules']) ? self::$APP_CONFIG['modules'] : self::$APP_CONFIG; self::$DefaultModule = key(self::$Modules); # URL Variables $values = !empty($_GET['GET_VARS']) ? explode('/', strtolower($_GET['GET_VARS'])) : [self::$DefaultModule, 'index', 'index']; # Modulo if (isset(self::$Modules[$values[0]])) { self::$CurrentModule = $values[0]; unset($values[0]); $values = array_values($values); } else { self::$CurrentModule = self::$DefaultModule; } # Controller if (empty($values[0]) or controller_exists(strtolower($values[0])) === false) { $Controller = 'index'; } else { $Controller = $values[0]; unset($values[0]); $values = array_values($values); } # Action if (empty($values[0]) and controller_action_exists($Controller, 'index')) { $Action = 'indexAction'; } else { if (empty($values[0]) or !($Action = controller_action_exists($Controller, $values[0]))) { self::$Parans['action'] = strtolower(@$values[0]); $Action = 'notFoundPage'; } else { unset($values[0]); $values = array_values($values); } } # Parâmetros númericos self::$Parans = $values; # Parâmetros nomeados if (count(self::$Parans) > 1) { for ($i = 0; $i < count($values); $i += 2) { if (isset($values[$i + 1])) { self::$Parans[$values[$i]] = $values[$i + 1]; } } } # Modulo if (!isset(self::$Parans['module'])) { self::$Parans['module'] = APP::getCurrentModule(); } # Controller if (!isset(self::$Parans['controller'])) { self::$Parans['controller'] = APP::getControllerName(); } # Action if (!isset(self::$Parans['action'])) { self::$Parans['action'] = $Action; } # Valores GET if (preg_match('/\\?/', inputServer('REQUEST_URI'))) { parse_str(preg_replace('/.*\\?/', NULL, inputServer('REQUEST_URI')), $getValues); foreach ($getValues as $key => $value) { $_GET[$key] = $value; if (!isset(self::$Parans[$key])) { self::$Parans[$key] = $value; } } } # Action self::$Action = $Action; # Cria instancia do modulo if (file_exists($ModuleClass = ABSPATH . '/' . self::getCurrentModule(true) . '/Module.class.php')) { file_include($ModuleClass); self::$Module = new Module(); } # Executando a action self::setController($Controller); self::getController()->{$Action}(); }
require APPPATH . "app/helper/{$file}.php"; } foreach ($config['autoload_languages'] as $file) { require APPPATH . "app/languages/" . get_site_lang() . "/{$file}.php"; } $session = new Session(); session_set_save_handler(array(&$session, '_open'), array(&$session, '_close'), array(&$session, '_read'), array(&$session, '_write'), array(&$session, '_destroy'), array(&$session, '_clean')); session_start(); $params = get_controller_params($_GET); if (isset($_GET['u']) and isset($params['lang'])) { if (!is_valid_site_lang()) { redirect('/'); } } if (isset($params['controller'])) { if (controller_exists($params['controller'])) { $obj = new $params['controller'](); if (isset($params['method'])) { if (is_callable(array($obj, $params['method']))) { echo call_user_func_array(array($obj, $params['method']), $params['args']); } else { display_page_error(); } } else { if (is_callable(array($obj, 'index'))) { echo call_user_func_array(array($obj, 'index'), array()); } else { display_page_error(); } } } else {