示例#1
0
 public function display()
 {
     $host = Settings::getInstance()->get("host");
     echo "<div style=\"width:300px;margin-right:10px;float:left;\"><h2>" . Language::DirectTranslateHtml("DATATYPES") . "</h2>";
     $list = new LinkList();
     $url = UrlRewriting::GetUrlByAlias("admin/data", "show=");
     $list->fillSelect = "SELECT displayName as text, CONCAT('" . $url . "',id) as href FROM {'dbprefix'}datatypes ORDER BY displayName";
     $list->display();
     echo "</div>";
     if (is_numeric($_GET['show'])) {
         $id = DataBase::Current()->EscapeString($_GET['show']);
         $datatype = DataBase::Current()->ReadRow("SELECT * FROM {'dbprefix'}datatypes WHERE id = '" . $id . "' ORDER BY displayName");
         echo "<div><h2>" . htmlentities($datatype->displayName) . "</h2><p>" . htmlentities($datatype->description) . "</p><h2>" . Language::DirectTranslateHtml("PROPERTIES") . "</h2>";
         $table = new Table();
         $displayName = new TableColumn("displayName", "Name");
         $dataName = new TableColumn("dataName", "Datenname");
         $validator = new TableColumn("validator_name", "Inhalt", "IFNULL((SELECT name FROM {'dbprefix'}data_validator WHERE id = {'dbprefix'}datafields.validator),'')");
         $table->columns->add($displayName);
         $table->columns->add($dataName);
         $table->columns->add($validator);
         $displayName->autoWidth = true;
         $validator->autoWidth = true;
         $table->condition = "dataType = '" . DataBase::Current()->EscapeString($_GET['show']) . "'";
         $table->name = "{'dbprefix'}datafields";
         $table->orderBy = "displayName";
         $table->display();
         echo "</div>";
         $this->displayEvents();
         $this->displaySharing();
     }
 }
示例#2
0
$myMain =& $MODULES[$meMod]['mainright'];
$mySubs =& $catSection->readSubsDataDB();
$myArts =& $catSection->readArtsDataDB();
if (!$MODULES['argv']['do_admin']) {
    $catSection->readTuitContentsDB();
    $catSection->readTextBoxesDB();
}
if (count($mySubs) + count($myArts) >= MIN_TO_COUNT) {
    $doCnt = 1;
}
if (!$artToShow and !$MODULES['argv']['do_admin']) {
    $myMain .= "\n  <table>\n  <tr valign=\"top\">\n  <td>\n    <table cellspacing=2 cellpadding=5>\n    " . $catSection->allElementsHTML($doCnt);
    $myMain .= "\n    <tr>\n    <td colspan=2>\n      <a href=\"?m={$meMod}&do_admin=1&act=section&s=1\">Edit main section</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=section&pre={$catSecNum}\">Add subsection</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=article&s={$catSecNum}\">Add article</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=textbox&s={$catSecNum}\">Add textbox</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=xoftheday&s={$catSecNum}\">Add X of the day</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=linx&s={$catSecNum}\">Add link</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=tuit&add=exercise&s={$catSecNum}\">Add exercise</a><br>\n      <a href=\"?m={$meMod}&do_admin=1&act=tuit&add=unit&s={$catSecNum}\">Add unit</a>\n    </td>\n    </tr>\n";
    $myMain .= "\n  <tr>\n  <td colspan=2>\n";
    //  $myMain .= $catSection->textBoxesHTML();
    $myLinx = new LinkList($catSection->id);
    $myMain .= $myLinx->linxHTML();
    $myMain .= "\n  </td>\n  </tr>\n  </table>\n  </td>\n";
    $catSection->readXOfTheDaysDataDB();
    if (count($catSection->xOfTheDays) or $catSection->desc) {
        $myMain .= "\n    <td class=\"xoftheday\">";
        if ($catSection->desc) {
            $myMain .= $catSection->sectionDescriptionHTML();
        }
        if (count($catSection->xOfTheDays)) {
            $myMain .= $catSection->xOfTheDaysHTML();
        }
        $myMain .= "</td>\n";
    }
    $myMain .= "\n  </tr>\n  </table>\n";
} elseif ($artToShow and !$MODULES['argv']['do_admin']) {
示例#3
0
<?php

include_once "../include/page.php";
include_once "../include/linklist.php";
$p = new Page("news", 2);
$l = new LinkList($p->u);
dev();
$l->additem("news items", "news", 0);
echo $l->dispList();
$p->addJs("\$(\"#accordion\").accordion({autoHeight: false, navigation: true})");
if (!isset($_GET['action'])) {
    //if no action, do nothing. This is just so we do not need to check every time.
} elseif ($_GET['action'] == 'addnews') {
    if (!isset($_GET['item']) || $_GET['item'] == "") {
        $p->db->qry("INSERT INTO news (title, uid, content) VALUES ('{$_GET['title']}','{$p->u->id}', '" . addSlashes($_GET['newscontent']) . "')");
    } else {
        $p->db->qry("UPDATE news SET uid = '{$p->u->id}',time = CURRENT_TIMESTAMP, title = '{$_GET['title']}',content = '" . addSlashes($_GET['newscontent']) . "' WHERE id='" . $_GET['item'] . "'");
    }
} elseif ($_GET['action'] == 'modify') {
    extract($_GET);
    $p->db->qry("SELECT title, content FROM news WHERE id='{$item}' LIMIT 1");
    $row = $p->db->fetchLast();
    $p->addJs("document.addnews.newscontent.value='" . addSlashes($row['content']) . "';");
    $p->addJs("document.addnews.title.value='{$row['title']}';");
    $p->addJs("document.addnews.item.value='{$item}';");
} elseif ($_GET['action'] == 'delete') {
    $p->db->qry("DELETE FROM news WHERE id = {$_GET['item']}");
}
//new
echo "<div id=\"accordion\"><h3><a>Edit Entry</a></h3><div>";
echo "<form name=\"addnews\" id=\"addnews\" onsubmit=\"sendForm(this,'admin_news');false;\">\r\n<input type=\"text\" name=\"title\" /> by {$p->u->username} @ [now] wrote:<br/><textarea id=\"newscontent\" name=\"newscontent\" cols=\"45\" rows=\"5\"></textarea><br/><input type=\"submit\" class=\"ui-button ui-widget ui-state-default ui-corner-all\" /><input type=\"hidden\" name=\"item\" id=\"item\" value=\"\" /></form></div>";
 public function testLinkList()
 {
     $totalNodes = 100;
     $theList = new LinkList();
     for ($i = 1; $i <= $totalNodes; $i++) {
         $theList->insertLast($i);
     }
     $this->assertEquals($totalNodes, $theList->totalNodes());
     for ($i = 1; $i <= $totalNodes; $i++) {
         $theList->insertFirst($i);
     }
     $totalNodes = $totalNodes * 2;
     $this->assertEquals($totalNodes, $theList->totalNodes());
     $theList->reverseList();
     $this->assertEquals($totalNodes, $theList->totalNodes());
     $theList->deleteFirstNode();
     $this->assertEquals($totalNodes - 1, $theList->totalNodes());
     $theList->deleteLastNode();
     $this->assertEquals($totalNodes - 2, $theList->totalNodes());
     /* Delete node which has a value of '5' */
     $theList->deleteNode(5);
     $this->assertEquals($totalNodes - 3, $theList->totalNodes());
     /* Insert a node at the end of the list with a value of '22' */
     $theList->insertLast(22);
     $this->assertEquals($totalNodes - 2, $theList->totalNodes());
     /* Find a node with a value of '25' (is in the list) */
     $found = $theList->find(25);
     $this->assertEquals(25, $found->data);
     /* Find a node with a value of '125' (is not in the list) */
     $found = $theList->find(125);
     $this->assertNull($found);
     /* Return the data stored in the node at position '50'
        which is in the list */
     $data = $theList->readNode(50);
     $this->assertEquals(50, $data);
     /* Return the data stored in the node at position '450'
        which is not in the list */
     $data = $theList->readNode(450);
     $this->assertNull($data);
 }
示例#5
0
    /**
     * Displays a list of recently approved links if this feature is enabled in
     * $wgLinkPageDisplay.
     *
     * @return HTML
     */
    function getNewLinks()
    {
        global $wgLinkPageDisplay;
        if (!$wgLinkPageDisplay['new_links']) {
            return '';
        }
        $output = '';
        $linkRedirect = SpecialPage::getTitleFor('LinkRedirect');
        $l = new LinkList();
        $links = $l->getLinkList(LINK_APPROVED_STATUS, '', 7, 0);
        foreach ($links as $link) {
            $output .= '<div class="link-recent">
			<a href="' . $linkRedirect->escapeFullURL("url={$link['url']}") . "\" target=\"new\">{$link['title']}</a>\n\t\t</div>";
        }
        $output = '<div class="link-container">
			<h2>' . wfMsg('linkfilter-new-links-title') . '</h2>
			<div>' . $output . '</div>
		</div>';
        return $output;
    }
    /**
     * Callback function for registerLinkFilterHook.
     */
    public static function renderLinkFilterHook($input, $args, $parser)
    {
        global $wgMemc, $wgOut;
        $parser->disableCache();
        // Add CSS (ParserOutput class only has addModules(), not
        // addModuleStyles() or addModuleScripts()...strange)
        $wgOut->addModuleStyles('ext.linkFilter');
        if (isset($args['count'])) {
            $count = intval($args['count']);
        } else {
            $count = 10;
        }
        $key = wfMemcKey('linkfilter', $count);
        $data = $wgMemc->get($key);
        if ($data) {
            wfDebugLog('LinkFilter', "Loaded linkfilter hook from cache\n");
            $links = $data;
        } else {
            wfDebugLog('LinkFilter', "Loaded linkfilter hook from DB\n");
            $l = new LinkList();
            $links = $l->getLinkList(LINK_APPROVED_STATUS, '', $count, 1, 'link_approved_date');
            $wgMemc->set($key, $links, 60 * 5);
        }
        $link_submit = SpecialPage::getTitleFor('LinkSubmit');
        $link_all = SpecialPage::getTitleFor('LinksHome');
        $output = '<div>

				<div class="linkfilter-links">
					<a href="' . $link_submit->escapeFullURL() . '">' . wfMsg('linkfilter-submit') . '</a> / <a href="' . $link_all->escapeFullURL() . '">' . wfMsg('linkfilter-all') . '</a>';
        // Show a link to the link administration panel for privileged users
        if (Link::canAdmin()) {
            $output .= ' / <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
        }
        $output .= '</div>
				<div class="cleared"></div>';
        foreach ($links as $link) {
            $output .= '<div class="link-item-hook">
			<span class="link-item-hook-type">' . $link['type_name'] . '</span>
			<span class="link-item-hook-url">
				<a href="' . $link['wiki_page'] . '" rel="nofollow">' . $link['title'] . '</a>
			</span>
			<span class="link-item-hook-page">
				<a href="' . $link['wiki_page'] . '">(' . wfMsgExt('linkfilter-comments', 'parsemag', $link['comments']) . ')</a>
			</span>
		</div>';
        }
        $output .= '</div>';
        return $output;
    }
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgOut, $wgRequest, $wgSupressPageTitle;
        $wgSupressPageTitle = true;
        // Add CSS & JS
        $wgOut->addModules('ext.linkFilter');
        $per_page = 20;
        $page = $wgRequest->getInt('page', 1);
        $link_type = $wgRequest->getInt('link_type');
        if ($link_type) {
            $type_name = Link::$link_types[$link_type];
            $pageTitle = wfMsg('linkfilter-home-title', $type_name);
        } else {
            $type_name = 'All';
            $pageTitle = wfMsg('linkfilter-home-title-all');
        }
        $wgOut->setPageTitle($pageTitle);
        $output = '<div class="links-home-left">' . "\n\t";
        $output .= '<h1 class="page-title">' . $pageTitle . '</h1>' . "\n\t";
        $output .= '<div class="link-home-navigation">
		<a href="' . Link::getSubmitLinkURL() . '">' . wfMsg('linkfilter-submit-title') . '</a>' . "\n";
        if (Link::canAdmin()) {
            $output .= "\t\t" . '<a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>' . "\n";
        }
        $output .= "\t\t" . '<div class="cleared"></div>
		</div>' . "\n";
        $l = new LinkList();
        $type = 0;
        // FIXME lazy hack --Jack on July 2, 2009
        $total = $l->getLinkListCount(LINK_APPROVED_STATUS, $type);
        $links = $l->getLinkList(LINK_APPROVED_STATUS, $type, $per_page, $page, 'link_approved_date');
        $linkRedirect = SpecialPage::getTitleFor('LinkRedirect');
        $output .= '<div class="links-home-container">';
        $link_count = count($links);
        $x = 1;
        // No links at all? Oh dear...show a message to the user about that!
        if ($link_count <= 0) {
            $wgOut->addWikiMsg('linkfilter-no-links-at-all');
        }
        // Create RSS feed icon for special page
        $wgOut->setSyndicated(true);
        // Make feed (RSS/Atom) if requested
        $feedType = $wgRequest->getVal('feed');
        if ($feedType != '') {
            return $this->makeFeed($feedType, $links);
        }
        foreach ($links as $link) {
            $border_fix = '';
            if ($link_count == $x) {
                $border_fix = 'border-fix';
            }
            $border_fix2 = '';
            wfSuppressWarnings();
            $date = date('l, F j, Y', $link['approved_timestamp']);
            if ($date != $last_date) {
                $border_fix2 = ' border-top-fix';
                $output .= "<div class=\"links-home-date\">{$date}</div>";
                #global $wgLang;
                #$unix = wfTimestamp( TS_MW, $link['approved_timestamp'] );
                #$weekday = $wgLang->getWeekdayName( gmdate( 'w', $unix ) + 1 );
                #$output .= '<div class="links-home-date">' . $weekday .
                #	wfMsg( 'word-separator' ) . $wgLang->date( $unix, true ) .
                #	'</div>';
            }
            wfRestoreWarnings();
            // okay, so suppressing E_NOTICEs is kinda bad practise, but... -Jack, January 21, 2010
            $last_date = $date;
            $output .= "<div class=\"link-item-container{$border_fix2}\">\n\t\t\t\t\t<div class=\"link-item-type\">\n\t\t\t\t\t\t{$link['type_name']}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"link-item\">\n\t\t\t\t\t\t<div class=\"link-item-url\">\n\t\t\t\t\t\t\t<a href=\"" . $linkRedirect->escapeFullURL(array('link' => 'true', 'url' => $link['url'])) . '" target="new">' . $link['title'] . '</a>
						</div>
						<div class="link-item-desc">' . $link['description'] . '</div>
					</div>
					<div class="link-item-page">
						<a href="' . $link['wiki_page'] . '">(' . wfMsgExt('linkfilter-comments', 'parsemag', $link['comments']) . ')</a>
					</div>
					<div class="cleared"></div>';
            $output .= '</div>';
            $x++;
        }
        $output .= '</div>';
        /**
         * Build next/prev nav
         */
        $numofpages = $total / $per_page;
        $pageLink = $this->getTitle();
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $pageLink->escapeFullURL('page=' . ($page - 1)) . '">' . wfMsg('linkfilter-previous') . '</a> ';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
            }
            if ($numofpages > $total / $per_page) {
                $numofpages = $total / $per_page + 1;
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= '<a href="' . $pageLink->escapeFullURL('page=' . $i) . "\">{$i}</a> ";
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= ' <a href="' . $pageLink->escapeFullURL('page=' . ($page + 1)) . '">' . wfMsg('linkfilter-next') . '</a>';
            }
            $output .= '</div>';
        }
        $output .= '</div>' . "\n";
        // .links-home-left
        global $wgLinkPageDisplay;
        if ($wgLinkPageDisplay['rightcolumn']) {
            $output .= '<div class="links-home-right">';
            $output .= '<div class="links-home-unit-container">';
            $output .= $this->getPopularArticles();
            $output .= $this->getInTheNews();
            $output .= '</div>';
            $output .= $this->getAdUnit();
            $output .= '</div>';
        }
        $output .= '<div class="cleared"></div>' . "\n";
        $wgOut->addHTML($output);
    }
示例#8
0
         }
         $SQL->query("insert into " . DB_XOTD_SECTIONS_TABLE . " values {$ls}");
         header("Location: index.php?s={$catSecNum}");
     }
     if (is_numeric($catSecNum)) {
         $catSection = new Section($catSecNum);
     }
     $catSection->readXOfTheDaysDB();
     $xs = readXOfTheDayIDs();
     $myMain .= $catSection->addXOfTheDayForm($xs);
     break;
 case 'linx':
     if (!is_numeric($catSecNum)) {
         $linx = new LinkList();
     } else {
         $linx = new LinkList($catSecNum);
     }
     if ($MODULES['argv']['do_delete'] and $miscId) {
         $SQL->query("delete from " . DB_LINX_TABLE . " where " . DB_LINX_ID . "={$miscId}");
         header("Location: index.php?s=" . $linx->section . "\n");
         break;
     }
     if (!empty($MODULES['argv']['do_save'])) {
         if ($miscId) {
             $linx->linx[$miscId][DB_LINX_ID] = $miscId;
             $linx->linx[$miscId][DB_LINX_URL] = $MODULES['argv']['L_URL'];
             $linx->linx[$miscId][DB_LINX_NAME] = $MODULES['argv']['L_NAME'];
             $linx->linx[$miscId][DB_LINX_DESCRIPTION] = $MODULES['argv']['L_DESCRIPTION'];
             $linx->section = $MODULES['argv']['L_SECTION'];
             $linx->writeDataDB($miscId);
         } else {
示例#9
0
    }
    //empty linklist
    public function emptyList()
    {
        $this->firstNode == NULL;
    }
    //insertion at index
    public function insert($NewItem, $key)
    {
        if ($key == 0) {
            $this->insertFirst($NewItem);
        } else {
            $link = new ListNode($NewItem);
            $current = $this->firstNode;
            $previous = $this->firstNode;
            for ($i = 0; $i < $key; $i++) {
                $previous = $current;
                $current = $current->next;
            }
            $previous->next = $link;
            $link->next = $current;
            $this->count++;
        }
    }
}
$obj = new LinkList();
$obj->insertFirst($value);
$obj->insert($value, $key);
// at any index
$obj->deleteNode($value);
$obj->readList();
    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgUser, $wgOut, $wgRequest;
        // Check for linkadmin permission
        if (!$wgUser->isAllowed('linkadmin')) {
            throw new ErrorPageError('error', 'badaccess');
            return false;
        }
        // Blocked through Special:Block? No access for you either!
        if ($wgUser->isBlocked()) {
            $wgOut->blockedPage(false);
            return false;
        }
        // Is the database locked or not?
        if (wfReadOnly()) {
            $wgOut->readOnlyPage();
            return false;
        }
        // Set the page title
        $wgOut->setPageTitle(wfMsgHtml('linkfilter-approve-title'));
        // Add CSS & JS
        $wgOut->addModules('ext.linkFilter');
        $output = '';
        $output .= '<div class="lr-left">';
        $l = new LinkList();
        $links = $l->getLinkList(LINK_OPEN_STATUS, 0, 0, 0);
        $links_count = count($links);
        $x = 1;
        // The approval queue is empty? If so, show a message to the user about
        // that!
        if ($links_count <= 0) {
            $wgOut->addWikiMsg('linkfilter-nothing-to-approve');
        }
        foreach ($links as $link) {
            $submitter = Title::makeTitle(NS_USER, $link['user_name']);
            $linkText = preg_replace_callback('/(<a[^>]*>)(.*?)(<\\/a>)/i', array('LinkApprove', 'cutLinkFilterLinkText'), "<a href=\"{$link['url']}\" target=\"new\">{$link['url']}</a>");
            $border_fix = '';
            if ($links_count == $x) {
                $border_fix = ' border-fix';
            }
            $output .= "<div class=\"admin-link{$border_fix}\">\n\t\t\t\t\t<div class=\"admin-title\"><b>" . wfMsg('linkfilter-title') . '</b>: ' . htmlspecialchars($link['title']) . '</div>
					<div class="admin-desc"><b>' . wfMsg('linkfilter-description') . '</b>: ' . htmlspecialchars($link['description']) . '</div>
					<div class="admin-url"><b>' . wfMsg('linkfilter-url') . '</b>: <a href="' . $link['url'] . '" target="new">' . $linkText . '</a></div>
					<div class="admin-submitted"><b>' . wfMsg('linkfilter-submittedby') . "</b>: <a href=\"{$submitter->escapeFullURL()}\">{$link['user_name']}</a> " . wfMsg('linkfilter-ago', self::getLFTimeAgo($link['timestamp']), Link::getLinkType($link['type'])) . "</div>\n\t\t\t\t\t<div id=\"action-buttons-{$link['id']}\" class=\"action-buttons\">\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" class=\"action-accept\" data-link-id=\"{$link['id']}\">" . wfMsgHtml('linkfilter-admin-accept') . "</a>\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" class=\"action-reject\" data-link-id=\"{$link['id']}\">" . wfMsgHtml('linkfilter-admin-reject') . '</a>
						<div class="cleared"></div>
					</div>';
            $output .= '</div>';
            $x++;
        }
        // Admin instructions and the column of recently approved links
        $output .= '</div>';
        $output .= '<div class="lr-right">
			<div class="admin-link-instruction">' . wfMessage('linkfilter-admin-instructions')->inContentLanguage()->parse() . '</div>
			<div class="approved-link-container">
				<h3>' . wfMsgHtml('linkfilter-admin-recent') . '</h3>';
        $l = new LinkList();
        $links = $l->getLinkList(LINK_APPROVED_STATUS, 0, 10, 0, 'link_approved_date');
        // Nothing has been approved recently? Okay...
        if (count($links) <= 0) {
            $output .= wfMsg('linkfilter-no-recently-approved');
        } else {
            // Yay, we have something! Let's build a list!
            foreach ($links as $link) {
                $output .= '<div class="approved-link">
				<a href="' . $link['url'] . '" target="new">' . $link['title'] . '</a>
				<span class="approve-link-time">' . wfMsg('linkfilter-ago', self::getLFTimeAgo($link['approved_timestamp']), Link::getLinkType($link['type'])) . '</span>
			</div>';
            }
        }
        $output .= '</div>
			</div>
			<div class="cleared"></div>';
        $wgOut->addHTML($output);
    }