function message() { $this->helper->filter->defaults($this->args, array('messages' => array(), 'component' => '', 'status' => array())); if ($this->args['status']) { $status = $this->args['status']; } else { $status = Session::getFlash('admin_message'); } if ($status) { if ($status[2] != $this->args['component']) { $status = ''; } else { $success = $status[1] ? 0 : 1; if (isset($status[3])) { $text = $status[3]; } else { if (isset($this->args['messages'][$status[0]][$success])) { $text = $this->args['messages'][$status[0]][$success]; } else { if (isset($this->lang->list['messages'][$status[0]][$success])) { $text = $this->lang->list['messages'][$status[0]][$success]; } else { $text = ''; } } } if ($text) { $status = array($text, $status[1] ? 'success' : 'failure'); } } } $this->view->set('message', $status); }
function __construct($context, &$values = array(), &$args = array(), &$errors = array()) { //Notice: There's no difference in sending an empty $values array //or sending no value at all. Should this be detected? $action = $context->getAction(); if (!isset(self::$id_count[$action])) { self::$id_count[$action] = 0; } $this->_id = strtolower(get_class($this) . '_' . $action . '_' . ++self::$id_count[$action]); $this->_raw_value = (array) $values; $this->_context = $context; $this->args = (array) $args; $this->load = new Loader($context); $this->db = new DatabaseProxy($this->load); $this->plugin = PluginManager::getInstance()->getPluginList(); $this->lang = $this->load->lang(); $this->session = new Session($context->getModule()); $this->valid = $this->load->validator('/phaxsi/validator'); $this->helper = new HelperLoader($this->load); if (empty($this->_raw_value)) { if ($flash = Session::getFlash($this->_id)) { $this->_raw_value = $flash['values']; $this->_errors = $flash['errors']; } } if ($errors) { $this->_errors = array_merge((array) $this->_errors, $errors); } $create_method_ptr = array(&$this, $this->_context->getAction()); if (is_callable($create_method_ptr)) { call_user_func($create_method_ptr); } else { trigger_error("Form '" . $this->_context->getPath() . "' does not exist.", E_USER_ERROR); } }
function login() { $this->view->setTemplate('themes/' . $this->config['theme'] . '/login'); $login = $this->view->set('login', $this->load->form('login')); $login->setAction("login_process"); $login->setErrorSummary($this->lang->invalid_user); $login->next->setValue(Session::getFlash('next')); $this->view->addHelper('form_helper', 'form'); }
function setValues($inputs, $values, $overwrite_post = false) { $prefix = is_string($inputs) ? $inputs : $inputs->__prefix; if (!Session::getFlash($this->form->getId()) && !$_POST || $overwrite_post) { $prefixed_values = array(); foreach ($values as $name => $value) { $prefixed_values[$prefix . $name] = $value; } $this->form->setValue($prefixed_values); } }
public static function index($params) { $page = intval(Helpers::select("page", $params, 1)); $per_page = Config::get("posts.per_page"); $posts = DB::getAll("select * from posts " . "order by posted_at desc " . "limit :limit offset :offset", array("limit" => $per_page, "offset" => ($page - 1) * $per_page)); View::set("posts", $posts); View::set("total", DB::getValue("select count(*) from posts")); View::set("first", ($page - 1) * $per_page + 1); View::set("last", min(View::get("first") + $per_page - 1, View::get("total"))); View::set("page", $page); View::set("pages", ceil(View::get("total") / $per_page)); View::set("highlight", Session::getFlash("highlight")); if ($page > 1 && count($posts) === 0) { Helpers::notFound(); } View::render("post/index"); }
} else { $data = Member::getProfile($name, array('password')); $data['status_message'] = Localization::fetch('editing_member'); } $data['fields'] = YAML::parse(Config::getConfigPath() . '/bundles/member/fields.yaml'); $data['original_name'] = $original_name; $data['full_name'] = array_get($data, 'first_name', $name) . ' ' . array_get($data, 'last_name', ''); // overwrite 'biography' as it needs to be 'biography_raw' here if (isset($data['fields']['fields']['biography'])) { $data['fields']['fields']['biography_raw'] = $data['fields']['fields']['biography']; unset($data['fields']['fields']['biography']); } $template_list = array("member"); // check for flash data $errors = Session::getFlash('member_errors', array()); $old_values = Session::getFlash('member_old_values', array()); // merge $data = $old_values + $data + array('_errors' => $errors, 'new' => $new); Statamic_View::set_templates(array_reverse($template_list)); $admin_app->render(null, array('route' => 'members', 'app' => $admin_app) + $data); })->name('member'); // GET: DELETE MEMBER $admin_app->get('/deletemember', function () use($admin_app) { authenticateForRole('admin'); doStatamicVersionCheck($admin_app); $name = $admin_app->request()->get('name'); if (Member::exists($name)) { $user = Auth::getMember($name); $user->delete(); } // Redirect
/** * Gets the value of a given $key for this addon's flash namespace * * @param string $key Key to retrieve * @param mixed $default Default value to return if $key isn't set * @return mixed */ public function get($key, $default=null) { return Session::getFlash($this->getNamespacedKey($key), $default); }
<?php } else { if (Session::getFlash('info')) { ?> <div class="alert alert-info"><?php echo Session::getFlash('info'); ?> </div> <?php } else { if (Session::getFlash() && is_array(Session::getFlash())) { ?> <div class="alert alert-info"> <ul> <?php foreach (Session::getFlash() as $message) { ?> <li><?php echo $message; ?> </li> <?php } ?> </ul> </div> <?php } } } }
/** * Get and destroy a flash messsage * * @param string $name * @return mixed */ function getflash($name) { return Session::getFlash($name); }
/** * Flash-messages flag * * @return mixed */ public static function flash() { return Session::getFlash(); }
public function flash() { $s = new Session(); $d = $s->getFlash(); if (!empty($d)) { return $this->element('Flash/' . $d['type'], $d); } return null; }
function setValues(AdminFormTable $admin_table, $values, $overwrite_post = false) { $prefix = $admin_table->getPrefix(); if (!Session::getFlash($this->form->getId()) && !$_POST || $overwrite_post) { $prefixed_values = array(); foreach ($values as $name => $value) { $prefixed_values[$prefix . $name] = $value; } $this->form->setValue($prefixed_values); } }