本文整理汇总了PHP中Fisharebest\Webtrees\Filter::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::get方法的具体用法?PHP Filter::get怎么用?PHP Filter::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Filter
的用法示例。
在下文中一共展示了Filter::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Startup activity
*/
public function __construct()
{
global $WT_TREE;
$xref = Filter::get('mid', WT_REGEX_XREF);
$this->record = Media::getInstance($xref, $WT_TREE);
parent::__construct();
}
示例2: pageBody
public function pageBody()
{
$tmp_dir = WT_DATA_DIR . 'ftv_pdf_tmp/';
define('_JPGRAPH_PATH', $tmp_dir);
define('_MPDF_TEMP_PATH', $tmp_dir);
define('_MPDF_TTFONTDATAPATH', $tmp_dir);
require_once WT_MODULES_DIR . $this->getName() . '/mpdf/mpdf.php';
$stylesheet = file_get_contents($this->directory . '/css/style.css');
$stylesheet_rtl = file_get_contents($this->directory . '/css/style-rtl.css');
$html = Filter::post('pdfContent');
$header = '<header>=== ' . $this->tree()->getTitleHtml() . ' ===</header>';
$footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
$mpdf = new mPDF();
$mpdf->simpleTables = true;
$mpdf->shrink_tables_to_fit = 1;
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1;
$mpdf->autoVietnamese = true;
$mpdf->autoArabic = true;
$mpdf->autoLangToFont = true;
if (I18N::direction() === 'rtl') {
$mpdf->SetDirectionality('rtl');
$mpdf->WriteHTML($stylesheet_rtl, 1);
} else {
$mpdf->WriteHTML($stylesheet, 1);
}
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->autoMarginPadding = 5;
$admin = User::find($this->tree()->getPreference('WEBMASTER_USER_ID'))->getRealName();
$mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
$mpdf->SetTitle(Filter::get('title'));
$mpdf->setAuthor($admin);
$mpdf->SetHTMLHeader($header);
$mpdf->setHTMLFooter($footer);
$html_chunks = explode("\n", $html);
$chunks = count($html_chunks);
$i = 1;
foreach ($html_chunks as $html_chunk) {
// write html body parts only (option 2);
if ($i === 1) {
// first chunk (initialize all buffers - init=true)
$mpdf->WriteHTML($html_chunk, 2, true, false);
} elseif ($i === $chunks) {
// last chunck (close all buffers - close=true)
$mpdf->WriteHTML($html_chunk, 2, false, true);
} else {
// all other parts (keep the buffer open)
$mpdf->WriteHTML($html_chunk, 2, false, false);
}
$i++;
}
$index = '
<pagebreak type="next-odd" />
<h2>' . I18N::translate('Index') . '</h2>
<columns column-count="2" column-gap="5" />
<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
$mpdf->writeHTML($index);
$mpdf->Output($tmp_dir . Filter::get('title') . '.pdf', 'F');
}
示例3: __construct
/**
* Create the chart controller
*
* @param int $show_full needed for use by charts module
*/
public function __construct($show_full = 1)
{
global $WT_TREE;
parent::__construct();
$rootid = Filter::get('rootid', WT_REGEX_XREF);
$this->root = Individual::getInstance($rootid, $WT_TREE);
if (!$this->root) {
// Missing root individual? Show the chart for someone.
$this->root = $this->getSignificantIndividual();
}
if (!$this->root || !$this->root->canShowName()) {
http_response_code(404);
$this->error_message = I18N::translate('This individual does not exist or you do not have permission to view it.');
}
// Extract parameter from form
if ($show_full) {
$this->show_full = Filter::getInteger('show_full', 0, 1, $WT_TREE->getPreference('PEDIGREE_FULL_DETAILS'));
} else {
$this->show_full = 0;
}
$this->box = new \stdClass();
if ($this->showFull()) {
$this->box->width = Theme::theme()->parameter('chart-box-x');
$this->box->height = Theme::theme()->parameter('chart-box-y');
} else {
$this->box->width = Theme::theme()->parameter('compact-chart-box-x');
$this->box->height = Theme::theme()->parameter('compact-chart-box-y');
}
}
示例4: pageBody
public function pageBody()
{
$cache_dir = WT_DATA_DIR . 'ftv_cache/';
define("_JPGRAPH_PATH", $cache_dir);
define("_MPDF_TEMP_PATH", $cache_dir);
define('_MPDF_TTFONTDATAPATH', $cache_dir);
require_once WT_MODULES_DIR . $this->getName() . '/packages/mpdf60/mpdf.php';
$tmpfile = $cache_dir . 'fancy-treeview-tmp.txt';
if (file_exists($cache_dir) && is_readable($tmpfile)) {
$stylesheet = file_get_contents($this->directory . '/css/pdf/style.css');
$stylesheet_rtl = file_get_contents($this->directory . '/css/pdf/style-rtl.css');
$html = file_get_contents($tmpfile);
$header = '<header>=== ' . $this->tree->getTitleHtml() . ' ===</header>';
$footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
$mpdf = new mPDF();
$mpdf->simpleTables = true;
$mpdf->shrink_tables_to_fit = 1;
$mpdf->autoScriptToLang = true;
if (I18N::direction() === 'rtl') {
$mpdf->SetDirectionality('rtl');
}
if (I18N::direction() === 'rtl') {
$mpdf->WriteHTML($stylesheet_rtl, 1);
} else {
$mpdf->WriteHTML($stylesheet, 1);
}
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->autoMarginPadding = 5;
$admin = User::find($this->tree->getPreference('WEBMASTER_USER_ID'))->getRealName();
$mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
$mpdf->SetTitle(Filter::get('title'));
$mpdf->setAuthor($admin);
$mpdf->SetHTMLHeader($header);
$mpdf->setHTMLFooter($footer);
$html_chunks = explode("\n", $html);
$chunks = count($html_chunks);
$i = 1;
foreach ($html_chunks as $html_chunk) {
if ($i === 1) {
$mpdf->WriteHTML($html_chunk, 2, true, false);
} elseif ($i === $chunks) {
$mpdf->WriteHTML($html_chunk, 2, false, false);
} else {
$mpdf->WriteHTML($html_chunk, 2, false, true);
}
$i++;
}
$index = '
<pagebreak type="next-odd" />
<h2>' . I18N::translate('Index') . '</h2>
<columns column-count="2" column-gap="5" />
<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
$mpdf->writeHTML($index);
$mpdf->Output(Filter::get('title') . '.pdf', 'D');
} else {
echo $this->addMessage('alert', 'danger', false, I18N::translate('Error: the pdf file could not be generated.'));
}
}
示例5: __construct
public function __construct()
{
parent::__construct('modulename');
$this->directory = WT_MODULES_DIR . $this->getName();
$this->action = Filter::get('mod_action');
// register the namespaces
$loader = new ClassLoader();
$loader->addPsr4('vendor\\WebtreesModules\\modulename\\', $this->directory);
$loader->register();
}
示例6: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
switch (Filter::get('action')) {
case 'deletenews':
$news_id = Filter::get('news_id');
if ($news_id) {
Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
}
break;
}
$more_news = Filter::getInteger('more_news');
$limit = 5 * (1 + $more_news);
$articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE gedcom_id = :tree_id ORDER BY updated DESC LIMIT :limit")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'tree_id' => $WT_TREE->getTreeId(), 'limit' => $limit))->fetchAll();
$count = Database::prepare("SELECT SQL_CACHE COUNT(*) FROM `##news` WHERE gedcom_id = :tree_id")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchOne();
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = $this->getTitle();
$content = '';
if (empty($articles)) {
$content .= I18N::translate('No news articles have been submitted.');
}
foreach ($articles as $article) {
$content .= '<div class="news_box">';
$content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
$content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
if ($article->body == strip_tags($article->body)) {
$article->body = nl2br($article->body, false);
}
$content .= $article->body;
if (Auth::isManager($WT_TREE)) {
$content .= '<hr>';
$content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
$content .= ' | ';
$content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
}
$content .= '</div>';
}
if (Auth::isManager($WT_TREE)) {
$content .= '<a href="#" onclick="window.open(\'editnews.php?gedcom_id=' . $WT_TREE->getTreeId() . '\', \'_blank\', news_window_specs); return false;">' . I18N::translate('Add a news article') . '</a>';
}
if ($count > $limit) {
if (Auth::isManager($WT_TREE)) {
$content .= ' | ';
}
$content .= '<a href="#" onclick="jQuery(\'#' . $id . '\').load(\'index.php?ctype=gedcom&ged=' . $WT_TREE->getNameUrl() . '&block_id=' . $block_id . '&action=ajax&more_news=' . ($more_news + 1) . '\'); return false;">' . I18N::translate('More news articles') . "</a>";
}
if ($template) {
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
示例7: 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)
{
switch ($mod_action) {
case 'admin':
$this->admin();
break;
case 'generate':
$this->generate(Filter::get('file'));
break;
default:
http_response_code(404);
}
}
示例8: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
switch (Filter::get('action')) {
case 'deletenews':
$news_id = Filter::getInteger('news_id');
if ($news_id) {
Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
}
break;
}
$block = $this->getBlockSetting($block_id, 'block', '1');
foreach (array('block') as $name) {
if (array_key_exists($name, $cfg)) {
${$name} = $cfg[$name];
}
}
$usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE user_id = ? ORDER BY updated DESC")->execute(array(Auth::id()))->fetchAll();
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = '';
$title .= $this->getTitle();
$content = '';
if (!$usernews) {
$content .= I18N::translate('You have not created any journal items.');
}
foreach ($usernews as $news) {
$content .= '<div class="journal_box">';
$content .= '<div class="news_title">' . $news->subject . '</div>';
$content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>';
if ($news->body == strip_tags($news->body)) {
// No HTML?
$news->body = nl2br($news->body, false);
}
$content .= $news->body . '<br><br>';
$content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ';
$content .= '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
$content .= "</div><br>";
}
$content .= '<br><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a new journal entry') . '</a>';
if ($template) {
if ($block) {
$class .= ' small_inner_block';
}
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
示例9: __construct
/**
* Create a branches list controller
*/
public function __construct()
{
global $WT_TREE;
parent::__construct();
$this->surname = Filter::get('surname');
$this->soundex_std = Filter::getBool('soundex_std');
$this->soundex_dm = Filter::getBool('soundex_dm');
if ($this->surname) {
$this->setPageTitle(I18N::translate('Branches of the %s family', Filter::escapeHtml($this->surname)));
$this->loadIndividuals();
$self = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'gedcomid'), $WT_TREE);
if ($self) {
$this->loadAncestors($self, 1);
}
} else {
$this->setPageTitle(I18N::translate('Branches'));
}
}
示例10: getSidebarAjaxContent
/** {@inheritdoc} */
public function getSidebarAjaxContent()
{
global $WT_TREE;
$alpha = Filter::get('alpha');
// All surnames beginning with this letter where "@"=unknown and ","=none
$surname = Filter::get('surname');
// All indis with this surname.
$search = Filter::get('search');
if ($search) {
return $this->search($WT_TREE, $search);
} elseif ($alpha == '@' || $alpha == ',' || $surname) {
return $this->getSurnameIndis($WT_TREE, $alpha, $surname);
} elseif ($alpha) {
return $this->getAlphaSurnames($WT_TREE, $alpha);
} else {
return '';
}
}
示例11: 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;
header('Content-Type: text/html; charset=UTF-8');
switch ($mod_action) {
case 'search':
$search = Filter::get('search');
echo $this->search($search, $WT_TREE);
break;
case 'descendants':
$individual = Individual::getInstance(Filter::get('xref', WT_REGEX_XREF), $WT_TREE);
if ($individual) {
echo $this->loadSpouses($individual, 1);
}
break;
default:
http_response_code(404);
break;
}
}
示例12: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
switch (Filter::get('action')) {
case 'deletenews':
$news_id = Filter::getInteger('news_id');
if ($news_id) {
Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
}
break;
}
$articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE user_id = :user_id ORDER BY updated DESC")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'user_id' => Auth::id()))->fetchAll();
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = $this->getTitle();
$content = '';
if (empty($articles)) {
$content .= '<p>' . I18N::translate('You have not created any journal items.') . '</p>';
}
foreach ($articles as $article) {
$content .= '<div class="journal_box">';
$content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
$content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
if ($article->body == strip_tags($article->body)) {
$article->body = nl2br($article->body, false);
}
$content .= $article->body;
$content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
$content .= ' | ';
$content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
$content .= '</div><br>';
}
$content .= '<p><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a journal entry') . '</a></p>';
if ($template) {
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
示例13: index
/**
* Piwik@index
*/
public function index()
{
$ctrl = new AjaxController();
$data = new ViewBag();
$data->set('has_stats', false);
$block_id = Filter::get('block_id');
if ($block_id) {
$cached_item = Cache::get('piwikCountYear', $this->module);
$visitCountYear = $cached_item->get();
if (!$cached_item->isHit()) {
$visitCountYear = $this->getNumberOfVisitsPiwik($block_id);
Cache::save($cached_item, $visitCountYear);
}
if ($visitCountYear) {
$visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day'));
$visitCountYear = max(0, $visitCountYear);
$data->set('has_stats', true);
$data->set('visits_today', $visitCountToday);
$data->set('visits_year', $visitCountYear + $visitCountToday);
}
}
ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render();
}
示例14: substr
use Fisharebest\Webtrees\Date\JalaliDate;
use Fisharebest\Webtrees\Date\JewishDate;
use Fisharebest\Webtrees\Date\JulianDate;
use Fisharebest\Webtrees\Functions\FunctionsDb;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
define('WT_SCRIPT_NAME', 'calendar.php');
require './includes/session.php';
$CALENDAR_FORMAT = $WT_TREE->getPreference('CALENDAR_FORMAT');
$cal = Filter::get('cal', '@#D[A-Z ]+@');
$day = Filter::get('day', '\\d\\d?');
$month = Filter::get('month', '[A-Z]{3,5}');
$year = Filter::get('year', '\\d{1,4}(?: B\\.C\\.)?|\\d\\d\\d\\d\\/\\d\\d|\\d+(-\\d+|[?]+)?');
$view = Filter::get('view', 'day|month|year', 'day');
$filterev = Filter::get('filterev', '[_A-Z-]+', 'BIRT-MARR-DEAT');
$filterof = Filter::get('filterof', 'all|living|recent', 'all');
$filtersx = Filter::get('filtersx', '[MF]', '');
if ($cal . $day . $month . $year === '') {
// No date specified? Use the most likely calendar
$cal = I18N::defaultCalendar()->gedcomCalendarEscape();
}
// Create a CalendarDate from the parameters
// We cannot display new-style/old-style years, so convert to new style
if (preg_match('/^(\\d\\d)\\d\\d\\/(\\d\\d)$/', $year, $match)) {
$year = $match[1] . $match[2];
}
// advanced-year "year range"
if (preg_match('/^(\\d+)-(\\d+)$/', $year, $match)) {
if (strlen($match[1]) > strlen($match[2])) {
$match[2] = substr($match[1], 0, strlen($match[1]) - strlen($match[2])) . $match[2];
}
$ged_date = new Date("FROM {$cal} {$match[1]} TO {$cal} {$match[2]}");
示例15: ajaxRequest
/**
* Handle AJAX requests - to generate the tab content
*/
public function ajaxRequest()
{
// Search engines should not make AJAX requests
if (Auth::isSearchEngine()) {
http_response_code(403);
exit;
}
// Initialise tabs
$tab = Filter::get('module');
// A request for a non-existant tab?
if (array_key_exists($tab, $this->tabs)) {
$mod = $this->tabs[$tab];
} else {
http_response_code(404);
exit;
}
header("Content-Type: text/html; charset=UTF-8");
// AJAX calls do not have the meta tag headers and need this set
header("X-Robots-Tag: noindex,follow");
// AJAX pages should not show up in search results, any links can be followed though
echo $mod->getTabContent();
if (WT_DEBUG_SQL) {
echo Database::getQueryLog();
}
}