예제 #1
0
파일: news.php 프로젝트: skdong/nfs-ovd
function show_default()
{
    $news = Abstract_News::load_all();
    $can_manage_news = isAuthorized('manageNews');
    page_header();
    echo '<div id="news_div">';
    echo '<h1>' . _('News') . '</h1>';
    echo '<div id="news_list_div">';
    echo '<table border="0" cellspacing="1" cellpadding="3">';
    echo '<tr><th>' . _('Title') . '</th><th>' . _('Content') . '</th><th>' . _('Date') . '</th><th></th></tr>';
    foreach ($news as $new) {
        echo '<tr>';
        echo '<td><a href="news.php?action=manage&amp;id=' . $new->id . '">' . $new->title . '</a></td>';
        echo '<td>';
        if (strlen($new->content) > 32) {
            echo substr($new->content, 0, 32) . '...';
        } else {
            echo $new->content;
        }
        echo '</td>';
        echo '<td>' . date('r', $new->timestamp) . '</td>';
        if ($can_manage_news) {
            echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this news?') . '\');">';
            echo '<input type="hidden" name="name" value="News" />';
            echo '<input type="hidden" name="action" value="del" />';
            echo '<input type="hidden" name="id" value="' . $new->id . '" />';
            echo '<input type="submit" value="' . _('Delete this news') . '" />';
            echo '</form></td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    echo '</div>';
    echo '<br />';
    echo '<h2>' . _('Add news') . '</h2>';
    echo '<div>';
    echo '<table border="0" cellspacing="1" cellpadding="3">';
    if ($can_manage_news) {
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="News" />';
        echo '<input type="hidden" name="action" value="add" />';
        echo '<tr><td><strong>' . _('Title:') . '</strong></td><td><input type="text" name="news_title" value="" /></td></tr>';
        echo '<tr><td><strong>' . _('Content:') . '</strong></td><td><textarea name="news_content" cols="40" rows="4"></textarea></td></tr>';
        echo '<tr><td><strong>' . _('Date:') . '</strong></td><td>' . date('r') . '</td></tr>';
        echo '<tr><td colspan="2"><input type="submit" value="' . _('Add this news') . '" /></td></tr>';
        echo '</form>';
    }
    echo '</table>';
    echo '</div>';
    page_footer();
    die;
}
예제 #2
0
파일: news.php 프로젝트: bloveing/openulteo
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php';
$news = Abstract_News::load_all();
$dom = new DomDocument('1.0', 'utf-8');
$news_node = $dom->createElement('news');
foreach ($news as $new) {
    $new_node = $dom->createElement('new');
    $new_node->setAttribute('id', $new->getAttribute('id'));
    $new_node->setAttribute('title', $new->getAttribute('title'));
    $new_node->setAttribute('timestamp', (int) $new->getAttribute('timestamp'));
    $new_textnode = $dom->createTextNode($new->getAttribute('content'));
    $new_node->appendChild($new_textnode);
    $news_node->appendChild($new_node);
}
$dom->appendChild($news_node);
header('Content-Type: text/xml; charset=utf-8');
echo $dom->saveXML();
die;
예제 #3
0
파일: api.php 프로젝트: bloveing/openulteo
 public function news_list()
 {
     $this->check_authorized('manageNews');
     $news = Abstract_News::load_all();
     $ret = array();
     foreach ($news as $new) {
         $n = self::generate_news_array($new);
         $ret[$n['id']] = $n;
     }
     return $ret;
 }