本文整理汇总了PHP中Fisharebest\Webtrees\Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-sour');
if (Auth::isEditor($this->record->getTree())) {
$fact = $this->record->getFirstFact('TITL');
if ($fact) {
// Edit existing name
$menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");')));
} else {
// Add new name
$menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "TITL");')));
}
// delete
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-sour-del', array('onclick' => "return delete_record('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');")));
}
// edit raw
if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-sour-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
}
return $menu;
}
示例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: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-note');
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Edit note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");')));
}
// delete
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_note("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
// add to favorites
if (Module::getModuleByName('user_favorites')) {
$menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-note-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})')));
}
// Get the link for the first submenu and set it as the link for the main menu
if ($menu->getSubmenus()) {
$submenus = $menu->getSubmenus();
$menu->setLink($submenus[0]->getLink());
$menu->setAttrs($submenus[0]->getAttrs());
}
return $menu;
}
示例4: __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');
}
}
示例5: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-obje');
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the media object'), '#', 'menu-obje-edit', array('onclick' => 'window.open("addmedia.php?action=editmedia&pid=' . $this->record->getXref() . '", "_blank", edit_window_specs)')));
// main link displayed on page
if (Module::getModuleByName('GEDFact_assistant')) {
$menu->addSubmenu(new Menu(I18N::translate('Manage the links'), '#', 'menu-obje-link', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","manage");')));
} else {
$menu->addSubmenu(new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","person");')));
$menu->addSubmenu(new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","family");')));
$menu->addSubmenu(new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","source");')));
}
// delete
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-obje-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
// edit raw
if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-obje-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
}
return $menu;
}
示例6: __construct
/**
* Startup activity
*/
public function __construct()
{
global $WT_TREE;
$xref = Filter::get('famid', WT_REGEX_XREF);
$this->record = Family::getInstance($xref, $WT_TREE);
parent::__construct();
}
示例7: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-repo');
if (Auth::isEditor($this->record->getTree())) {
$fact = $this->record->getFirstFact('NAME');
if ($fact) {
// Edit existing name
$menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");')));
} else {
// Add new name
$menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "NAME");')));
}
}
// delete
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-repo-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
// edit raw
if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-repo-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
}
// add to favorites
if (Module::getModuleByName('user_favorites')) {
$menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-repo-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite" ,{xref:"' . $this->record->getXref() . '"},function(){location.reload();})')));
}
return $menu;
}
示例8: __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();
}
示例9: send
/**
* Send an external email message
* Caution! gmail may rewrite the "From" header unless you have added the address to your account.
*
* @param Tree $tree
* @param string $to_email
* @param string $to_name
* @param string $replyto_email
* @param string $replyto_name
* @param string $subject
* @param string $message
*
* @return bool
*/
public static function send(Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message)
{
try {
$mail = new Zend_Mail('UTF-8');
$mail->setSubject($subject)->setBodyHtml($message)->setBodyText(Filter::unescapeHtml($message))->setFrom(Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))->addTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->send(self::transport());
} catch (\Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
}
示例10: send
/**
* Send an external email message
* Caution! gmail may rewrite the "From" header unless you have added the address to your account.
*
* @param Tree $tree
* @param string $to_email
* @param string $to_name
* @param string $replyto_email
* @param string $replyto_name
* @param string $subject
* @param string $message
*
* @return bool
*/
public static function send(Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message)
{
try {
$mail = Swift_Message::newInstance()->setSubject($subject)->setFrom(Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))->setTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->setBody($message, 'text/html')->addPart(Filter::unescapeHtml($message), 'text/plain');
Swift_Mailer::newInstance(self::transport())->send($mail);
} catch (Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
}
示例11: __construct
/**
* Startup activity
*/
public function __construct()
{
parent::__construct();
// Extract the request parameters
$this->show_thumbs = Filter::getBool('show_thumbs');
if ($this->root && $this->root->canShowName()) {
$this->setPageTitle(I18N::translate('Compact tree of %s', $this->root->getFullName()));
} else {
$this->setPageTitle(I18N::translate('Compact tree'));
}
$this->treeid = $this->sosaAncestors(5);
}
示例12: __construct
/**
* Create the descendancy controller
*/
public function __construct()
{
global $WT_TREE;
parent::__construct();
// Extract parameters from form
$this->chart_style = Filter::getInteger('chart_style', 0, 3, 0);
$this->generations = Filter::getInteger('generations', 2, $WT_TREE->getPreference('MAX_DESCENDANCY_GENERATIONS'), $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
if ($this->root && $this->root->canShowName()) {
$this->setPageTitle(I18N::translate('Descendants of %s', $this->root->getFullName()));
} else {
$this->setPageTitle(I18N::translate('Descendants'));
}
}
示例13: upgrade
/**
* Upgrade to to the next version
*/
public function upgrade()
{
$WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', Filter::server('SERVER_NAME'));
// Default settings for new trees. No defaults for:
// imported, title, CONTACT_USER_ID, WEBMASTER_USER_ID
// The following settings have defaults, but may need overwriting:
// LANGUAGE, SURNAME_TRADITION
Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES" . "(-1, 'ADVANCED_NAME_FACTS', 'NICK,_AKA')," . "(-1, 'ADVANCED_PLAC_FACTS', '')," . "(-1, 'ALLOW_THEME_DROPDOWN', '1')," . "(-1, 'CALENDAR_FORMAT', 'gregorian')," . "(-1, 'CHART_BOX_TAGS', '')," . "(-1, 'COMMON_NAMES_ADD', '')," . "(-1, 'COMMON_NAMES_REMOVE', '')," . "(-1, 'COMMON_NAMES_THRESHOLD', '40')," . "(-1, 'DEFAULT_PEDIGREE_GENERATIONS', '4')," . "(-1, 'EXPAND_RELATIVES_EVENTS', '0')," . "(-1, 'EXPAND_SOURCES', '0')," . "(-1, 'FAM_FACTS_ADD', 'CENS,MARR,RESI,SLGS,MARR_CIVIL,MARR_RELIGIOUS,MARR_PARTNERS,RESN')," . "(-1, 'FAM_FACTS_QUICK', 'MARR,DIV,_NMR')," . "(-1, 'FAM_FACTS_UNIQUE', 'NCHI,MARL,DIV,ANUL,DIVF,ENGA,MARB,MARC,MARS')," . "(-1, 'FAM_ID_PREFIX', 'F')," . "(-1, 'FORMAT_TEXT', 'markdown')," . "(-1, 'FULL_SOURCES', '0')," . "(-1, 'GEDCOM_ID_PREFIX', 'I')," . "(-1, 'GEDCOM_MEDIA_PATH', '')," . "(-1, 'GENERATE_UIDS', '0')," . "(-1, 'HIDE_GEDCOM_ERRORS', '1')," . "(-1, 'HIDE_LIVE_PEOPLE', '1')," . "(-1, 'INDI_FACTS_ADD', 'AFN,BIRT,DEAT,BURI,CREM,ADOP,BAPM,BARM,BASM,BLES,CHRA,CONF,FCOM,ORDN,NATU,EMIG,IMMI,CENS,PROB,WILL,GRAD,RETI,DSCR,EDUC,IDNO,NATI,NCHI,NMR,OCCU,PROP,RELI,RESI,SSN,TITL,BAPL,CONL,ENDL,SLGC,_MILI,ASSO,RESN')," . "(-1, 'INDI_FACTS_QUICK', 'BIRT,BURI,BAPM,CENS,DEAT,OCCU,RESI')," . "(-1, 'INDI_FACTS_UNIQUE', '')," . "(-1, 'KEEP_ALIVE_YEARS_BIRTH', '')," . "(-1, 'KEEP_ALIVE_YEARS_DEATH', '')," . "(-1, 'LANGUAGE', 'en-US')," . "(-1, 'MAX_ALIVE_AGE', '120')," . "(-1, 'MAX_DESCENDANCY_GENERATIONS', '15')," . "(-1, 'MAX_PEDIGREE_GENERATIONS', '10')," . "(-1, 'MEDIA_DIRECTORY', 'media/')," . "(-1, 'MEDIA_ID_PREFIX', 'M')," . "(-1, 'MEDIA_UPLOAD', :MEDIA_UPLOAD)," . "(-1, 'META_DESCRIPTION', '')," . "(-1, 'META_TITLE', :META_TITLE)," . "(-1, 'NOTE_FACTS_ADD', 'SOUR,RESN')," . "(-1, 'NOTE_FACTS_QUICK', '')," . "(-1, 'NOTE_FACTS_UNIQUE', '')," . "(-1, 'NOTE_ID_PREFIX', 'N')," . "(-1, 'NO_UPDATE_CHAN', '0')," . "(-1, 'PEDIGREE_FULL_DETAILS', '1')," . "(-1, 'PEDIGREE_LAYOUT', '1')," . "(-1, 'PEDIGREE_ROOT_ID', '')," . "(-1, 'PEDIGREE_SHOW_GENDER', '0')," . "(-1, 'PREFER_LEVEL2_SOURCES', '1')," . "(-1, 'QUICK_REQUIRED_FACTS', 'BIRT,DEAT')," . "(-1, 'QUICK_REQUIRED_FAMFACTS', 'MARR')," . "(-1, 'REPO_FACTS_ADD', 'PHON,EMAIL,FAX,WWW,RESN')," . "(-1, 'REPO_FACTS_QUICK', '')," . "(-1, 'REPO_FACTS_UNIQUE', 'NAME,ADDR')," . "(-1, 'REPO_ID_PREFIX', 'R')," . "(-1, 'REQUIRE_AUTHENTICATION', '0')," . "(-1, 'SAVE_WATERMARK_IMAGE', '0')," . "(-1, 'SAVE_WATERMARK_THUMB', '0')," . "(-1, 'SHOW_AGE_DIFF', '0')," . "(-1, 'SHOW_COUNTER', '1')," . "(-1, 'SHOW_DEAD_PEOPLE', :SHOW_DEAD_PEOPLE)," . "(-1, 'SHOW_EST_LIST_DATES', '0')," . "(-1, 'SHOW_FACT_ICONS', '1')," . "(-1, 'SHOW_GEDCOM_RECORD', '0')," . "(-1, 'SHOW_HIGHLIGHT_IMAGES', '1')," . "(-1, 'SHOW_LDS_AT_GLANCE', '0')," . "(-1, 'SHOW_LEVEL2_NOTES', '1')," . "(-1, 'SHOW_LIVING_NAMES', :SHOW_LIVING_NAMES)," . "(-1, 'SHOW_MEDIA_DOWNLOAD', '0')," . "(-1, 'SHOW_NO_WATERMARK', :SHOW_NO_WATERMARK)," . "(-1, 'SHOW_PARENTS_AGE', '1')," . "(-1, 'SHOW_PEDIGREE_PLACES', '9')," . "(-1, 'SHOW_PEDIGREE_PLACES_SUFFIX', '0')," . "(-1, 'SHOW_PRIVATE_RELATIONSHIPS', '1')," . "(-1, 'SHOW_RELATIVES_EVENTS', '_BIRT_CHIL,_BIRT_SIBL,_MARR_CHIL,_MARR_PARE,_DEAT_CHIL,_DEAT_PARE,_DEAT_GPAR,_DEAT_SIBL,_DEAT_SPOU')," . "(-1, 'SOURCE_ID_PREFIX', 'S')," . "(-1, 'SOUR_FACTS_ADD', 'NOTE,REPO,SHARED_NOTE,RESN')," . "(-1, 'SOUR_FACTS_QUICK', 'TEXT,NOTE,REPO')," . "(-1, 'SOUR_FACTS_UNIQUE', 'AUTH,ABBR,TITL,PUBL,TEXT')," . "(-1, 'SUBLIST_TRIGGER_I', '200')," . "(-1, 'SURNAME_LIST_STYLE', 'style2')," . "(-1, 'SURNAME_TRADITION', 'paternal')," . "(-1, 'THUMBNAIL_WIDTH', '100')," . "(-1, 'USE_RIN', '0')," . "(-1, 'USE_SILHOUETTE', '1')," . "(-1, 'WATERMARK_THUMB', '0')," . "(-1, 'WEBTREES_EMAIL', :WEBTREES_EMAIL)," . "(-1, 'WORD_WRAPPED_NOTES', '0')")->execute(array('MEDIA_UPLOAD' => Auth::PRIV_USER, 'META_TITLE' => WT_WEBTREES, 'SHOW_DEAD_PEOPLE' => Auth::PRIV_PRIVATE, 'SHOW_LIVING_NAMES' => Auth::PRIV_USER, 'SHOW_NO_WATERMARK' => Auth::PRIV_USER, 'WEBTREES_EMAIL' => $WEBTREES_EMAIL));
// Previous versions of webtrees allowed this setting to be empty.
Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name ='WEBTREES_EMAIL' AND setting_value = ''")->execute();
Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT gedcom_id, 'WEBTREES_EMAIL', :WEBTREES_EMAIL" . " FROM `##gedcom` WHERE gedcom_id > 0")->execute(array('WEBTREES_EMAIL' => $WEBTREES_EMAIL));
// Default restrictions
Database::prepare("INSERT IGNORE INTO `##default_resn` (gedcom_id, tag_type, resn) VALUES " . "(-1, 'SSN', 'confidential')," . "(-1, 'SOUR', 'privacy')," . "(-1, 'REPO', 'privacy')," . "(-1, 'SUBM', 'confidential')," . "(-1, 'SUBN', 'confidential')")->execute();
}
示例14: 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;
}
}
示例15: getEditMenu
/**
* get edit menu
*/
public function getEditMenu()
{
if (!$this->record || $this->record->isPendingDeletion()) {
return null;
}
// edit menu
$menu = new Menu(I18N::translate('Edit'), '#', 'menu-note');
if (Auth::isEditor($this->record->getTree())) {
$menu->addSubmenu(new Menu(I18N::translate('Edit the note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");')));
// delete
$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
}
return $menu;
}