public static function getView($view, $data = array())
 {
     if (self::$instance == null) {
         self::$instance = new View();
     }
     self::$instance->render($view, $data);
 }
Exemple #2
0
 public function p_signup()
 {
     # Check if data was entered
     if ($_POST['first_name'] == "" || $_POST['last_name'] == "" || $_POST['password'] == "") {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Please enter all requested information");
     }
     # Check if email address is of the right form
     if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Please enter a valid email address");
     }
     # Check if passwords match
     if ($_POST['password'] != $_POST['password_check']) {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Passwords do not match");
     }
     # Remove the password check from the array
     unset($_POST['password_check']);
     # Encrypt the password
     $_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
     # More data we want stored with the user
     $_POST['created'] = Time::now();
     $_POST['modified'] = Time::now();
     $_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
     # Insert this user into the database
     $user_id = DB::instance(DB_NAME)->insert("users", $_POST);
     # Send the user to the signup success page
     $this->template->content = View::instance('v_users_signup_success');
     $this->template->title = "Success!";
     echo $this->template;
 }
Exemple #3
0
 public function edit()
 {
     if (isset($_POST['update'])) {
         if ($_POST['fields_name'] == '') {
             message(App::$lang['Fields name error']);
         }
         $field['name'] = $_POST['fields_name'] != '' ? '\'' . App::$forum_db->escape($_POST['fields_name']) . '\'' : NULL;
         $field['desc'] = $_POST['fields_desc'] != '' ? '\'' . App::$forum_db->escape($_POST['fields_desc']) . '\'' : NULL;
         $field['url'] = $_POST['fields_url'] != '' ? '\'' . App::$forum_db->escape($_POST['fields_url']) . '\'' : '\'\'';
         if (!isset($_POST['fields_in_vt']) || $_POST['fields_in_vt'] != '1') {
             $field['vt'] = '0';
         } else {
             $field['vt'] = '1';
         }
         $this->_fields->set_fields_by_uid($field, $this->uid);
         if ($_POST['field'] != $_POST['fields_name']) {
             $this->_fields->change_field('users', $_POST['field'], $_POST['fields_name']);
         }
         K_Fields_Module_Cache::fields();
         App::$forum_flash->add_info(App::$lang['Fields updated']);
         redirect(forum_link(App::$forum_url['admin_fields_id'], array($this->uid)), App::$lang['Fields updated']);
     } elseif (isset($_POST['delete'])) {
         $this->_fields->delete_field($this->uid);
         K_Fields_Module_Cache::fields();
         App::$forum_flash->add_info(App::$lang['Fields removed']);
         redirect(forum_link(App::$forum_url['admin_fields'], array($this->uid)), App::$lang['Fields removed']);
     } else {
         View::$instance = View::factory(FORUM_ROOT . 'extensions/k_fields/view/field_edit', array('records' => $this->_fields->get_fields_by_uid($this->uid)));
     }
 }
Exemple #4
0
 public function class1()
 {
     $this->template->content = View::instance("v_javascript_class1");
     $client_files = array("/js/class1.js");
     $this->template->client_files = Utils::load_client_files($client_files);
     echo $this->template;
 }
Exemple #5
0
 public function post_clientsList()
 {
     try {
         $chat = $this->orm->chat();
         $chat->select('id_chat, id_client_user, id_support_user, subject');
         $chat->select('TIMESTAMPDIFF(MINUTE, created, NOW()) AS waiting_minutes');
         $chat->select('LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, created, NOW())), 5) AS waiting_time');
         $chat->where('closed IS NULL');
         $chat->and('(id_support_user IS NULL')->or('id_support_user', $_SESSION['support_user']['id_user'])->where(')');
         $supportStatus = $this->orm->param[array('name' => 'STATUS')]['value'];
         $waitingTooMuch = $this->orm->param[array('name' => 'WAITING_TOO_MUCH')]['value'];
         $clients = array();
         $userOccupied = false;
         foreach ($chat as $row) {
             $clients[] = array('id_chat' => $row['id_chat'], 'id_support_user' => $row['id_support_user'], 'subject' => $row['subject'], 'waiting_too_much' => $row['waiting_minutes'] > $waitingTooMuch, 'waiting_time' => $row['waiting_time'], 'client_user_name' => $row->client_user['name'], 'client_user_sex' => str_replace(array('M', 'F'), array('male', 'female'), $row->client_user['sex']), 'client_user_email' => $row->client_user['email']);
             if ($row['id_support_user']) {
                 $userOccupied = true;
             }
         }
         $view = View::instance();
         $view->clients = $clients;
         $view->supportStatus = $supportStatus;
         $view->userOccupied = $userOccupied;
         $view->render('partial/clients-list');
     } catch (Exception $e) {
         print '
             <tr>
                 <td colspan="6">
                     <div class="result-error">Error occurred</div>
                 </td>
             </tr>
         ';
     }
 }
Exemple #6
0
 public function p_fill_request_table($option)
 {
     //NOT USED. Old style that injects directly into the page
     # Set up view...
     $template = View::instance('v_requests_index_sub1');
     if ($option == 'all') {
         $q = 'SELECT request_id,constructName, program, date, projectSponsor, u.first_name,u.last_name
             FROM requests r
             INNER JOIN users u
             ON u.user_id = r.client_id;';
     } else {
         // only one other alternative at this point to 'all' for $option switch
         $q = 'SELECT request_id,constructName, program, date, projectSponsor, u.first_name,u.last_name
             FROM requests r
             INNER JOIN users u
             ON u.user_id = r.client_id
             where r.client_id =' . $this->user->user_id . ';';
     }
     # Run our query, store the results in the array $requests
     $requests = DB::instance(DB_NAME)->select_rows($q);
     # Pass data to the View
     $template->requests = $requests;
     # Render view...Whatever HTML we render is what JS will receive as a result of it's Ajax call
     echo $template;
 }
Exemple #7
0
 public static function &instance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #8
0
 public function index()
 {
     #$this->template->content = View::instance('v_users_signup');
     $q = "SHOW TABLES";
     #$tableDump = DB::instance(DB_NAME)->select_rows($q);
     #array(3) {
     # [0]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "posts" }
     # [1]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "users" }
     # [2]=> array(1) { ["Tables_in_rtizardc_p2_rtizard_com"]=> string(11) "users_users" } }
     $tableDump = DB::instance(DB_NAME)->select_rows($q, "array");
     #array(3)
     #{ [0]=> array(2) { [0]=> string(5) "posts" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "posts" }
     #[1]=> array(2) { [0]=> string(5) "users" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(5) "users" }
     #[2]=> array(2) { [0]=> string(11) "users_users" ["Tables_in_rtizardc_p2_rtizard_com"]=> string(11) "users_users" } }
     #$this->template->content = var_dump($tableDump);
     $i = 0;
     $tableArray = array();
     foreach ($tableDump as $row) {
         #echo $row[0].", ";
         $tableArray[$i] = $row[0];
         $i++;
     }
     $this->template->content = View::instance('v_data_index');
     $this->template->content->tableArray = $tableArray;
     #$this->template->content = var_dump($tableArray);
     $this->template->title = "Data";
     # Render template
     echo $this->template;
 }
Exemple #9
0
 public function view()
 {
     if (FALSE === ($user_thanks = $this->thanks->get_user($this->uid))) {
         message(App::$lang_common['Bad request']);
     }
     App::$forum_page['form_action'] = forum_link(App::$forum_url['thanks_delete'], $this->uid);
     View::$instance = View::factory($this->view . 'view', array('heading' => sprintf(App::$lang['User thanks'], forum_htmlencode($user_thanks['username'])) . '&nbsp;&nbsp;<strong>' . $user_thanks['thanks'] . '</strong>'));
     $count = $this->thanks->count_by_user_id($this->uid);
     if ($count > 0) {
         App::paginate($count, App::$forum_user['disp_topics'], App::$forum_url['thanks_view'], array($this->uid));
         if (App::$forum_user['g_id'] == FORUM_ADMIN) {
             /*
              * Fix table layout described on: http://punbb.ru/post31786.html#p31786
              */
             App::$forum_loader->add_css('#brd-thanks table{table-layout:inherit;}', array('type' => 'inline'));
             $template = 'view_admin';
         } else {
             $template = 'view_user';
         }
         View::$instance->content = View::factory($this->view . $template, array('records' => $this->thanks->get_info($this->uid, App::$forum_user['g_id'], App::$forum_page['start_from'], App::$forum_page['finish_at'])));
     } else {
         View::$instance->content = View::factory($this->view . 'view_empty', array('lang' => App::$lang));
     }
     App::$forum_page['crumbs'][] = array(sprintf(App::$lang['User thanks'], forum_htmlencode($user_thanks['username'])), forum_link(App::$forum_url['thanks_view'], $this->uid));
 }
 /**
  * View Singleton Factory method.
  * 
  * @return the Singleton instance of <code>View</code>
  */
 public static function getInstance()
 {
     if (is_null(View::$instance)) {
         View::$instance = new View();
     }
     return View::$instance;
 }
 public function __construct()
 {
     # Instantiate User obj
     $this->userObj = new User();
     # Authenticate / load user
     $this->user = $this->userObj->authenticate();
     # Set up templates
     $this->template = View::instance('_v_template');
     $this->email_template = View::instance('_v_email');
     # So we can use $user in views
     $this->template->set_global('user', $this->user);
     # Is this user connected to Twitter?
     if ($this->user) {
         # Ideally these constants should be in config.php but leaving here for demonstration purposes.
         define('CONSUMER_KEY', 'DaCTGU1jK93WxrZ5RKg');
         define('CONSUMER_SECRET', 'H9DS2HoWBv8PEseeg2bpQj9Ho9A0lq3GJgqEPRvfZ8');
         # Create object in user object to store twitter related data
         $this->user->twitter = new stdClass();
         # First, find out if they're already conected
         if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
             $this->user->twitter->connected = FALSE;
         } else {
             $this->user->twitter->connected = TRUE;
             # Get user access tokens out of the session.
             $access_token = $_SESSION['access_token'];
             # Create a TwitterOauth object with consumer/user tokens.
             $this->user->twitter->connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
         }
     }
 }
Exemple #12
0
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #13
0
 /**
  * Description: The execution of the specified rules
  * @param       $status
  * @param       $params
  * @throws      ViewException
  * @internal    param $data
  */
 private static function executeRules($status, $params)
 {
     extract($params);
     $data = [];
     if ($status == 'on') {
         //get the params
         foreach ($on as $key => $val) {
             $data[$key] = $val;
         }
     } elseif ($status == 'off') {
         //get the params
         foreach ($off as $key => $val) {
             $data[$key] = $val;
         }
     }
     //if there is url, the redirection is performed
     if (isset($data['url'])) {
         URL::redirect($data['url'], 5);
         if ($data['stop'] === true) {
             exit;
         }
     } elseif (isset($data['view'])) {
         //if there is a view parameter, will be loaded a view file
         View::instance($data['view'])->render();
         if ($data['stop'] === true) {
             exit;
         }
     }
 }
Exemple #14
0
 public function render($print = FALSE, $renderer = FALSE)
 {
     // Give helpers an entry to this view instance
     self::$instance = $this;
     if ($this->is_set('mustache_template') or stristr($this->kohana_filename, '.mus')) {
         if (isset($this->kohana_local_data['mustache_template']) and $this->kohana_local_data['mustache_template'] === FALSE) {
             return parent::render($print, $renderer);
         }
         $mustache_data = arr::merge(self::$kohana_global_data, $this->kohana_local_data);
         if (empty($this->kohana_local_data['mustache_partials'])) {
             $mustache_partials = array();
         } else {
             $mustache_partials = $this->kohana_local_data['mustache_partials'];
             unset($mustache_data['mustache_partials']);
         }
         $mustache = new Mustache();
         $output = $mustache->render(parent::render(FALSE), $mustache_data, $mustache_partials);
         $output = str_replace(array("\n", '  '), '', $output);
         if (!empty($this->kohana_local_data['mustache_escape_apostrophes'])) {
             $output = str_replace('\'', '\\\'', $output);
         }
         if ($print === TRUE) {
             // Display the output
             echo $output;
             return;
         }
         return $output;
     } else {
         return parent::render($print, $renderer);
     }
 }
Exemple #15
0
 /**
  * Singleton constructor
  * @return static
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new static();
     }
     return self::$instance;
 }
Exemple #16
0
 protected function _runThemeInit()
 {
     try {
         \View::instance()->render('_init.php', 'text/html', array());
     } catch (\Exception $e) {
     }
     return $this;
 }
Exemple #17
0
 public function testPush()
 {
     $this->Html->push()->a('test link');
     $a = $this->Html->a('test link');
     $v = View::instance();
     $this->assertEquals($v->getViewVariable('body'), $a);
     $v->setViewVariable('body', '');
 }
Exemple #18
0
 public function afterroute()
 {
     $f3 = \Base::instance();
     $classPath = explode('\\', get_called_class());
     $calledClass = substr(end($classPath), 0, strpos(end($classPath), "Controller"));
     $f3->set('content', $calledClass . '\\' . $calledClass . '.phtml');
     // Render HTML layout
     echo \View::instance()->render('layout.phtml');
 }
Exemple #19
0
 public function proposal()
 {
     //     array_push($this->client_files, "/css/styleProposal.css");
     $this->client_files[0] = "/css/styleProposal.css";
     // replace sitewide.css, don't add an element to the array
     $this->template->client_files = Utils::load_client_files($this->client_files);
     $this->template->content = View::instance('v_index_proposal');
     echo $this->template;
 }
Exemple #20
0
 /**
  * @param string $template Message Template
  * @param string $to Receiver Mailaddress
  */
 public function sendMessage($template, array $to)
 {
     $f3 = \Base::instance();
     $this->smtp->set('Content-Type', 'text/html; charset=UTF-8');
     $this->smtp->set('From', $f3->get('mail.FROM'));
     $this->smtp->set('To', $f3->get('mail.FROM'));
     $this->smtp->set('Bcc', "<" . implode('>;<', $to) . ">");
     $message = \View::instance()->render('MailView\\' . $template . ".phtml");
     $this->smtp->send($message);
 }
Exemple #21
0
 public function index()
 {
     $this->template->content = View::instance('v_peptide_index');
     $this->template->title = "Peptide Analysis and Gratuitous Quiz";
     $this->menuArray = array("Jump to my proposal" => "/index/proposal/", "Logout" => "/users/logout/", "Request submissions" => "/requests/index/");
     $this->template->content->menuArray = $this->menuArray;
     // 			$this->template->title   = "Signup"; // may be pushing out a posted sequence here
     # Render template
     echo $this->template;
 }
 public function test()
 {
     # Setup view
     $this->template->content = View::instance('v_contacts_info');
     #$this->template->title = "Contacts";
     #$this->template->body_id = 'contacts';
     # Render template
     echo $this->template;
     #echo "This is the contacts page";
 }
Exemple #23
0
 protected function __construct()
 {
     session_start();
     $this->view = View::instance();
     $this->data = $_POST;
     $this->get = $_GET;
     $this->file = $_FILES;
     $this->session = $_SESSION;
     $this->init();
 }
 public function afterroute($f3)
 {
     if ($f3->get('AJAX')) {
         echo View::instance()->render($this->tpl['async']);
     } else {
         if (!$f3->get('AJAX')) {
             echo View::instance()->render($this->tpl['sync']);
         }
     }
 }
 public function test()
 {
     # Setup view
     $this->template->content = View::instance('v_products_test');
     #$this->template->title = "Products";
     #$this->template->body_id = 'products';
     # Render template
     echo $this->template;
     #echo "This is the products page";
 }
 public function cardgenerator()
 {
     # Set up the view
     $this->template->content = View::instance("v_javascript_cardgenerator");
     # Specify what JS/CSS files we need to load in the view
     $client_files = array("/css/cardgenerator.css", "/js/cardgenerator.js");
     # Load the above specified files
     $this->template->client_files = Utils::load_client_files($client_files);
     # Render the view
     echo $this->template;
 }
Exemple #27
0
 public function __construct()
 {
     # Instantiate User class
     $this->userObj = new User();
     # Authenticate / load user
     $this->user = $this->userObj->authenticate();
     # Set up templates
     $this->template = View::instance('_v_template');
     $this->email_template = View::instance('_v_email');
     # So we can use $user in views
     $this->template->set_global('user', $this->user);
 }
Exemple #28
0
 public function index()
 {
     # Any method that loads a view will commonly start with this
     # First, set the content of the template with a view file
     $this->template->active_tab = 'home';
     $this->template->body = View::instance('v_index_landing');
     # If this view needs any JS or CSS files, add their paths to this array so they will get loaded in the head
     $client_files = array("");
     $this->template->client_files = Utils::load_client_files($client_files);
     # Render the view
     echo $this->template;
 }
 public function profile($id, $first_name)
 {
     parent::index();
     $id = explode('-', $id);
     $id = $id['0'];
     $id = intval($id);
     $this->f3->set('page_name', ucwords($first_name) . '\'s Profile');
     $first_name = strtolower($first_name);
     $this->f3->set('main', 'views/members/profile.html');
     $this->f3->set('js', 'loadProfile(' . $id . ',\'' . $first_name . '\')');
     echo View::instance()->render('views/layout.html');
 }
Exemple #30
0
 public function index()
 {
     # Any method that loads a view will commonly start with this
     # First, set the content of the template with a view file
     $this->template->content = View::instance('v_index_index');
     # Now set the <title> tag
     $this->template->title = "p2.neokobe.com";
     # If this view needs any JS or CSS files, add their paths to this array so they will get loaded in the head
     $client_files = array("views/css/main.css", "views/js/modernizr-2.6.1.min.js");
     $this->template->client_files = Utils::load_client_files($client_files);
     # Render the view
     echo $this->template;
 }