Ejemplo n.º 1
0
 static function boot()
 {
     $pathinfo = request::getPathInfo();
     // 生成part
     if (isset($pathinfo[1])) {
         if ($p = strpos($pathinfo, '/', 2)) {
             $part = substr($pathinfo, 0, $p);
         } else {
             $part = $pathinfo;
         }
     } else {
         $part = '/';
     }
     if ($part == '/openapi') {
         return kernel::single('base_rpc_service')->process($pathinfo);
     } elseif ($part == '/app-doc') {
         //cachemgr::init();
         return kernel::single('base_misc_doc')->display($pathinfo);
     }
     // 确认是否安装流程. 如果是安装流程则开启debug. 如果不是则检查是否安装, 如果未安装则跳到安装流程
     // 目前其他的url, 都应移到routes中进行
     //
     if ($part == '/setup') {
         config::set('app.debug', true);
     } else {
         static::checkInstalled();
     }
     cacheobject::init();
     static::registRouteMiddleware();
     $response = route::dispatch(request::instance());
     // 临时处理方式
     kernel::single('base_session')->close();
     $response->send();
     exit;
 }
 function _init_search_query_object()
 {
     $request = request::instance();
     if ($search_query = trim($request->get_attribute('search_query'))) {
         $this->query_object->add(search_text_normalizer::process($search_query));
     }
 }
 function &get_dataset($params = array())
 {
     $request = request::instance();
     if (!($class_id = $request->get_attribute('class_id'))) {
         return new array_dataset();
     }
     $db_table =& db_table_factory::instance('sys_class');
     $class_data = $db_table->get_row_by_id($class_id);
     if (!$class_data) {
         return new array_dataset();
     }
     $c =& site_object_factory::instance($class_data['class_name']);
     $site_object_controller =& $c->get_controller();
     $actions = $site_object_controller->get_actions_definitions();
     $user_groups =& fetch_sub_branch('/root/user_groups', 'user_group', $counter);
     $result = array();
     foreach ($user_groups as $group_id => $group_data) {
         foreach ($actions as $action => $action_params) {
             if (!isset($action_params['can_have_access_template']) || !$action_params['can_have_access_template']) {
                 continue;
             }
             if (isset($action_params['action_name'])) {
                 $result[$group_id]['actions'][$action]['action_name'] = $action_params['action_name'];
             } else {
                 $result[$group_id]['actions'][$action]['action_name'] = str_replace('_', ' ', strtoupper($action[0]) . substr($action, 1));
             }
             $result[$group_id]['group_name'] = $group_data['identifier'];
             $result[$group_id]['actions'][$action]['read_selector_name'] = 'template[' . $action . '][' . $group_id . '][r]';
             $result[$group_id]['actions'][$action]['write_selector_name'] = 'template[' . $action . '][' . $group_id . '][w]';
         }
     }
     return new array_dataset($result);
 }
 function render_attributes()
 {
     if (!isset($this->attributes['path']) || !$this->attributes['path']) {
         $action_path = $_SERVER['PHP_SELF'];
         $request = request::instance();
         if ($node_id = $request->get_attribute('node_id')) {
             $action_path .= '?node_id=' . $node_id;
         }
     } else {
         $action_path = $this->attributes['path'];
     }
     if (strpos($action_path, '?') === false) {
         $action_path .= '?';
     } else {
         $action_path .= '&';
     }
     if (isset($this->attributes['action'])) {
         $action_path .= 'action=' . $this->attributes['action'];
     }
     if (isset($this->attributes['reload_parent']) && $this->attributes['reload_parent']) {
         $action_path .= '&reload_parent=1';
         unset($this->attributes['reload_parent']);
     }
     if (!isset($this->attributes['onclick'])) {
         $this->attributes['onclick'] = '';
     }
     $this->attributes['onclick'] .= "submit_form(this.form, '{$action_path}')";
     unset($this->attributes['path']);
     unset($this->attributes['action']);
     parent::render_attributes();
 }
  function & get_dataset($params = array())
  {
    $request = request :: instance();

    if(!$controller_id = $this->_get_controller_id())
      return new array_dataset();

    $db_table =& db_table_factory :: instance('sys_controller');
    $controller_data = $db_table->get_row_by_id($controller_id);

    if (!$controller_data)
      return new array_dataset();

    $site_object_controller =& site_object_controller :: create($controller_data['name']);

    $actions = $site_object_controller->get_actions_definitions();

    $result = array();
    foreach($actions as $action => $action_params)
    {
      if (!isset($action_params['can_have_access_template']) || !$action_params['can_have_access_template'])
        continue;

      if(isset($action_params['action_name']))
        $result[$action]['action_name'] = $action_params['action_name'];
      else
        $result[$action]['action_name'] = str_replace('_', ' ', strtoupper($action{0}) . substr($action, 1));
    }

    return new array_dataset($result);
  }
 function &get_dataset(&$counter, $params = array())
 {
     $counter = 0;
     $request = request::instance();
     if (!($version = $request->get_attribute('version'))) {
         return new empty_dataset();
     }
     if (!($node_id = $request->get_attribute('version_node_id'))) {
         return new empty_dataset();
     }
     $version = (int) $version;
     $node_id = (int) $node_id;
     if (!($site_object = wrap_with_site_object(fetch_one_by_node_id($node_id)))) {
         return new empty_dataset();
     }
     if (!is_subclass_of($site_object, 'content_object')) {
         return new empty_dataset();
     }
     if (($version_data = $site_object->fetch_version($version)) === false) {
         return new empty_dataset();
     }
     $result = array();
     foreach ($version_data as $attrib => $value) {
         $data['attribute'] = $attrib;
         $data['value'] = $value;
         $result[] = $data;
     }
     return new array_dataset($result);
 }
 function save()
 {
     $request =& request::instance();
     $tab_id = session_history_manager::datermine_tab_id();
     if (!($history = session::get('session_history'))) {
         $history = array();
     }
     if (!isset($history[$tab_id])) {
         $history[$tab_id] = array();
     }
     $uri =& $request->get_uri();
     $uri->remove_query_item('rn');
     if ($uri->get_query_item('popup')) {
         return;
     }
     $object_data = fetch_requested_object();
     if ($object_data['class_name'] == 'control_panel') {
         return;
     }
     $history_item = array('title' => $object_data['title'], 'href' => $uri->to_string());
     $first = end($history[$tab_id]);
     if ($first) {
         $latest_uri =& new uri($first['href']);
         if ($uri->compare($latest_uri)) {
             return;
         }
     }
     if (count($history[$tab_id]) >= 10) {
         $history[$tab_id] = array_reverse($history[$tab_id]);
         array_pop($history[$tab_id]);
         $history[$tab_id] = array_reverse($history[$tab_id]);
     }
     array_push($history[$tab_id], $history_item);
     session::set('session_history', $history);
 }
 function &get_dataset($params = array())
 {
     $request = request::instance();
     if (!($controller_id = $request->get_attribute('controller_id'))) {
         return new array_dataset();
     }
     $db_table =& db_table_factory::instance('sys_controller');
     $controller_data = $db_table->get_row_by_id($controller_id);
     if (!$controller_data) {
         return new array_dataset();
     }
     $site_object_controller =& site_object_controller::create($controller_data['name']);
     $actions = $site_object_controller->get_actions_definitions();
     $user_groups =& fetch_sub_branch('/root/user_groups', 'user_group', $counter);
     $result = array();
     foreach ($actions as $action => $action_params) {
         if (isset($action_params['action_name'])) {
             $result[$action]['action_name'] = $action_params['action_name'];
         } else {
             $result[$action]['action_name'] = str_replace('_', ' ', strtoupper($action[0]) . substr($action, 1));
         }
         $result[$action]['permissions_required'] = $action_params['permissions_required'];
         foreach ($user_groups as $group_id => $group_data) {
             $result[$action]['groups'][$group_id]['selector_name'] = 'policy[' . $group_id . '][' . $action . ']';
         }
     }
     return new array_dataset($result);
 }
  function determine_action($request = null)
  {
    if($request === null)
      $request =& request :: instance();

    if (!$action = $request->get_attribute('action'))
      $action = $this->_default_action;

    if (!$this->action_exists($action))
    {
      debug :: write_warning(
        'action not found',
        __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__,
        array(
          'class' => get_class($this),
          'action' => $action,
          'default_action' => $this->_default_action
        ));
      return false;
    }

    $this->_current_action = $action;

    return $this->_current_action;
  }
 function render_attributes()
 {
     $this->_process_attributes();
     if (!$this->path) {
         $action_path = $_SERVER['PHP_SELF'];
         $request = request::instance();
         if ($node_id = $request->get_attribute('node_id')) {
             $action_path .= '?node_id=' . $node_id;
         }
     } else {
         $action_path = $this->path;
     }
     if (strpos($action_path, '?') === false) {
         $action_path .= '?';
     } else {
         $action_path .= '&';
     }
     if ($this->action) {
         $action_path .= 'action=' . $this->action;
     }
     if ((bool) $this->reload_parent) {
         $action_path .= '&reload_parent=1';
     }
     $this->attributes['onclick'] = $this->onclick;
     $this->attributes['onclick'] .= "submit_form(this.form, '{$action_path}')";
     parent::render_attributes();
     unset($this->attributes['onclick']);
 }
Ejemplo n.º 11
0
function add_url_query_items($url, $items=array())
{
	$str_params = '';

  $request = request :: instance();
  
  if (($node_id = $request->get_attribute('node_id')) && !isset($items['node_id']))
		$items['node_id'] = $node_id;
	
	if(strpos($url, '?') === false)
		$url .= '?';
	
	foreach($items as $key => $val)
	{
		$url = preg_replace("/&*{$key}=[^&]*/", '', $url);
		$str_params .= "&$key=$val";
	}
	
	$items = explode('#', $url);
	
	$url = $items[0];
	$fragment = isset($items[1]) ? '#' . $items[1] : '';
	
	return $url . $str_params . $fragment;
}
 function &get_dataset($params = array())
 {
     $request = request::instance();
     if (!($class_id = $request->get_attribute('class_id'))) {
         return new array_dataset();
     }
     $db_table =& db_table_factory::instance('sys_class');
     $class_data = $db_table->get_row_by_id($class_id);
     if (!$class_data) {
         return new array_dataset();
     }
     $c =& site_object_factory::instance($class_data['class_name']);
     $site_object_controller =& $c->get_controller();
     $actions = $site_object_controller->get_actions_definitions();
     $result = array();
     foreach ($actions as $action => $action_params) {
         if (!isset($action_params['can_have_access_template']) || !$action_params['can_have_access_template']) {
             continue;
         }
         if (isset($action_params['action_name'])) {
             $result[$action]['action_name'] = $action_params['action_name'];
         } else {
             $result[$action]['action_name'] = str_replace('_', ' ', strtoupper($action[0]) . substr($action, 1));
         }
     }
     return new array_dataset($result);
 }
 function &_fetch(&$counter, $params)
 {
     $items =& parent::_fetch($counter, $params);
     if (!count($items)) {
         return array();
     }
     reset($items);
     $request = request::instance();
     if (!($current_id = $request->get_attribute('id'))) {
         $current_id = $items[key($items)]['id'];
     }
     foreach ($items as $id => $item) {
         if ($current_id == $item['id']) {
             $current_item = $item;
             break;
         } else {
             next($items);
         }
     }
     $result = array();
     $result['prev'] = array($this->_get_prev_item($items, $current_id));
     $result['next'] = array($this->_get_next_item($items, $current_id));
     $result['current'] = array($current_item);
     $result['prev']['presentation_path'] = $params['path'];
     $result['next']['presentation_path'] = $params['path'];
     $result['current']['presentation_path'] = $params['path'];
     return array($result);
 }
Ejemplo n.º 14
0
 protected static function getFacadeAccessor()
 {
     if (!static::$__url) {
         $routes = route::getRoutes();
         static::$__url = new base_routing_urlgenerator($routes, request::instance());
     }
     return static::$__url;
 }
Ejemplo n.º 15
0
 protected static function getFacadeAccessor()
 {
     if (!static::$__router) {
         static::$__router = kernel::single('base_routing_router', request::instance());
         route::boot();
     }
     return static::$__router;
 }
 function &_get_request()
 {
     if (is_object($this->request)) {
         return $this->request;
     }
     //ugly!?
     return request::instance();
 }
  function & _fetch_object_data()
  {
    $request =& request :: instance();

    if($object_id = $request->get_attribute('object_id'))
      return fetch_one_by_id($object_id);
    else
      return fetch_requested_object();
  }
 function _configure_stats_event_report_filter()
 {
     $request = request::instance();
     $this->_set_ip_filter($request);
     $this->_set_login_filter($request);
     $this->_set_action_filter($request);
     $this->_set_period_filter($request);
     $this->_set_uri_filter($request);
     $this->_set_status_filter($request);
 }
 function fetch_requested_object()
 {
     $object_arr = fetch_requested_object();
     $request = request::instance();
     if ($version = $request->get_attribute('version')) {
         $site_object = site_object_factory::create($object_arr['class_name']);
         $site_object->import_attributes($object_arr);
         $object_arr = $site_object->fetch_version((int) $version);
     }
     $this->import($object_arr);
 }
  function _get_controller_id()
  {
    $request = request :: instance();
    if($controller_id = $request->get_attribute('controller_id'))
      return $controller_id;

    if($object_id = $request->get_attribute('object_id'))
      $object_data =& fetch_one_by_id($object_id);
    else
      $object_data =& fetch_requested_object();

    return $object_data['controller_id'];
  }  
 function get_value()
 {
     $form =& $this->find_parent_by_class('form_component');
     if ($form->is_first_time()) {
         $request = request::instance();
         if ($value = $request->get_attribute($this->attributes['name'])) {
             return $value;
         } else {
             return '';
         }
     } else {
         return parent::get_value();
     }
 }
  function run()
  {
    $request =& request :: instance();
    $response =& new http_response();

    $response->set_redirect_strategy($this->_get_default_redirect_strategy());

    $filter_chain =& new filter_chain($request, $response);

    $this->_register_filters($filter_chain);

    $filter_chain->process();

    $response->commit();
  }
 function append_request_attributes(&$content)
 {
     $transfer_attributes = explode(',', $this->get_attribute('attributes'));
     $attributes_to_append = array();
     $request = request::instance();
     foreach ($transfer_attributes as $attribute) {
         if ($value = $request->get_attribute($attribute)) {
             $attributes_to_append[] = $attribute . '=' . addslashes($value);
         }
     }
     if ($this->attributes_string = implode('&', $attributes_to_append)) {
         $callback = array(&$this, '_replace_callback');
         $content = preg_replace_callback("/(<(?:a|area|form|frame|input)[^>\\w]+(?:href|action|src)=)(?>(\"|'))?((?(2)[^\\2>]+?|[^\\s>]+))((?(2)\\2)[^>]*>)/", $callback, $content);
     }
 }
 function &get_dataset(&$counter, $params = array())
 {
     $counter = 0;
     $request = request::instance();
     if (!($controller_id = $request->get_attribute('controller_id'))) {
         return new array_dataset();
     }
     $db_table =& db_table_factory::instance('sys_controller');
     $controller_data = $db_table->get_row_by_id($controller_id);
     if ($controller_data) {
         $counter = 1;
         return new array_dataset(array(0 => $controller_data));
     } else {
         return new array_dataset(array());
     }
 }
 function run()
 {
     $request =& request::instance();
     $response =& new http_response();
     $filter_chain =& new filter_chain($request, $response);
     $this->_register_filters($filter_chain);
     $filter_chain->process();
     if ($response->get_content_type() == 'text/html' && $response->get_status() == 200) {
         if (debug::is_console_enabled()) {
             $response->write(debug::parse_html_console());
         }
         $response->write(message_box::parse());
         //It definetly should be somewhere else!
     }
     $response->commit();
 }
 function run()
 {
     $this->_inititiliaze_user_session();
     $request =& request::instance();
     $response =& new http_response();
     $filter_chain =& new filter_chain($request, $response);
     $this->_register_filters($filter_chain);
     $filter_chain->process();
     if (!$response->file_sent()) {
         if (debug::is_console_enabled()) {
             echo debug::parse_html_console();
         }
         echo message_box::parse();
         //It definetly should be somewhere else!
     }
     $response->commit();
 }
 function get_search_query_object()
 {
     if ($this->query_object) {
         return $this->query_object;
     }
     $request = request::instance();
     if (!($search_query = trim($request->get_attribute('search_query')))) {
         return null;
     }
     $this->query_object = new search_query();
     $search_query = search_text_normalizer::process($search_query);
     $words = explode(' ', $search_query);
     foreach ($words as $word) {
         $this->query_object->add($word);
     }
     return $this->query_object;
 }
 function _process_path()
 {
     $default_path = '/root/';
     $request = request::instance();
     if (!($path = $request->get_attribute('path'))) {
         return $default_path;
     }
     if (strpos($path, '?') !== false) {
         if (!($node = map_url_to_node($path))) {
             return $default_path;
         }
         $tree =& tree::instance();
         if (!($path = $tree->get_path_to_node($node))) {
             return $default_path;
         }
     }
     return $path;
 }
  function render_attributes()
  {
    $this->_process_attributes();

    if (!$this->path)
    {
      $action_path = $_SERVER['PHP_SELF'];

      $request = request :: instance();

      if($node_id = $request->get_attribute('node_id'))
        $action_path .= '?node_id=' . $node_id;
    }
    else
      $action_path = $this->path;

    if (strpos($action_path, '?') === false)
      $action_path .= '?';
    else
      $action_path .= '&';

    if($this->action)
      $action_path .= 'action=' . $this->action;

    if ((bool)$this->reload_parent)
    {
      $action_path .= '&reload_parent=1';
    }

    $window_name = '';
    if($this->target)
      $window_name = ", '{$this->target}'";

    $this->attributes['onclick'] = $this->onbeforeclick;
    $this->attributes['onclick'] .= $this->onclick;
    $this->attributes['onclick'] .= "submit_form(this.form, '{$action_path}'{$window_name});";
    $this->attributes['onclick'] .= $this->onafterclick;

    parent :: render_attributes();

    unset($this->attributes['onclick']);
  }
Ejemplo n.º 30
0
 function activate_password()
 {
     $request = request::instance();
     if (!($email = $request->get_attribute('user'))) {
         return false;
     }
     if (!($password = $request->get_attribute('id'))) {
         return false;
     }
     $user_data = $this->get_user_by_email($email);
     if ($password != $user_data['password'] || empty($user_data['generated_password'])) {
         return false;
     }
     $this->import_attributes($user_data);
     $this->set_attribute('password', $user_data['generated_password']);
     $this->set_attribute('generated_password', '');
     return $this->update(false);
 }