本文整理汇总了PHP中Fisharebest\Webtrees\FlashMessages类的典型用法代码示例。如果您正苦于以下问题:PHP FlashMessages类的具体用法?PHP FlashMessages怎么用?PHP FlashMessages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlashMessages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Manage updates sent from the AdminConfig@index form.
*/
protected function update()
{
if (Auth::isAdmin()) {
$this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
$this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
$this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
}
if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
$this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
}
// Only accept valid color for MAJ_WM_FONT_COLOR
$MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');
if ($MAJ_WM_FONT_COLOR) {
$this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
}
// Only accept valid folders for MAJ_CERT_ROOTDIR
$MAJ_CERT_ROOTDIR = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
$MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
}
if ($MAJ_CERT_ROOTDIR) {
if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
$this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
} elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
$this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
} else {
FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
}
}
FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
return;
}
}
示例2: bodyHeaderPopupWindow
/** {@inheritdoc} */
public function bodyHeaderPopupWindow()
{
if (Filter::get('action') === 'addnewnote_assisted') {
$class = 'class="census-assistant"';
} else {
$class = '';
}
return '<body class="container container-popup">' . '<main id="content"' . $class . '">' . $this->flashMessagesContainer(FlashMessages::getMessages());
}
示例3: modAction
/**
* This is a general purpose hook, allowing modules to respond to routes
* of the form module.php?mod=FOO&mod_action=BAR
*
* @param string $mod_action
*/
public function modAction($mod_action)
{
global $WT_TREE;
switch ($mod_action) {
case 'menu-add-favorite':
// Process the "add to user favorites" menu item on indi/fam/etc. pages
$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
if (Auth::check() && $record->canShowName()) {
self::addFavorite(array('user_id' => Auth::id(), 'gedcom_id' => $record->getTree()->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => null, 'title' => null));
FlashMessages::addMessage(I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
}
break;
}
}
示例4: __construct
/**
* Startup activity
*
* @param GedcomRecord|null $record
*/
public function __construct(GedcomRecord $record = null)
{
$this->record = $record;
// Automatically fix broken links
if ($this->record && $this->record->canEdit()) {
$broken_links = 0;
foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
if (!$fact->isPendingDeletion() && $fact->getTarget() === null) {
$this->record->deleteFact($fact->getFactId(), false);
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
$broken_links = true;
}
}
foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
// These can be links or inline. Only delete links.
if (!$fact->isPendingDeletion() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
$this->record->deleteFact($fact->getFactId(), false);
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
$broken_links = true;
}
}
if ($broken_links) {
// Reload the updated family
$this->record = GedcomRecord::getInstance($this->record->getXref(), $this->record->getTree());
}
}
parent::__construct();
// We want robots to index this page
$this->setMetaRobots('index,follow');
// Set a page title
if ($this->record) {
if ($this->record->canShowName()) {
// e.g. "John Doe" or "1881 Census of Wales"
$this->setPageTitle($this->record->getFullName());
} else {
// e.g. "Individual" or "Source"
$record = $this->record;
$this->setPageTitle(GedcomTag::getLabel($record::RECORD_TYPE));
}
} else {
// No such record
$this->setPageTitle(I18N::translate('Private'));
}
}
示例5: update
/**
* Saves Sosa's user preferences (root individual for the user).
*
* @param BaseController $controller
* @return bool True is saving successfull
*/
protected function update(BaseController $controller)
{
global $WT_TREE;
if ($this->canUpdate() && Filter::checkCsrf()) {
$indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE);
$user = User::find(Filter::postInteger('userid', -1));
if ($user && $indi) {
$WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref());
$controller->addInlineJavascript('
$( document ).ready(function() {
majComputeSosa(' . $user->getUserId() . ');
});');
FlashMessages::addMessage(I18N::translate('The preferences have been updated.'));
return true;
}
}
FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger');
return false;
}
示例6: elseif
$timezone = Filter::post('timezone');
$contact_method = Filter::post('contact_method');
$comment = Filter::post('comment');
$auto_accept = Filter::postBool('auto_accept');
$canadmin = Filter::postBool('canadmin');
$visible_online = Filter::postBool('visible_online');
$verified = Filter::postBool('verified');
$approved = Filter::postBool('approved');
if ($user_id === 0) {
// Create a new user
if (User::findByUserName($username)) {
FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
} elseif (User::findByEmail($email)) {
FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
} elseif ($pass1 !== $pass2) {
FlashMessages::addMessage(I18N::translate('The passwords do not match.'));
} else {
$user = User::create($username, $real_name, $email, $pass1);
$user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0');
Log::addAuthenticationLog('User ->' . $username . '<- created');
}
} else {
$user = User::find($user_id);
if ($user && $username && $real_name) {
$user->setEmail($email);
$user->setUserName($username);
$user->setRealName($real_name);
if ($pass1 !== null && $pass1 === $pass2) {
$user->setPassword($pass1);
}
}
示例7: config
/**
* A form to edit the module configuration.
*/
private function config()
{
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Google Maps™'));
if (Filter::post('action') === 'update') {
$this->setSetting('GM_MAP_TYPE', Filter::post('GM_MAP_TYPE'));
$this->setSetting('GM_USE_STREETVIEW', Filter::post('GM_USE_STREETVIEW'));
$this->setSetting('GM_MIN_ZOOM', Filter::post('GM_MIN_ZOOM'));
$this->setSetting('GM_MAX_ZOOM', Filter::post('GM_MAX_ZOOM'));
$this->setSetting('GM_XSIZE', Filter::post('GM_XSIZE'));
$this->setSetting('GM_YSIZE', Filter::post('GM_YSIZE'));
$this->setSetting('GM_PRECISION_0', Filter::post('GM_PRECISION_0'));
$this->setSetting('GM_PRECISION_1', Filter::post('GM_PRECISION_1'));
$this->setSetting('GM_PRECISION_2', Filter::post('GM_PRECISION_2'));
$this->setSetting('GM_PRECISION_3', Filter::post('GM_PRECISION_3'));
$this->setSetting('GM_PRECISION_4', Filter::post('GM_PRECISION_4'));
$this->setSetting('GM_PRECISION_5', Filter::post('GM_PRECISION_5'));
$this->setSetting('GM_COORD', Filter::post('GM_COORD'));
$this->setSetting('GM_PLACE_HIERARCHY', Filter::post('GM_PLACE_HIERARCHY'));
$this->setSetting('GM_PH_XSIZE', Filter::post('GM_PH_XSIZE'));
$this->setSetting('GM_PH_YSIZE', Filter::post('GM_PH_YSIZE'));
$this->setSetting('GM_PH_MARKER', Filter::post('GM_PH_MARKER'));
$this->setSetting('GM_PREFIX_1', Filter::post('GM_PREFIX_1'));
$this->setSetting('GM_PREFIX_2', Filter::post('GM_PREFIX_2'));
$this->setSetting('GM_PREFIX_3', Filter::post('GM_PREFIX_3'));
$this->setSetting('GM_PREFIX_4', Filter::post('GM_PREFIX_4'));
$this->setSetting('GM_PREFIX_5', Filter::post('GM_PREFIX_5'));
$this->setSetting('GM_PREFIX_6', Filter::post('GM_PREFIX_6'));
$this->setSetting('GM_PREFIX_7', Filter::post('GM_PREFIX_7'));
$this->setSetting('GM_PREFIX_8', Filter::post('GM_PREFIX_8'));
$this->setSetting('GM_PREFIX_9', Filter::post('GM_PREFIX_9'));
$this->setSetting('GM_POSTFIX_1', Filter::post('GM_POSTFIX_1'));
$this->setSetting('GM_POSTFIX_2', Filter::post('GM_POSTFIX_2'));
$this->setSetting('GM_POSTFIX_3', Filter::post('GM_POSTFIX_3'));
$this->setSetting('GM_POSTFIX_4', Filter::post('GM_POSTFIX_4'));
$this->setSetting('GM_POSTFIX_5', Filter::post('GM_POSTFIX_5'));
$this->setSetting('GM_POSTFIX_6', Filter::post('GM_POSTFIX_6'));
$this->setSetting('GM_POSTFIX_7', Filter::post('GM_POSTFIX_7'));
$this->setSetting('GM_POSTFIX_8', Filter::post('GM_POSTFIX_8'));
$this->setSetting('GM_POSTFIX_9', Filter::post('GM_POSTFIX_9'));
FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->getName()), 'success');
header('Location: ' . WT_BASE_URL . 'module.php?mod=googlemap&mod_action=admin_config');
return;
}
$controller->pageHeader();
?>
<ol class="breadcrumb small">
<li><a href="admin.php"><?php
echo I18N::translate('Control panel');
?>
</a></li>
<li><a href="admin_modules.php"><?php
echo I18N::translate('Module administration');
?>
</a></li>
<li class="active"><?php
echo $controller->getPageTitle();
?>
</li>
</ol>
<ul class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation" class="active">
<a href="#" role="tab">
<?php
echo I18N::translate('Google Maps™ preferences');
?>
</a>
</li>
<li role="presentation">
<a href="?mod=googlemap&mod_action=admin_places">
<?php
echo I18N::translate('Geographic data');
?>
</a>
</li>
<li role="presentation">
<a href="?mod=googlemap&mod_action=admin_placecheck">
<?php
echo I18N::translate('Place check');
?>
</a>
</li>
</ul>
<h2><?php
echo I18N::translate('Google Maps™ preferences');
?>
</h2>
<form class="form-horizontal" method="post" name="configform" action="module.php?mod=googlemap&mod_action=admin_config">
<input type="hidden" name="action" value="update">
<h3><?php
echo I18N::translate('Basic');
?>
</h3>
//.........这里部分代码省略.........
示例8: header
if (Filter::checkCsrf()) {
Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
}
header('Location: ' . WT_BASE_URL . 'admin.php');
return;
case 'languages':
if (Filter::checkCsrf()) {
Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
}
header('Location: ' . WT_BASE_URL . 'admin.php');
return;
}
// Lists of options for <select> controls.
$SMTP_SSL_OPTIONS = array('none' => I18N::translate('none'), 'ssl' => I18N::translate('ssl'), 'tls' => I18N::translate('tls'));
$SMTP_ACTIVE_OPTIONS = array('internal' => I18N::translate('Use PHP mail to send messages'), 'external' => I18N::translate('Use SMTP to send messages'));
$WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => I18N::translate('No predefined text'), 1 => I18N::translate('Predefined text that states all users can request a user account'), 2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => I18N::translate('Predefined text that states only family members can request a user account'), 4 => I18N::translate('Choose user defined welcome text typed below'));
$language_tags = array();
foreach (I18N::activeLocales() as $active_locale) {
$language_tags[] = $active_locale->languageTag();
}
switch (Filter::get('action')) {
case 'site':
$controller->setPageTitle(I18N::translate('Website preferences'));
示例9: function
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">
<?php
echo I18N::translate('continue');
?>
</button>
</div>
</div>
</form>
<?php
return;
}
if (!Tree::getAll()) {
FlashMessages::addMessage(I18N::translate('You need to create a family tree.'), 'info');
}
$controller->pageHeader();
$all_trees = Tree::getAll();
// On sites with hundreds or thousands of trees, this page becomes very large.
// Just show the current tree, the default tree, and unimported trees
if (count($all_trees) >= $multiple_tree_threshold) {
$all_trees = array_filter($all_trees, function (Tree $x) use($WT_TREE) {
return $x->getPreference('imported') === '0' || $WT_TREE->getTreeId() === $x->getTreeId() || $x->getName() === Site::getPreference('DEFAULT_GEDCOM');
});
}
// List the gedcoms available to this user
?>
<ol class="breadcrumb small">
<li><a href="admin.php"><?php
echo I18N::translate('Control panel');
示例10: catch
$WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'info');
} else {
FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
}
}
$gedcom = Filter::post('gedcom');
if ($gedcom && $gedcom !== $WT_TREE->getName()) {
try {
Database::prepare("UPDATE `##gedcom` SET gedcom_name = ? WHERE gedcom_id = ?")->execute(array($gedcom, $WT_TREE->getTreeId()));
Database::prepare("UPDATE `##site_setting` SET setting_value = ? WHERE setting_name='DEFAULT_GEDCOM' AND setting_value = ?")->execute(array($gedcom, $WT_TREE->getName()));
} catch (\Exception $ex) {
// Probably a duplicate name.
}
}
FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
return;
}
switch (Filter::get('action')) {
case 'privacy':
$controller->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Privacy'))->addInlineJavascript('
jQuery("#default-resn input[type=checkbox]").on("click", function() {
if ($(this).prop("checked")) {
jQuery($(this).closest("tr").addClass("text-muted"));
} else {
jQuery($(this).closest("tr").removeClass("text-muted"));
}
});
jQuery("#add-resn").on("click", function() {
jQuery("#default-resn tbody").prepend(jQuery("#new-resn-template").html()); autocomplete();
示例11: headerSimple
/**
* Create the <header> tag for a popup window.
*
* @return string
*/
protected function headerSimple()
{
return $this->flashMessagesContainer(FlashMessages::getMessages()) . '<div id="content">';
}
示例12: checkCsrf
/**
* Check that the POST request contains the CSRF token generated above.
*
* @return bool
*/
public static function checkCsrf()
{
if (self::post('csrf') !== self::getCsrfToken()) {
// Oops. Something is not quite right
Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack');
FlashMessages::addMessage(I18N::translate('This form has expired. Try again.'), 'error');
return false;
}
return true;
}
示例13: define
// The login URL must be an absolute URL, and can be user-defined
if (Site::getPreference('LOGIN_URL')) {
define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
} else {
define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
}
// If there is no current tree and we need one, then redirect somewhere
if (WT_SCRIPT_NAME != 'admin_trees_manage.php' && WT_SCRIPT_NAME != 'admin_pgv_to_wt.php' && WT_SCRIPT_NAME != 'login.php' && WT_SCRIPT_NAME != 'logout.php' && WT_SCRIPT_NAME != 'import.php' && WT_SCRIPT_NAME != 'help_text.php' && WT_SCRIPT_NAME != 'message.php' && WT_SCRIPT_NAME != 'action.php') {
if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
if (Auth::isAdmin()) {
header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
} else {
// We're not an administrator, so we can only log in if there is a tree.
if (Auth::id()) {
Auth::logout();
FlashMessages::addMessage(I18N::translate('This user account does not have access to any tree.'));
}
header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
}
exit;
}
}
// Update the last-login time no more than once a minute
if (WT_TIMESTAMP - Session::get('activity_time') >= 60) {
Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
Session::put('activity_time', WT_TIMESTAMP);
}
// Set the theme
if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php' && substr(Filter::get('mod_action'), 0, 5) === 'admin') {
// Administration scripts begin with “admin” and use a special administration theme
Theme::theme(new AdministrationTheme())->init($WT_TREE);
示例14: addMessage
if (!empty($from_name)) {
$message['from_name'] = $from_name;
$message['from_email'] = $from_email;
}
$message['subject'] = $subject;
$message['body'] = nl2br($body, false);
$message['created'] = WT_TIMESTAMP;
$message['method'] = $method;
$message['url'] = $url;
if ($i > 0) {
$message['no_from'] = true;
}
if (addMessage($message)) {
FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', Filter::escapeHtml($to)));
} else {
FlashMessages::addMessage(I18N::translate('The message was not sent.'));
Log::addErrorLog('Unable to send a message. FROM:' . $from . ' TO:' . $to . ' (failed to send)');
}
$i++;
}
$controller->pageHeader()->addInlineJavascript('window.opener.location.reload(); window.close();');
break;
}
/**
* Add a message to a user's inbox
*
* @param string[] $message
*
* @return bool
*/
function addMessage($message)
示例15: foreach
require './includes/session.php';
$to_delete = Filter::postArray('to_delete');
if ($to_delete && Filter::checkCsrf()) {
foreach ($to_delete as $path) {
$is_dir = is_dir(WT_DATA_DIR . $path);
if (File::delete(WT_DATA_DIR . $path)) {
if ($is_dir) {
FlashMessages::addMessage(I18N::translate('The folder %s has been deleted.', Filter::escapeHtml($path)), 'success');
} else {
FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', Filter::escapeHtml($path)), 'success');
}
} else {
if ($is_dir) {
FlashMessages::addMessage(I18N::translate('The folder %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
} else {
FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
}
}
}
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
return;
}
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Clean up data folder'))->pageHeader();
$do_not_delete = array('index.php', 'config.ini.php');
// If we are storing the media in the data folder (this is the default), then don’t delete it.
foreach (Tree::getAll() as $tree) {
$MEDIA_DIRECTORY = $tree->getPreference('MEDIA_DIRECTORY');
if (substr($MEDIA_DIRECTORY, 0, 3) != '../') {
// Just need to add the first part of the path
$tmp = explode('/', $MEDIA_DIRECTORY);