/** * Set Certain Default Control Panel View Variables * * @access public * @return void */ function set_default_view_variables() { $js_folder = ee()->config->item('use_compressed_js') == 'n' ? 'src' : 'compressed'; $langfile = substr(ee()->router->class, 0, strcspn(ee()->router->class, '_')); // Javascript Path Constants define('PATH_JQUERY', PATH_THEMES . 'javascript/' . $js_folder . '/jquery/'); define('PATH_JAVASCRIPT', PATH_THEMES . 'javascript/' . $js_folder . '/'); define('JS_FOLDER', $js_folder); ee()->load->library('javascript', array('autoload' => FALSE)); ee()->load->model('member_model'); // for screen_name, quicklinks ee()->lang->loadfile($langfile); // Success/failure messages $cp_messages = array(); foreach (array('message_success', 'message_notice', 'message_error', 'message_failure') as $flash_key) { if ($message = ee()->session->flashdata($flash_key)) { $flash_key = $flash_key == 'message_failure' ? 'error' : substr($flash_key, 8); $cp_messages[$flash_key] = $message; } } $cp_table_template = array('table_open' => '<table class="mainTable" border="0" cellspacing="0" cellpadding="0">'); $cp_pad_table_template = array('table_open' => '<table class="mainTable padTable" border="0" cellspacing="0" cellpadding="0">'); $user_q = ee()->member_model->get_member_data(ee()->session->userdata('member_id'), array('screen_name', 'notepad', 'quick_links', 'avatar_filename', 'avatar_width', 'avatar_height')); $notepad_content = $user_q->row('notepad') ? $user_q->row('notepad') : ''; // Global view variables $vars = array('cp_page_onload' => '', 'cp_page_title' => '', 'cp_breadcrumbs' => array(), 'cp_right_nav' => array(), 'cp_messages' => $cp_messages, 'cp_notepad_content' => $notepad_content, 'cp_table_template' => $cp_table_template, 'cp_pad_table_template' => $cp_pad_table_template, 'cp_theme_url' => $this->cp_theme_url, 'cp_current_site_label' => ee()->config->item('site_name'), 'cp_screen_name' => $user_q->row('screen_name'), 'cp_avatar_path' => $user_q->row('avatar_filename') ? ee()->config->slash_item('avatar_url') . $user_q->row('avatar_filename') : '', 'cp_avatar_width' => $user_q->row('avatar_filename') ? $user_q->row('avatar_width') : '', 'cp_avatar_height' => $user_q->row('avatar_filename') ? $user_q->row('avatar_height') : '', 'cp_quicklinks' => $this->_get_quicklinks($user_q->row('quick_links')), 'EE_view_disable' => FALSE, 'is_super_admin' => ee()->session->userdata['group_id'] == 1 ? TRUE : FALSE); // global table data ee()->session->set_cache('table', 'cp_template', $cp_table_template); ee()->session->set_cache('table', 'cp_pad_template', $cp_pad_table_template); // we need these paths again in my account, so we'll keep track of them // kind of hacky, but before it was accessing _ci_cache_vars, which is worse ee()->session->set_cache('cp_sidebar', 'cp_avatar_path', $vars['cp_avatar_path'])->set_cache('cp_sidebar', 'cp_avatar_width', $vars['cp_avatar_width'])->set_cache('cp_sidebar', 'cp_avatar_height', $vars['cp_avatar_height']); if (ee()->router->method != 'index') { $this->set_breadcrumb(BASE . AMP . 'C=' . ee()->router->class, lang(ee()->router->class)); } // The base javascript variables that will be available globally through EE.varname // this really could be made easier - ideally it would show up right below the main // jQuery script tag - before the plugins, so that it has access to jQuery. // If you use it in your js, please uniquely identify your variables - or create // another object literal: // Bad: EE.test = "foo"; // Good: EE.unique_foo = "bar"; EE.unique = { foo : "bar"}; $js_lang_keys = array('logout' => lang('logout'), 'search' => lang('search'), 'session_idle' => lang('session_idle')); require_once APPPATH . 'libraries/El_pings' . EXT; $pings = new El_pings(); ee()->javascript->set_global(array('BASE' => str_replace(AMP, '&', BASE), 'XID' => CSRF_TOKEN, 'CSRF_TOKEN' => CSRF_TOKEN, 'PATH_CP_GBL_IMG' => PATH_CP_GBL_IMG, 'CP_SIDEBAR_STATE' => ee()->session->userdata('show_sidebar'), 'username' => ee()->session->userdata('username'), 'registered' => $pings->is_registered(), 'router_class' => ee()->router->class, 'lang' => $js_lang_keys, 'THEME_URL' => $this->cp_theme_url, 'hasRememberMe' => (bool) ee()->remember->exists())); // Combo-load the javascript files we need for every request $js_scripts = array('ui' => array('core', 'widget', 'mouse', 'position', 'sortable', 'dialog'), 'plugin' => array('ee_interact.event', 'ee_broadcast.event', 'ee_notice', 'ee_txtarea', 'tablesorter', 'ee_toggle_all'), 'file' => array('json2', 'underscore', 'cp/global_start')); if ($this->cp_theme != 'mobile') { $js_scripts['plugin'][] = 'ee_navigation'; } $this->add_js_script($js_scripts); $this->_seal_combo_loader(); ee()->load->vars($vars); }
protected function validateLicense() { $license = ee('License')->getEELicense(); require_once APPPATH . 'libraries/El_pings.php'; $pings = new El_pings(); $registered = $pings->is_registered($license); if (!$license->isValid()) { $alert = ee('CP/Alert')->makeBanner('invalid-license')->asWarning()->cannotClose()->withTitle(lang('software_unregistered')); foreach ($license->getErrors() as $key => $value) { if ($key == 'missing_pubkey') { $alert->addToBody(sprintf(lang($key), 'https://store.ellislab.com/manage')); } else { $alert->addToBody(sprintf(lang($key), ee('CP/URL')->make('settings/license'))); } } $alert->now(); } return $license; }