Example #1
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype;
     switch (WT_Filter::get('action')) {
         case 'deletenews':
             $news_id = WT_Filter::getInteger('news_id');
             if ($news_id) {
                 deleteNews($news_id);
             }
             break;
     }
     $block = get_block_setting($block_id, 'block', true);
     if ($cfg) {
         foreach (array('block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     $usernews = getUserNews(WT_USER_ID);
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = '';
     $title .= $this->getTitle();
     $content = '';
     if (count($usernews) == 0) {
         $content .= WT_I18N::translate('You have not created any journal items.');
     }
     foreach ($usernews as $key => $news) {
         $day = date('j', $news['date']);
         $mon = date('M', $news['date']);
         $year = date('Y', $news['date']);
         $content .= "<div class=\"journal_box\">";
         $content .= "<div class=\"news_title\">" . $news['title'] . '</div>';
         $content .= "<div class=\"news_date\">" . format_timestamp($news['date']) . '</div>';
         if ($news["text"] == strip_tags($news["text"])) {
             // No HTML?
             $news["text"] = nl2br($news["text"], false);
         }
         $content .= $news["text"] . "<br><br>";
         $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?news_id='+" . $key . ", '_blank', indx_window_specs); return false;\">" . WT_I18N::translate('Edit') . "</a> | ";
         $content .= "<a href=\"index.php?action=deletenews&amp;news_id={$key}&amp;ctype={$ctype}\" onclick=\"return confirm('" . WT_I18N::translate('Are you sure you want to delete this journal entry?') . "');\">" . WT_I18N::translate('Delete') . "</a><br>";
         $content .= "</div><br>";
     }
     if (WT_USER_ID) {
         $content .= "<br><a href=\"#\" onclick=\"window.open('editnews.php?user_id='+WT_USER_ID, '_blank', indx_window_specs); return false;\">" . WT_I18N::translate('Add a new journal entry') . "</a>";
     }
     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;
     }
 }
Example #2
0
/**
 * Prints a user news/journal
 *
 */
function print_user_news($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $TEXT_DIRECTION, $ctype;
    $usernews = getUserNews(PGV_USER_ID);
    $id = "user_news";
    $title = print_help_link("mygedview_myjournal_help", "qm", "", false, true);
    $title .= $pgv_lang["my_journal"];
    $content = "";
    if (count($usernews) == 0) {
        $content .= $pgv_lang["no_journal"] . ' ';
    }
    foreach ($usernews as $key => $news) {
        $day = date("j", $news["date"]);
        $mon = date("M", $news["date"]);
        $year = date("Y", $news["date"]);
        $content .= "<div class=\"person_box\">";
        $ct = preg_match("/#(.+)#/", $news["title"], $match);
        if ($ct > 0) {
            if (isset($pgv_lang[$match[1]])) {
                $news["title"] = str_replace($match[0], $pgv_lang[$match[1]], $news["title"]);
            }
        }
        $content .= "<span class=\"news_title\">" . PrintReady($news["title"]) . "</span><br />";
        $content .= "<span class=\"news_date\">" . format_timestamp($news["date"]) . "</span><br /><br />";
        if (preg_match("/#(.+)#/", $news["text"], $match)) {
            if (isset($pgv_lang[$match[1]])) {
                $news["text"] = str_replace($match[0], $pgv_lang[$match[1]], $news["text"]);
            }
        }
        if (preg_match("/#(.+)#/", $news["text"], $match)) {
            if (isset($pgv_lang[$match[1]])) {
                $news["text"] = str_replace($match[0], $pgv_lang[$match[1]], $news["text"]);
            }
            if (isset(${$match}[1])) {
                $news["text"] = str_replace($match[0], ${$match}[1], $news["text"]);
            }
        }
        $trans = get_html_translation_table(HTML_SPECIALCHARS);
        $trans = array_flip($trans);
        $news["text"] = strtr($news["text"], $trans);
        $news["text"] = nl2br($news["text"]);
        $content .= PrintReady($news["text"]) . "<br /><br />";
        $content .= "<a href=\"javascript:;\" onclick=\"editnews('{$key}'); return false;\">" . $pgv_lang["edit"] . "</a> | ";
        $content .= "<a href=\"" . encode_url("index.php?action=deletenews&news_id={$key}&ctype={$ctype}") . "\" onclick=\"return confirm('" . $pgv_lang["confirm_journal_delete"] . "');\">" . $pgv_lang["delete"] . "</a><br />";
        $content .= "</div><br />";
    }
    if (PGV_USER_ID) {
        $content .= "<br /><a href=\"javascript:;\" onclick=\"addnews('" . PGV_USER_ID . "'); return false;\">" . $pgv_lang["add_journal"] . "</a>";
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
             ${$key} = true;
         } elseif ($value == 'no') {
             ${$key} = false;
         } else {
             ${$key} = $value;
         }
     }
 }
 //-- delete the cache files for the welcome page blocks
 require_once PGV_ROOT . 'includes/index_cache.php';
 clearCache();
 $logline = AddToLog("Gedcom configuration " . $INDEX_DIRECTORY . $FILE . "_conf.php" . " updated");
 $gedcomconfname = $FILE . "_conf.php";
 check_in($logline, $gedcomconfname, $INDEX_DIRECTORY);
 if (!$errors) {
     $gednews = getUserNews($FILE);
     if (count($gednews) == 0) {
         $news = array();
         $news["title"] = "#default_news_title#";
         $news["username"] = $FILE;
         $news["text"] = "#default_news_text#";
         $news["date"] = client_time();
         addNews($news);
     }
     if ($source == "upload_form") {
         $check = "upload";
     } elseif ($source == "add_form") {
         $check = "add";
     } elseif ($source == "add_new_form") {
         $check = "add_new";
     }
Example #4
0
 function totalGedcomNews()
 {
     return WT_I18N::number(count(getUserNews(WT_GEDCOM)));
 }
Example #5
0
/**
 * Prints a gedcom news/journal
 *
 * @todo Add an allowed HTML translation
 */
function print_gedcom_news($block = true, $config = '', $side, $index)
{
    global $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $TEXT_DIRECTION, $ctype, $PGV_BLOCKS;
    if (empty($config)) {
        $config = $PGV_BLOCKS['print_gedcom_news']['config'];
    }
    if ($config['flag'] == 0) {
        $config['limit'] = 'nolimit';
    }
    if (isset($_REQUEST['gedcom_news_archive'])) {
        $config['limit'] = 'nolimit';
        $config['flag'] = 0;
    }
    $usernews = getUserNews(PGV_GEDCOM);
    $id = "gedcom_news";
    $title = "";
    if (PGV_USER_GEDCOM_ADMIN) {
        $title .= print_help_link('index_gedcom_news_ahelp', 'qm_ah', "", false, true);
    } else {
        $title .= print_help_link('index_gedcom_news_help', 'qm', "", false, true);
    }
    if ($PGV_BLOCKS['print_gedcom_news']['canconfig']) {
        if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
            if ($ctype == "gedcom") {
                $name = PGV_GEDCOM;
            } else {
                $name = PGV_USER_NAME;
            }
            $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('index_edit.php?name={$name}&amp;ctype={$ctype}&amp;action=configure&amp;side={$side}&amp;index={$index}', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">" . "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>\n";
        }
    }
    $title .= $pgv_lang['gedcom_news'];
    $content = "";
    if (count($usernews) == 0) {
        $content .= $pgv_lang['no_news'] . '<br />';
    }
    $c = 0;
    $td = time();
    foreach ($usernews as $news) {
        if ($config['limit'] == 'count') {
            if ($c >= $config['flag']) {
                break;
            }
            $c++;
        }
        if ($config['limit'] == 'date') {
            if (floor(($td - $news['date']) / 86400) > $config['flag']) {
                break;
            }
        }
        //		print "<div class=\"person_box\" id=\"{$news['anchor']}\">\n";
        $content .= "<div class=\"news_box\" id=\"{$news['anchor']}\">\n";
        // Look for $pgv_lang, $factarray, and $GLOBALS substitutions in the News title
        $newsTitle = print_text($news['title'], 0, 2);
        $ct = preg_match("/#(.+)#/", $newsTitle, $match);
        if ($ct > 0) {
            if (isset($pgv_lang[$match[1]])) {
                $newsTitle = str_replace("{$match['0']}", $pgv_lang[$match[1]], $newsTitle);
            }
        }
        $content .= "<span class=\"news_title\">" . PrintReady($newsTitle) . "</span><br />\n";
        $content .= "<span class=\"news_date\">" . format_timestamp($news['date']) . "</span><br /><br />\n";
        // Look for $pgv_lang, $factarray, and $GLOBALS substitutions in the News text
        $newsText = print_text($news['text'], 0, 2);
        $ct = preg_match("/#(.+)#/", $newsText, $match);
        if ($ct > 0) {
            if (isset($pgv_lang[$match[1]])) {
                $newsText = str_replace("{$match['0']}", $pgv_lang[$match[1]], $newsText);
            }
        }
        $ct = preg_match("/#(.+)#/", $newsText, $match);
        if ($ct > 0) {
            $varname = $match[1];
            if (isset($pgv_lang[$varname])) {
                $newsText = str_replace("{$match['0']}", $pgv_lang[$varname], $newsText);
            } else {
                if (defined('PGV_' . $varname)) {
                    // e.g. global $VERSION is now constant PGV_VERSION
                    $varname = 'PGV_' . $varname;
                }
                if (defined($varname)) {
                    $newsText = str_replace("{$match['0']}", constant($varname), $newsText);
                } else {
                    if (isset(${$varname})) {
                        $newsText = str_replace("{$match['0']}", ${$varname}, $newsText);
                    }
                }
            }
        }
        $trans = get_html_translation_table(HTML_SPECIALCHARS);
        $trans = array_flip($trans);
        $newsText = strtr($newsText, $trans);
        $newsText = nl2br($newsText);
        $content .= PrintReady($newsText) . "<br />\n";
        // Print Admin options for this News item
        if (PGV_USER_GEDCOM_ADMIN) {
            $content .= "<hr size=\"1\" />" . "<a href=\"javascript:;\" onclick=\"editnews('" . $news['id'] . "'); return false;\">{$pgv_lang['edit']}</a> | " . "<a href=\"" . encode_url("index.php?action=deletenews&news_id=" . $news['id'] . "&ctype={$ctype}") . "\" onclick=\"return confirm('{$pgv_lang['confirm_news_delete']}');\">{$pgv_lang['delete']}</a><br />";
        }
        $content .= "</div>\n";
    }
    $printedAddLink = false;
    if (PGV_USER_GEDCOM_ADMIN) {
        $content .= "<a href=\"javascript:;\" onclick=\"addnews('" . urlencode(PGV_GEDCOM) . "'); return false;\">" . $pgv_lang["add_news"] . "</a>";
        $printedAddLink = true;
    }
    if ($config['limit'] == 'date' || $config['limit'] == 'count') {
        if ($printedAddLink) {
            $content .= "&nbsp;&nbsp;|&nbsp;&nbsp;";
        }
        $content .= print_help_link("gedcom_news_archive_help", "qm", "", false, true);
        $content .= "<a href=\"" . encode_url("index.php?gedcom_news_archive=yes&ctype={$ctype}") . "\">" . $pgv_lang['gedcom_news_archive'] . "</a><br />";
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
Example #6
0
 function totalGedcomNews()
 {
     return count(getUserNews($GLOBALS['GEDCOM']));
 }
Example #7
0
function getShareContent($module = 'Space', $id)
{
    $content = '';
    if ($module == 'Space') {
        $blog = D('User')->find($id);
        $userFace = getUserFace($id, 'm');
        $userName = getUserName($id);
        $userProvince = getUserProvince($id);
        $userNews = getUserNews($id);
        $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/space/" . $id . "\"><img src=\"" . $userFace . "\" alt=\"" . $userName . "\"></a></div>";
        $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/space/" . $id . "\">" . $userName . "</a></strong><br>" . $userProvince . "<br><br>" . $userNews . "</div>";
    } else {
        if ($module == 'Blog') {
            $blog = D('Blog')->find($id);
            $titleImage = getBlogTitleImage($id);
            if ($titleImage) {
                $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/blog/" . $blog->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=72&h=72&url=" . $titleImage . "\" alt=\"" . $blog->title . "\"></a></div>";
            }
            $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/blog/" . $blog->id . "\">" . $blog->title . "</a></strong> - <a href=\"" . __APP__ . "/space/" . $blog->userId . "\">" . getUserName($blog->userId) . "</a><br>" . getBlogShort($blog->content) . "<br><a href=\"" . __APP__ . "/blog/" . $blog->id . "\">阅读全文</a></div>";
        } else {
            if ($module == 'Photo') {
                $photo = D('Photo')->find($id);
                $titleImage = $photo->imagePath;
                $album = D('Album')->find($photo->albumId);
                if ($titleImage) {
                    $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/photo/" . $photo->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=130&h=200&t=f&url=" . $titleImage . "\" alt=\"" . $photo->title . "\"></a></div>";
                }
                $content .= "<div class=\"share-content-desc\">相册:<a href=\"" . __APP__ . "/album/" . $album->id . "\">" . $album->title . "</a><br>用户:<a href=\"" . __APP__ . "/space/" . $photo->userId . "\">" . getUserName($photo->userId) . "</a><br><strong><a href=\"__APP__/photo/" . $photo->id . "\">" . $photo->title . "</a></strong></div>";
            } else {
                if ($module == 'Album') {
                    $album = D('Album')->find($id);
                    $titleImage = $album->coverPhotoId;
                    if ($titleImage > 0) {
                        $titleImage = D('Photo')->find($album->coverPhotoId)->imagePath;
                        $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/album/" . $album->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=130&h=200&t=f&url=" . $titleImage . "\" alt=\"" . $album->title . "\"></a></div>";
                    }
                    $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/album/" . $album->id . "\">" . $album->title . "</a></strong> - <a href=\"" . __APP__ . "/space/" . $album->userId . "\">" . getUserName($album->userId) . "</a><br>共" . $album->photoCount . "张照片<br>" . $album->info . "</div>";
                }
            }
        }
    }
    return $content;
}