Example #1
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype;
     require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
     // Block actions
     $action = WT_Filter::get('action');
     $message_id = WT_Filter::getArray('message_id');
     if ($action == 'deletemessage') {
         foreach ($message_id as $msg_id) {
             deleteMessage($msg_id);
         }
     }
     $block = get_block_setting($block_id, 'block', true);
     if ($cfg) {
         foreach (array('block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     $messages = getUserMessages(WT_USER_ID);
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = WT_I18N::plural('%s message', '%s messages', count($messages), WT_I18N::number(count($messages)));
     $content = '<form name="messageform" action="index.php?ctype=' . $ctype . '" method="get" onsubmit="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message?  It cannot be retrieved later.') . '\');">';
     if (count(User::all()) > 1) {
         $content .= '<br>' . WT_I18N::translate('Send message') . " <select name=\"touser\">";
         $content .= '<option value="">' . WT_I18N::translate('&lt;select&gt;') . '</option>';
         foreach (User::all() as $user) {
             if ($user->getUserId() != WT_USER_ID && $user->getSetting('verified_by_admin') && $user->getSetting('contactmethod') != 'none') {
                 $content .= '<option value="' . WT_Filter::escapeHtml($user->getUserName()) . '">';
                 $content .= '<span dir="auto">' . WT_Filter::escapeHtml($user->getRealName()) . '</span> - <span dir="auto">' . WT_Filter::escapeHtml($user->getUserName()) . '</span>';
                 $content .= '</option>';
             }
         }
         $content .= '</select> <input type="button" value="' . WT_I18N::translate('Send') . '" onclick="message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\'); return false;"><br><br>';
     }
     if (count($messages) == 0) {
         $content .= WT_I18N::translate('You have no pending messages.') . "<br>";
     } else {
         $content .= '<input type="hidden" name="action" value="deletemessage">';
         $content .= '<table class="list_table"><tr>';
         $content .= '<td class="list_label">' . WT_I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . WT_I18N::translate('All') . '</a></td>';
         $content .= '<td class="list_label">' . WT_I18N::translate('Subject:') . '</td>';
         $content .= '<td class="list_label">' . WT_I18N::translate('Date sent:') . '</td>';
         $content .= '<td class="list_label">' . WT_I18N::translate('Email address:') . '</td>';
         $content .= '</tr>';
         foreach ($messages as $message) {
             $content .= '<tr>';
             $content .= '<td class="list_value_wrap"><input type="checkbox" id="cb_message' . $message->message_id . '" name="message_id[]" value="' . $message->message_id . '"></td>';
             $content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . WT_Filter::escapeHtml($message->subject) . '</b></a></td>';
             $content .= '<td class="list_value_wrap">' . format_timestamp($message->created) . '</td>';
             $content .= '<td class="list_value_wrap">';
             $user = User::findByIdentifier($message->sender);
             if ($user) {
                 $content .= '<span dir="auto">' . $user->getRealName() . '</span>';
                 $content .= '  - <span dir="auto">' . $user->getEmail() . '</span>';
             } else {
                 $content .= '<a href="mailto:' . WT_Filter::escapeHtml($message->sender) . '">' . WT_Filter::escapeHtml($message->sender) . '</a>';
             }
             $content .= '</td>';
             $content .= '</tr>';
             $content .= '<tr><td class="list_value_wrap" colspan="5"><div id="message' . $message->message_id . '" style="display:none;">';
             $content .= '<div dir="auto" style="white-space: pre-wrap;">' . WT_Filter::expandUrls($message->body) . '</div><br>';
             if (strpos($message->subject, WT_I18N::translate('RE: ')) !== 0) {
                 $message->subject = WT_I18N::translate('RE: ') . $message->subject;
             }
             if ($user) {
                 $content .= '<a href="#" onclick="reply(\'' . WT_Filter::escapeJs($message->sender) . '\', \'' . WT_Filter::escapeJs($message->subject) . '\'); return false;">' . WT_I18N::translate('Reply') . '</a> | ';
             }
             $content .= '<a href="index.php?action=deletemessage&amp;message_id[]=' . $message->message_id . '" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message?  It cannot be retrieved later.') . '\');">' . WT_I18N::translate('Delete') . '</a></div></td></tr>';
         }
         $content .= '</table>';
         $content .= '<input type="submit" value="' . WT_I18N::translate('Delete selected messages') . '"><br>';
     }
     $content .= '</form>';
     if ($template) {
         if ($block) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
 }
/**
 * Print SOUR structure
 *
 *  This function prints the input array of SOUR sub-records built by the
 *  getSourceStructure() function.
 */
function printSourceStructure($textSOUR)
{
    global $WT_TREE;
    $html = '';
    if ($textSOUR['PAGE']) {
        $html .= WT_Gedcom_Tag::getLabelValue('PAGE', WT_Filter::expandUrls($textSOUR['PAGE']));
    }
    if ($textSOUR['EVEN']) {
        $html .= WT_Gedcom_Tag::getLabelValue('EVEN', WT_Filter::escapeHtml($textSOUR['EVEN']));
        if ($textSOUR['ROLE']) {
            $html .= WT_Gedcom_Tag::getLabelValue('ROLE', WT_Filter::escapeHtml($textSOUR['ROLE']));
        }
    }
    if ($textSOUR['DATE'] || count($textSOUR['TEXT'])) {
        if ($textSOUR['DATE']) {
            $date = new WT_Date($textSOUR['DATE']);
            $html .= WT_Gedcom_Tag::getLabelValue('DATA:DATE', $date->Display(false));
        }
        foreach ($textSOUR['TEXT'] as $text) {
            $html .= WT_Gedcom_Tag::getLabelValue('TEXT', WT_Filter::formatText($text, $WT_TREE));
        }
    }
    if ($textSOUR['QUAY'] != '') {
        $html .= WT_Gedcom_Tag::getLabelValue('QUAY', WT_Gedcom_Code_Quay::getValue($textSOUR['QUAY']));
    }
    return '<div class="indent">' . $html . '</div>';
}
Example #3
0
 public static function formatText($text, WT_Tree $WT_TREE)
 {
     switch ($WT_TREE->preference('FORMAT_TEXT')) {
         case 'markdown':
             return '<div class="markdown" dir="auto">' . WT_Filter::markdown($text) . '</div>';
             break;
         case '':
         default:
             return '<div style="white-space: pre-wrap;" dir="auto">' . WT_Filter::expandUrls($text) . '</div>';
             break;
     }
 }