toss Duck's news app into the hatchery so it's around somewhere other than the wiki
authorChuck Hagenbuch <chuck@horde.org>
Wed, 3 Dec 2008 15:34:28 +0000 (10:34 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Wed, 3 Dec 2008 15:34:28 +0000 (10:34 -0500)
101 files changed:
news/add.php [new file with mode: 0644]
news/admin/categories/delete.php [new file with mode: 0644]
news/admin/categories/edit.php [new file with mode: 0644]
news/admin/categories/index.php [new file with mode: 0644]
news/admin/sources/delete.php [new file with mode: 0644]
news/admin/sources/edit.php [new file with mode: 0644]
news/admin/sources/index.php [new file with mode: 0644]
news/admin/tabs.php [new file with mode: 0644]
news/browse.php [new file with mode: 0644]
news/cloud.php [new file with mode: 0644]
news/config/conf.xml [new file with mode: 0644]
news/config/prefs.php.dist [new file with mode: 0644]
news/content.php [new file with mode: 0644]
news/content_edit.php [new file with mode: 0644]
news/delete.php [new file with mode: 0644]
news/diff.php [new file with mode: 0644]
news/edit.php [new file with mode: 0644]
news/feed.php [new file with mode: 0644]
news/files.php [new file with mode: 0644]
news/index.php [new file with mode: 0644]
news/js/feed.js [new file with mode: 0644]
news/lib/Block/categories.php [new file with mode: 0755]
news/lib/Block/category.php [new file with mode: 0755]
news/lib/Block/jonah.php [new file with mode: 0755]
news/lib/Block/last.php [new file with mode: 0755]
news/lib/Block/last_blogs.php [new file with mode: 0755]
news/lib/Block/last_comments.php [new file with mode: 0755]
news/lib/Block/most_commented.php [new file with mode: 0755]
news/lib/Block/most_read.php [new file with mode: 0755]
news/lib/Block/my_comments.php [new file with mode: 0644]
news/lib/Block/sources.php [new file with mode: 0755]
news/lib/Block/tags_cloud.php [new file with mode: 0644]
news/lib/Categories.php [new file with mode: 0755]
news/lib/Forms/Search.php [new file with mode: 0644]
news/lib/News.php [new file with mode: 0755]
news/lib/TagCloud.php [new file with mode: 0644]
news/lib/View.php [new file with mode: 0755]
news/lib/api.php [new file with mode: 0755]
news/lib/base.php [new file with mode: 0755]
news/lib/version.php [new file with mode: 0755]
news/locale/sl_SI/LC_MESSAGES/news.mo [new file with mode: 0755]
news/mail.php [new file with mode: 0644]
news/news.php [new file with mode: 0644]
news/note.php [new file with mode: 0644]
news/pdf.php [new file with mode: 0644]
news/po/messages.mo [new file with mode: 0644]
news/po/news.pot [new file with mode: 0644]
news/po/sl_SI.po [new file with mode: 0644]
news/print.php [new file with mode: 0644]
news/reads.php [new file with mode: 0644]
news/rss/comments.php [new file with mode: 0644]
news/rss/index.php [new file with mode: 0644]
news/rss/news.php [new file with mode: 0755]
news/scripts/sql/news.mysql.sql [new file with mode: 0644]
news/scripts/upgrades/20070302_trackback.sql [new file with mode: 0644]
news/scripts/upgrades/20070609_sponsored.sql [new file with mode: 0644]
news/scripts/upgrades/20071220_tags.sql [new file with mode: 0644]
news/search.php [new file with mode: 0644]
news/tags.php [new file with mode: 0644]
news/templates/add/before.inc [new file with mode: 0755]
news/templates/block/news.php [new file with mode: 0644]
news/templates/block/titles.php [new file with mode: 0644]
news/templates/browse/footer.inc [new file with mode: 0755]
news/templates/browse/header.inc [new file with mode: 0755]
news/templates/browse/row.inc [new file with mode: 0755]
news/templates/categories/delete.html [new file with mode: 0755]
news/templates/categories/edit.html [new file with mode: 0755]
news/templates/categories/index.html [new file with mode: 0755]
news/templates/categories/index.php [new file with mode: 0644]
news/templates/common-header.inc [new file with mode: 0755]
news/templates/edit/footer.inc [new file with mode: 0755]
news/templates/edit/header.inc [new file with mode: 0755]
news/templates/edit/info.inc [new file with mode: 0755]
news/templates/edit/info.php [new file with mode: 0644]
news/templates/edit/row.php [new file with mode: 0644]
news/templates/menu.inc [new file with mode: 0755]
news/templates/news/attachments.php [new file with mode: 0644]
news/templates/news/blog.php [new file with mode: 0644]
news/templates/news/comments.php [new file with mode: 0644]
news/templates/news/gallery.php [new file with mode: 0644]
news/templates/news/info.php [new file with mode: 0644]
news/templates/news/mail.php [new file with mode: 0644]
news/templates/news/news.php [new file with mode: 0644]
news/templates/news/parents.php [new file with mode: 0644]
news/templates/news/selling.php [new file with mode: 0644]
news/templates/news/threads.php [new file with mode: 0644]
news/templates/news/today.php [new file with mode: 0644]
news/templates/news/tools.php [new file with mode: 0644]
news/templates/news/ulaform.php [new file with mode: 0644]
news/templates/print/footer.inc [new file with mode: 0755]
news/templates/print/header.inc [new file with mode: 0755]
news/templates/reads/footer.inc [new file with mode: 0755]
news/templates/reads/header.inc [new file with mode: 0755]
news/templates/reads/row.inc [new file with mode: 0755]
news/templates/sources/index.php [new file with mode: 0644]
news/themes/graphics/folder_open.png [new file with mode: 0755]
news/themes/graphics/mkdir.png [new file with mode: 0755]
news/themes/graphics/news.png [new file with mode: 0755]
news/themes/microfila/graphics/favicon.ico [new file with mode: 0755]
news/themes/screen.css [new file with mode: 0755]
news/trackback.php [new file with mode: 0644]

diff --git a/news/add.php b/news/add.php
new file mode 100644 (file)
index 0000000..73919ee
--- /dev/null
@@ -0,0 +1,492 @@
+<?php
+/**
+ * Add
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: add.php 750 2008-08-19 06:03:03Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+/**
+ * This routine removes all attributes from a given tag except
+ * the attributes specified in the array $attr.
+ * Author daneel@neezine.net 22-Aug-2005 05:08
+ * http://www.php.net/manual/en/function.strip-tags.php
+ *
+ * @param string    $msg   text to clean
+ * @param string    $tag   tag to clean
+ * @param string    $attr  attributest to leave
+ *
+ * @return string $msg cleaned text
+ */
+function stripeentag($msg, $tag, $attr = array())
+{
+    $lengthfirst = 0;
+    while (strstr(substr($msg, $lengthfirst), "<$tag ") != "")
+    {
+        $imgstart = $lengthfirst + strpos(substr($msg,$lengthfirst), "<$tag ");
+        $partafterwith = substr($msg, $imgstart);
+        $img = substr($partafterwith, 0, strpos($partafterwith, ">") + 1);
+        $img = str_replace(" =", "=", $msg);
+        $out = "<$tag";
+
+        for ($i=0; $i <= (count($attr) - 1); $i++) {
+            $long_val = strpos($img, " ", strpos($img, $attr[$i] . "=")) - (strpos($img, $attr[$i] . "=") + strlen($attr[$i]) + 1);
+            $val = substr($img, strpos($img, $attr[$i] . "=") + strlen($attr[$i]) + 1, $long_val);
+            if (strlen($val)>0) {
+                $attr[$i] = " ".$attr[$i]."=".$val;
+            } else {
+                $attr[$i] = "";
+            }
+            $out .= $attr[$i];
+        }
+
+        $out .= ">";
+        $partafter = substr($partafterwith, strpos($partafterwith, ">") + 1);
+        $msg = substr($msg, 0, $imgstart) . $out . $partafter;
+        $lengthfirst = $imgstart + 3;
+    }
+
+    return $msg;
+}
+
+// Is logged it?
+if (!Auth::isAuthenticated()) {
+    $notification->push(_("Only authenticated users can post news."), 'horde.warning');
+    Horde::authenticationFailureRedirect();
+}
+
+/* default vars */
+$title = _("Add news");
+$default_lang = News::getLang();
+$id = Util::getFormData('id', false);
+$return = Util::getFormData('return', false);
+
+/* prepare form */
+$vars = Variables::getDefaultVariables();
+$form = &new Horde_Form($vars, '', 'addnews');
+$form->_submit = _("Save");
+$form->addHidden('', 'return', 'text', false, true);
+
+
+// General
+$form->setSection('content', _("Content"), '', false);
+$form->addVariable(_("News content"), 'content', 'header', false);
+
+$v = &$form->addVariable(_("Publish"), 'publish', 'datetime', true, false, false, $news->datetimeParams());
+$v->setDefault(date('Y-m-d H:i:s'));
+$form->addVariable(_("Primary category"), 'category1', 'enum', true, false, false, array($news_cat->getEnum(), _("-- select --")));
+
+/* Sources */
+$sources = $GLOBALS['news']->getSources();
+if ($sources instanceof PEAR_Error) {
+    $notification->push($sources->getDebugInfo(), 'horde.error');
+} elseif (!empty($sources)) {
+    $form->addVariable(_("Source"), 'source', 'enum', false, false, false, array($sources, _("-- select --")));
+}
+$form->addVariable(_("Source link"), 'sourcelink', 'text', false, false);
+
+/* Picture */
+$form->addVariable(_("Picture"), 'picture', 'image', false, false, false, array('showUpload' => false));
+if ($id) {
+    $form->addVariable(_("Picture delete"), 'picture_delete', 'boolean', false, false, _("Delete existing picture"));
+}
+
+/* Languages */
+foreach ($conf['attributes']['languages'] as $key) {
+    $flag = (count($conf['attributes']['languages']) > 1) ? News::getFlag($key) . ' ' : '';
+    $form->addVariable($flag . _("Title"), "title_$key", 'text', ($key == $default_lang) ? true : false);
+    $form->addVariable($flag . _("Picture comment"), "picture_comment_$key", 'text', false);
+    if ($conf['attributes']['tags']) {
+        $form->addVariable($flag . _("Tags"), "tags_$key", 'text', false, false, _("Enter one or more keywords that describe your news. Separate them by spaces."));
+    }
+    $form->addVariable($flag . _("Content"), "content_$key", 'longtext', ($key == $default_lang) ? true : false , false, false, array(20, 120));
+    Horde_Editor::singleton('tinymce',
+        array('id' => "content_$key",
+              'config' => array('mode'=> 'exact',
+                                'elements' => "content_$key",
+                                'theme' => 'advanced',
+                                'plugins' => "xhtmlxtras,paste,media,fullscreen,wordfix",
+                                'extended_valid_elements' => "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],object,iframe[src|width|height|frameborder]",
+                                'paste_auto_cleanup_on_paste' => 'true',
+                                'paste_convert_headers_to_strong' => 'true',
+                                'theme_advanced_toolbar_location' => 'top',
+                                'theme_advanced_toolbar_align' => 'left',
+                                'theme_advanced_buttons1' => 'bold,italic,underline,fontsizeselect,separator,strikethrough,sub,sup,bullist,numlist,separator,link,unlink,image,separator,undo,redo,cleanup,code,hr,removeformat,wordfix,fullscreen',
+                                'theme_advanced_buttons2' => '',
+                                'theme_advanced_buttons3' => '',
+                                'theme_advanced_path_location' => 'bottom',
+                                'content_css' => '/include/tinymce/screen.css',
+                                //'cleanup_on_startup' => 'true',
+                                'button_tile_map' => 'true',
+                                'theme_advanced_buttons1_add' => 'media',
+                                'language' => 'en',
+                                'gecko_spellcheck' => 'true',
+                                'entity_encoding' => 'raw'
+    )));
+
+}
+
+// Additional
+$form->setSection('attributes', _("Attributes"), '', true);
+$form->addVariable(_("Additional news attributes"), 'attributes', 'header', false);
+$form->addVariable(_("Secondary category"), 'category2', 'enum', false, false, false, array($news_cat->getEnum(), _("-- select --")));
+$form->addVariable(_("Sort order"), 'sortorder', 'enum', false, false, false, array(range(0, 10)));
+$form->addVariable(_("Parents"), 'parents', 'intList', false, false, _("Enter news ids separated by commas."));
+
+if ($registry->hasMethod('forums/doComments')) {
+    $form->addVariable(sprintf(_("Threads in %s"), $registry->get('name', 'agora')), 'threads', 'intList', false, false, _("Enter threads separated by commas."));
+}
+
+/* Link to a gallery */
+if ($conf['attributes']['ansel-images'] 
+    && $registry->hasMethod('images/listGalleries')
+    && $registry->call('images/countGalleries', array()) > 0) {
+
+    if ($registry->call('images/countGalleries', array()) > 30) {
+        $form->addVariable(_("Gallery"), 'gallery', 'int', false);
+    } else {
+        $ansel_galleries = $registry->call('images/listGalleries', array());
+        $galleries = array();
+        foreach ($ansel_galleries as $gallery_id => $gallery) {
+            $galleries[$gallery_id] = $gallery['attribute_name'];
+        }
+        $form->addVariable(_("Gallery"), 'gallery', 'enum', false, false, false, array('enum' => $galleries, 'prompt' => true));
+    }
+}
+
+if (Auth::isAdmin('news:admin')) {
+
+    if ($conf['attributes']['sponsored']) {
+        $form->addVariable(_("Sponsored"), 'sponsored', 'boolean', false);
+    }
+
+    /* Allow commeting this content */
+    if ($conf['comments']['allow'] != 'never' && $registry->hasMethod('forums/doComments')) {
+        $form->addVariable(_("Disallow comments"), 'disable_comments', 'boolean', false, false);
+    }
+
+    /* Link to selling  */
+    $apis = array();
+    foreach ($registry->listAPIs() as $api) {
+        if ($registry->hasMethod($api . '/getSellingForm')) {
+            $apis[$api] = array();
+            $articles = $registry->call($api  . '/listCostObjects');
+            if ($articles instanceof PEAR_Error) {
+                $notification->push($articles->getMessage(), 'horde.error');
+            } elseif (!empty($articles)) {
+                foreach ($articles[0]['objects'] as $item) {
+                    $apis[$api][$item['id']] = $item['name'];
+                }
+            }
+        }
+    }
+
+    if (!empty($apis)) {
+        $v = &$form->addVariable(_("Selling item"), 'selling', 'mlenum', false, false, false, array($apis));
+    }
+
+    /* Show from */
+    $available = $GLOBALS['registry']->callByPackage('ulaform', 'getForms');
+    if (!($available instanceof PEAR_Error)) {
+        $forms = array();
+        foreach ($available as $f) {
+            $forms[$f['form_id']] = $f['form_name'];
+        }
+
+        $form->addVariable(_("Form ID"), 'form_id', 'enum', false, false, false, array($forms, true));
+        $form->addVariable(_("Form to"), 'form_ttl', 'datetime', false);
+    }
+}
+
+/* Files in gollem */
+if ($conf['attributes']['attachments'] && $registry->hasMethod('files/setSelectList')) {
+    $selectid = Util::getFormData('selectlist_selectid', $registry->call('files/setSelectList'));
+    $form->addVariable(_("Attachments"), 'attachments', 'selectfiles', false, false, false, array('link_text' => _("Select files"),
+                                                                                                  'link_style' => '',
+                                                                                                  'icon' => false,
+                                                                                                  'selectid' => $selectid));
+}
+
+/* Process form */
+if ($form->validate()) {
+
+    $status_inserted = false;
+    $allowed_cats = $news_cat->getAllowed(PERMS_DELETE);
+    $form->getInfo(null, $info);
+
+    // Check permissions
+    $info['status'] = News::UNCONFIRMED;
+    $info['editor'] = '';
+    $info['category1'] = (int)$info['category1'];
+    $info['category2'] = (int)@$info['category2'];
+
+    if (!empty($allowed_cats) &&
+        (in_array($info['category1'], $allowed_cats) || in_array($info['category2'], $allowed_cats))) {
+        $info['editor'] = Auth::getAuth();
+        $info['status'] = News::CONFIRMED;
+    }
+
+    /* Multi language */
+    $info['chars'] = strlen(preg_replace('/\s\s+/', '', trim(strip_tags($info["content_$default_lang"]))));
+
+    foreach ($conf['attributes']['languages'] as $key) {
+        if (!$info["title_$key"]) {
+            continue;
+        }
+        $info['body'][$key]['title'] = $info["title_$key"];
+        $info['body'][$key]['content'] = $info["content_$key"];
+        $info['body'][$key]['picture_comment'] = $info["picture_comment_$key"];
+        $info['body'][$key]['tags'] = $conf['attributes']['tags'] ? $info["tags_$key"] : '';
+        unset($info["title_$key"]);
+        unset($info["content_$key"]);
+        unset($info["picture_comment_$key"]);
+        unset($info["tags_$key"]);
+
+        if (strpos($info['body'][$key]['content'], '<') === FALSE) {
+            $info['body'][$key]['content'] = nl2br($info['body'][$key]['content']);
+        } else {
+            $info['body'][$key]['content'] = stripeentag($info['body'][$key]['content'], 'p', array());
+            $info['body'][$key]['content'] = stripeentag($info['body'][$key]['content'], 'font', array());
+        }
+        $info['chars'] = strlen(strip_tags( $info['body'][$key]['content']));
+    }
+
+    /* Selling */
+    if (empty($info['selling'][1])) {
+        $info['selling'] = '';
+    } else {
+        $info['selling'] = $info['selling'][1] . '|' . $info['selling'][2];
+    }
+
+    /* Clean up parents ID */
+    if ($info['parents']) {
+        $info['parents'] = explode(',', trim($info['parents']));
+        foreach ($info['parents'] as $i => $parent_id) {
+            if (intval($parent_id) == 0) {
+                unset($info['parents'][$i]);
+            }
+        }
+        $info['parents'] = implode(',', array_unique($info['parents']));
+    }
+
+    /* save as current version */
+    if (empty($id)) {
+
+        $query = 'INSERT INTO ' . $news->prefix
+               . ' (sortorder, status, publish, submitted, updated, user, editor, sourcelink, source,'
+               . ' sponsored, parents, category1, category2, chars, attachments, gallery, selling,'
+               . ' threads, form_id, form_ttl) '
+               . ' VALUES (?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+
+        $data = array($info['sortorder'],
+                      $info['status'],
+                      $info['publish'],
+                      Auth::getAuth(),
+                      $info['editor'],
+                      @$info['sourcelink'],
+                      isset($info['source']) ? $info['source'] : '',
+                      empty($info['sponsored']) ? 0 : 1,
+                      $info['parents'],
+                      $info['category1'],
+                      $info['category2'],
+                      $info['chars'],
+                      sizeof(@$info['attachments']),
+                      isset($galleries) ? $info['gallery'] : 0,
+                      $info['selling'],
+                      $info['threads'],
+                      empty($info['form_id']) ? 0 : (int)$info['form_id'],
+                      empty($info['form_ttl']) ? 0 : (int)$info['form_ttl']);
+        $status_inserted = true;
+    } else {
+
+        $query = 'UPDATE ' . $news->prefix . ' SET '
+                 . 'sortorder = ?, publish = ?, updated = NOW(), editor=?, sourcelink = ?, source = ?, '
+                 . 'sponsored = ?, parents = ?, category1 = ?, category2 = ?, '
+                 . 'chars = ?, attachments = ?, gallery = ?, selling = ?, threads = ?, '
+                 . 'form_id = ?, form_ttl = ? WHERE id = ?';
+
+        $data = array($info['sortorder'],
+                      $info['publish'],
+                      $info['editor'],
+                      @$info['sourcelink'],
+                      isset($info['source']) ? $info['source'] : '',
+                      empty($info['sponsored']) ? 0 : 1,
+                      $info['parents'],
+                      $info['category1'],
+                      $info['category2'],
+                      $info['chars'],
+                      sizeof(@$info['attachments']),
+                      isset($galleries) ? $info['gallery'] : 0,
+                      $info['selling'],
+                      $info['threads'],
+                      empty($info['form_id']) ? 0 : (int)$info['form_id'],
+                      empty($info['form_ttl']) ? 0 : (int)$info['form_ttl'],
+                      $id);
+    }
+
+    $result = $news->writedb->query($query, $data);
+    if ($result instanceof PEAR_Error) {
+        $notification->push($result->getDebugInfo(), 'horde.error');
+        header('Location: ' . Horde::applicationUrl('edit.php'));
+        exit;
+    }
+
+    if (!$id) {
+        $id = $news->writedb->getOne('SELECT LAST_INSERT_ID()');
+    }
+
+    /* picture */
+    if (isset($info['picture_delete']) && $info['picture_delete']) {
+        $news->writedb->query('UPDATE ' . $news->prefix . ' SET picture = ? WHERE id = ?', array(0, $id));
+    } elseif (getimagesize(@$info['picture']['file']) !== FALSE) {
+        News::saveImage($id, $info['picture']['file']);
+        
+        $news->writedb->query('UPDATE  ' . $news->prefix . '  SET picture = ? WHERE id = ?', array(1, $id));
+    }
+
+    /* comments */
+    if (isset($info['disable_comments']) && $info['disable_comments']) {
+        $news->writedb->query('UPDATE  ' . $news->prefix . '  SET comments = ? WHERE id = ?', array(-1, $id));
+    }
+
+    /* bodies */ 
+    $news->writedb->query('DELETE FROM ' . $news->prefix . '_body WHERE id=?', array($id));
+    $news->writedb->query('DELETE FROM ' . $news->prefix . '_attachment WHERE id=?', array($id));
+
+    $attachments = array();
+    if (isset($info['attachments'])) {
+        foreach ($info['attachments'] as $file) {
+            $attachments[] =  Util::realPath(key($file) . '/' . current($file));
+        }
+    }
+
+    $query_attach = $news->writedb->prepare('INSERT INTO ' . $news->prefix . '_attachment (id, lang, filename, filesize) VALUES (?, ?, ?, ?)');
+    $query_body   = $news->writedb->prepare('INSERT INTO ' . $news->prefix . '_body '
+                                            . '(id, lang, title, abbreviation, content, picture_comment, tags) VALUES (?, ?, ?, ?, ?, ?, ?)');
+
+    foreach ($info['body'] as $lang => $values) {
+        $abbr = String::substr(strip_tags($values['content']), 0, $conf['preview']['list_content']);
+        $news->writedb->execute($query_body, array($id, $lang, $values['title'], $abbr, $values['content'], $values['picture_comment'], $values['tags']));
+        if (isset($info['attachments'])) {
+            for ($i = 0; $i < sizeof($info['attachments']); $i++) {
+                $f = $conf['attributes']['attachments'] . $attachments[$i];
+                $size = filesize($f);
+                if ($size) {
+                    $news->writedb->execute($query_attach, array($id, $lang, $attachments[$i], $size));
+                } else {
+                    $notification->push(sprintf(_("Cannot access file %s"), $f), 'horde.warning');
+                }
+            }
+        }
+    }
+
+    /* save as future version */
+    if ($status_inserted === true) {
+        $status_version = 'insert';
+    } else {
+        $status_version = 'update';
+    }
+    $version = $news->db->getOne('SELECT MAX(version) FROM ' . $news->prefix . '_versions WHERE id = ?', array($id));
+    $result  = $news->writedb->query('INSERT INTO ' . $news->prefix . '_versions (id, version, action, created, user_uid, content) VALUES (?,?,?,NOW(),?,?)',
+                                array($id, $version + 1, $status_version, Auth::getAuth(), serialize($info['body'])));
+    if ($result instanceof PEAR_Error) {
+        $notification->push($result->getMessage(), 'horde.error');
+    }
+
+    /* Expire newscache */
+    foreach ($conf['attributes']['languages'] as $key) {
+            $cache->expire('news_'  . $key . '_' . $id);
+    }
+
+    /* return */
+    if ($return) {
+        $url = $return;
+    } elseif (in_array($info['category1'], $allowed_cats) ||
+              in_array($info['category2'], $allowed_cats)) {
+        $url = Util::addParameter(Horde::applicationUrl('edit.php'), 'id', $id);
+    } else {
+        $url = Horde::applicationUrl('browse.php');
+    }
+
+    if ($info['status'] != News::CONFIRMED && $status_inserted == true) {
+        $notification->push(_("News added. The editors will check the entry and confirm it if they find it suitable."), 'horde.success');
+    } elseif ($info['status'] == News::CONFIRMED && $status_inserted == true) {
+        $notification->push(_("News published."), 'horde.success');
+    } elseif ($status_inserted == false) {
+        $notification->push(_("News updated."), 'horde.success');
+    }
+
+    header('Location: ' . $url);
+    exit;
+
+} elseif ($id && !$form->isSubmitted()) {
+
+    $title = _("Edit news");
+    $sql = 'SELECT * FROM ' . $news->prefix . ' WHERE id = ?';
+    $result = $news->db->getRow($sql, array($id), DB_FETCHMODE_ASSOC);
+
+    foreach ($result as $key => $value) {
+        if ($key == 'picture') {
+            continue;
+        } elseif ($key == 'comments' && $value == -1) {
+            $key = 'disable_comments';
+            $value = true;
+        } elseif ($key == 'selling') {
+            if (empty($value)) {
+                continue;
+            } else {
+                $value = explode('|', $value);
+                $vars->set('selling', array(1 => $value[0], 2 => $value[1]));
+                continue;
+            }
+        } 
+
+        $vars->set($key, $value);
+    }
+
+    $sql = 'SELECT lang, title, content, picture_comment, tags FROM ' . $news->prefix . '_body WHERE id = ?';
+    $result = $news->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC);
+    foreach ($result as $row) {
+        $vars->set('title_' . $row['lang'], $row['title']);
+        $vars->set('content_' . $row['lang'], $row['content']);
+        $vars->set('picture_comment_' . $row['lang'], $row['picture_comment']);
+        if ($conf['attributes']['tags']) {
+            $vars->set('tags_' . $row['lang'], $row['tags']);
+        }
+    }
+
+    if ($conf['attributes']['attachments'] && $registry->hasMethod('files/setSelectList')) {
+        $sql = 'SELECT lang, filename FROM ' . $news->prefix . '_attachment WHERE id = ?';
+        $result = $news->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC);
+        $files = array();
+        if (sizeof($result)>0) {
+            foreach ($result as $row) {
+                $files[] = array(dirname($row['filename']) => basename($row['filename']));
+            }
+        }
+
+        $registry->call('files/setSelectList', array($selectid, $files));
+    }
+
+    $form->_submit = _("Update");
+    $form->_reset = _("Reset");
+}
+
+/* display */
+require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/menu.inc';
+require_once NEWS_TEMPLATES . '/add/before.inc';
+
+$form->renderActive(null, null, Util::addParameter(Horde::applicationUrl('add.php'), 'id', $id, false), 'post');
+
+require_once $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/categories/delete.php b/news/admin/categories/delete.php
new file mode 100644 (file)
index 0000000..2a1a30a
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * The News script to delete a category.
+ *
+ * Copyright 2007 - 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: delete.php 183 2008-01-06 17:39:50Z duck $
+ */
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require NEWS_BASE . '/admin/tabs.php';
+
+$vars = Variables::getDefaultVariables();
+$form = new Horde_Form($vars, _("Do you really wont to delete this category?"), 'delete');
+$form->setButtons(array(_("Remove"), _("Cancel")));
+
+$category_id = Util::getFormData('category_id');
+$form->addHidden('', 'category_id', 'int', $category_id);
+
+if ($form->validate()) {
+    if (Util::getFormData('submitbutton') == _("Remove")) {
+        $news_cat->deleteCategory($category_id);
+        if ($result instanceof PEAR_Error) {
+            $notification->push(_("Category was not deleted.") . ' ' . $result->getMessage(), 'horde.error');
+        } else {
+            $notification->push(_("Category deleted."), 'horde.success');
+        }
+    } else {
+        $notification->push(_("Category was not deleted."), 'horde.warning');
+    }
+    header('Location: ' . Horde::applicationUrl('admin/categories/index.php'));
+    exit;
+}
+
+require NEWS_BASE . '/templates/common-header.inc';
+require NEWS_BASE . '/templates/menu.inc';
+echo $tabs->render('categories');
+$form->renderActive(null, null, null, 'post');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/categories/edit.php b/news/admin/categories/edit.php
new file mode 100644 (file)
index 0000000..41f1476
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * The News script to edit categories.
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: edit.php 238 2008-01-16 15:28:51Z duck $
+ */
+
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require NEWS_BASE . '/admin/tabs.php';
+
+$category_id = Util::getFormData('category_id');
+$title = !empty($category_id) ? _("Edit category") : _("Add category");
+$vars = Variables::getDefaultVariables();
+$form = new Horde_Form($vars, $title, 'editcategory');
+
+if ($category_id && !$form->isSubmitted()) {
+    $category = $news_cat->getCatArray($category_id);
+    $vars->merge($category);
+}
+
+$form->addHidden('', 'category_id', 'int', $category_id);
+
+foreach ($GLOBALS['conf']['attributes']['languages'] as $lang) {
+    $flag = (count($conf['attributes']['languages']) > 1) ? News::getFlag($lang) . ' ' : '';
+    $form->addVariable($flag . _("Name"), 'category_name_' . $lang, 'text', true);
+    $form->addVariable($flag . _("Description"), 'category_description_' . $lang, 'text', false);
+}
+
+$form->addVariable(_("Parent"), 'category_parentid', 'radio', false, false, null, array($news_cat->getCategories(), true));
+$v = &$form->addVariable(_("Resize Image"), 'image_resize', 'boolean', false);
+$v->setDefault(true);
+$form->addVariable(_("Image"), 'image', 'image', false);
+
+if ($form->validate()) {
+    $form->getInfo(null, $info);
+    $result = $news_cat->saveCategory($info);
+    if ($result instanceof PEAR_Error) {
+        $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
+    } else {
+        $notification->push(sprintf(_("Category succesfully saved.")));
+        $url = Horde::applicationUrl('admin/categories/index.php', true);
+        header('Location: ' . $url);
+        exit;
+    }
+}
+
+require NEWS_BASE . '/templates/common-header.inc';
+require NEWS_BASE . '/templates/menu.inc';
+echo $tabs->render('cetegories');
+$form->renderActive(null, null, null, 'post');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/categories/index.php b/news/admin/categories/index.php
new file mode 100644 (file)
index 0000000..fa65fa5
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * The News script to navigate categories.
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: index.php 183 2008-01-06 17:39:50Z duck $
+ */
+
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require NEWS_BASE . '/admin/tabs.php';
+
+// Get category list
+$categories = $news_cat->getCategories(false);
+if ($categories instanceof PEAR_Error) {
+    $notification->push($categories->getMessage(), 'horde.error');
+    $categories = array();
+}
+
+/* Set up the template fields. */
+$title = _("Category Administration");
+$edit_url = Horde::applicationUrl('admin/categories/edit.php');
+$edit_img = Horde::img('edit.png', _("Edit"), '', $registry->getImageDir('horde'));
+$delete_url = Horde::applicationUrl('admin/categories/delete.php');
+$delete_img = Horde::img('delete.png', _("Delete"), '', $registry->getImageDir('horde'));
+
+foreach ($categories as $category_id => $category) {
+    $categories[$category_id]['actions'][] = Horde::link(Util::addParameter($delete_url, 'category_id', $category_id), _("Delete")) .
+                                    $delete_img . '</a>';
+    $categories[$category_id]['actions'][] = Horde::link(Util::addParameter($edit_url, 'category_id', $category_id), _("Edit")) .
+                                     $edit_img . '</a>';
+}
+
+$view = new News_View();
+$view->categories = $categories;
+$view->add_url = Horde::link($edit_url, _("Add New")) . _("Add New") . '</a>';
+
+Horde::addScriptFile('tables.js', 'horde', true);
+require NEWS_BASE . '/templates/common-header.inc';
+require NEWS_BASE . '/templates/menu.inc';
+echo $tabs->render('cetegories');
+echo $view->render('/categories/index.php');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/sources/delete.php b/news/admin/sources/delete.php
new file mode 100644 (file)
index 0000000..59f940c
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * The News script to delete a source.
+ *
+ * Copyright 2007 - 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: delete.php 183 2008-01-06 17:39:50Z duck $
+ */
+
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require '../tabs.php';
+
+$vars = Variables::getDefaultVariables();
+$form = new Horde_Form($vars, _("Do you really wont to delete this source?"), 'delete');
+$form->setButtons(array(_("Remove"), _("Cancel")));
+
+$source_id = Util::getFormData('source_id');
+$form->addHidden('', 'source_id', 'int', $source_id);
+
+if ($form->validate()) {
+    if (Util::getFormData('submitbutton') == _("Remove")) {
+        $news->deleteSource($source_id);
+        if ($result instanceof PEAR_Error) {
+            $notification->push(_("Source was not deleted.") . ' ' . $result->getMessage(), 'horde.error');
+        } else {
+            $notification->push(_("Source deleted."), 'horde.success');
+        }
+    } else {
+        $notification->push(_("Source was not deleted."), 'horde.warning');
+    }
+    header('Location: ' . Horde::applicationUrl('admin/sources/index.php'));
+    exit;
+}
+
+require NEWS_BASE . '/templates/common-header.inc';
+require NEWS_BASE . '/templates/menu.inc';
+echo $tabs->render('sources');
+$form->renderActive(null, null, null, 'post');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/sources/edit.php b/news/admin/sources/edit.php
new file mode 100644 (file)
index 0000000..5d54270
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * The News script to edit sources.
+ *
+ * Copyright 2007 - 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: edit.php 183 2008-01-06 17:39:50Z duck $
+ */
+
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require '../tabs.php';
+
+$vars = Variables::getDefaultVariables();
+$source_id = $vars->get('source_id');
+$title = !empty($source_id) ? _("Edit Source") : _("Add Source");
+
+$form = new Horde_Form($vars, $title, 'editsource');
+if ($source_id && !$form->isSubmitted()) {
+    $sources = $news->getSources(true);
+    foreach ($sources[$source_id] as $key => $val) {
+        if ($key != 'source_image') {
+            $vars->set($key, $val);
+        }
+    }
+}
+
+$form->addHidden('', 'source_id', 'int', $source_id);
+$form->addVariable(_("Name"), 'source_name', 'text', true);
+$form->addVariable(_("Url"), 'source_url', 'text', true);
+
+$v = &$form->addVariable(_("Resize Image"), 'source_image_resize', 'boolean', false);
+$v->setDefault(true);
+$form->addVariable(_("Image"), 'source_image', 'image', false);
+
+if ($form->validate()) {
+    $form->getInfo(null, $info);
+    $result = $news->saveSource($info);
+    if ($result instanceof PEAR_Error) {
+        $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
+    } else {
+        $notification->push(_("Source saved succesfully."));
+        header('Location: ' . Horde::applicationUrl('admin/sources/index.php'));
+        exit;
+    }
+}
+
+require NEWS_TEMPLATES . '/common-header.inc';
+require NEWS_TEMPLATES . '/menu.inc';
+echo $tabs->render('sources');
+$form->renderActive(null, null, null, 'post');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/sources/index.php b/news/admin/sources/index.php
new file mode 100644 (file)
index 0000000..0da38e9
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/**
+ * The News script to navigate source options.
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: index.php 183 2008-01-06 17:39:50Z duck $
+ */
+
+define('NEWS_BASE', dirname(__FILE__) . '/../..');
+require_once NEWS_BASE . '/lib/base.php';
+require '../tabs.php';
+
+$title = _("Sources Administration");
+$sources = $news->getSources(true);
+if ($sources instanceof PEAR_Error) {
+    $notification->push($sources->getDebugInfo(), 'horde.error');
+    $sources = array();
+}
+
+$edit_url = Horde::applicationUrl('admin/sources/edit.php');
+$edit_img = Horde::img('edit.png', _("Edit"), '', $registry->getImageDir('horde'));
+$delete_url = Horde::applicationUrl('admin/sources/delete.php');
+$delete_img = Horde::img('delete.png', _("Delete"), '', $registry->getImageDir('horde'));
+$view_url = Horde::applicationUrl('browse.php');
+$view_img = Horde::img('category.png', _("View items"), '', $registry->getImageDir('horde'));
+
+foreach ($sources as $source_id => $source) {
+    $sources[$source_id]['actions'][] = Horde::link(Util::addParameter($view_url, 'source_id', $source_id), _("View articles")) .
+                                        $view_img . '</a>';
+    $sources[$source_id]['actions'][] = Horde::link(Util::addParameter($delete_url, 'source_id', $source_id), _("Delete")) .
+                                        $delete_img . '</a>';
+    $sources[$source_id]['actions'][] = Horde::link(Util::addParameter($edit_url, 'source_id', $source_id), _("Edit")) .
+                                        $edit_img . '</a>';
+}
+
+$view = new News_View();
+$view->sources = $sources;
+$view->add_url = Horde::link($edit_url, _("Add New")) . _("Add New") . '</a>';
+
+Horde::addScriptFile('tables.js', 'horde', true);
+require NEWS_BASE . '/templates/common-header.inc';
+require NEWS_BASE . '/templates/menu.inc';
+echo $tabs->render('sources');
+echo $view->render('/sources/index.php');
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/admin/tabs.php b/news/admin/tabs.php
new file mode 100644 (file)
index 0000000..398ed05
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/**
+ * $Id: tabs.php 22 2007-12-13 11:10:52Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ */
+
+/* Only admin should be using this. */
+if (!Auth::isAdmin('news:admin')) {
+    $notification->push(_("You are not authorised for this action."), 'horde.warning');
+    Horde::authenticationFailureRedirect();
+}
+
+require_once 'Horde/Variables.php';
+require_once 'Horde/UI/Tabs.php';
+require_once 'Horde/Form.php';
+
+$vars = Variables::getDefaultVariables();
+$tabs = new Horde_UI_Tabs('admin', $vars);
+
+$tabs->addTab(_("Sources"), Horde::applicationUrl('admin/sources/index.php'), 'sources');
+$tabs->addTab(_("Categories"), Horde::applicationUrl('admin/categories/index.php'), 'categories');
diff --git a/news/browse.php b/news/browse.php
new file mode 100644 (file)
index 0000000..e36d3cb
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Browse
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: browse.php 210 2008-01-10 12:41:43Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+require_once NEWS_BASE . '/lib/Forms/Search.php';
+
+// Default vars
+$title = _("Browse");
+$page = Util::getGet('news_page', 0);
+$per_page = $prefs->getValue('per_page');
+$news_url = Horde::applicationUrl('news.php');
+$browse_url = Horde::applicationUrl('browse.php');
+$cid = Util::getGet('cid');
+
+// Define creteria
+if (!empty($_GET)) {
+    $criteria = $_GET;
+    $browse_url = Util::addParameter($browse_url, $_GET);
+} else {
+    $criteria = array();
+}
+
+// Count rows
+$count = $news->countNews($criteria);
+if ($count instanceof PEAR_Error) {
+    echo $count->getMessage() . ': ' . $count->getDebugInfo();
+    exit;
+}
+
+
+$rows = $news->listNews($criteria, $page*$per_page, $per_page);
+if ($rows instanceof PEAR_Error) {
+    echo $rows->getMessage() . ': ' . $rows->getDebugInfo();
+    exit;
+}
+
+// If we have only one row redirect ot it
+if ($count == 1 && sizeof($cats) < 2 && $page < 1) {
+    header('Location: '. Util::addParameter($news_url, 'id', $rows[0]['id'], false));
+    exit;
+}
+
+// Get pager
+$pager = News_Search::getPager(array(), $count, $browse_url);
+
+require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/menu.inc';
+
+$browse_template_path = News::getTemplatePath($cid, 'browse');
+require_once $browse_template_path . 'header.inc';
+foreach ($rows as $row) {
+    require $browse_template_path . 'row.inc';
+}
+require_once $browse_template_path . '/footer.inc';
+
+require_once $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/cloud.php b/news/cloud.php
new file mode 100644 (file)
index 0000000..1062699
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+* $Id: index.php 31 2007-12-13 14:33:33Z duck $
+*
+* Copyright Obala d.o.o. (www.obala.si)
+*
+* See the enclosed file COPYING for license information (GPL). If you
+* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+*
+* @author Duck <duck@obala.net>
+* @package Folks
+*/
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$cloud = $news->getCloud();
+if ($cloud instanceof PEAR_Error) {
+    $notification->push($cloud->getMessage(), 'horde.error');
+    $cloud = '';
+}
+
+require NEWS_TEMPLATES . '/common-header.inc';
+require NEWS_TEMPLATES . '/menu.inc';
+
+echo $cloud;
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/config/conf.xml b/news/config/conf.xml
new file mode 100644 (file)
index 0000000..9f4934f
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<!-- $Horde: news/config/conf.xml,v 1.2 2004/01/20 18:17:25 jan Exp $ -->
+<configuration>
+
+<configtab name="storage" desc="Storage Settings">
+    <configsection name="storage" desc="Storage Settings">
+    <configdescription>
+        These are the settings for storing all the News data, such as categories,
+        items within those categories, item options, etc.
+    </configdescription>
+    <configswitch name="driver" desc="What storage driver should we use?">sql
+        <case name="sql" desc="SQL">
+        <configsection name="params">
+            <configsql switchname="driverconfig"/>
+            <configsection name="categories">
+              <configstring name="table"  desc="Categories table">horde_datatree</configstring>
+              <configstring name="table_attributes" desc="Categories attributes table">horde_datatree_attributes</configstring>
+      </configsection>
+        </configsection>
+        </case>
+    </configswitch>
+    </configsection>
+</configtab>
+
+<configtab name="news" desc="Content settings">
+
+    <configsection name="preview">
+        <configheader>Settings for displaying</configheader>
+        <configinteger name="list_content" desc="Lenght of abbrevation">130</configinteger>
+    </configsection>
+
+    <configsection name="attributes">
+        <configheader>Enable optional news attributes</configheader>
+        <configboolean name="ansel-images" desc="Link to Ansel galleries">TRUE</configboolean>
+        <configstring name="ansel-url" desc="Ansel images url">TRUE</configstring>
+        <configboolean name="tags" desc="Use tags">false</configboolean>
+        <configstring name="attachments" desc="Attachments dir"></configstring>
+        <configmultienum name="languages" desc="Select all languages that should be activated">
+            <values>
+                <configspecial name="list-horde-languages" />
+            </values>
+        </configmultienum>
+    </configsection>
+
+    <configsection name="images">
+      <configheader>Images settigns</configheader>
+      <configboolean name="ansel-images" desc="Link items to Ansel Galleries.">true</configboolean> 
+      <configvfs switchname="type">horde
+        <case name="sql">
+          <configstring name="table" desc="Table to use">horde_vfs</configstring>
+        </case>
+      </configvfs>
+      <configstring name="direct" desc="If should images be viewed directly out of
+                    the VFS, specify the alias pointing to the right place on your filesystem
+                    defined in your webserver. Example: /schedul-images">/schedul-images</configstring>
+      <configenum name="image_type" desc="What format should images be generated in? Make 
+                  sure that your server supports whichever format you choose!">png
+        <values>
+          <value desc="JPEG">jpeg</value>
+          <value desc="PNG">png</value>
+        </values>
+        </configenum>
+        <configstring name="thumbnail_width" desc="Thumbnail width">150</configstring>
+        <configstring name="thumbnail_height" desc="Thumbnail height">150</configstring>
+        <configstring name="image_width" desc="Image width">300</configstring>
+        <configstring name="image_height" desc="Image height">300</configstring>
+    </configsection>
+
+    <configsection name="comments">
+    <configheader>Comments</configheader>
+    <configenum name="allow" desc="Can users comment news?">authenticated
+        <values>
+        <value desc="Authenticated users">authenticated</value>
+        <value desc="No one">never</value>
+        <value desc="All">all</value>
+        </values>
+    </configenum>
+    <configstring name="comment_template" desc="Template file to use for render comments." required="false"></configstring>
+    </configsection>
+
+</configtab>
+
+<configtab name="trackback" desc="Trackback">
+    <configsection name="trackback">
+    <configheader>Trackback Settings</configheader>
+    <configinteger name="strictness" desc="Strictness">1</configinteger>
+    <configinteger name="timeout" desc="The default timeout for network operations in seconds">30</configinteger>
+    <configinteger name="fetchlines" desc="The maximum number of lines to fetch over the network">30</configinteger>
+    <configmultienum name="spamcheck" desc="Select spam filters to use">
+        <values>
+        <value desc="Searches a given trackback for word matches using wordlist">Wordlist</value>
+        <value desc="Searches a given trackback for word matches using regex">Regex</value>
+        <value desc="Utilize DNS blacklists for detection of hosts used for spamming">DNSBL</value>
+        <value desc="Utilizes SUR blacklists for detection of URLs used in spam">SURBL</value>
+        </values>
+    </configmultienum>
+    </configsection>
+</configtab>
+
+<configtab name="menu" desc="Menu">
+    <configsection name="menu">
+        <configheader>Menu Settings</configheader>
+        <configmultienum name="apps" desc="Select any applications that should be linked in news menu">
+        <values>
+            <configspecial name="list-horde-apps" />
+        </values>
+        </configmultienum>
+    </configsection>
+</configtab>
+
+</configuration>
+
+
diff --git a/news/config/prefs.php.dist b/news/config/prefs.php.dist
new file mode 100644 (file)
index 0000000..50177dd
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * $Horde: news/config/prefs.php.dist,v 1.3 2003/12/03 20:09:14 chuck Exp $
+ *
+ * See horde/config/prefs.php for documentation on the structure of this file.
+ */
+
+$prefGroups['Preview'] = array(
+    'column' => _("Preview"),
+    'label' => _("How to preview news"),
+    'desc' => _("Set news previerw paramaters"),
+    'members' => array('per_page', 'sort_by', 'sort_dir')
+);
+
+$_prefs['per_page'] = array(
+    'value' => 20,
+    'locked' => false,
+    'shared' => true,
+    'type' => 'number',
+    'desc' => _("How many news to show per page")
+);
+
+$_prefs['sort_by'] = array(
+    'value' => 'n.publish',
+    'locked' => false,
+    'shared' => true,
+    'type' => 'enum',
+    'enum' => array('n.publish' => _("Publish date"),
+                    'n.id' => _("Id"),
+                    'nl.title' => _("Title")),
+    'desc' => _("Sort news by")
+);
+
+$_prefs['sort_dir'] = array(
+    'value' => 'DESC',
+    'locked' => false,
+    'shared' => true,
+    'type' => 'enum',
+    'enum' => array('DESC' => _("Descesending"),
+                    'ASC' => _("Ascesending")),
+    'desc' => _("Sort news by")
+);
+
+// the layout of the news portal.
+$_prefs['news_layout'] = array(
+    'value' => 'a:0:{}',
+    'locked' => false,
+    'shared' => false,
+    'type' => 'implicit'
+);
+
diff --git a/news/content.php b/news/content.php
new file mode 100644 (file)
index 0000000..bbe1ee1
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * $Id: content.php 479 2008-03-30 17:07:34Z duck $
+ *
+ * Copyright 2007 The Horde Project(http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information(GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ */
+
+require_once dirname(__FILE__) . '/lib/base.php';
+
+// Default layout.
+$layout = new Horde_Block_Layout_View(
+    unserialize($prefs->getValue('news_layout')),
+    Horde::applicationUrl('content_edit.php'));
+$layout_html = $layout->toHtml();
+
+$title = $registry->get('name');
+require NEWS_TEMPLATES . '/common-header.inc';
+require NEWS_TEMPLATES . '/menu.inc';
+echo '<div id="menuBottom"><a href="' . Horde::applicationUrl('content_edit.php') . '">' . _("Add Content") . '</a></div><div class="clear">&nbsp;</div>';
+echo $layout_html;
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/content_edit.php b/news/content_edit.php
new file mode 100644 (file)
index 0000000..6dd244b
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * $Id: content_edit.php 229 2008-01-12 19:47:30Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/thomas/LICENSE.
+ *
+ * @author Duck <duck@obala.net>
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+// Instantiate the blocks objects.
+$blocks = &Horde_Block_Collection::singleton('news_layout', array('news'));
+$layout = &Horde_Block_Layout_Manager::singleton('news_layout', $blocks, unserialize($prefs->getValue('news_layout')));
+
+// Handle requested actions.
+$layout->handle(Util::getFormData('action'),
+                (int)Util::getFormData('row'),
+                (int)Util::getFormData('col'));
+if ($layout->updated()) {
+    $prefs->setValue('news_layout', $layout->serialize());
+}
+
+$title = sprintf(_("%s :: Add Content"), $registry->get('name'));
+require NEWS_TEMPLATES . '/common-header.inc';
+require NEWS_TEMPLATES . '/menu.inc';
+$notification->notify(array('listeners' => 'status'));
+require $registry->get('templates', 'horde') . '/portal/edit.inc';
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/delete.php b/news/delete.php
new file mode 100644 (file)
index 0000000..ada3de8
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Delete an news
+ *
+ * $Id: delete.php 229 2008-01-12 19:47:30Z duck $
+ *
+ * NEWS: Copyright 2007 Duck <duck@obala.net>
+ *
+ * @author  Duck <duck@obala.net>
+ * @package NEWS
+*/
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+if (!Auth::isAdmin('news:admin')) {
+    $notification->push(_("Only admin can delete a news."));
+    header('Location: ' . Horde::applicationUrl('edit.php'));
+    exit;
+};
+
+require_once 'Horde/Form.php';
+require_once 'Horde/Variables.php';
+
+$vars = Variables::getDefaultVariables();
+$form = new Horde_Form($vars, _("Are you sure you want to delete this news?"), 'delete');
+$form->setButtons(array(_("Remove"), _("Cancel")));
+
+$id = (int)Util::getFormData('id');
+$form->addHidden('', 'id', 'int', $id);
+
+if ($form->validate()) {
+
+    if (Util::getFormData('submitbutton') == _("Remove")) {
+
+        $news->writedb->query('DELETE FROM ' . $news->prefix . ' WHERE id=?', array($id));
+        $news->writedb->query('DELETE FROM ' . $news->prefix . '_version WHERE id=?', array($id));
+        $news->writedb->query('DELETE FROM ' . $news->prefix . '_body WHERE id=?', array($id));
+        $news->writedb->query('DELETE FROM ' . $news->prefix . '_user_reads WHERE id=?', array($id));
+
+        // Delete attachment
+        $sql = 'SELECT filename FROM ' . $news->prefix . '_attachment WHERE id = ?';
+        $files = $news->db->getCol($sql, 0, array($id));
+        foreach ($files as $file) {
+            unlink($conf['attributes']['attachments'] . $file);
+        }
+        $news->writedb->query('DELETE FROM ' . $news->prefix . '_attachment WHERE id=?', array($id));
+        // Delete forum
+        if ($registry->hasMethod('forums/deleteForum')) {
+            $comments = $registry->call('forums/deleteForum', array('news', $id));
+            if ($comments instanceof PEAR_Error) {
+                $notification->push($comments->getMessage(), 'horde.error');
+            }
+        }
+
+        $notification->push(sprintf(_("News %s: %s"), $id, _("deleted")), 'horde.success');
+    } else {
+        $notification->push(sprintf(_("News %s: %s"), $id, _("not deleted")), 'horde.warning');
+    }
+    header('Location: ' . Horde::applicationUrl('edit.php'));
+    exit;
+}
+
+require NEWS_TEMPLATES . '/common-header.inc';
+require NEWS_TEMPLATES . '/menu.inc';
+
+$form->renderActive(null, null, null, 'post');
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/diff.php b/news/diff.php
new file mode 100644 (file)
index 0000000..233aa10
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Diff
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: diff.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$title = _("Diff");
+$id = Util::getFormData('id', 0);
+$version = Util::getFormData('version', 0);
+
+/* Set up the diff renderer. */
+$render_type = Util::getFormData('render', 'inline');
+$class = 'Text_Diff_Renderer_' . $render_type;
+$renderer = &new $class();
+
+/* get current version content */
+$current_data = array();
+$result = $news->db->getAll('SELECT lang, title, content FROM ' . $news->prefix . '_body WHERE id = ?', array($id), DB_FETCHMODE_ASSOC);
+if ($result instanceof PEAR_Error) {
+    var_dump($result);
+    exit;
+}
+
+foreach ($result as $row) {
+    $current_data[$row['lang']]['title'] = $row['title'];
+    $current_data[$row['lang']]['content'] = $row['content'];
+}
+
+/* get version data */
+$version_data = $news->db->getOne('SELECT content FROM ' . $news->prefix . '_versions WHERE id = ? AND version = ?', array($id, $version));
+if ($version_data instanceof PEAR_Error) {
+    var_dump($version_data);
+    exit;
+}
+
+$version_data = unserialize($version_data);
+
+echo Horde::stylesheetLink('news');
+
+while (list($k, $v) = each($current_data)) {
+    echo '<hr><strong>' . $nls['languages'][$k] . '</strong><hr>' . "\n";
+    $to = explode("\n", @htmlentities(strip_tags($v['content'])));
+    $from = explode("\n", @htmlentities(strip_tags($version_data[$k]['content'])));
+    $diff = &new Text_Diff($from, $to);
+    if (!empty($diff)) {
+       echo nl2br($renderer->render($diff));
+    } else {
+       return _("No change.");
+    }
+}
diff --git a/news/edit.php b/news/edit.php
new file mode 100644 (file)
index 0000000..db45118
--- /dev/null
@@ -0,0 +1,183 @@
+<?php
+/**
+ * Edit browsing
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: edit.php 372 2008-02-29 12:05:00Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+/* application include */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+require_once NEWS_BASE . '/lib/Forms/Search.php';
+
+/* redirect if not an admin */
+$allowed_cats = $news_cat->getAllowed(PERMS_DELETE);
+if (empty($allowed_cats)) {
+    $notification->push(_("You have not editor permission on any category."));
+    header('Location: ' . Horde::applicationUrl('add.php'));
+    exit;
+}
+
+$id = Util::getFormData('id', 0);
+$page = Util::getFormData('page', 0);
+$browse_url = Horde::applicationUrl('edit.php');
+$news_url = Horde::applicationUrl('news.php');
+$edit_url = Horde::applicationUrl('add.php');
+$read_url = Horde::applicationUrl('reads.php');
+$has_comments = $registry->hasMethod('forums/doComments');
+$actionID = Util::getFormData('actionID');
+
+if (!empty($actionID) && $id > 0) {
+    /* save as future version */
+    $version = $news->db->getOne('SELECT MAX(version) FROM ' . $news->prefix . '_versions WHERE id=?', array($id));
+    $result  = $news->writedb->query('INSERT INTO ' . $news->prefix . '_versions (id, version, action, created, user_uid) VALUES (?,?,?,NOW(),?)',
+                                array($id, $version  + 1, $actionID, Auth::getAuth()));
+}
+
+switch ($actionID) {
+case 'delete_attachments';
+
+    $news->writedb->query('DELETE FROM ' . $news->prefix . '_attachment WHERE id = ?', array($id));
+    $news->writedb->query('UPDATE ' . $news->prefix . ' SET attachments = ? WHERE id = ?', array(0, $id));
+
+    $notification->push(sprintf(_("News %s: %s"), $id, _("Attachment deleted")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+case 'deactivate';
+
+    $news->writedb->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id));
+    $notification->push(sprintf(_("News %s: %s"), $id, _("deactivated")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+case 'activate';
+
+    $news->writedb->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::CONFIRMED, $id));
+    $notification->push(sprintf(_("News %s: %s"), $id, _("activated")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+case 'lock';
+
+    $news->writedb->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::LOCKED, $id));
+    $notification->push(sprintf(_("News %s: %s"), $id, _("locked")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+case 'unlock';
+
+    $news->writedb->query('UPDATE ' . $news->prefix . ' SET status = ? WHERE id = ?', array(News::UNCONFIRMED, $id));
+    $notification->push(sprintf(_("News %s: %s"), $id, _("unlocked")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+case 'renew';
+
+    $version = Util::getFormData('version');
+
+    $version_data = $news->db->getRow('SELECT content FROM ' . $news->prefix . '_versions WHERE id = ? AND version = ?',
+                                      array($id, $version), DB_FETCHMODE_ASSOC);
+
+    $version_data['content'] = unserialize($version_data['content']);
+    $news->writedb->query('DELETE FROM ' . $news->prefix . '_body WHERE id = ?', array($id));
+
+    $new_version = array();
+    $sql = 'INSERT INTO ' . $news->prefix . '_body (id,lang,title,abbreviation,content) VALUES (?,?,?,?,?)';
+
+    foreach ($version_data['content'] as $lang => $values) {
+        $new_version[$lang] = $values;
+        $data = array($id,
+                      $lang,
+                      $values['title'],
+                      substr(strip_tags($values['content']), 0, $conf['preview']['list_content']),
+                      $values['content']);
+        $news->writedb->query($sql, $data);
+    }
+
+    /* save as future version */
+    $version = $news->db->getOne('SELECT MAX(version) FROM ' . $news->prefix . '_versions WHERE id = ?', array($id)) + 1;
+    $result  = $news->writedb->query('INSERT INTO ' . $news->prefix . '_versions (id, version, created, user_uid, content) VALUES (?,?,NOW(),?,?)',
+                                array($id, $version, Auth::getAuth(), serialize($new_version)));
+
+    $notification->push(sprintf(_("News %s: %s"), $id, _("renewed")), 'horde.success');
+    header('Location: ' . $browse_url);
+    exit;
+
+break;
+}
+
+$title = _("Edit");
+$vars = Variables::getDefaultVariables();
+$form = new News_Search($vars);
+$form->getInfo(null, $info);
+
+/* prepare query */
+$binds = $news->buildQuery(PERMS_DELETE, $info);
+$sql = 'SELECT n.id, n.sortorder, n.category1, n.category2, n.source, n.status, n.editor, n.publish, ' .
+       'n.user, n.comments, n.unpublish, n.picture, n.chars, n.view_count, n.attachments, l.title, n.selling '
+       . $binds[0];
+
+if (!isset($info['sort_by'])) {
+    $info['sort_by'] = 'n.publish';
+}
+if (!isset($info['sort_dir'])) {
+    $info['sort_dir'] = 'DESC';
+}
+
+$sql .= ' ORDER BY ' . $info['sort_by'] . ' ' . $info['sort_dir'];
+
+// Count rows
+$count = $news->countNews($info, PERMS_DELETE);
+if ($count instanceof PEAR_Error) {
+    echo $count->getMessage() . ': ' . $count->getDebugInfo();
+    exit;
+}
+
+// Select rows
+$page = Util::getGet('news_page', 0);
+$per_page = $prefs->getValue('per_page');
+$sql = $news->db->modifyLimitQuery($sql, $page*$per_page, $per_page);
+$rows = $news->db->getAll($sql, $binds[1], DB_FETCHMODE_ASSOC);
+if ($rows instanceof PEAR_Error) {
+    echo $rows->getMessage() . ': ' . $rows->getDebugInfo();
+    exit;
+}
+
+// Get pager
+$pager = News_Search::getPager($binds[1], $count, $browse_url);
+
+/* Output */
+Horde::addScriptFile('tables.js', 'horde', true);
+Horde::addScriptFile('popup.js', 'horde', true);
+
+require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/menu.inc';
+require_once NEWS_TEMPLATES . '/edit/header.inc';
+
+$img_dir = $registry->getImageDir('horde');
+foreach ($rows as $row) {
+    require NEWS_TEMPLATES . '/edit/row.php';
+    if ($row['id'] == $id ) {
+        require NEWS_TEMPLATES . '/edit/info.php';
+    }
+}
+
+require NEWS_TEMPLATES . '/edit/footer.inc';
+
+$form->renderActive(null, null, null, 'post');
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/feed.php b/news/feed.php
new file mode 100644 (file)
index 0000000..e454ff9
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Show feed
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: feed.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+function _getStories($feed_id)
+{
+    $stories = $GLOBALS['cache']->get('news_feed_' . $feed_id, $GLOBALS['conf']['cache']['default_lifetime']);
+    if (!$stories) {
+        $stories = $GLOBALS['registry']->call('news/stories', array($feed_id));
+        $GLOBALS['cache']->set('news_feed_' . $feed_id, serialize($stories));
+        return $stories;
+    } else {
+        return unserialize($stories); 
+    }
+}
+
+$feed_id = Util::getPost('feed_id');
+$stories = _getStories($feed_id);
+$df = $GLOBALS['prefs']->getValue('date_format');
+foreach ($stories as $story) {
+    echo strftime($df, $story['story_published'])
+        . ' <a href="' . $story['story_url'] . '" target="_blank" title="' . strip_tags($story['story_desc']) . '">' . $story['story_title'] . '</a><br />';
+}
diff --git a/news/files.php b/news/files.php
new file mode 100644 (file)
index 0000000..314e9fa
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/**
+* Download and veiew files
+*
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: files.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+/* application include */
+$no_compress = true;
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$id = Util::getFormData('id', false);
+$actionID = Util::getFormData('actionID');
+$filedir = Util::getFormData('dir');
+$filename = Util::getFormData('file');
+$type = substr($filename, strpos($filename, '.'));
+
+/* Run through action handlers. */
+switch ($actionID) {
+case 'download_file':
+
+    $browser->downloadHeaders($filename);
+    readfile($conf['attributes']['attachments'] . $filedir . '/' . $filename);
+    break;
+
+case 'view_file':
+
+    require_once 'Horde/MIME/Part.php';
+    require_once 'Horde/MIME/Viewer.php';
+    require_once 'Horde/MIME/Magic.php';
+    require_once 'Horde/MIME/Contents.php';
+
+    $data = file_get_contents($conf['attributes']['attachments'] . $filedir . '/' . $filename);
+    $mime = &new MIME_Part(MIME_Magic::extToMIME($type), $data);
+    $mime->setName($filename);
+    $contents = &new MIME_Contents($mime);
+    $body = $contents->renderMIMEPart($mime);
+    $type = $contents->getMIMEViewerType($mime);
+    $browser->downloadHeaders($mime->getName(true, true), $type, true, strlen($body));
+    echo $body;
+
+break;
+
+case 'download_zip':
+
+    if ($id) {
+        $filename = sprintf(_("FilesOfNews-%s"), $id);
+        $zipfiles = array();
+        foreach ($news->getFiles($id) as $file_data) {
+            $zipfiles[] = array('data' => file_get_contents($conf['attributes']['attachments'] . $file_data['filename']),
+                                'name' => basename($file_data['filename']));
+        }
+    } else {
+        $zipfiles = array('data' => file_get_contents($conf['attributes']['attachments'] . $filedir . '/' . $filename),
+                            'name' => $filename);
+    }
+
+    $zip = Horde_Compress::singleton('zip');
+    $body = $zip->compress($zipfiles);
+    $browser->downloadHeaders($filename . '.zip', 'application/zip', false, strlen($body));
+    echo $body;
+
+break;
+}
+
diff --git a/news/index.php b/news/index.php
new file mode 100644 (file)
index 0000000..8a3a7fa
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: index.php 308 2008-01-31 13:20:46Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+$news_configured = (is_readable(NEWS_BASE . '/config/conf.php') &&
+                    is_readable(NEWS_BASE . '/config/prefs.php'));
+
+if (!$news_configured) {
+    define('HORDE_LIBS', '');
+    require NEWS_BASE . '/../lib/Test.php';
+    Horde_Test::configFilesMissing('news', NEWS_BASE,
+                                   array('conf.php', 'prefs.php', 'sources.php'));
+}
+
+require NEWS_BASE . '/content.php';
diff --git a/news/js/feed.js b/news/js/feed.js
new file mode 100644 (file)
index 0000000..a3a786b
--- /dev/null
@@ -0,0 +1,24 @@
+
+function getFeed() {
+    RedBox.loading();
+    new Ajax.Updater('feed_content',
+                    document.feed_select.action,
+                    {
+                        onComplete: function(){ RedBox.close();},
+                        parameters: { feed_id: $F('feed_id') },
+                        onFailure: function(){ RedBox.close(); alert('Error'); },
+                        asynchronous: true
+                    });
+}
+
+function send_news_mail() {
+    RedBox.loading();
+    new Ajax.Updater('mail_send',
+                    document.mail_send.action,
+                    {
+                        onComplete: function(){ RedBox.close();},
+                        onFailure: function(){ RedBox.close(); alert('Error'); },
+                        asynchronous: true,
+                        parameters: { fee: $F('email') }
+                    });
+}
\ No newline at end of file
diff --git a/news/lib/Block/categories.php b/news/lib/Block/categories.php
new file mode 100755 (executable)
index 0000000..64e8876
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+$block_name = _("Categories");
+
+/**
+ * $Id: categories.php 22 2007-12-13 11:10:52Z duck $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_News_categories extends Horde_Block {
+
+    var $_app = 'news';
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        return _("Categories");
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+        return $GLOBALS['news_cat']->getHtml();
+    }
+
+}
diff --git a/news/lib/Block/category.php b/news/lib/Block/category.php
new file mode 100755 (executable)
index 0000000..3300367
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+
+$block_name = _("Last news in category");
+
+/**
+ * $Id: category.php 201 2008-01-09 08:38:05Z duck $
+ *
+ * @package Horde_Block
+*/
+
+class Horde_Block_News_category extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _title()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $url = Util::addParameter(Horde::applicationUrl('browse.php'), 'category', $this->_params['category']);
+        $name = $GLOBALS['news_cat']->getName($this->_params['category']);
+        $html = Horde::link($url, sprintf(_("Last news in %s"), $name), 'header');
+        $html .= sprintf(_("Last news in %s"), $name) . '</a>';
+
+        return $html;
+    }
+
+    function _params()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        return array('limit'    => array('type' => 'int',
+                                         'name' => _("How many news to display?"),
+                                         'default' => 10),
+                     'category' => array('type' => 'enum',
+                                         'name' => _("Category"),
+                                         'values' => $GLOBALS['news_cat']->getEnum()));
+    }
+
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $query = 'SELECT n.id, n.publish, n.comments, n.picture, n.category1, nl.title, nl.abbreviation ' .
+                 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
+                 'n.status = ? AND n.publish <= NOW() ' .
+                 'AND (n.category1 = ? OR n.category2 = ?) ' .
+                 'AND nl.lang = ? AND n.id = nl.id ' .
+                 'ORDER BY n.publish DESC ' .
+                 'LIMIT 0, ' . $this->_params['limit'];
+
+        $params = array(News::CONFIRMED, $this->_params['category'], $this->_params['category'], NLS::select());
+        $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
+        if ($rows instanceof PEAR_Error) {
+            return $rows->getDebugInfo();
+        }
+
+        $view = new News_View();
+        $view->news = $rows;
+        $view->news_url = Horde::applicationUrl('news.php');
+        $view->moreurl = Util::addParameter(Horde::applicationUrl('browse.php'), 'category', $this->_params['category']);
+
+        return $view->render('/block/news.php');
+    }
+
+}
diff --git a/news/lib/Block/jonah.php b/news/lib/Block/jonah.php
new file mode 100755 (executable)
index 0000000..6e74ae9
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+if ($GLOBALS['registry']->hasInterface('news')) {
+    $block_name = _("Press overview");
+}
+
+/**
+ * $Id: jonah.php 201 2008-01-09 08:38:05Z duck $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_News_jonah extends Horde_Block {
+
+    var $_app = 'news';
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        $url = $GLOBALS['registry']->get('webroot', 'jonah') . '/';
+        return Horde::link($url, _("Press overview")) . _("Press overview") . '</a>';
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        $html = '<div id="feed_content" name="feed_content">';
+        $html .= _("Select a feed.");
+        $html .= '</div>';
+
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $sql = 'SELECT channel_id, channel_name '
+             . ' FROM jonah_channels WHERE channel_type = 1 ORDER BY channel_name';
+        $chanels = $GLOBALS['news']->db->getAll($sql);
+
+        $html .= '<form action="' . Horde::applicationUrl('feed.php') . '" id="feed_select" name="feed_select">'
+              . '<select id="feed_id" name="feed_id" onchange="getFeed()">'
+              . '<option>- - - - - - - </option>';
+        foreach ($chanels as $chanel) {
+            $html .= '<option value="'  . $chanel[0] . '">'  . $chanel[1] . '</option>';
+        }
+        $html .= '</select></form>';
+
+        Horde::addScriptFile('prototype.js', 'horde', true);
+        Horde::addScriptFile('effects.js', 'horde', true);
+        Horde::addScriptFile('redbox.js', 'horde', true);
+        Horde::addScriptFile('feed.js', 'news', true);
+
+        return $html;
+    }
+
+}
diff --git a/news/lib/Block/last.php b/news/lib/Block/last.php
new file mode 100755 (executable)
index 0000000..1b96aa1
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+$block_name = _("Last news");
+
+/**
+ * $Id: last.php 201 2008-01-09 08:38:05Z duck $
+ *
+ * @package Horde_Block
+*/
+
+class Horde_Block_News_last extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _title()
+    {
+        return Horde::link(Horde::applicationUrl('browse.php'), _("Last news"), 'header') . _("Last news") . '</a>';
+    }
+
+    function _params()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        return array('limit'    => array('type' => 'int',
+                                         'name' => _("How many news to display?"),
+                                         'default' => 10),
+                     'category' => array('type' => 'enum',
+                                         'name' => _("Skip category"),
+                                         'values' => $GLOBALS['news_cat']->getEnum()));
+    }
+
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $params = array(News::CONFIRMED, NLS::select());
+        $query = 'SELECT n.id, n.publish, n.comments, n.picture, n.category1, nl.title, nl.abbreviation ' .
+                 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
+                 'n.status = ? AND n.publish <= NOW() ' .
+                 'AND nl.lang = ? AND n.id = nl.id ';
+
+        if (!empty($this->_params['category'])) {
+            $query .= ' AND n.category1 <> ? ';
+            $params[] = (int)$this->_params['category'];
+        }
+
+        $query .= 'ORDER BY n.publish DESC ' .
+                 'LIMIT 0, ' . $this->_params['limit'];
+
+        $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
+        if ($rows instanceof PEAR_Error) {
+            return $rows->getDebugInfo();
+        }
+
+        $view = new News_View();
+        $view->news = $rows;
+        $view->news_url = Horde::applicationUrl('news.php');
+        $view->moreurl = Horde::applicationUrl('browse.php');
+
+        return $view->render('/block/news.php');
+    }
+
+}
diff --git a/news/lib/Block/last_blogs.php b/news/lib/Block/last_blogs.php
new file mode 100755 (executable)
index 0000000..2f52f58
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+$block_name = _("Last news blogged");
+
+/**
+ * $Horde: news/lib/Block/category.php,v 1.40 2004/06/01 14:46:58 chuck Exp $
+ *
+ * @package Horde_Block
+*/
+
+class Horde_Block_News_last_blogs extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _title()
+    {
+        return _("Last news blog");
+    }
+
+    function _params()
+    {
+        return array('limit' => array('type' => 'int',
+                                      'name' => _("How many news to display?"),
+                                      'default' => 10));
+    }
+
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $query = 'SELECT n.id, n.publish, n.comments, n.picture, n.category1, nl.title, nl.abbreviation ' .
+                 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
+                 'n.status = ? AND n.publish <= NOW() AND n.trackbacks > ? ' .
+                 'AND nl.lang = ? AND n.id = nl.id ' .
+                 'ORDER BY n.publish DESC ' .
+                 'LIMIT 0, ' . $this->_params['limit'];
+
+        $params = array(News::CONFIRMED, 0, NLS::select());
+        $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
+        if ($rows instanceof PEAR_Error) {
+            return $rows->getDebugInfo();
+        }
+
+        $view = new News_View();
+        $view->news = $rows;
+        $view->news_url = Horde::applicationUrl('news.php');
+
+        return $view->render('/block/news.php');
+    }
+
+}
diff --git a/news/lib/Block/last_comments.php b/news/lib/Block/last_comments.php
new file mode 100755 (executable)
index 0000000..4027655
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+$block_name = _("Last comments");
+
+/**
+ * thomas_Minisearch_Block:: Implementation of the Horde_Block API to
+ * allows searching of addressbooks from the portal.
+ *
+ * $Id: last_comments.php 22 2007-12-13 11:10:52Z duck $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_news_last_comments extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _params()
+    {
+        return array('limit' => array('name' => _("Number of comments to display"),
+                                      'type' => 'int',
+                                      'default' => 10));
+    }
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        return _("Last comments");
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../News.php';
+
+        $comments = News::getLastComments($this->_params['limit']);
+        if ($comments instanceof PEAR_Error) {
+            return $comments->getMessage();
+        }
+
+        $html = '';
+        foreach ($comments as $message) {
+            $html .= '- '
+                  . Horde::link($message['read_url']) . $message['message_subject'] . '</a> '
+                  . ' (' . $message['message_author'] . ') <br />';
+        }
+        return $html;
+    }
+
+}
diff --git a/news/lib/Block/most_commented.php b/news/lib/Block/most_commented.php
new file mode 100755 (executable)
index 0000000..a4bfed1
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+$block_name = _("Last most commented news");
+
+/**
+ * $Id: most_commented.php 201 2008-01-09 08:38:05Z duck $
+ *
+ * @package Horde_Block
+*/
+
+class Horde_Block_News_most_commented extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _title()
+    {
+        return _("Last most commented news");
+    }
+
+    function _params()
+    {
+        return array('limit' => array('type' => 'int',
+                                      'name' => _("How many news to display?"),
+                                      'default' => 10),
+                     'days' => array('type' => 'int',
+                                      'name' => _("How many days back to check?"),
+                                      'default' => 30));
+    }
+
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $query = 'SELECT n.id, n.publish, n.comments, n.picture, n.category1, nl.title, nl.abbreviation ' .
+                 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
+                 'n.status = ? AND n.publish <= NOW()  AND n.publish > ?' .
+                 'AND nl.lang = ? AND n.id = nl.id ' .
+                 'ORDER BY n.comments DESC ' .
+                 'LIMIT 0, ' . $this->_params['limit'];
+
+        $younger = $_SERVER['REQUEST_TIME'] - $this->_params['days'] * 86400;
+        $params = array(News::CONFIRMED, date('Y-m-d', $younger), NLS::select());
+        $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
+        if ($rows instanceof PEAR_Error) {
+            return $rows->getDebugInfo();
+        }
+
+        $view = new News_View();
+        $view->news = $rows;
+        $view->news_url = Horde::applicationUrl('news.php');
+
+        return $view->render('/block/titles.php');
+    }
+
+}
diff --git a/news/lib/Block/most_read.php b/news/lib/Block/most_read.php
new file mode 100755 (executable)
index 0000000..aff21f3
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+$block_name = _("Last most read news");
+
+/**
+ * $Id: most_read.php 201 2008-01-09 08:38:05Z duck $
+ *
+ * @package Horde_Block
+*/
+
+class Horde_Block_News_most_read extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _title()
+    {
+        return _("Last most read news");
+    }
+
+    function _params()
+    {
+        return array('limit' => array('type' => 'int',
+                                      'name' => _("How many news to display?"),
+                                      'default' => 10),
+                     'days' => array('type' => 'int',
+                                      'name' => _("How many days back to check?"),
+                                      'default' => 30));
+    }
+
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        $query = 'SELECT n.id, n.publish, n.comments, n.picture, nl.title, nl.abbreviation ' .
+                 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
+                 'n.status = ? AND n.publish <= NOW() AND n.publish > ?' .
+                 'AND nl.lang = ? AND n.id = nl.id ' .
+                 'ORDER BY n.view_count DESC ' .
+                 'LIMIT 0, ' . $this->_params['limit'];
+
+        $younger = $_SERVER['REQUEST_TIME'] - $this->_params['days'] * 86400;
+        $params = array(News::CONFIRMED, date('Y-m-d', $younger), NLS::select());
+        $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
+        if ($rows instanceof PEAR_Error) {
+            return $rows->getDebugInfo();
+        }
+
+        $view = new News_View();
+        $view->news = $rows;
+        $view->news_url = Horde::applicationUrl('news.php');
+
+        return $view->render('/block/titles.php');
+    }
+
+}
diff --git a/news/lib/Block/my_comments.php b/news/lib/Block/my_comments.php
new file mode 100644 (file)
index 0000000..61aeaca
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+$block_name = _("Last comments on my news");
+
+/**
+ * Horde_Block_news_my_comments:: Implementation of the Horde_Block API to
+ * display last comments on users videos.
+ *
+ * $Horde: incubator/news/lib/Block/my_comments.php,v 1.1 2008/03/27 11:02:57 duck Exp $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_news_my_comments extends Horde_Block {
+
+    var $_app = 'news';
+
+    function _params()
+    {
+        return array('limit' => array('name' => _("Number of comments to display"),
+                                      'type' => 'int',
+                                      'default' => 10));
+    }
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        return ("Last comments on my news");
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        if (!Auth::isAuthenticated()) {
+            return '';
+        }
+
+        $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
+                                           Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+
+        $cache_key = 'news_myscommetns_' . $this->_params['limit'];
+        $threads = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
+        if ($threads) {
+            return $threads;
+        }
+
+        Horde::addScriptFile('tables.js', 'horde', true);
+        $html = '<table class="sortable striped" id="my_comment_list" style="width: 100%">'
+              . '<thead><tr><th>' . _("Title") . '</th>'
+              . '<th>' . _("User") . '</th></tr></thead>';
+
+        $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
+                                    array(Auth::getAuth(), 'message_timestamp', 1, false,
+                                            'news', 0, $this->_params['limit']));
+        if ($threads instanceof PEAR_Error) {
+            return $threads->getMessage();
+        }
+
+        $url = Util::addParameter(Horde::applicationUrl('news.php'), 'id', null);
+        foreach ($threads as $message) {
+            $html .= '<tr><td>'
+                  . '<a href="' . $url  . $message['forum_name'] . '" title="' . $message['message_date'] . '">'
+                  . $message['message_subject'] . '</a> '
+                  . '</td><td>'
+                  . $message['message_author'] . '</td></tr>';
+        }
+        $html .= '</table>';
+
+        $GLOBALS['cache']->set($cache_key, $html);
+        return $html;
+    }
+
+}
diff --git a/news/lib/Block/sources.php b/news/lib/Block/sources.php
new file mode 100755 (executable)
index 0000000..9316990
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+$block_name = _("Sources");
+
+/**
+ * $Id: sources.php 22 2007-12-13 11:10:52Z duck $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_News_sources extends Horde_Block {
+
+    var $_app = 'news';
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        return _("Sources");
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+        $sources = $GLOBALS['news']->getSources();
+
+        $html = '';
+        $url = Horde::applicationUrl('browse.php');
+        foreach ($sources as $source_id => $source_name) {
+            $html .= '- ' 
+                  . Horde::link(Util::addparameter($url, 'source_id', $source_id), '', '', '_blank')
+                  . $source_name . '</a><br />';
+        }
+
+        return $html;
+    }
+
+}
diff --git a/news/lib/Block/tags_cloud.php b/news/lib/Block/tags_cloud.php
new file mode 100644 (file)
index 0000000..0a66943
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+$block_name = _("Tags");
+
+/**
+ * oscar_tags_cloud:: Implementation of the Horde_Block API to show a tag
+ * cloud.
+ *
+ * $Id: tags_cloud.php 78 2007-12-19 22:44:56Z jan $
+ *
+ * @package Horde_Block
+ */
+class Horde_Block_news_tags_cloud extends Horde_Block {
+
+    var $_app = 'news';
+
+    /**
+     * The title to go in this block.
+     *
+     * @return string   The title text.
+     */
+    function _title()
+    {
+        return _("Tags");
+    }
+
+    /**
+     * The content to go in this block.
+     *
+     * @return string   The content
+     */
+    function _content()
+    {
+        require_once dirname(__FILE__) . '/../base.php';
+
+        return $GLOBALS['news']->getCloud(true);
+    }
+
+}
diff --git a/news/lib/Categories.php b/news/lib/Categories.php
new file mode 100755 (executable)
index 0000000..e2136e3
--- /dev/null
@@ -0,0 +1,599 @@
+<?php
+/**
+ * News Tree Class.
+ *
+ * $Id: Categories.php 268 2008-01-22 10:15:10Z mclion $
+ *
+ * Copyright 2007-2008 Obala d.o.o. (http://www.obala.si/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Duck <duck@obala.net>
+ * @package News
+ */
+class News_Categories {
+
+    /**
+     * Hash containing connection parameters.
+     *
+     * @var array
+     */
+    private $_params = array();
+
+    /**
+     * Handle for the current database connection.
+     *
+     * @var DB
+     */
+    private $_db;
+
+    /**
+     * Handle for the current database connection, used for writing. Defaults
+     * to the same handle as $db if a separate write database is not required.
+     *
+     * @var DB
+     */
+    private $_write_db;
+
+    /**
+     * An array containing all the tree nodes.
+     *
+     * @var array
+     */
+    private $_nodes = array();
+
+    /**
+     * The top-level nodes in the tree.
+     *
+     * @var array
+     */
+    private $_root_nodes = array();
+
+    /**
+     * An enumeratic array
+     *
+     * @var array
+     */
+    private $_enum = array();
+
+    /**
+     * Has for view url link
+     *
+     * @var array
+     */
+    private $_view_url;
+
+    /**
+     * Handle for the tables prefix.
+     *
+     * @var prefix
+     */
+    private $prefix = 'news';
+
+    /**
+     * Contruct the News object
+     */
+    public function __construct($categoreis = null)
+    {
+        $this->_nodes = $this->getCategories(false);
+        if ($this->_nodes instanceof PEAR_Error) {
+            return $this->_nodes;
+        }
+
+        foreach ($this->_nodes as $id => $category) {
+            if (empty($category['category_parentid'])) {
+                if (!in_array($id, $this->_root_nodes)) {
+                    $this->_root_nodes[] = $id;
+                }
+            } else {
+                if (empty($this->_nodes[$category['category_parentid']]['children'])) {
+                    $this->_nodes[$category['category_parentid']]['children'] = array();
+                }
+                if (!in_array($id, $this->_nodes[$category['category_parentid']]['children'])) {
+                    $this->_nodes[$category['category_parentid']]['children'][] = $id;
+                }
+            }
+        }
+        $this->_buildIndents($this->_root_nodes);
+    }
+
+    /**
+     * Returns the string for category selection
+     *
+     * @return string
+     */
+    public function getSelect()
+    {
+        $output = '';
+        foreach ($this->_root_nodes as $node_id) {
+            $output .= $this->_buildSelect($node_id);
+        }
+
+        return $output;
+    }
+
+    /**
+    *
+    */
+    private function _buildSelect($node_id)
+    {
+        $output = '<option value="' . $node_id . '">'
+                . str_repeat(' - ', $this->_nodes[$node_id]['indent'])
+                . $this->_nodes[$node_id]['category_name'] . '</option>';
+
+        if (isset($this->_nodes[$node_id]['children'])) {
+            $num_subnodes = count($this->_nodes[$node_id]['children']);
+            for ($c = 0; $c < $num_subnodes; $c++) {
+                $child_node_id = $this->_nodes[$node_id]['children'][$c];
+                $output .= $this->_buildSelect($child_node_id);
+            }
+        }
+
+        return $output;
+    }
+
+    /**
+     * Returns the enumeratic array for select form pameter.
+     *
+     * @return array  The category array (cat => name)
+     */
+    public function getEnum()
+    {
+        if (empty($this->_enum)) {
+            foreach ($this->_root_nodes as $node_id) {
+                $this->_buildEnum($node_id);
+            }
+        }
+
+        return $this->_enum;
+    }
+
+    private function _buildEnum($node_id)
+    {
+        $this->_enum[$node_id] = str_repeat(' - ', $this->_nodes[$node_id]['indent'])
+                                . $this->_nodes[$node_id]['category_name'];
+
+        if (isset($this->_nodes[$node_id]['children'])) {
+            $num_subnodes = count($this->_nodes[$node_id]['children']);
+            for ($c = 0; $c < $num_subnodes; $c++) {
+                $child_node_id = $this->_nodes[$node_id]['children'][$c];
+                $this->_buildEnum($child_node_id);
+            }
+        }
+    }
+
+    /**
+     * Returns html for category selection
+     *
+     * @return string
+     */
+    public function getHtml()
+    {
+        $this->_view_url = Horde::applicationUrl('browse.php');
+
+        $output = '';
+        foreach ($this->_root_nodes as $node_id) {
+            $output .= $this->_buildHtml($node_id);
+        }
+
+        return $output;
+    }
+
+    private function _buildHtml($node_id)
+    {
+        $output = '';
+        if ($this->_nodes[$node_id]['indent'] == 0) {
+            $output .= '<strong>';
+        }
+        $url = Util::addParameter($this->_view_url, 'cid', $node_id);
+        $output .= Horde::link($url) . $this->_nodes[$node_id]['category_name'] . '</a>, ';
+        if ($this->_nodes[$node_id]['indent'] == 0) {
+            $output .= '</strong><br />';
+        }
+
+        if (isset($this->_nodes[$node_id]['children'])) {
+            $num_subnodes = count($this->_nodes[$node_id]['children']);
+            for ($c = 0; $c < $num_subnodes; $c++) {
+                $child_node_id = $this->_nodes[$node_id]['children'][$c];
+                $output .= $this->_buildHtml($child_node_id);
+            }
+        }
+
+        return $output;
+    }
+
+    /**
+     * Set the indent level for each node in the tree.
+     */
+    private function _buildIndents($nodes, $indent = 0)
+    {
+        foreach ($nodes as $id) {
+            $this->_nodes[$id]['indent'] = $indent;
+            if (!empty($this->_nodes[$id]['children'])) {
+                $this->_buildIndents($this->_nodes[$id]['children'], $indent + 1);
+            }
+        }
+    }
+
+    /**
+     * Returns array of cateogriy children id
+     *
+     * @return array
+     */
+    public function getChildren($id)
+    {
+        if (!empty($this->_nodes[$id]['children'])) {
+            return $this->_nodes[$id]['children'];
+        } else {
+            return array();
+        }
+    }
+
+    /**
+     * Returns the current language
+     *
+     * @return string  The current language.
+     */
+    public function getAllowed($perm = PERMS_SHOW)
+    {
+        $cats = $this->getCategories();
+        if (Auth::isAdmin('news:admin') ||
+            $GLOBALS['perms']->hasPermission('news', Auth::getAuth(), $perm)) {
+            return $cats;
+        }
+
+        foreach ($cats as $key => $value) {
+            // user has access?
+            if (!$GLOBALS['perms']->hasPermission('news:categories', Auth::getAuth(), $perm)  && // master
+                !$GLOBALS['perms']->hasPermission('news:categories:' . $key, Auth::getAuth(), $perm) && // child
+                !$GLOBALS['perms']->hasPermission('news:categories:' . $this->_nodes[$key]['category_parentid'], Auth::getAuth(), $perm) // father
+                ) {
+                unset($cats[$key]);
+            }
+        }
+
+        return $cats;
+    }
+
+    /**
+     * Returns the name for category
+     *
+     * @return string
+     */
+    public function getName($id)
+    {
+        $cats = $this->getCategories();
+        return $cats[$id];
+    }
+
+    /**
+     * Returns the full name of a category
+     *
+     * @return string
+     */
+    public function getFullName($id)
+    {
+        static $names;
+
+        if (isset($names[$id])) {
+            return $names[$id];
+        } elseif (empty($id)) {
+            return $GLOBALS['registry']->get('name');
+        }
+
+        $cats = $this->getCategories(false);
+        $names[$id] = '';
+        $parent = $cats[$id]['category_parentid'];
+
+        while ($parent) {
+            $names[$id] .= $cats[$parent]['category_name'] . ': ';
+            $parent = $cats[$parent]['category_parentid'];
+        }
+
+        $names[$id] .= $cats[$id]['category_name'];
+
+        return $names[$id];
+    }
+
+    /**
+     * Save a category data into the backend from edit form.
+     *
+     * @param array $info  The category data to save.
+     *
+     * @return mixed  PEAR error.
+     */
+    public function saveCategory($info)
+    {
+        $this->_connect();
+
+        /* Update/Insert category. */
+        if (!empty($info['category_id'])) {
+            $result = $this->_updateCategory($info['category_id'], $info);
+            if ($result instanceof PEAR_Error) {
+                return $result;
+            }
+        } else {
+            $info['category_id'] = $this->_insertCategory($info);
+            if ($info['category_id'] instanceof PEAR_Error) {
+                return $info['category_id'];
+            }
+        }
+
+        /* If image uploaded save to backend. */
+        if (!empty($info['category_image']['name'])) {
+            $image = News::saveImage($info['category_image']['file'], $info['category_id'], 'categories', $info['image_resize']);
+            if ($image instanceof PEAR_Error) {
+                return $image;
+            }
+
+            $sql = 'UPDATE ' . $this->prefix . '_categories SET category_image = ? WHERE category_id = ?';
+            $this->_write_db->query($sql, array(1, $info['category_id']));
+        }
+
+        // Clean cache
+        $this->_expireCache();
+
+        return $info['category_id'];
+    }
+
+    /**
+     * Insert category data.
+     *
+     * @param mixed $data  The category data to insert.
+     *
+     * @return array  Inserted ID or PEAR error.
+     */
+    private function _insertCategory($data)
+    {
+        $new_id = $this->_write_db->nextId('news_categories');
+
+        $sql = 'INSERT INTO ' . $this->prefix . '_categories' .
+               ' (category_id, category_parentid) VALUES (?, ?)';
+        $values = array($new_id, (int)$data['category_parentid']);
+
+        $category = $this->_write_db->query($sql, $values);
+        if ($category instanceof PEAR_Error) {
+            Horde::logMessage($category, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $category;
+        }
+
+        $sql = 'INSERT INTO ' . $this->prefix . '_categories_nls VALUES (?, ?, ?, ?)';
+        foreach ($GLOBALS['conf']['attributes']['languages'] as $lang) {
+            $values = array($new_id,
+                            $lang,
+                            $data['category_name_' . $lang],
+                            $data['category_description_' . $lang]);
+            $this->_write_db->query($sql, $values);
+        }
+
+        return $new_id;
+    }
+
+    /**
+     * Update category data.
+     *
+     * @param integer $category_id  The category id to update.
+     * @param array   $data       The category data to update.
+     *
+     * @return array  NULL or PEAR error.
+     */
+    private function _updateCategory($category_id, $data)
+    {
+        $sql = 'UPDATE ' . $this->prefix . '_categories' .
+               ' SET category_parentid = ? ' .
+               ' WHERE category_id = ?';
+        $values = array((int)$data['category_parentid'], $category_id);
+
+        $category = $this->_write_db->query($sql, $values);
+        if ($category instanceof PEAR_Error) {
+            Horde::logMessage($category, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $category;
+        }
+
+        $sql = 'UPDATE ' . $this->prefix . '_categories_nls SET '
+            . ' category_name = ?, category_description = ? WHERE '
+            . ' category_id = ? AND category_nls = ?';
+        foreach ($GLOBALS['conf']['attributes']['languages'] as $lang) {
+            $values = array($data['category_name_' . $lang],
+                            $data['category_description_' . $lang],
+                            $category_id,
+                            $lang);
+            $result = $this->_write_db->query($sql, $values);
+        }
+
+        return $result;
+    }
+
+    /**
+     * Delete a category
+     *
+     * @return booelan
+     */
+    public function deleteCategory($id)
+    {
+        // Clean cache
+        $this->_expireCache();
+
+        // Delete image
+        News::deleteImage($id, 'categories');
+
+        // Delete record
+        $this->_connect();
+        $this->_write_db->query('DELETE FROM ' . $this->prefix . '_categories WHERE category_id = ?', array($id));
+        return $this->_write_db->query('DELETE FROM ' . $this->prefix . '_categories_nls WHERE category_id = ?', array($id));
+    }
+
+     /**
+     * Return an array of data for edit form.
+     *
+     * @param  $cid  The category ID.
+     *
+     * @return mixed Array that hold data for edit form.
+     */
+    function getCatArray($cid)
+    {
+        $this->_connect();
+
+        $sql = 'SELECT c.category_parentid, c.category_image, '
+            . ' l.category_nls, l.category_name, l.category_description '
+            . ' FROM news_categories c, news_categories_nls l '
+            . ' WHERE c.category_id = ? AND c.category_id = l.category_id';
+
+        $category = array('category_id' => $cid);
+        $result = $this->_db->getAll($sql, array($cid), DB_FETCHMODE_ASSOC);
+
+        foreach ($result as $row) {
+            $category['category_parentid'] = $row['category_parentid'];
+            $category['category_image'] = $row['category_image'];
+            $category['category_name_' . $row['category_nls']] = $row['category_name'];
+            $category['category_description_' . $row['category_nls']] = $row['category_description'];
+        }
+
+        return $category;
+    }
+
+    /**
+     * Return a Horde_Tree representation of the News_Categories tree.
+     *
+     * @return string  The html showing the categories as a Horde_Tree.
+     */
+    function renderTree($current = null, $click_url = null, $browse_only = false, $have_add_item = false)
+    {
+        $cats = $this->getCategories(false);
+
+        $params = array('icondir' => $GLOBALS['registry']->getImageDir(),
+                        'icon' => 'folder_open.png');
+
+        // Set up the tree
+        $tree = Horde_Tree::singleton('news_cats', 'javascript');
+        $tree->setOption(array('width' => '100%', 'border' => '0', 'class' => 'item', 'cellpadding' => '0', 'cellspacing' => '0', 'alternate' => true));
+
+        // prepare add link
+        if ($have_add_item) {
+            $add_img = Horde::img('mkdir.png', _("Add New Item"));
+            $add_item = Horde::applicationUrl('items/edit.php');
+        }
+
+        foreach ($cats as $cid => $category) {
+
+            if ($click_url !== null) {
+                $name = Horde::link(Util::addParameter($click_url, 'cid', $cid), _("Select Category")) . $category['category_name'] . '</a>';
+            } else {
+                $name = $category['category_name'];
+            }
+
+            $links = array();
+            if ($have_add_item) {
+                $links[] = Horde::link(Util::addParameter($add_item, 'cid', $cid), _("Add New Item")) . $add_img . '</a>';
+            }
+
+            $parent_id = $category['category_parentid'] ? $category['category_parentid'] : null;
+            $tree->addNode($cid, $parent_id, $name, $this->_nodes[$cid]['indent'], true, $params, $links);
+        }
+
+
+        return $tree->renderTree();
+    }
+
+    /**
+    * Get category child list
+    */
+    public function getChildList($id)
+    {
+        return isset($this->_nodes[$id]['children']) ? $this->_nodes[$id]['children'] : array();
+    }
+
+    /**
+     * Return a stored image for a category.
+     *
+     * @param integer $cid  The id of the category requested.
+     *
+     * @return string  The image name.
+     */
+    function getImage($cid)
+    {
+        /* Check if there is an image for requested category. */
+        if (!isset($this->_nodes[$cid]['category_image'])) {
+            return '';
+        }
+
+        /* return url */
+        if ($GLOBALS['conf']['images']['direct']) {
+            return Horde::img('/categories/' . $cid . '.' . $GLOBALS['conf']['images']['image_type'], $cid, '', $GLOBALS['conf']['images']['direct']);
+        } else {
+            $img_params = array('f' => $cid . '.' . $GLOBALS['conf']['images']['image_type'],
+                                's' => 'vfs',
+                                'p' => self::VFS_PATH . '/images/categories/',
+                                'c' => 'news');
+            return Util::addParameter(Horde::url('/services/images/view.php'), $img_params);
+        }
+    }
+
+    /**
+     * Get available categories
+     *
+     * @return array  An array containing caegories
+     */
+    public function getCategories($flat = true)
+    {
+        $lang = News::getLang();
+        $cache_key = 'NewsCategories_' . $lang . '_'. $flat;
+        $categories = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
+        if ($categories) {
+            return unserialize($categories);
+        }
+
+        $this->_connect();
+
+        $sql = 'SELECT c.category_id, l.category_name, c.category_parentid, l.category_description, c.category_image '
+            . ' FROM ' . $this->prefix . '_categories c, ' . $this->prefix . '_categories_nls l '
+            . ' WHERE c.category_id = l.category_id AND l.category_nls = ? ORDER BY category_name ASC';
+        $result = $this->_db->getAssoc($sql, false, array($lang), DB_FETCHMODE_ASSOC);
+
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        if (!$flat) {
+            $GLOBALS['cache']->set($cache_key, serialize($result));
+            return $result;
+        }
+
+        $categories = array();
+        foreach ($result as $category_id => $row) {
+            if (!empty($row['category_description']) && $row['category_name'] != $row['category_description']) {
+                $row['category_name'] .=  ' [ ' . $row['category_description'] . ' ]';
+            }
+            $categories[$category_id] = $row['category_name'];
+        }
+
+        $GLOBALS['cache']->set($cache_key, serialize($categories));
+        return $categories;
+    }
+
+    /**
+     * Expire categories cache
+     */
+    private function _expireCache()
+    {
+        $langs = $GLOBALS['conf']['attributes']['languages'];
+        $langs[] = News::getLang();
+
+        foreach ($langs as $lang) {
+            $GLOBALS['cache']->expire('NewsCategories_' . $lang . '_0');
+            $GLOBALS['cache']->expire('NewsCategories_' . $lang . '_1');
+        }
+    }
+
+    /**
+     * Attempts to open a persistent connection to the SQL server.
+     *
+     * @return boolean  True on success; exits (Horde::fatal()) on error.
+     */
+    private function _connect()
+    {
+        $this->_db = $GLOBALS['news']->db;
+        $this->_write_db = $GLOBALS['news']->writedb;
+    }
+}
diff --git a/news/lib/Forms/Search.php b/news/lib/Forms/Search.php
new file mode 100644 (file)
index 0000000..a71895a
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/**
+ * News search
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+class News_Search extends Horde_Form {
+
+    /**
+     * Creator
+     */
+    public function __construct($vars)
+    {
+        parent::__construct($vars, _("Search"), 'news_search');
+
+        $this->_submit = _("Search");
+
+        $this->addVariable(_("Search world"), 'word', 'text', false, false, false);
+
+        $s = array(News::UNCONFIRMED => _("Unconfirmed"),
+                   News::CONFIRMED => _("Confirmed"),
+                   News::LOCKED => _("Locked"));
+        $this->addVariable(_("Status"), 'status', 'enum', false, false, false, array($s, true));
+
+        $allowed_cats = $GLOBALS['news_cat']->getAllowed(PERMS_DELETE);
+        $this->addVariable(_("Category"), 'category', 'enum', false, false, false, array($allowed_cats, true));
+
+        $this->addVariable(_("Order by"), 'sort_by', 'enum', false, false, false, array(array('n.publish' => _("Publish date"),
+                                                                                              'n.id' => _("Id"),
+                                                                                              'l.title' => _("Title"),
+                                                                                              'n.comments' => _("Comments"),
+                                                                                              'n.reads' => _("Reads"),
+                                                                                              'n.attachemt' => _("Attachments"))));
+
+        $this->addVariable(_("Sort order"), 'sort_dir', 'enum', false, false, false, array(array('DESC' => _("Descending"),
+                                                                                                 'ASC' => _("Ascending"))));
+
+        $this->addVariable(_("Publish"), 'publish', 'datetime', false, false, false, $GLOBALS['news']->datetimeParams());
+        $this->addVariable(_("Unpublish"), 'unpublish', 'datetime', false, false, false, $GLOBALS['news']->datetimeParams());
+        $this->addVariable(_("User"), 'user', 'text', false, false, false);
+
+        if (Auth::isAdmin()) {
+            $this->addVariable(_("Editor"), 'editor', 'text', false, false, false);
+        }
+
+    }
+
+    /**
+     * Get pager
+     */
+    public function getPager($info, $count, $url)
+    {
+        $pager = &new Horde_UI_Pager('news_page',
+                                    Variables::getDefaultVariables(),
+                                    array('num' => $count,
+                                          'url' => $url,
+                                          'page_count' => 10,
+                                          'perpage' => $GLOBALS['prefs']->getValue('per_page')));
+
+        foreach ($info as $key => $value) {
+            if (substr($key, 0, 1) == '_') {
+                continue;
+            } elseif ($key == 'word') {
+                $pager->preserve($key, substr($value, 1, -1));
+            } else {
+                $pager->preserve($key, $value);
+            }
+        }
+
+        return $pager;
+    }
+    /**
+     * Fetch the field values of the submitted form.
+     *
+     * @param Variables $vars  A Variables instance, optional since Horde 3.2.
+     * @param array $info      Array to be filled with the submitted field
+     *                         values.
+     */
+    function getInfo($vars, &$info)
+    {
+        $this->_getInfoFromVariables($this->getVariables(), $this->_vars, $info);
+    }
+
+    /**
+     * Fetch the field values from a given array of variables.
+     *
+     * @access private
+     *
+     * @param array  $variables  An array of Horde_Form_Variable objects to
+     *                           fetch from.
+     * @param object $vars       The Variables object.
+     * @param array  $info       The array to be filled with the submitted
+     *                           field values.
+     */
+    function _getInfoFromVariables($variables, &$vars, &$info)
+    {
+        foreach ($variables as $var) {
+            $value = $var->getValue($vars);
+            if (empty($value)) {
+                continue;
+            }
+
+            require_once 'Horde/Array.php';
+            if (Horde_Array::getArrayParts($var->getVarName(), $base, $keys)) {
+                if (!isset($info[$base])) {
+                    $info[$base] = array();
+                }
+                $pointer = &$info[$base];
+                while (count($keys)) {
+                    $key = array_shift($keys);
+                    if (!isset($pointer[$key])) {
+                        $pointer[$key] = array();
+                    }
+                    $pointer = &$pointer[$key];
+                }
+                $var->getInfo($vars, $pointer);
+            } else {
+                $var->getInfo($vars, $info[$var->getVarName()]);
+            }
+
+        }
+    }
+
+}
diff --git a/news/lib/News.php b/news/lib/News.php
new file mode 100755 (executable)
index 0000000..04dda60
--- /dev/null
@@ -0,0 +1,1066 @@
+<?php
+/**
+ * News base calss
+ *
+ * Copyright 2007 Obala d.o.o.
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: News.php 287 2008-01-25 17:45:33Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+class News {
+
+    const UNCONFIRMED = 0;
+    const CONFIRMED = 1;
+    const LOCKED = 2;
+    const VFS_PATH = '.horde/news';
+
+    /**
+     * Hash containing connection parameters.
+     *
+     * @var array
+     */
+    private $_params = array();
+
+    /**
+     * Handle for the current database connection.
+     *
+     * @var DB
+     */
+    public $db;
+
+    /**
+     * Handle for the current database connection, used for writing. Defaults
+     * to the same handle as $db if a separate write database is not required.
+     *
+     * @var DB
+     */
+    public $writedb;
+
+    /**
+     * Handle for the tables prefix.
+     *
+     * @var prefix
+     */
+    public $prefix = 'news';
+
+    /**
+     */
+    public function __construct()
+    {
+        $this->_params = Horde::getDriverConfig('storage', 'sql');
+        $this->_connect();
+    }
+
+    /**
+     * Returns the current language
+     *
+     * @return string  The current language.
+     */
+    static public function getLang()
+    {
+        global $conf;
+
+        static $lang;
+
+        if ($lang === null) {
+            $lang = NLS::Select();
+            if (!empty($conf['attributes']['languages']) &&
+                !in_array($lang, $conf['attributes']['languages'])) {
+                $lang = $conf['attributes']['languages'][0];
+            }
+        }
+
+        return $lang;
+    }
+
+    /**
+     * Returns a flag image for a language.
+     *
+     * @param string $lang  The language to return the flag for, e.g. 'en_US'.
+     */
+    static public function getFlag($lang)
+    {
+        $flag = 'flags/' . strtolower(substr($lang, -2)) . '.png';
+        return Horde::img($flag, $lang, 'align="middle"', $GLOBALS['registry']->getImageDir('horde'));
+    }
+
+    /**
+     * Load trackback object
+     *
+     * @param array $data Data to pass to the communication
+     */
+    static public function loadTrackback($data = array())
+    {
+        include_once 'Services/Trackback.php';
+        if (!class_exists('Services_Trackback')) {
+            return PEAR::raiseError(_("Services/Trackback is not installed."));
+        }
+
+        $trackback_conf = $GLOBALS['conf']['trackback'];
+        unset($trackback_conf['spamcheck']);
+        $trackback_conf['httprequest'] = array(
+            'allowRedirects'    => true,
+            'maxRedirects'      => 2,
+            'useragent'         => 'HORDE News'
+        );
+
+        return Services_Trackback::create($data, $trackback_conf);
+    }
+
+    /**
+     * Template path
+     *
+     * @param intiger    $id $category id
+     * @param string     $type browse/news
+     *
+     * @return string $template template path
+     */
+    static public function getTemplatePath($cid, $type)
+    {
+        $template = NEWS_TEMPLATES . '/' . $type . '/';
+        if (file_exists($template .  $cid)) {
+            $template .= $cid . '/';
+        }
+
+        return $template;
+    }
+
+    /**
+     * Format file size
+     *
+     * @param int filesize
+     *
+     * @return boolean formatted filesize.
+     */
+    static public function format_filesize($filesize)
+    {
+        $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
+        $pass = 0; // set zero, for Bytes
+        while ($filesize >= 1024) {
+            $filesize /= 1024;
+            $pass++;
+        }
+
+        return round($filesize, 2) . ' ' . $units[$pass];
+    }
+
+    /**
+     * Format file size
+     *
+     * @param int filesize
+     *
+     * @return boolean formatted filesize.
+     */
+    static public function format_attached($id)
+    {
+        global $mime_drivers, $mime_drivers_map;
+
+        require_once 'Horde/MIME/Part.php';
+        require_once 'Horde/MIME/Viewer.php';
+        require_once 'Horde/MIME/Magic.php';
+        require_once 'Horde/MIME/Contents.php';
+        require HORDE_BASE . '/config/mime_drivers.php';
+
+        $dowload_img = Horde::img('save.png', _("Dowload"), ' style="width: 16px height: 16px"', $GLOBALS['registry']->getImageDir('horde'));
+        $dowload_zip = Horde::img('mime/compressed.png', _("Dowload Zip Compressed"), 'style="width: 16px height: 16px"', $GLOBALS['registry']->getImageDir('horde'));
+        $view_url = Horde::applicationUrl('files.php');
+
+        $html = '<table><tr valign="top"><td>';
+        $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'dowload_zip', 'id' => $id)), _("Compress and dowload all files at once")) . $dowload_zip . '</a> ' . "\n";
+        $html .= _("Attached files: ") . '</td><td>' . "\n";
+
+        $sql = 'SELECT filename, filesize FROM ' . $this->prefix . '_attachment WHERE id = ? AND lang = ?';
+        $files = $GLOBALS['news']->db->getAll($sql, array($id, NLS::select()),  DB_FETCHMODE_ASSOC);
+
+        foreach ($files as $file_data) {
+            $html .= ' -  ' . "\n";
+            $file = basename($file_data['filename']);
+            $dir = dirname($file_data['filename']);
+
+            $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'dowload_zip', 'dir' => $dir, 'file' => $file)), sprintf(_("Compress and dowload %s"), $file)) . $dowload_zip . '</a> ' . "\n";
+            $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'dowload_file', 'dir' => $dir, 'file' => $file)), sprintf(_("Dowload %s"), $file)) . $dowload_img . '</a> ' . "\n";
+            $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'view_file', 'dir' => $dir, 'file' => $file)), sprintf(_("Preview %s"), $file), '', '_file_view');
+            $html .= Horde::img(MIME_Viewer::getIcon(MIME_Magic::extToMIME(substr($file, strpos($file, '.')))), $file, 'width="16" height="16"', '') . ' ';
+            $html .= $file . '</a> ' . "\n";
+
+            $html .= ' (' . self::format_filesize($file_data['filesize']) . ')';
+            $html .= '<br /> ' . "\n";
+        }
+
+        $html .= ' </td></tr></table>';
+
+        return $html;
+    }
+
+    /**
+     * Load VFS Backend
+     */
+    static public function loadVFS()
+    {
+        $v_params = Horde::getVFSConfig('images');
+        if ($v_params instanceof PEAR_Error) {
+            return $v_params;
+        }
+
+        require_once 'VFS.php';
+        return VFS::singleton($v_params['type'], $v_params['params']);
+    }
+
+    /**
+     * Store image
+     *
+     * @param $id     Image id (item id)
+     * @param $file   Image file
+     * @param $type   Image type ('events', 'categories' ...)
+     * @param $resize Resize the big image?
+     */
+    static public function saveImage($id, $file, $type = 'news', $resize = true)
+    {
+        global $conf;
+
+        if ($file['uploaded'] instanceof PEAR_Error) {
+            return $file['uploaded'];
+        }
+
+        $vfs = self::loadVFS();
+        if ($vfs instanceof PEAR_Error) {
+            return $vfs;
+        }
+
+        $vfspath = self::VFS_PATH . '/images/' . $type;
+        $vfs_name = $id . '.' . $conf['images']['image_type'];
+
+        require_once 'Horde/Image.php';
+        $img = Horde_Image::factory('gd', array('type' => $conf['images']['image_type'],
+                                                'temp' => Horde::getTempDir()));
+
+        if ($img instanceof PEAR_Error) {
+            return $img;
+        }
+
+        $result = $img->loadFile($file);
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        // Store big image for articles
+        if ($type == 'news') {
+
+            // Resize big image?
+            if ($resize) {
+                $dimensions = $img->getDimensions();
+                if ($dimensions instanceof PEAR_Error) {
+                    return $dimensions;
+                }
+
+                $resize = $img->resize(min($conf['images']['image_width'], $dimensions['width']),
+                                       min($conf['images']['image_height'], $dimensions['height']));
+                if ($resize instanceof PEAR_Error) {
+                    return $resize;
+                }
+            }
+
+            // Store big image
+            $result = $vfs->writeData($vfspath . '/big/', $vfs_name, $img->raw(), true);
+            if ($result instanceof PEAR_Error) {
+                return $result;
+            }
+        }
+
+        // Resize thumbnail
+        $dimensions = $img->getDimensions();
+        $resize = $img->resize(min($conf['images']['thumbnail_width'], $dimensions['width']),
+                               min($conf['images']['thumbnail_height'], $dimensions['height']));
+        if ($resize instanceof PEAR_Error) {
+            return $resize;
+        }
+
+        // Trick path for articles
+        if ($type == 'news') {
+            $vfspath .= '/small';
+        }
+
+        // Store thumbnail
+        return $vfs->writeData($vfspath, $vfs_name, $img->raw(), true);
+    }
+
+    /**
+     * Delete image
+     *
+     * @param $id     Image id (item id)
+     */
+    static public function deleteImage($id)
+    {
+        global $conf;
+
+        $vfs = NEWS::loadVFS();
+        if ($vfs instanceof PEAR_Error) {
+            return $vfs;
+        }
+
+        $vfspath = self::VFS_PATH . '/images/' . $type;
+        $vfs_name = $id . '.' . $conf['images']['image_type'];
+
+        $vfs->deleteFile($vfspath . '/small/', $vfs_name);
+        $vfs->deleteFile($vfspath . '/big/', $vfs_name);
+    }
+
+    /**
+     * get Image path
+     */
+    static public function getImageUrl($id, $view = 'small', $type = 'news')
+    {
+        if (empty($GLOBALS['conf']['images']['direct'])) {
+            return Util::addParameter(Horde::applicationUrl('view.php'),
+                                     array('type' => $type,
+                                           'view' => $view,
+                                           'id' => $id),
+                                     null, false);
+        } else {
+            return $GLOBALS['conf']['images']['direct'] .
+                   '/' . $type . '/' . $view . '/' .
+                   $id . '.' . $GLOBALS['conf']['images']['image_type'];
+        }
+    }
+
+    /**
+     * get gallery images
+     */
+    static public function getGalleyImages($id)
+    {
+        $images = $GLOBALS['cache']->get("news_gallery_$id", 0);
+        if ($images) {
+            return unserialize($images);
+        }
+
+        $images = $GLOBALS['registry']->call('images/listImages', array('ansel', $id, PERMS_SHOW, 'thumb'));
+        $GLOBALS['cache']->set("news_gallery_$id", serialize($images));
+
+        return $images;
+    }
+
+    /**
+     * Formats time according to user preferences.
+     *
+     * @param int $timestamp  Message timestamp.
+     *
+     * @return string  Formatted date.
+     */
+    static public function dateFormat($timestamp)
+    {
+        static $df, $tf;
+
+        if ($df === null) {
+            $df = $GLOBALS['prefs']->getValue('date_format');
+            $tf = $GLOBALS['prefs']->getValue('twentyFour');
+        }
+
+        if (is_string($timestamp)) {
+            $timestamp = strtotime($timestamp);
+        }
+
+        return strftime($df, $timestamp)
+            . ' '
+            . (date($tf ? 'G:i' : 'g:ia', $timestamp));
+    }
+
+    /**
+     * Fomates time accoring to user prefs
+     *
+     * @param int $timestamp message timestamp
+     *
+     * @return string $date fromatted date
+     */
+    public function datetimeParams()
+    {
+        static $params;
+
+        if (!is_array($params)) {
+            $sql = 'SELECT MIN(YEAR(publish)) FROM ' . $this->prefix;
+            $params = array('start_year' => $GLOBALS['news']->db->getOne($sql),
+                            'end_year' => date('Y') + 1,
+                            'picker' => true, 
+                            'format_in' => '%Y-%m-%d %H:%M:%S',
+                            'format_out' => '%Y-%m-%d %H:%M:%S');
+        }
+
+        return $params;
+    }
+
+    /**
+     * Get last submitted comments
+     *
+     * @param int $limit    How many comments to show
+     */
+    static public function getLastComments($limit = 10)
+    {
+        $cache_key = 'news_lastcommetns_' . $limit;
+        $threads = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
+        if ($threads) {
+            return unserialize($threads);
+        }
+
+        global $registry;
+
+        if (!$registry->hasMethod('forums/getForumName')) {
+            return PEAR::raiseError(_("Comments are not supported."));
+        }
+
+        $params = array(0, 'message_timestamp', 1, false, 'news', null, 0, $limit);
+        $threads = $registry->call('forums/getThreads', $params);
+        if ($threads instanceof PEAR_Error) {
+            return $threads;
+        }
+
+        $read_url = Horde::applicationUrl('news.php', true);
+        foreach ($threads as $id => $message) {
+            $news_id = $registry->call('forums/getForumName', array('news', $message['forum_id']));
+            if ($news_id instanceof PEAR_Error) {
+                unset($threads[$id]);
+                continue;
+            }
+
+            $threads[$id]['news_id'] = $news_id;
+            $threads[$id]['read_url'] = Util::addParameter($read_url, 'id', $news_id);
+        }
+
+        $GLOBALS['cache']->set($cache_key, serialize($threads));
+        return $threads;
+    }
+
+    /**
+     * Updates schedul comments counter
+     *
+     * @param int $id schedul id
+     *
+     * @return true on succes PEAR_Error on failure
+     */
+    public function updateComments($id, $count)
+    {
+        return $this->writedb->query('UPDATE ' . $this->prefix . ' SET comments = ? WHERE id = ?', array($count, $id));
+    }
+
+    /**
+     * Get news
+     *
+     * @param int    $news news id
+     *
+     * @return true on succes PEAR_Error on failure
+     */
+    public function get($id)
+    {
+        // Admins bypass the cache (can read nonpublished and locked news)
+        if (!Auth::isAdmin('news:admin')) {
+            $key = 'news_'  . self::getLang() . '_' . $id;
+            $data = $GLOBALS['cache']->get($key, $GLOBALS['conf']['cache']['default_lifetime']);
+            if ($data) {
+                return unserialize($data);
+            }
+        }
+
+        $query = 'SELECT n.publish, n.user, n.source, n.sourcelink, n.category1, n.parents, ' .
+                ' n.category2, n.attachments, n.picture, n.comments, n.gallery, n.sponsored, ' .
+                ' l.title, l.content, l.picture_comment, l.tags, n.selling, n.trackbacks, n.threads, ' .
+                ' n.form_id, n.form_ttl FROM ' . $this->prefix . ' AS n, ' . $this->prefix . '_body AS l ' .
+                ' WHERE n.id=? AND n.id=l.id AND l.lang=?';
+
+        if (!Auth::isAdmin('news:admin')) {
+            $query .= ' AND n.status = ' . self::CONFIRMED;
+        }
+
+        $data = $this->db->getRow($query, array($id, self::getLang()), DB_FETCHMODE_ASSOC);
+        if ($data instanceof PEAR_Error) {
+            return $data;
+        }
+
+        if (empty($data)) {
+            return PEAR::raiseError(sprintf(_("There requested news %s don't exist."), $id));
+        }
+
+        /* Get talks backs */
+        if ($data['trackbacks']) {
+            $sql = 'SELECT excerpt, created, title, url, blog_name FROM ' . $this->prefix . '_trackback WHERE id = ?';
+            $data['trackback'] = $this->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC);
+            if ($data['trackback'] instanceof PEAR_Error) {
+                return $data['trackback'];
+            }
+        }
+
+        /* Get parents */
+        if ($data['parents']) {
+            $sql = 'SELECT n.id, n.publish, n.comments, l.title ' .
+                ' FROM ' . $this->prefix . ' AS n, ' . $this->prefix . '_body AS l ' .
+                ' WHERE n.id IN (' . $data['parents'] . ') AND n.id = l.id AND l.lang = ?';
+            $data['parents'] = $this->db->getAssoc($sql, false, array(self::getLang()), DB_FETCHMODE_ASSOC);
+            if ($data['parents'] instanceof PEAR_Error) {
+                return $data['parents'];
+            }
+        }
+
+        /* Get threads */
+        if ($data['threads']) {
+            $sql = 'SELECT message_id, forum_id, message_subject, message_seq ' .
+                ' FROM agora_messages WHERE message_id IN (' . $data['threads'] . ')';
+            $data['threads'] = $this->db->getAssoc($sql, false, null, DB_FETCHMODE_ASSOC);
+            if ($data['threads'] instanceof PEAR_Error) {
+                return $data['threads'];
+            }
+        }
+
+        if (!Auth::isAdmin('news:admin')) {
+            $GLOBALS['cache']->set($key, serialize($data));
+        }
+
+        return $data;
+    }
+
+    /**
+     * Updates news comments counter
+     *
+     * @param int    $news news id
+     *
+     * @return true on succes PEAR_Error on failure
+     */
+    public function getFiles($id)
+    {
+        $sql = 'SELECT filename, filesize FROM ' . $this->prefix . '_attachment WHERE id=? AND lang=?';
+        return $this->db->getAll($sql, array($id, self::getLang()),  DB_FETCHMODE_ASSOC);
+    }
+
+    /**
+     * Get version
+     *
+     * @param intiger    $id news id
+     * @param array      $info array with all news info
+     *
+     * @return result of the insert
+     */
+    public function getVerison($id, $version)
+    {
+        $sql = 'SELECT id, created, user_uid, content FROM ' . $this->prefix . '_versions WHERE id = ? AND version = ?';
+        $result = $this->db->getRow($sql, array($id, $version), DB_FETCHMODE_ASSOC);
+        $result['content'] = unserialize($result['content']);
+        return $result;
+    }
+
+    /**
+     * Get versions
+     *
+     * @param intiger    $id news id
+     * @param array      $info array with all news info
+     *
+     * @return result of the insert
+     */
+    public function getVerisons($id)
+    {
+        $sql = 'SELECT version, created, user_uid,content,action FROM ' . $this->prefix . '_versions WHERE id = ? ORDER BY version DESC';
+        return $this->db->getAll($sql, array($id), DB_FETCHMODE_ASSOC);
+    }
+
+    /**
+     * Logs a news view.
+     *
+     * @return boolean True, if the view was logged, false if the message was aleredy seen
+     */
+    function logView($id)
+    {
+        if ($GLOBALS['browser']->isRobot()) {
+            exit;
+        }
+
+        /* We already read this story? */
+        if (isset($_COOKIE['news_viewed_news']) &&
+            strpos($_COOKIE['news_viewed_news'], ':' . $id . '|') !== false) {
+            return false;
+        }
+
+        /* Rembember when we see a story */
+        if (!isset($_COOKIE['news_viewed_news'])) {
+            $_COOKIE['news_viewed_news'] = ':';
+        }
+        $_COOKIE['news_viewed_news'] .= $id . '|' . $_SERVER['REQUEST_TIME'] . ':';
+
+        setcookie('news_viewed_news', $_COOKIE['news_viewed_news'], $_SERVER['REQUEST_TIME'] + 22896000, $GLOBALS['conf']['cookie']['path'],
+                  $GLOBALS['conf']['cookie']['domain'],  $GLOBALS['conf']['use_ssl'] == 1 ? 1 : 0);
+
+        /* Update the count */
+        $sql = 'UPDATE ' . $this->prefix . ' SET view_count = view_count + 1 WHERE id = ?';
+        $result = $this->writedb->query($sql, array($id));
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        /* Log it */
+        $sql = 'INSERT INTO ' . $this->prefix . '_user_reads (id,user,ip,useragent,readdate) VALUES (?,?,?,?,NOW())';
+        $result = $this->writedb->query($sql, array($id,Auth::getAuth(),$_SERVER['REMOTE_ADDR'],$_SERVER["HTTP_USER_AGENT"]));
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        return true;
+    }
+
+    /**
+     * Remove from shop recursively by category ID: categories, articles, stocks and images
+     *
+     * @param mixed int Category ID
+     *
+     * @return mixed TRUE or PEAR error
+     */
+    public function removeByCategory($cid)
+    {
+        /*vse v kategoriji in pol delete povsot */
+    }
+
+    /**
+     * Attach a trackback
+     */
+    public function saveTrackback($id, $title, $url, $excerpt, $blog_name, $trackback_url)
+    {
+        $sql = 'SELECT COUNT(*) FROM ' . $this->prefix . '_trackback WHERE id = ? AND url = ?';
+        $result = $this->db->getOne($sql, array($id, $url));
+        if ($result > 0) {
+            return PEAR::raiseError(sprintf(_("URL already trackbacked: %s"), $url));
+        }
+
+        $params = array('id' => $id,
+                        'title' => $title,
+                        'url' => $url,
+                        'excerpt' => $excerpt,
+                        'blog_name' => $blog_name,
+                        'created' => date('Y-m-d H:i:s'));
+
+        $sql = 'INSERT INTO ' . $this->prefix . '_trackback (' . implode(',', array_keys($params)) . ') VALUES (?, ?, ?, ?, ?, ?)';
+        $result = $this->writedb->query($sql, $params);
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        /* Update trackback count */
+        $GLOBALS['cache']->expire('news_'  . self::getLang() . '_' . $id);
+        return $this->writedb->query('UPDATE ' . $this->prefix . ' SET trackbacks = trackbacks + 1 WHERE id = ?', array($id));
+    }
+
+    /**
+     * Delete a source
+     *
+     * @param integer $id  The source id to delete.
+     *
+     * @return boolean
+     */
+    public function deleteSource($id)
+    {
+        $GLOBALS['cache']->expire('newsSources');
+        $this->deleteImage($id, 'sources');
+        $sql = 'DELETE FROM ' . $this->prefix . '_sources WHERE sources_id = ?';
+        return $this->writedb->query($sql, array($id));
+    }
+
+    /**
+     * Fetches sources list
+     *
+     * @return array  An array containing all sources names
+     */
+    public function getSources($flat = false)
+    {
+        $sources = $GLOBALS['cache']->get('newsSources');
+        if (empty($sources)) {
+            $sql = 'SELECT source_id, source_name, source_url FROM ' . $this->prefix . '_sources ORDER BY source_name ASC';
+            $sources = $this->db->getAssoc($sql, true, array(), DB_FETCHMODE_ASSOC);
+            $GLOBALS['cache']->set('newsSources', serialize($sources));
+        } else {
+            $sources = unserialize($sources);
+        }
+
+        if (!$flat) {
+            foreach ($sources as $source_id => $source) {
+                $sources[$source_id] = $source['source_name'];
+            }
+        }
+
+        return $sources;
+    }
+
+    /**
+     * Save a source data into the backend from edit form.
+     *
+     * @param array $info  The source data to save.
+     *
+     * @return mixed  PEAR error.
+     */
+    public function saveSource($info)
+    {
+        /* Update/Insert source. */
+        if (!empty($info['source_id'])) {
+            $result = $this->_updateSource($info['source_id'], $info);
+            if ($result instanceof PEAR_Error) {
+                return $result;
+            }
+        } else {
+            $info['source_id'] = $this->_insertSource($info);
+            if ($info['source_id'] instanceof PEAR_Error) {
+                return $info['source_id'];
+            }
+        }
+
+        /* If image uploaded save to backend. */
+        if (!empty($info['source_image']['name'])) {
+            $image = $this->_saveImage($info['source_id'], $info['source_image']['file'], 'sources', $info['source_image_resize']);
+            if ($image instanceof PEAR_Error) {
+                return $image;
+            }
+
+            $sql = 'UPDATE ' . $this->prefix . '_sources SET source_image = ? WHERE source_id = ?';
+            $this->writedb->query($sql, array(1, $info['source_id']));
+        }
+
+        $GLOBALS['cache']->expire('newsSources');
+        return $info['source_id'];
+    }
+
+    /**
+     * Insert source data.
+     *
+     * @param mixed $data  The source data to insert.
+     *
+     * @return array  Inserted ID or PEAR error.
+     */
+    private function _insertSource($data)
+    {
+        $new_id = $this->writedb->nextId('news_sources');
+
+        $sql = 'INSERT INTO ' . $this->prefix . '_sources' .
+               ' (source_id, source_name, source_url)' .
+               ' VALUES (?, ?, ?)';
+        $values = array($new_id,
+                        $data['source_name'],
+                        $data['source_url']);
+
+        $source = $this->writedb->query($sql, $values);
+        if ($source instanceof PEAR_Error) {
+            Horde::logMessage($source, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $source;
+        }
+
+        return $new_id;
+    }
+
+    /**
+     * Update source data.
+     *
+     * @param integer $source_id  The source id to update.
+     * @param array   $data       The source data to update.
+     *
+     * @return array  NULL or PEAR error.
+     */
+    private function _updateSource($source_id, $data)
+    {
+        $sql = 'UPDATE ' . $this->prefix . '_sources' .
+               ' SET source_name = ?, source_url = ?' .
+               ' WHERE source_id = ?';
+        $values = array($data['source_name'],
+                        $data['source_url'],
+                        $source_id);
+
+        $source = $this->writedb->query($sql, $values);
+        if ($source instanceof PEAR_Error) {
+            Horde::logMessage($source, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $source;
+        }
+    }
+
+    /**
+     * Attempts to open a persistent connection to the SQL server.
+     *
+     * @return boolean  True on success; exits (Horde::fatal()) on error.
+     */
+    private function _connect()
+    {
+        Horde::assertDriverConfig($this->_params, 'storage',
+                                  array('phptype', 'charset'));
+
+        if (!isset($this->_params['database'])) {
+            $this->_params['database'] = '';
+        }
+        if (!isset($this->_params['username'])) {
+            $this->_params['username'] = '';
+        }
+        if (!isset($this->_params['hostspec'])) {
+            $this->_params['hostspec'] = '';
+        }
+        if (isset($this->_params['prefix'])) {
+            $this->prefix = $this->_params['prefix'];
+        }
+
+        /* Connect to the SQL server using the supplied parameters. */
+        require_once 'DB.php';
+        $this->writedb = &DB::connect($this->_params,
+                                        array('persistent' => !empty($this->_params['persistent'])));
+        if ($this->writedb instanceof PEAR_Error) {
+            Horde::fatal($this->writedb, __FILE__, __LINE__);
+        }
+
+        // Set DB portability options.
+        switch ($this->writedb->phptype) {
+        case 'mssql':
+            $this->writedb->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM);
+            break;
+        default:
+            $this->writedb->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+        }
+
+        /* Check if we need to set up the read DB connection seperately. */
+        if (!empty($this->_params['splitread'])) {
+            $params = array_merge($this->_params, $this->_params['read']);
+            $this->db = &DB::connect($params,
+                                      array('persistent' => !empty($params['persistent'])));
+            if ($this->db instanceof PEAR_Error) {
+                Horde::fatal($this->db, __FILE__, __LINE__);
+            }
+
+            // Set DB portability options.
+            switch ($this->db->phptype) {
+            case 'mssql':
+                $this->db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM);
+                break;
+            default:
+                $this->db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+            }
+
+        } else {
+            /* Default to the same DB handle for the writer too. */
+            $this->db =& $this->writedb;
+        }
+
+        return true;
+    }
+
+   /**
+     * Build whare search
+     */
+    public function buildQuery($perms = PERMS_READ, $criteria = array())
+    {
+        static $parts;
+
+        $id = serialize($criteria);
+        if (isset($parts[$id])) {
+            return $parts[$id];
+        }
+
+        $sql = 'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS l '
+            . ' WHERE n.id = l.id AND l.lang = ?';
+        $params = array('_lang' => NLS::select());
+
+        if ($perms == PERMS_READ) {
+            $sql .= ' AND n.publish <= ? ';
+            $params['_perms'] = date('Y-m-d H:i:s');
+            $sql .= ' AND n.status = ? ';
+            $params['_status'] = self::CONFIRMED;
+        }
+
+        if (empty($criteria)) {
+            $parts[$id] = array($sql, $params);
+            return $parts[$id];
+        }
+
+        /* check status */
+        if (isset($criteria['status'])) {
+            $sql .= ' AND n.status = ?';
+            $params['status'] = $criteria['status'];
+        }
+
+        /* get category */
+        if (isset($criteria['category'])) {
+            $sql .= ' AND (n.category1 = ? OR n.category2 = ?)';
+            $params['category'] = $criteria['category'];
+            $params['_category'] = $criteria['category'];
+        }
+
+        /* seaching for a pericolar word */
+        if (isset($criteria['word'])) {
+            $sql .= ' AND (l.title LIKE ? OR l.content LIKE ? OR l.tags LIKE ?)';
+            $params['word'] = '%' . $criteria['word'] . '%';
+            $params['_word'] = '%' . $criteria['word'] . '%';
+            $params['tags'] = '%' . $criteria['word'] . '%';
+        }
+
+        /* submitter */
+        if (isset($criteria['user'])) {
+            $sql .= ' AND n.user = ? ';
+            $params['user'] = $criteria['user'];
+        }
+
+        /* editor */
+        if (isset($criteria['editor'])) {
+            $sql .= ' AND n.editor = ? ';
+            $params['editor'] = $criteria['editor'];
+        }
+
+        /* publish time */
+        if (isset($criteria['published_to'])) {
+            $sql .= ' AND n.publish <= ? ';
+            $params['published_to'] =  $criteria['published_to'];
+        }
+
+        if (isset($criteria['published_from'])) {
+            $sql .= ' AND n.publish >= ? ';
+            $params['published_from'] =  $criteria['published_from'];
+        }
+
+        $parts[$id] = array($sql, $params);
+
+        return $parts[$id];
+    }
+
+    /**
+     * Count news
+     *
+     * @param array $criteria Filter parameter
+
+     * @param int $perms Permissions filter
+     *
+     * @return Nimber of news
+     */
+    public function countNews($criteria = array(), $perms = PERMS_READ)
+    {
+        $binds = $this->buildQuery($perms, $criteria);
+        $binds[0] = 'SELECT COUNT(*) ' . $binds[0];
+
+        return $this->db->getOne($binds[0], $binds[1]);
+    }
+
+    /**
+     * List news
+     *
+     * @param array $criteria Filter parameter
+     * @param int $from Offset
+     * @param int $count Limit rows
+     * @param int $perms Permissions filter
+     *
+     * @return array of news data
+     */
+    public function listNews($criteria = array(), $from = 0, $count = 0, $perms = PERMS_READ)
+    {
+        $binds = $this->buildQuery($perms, $criteria);
+
+        if (!isset($criteria['sort_by'])) {
+            $criteria['sort_by'] = 'n.publish';
+        }
+        if (!isset($criteria['sort_dir'])) {
+            $criteria['sort_dir'] = 'DESC';
+        }
+
+        $binds[0] = 'SELECT n.id, n.publish, n.user, n.category1, n.category2, n.comments, '
+                    . ' n.picture, n.chars, l.title, l.abbreviation ' . $binds[0]
+                    . ' ORDER BY ' . $criteria['sort_by']
+                    . ' ' . $criteria['sort_dir'];
+
+        if ($count) {
+            $binds[0] = $this->db->modifyLimitQuery($binds[0], $from, $count);
+        }
+
+        return $this->db->getAll($binds[0], $binds[1], DB_FETCHMODE_ASSOC);
+    }
+
+    /**
+     * Construct tag cloud
+     *
+     * @param boolean $minimize  Minimize tag cloud
+     *                          (remove 1 length strings, and single occurrence)
+     *
+     * @return mixed  The HTML for the tag cloud | PEAR_Error
+     */
+    public function getCloud($minimize = false)
+    {
+        $cache_key = 'news_cloud_' . $minimize;
+        $cloud = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
+        if ($cloud) {
+            // return $cloud;
+        }
+
+        $sql = 'SELECT l.tags, n.publish FROM ' . $this->prefix . '_body AS l, '
+               . $this->prefix . ' AS n WHERE l.lang = ? AND n.id = l.id AND n.status = ? ORDER BY n.publish DESC LIMIT 0, '
+               . ($minimize ? '100' : '500');
+
+        $result = $this->db->query($sql, array(NLS::select(), self::CONFIRMED));
+        if ($result instanceof PEAR_Error) {
+            return $result;
+        }
+
+        $tags_elemets = array();
+        while ($news = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
+            foreach (explode(' ', $news['tags']) as $tag) {
+                if ($minimize && strlen($tag) < 2) {
+                    continue;
+                }
+                $tags_elemets[$tag][] = strtotime($news['publish']);
+            }
+        }
+
+        if ($minimize) {
+            foreach ($tags_elemets as $tag => $content) {
+                if (count($content) == 1) {
+                    unset($tags_elemets[$tag]);
+                }
+            }
+        }
+
+        if (empty($tags_elemets)) {
+            return '';
+        }
+
+        $i = 0;
+        require_once dirname(__FILE__) . '/TagCloud.php';
+        $tags = new Oscar_TagCloud();
+        $tag_link = Horde::applicationUrl('search.php');
+        foreach ($tags_elemets as $tag => $time) {
+            sort($time);
+            $tags->addElement($tag, Util::addParameter($tag_link, array('word' => $tag)),
+                              count($tags_elemets[$tag]), $time[0]);
+        }
+
+        $cloud = $tags->buildHTML();
+        $GLOBALS['cache']->set($cache_key, $cloud);
+
+        return $cloud;
+    }
+
+    /**
+     * Build News's list of menu articles
+     */
+    static public function getMenu($returnType = 'object')
+    {
+        require_once 'Horde/Menu.php';
+
+        $menu = &new Menu();
+        $img_dir = $GLOBALS['registry']->getImageDir('horde');
+
+        if ($GLOBALS['prefs']->getValue('news_layout') != '') {
+            $menu->add(Horde::applicationUrl('content.php'), _("Overview"), 'layout.png', $img_dir);
+        }
+        $menu->add(Horde::applicationUrl('browse.php'), _("Archive"), 'info.png', $img_dir);
+        $menu->add(Horde::applicationUrl('search.php'), _("Search"), 'search.png', $img_dir);
+        $menu->add(Horde::applicationUrl('add.php'), _("Add"), 'edit.png', $img_dir);
+
+        if ($GLOBALS['conf']['attributes']['tags']) {
+            $menu->add(Horde::applicationUrl('cloud.php'), _("Tag cloud"), 'colorpicker.png', $img_dir);
+        }
+
+        if (Auth::isAdmin('news:admin')) {
+            $menu->add(Horde::applicationUrl('edit.php'), _("Editorship"), 'config.png', $img_dir);
+            $menu->add(Horde::applicationUrl('admin/categories/index.php'), _("Administration"), 'administration.png', $img_dir);
+        }
+
+        if ($returnType == 'object') {
+            return $menu;
+        } else {
+            return $menu->render();
+        }
+    }
+
+}
diff --git a/news/lib/TagCloud.php b/news/lib/TagCloud.php
new file mode 100644 (file)
index 0000000..b594d90
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+* extend Horde TagCloud to allow complete css font sizes
+*/
+class Oscar_TagCloud extends Horde_UI_TagCloud {
+
+    /**
+     * create a Element of HTML part
+     *
+     * @return  string a Element of Tag HTML
+     * @param   array  $tag
+     * @param   string $type css class of time line param
+     * @param   int    $fontsize
+     * @access  private
+     */
+    function _createHTMLTag($tag, $type, $fontsize)
+    {
+        return sprintf("<a class=\"%s\" href=\"%s\">%s</a>\n",
+                       $type,
+                       $tag['url'],
+                       htmlspecialchars($tag['name']));
+    }
+
+    /**
+     * wrap div tag
+     *
+     * @return  string
+     * @param   string $html
+     * @access  private
+     */
+    function _wrapDiv($html)
+    {
+        return $html;
+    }
+
+}
diff --git a/news/lib/View.php b/news/lib/View.php
new file mode 100755 (executable)
index 0000000..552c0c1
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+/**
+ * News General View Class
+ *
+ * $Id: View.php 250 2008-01-18 15:31:32Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Duck <duck@obala.net>
+ * @package News
+ */
+class News_View extends Horde_View {
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        /* Set parents defualt data */
+        parent::__construct(array('templatePath' => NEWS_TEMPLATES,
+                                  'encoding' => NLS::select()));
+
+        $this->list_url = Horde::applicationUrl('list.php');
+    }
+
+    /**
+     * Format value accoring to currency
+     *
+     * @param float   $price  The price value to format.
+     *
+     * @return Currency formatted price string.
+     */
+    public public function format_price($price)
+    {
+        if (empty($price)) {
+            return '';
+        }
+
+        static $currency;
+
+        if (is_null($currency)) {
+            $currencies = new Horde_CurrenciesMapper();
+            $currency = $currencies->getDefault('data');
+        }
+
+        return Horde_Currencies::formatPrice($price, $currency);
+    }
+
+    /**
+     * Formats time according to user preferences.
+     *
+     * @param int $timestamp  Message timestamp.
+     *
+     * @return string  Formatted date.
+     */
+    public function format_date($timestamp)
+    {
+        return strftime($GLOBALS['prefs']->getValue('date_format'), $timestamp);
+    }
+
+    /**
+     * Formats time according to user preferences.
+     *
+     * @param int $timestamp  Message timestamp.
+     *
+     * @return string  Formatted date.
+     */
+    public function format_datetime($timestamp)
+    {
+        return strftime($GLOBALS['prefs']->getValue('date_format'), $timestamp)
+            . ' '
+            . (date($GLOBALS['prefs']->getValue('twentyFour') ? 'G:i' : 'g:ia', $timestamp));
+    }
+
+    /**
+     * Link tags
+     *
+     * @param string $tags Video's tags
+     */
+    function getTagsLinks($tags)
+    {
+        if (empty($tags)) {
+            return '';
+        }
+
+        $html = '';
+        $search = Horde::applicationUrl('search.php');
+        foreach (explode(' ', $tags) as $tag) {
+            $html .= '<a href="'
+                    . Util::addParameter($search, array('word' => $tag))
+                     . '">' . $tag . '</a> ';
+        }
+
+        return $html;
+    }
+}
diff --git a/news/lib/api.php b/news/lib/api.php
new file mode 100755 (executable)
index 0000000..5723e8f
--- /dev/null
@@ -0,0 +1,148 @@
+<?php
+/**
+ * News api
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: api.php 730 2008-08-10 09:52:55Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+$_services['perms'] = array(
+    'args' => array(),
+    'type' => '{urn:horde}stringArray'
+);
+
+$_services['commentCallback'] = array(
+    'args' => array('id' => 'string'),
+    'type' => 'string'
+);
+
+$_services['hasComments'] = array(
+    'args' => array(),
+    'type' => 'boolean'
+);
+
+$_services['listNews'] = array(
+    'args' => array('perms' => 'string', 'criteria' => 'array', 'from' => 'int', 'count' => 'int'),
+    'type' => 'array'
+);
+
+$_services['countNews'] = array(
+    'args' => array('perms' => 'string', 'criteria' => 'array'),
+    'type' => 'int'
+);
+
+/**
+ * Categories/Permissions
+ */
+function _news_perms()
+{
+    static $perms = array();
+    if (!empty($perms)) {
+        return $perms;
+    }
+
+    $perms['tree']['news']['admin'] = true;
+    $perms['title']['news:admin'] = _("Admin");
+
+    $perms['tree']['news']['editors'] = true;
+    $perms['title']['news:editors'] = _("Editors");
+
+    require_once dirname(__FILE__) . '/base.php';
+    $tree = $GLOBALS['news_cat']->getEnum();
+
+    $perms['title']['news:categories'] = _("Categories");
+    foreach ($tree as $cat_id => $cat_name) {
+        $perms['tree']['news']['categories'][$cat_id] = false;
+        $perms['title']['news:categories:' . $cat_id] = $cat_name;
+    }
+
+    return $perms;
+}
+
+/**
+ * Callback for comment API
+ *
+ * @param int $id                Internal data identifier
+ * @param string $type      Type of data to retreive (title, owner...)
+ * @param array $params Additional parameters
+ */
+function _news_commentCallback($id, $type = 'title', $params = null)
+{
+    static $info;
+
+    if (!empty($info[$id][$type])) {
+        return $info[$id][$type];
+    }
+
+    require_once dirname(__FILE__) . '/base.php';
+
+    $news = $GLOBALS['news']->get($id);
+    if ($news instanceof PEAR_Error) {
+        return $news;
+    }
+
+    switch ($type) {
+
+    case 'owner':
+        return $news['user'];
+
+    case 'link':
+        return Util::addParameter(Horde::applicationUrl('news.php', true, -1), 'id', $id);
+
+    case 'messages':
+        $GLOBALS['news']->updateComments($id, $params);
+        return true;
+
+    default:
+        $info[$id][$type] = $news['title'];
+        return $news['title'];
+    }
+}
+
+/**
+ * Returns if applications allows comments
+ */
+function _news_hasComments()
+{
+    return $GLOBALS['conf']['comments']['allow'];
+}
+
+/**
+ * List news
+ *
+ * @param array $criteria  Array of news attributes match
+ * @param intiger $from    Start fetching from news
+ * @param intiger $count  The number of news to fetch
+ * @param intiger $perms News permission access type
+ *
+ * @return array | PEAR_Error  True on success, PEAR_Error on failure.
+ */
+function _news_listNews($criteria = array(), $from = 0, $count = 0, $perms = PERMS_READ)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    return $GLOBALS['news']->listNews($criteria, $perms);
+}
+
+/**
+ * Count news
+ *
+ * @param array $criteria Array of news attributes match
+ * @param integer $perms Permisson level
+ *
+ * @return integer | PEAR_Error  True on success, PEAR_Error on failure.
+ */
+function _news_countNews($criteria = array(), $perms = PERMS_READ)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    return $GLOBALS['news']->countNews($criteria, $perms);
+}
+
diff --git a/news/lib/base.php b/news/lib/base.php
new file mode 100755 (executable)
index 0000000..e6561e8
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * News base
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: base.php 200 2008-01-09 08:29:52Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+// Check for a prior definition of HORDE_BASE (perhaps by an
+// auto_prepend_file definition for site customization).
+if (!defined('HORDE_BASE')) {
+    define('HORDE_BASE', dirname(__FILE__) . '/../..');
+}
+
+// Load the Horde Framework core, and set up inclusion paths.
+require_once HORDE_BASE . '/lib/core.php';
+require_once 'Horde/Loader.php';
+
+// Registry.
+$registry = &Registry::singleton();
+if (($pushed = $registry->pushApp('news', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) {
+    if ($pushed->getCode() == 'permission_denied') {
+        Horde::authenticationFailureRedirect();
+    }
+    Horde::fatal($pushed, __FILE__, __LINE__, false);
+}
+$conf = &$GLOBALS['conf'];
+define('NEWS_TEMPLATES', $registry->get('templates'));
+
+// Notification system.
+$notification = &Notification::singleton();
+$notification->attach('status');
+
+// Define the base file path of News.
+if (!defined('NEWS_BASE')) {
+    define('NEWS_BASE', dirname(__FILE__) . '/..');
+}
+
+// Cache
+$GLOBALS['cache'] = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
+                                            Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+
+// News base library
+require_once NEWS_BASE . '/lib/News.php';
+require_once NEWS_BASE . '/lib/Categories.php';
+require_once NEWS_BASE . '/lib/View.php';
+
+// Set up News drivers.
+$GLOBALS['news'] = new News();
+$GLOBALS['news_cat'] = new News_Categories();
+
+// Start compression.
+if (!Util::nonInputVar('no_compress')) {
+    Horde::compressOutput();
+}
+
diff --git a/news/lib/version.php b/news/lib/version.php
new file mode 100755 (executable)
index 0000000..faa86ef
--- /dev/null
@@ -0,0 +1 @@
+<?php define('NEWS_VERSION', '0.2-cvs') ?>
\ No newline at end of file
diff --git a/news/locale/sl_SI/LC_MESSAGES/news.mo b/news/locale/sl_SI/LC_MESSAGES/news.mo
new file mode 100755 (executable)
index 0000000..8df9f2c
Binary files /dev/null and b/news/locale/sl_SI/LC_MESSAGES/news.mo differ
diff --git a/news/mail.php b/news/mail.php
new file mode 100644 (file)
index 0000000..6526f0f
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * News
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: mail.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$id = Util::getFormData('id');
+$row = $news->get($id);
+if ($row instanceof PEAR_Error) {
+    $notification->push($row->getMessage(), 'horde.error');
+    header('Location: ' . Horde::applicationUrl('browse.php'));
+    exit;
+}
+
+/* Error handler */
+function _error($msg)
+{
+    $GLOBALS['notification']->push($msg, 'horde.error');
+    $news_url = Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $GLOBALS['id']);
+    header('Location: ' . $news_url);
+    exit;
+}
+
+if (!Auth::isAuthenticated()) {
+    _error(_("Only authenticated users can send mails."));
+}
+
+$to = Util::getFormData('email');
+if (empty($to)) {
+    _error(_("No mail entered."));
+    exit;
+}
+
+$from = $prefs->getValue('from_addr');
+if (empty($from)) {
+    _error(_("You have no email set."));
+    exit;
+}
+
+$body = sprintf(_("%s would you like to invite you to read the news\n Title: %s\n\n Published: %s \nLink: %s"),
+                Auth::getAuth(),
+                $row['title'],
+                $row['publish'],
+                Util::addParameter(Horde::applicationUrl('news.php', true, -1), 'id', $id));
+
+require_once 'Horde/MIME/Mail.php';
+$mail = new MIME_Mail($row['title'], $body, $to, $from, NLS::getCharset());
+$result = $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
+if ($result instanceof PEAR_Error) {
+    $notification->push($result->getMessage(), 'horde.error');
+} else {
+    $notification->push(sprintf(_("News succesfully send to %s"), $to), 'horde.success');
+}
+
+header('Location: ' . Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $id));
+exit;
diff --git a/news/news.php b/news/news.php
new file mode 100644 (file)
index 0000000..5ad644f
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/**
+ * News
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: news.php 229 2008-01-12 19:47:30Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$id = Util::getFormData('id');
+$row = $news->get($id);
+
+// check if the news eyists
+if ($row instanceof PEAR_Error) {
+    $notification->push($row->getMessage(), 'horde.error');
+    header('Location: ' . Horde::applicationUrl('index.php'));
+    exit;
+}
+
+// check if the news exists
+if (($version = Util::getFormData('version')) !== null) {
+    $sql = 'SELECT created, user_uid, content FROM ' . $news->prefix . '_versions WHERE id = ? AND version = ?';
+    $version_data = $news->db->getRow($sql, array($id, $version), DB_FETCHMODE_ASSOC);
+    if (empty($version_data)) {
+        $notification->push(_("There requested version don't exist."), 'horde.error');
+        exit;
+    } else {
+        $version_data['content'] = unserialize($version_data['content']);
+        $row['content'] = $version_data['content'][NLS::select()]['content'];
+        $row['title'] = $version_data['content'][NLS::select()]['title'] .
+                        '<span class="small"> - v.' . $version . ' from ' . $version_data['user_uid'] .
+                        ' @ ' . $version_data['created'] . ' </span>';
+    }
+} else {
+    $news->logView($id);
+}
+
+$title = $row['title'];
+$template_path = News::getTemplatePath($row['category1'], 'news');
+$browse_url = Horde::applicationUrl('browse.php');
+$news_url = Horde::applicationUrl('news.php', true);
+
+Horde::addScriptFile('popup.js', 'horde', true);
+require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/menu.inc';
+
+require $template_path . 'news.php';
+
+require_once $registry->get('templates', 'horde') . '/common-footer.inc';
+
diff --git a/news/note.php b/news/note.php
new file mode 100644 (file)
index 0000000..741a166
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * News
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: note.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$id = Util::getFormData('id');
+$row = $news->get($id);
+if ($row instanceof PEAR_Error) {
+    $notification->push($row->getMessage(), 'horde.error');
+    header('Location: ' . Horde::applicationUrl('browse.php'));
+    exit;
+}
+
+$news_url = Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $id);
+$body = $row['title'] . "\n\n"
+       . _("On") . ': ' . $news->dateFormat($row['publish']) . "\n"
+       . _("Link") . ': ' . $news_url . "\n\n"
+       . strip_tags($row['content']);
+
+/* Create a new vNote object using this message's contents. */
+$vCal = new Horde_iCalendar();
+$vNote = &Horde_iCalendar::newComponent('vnote', $vCal);
+$vNote->setAttribute('BODY', $body);
+
+/* Attempt to add the new vNote item to the requested notepad. */
+$res = $registry->call('notes/import', array($vNote, 'text/x-vnote'));
+
+if ($res instanceof PEAR_Error) {
+    $notification->push($res->getMessage(), 'horde.error');
+    header('Location: ' . $news_url);
+    exit;
+} else {
+    $notification->push(_("News sucessfuly added to you notes."), 'horde.success');
+    header('Location: ' . $registry->getInitialPage('mnemo'));
+    exit;
+}
diff --git a/news/pdf.php b/news/pdf.php
new file mode 100644 (file)
index 0000000..832eaac
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * News
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: pdf.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+require_once 'File/PDF.php';
+
+$id = Util::getFormData('id');
+$row = $news->get($id);
+
+// check if the news eyists
+if ($row instanceof PEAR_Error) {
+    $notification->push($row->getMessage(), 'horde.error');
+    header('Location: ' . Horde::applicationUrl('browse.php'));
+    exit;
+}
+
+/* Set up the PDF object. */
+$pdf = File_PDF::factory(array('orientation' => 'P', 'unit' => 'mm', 'format' => 'A4'));
+$pdf->setMargins(5, 5, 20);
+
+/* Enable automatic page breaks. */
+$pdf->setAutoPageBreak(true, 50);
+
+/* Start the document. */
+$pdf->open();
+
+/* Start a page. */
+$pdf->addPage();
+
+/* Write the header in Times 24 Bold. */
+@$pdf->setFont('timesce', '', 20);
+$pdf->multiCell(0, 20, $row['title']);
+$pdf->newLine(1);
+
+/* News data */
+$news_url = Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $id);
+$body = _("On") . ': ' . $news->dateFormat($row['publish']) . "\n"
+       . _("Link") . ': ' . $news_url . "\n"
+      . iconv('utf-8', 'cp1250', strip_tags($row['content']));
+
+/* Write the note body in Times 14. */
+$pdf->setFont('timesce', '', 12);
+$pdf->write(12, $body);
+
+/* Output the generated PDF. */
+$browser->downloadHeaders($id . '.pdf', 'application/pdf');
+echo $pdf->getOutput();
diff --git a/news/po/messages.mo b/news/po/messages.mo
new file mode 100644 (file)
index 0000000..e54f6c9
Binary files /dev/null and b/news/po/messages.mo differ
diff --git a/news/po/news.pot b/news/po/news.pot
new file mode 100644 (file)
index 0000000..6f01c3f
--- /dev/null
@@ -0,0 +1,875 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Horde Project
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
+"POT-Creation-Date: 2008-03-30 19:15+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: templates/edit/info.inc:86 templates/edit/info.php:91
+msgid " at "
+msgstr ""
+
+#: templates/edit/info.inc:86 templates/edit/info.php:91
+msgid " by "
+msgstr ""
+
+#: content_edit.php:28
+#, php-format
+msgid "%s :: Add Content"
+msgstr ""
+
+#: mail.php:51
+#, php-format
+msgid ""
+"%s would you like to invite you to read the news\n"
+" Title: %s\n"
+"\n"
+" Published: %s \n"
+"Link: %s"
+msgstr ""
+
+#: templates/news/news.php:18
+msgid "* Sponsored news"
+msgstr ""
+
+#: add.php:87 add.php:94 add.php:142
+msgid "-- select --"
+msgstr ""
+
+#: templates/edit/header.inc:5
+msgid "Action"
+msgstr ""
+
+#: templates/edit/row.php:20
+msgid "Activate"
+msgstr ""
+
+#: lib/News.php:1048
+msgid "Add"
+msgstr ""
+
+#: content.php:24
+msgid "Add Content"
+msgstr ""
+
+#: admin/categories/index.php:40 admin/sources/index.php:42
+msgid "Add New"
+msgstr ""
+
+#: lib/Categories.php:474 lib/Categories.php:488
+msgid "Add New Item"
+msgstr ""
+
+#: admin/sources/edit.php:19
+msgid "Add Source"
+msgstr ""
+
+#: admin/categories/edit.php:18
+msgid "Add category"
+msgstr ""
+
+#: add.php:69
+msgid "Add news"
+msgstr ""
+
+#: templates/news/tools.php:16
+msgid "Add to bookmarks."
+msgstr ""
+
+#: templates/news/tools.php:22
+msgid "Add to notes."
+msgstr ""
+
+#: add.php:141
+msgid "Additional news attributes"
+msgstr ""
+
+#: lib/api.php:52
+msgid "Admin"
+msgstr ""
+
+#: lib/News.php:1056
+msgid "Administration"
+msgstr ""
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "Allow comments"
+msgstr ""
+
+#: lib/News.php:1046
+msgid "Archive"
+msgstr ""
+
+#: delete.php:25
+msgid "Are you sure you want to delete this news?"
+msgstr ""
+
+#: lib/Forms/Search.php:39
+msgid "Ascending"
+msgstr ""
+
+#: config/prefs.php.dist:40
+msgid "Ascesending"
+msgstr ""
+
+#: lib/News.php:175
+msgid "Attached files: "
+msgstr ""
+
+#: edit.php:51
+msgid "Attachment deleted"
+msgstr ""
+
+#: add.php:214 lib/Forms/Search.php:36
+msgid "Attachments"
+msgstr ""
+
+#: add.php:140
+msgid "Attributes"
+msgstr ""
+
+#: templates/news/info.php:10
+msgid "Besed"
+msgstr ""
+
+#: trackback.php:67
+#, php-format
+msgid "Blog entry %s does not exist."
+msgstr ""
+
+#: templates/news/blog.php:3
+msgid "Blogs"
+msgstr ""
+
+#: browse.php:20 search.php:21
+msgid "Browse"
+msgstr ""
+
+#: templates/news/info.php:4
+msgid "By"
+msgstr ""
+
+#: delete.php:26 admin/categories/delete.php:18 admin/sources/delete.php:19
+msgid "Cancel"
+msgstr ""
+
+#: add.php:387
+#, php-format
+msgid "Cannot access file %s"
+msgstr ""
+
+#: admin/tabs.php:27 lib/api.php:60 lib/Block/categories.php:3
+#: lib/Block/categories.php:21 templates/categories/edit.html:5
+#: templates/categories/index.html:4 templates/categories/delete.html:5
+msgid "Categories"
+msgstr ""
+
+#: templates/menu.inc:4 templates/news/info.php:6 lib/Forms/Search.php:29
+#: lib/Block/category.php:35
+msgid "Category"
+msgstr ""
+
+#: admin/categories/index.php:25
+msgid "Category Administration"
+msgstr ""
+
+#: admin/categories/delete.php:29
+msgid "Category deleted."
+msgstr ""
+
+#: admin/categories/edit.php:46
+#, php-format
+msgid "Category succesfully saved."
+msgstr ""
+
+#: admin/categories/delete.php:27 admin/categories/delete.php:32
+msgid "Category was not deleted."
+msgstr ""
+
+#: templates/browse/row.inc:9 templates/news/info.php:9
+msgid "Chars"
+msgstr ""
+
+#: templates/browse/row.inc:10 templates/edit/header.inc:13
+#: lib/Forms/Search.php:34
+msgid "Comments"
+msgstr ""
+
+#: lib/News.php:411
+msgid "Comments are not supported."
+msgstr ""
+
+#: lib/News.php:185
+#, php-format
+msgid "Compress and dowload %s"
+msgstr ""
+
+#: lib/News.php:174
+msgid "Compress and dowload all files at once"
+msgstr ""
+
+#: templates/edit/row.php:43 lib/Forms/Search.php:24
+msgid "Confirmed"
+msgstr ""
+
+#: add.php:82 add.php:112
+msgid "Content"
+msgstr ""
+
+#: templates/reads/header.inc:8
+msgid "Date"
+msgstr ""
+
+#: templates/edit/row.php:17
+msgid "Deactivate"
+msgstr ""
+
+#: templates/edit/row.php:23 admin/categories/index.php:29
+#: admin/categories/index.php:32 admin/sources/index.php:27
+#: admin/sources/index.php:34
+msgid "Delete"
+msgstr ""
+
+#: add.php:101
+msgid "Delete existing picture"
+msgstr ""
+
+#: lib/Forms/Search.php:38
+msgid "Descending"
+msgstr ""
+
+#: config/prefs.php.dist:39
+msgid "Descesending"
+msgstr ""
+
+#: templates/categories/index.php:8 admin/categories/edit.php:32
+msgid "Description"
+msgstr ""
+
+#: diff.php:18 templates/edit/info.inc:95 templates/edit/info.php:100
+msgid "Diff"
+msgstr ""
+
+#: add.php:175
+msgid "Disallow comments"
+msgstr ""
+
+#: admin/categories/delete.php:17
+msgid "Do you really wont to delete this category?"
+msgstr ""
+
+#: admin/sources/delete.php:18
+msgid "Do you really wont to delete this source?"
+msgstr ""
+
+#: lib/News.php:169
+msgid "Dowload"
+msgstr ""
+
+#: lib/News.php:186
+#, php-format
+msgid "Dowload %s"
+msgstr ""
+
+#: lib/News.php:170
+msgid "Dowload Zip Compressed"
+msgstr ""
+
+#: edit.php:123 templates/edit/row.php:6 templates/edit/row.php:7
+#: admin/categories/index.php:27 admin/categories/index.php:34
+#: admin/sources/index.php:25 admin/sources/index.php:36
+msgid "Edit"
+msgstr ""
+
+#: admin/sources/edit.php:19
+msgid "Edit Source"
+msgstr ""
+
+#: admin/categories/edit.php:18
+msgid "Edit category"
+msgstr ""
+
+#: templates/edit/info.inc:75 templates/edit/info.php:80
+msgid "Edit history: "
+msgstr ""
+
+#: add.php:434
+msgid "Edit news"
+msgstr ""
+
+#: templates/edit/info.inc:25 templates/edit/info.php:25
+#: lib/Forms/Search.php:46
+msgid "Editor"
+msgstr ""
+
+#: lib/api.php:55
+msgid "Editors"
+msgstr ""
+
+#: lib/News.php:1055
+msgid "Editorship"
+msgstr ""
+
+#: add.php:144
+msgid "Enter news ids separated by commas."
+msgstr ""
+
+#: add.php:110
+msgid ""
+"Enter one or more keywords that describe your news. Separate them by spaces."
+msgstr ""
+
+#: add.php:147
+msgid "Enter threads separated by commas."
+msgstr ""
+
+#: templates/news/today.php:11
+msgid "Events on this day."
+msgstr ""
+
+#: files.php:56
+#, php-format
+msgid "FilesOfNews-%s"
+msgstr ""
+
+#: add.php:206
+msgid "Form ID"
+msgstr ""
+
+#: add.php:207
+msgid "Form to"
+msgstr ""
+
+#: templates/news/blog.php:10
+msgid "From: "
+msgstr ""
+
+#: add.php:156 add.php:163
+msgid "Gallery"
+msgstr ""
+
+#: lib/Block/most_commented.php:26 lib/Block/most_read.php:26
+msgid "How many days back to check?"
+msgstr ""
+
+#: lib/Block/last_blogs.php:23 lib/Block/most_commented.php:23
+#: lib/Block/most_read.php:23 lib/Block/last.php:25 lib/Block/category.php:32
+msgid "How many news to display?"
+msgstr ""
+
+#: config/prefs.php.dist:20
+msgid "How many news to show per page"
+msgstr ""
+
+#: config/prefs.php.dist:10
+msgid "How to preview news"
+msgstr ""
+
+#: templates/reads/header.inc:7
+msgid "IP"
+msgstr ""
+
+#: templates/categories/index.php:5 templates/sources/index.php:5
+#: lib/Forms/Search.php:32 config/prefs.php.dist:29
+msgid "Id"
+msgstr ""
+
+#: admin/categories/edit.php:38 admin/sources/edit.php:37
+msgid "Image"
+msgstr ""
+
+#: templates/edit/row.php:9 templates/edit/row.php:10
+msgid "Info"
+msgstr ""
+
+#: templates/edit/info.inc:83 templates/edit/info.php:88
+msgid "Insert"
+msgstr ""
+
+#: templates/common-header.inc:27 rss/index.php:44 rss/comments.php:22
+#: lib/Block/last_comments.php:3 lib/Block/last_comments.php:31
+msgid "Last comments"
+msgstr ""
+
+#: lib/Block/my_comments.php:3
+msgid "Last comments on my news"
+msgstr ""
+
+#: lib/Block/most_commented.php:3 lib/Block/most_commented.php:17
+msgid "Last most commented news"
+msgstr ""
+
+#: lib/Block/most_read.php:3 lib/Block/most_read.php:17
+msgid "Last most read news"
+msgstr ""
+
+#: templates/common-header.inc:26 rss/index.php:38 rss/news.php:33
+#: lib/Block/last.php:3 lib/Block/last.php:17
+#, php-format
+msgid "Last news"
+msgstr ""
+
+#: lib/Block/last_blogs.php:17
+msgid "Last news blog"
+msgstr ""
+
+#: lib/Block/last_blogs.php:3
+msgid "Last news blogged"
+msgstr ""
+
+#: lib/Block/category.php:21 lib/Block/category.php:22
+#, php-format
+msgid "Last news in %s"
+msgstr ""
+
+#: lib/Block/category.php:3
+msgid "Last news in category"
+msgstr ""
+
+#: note.php:29 pdf.php:51
+msgid "Link"
+msgstr ""
+
+#: templates/edit/row.php:30
+msgid "Lock"
+msgstr ""
+
+#: templates/edit/row.php:44 lib/Forms/Search.php:25
+msgid "Locked"
+msgstr ""
+
+#: templates/categories/index.php:6 templates/sources/index.php:6
+#: admin/categories/edit.php:31 admin/sources/edit.php:32
+msgid "Name"
+msgstr ""
+
+#: templates/reads/header.inc:5
+msgid "News"
+msgstr ""
+
+#: reads.php:33
+#, php-format
+msgid "News %s"
+msgstr ""
+
+#: edit.php:51 edit.php:59 edit.php:67 edit.php:75 edit.php:83 edit.php:116
+#: delete.php:55 delete.php:57
+#, php-format
+msgid "News %s: %s"
+msgstr ""
+
+#: add.php:422
+msgid ""
+"News added. The editors will check the entry and confirm it if they find it "
+"suitable."
+msgstr ""
+
+#: add.php:83
+msgid "News content"
+msgstr ""
+
+#: templates/news/info.php:3
+msgid "News data"
+msgstr ""
+
+#: templates/news/today.php:5
+msgid "News of this day."
+msgstr ""
+
+#: add.php:424
+msgid "News published."
+msgstr ""
+
+#: mail.php:63
+#, php-format
+msgid "News succesfully send to %s"
+msgstr ""
+
+#: note.php:45
+msgid "News sucessfuly added to you notes."
+msgstr ""
+
+#: add.php:426
+msgid "News updated."
+msgstr ""
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "No"
+msgstr ""
+
+#: diff.php:59
+msgid "No change."
+msgstr ""
+
+#: mail.php:41
+msgid "No mail entered."
+msgstr ""
+
+#: lib/Block/my_comments.php:19 lib/Block/last_comments.php:19
+msgid "Number of comments to display"
+msgstr ""
+
+#: note.php:28 pdf.php:50 templates/news/info.php:5
+msgid "On"
+msgstr ""
+
+#: templates/news/today.php:3
+msgid "On this day"
+msgstr ""
+
+#: delete.php:16
+msgid "Only admin can delete a news."
+msgstr ""
+
+#: add.php:64
+msgid "Only authenticated users can post news."
+msgstr ""
+
+#: mail.php:36
+msgid "Only authenticated users can send mails."
+msgstr ""
+
+#: lib/Forms/Search.php:31
+msgid "Order by"
+msgstr ""
+
+#: lib/News.php:1044
+msgid "Overview"
+msgstr ""
+
+#: templates/news/tools.php:9
+msgid "PDF"
+msgstr ""
+
+#: templates/categories/index.php:7 admin/categories/edit.php:35
+msgid "Parent"
+msgstr ""
+
+#: add.php:144 templates/news/parents.php:5 templates/edit/info.inc:33
+#: templates/edit/info.php:33
+msgid "Parents"
+msgstr ""
+
+#: add.php:99
+msgid "Picture"
+msgstr ""
+
+#: add.php:108
+msgid "Picture comment"
+msgstr ""
+
+#: add.php:101
+msgid "Picture delete"
+msgstr ""
+
+#: lib/Block/jonah.php:4 lib/Block/jonah.php:24
+msgid "Press overview"
+msgstr ""
+
+#: config/prefs.php.dist:9
+msgid "Preview"
+msgstr ""
+
+#: lib/News.php:187
+#, php-format
+msgid "Preview %s"
+msgstr ""
+
+#: add.php:87 templates/edit/info.inc:10 templates/edit/info.php:10
+msgid "Primary category"
+msgstr ""
+
+#: templates/news/tools.php:6
+msgid "Printer firendly"
+msgstr ""
+
+#: add.php:85 lib/Forms/Search.php:41
+msgid "Publish"
+msgstr ""
+
+#: templates/edit/header.inc:8
+msgid "Publish at"
+msgstr ""
+
+#: lib/Forms/Search.php:31 config/prefs.php.dist:28
+msgid "Publish date"
+msgstr ""
+
+#: templates/news/parents.php:8 templates/edit/row.php:48
+msgid "Read"
+msgstr ""
+
+#: templates/edit/header.inc:10 lib/Forms/Search.php:35
+msgid "Reads"
+msgstr ""
+
+#: delete.php:26 delete.php:33 admin/categories/delete.php:18
+#: admin/categories/delete.php:24 admin/sources/delete.php:19
+#: admin/sources/delete.php:25
+msgid "Remove"
+msgstr ""
+
+#: templates/edit/info.inc:92 templates/edit/info.php:97
+msgid "Renew"
+msgstr ""
+
+#: add.php:482
+msgid "Reset"
+msgstr ""
+
+#: admin/categories/edit.php:36 admin/sources/edit.php:35
+msgid "Resize Image"
+msgstr ""
+
+#: add.php:77
+msgid "Save"
+msgstr ""
+
+#: lib/News.php:1047 lib/Forms/Search.php:17 lib/Forms/Search.php:19
+msgid "Search"
+msgstr ""
+
+#: lib/Forms/Search.php:21
+msgid "Search world"
+msgstr ""
+
+#: add.php:142 templates/edit/info.inc:13 templates/edit/info.php:13
+msgid "Secondary category"
+msgstr ""
+
+#: lib/Categories.php:481
+msgid "Select Category"
+msgstr ""
+
+#: lib/Block/jonah.php:35
+msgid "Select a feed."
+msgstr ""
+
+#: add.php:214
+msgid "Select files"
+msgstr ""
+
+#: add.php:195 templates/edit/info.inc:47 templates/edit/info.php:47
+msgid "Selling item"
+msgstr ""
+
+#: templates/news/mail.php:2
+msgid "Send by mail"
+msgstr ""
+
+#: lib/News.php:101
+msgid "Services/Trackback is not installed."
+msgstr ""
+
+#: config/prefs.php.dist:11
+msgid "Set news previerw paramaters"
+msgstr ""
+
+#: lib/Block/last.php:28
+msgid "Skip category"
+msgstr ""
+
+#: config/prefs.php.dist:31 config/prefs.php.dist:41
+msgid "Sort news by"
+msgstr ""
+
+#: add.php:143 templates/edit/info.inc:29 templates/edit/info.php:29
+#: lib/Forms/Search.php:38
+msgid "Sort order"
+msgstr ""
+
+#: add.php:94 templates/edit/info.inc:37 templates/edit/info.php:37
+msgid "Source"
+msgstr ""
+
+#: admin/sources/delete.php:30
+msgid "Source deleted."
+msgstr ""
+
+#: add.php:96 templates/edit/info.inc:41 templates/edit/info.php:41
+msgid "Source link"
+msgstr ""
+
+#: templates/news/info.php:18
+msgid "Source media"
+msgstr ""
+
+#: templates/news/info.php:13
+msgid "Source news"
+msgstr ""
+
+#: admin/sources/edit.php:45
+msgid "Source saved succesfully."
+msgstr ""
+
+#: admin/sources/delete.php:28 admin/sources/delete.php:33
+msgid "Source was not deleted."
+msgstr ""
+
+#: admin/tabs.php:26 lib/Block/sources.php:3 lib/Block/sources.php:21
+msgid "Sources"
+msgstr ""
+
+#: admin/sources/index.php:17
+msgid "Sources Administration"
+msgstr ""
+
+#: add.php:170
+msgid "Sponsored"
+msgstr ""
+
+#: templates/edit/header.inc:6 lib/Forms/Search.php:26
+msgid "Status"
+msgstr ""
+
+#: lib/News.php:1051
+msgid "Tag cloud"
+msgstr ""
+
+#: add.php:110 lib/Block/tags_cloud.php:3 lib/Block/tags_cloud.php:24
+msgid "Tags"
+msgstr ""
+
+#: templates/news/blog.php:7
+msgid "Talkbacks to this article:"
+msgstr ""
+
+#: templates/news/ulaform.php:13
+msgid "Thanks"
+msgstr ""
+
+#: templates/block/news.php:18 templates/block/titles.php:20
+msgid "There are no news to display."
+msgstr ""
+
+#: lib/News.php:482
+#, php-format
+msgid "There requested news %s don't exist."
+msgstr ""
+
+#: news.php:34
+msgid "There requested version don't exist."
+msgstr ""
+
+#: add.php:147 templates/news/threads.php:6
+#, php-format
+msgid "Threads in %s"
+msgstr ""
+
+#: add.php:107 templates/edit/header.inc:7 lib/Forms/Search.php:33
+#: lib/Block/my_comments.php:56 config/prefs.php.dist:30
+msgid "Title"
+msgstr ""
+
+#: templates/news/tools.php:3
+msgid "Tools"
+msgstr ""
+
+#: templates/news/blog.php:22
+msgid "Trackback this blog on this site."
+msgstr ""
+
+#: lib/News.php:628
+#, php-format
+msgid "URL already trackbacked: %s"
+msgstr ""
+
+#: templates/edit/row.php:42 lib/Forms/Search.php:23
+msgid "Unconfirmed"
+msgstr ""
+
+#: templates/edit/row.php:27
+msgid "Unlock"
+msgstr ""
+
+#: lib/Forms/Search.php:42
+msgid "Unpublish"
+msgstr ""
+
+#: templates/edit/info.inc:17 templates/edit/info.php:17
+msgid "Unpublish date"
+msgstr ""
+
+#: add.php:481 templates/edit/info.inc:81 templates/edit/info.php:86
+msgid "Update"
+msgstr ""
+
+#: templates/sources/index.php:7 admin/sources/edit.php:33
+msgid "Url"
+msgstr ""
+
+#: templates/news/blog.php:16
+msgid "Use the following link to trackback from your own site: "
+msgstr ""
+
+#: templates/reads/header.inc:6 templates/edit/header.inc:9
+#: lib/Forms/Search.php:43 lib/Block/my_comments.php:57
+msgid "User"
+msgstr ""
+
+#: templates/edit/info.inc:89 templates/edit/info.php:94
+msgid "View"
+msgstr ""
+
+#: admin/sources/index.php:32
+msgid "View articles"
+msgstr ""
+
+#: admin/sources/index.php:29
+msgid "View items"
+msgstr ""
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "Yes"
+msgstr ""
+
+#: admin/tabs.php:15
+msgid "You are not authorised for this action."
+msgstr ""
+
+#: mail.php:47
+msgid "You have no email set."
+msgstr ""
+
+#: edit.php:24
+msgid "You have not editor permission on any category."
+msgstr ""
+
+#: edit.php:67
+msgid "activated"
+msgstr ""
+
+#: edit.php:59
+msgid "deactivated"
+msgstr ""
+
+#: delete.php:55
+msgid "deleted"
+msgstr ""
+
+#: edit.php:75
+msgid "locked"
+msgstr ""
+
+#: delete.php:57
+msgid "not deleted"
+msgstr ""
+
+#: edit.php:116
+msgid "renewed"
+msgstr ""
+
+#: edit.php:83
+msgid "unlocked"
+msgstr ""
diff --git a/news/po/sl_SI.po b/news/po/sl_SI.po
new file mode 100644 (file)
index 0000000..2e8a846
--- /dev/null
@@ -0,0 +1,870 @@
+# translation of sl_SI.po to Slovene
+# Marko Milost <marko.milost@obala.si>, 2007, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: sl_SI\n"
+"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
+"POT-Creation-Date: 2008-01-15 13:59+0100\n"
+"PO-Revision-Date: 2008-01-15 14:13+0100\n"
+"Last-Translator: Marko Milost <marko.milost@obala.si>\n"
+"Language-Team: Slovene <sl@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.4\n"
+"Plural-Forms:  nplurals=3;\n"
+
+#: templates/edit/info.inc:86 templates/edit/info.php:91
+msgid " at "
+msgstr " ob "
+
+#: templates/edit/info.inc:86 templates/edit/info.php:91
+msgid " by "
+msgstr " od "
+
+#: content_edit.php:28
+#, php-format
+msgid "%s :: Add Content"
+msgstr "%s :: Dodaj vsebino"
+
+#: mail.php:51
+#, php-format
+msgid ""
+"%s would you like to invite you to read the news\n"
+" Title: %s\n"
+"\n"
+" Published: %s \n"
+"Link: %s"
+msgstr ""
+"%s vas vabi, da si preberete to novico\n"
+"\n"
+" Naslov: %s\n"
+" Objavljeno: %s\n"
+" Povezava: %s"
+
+#: templates/news/news.inc:18 templates/news/news.php:18
+msgid "* Sponsored news"
+msgstr "* Komercialna objava"
+
+#: add.php:87 add.php:94 add.php:142
+msgid "-- select --"
+msgstr "-- izberi --"
+
+#: templates/edit/header.inc:5
+msgid "Action"
+msgstr "Ukaz"
+
+#: templates/edit/row.inc:20 templates/edit/row.php:20
+msgid "Activate"
+msgstr "Aktiviraj"
+
+#: lib/News.php:451
+msgid "Add"
+msgstr "Vpis"
+
+#: content.php:23
+msgid "Add Content"
+msgstr "Dodaj vsebino"
+
+#: admin/categories/index.php:40 admin/sources/index.php:42
+msgid "Add New"
+msgstr "Dodaj novo"
+
+#: admin/sources/edit.php:19
+msgid "Add Source"
+msgstr "Dodaj vir"
+
+#: admin/categories/edit.php:18
+msgid "Add category"
+msgstr "Dodaj kategorije"
+
+#: add.php:69
+msgid "Add news"
+msgstr "Dodaj novice"
+
+#: templates/news/tools.inc:16 templates/news/tools.php:16
+msgid "Add to bookmarks."
+msgstr "Dodaj med priljubljene"
+
+#: templates/news/tools.inc:22 templates/news/tools.php:22
+msgid "Add to notes."
+msgstr "Dodaj med zapiske"
+
+#: add.php:141
+msgid "Additional news attributes"
+msgstr "Dodatne lastnosti novice"
+
+#: lib/api.php:52
+msgid "Admin"
+msgstr "Administracija"
+
+#: lib/News.php:459
+msgid "Administration"
+msgstr "Administracija"
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "Allow comments"
+msgstr "Dovoli komentarje"
+
+#: lib/News.php:449
+msgid "Archive"
+msgstr "Arhiv"
+
+#: delete.php:25
+msgid "Are you sure you want to delete this news?"
+msgstr "Resnično želite izbrisati to novico?"
+
+#: lib/Forms/Search.php:40
+msgid "Ascending"
+msgstr "Naraščajoče"
+
+#: config/prefs.php.dist:40
+msgid "Ascesending"
+msgstr "Naraščajoče"
+
+#: lib/News.php:175
+msgid "Attached files: "
+msgstr "Pripete datoteke: "
+
+#: edit.php:51
+msgid "Attachment deleted"
+msgstr "Pripeta datoteka je bila izbrisana"
+
+#: add.php:214 lib/Forms/Search.php:37
+msgid "Attachments"
+msgstr "Pripete datoteke"
+
+#: add.php:140
+msgid "Attributes"
+msgstr "Lastnosti"
+
+#: templates/news/info.inc:10 templates/news/info.php:10
+msgid "Besed"
+msgstr "Besed"
+
+#: trackback.php:67
+#, php-format
+msgid "Blog entry %s does not exist."
+msgstr "Blog vpis %s ne obstaja."
+
+#: templates/news/blog.inc:3 templates/news/blog.php:3
+msgid "Blogs"
+msgstr "Blogi"
+
+#: browse.php:20 search.php:21
+msgid "Browse"
+msgstr "Prebrskaj"
+
+#: templates/news/info.inc:4 templates/news/info.php:4
+msgid "By"
+msgstr "Od"
+
+#: delete.php:26 admin/categories/delete.php:18 admin/sources/delete.php:19
+msgid "Cancel"
+msgstr "Prekliči"
+
+#: add.php:387
+#, php-format
+msgid "Cannot access file %s"
+msgstr "Ne morem odpreti datoteke %s"
+
+#: admin/tabs.php:27 lib/api.php:60 lib/Block/categories.php:3
+#: lib/Block/categories.php:21 templates/categories/edit.html:5
+#: templates/categories/index.html:4 templates/categories/delete.html:5
+msgid "Categories"
+msgstr "Kategorije"
+
+#: lib/Forms/Search.php:30 lib/Block/category.php:35 templates/menu.inc:4
+#: templates/news/info.inc:6 templates/news/info.php:6
+msgid "Category"
+msgstr "Kategorija"
+
+#: admin/categories/index.php:25
+msgid "Category Administration"
+msgstr "Urejanje kategorij"
+
+#: admin/categories/delete.php:29
+msgid "Category deleted."
+msgstr "Kategorija je bila izbrisana."
+
+#: admin/categories/edit.php:44
+#, php-format
+msgid "Category succesfully saved."
+msgstr "Kategorija je bila uspešno shranjena."
+
+#: admin/categories/delete.php:27 admin/categories/delete.php:32
+msgid "Category was not deleted."
+msgstr "Kategorija ni bila izbrisana."
+
+#: templates/browse/row.inc:9 templates/news/info.inc:9
+#: templates/news/info.php:9
+msgid "Chars"
+msgstr "Znakov"
+
+#: lib/Forms/Search.php:35 templates/browse/row.inc:10
+#: templates/edit/header.inc:13
+msgid "Comments"
+msgstr "Komentarjev"
+
+#: lib/News.php:411
+msgid "Comments are not supported."
+msgstr "Komentarji niso podprti."
+
+#: lib/News.php:185
+#, php-format
+msgid "Compress and dowload %s"
+msgstr "Kompresiraj in prenesi datoteko %s"
+
+#: lib/News.php:174
+msgid "Compress and dowload all files at once"
+msgstr "Kompresiraj in prenesi vse datoteke naenkrat"
+
+#: lib/Forms/Search.php:25 templates/edit/row.inc:43 templates/edit/row.php:43
+msgid "Confirmed"
+msgstr "Potrjena"
+
+#: add.php:82 add.php:112
+msgid "Content"
+msgstr "Vsebina"
+
+#: templates/reads/header.inc:8
+msgid "Date"
+msgstr "Datum"
+
+#: templates/edit/row.inc:17 templates/edit/row.php:17
+msgid "Deactivate"
+msgstr "Deaktiviraj"
+
+#: admin/categories/index.php:29 admin/categories/index.php:32
+#: admin/sources/index.php:27 admin/sources/index.php:34
+#: templates/edit/row.inc:23 templates/edit/row.php:23
+msgid "Delete"
+msgstr "Izbriši"
+
+#: add.php:101
+msgid "Delete existing picture"
+msgstr "Zbriši obstoječo sliko"
+
+#: lib/Forms/Search.php:39
+msgid "Descending"
+msgstr "Padajoče"
+
+#: config/prefs.php.dist:39
+msgid "Descesending"
+msgstr "Padajoče"
+
+#: admin/categories/edit.php:31 templates/categories/index.php:8
+msgid "Description"
+msgstr "Opis"
+
+#: diff.php:18 templates/edit/info.inc:95 templates/edit/info.php:100
+msgid "Diff"
+msgstr "Razlike"
+
+#: add.php:175
+msgid "Disallow comments"
+msgstr "Ne dovoli komentarjev"
+
+#: admin/categories/delete.php:17
+msgid "Do you really wont to delete this category?"
+msgstr "Resnično želite izbrisati izbrano kategorijo?"
+
+#: admin/sources/delete.php:18
+msgid "Do you really wont to delete this source?"
+msgstr "Resnično želite izbrisati ta vir?"
+
+#: lib/News.php:169
+msgid "Dowload"
+msgstr "Prenesi"
+
+#: lib/News.php:186
+#, php-format
+msgid "Dowload %s"
+msgstr "Prenesi datoteko %s"
+
+#: lib/News.php:170
+msgid "Dowload Zip Compressed"
+msgstr "Presnemi Zip kompresirano datoteko"
+
+#: edit.php:123 admin/categories/index.php:27 admin/categories/index.php:34
+#: admin/sources/index.php:25 admin/sources/index.php:36
+#: templates/edit/row.inc:6 templates/edit/row.inc:7 templates/edit/row.php:6
+#: templates/edit/row.php:7
+msgid "Edit"
+msgstr "Uredi"
+
+#: admin/sources/edit.php:19
+msgid "Edit Source"
+msgstr "Uredi vir"
+
+#: admin/categories/edit.php:18
+msgid "Edit category"
+msgstr "Uredi kategoijo"
+
+#: templates/edit/info.inc:75 templates/edit/info.php:80
+msgid "Edit history: "
+msgstr "Zgodovina urejanja:"
+
+#: add.php:434
+msgid "Edit news"
+msgstr "Uredi novico"
+
+#: lib/Forms/Search.php:47 templates/edit/info.inc:25
+#: templates/edit/info.php:25
+msgid "Editor"
+msgstr "Urednik"
+
+#: lib/api.php:55
+msgid "Editors"
+msgstr "Uredniki"
+
+#: lib/News.php:458
+msgid "Editorship"
+msgstr "Uredništvo"
+
+#: add.php:144
+msgid "Enter news ids separated by commas."
+msgstr "Vnesi id-je novic ločene z vejico."
+
+#: add.php:110
+msgid "Enter one or more keywords that describe your news. Separate them by spaces."
+msgstr ""
+
+#: add.php:147
+msgid "Enter threads separated by commas."
+msgstr "Vnesi id-je debat ločene z vejico."
+
+#: templates/news/today.inc:11 templates/news/today.php:11
+msgid "Events on this day."
+msgstr "Dogodki tega dne"
+
+#: files.php:56
+#, php-format
+msgid "FilesOfNews-%s"
+msgstr "DatotekeNovice-%s"
+
+#: add.php:206
+msgid "Form ID"
+msgstr "Formular"
+
+#: add.php:207
+msgid "Form to"
+msgstr "Veljavnost formularja "
+
+#: templates/news/blog.inc:10 templates/news/blog.php:10
+msgid "From: "
+msgstr "Od: "
+
+#: add.php:156 add.php:163
+msgid "Gallery"
+msgstr "Galerija"
+
+#: lib/Block/most_commented.php:26 lib/Block/most_read.php:26
+msgid "How many days back to check?"
+msgstr "Koliko dni stare novice naj pregledam?"
+
+#: lib/Block/last_blogs.php:23 lib/Block/most_commented.php:23
+#: lib/Block/most_read.php:23 lib/Block/last.php:25 lib/Block/category.php:32
+msgid "How many news to display?"
+msgstr "Koliko novic naj pikažem?"
+
+#: config/prefs.php.dist:20
+msgid "How many news to show per page"
+msgstr "Koliko novic naj pikažem na stran?"
+
+#: config/prefs.php.dist:10
+msgid "How to preview news"
+msgstr "Kako naj prikažem novice"
+
+#: templates/reads/header.inc:7
+msgid "IP"
+msgstr "ID"
+
+#: lib/Forms/Search.php:33 templates/categories/index.php:5
+#: templates/sources/index.php:5 config/prefs.php.dist:29
+msgid "Id"
+msgstr "Id"
+
+#: admin/categories/edit.php:36 admin/sources/edit.php:37
+msgid "Image"
+msgstr "Slika"
+
+#: templates/edit/row.inc:9 templates/edit/row.inc:10 templates/edit/row.php:9
+#: templates/edit/row.php:10
+msgid "Info"
+msgstr "Info"
+
+#: templates/edit/info.inc:83 templates/edit/info.php:88
+msgid "Insert"
+msgstr "Dodana"
+
+#: lib/Block/last_comments.php:3 lib/Block/last_comments.php:31
+#: templates/common-header.inc:27
+msgid "Last comments"
+msgstr "Zadnji komentarji"
+
+#: lib/Block/most_commented.php:3 lib/Block/most_commented.php:17
+msgid "Last most commented news"
+msgstr "Zadnje najbolj komentirane"
+
+#: lib/Block/most_read.php:3 lib/Block/most_read.php:17
+msgid "Last most read news"
+msgstr "Zadnje najbolj brane"
+
+#: lib/Block/last.php:3 lib/Block/last.php:17 templates/common-header.inc:26
+msgid "Last news"
+msgstr "Zadnje novice"
+
+#: lib/Block/last_blogs.php:17
+msgid "Last news blog"
+msgstr "Zadnje novice z blogi"
+
+#: lib/Block/last_blogs.php:3
+msgid "Last news blogged"
+msgstr "Zadnje novice z blogi"
+
+#: lib/Block/category.php:21 lib/Block/category.php:22
+#, php-format
+msgid "Last news in %s"
+msgstr "Zadnje novice v %s"
+
+#: lib/Block/category.php:3
+msgid "Last news in category"
+msgstr "Zadnje novice v kategoriji"
+
+#: note.php:29 pdf.php:51
+msgid "Link"
+msgstr "Povezava"
+
+#: templates/edit/row.inc:30 templates/edit/row.php:30
+msgid "Lock"
+msgstr "Zakleni"
+
+#: lib/Forms/Search.php:26 templates/edit/row.inc:44 templates/edit/row.php:44
+msgid "Locked"
+msgstr "Zaklenjena"
+
+#: admin/categories/edit.php:30 admin/sources/edit.php:32
+#: templates/categories/index.php:6 templates/sources/index.php:6
+msgid "Name"
+msgstr "Ime"
+
+#: templates/reads/header.inc:5
+msgid "News"
+msgstr "Novica"
+
+#: reads.php:33
+#, php-format
+msgid "News %s"
+msgstr "Novica %s"
+
+#: edit.php:51 edit.php:59 edit.php:67 edit.php:75 edit.php:83 edit.php:116
+#: delete.php:55 delete.php:57
+#, php-format
+msgid "News %s: %s"
+msgstr "Novica %s: %s"
+
+#: add.php:422
+msgid ""
+"News added. The editors will check the entry and confirm it if they find it "
+"suitable."
+msgstr ""
+"Novica je bila vpisana. Uredniki bodo pregledali vaš vpis in ga potrdili, če "
+"je le-ta primeren za objavo pri nas."
+
+#: add.php:83
+msgid "News content"
+msgstr "Vsebina novice"
+
+#: templates/news/info.inc:3 templates/news/info.php:3
+msgid "News data"
+msgstr "O novici"
+
+#: templates/news/today.inc:5 templates/news/today.php:5
+msgid "News of this day."
+msgstr "Novice tega dne"
+
+#: add.php:424
+msgid "News published."
+msgstr "Novica objavljena."
+
+#: mail.php:63
+#, php-format
+msgid "News succesfully send to %s"
+msgstr "Novice je bila uspešno poslana na %s."
+
+#: note.php:45
+msgid "News sucessfuly added to you notes."
+msgstr "Novica je bila uspešno dodana med vaše zapiske"
+
+#: add.php:426
+msgid "News updated."
+msgstr "Novica osvežena."
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "No"
+msgstr "Št."
+
+#: diff.php:59
+msgid "No change."
+msgstr "Ni spremembe."
+
+#: mail.php:41
+msgid "No mail entered."
+msgstr "Pozabili ste vnesti email."
+
+#: lib/Block/last_comments.php:19
+msgid "Number of comments to display"
+msgstr "Število komentarjev"
+
+#: note.php:28 pdf.php:50 templates/news/info.inc:5 templates/news/info.php:5
+msgid "On"
+msgstr "Objavljena"
+
+#: templates/news/today.inc:3 templates/news/today.php:3
+msgid "On this day"
+msgstr "Na današnji dan"
+
+#: delete.php:16
+msgid "Only admin can delete a news."
+msgstr "Samo administratorji lahko brišejo novice."
+
+#: add.php:64
+msgid "Only authenticated users can post news."
+msgstr "Samo ragistrirani uporabniki lahko vpisujejo novice."
+
+#: mail.php:36
+msgid "Only authenticated users can send mails."
+msgstr "Samo ragistrirani uporabniki lahko pošiljajo novice."
+
+#: lib/Forms/Search.php:32
+msgid "Order by"
+msgstr "Razvrsti po"
+
+#: lib/News.php:447
+msgid "Overview"
+msgstr "Pregled"
+
+#: templates/news/tools.inc:9 templates/news/tools.php:9
+msgid "PDF"
+msgstr "PDF"
+
+#: admin/categories/edit.php:32 templates/categories/index.php:7
+msgid "Parent"
+msgstr "Sorodne"
+
+#: add.php:144 templates/news/parents.inc:5 templates/news/parents.php:5
+#: templates/edit/info.inc:33 templates/edit/info.php:33
+msgid "Parents"
+msgstr "Sorodne novice"
+
+#: add.php:99
+msgid "Picture"
+msgstr "Slika"
+
+#: add.php:108
+msgid "Picture comment"
+msgstr "Komentar k sliki"
+
+#: add.php:101
+msgid "Picture delete"
+msgstr "Izbriši sliko"
+
+#: lib/Block/jonah.php:4 lib/Block/jonah.php:24
+msgid "Press overview"
+msgstr "Pregled tiska"
+
+#: config/prefs.php.dist:9
+msgid "Preview"
+msgstr "Pregled %s"
+
+#: lib/News.php:187
+#, php-format
+msgid "Preview %s"
+msgstr "Pregled %s"
+
+#: add.php:87 templates/edit/info.inc:10 templates/edit/info.php:10
+msgid "Primary category"
+msgstr "Primarna kategorija"
+
+#: templates/news/tools.inc:6 templates/news/tools.php:6
+msgid "Printer firendly"
+msgstr "Tiskanju prijazen izpis"
+
+#: add.php:85 lib/Forms/Search.php:42
+msgid "Publish"
+msgstr "Objavi ob"
+
+#: templates/edit/header.inc:8
+msgid "Publish at"
+msgstr "Objavi ob"
+
+#: lib/Forms/Search.php:32 config/prefs.php.dist:28
+msgid "Publish date"
+msgstr "Objavi ob"
+
+#: templates/news/parents.inc:8 templates/news/parents.php:8
+#: templates/edit/row.inc:48 templates/edit/row.php:48
+msgid "Read"
+msgstr "Preberi"
+
+#: lib/Forms/Search.php:36 templates/edit/header.inc:10
+msgid "Reads"
+msgstr "Branj"
+
+#: delete.php:26 delete.php:33 admin/categories/delete.php:18
+#: admin/categories/delete.php:24 admin/sources/delete.php:19
+#: admin/sources/delete.php:25
+msgid "Remove"
+msgstr "Odstrani"
+
+#: templates/edit/info.inc:92 templates/edit/info.php:97
+msgid "Renew"
+msgstr "Obnovi"
+
+#: add.php:482
+msgid "Reset"
+msgstr "Povrni"
+
+#: admin/categories/edit.php:34 admin/sources/edit.php:35
+msgid "Resize Image"
+msgstr "Spremeni velikost slike"
+
+#: add.php:77
+msgid "Save"
+msgstr "Shrani"
+
+#: lib/News.php:450 lib/Forms/Search.php:18 lib/Forms/Search.php:20
+msgid "Search"
+msgstr "Najdi"
+
+#: lib/Forms/Search.php:22
+msgid "Search world"
+msgstr "Iskana beseda"
+
+#: add.php:142 templates/edit/info.inc:13 templates/edit/info.php:13
+msgid "Secondary category"
+msgstr "Pomožna kategorija"
+
+#: lib/Block/jonah.php:35
+msgid "Select a feed."
+msgstr "Izberite vir."
+
+#: add.php:214
+msgid "Select files"
+msgstr "Izberi datoteke"
+
+#: add.php:195 templates/edit/info.inc:47 templates/edit/info.php:47
+msgid "Selling item"
+msgstr "Prodajani artikel"
+
+#: templates/news/mail.inc:2 templates/news/mail.php:2
+msgid "Send by mail"
+msgstr "Pošlji po emailu"
+
+#: lib/News.php:101
+msgid "Services/Trackback is not installed."
+msgstr "Services/Trackback ni nameščen."
+
+#: config/prefs.php.dist:11
+msgid "Set news previerw paramaters"
+msgstr "Nastavitve prikazovanja novic"
+
+#: lib/Block/last.php:28
+msgid "Skip category"
+msgstr "Preskoči kategorijo"
+
+#: config/prefs.php.dist:31 config/prefs.php.dist:41
+msgid "Sort news by"
+msgstr "Razvrsti novice po"
+
+#: add.php:143 lib/Forms/Search.php:39 templates/edit/info.inc:29
+#: templates/edit/info.php:29
+msgid "Sort order"
+msgstr "Vrstni red"
+
+#: add.php:94 templates/edit/info.inc:37 templates/edit/info.php:37
+msgid "Source"
+msgstr "Vir"
+
+#: admin/sources/delete.php:30
+msgid "Source deleted."
+msgstr "Vir je bil izbrisan."
+
+#: add.php:96 templates/edit/info.inc:41 templates/edit/info.php:41
+msgid "Source link"
+msgstr "Izvirna novica"
+
+#: templates/news/info.inc:18 templates/news/info.php:18
+msgid "Source media"
+msgstr "Vir novice"
+
+#: templates/news/info.inc:13 templates/news/info.php:13
+msgid "Source news"
+msgstr "Izvirna novica"
+
+#: admin/sources/edit.php:45
+msgid "Source saved succesfully."
+msgstr "Vir je bil uspešno osvežen."
+
+#: admin/sources/delete.php:28 admin/sources/delete.php:33
+msgid "Source was not deleted."
+msgstr "Vir ni bil izbrisan."
+
+#: admin/tabs.php:26 lib/Block/sources.php:3 lib/Block/sources.php:21
+msgid "Sources"
+msgstr "Viri"
+
+#: admin/sources/index.php:17
+msgid "Sources Administration"
+msgstr "Urejanje virov"
+
+#: add.php:170
+msgid "Sponsored"
+msgstr "Komercialna"
+
+#: lib/Forms/Search.php:27 templates/edit/header.inc:6
+msgid "Status"
+msgstr "Status"
+
+#: lib/News.php:454
+msgid "Tag cloud"
+msgstr "Tagi novic"
+
+#: add.php:110 lib/Block/tags_cloud.php:3 lib/Block/tags_cloud.php:24
+msgid "Tags"
+msgstr "Tagi"
+
+#: templates/news/blog.inc:7 templates/news/blog.php:7
+msgid "Talkbacks to this article:"
+msgstr "Talkback na to novico:"
+
+#: templates/news/ulaform.php:13
+msgid "Thanks"
+msgstr "Hvala"
+
+#: templates/block/news.php:18 templates/block/titles.php:20
+msgid "There are no news to display."
+msgstr "Ni novic za prikaz."
+
+#: lib/News.php:508
+#, php-format
+msgid "There requested news %s don't exist."
+msgstr "Izbrana novica ne %s obstaja."
+
+#: news.php:34
+msgid "There requested version don't exist."
+msgstr "Izbrana verzja ne obstaja."
+
+#: add.php:147 templates/news/threads.inc:6 templates/news/threads.php:6
+#, php-format
+msgid "Threads in %s"
+msgstr "Debate v %s"
+
+#: add.php:107 lib/Forms/Search.php:34 templates/edit/header.inc:7
+#: config/prefs.php.dist:30
+msgid "Title"
+msgstr "Naslov"
+
+#: templates/news/tools.inc:3 templates/news/tools.php:3
+msgid "Tools"
+msgstr "Orodja"
+
+#: templates/news/blog.inc:22 templates/news/blog.php:22
+msgid "Trackback this blog on this site."
+msgstr "Vpišite blog na to novico."
+
+#: lib/News.php:652
+#, php-format
+msgid "URL already trackbacked: %s"
+msgstr "URL je bil že zapisan: %s"
+
+#: lib/Forms/Search.php:24 templates/edit/row.inc:42 templates/edit/row.php:42
+msgid "Unconfirmed"
+msgstr "Nepotrjena"
+
+#: templates/edit/row.inc:27 templates/edit/row.php:27
+msgid "Unlock"
+msgstr "Odkleni"
+
+#: lib/Forms/Search.php:43
+msgid "Unpublish"
+msgstr "Odstrani ob"
+
+#: templates/edit/info.inc:17 templates/edit/info.php:17
+msgid "Unpublish date"
+msgstr "Odstrani dne"
+
+#: add.php:481 templates/edit/info.inc:81 templates/edit/info.php:86
+msgid "Update"
+msgstr "Ažuriraj"
+
+#: admin/sources/edit.php:33 templates/sources/index.php:7
+msgid "Url"
+msgstr "Url"
+
+#: templates/news/blog.inc:16 templates/news/blog.php:16
+msgid "Use the following link to trackback from your own site: "
+msgstr "Uporabite sledeči naslov za trakback z vaše strani: "
+
+#: lib/Forms/Search.php:44 templates/reads/header.inc:6
+#: templates/edit/header.inc:9
+msgid "User"
+msgstr "Uporabnik"
+
+#: templates/edit/info.inc:89 templates/edit/info.php:94
+msgid "View"
+msgstr "Preglej"
+
+#: admin/sources/index.php:32
+msgid "View articles"
+msgstr "Preglej novice"
+
+#: admin/sources/index.php:29
+msgid "View items"
+msgstr "Preglej novice"
+
+#: templates/edit/info.inc:21 templates/edit/info.php:21
+msgid "Yes"
+msgstr "Da"
+
+#: admin/tabs.php:15
+msgid "You are not authorised for this action."
+msgstr "Niste avtorizirani za ta ukaz."
+
+#: mail.php:47
+msgid "You have no email set."
+msgstr "Nimate nastavljenega email naslova."
+
+#: edit.php:24
+msgid "You have not editor permission on any category."
+msgstr "Nimate uredniških pravic do nobene kategorije."
+
+#: edit.php:67
+msgid "activated"
+msgstr "aktivirana"
+
+#: edit.php:59
+msgid "deactivated"
+msgstr "deaktivirana"
+
+#: delete.php:55
+msgid "deleted"
+msgstr "izbrisana"
+
+#: edit.php:75
+msgid "locked"
+msgstr "zaklenjena"
+
+#: delete.php:57
+msgid "not deleted"
+msgstr "ni zbrisana"
+
+#: edit.php:116
+msgid "renewed"
+msgstr "povrnjena"
+
+#: edit.php:83
+msgid "unlocked"
+msgstr "odklenjena"
+
diff --git a/news/print.php b/news/print.php
new file mode 100644 (file)
index 0000000..024ee41
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Print news
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: print.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$id = Util::getFormData('id');
+$version = Util::getFormData('version', false);
+$row = $news->get($id);
+$template_path = News::getTemplatePath($row['category1'], 'news');
+
+require_once NEWS_TEMPLATES . '/print/header.inc';
+require $template_path . 'news.inc';
+require_once NEWS_TEMPLATES . '/print/footer.inc';
diff --git a/news/reads.php b/news/reads.php
new file mode 100644 (file)
index 0000000..a985966
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * News reads
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: reads.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+if (!Auth::isAuthenticated()) {
+    Horde::authenticationFailureRedirect();
+}
+
+$id = Util::getFormData('id', 0);
+$actionID = Util::getFormData('actionID', false);
+$url = Horde::applicationUrl('reads.php');
+
+$sql = 'SELECT id, user, ip, readdate FROM ' . $news->prefix . '_user_reads WHERE ';
+if ($actionID) {
+    $title = $actionID;
+    $result = $news->db->getAll($sql . 'user = ? ORDER BY readdate DESC', array($actionID), DB_FETCHMODE_ASSOC);
+} else {
+    $result = $news->db->getAll($sql . 'id = ? ORDER BY readdate DESC', array($id), DB_FETCHMODE_ASSOC);
+    $title = sprintf(_("News %s"), $id);
+}
+
+if ($result instanceof PEAR_Error) {
+    var_dump($result);
+    exit;
+}
+
+Horde::addScriptFile('tables.js', 'horde', true);
+Horde::includeScriptFiles();
+echo Horde::stylesheetLink('news');
+
+// require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/reads/header.inc';
+
+foreach ($result as $row) {
+    require NEWS_TEMPLATES . '/reads/row.inc';
+}
+
+// require_once $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/rss/comments.php b/news/rss/comments.php
new file mode 100644 (file)
index 0000000..b687514
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * $Id: comments.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ */
+
+define('AUTH_HANDLER', true);
+define('NEWS_BASE', dirname(__FILE__) . '/../');
+require_once NEWS_BASE . '/lib/base.php';
+
+$cache_key = 'news_rss_comments';
+//$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
+if (!$rss) {
+
+    $list = News::getLastComments(50);
+    $title = _("Last comments");
+
+
+    $rss = '<?xml version="1.0" encoding="' . NLS::getCharset() . '" ?>
+<rss version="2.0">
+<channel>
+    <title>' . htmlspecialchars($title) . '</title>
+    <language>' . str_replace('_', '-', strtolower(NLS::select())) . '</language>
+    <lastBuildDate>' . date('r') . '</lastBuildDate>
+    <description>' . htmlspecialchars($title) . '</description>
+    <link>' . Horde::applicationUrl('index.php', true, -1) . '</link>
+    <generator>' . htmlspecialchars($registry->get('name')) . '</generator>';
+
+    foreach ($list as $comment) {
+        $rss .= '
+    <item>
+        <title>' . htmlspecialchars($comment['message_subject']) . ' </title>
+        <link>' . $comment['read_url'] . '</link>
+        <guid isPermaLink="true">' . $comment['read_url'] . '</guid>
+        <pubDate>' . date('r', strtotime($comment['message_date'])) . '</pubDate>
+        <description><![CDATA[' . $comment['message_author'] . ': ' . strip_tags($comment['body']) . ']]></description>
+    </item>';
+    }
+
+    $rss .= '
+</channel>
+</rss>';
+
+    $cache->set($cache_key, $rss);
+}
+
+header('Content-type: text/xml; charset=' . NLS::getCharset());
+echo $rss;
diff --git a/news/rss/index.php b/news/rss/index.php
new file mode 100644 (file)
index 0000000..e5b010c
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * $Id: index.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ */
+
+define('AUTH_HANDLER', true);
+define('NEWS_BASE', dirname(__FILE__) . '/../');
+require_once NEWS_BASE . '/lib/base.php';
+
+// Show a specific user?
+$cache_key = 'news_rss_index';
+
+$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
+if (!$rss) {
+
+    $title = $registry->get('name', 'horde');
+
+    $read_url = Horde::applicationUrl('read.php', true, -1);
+    $rss = '<?xml version="1.0" encoding="' . NLS::getCharset() . '" ?>
+    <rss version="2.0">
+        <channel>
+        <title>' . htmlspecialchars($title) . '</title>
+        <language>' . str_replace('_', '-', strtolower(NLS::select())) . '</language>
+        <lastBuildDate>' . date('r') . '</lastBuildDate>
+        <description>' . htmlspecialchars($title) . '</description>
+        <link>' . Horde::applicationUrl('index.php', true, -1) . '</link>
+        <generator>' . htmlspecialchars($registry->get('name')) . '</generator>';
+
+    $rss .= '
+    <item>
+        <title>' . _("Last news") . ' </title>
+        <link>' . Horde::applicationUrl('rss/news.php', true, -1) . '</link>
+    </item>';
+
+    $rss .= '
+    <item>
+        <title>' . _("Last comments") . ' </title>
+        <link>' . Horde::applicationUrl('rss/comments.php', true, -1) . '</link>
+    </item>';
+
+    $rss .= '
+    </channel>
+    </rss>';
+
+    $cache->set($cache_key, $rss);
+}
+
+header('Content-type: text/xml');
+echo $rss;
diff --git a/news/rss/news.php b/news/rss/news.php
new file mode 100755 (executable)
index 0000000..961e3be
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * $Id: news.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @author McLion <mclion@obala.net>
+ */
+
+define('AUTH_HANDLER', true);
+define('NEWS_BASE', dirname(__FILE__) . '/../');
+require_once NEWS_BASE . '/lib/base.php';
+
+$cache_key = 'news_rss_news';
+$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']);
+if (empty($rss)) {
+
+    /* query preparation */
+    $query = 'SELECT n.id, publish, n.user, n.source, n.sourcelink, ' .
+             'n.category1, n.category2, n.comments, n.picture, n.chars, nl.content, ' .
+             'nl.title, nl.abbreviation ' .
+             'FROM ' . $news->prefix . ' AS n, ' . $news->prefix . '_body AS nl ' .
+             'WHERE n.status="' . News::CONFIRMED . '" AND n.publish<=NOW() ' .
+             'AND nl.lang="' . NLS::select() . '" AND n.id=nl.id  ORDER BY publish DESC';
+    $rssbody = '';
+    $query = $news->db->modifyLimitQuery($query, 0, 10);
+    $list = $news->db->getAssoc($query, true, array(), DB_FETCHMODE_ASSOC);
+    $categories = $news_cat->getCategories(false);
+    $title = sprintf(_("Last news"), $registry->get('name', 'horde'));
+
+    $read_url = Horde::applicationUrl('news.php', true, -1);
+    $lastnewstime = 0;
+    foreach ($list as $news_id => $news) {
+        $news_link = Util::addParameter($read_url, 'id', $news_id);
+        $rssbody .= '
+    <item>
+        <title>' . htmlspecialchars($news['title']) . ' </title>
+        <dc:creator>' . htmlspecialchars($news['user']). '</dc:creator>
+        <link>' . $news_link . '</link>
+        <guid isPermaLink="true">' . $news_link . '</guid>
+        <comments>' . $news_link . '#comments</comments>
+        <description><![CDATA[' . trim(substr(htmlspecialchars(strip_tags($news['content'])), 0, 512)) . ']]></description>
+        <pubDate>' . date('r', strtotime($news['publish'])) . '</pubDate>
+        <category><![CDATA[' . $categories[$news['category1']]['category_name'] . ']]></category>
+    </item>';
+
+        if (strtotime($news['publish']) > $lastnewstime) {
+            $lastnewstime = strtotime($news['publish']);
+        }
+    }
+    
+    // Wee need the last published news time
+    $rssheader = '<?xml version="1.0" encoding="' . NLS::getCharset() . '" ?>
+<rss version="2.0"
+    xmlns:content="http://purl.org/rss/1.0/modules/content/"
+    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+    xmlns:dc="http://purl.org/dc/elements/1.1/" >
+<channel>
+    <title>' . htmlspecialchars($title) . '</title>
+    <language>' . str_replace('_', '-', strtolower(NLS::select())) . '</language>
+    <lastBuildDate>' . date('r', $lastnewstime) . '</lastBuildDate>
+    <description>' . htmlspecialchars($title) . '</description>
+    <link>' . Horde::applicationUrl('index.php', true, -1) . '</link>
+    <generator>' . htmlspecialchars($registry->get('name')) . '</generator>';
+
+
+
+    $rssfooter = '
+</channel>
+</rss>';
+
+    // build rss
+    $rss = $rssheader . $rssbody . $rssfooter;
+
+    $cache->set($cache_key, $rss);
+}
+
+
+header('Content-type: text/xml;  charset=utf-8');
+echo $rss;
diff --git a/news/scripts/sql/news.mysql.sql b/news/scripts/sql/news.mysql.sql
new file mode 100644 (file)
index 0000000..53f375a
--- /dev/null
@@ -0,0 +1,103 @@
+CREATE TABLE news (
+  id smallint(5) UNSIGNED NOT NULL auto_increment,
+  sortorder tinyint(2) NOT NULL default '0',
+  status tinyint(1) UNSIGNED NOT NULL default '0',
+  view_count smallint(5) UNSIGNED NOT NULL default '0',
+  publish datetime default NULL,
+  unpublish datetime default NULL,
+  submitted datetime NOT NULL default '0000-00-00 00:00:00',
+  updated timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  user varchar(11) NOT NULL default '',
+  editor varchar(11) NOT NULL default '',
+  sourcelink varchar(34) NOT NULL default '',
+  source varchar(11) default NULL,
+  category1 smallint(5) UNSIGNED NOT NULL default '0',
+  category2 smallint(5) UNSIGNED NOT NULL default '0',
+  comments smallint(5) NOT NULL default '0',
+  chars smallint(5) UNSIGNED NOT NULL default '0',
+  attachments tinyint(1) UNSIGNED NOT NULL default '0',
+  picture int(4) NOT NULL default '0',
+  gallery int(10) UNSIGNED NOT NULL default '0',
+  selling varchar(50) default NULL,
+  trackbacks int(10) UNSIGNED NOT NULL default '0',
+  form_id smallint(5) UNSIGNED NOT NULL default '0',
+  form_ttl int(10) UNSIGNED NOT NULL default '0',
+  PRIMARY KEY  (id),
+  KEY datum (publish),
+  KEY sortorder (sortorder),
+  KEY STATUS (status),
+  KEY cat (category1)
+);
+
+CREATE TABLE news_attachment (
+  id int(10) UNSIGNED NOT NULL default '0',
+  lang varchar(5) NOT NULL,
+  filename varchar(85) NOT NULL default '',
+  filesize int(10) UNSIGNED NOT NULL default '0',
+  KEY news (id,lang)
+);
+
+CREATE TABLE news_body (
+  id smallint(5) UNSIGNED NOT NULL default '0',
+  lang varchar(5) NOT NULL default '0',
+  title varchar(67) NOT NULL default '',
+  abbreviation text NOT NULL,
+  content text NOT NULL,
+  picture_comment varchar(255);
+  tags varchar(255);
+  PRIMARY KEY  (id,lang)
+);
+
+CREATE TABLE news_categories (
+  category_id int(10) UNSIGNED NOT NULL auto_increment,
+  category_name varchar(50) NOT NULL,
+  category_description varchar(255) default NULL,
+  category_parentid int(10) UNSIGNED NOT NULL,
+  category_form varchar(50) NOT NULL,
+  category_image int(1) UNSIGNED NOT NULL,
+  PRIMARY KEY  (category_id)
+);
+
+CREATE TABLE news_categories_nls (
+  category_id int(10) UNSIGNED NOT NULL,
+  category_nls char(5) NOT NULL,
+  category_name varchar(50) NOT NULL,
+  category_description varchar(255) NOT NULL,
+  PRIMARY KEY  (category_id, category_nls)
+  KEY category_nls (category_nls)
+);
+
+CREATE TABLE news_sources (
+  source_id int(10) UNSIGNED NOT NULL,
+  source_name varchar(255) NOT NULL,
+  source_url varchar(255) NOT NULL,
+  PRIMARY KEY  (source_id)
+);
+
+CREATE TABLE news_trackback (
+  id int(11) NOT NULL,
+  excerpt text,
+  created datetime NOT NULL,
+  title varchar(255) NOT NULL,
+  url varchar(255) NOT NULL,
+  blog_name varchar(255) NOT NULL,
+  KEY created (created),
+  KEY id (id)
+);
+
+CREATE TABLE news_user_reads (
+  id int(10) UNSIGNED NOT NULL default '0',
+  user varchar(85) NOT NULL default '',
+  ip varchar(9) NOT NULL default '',
+  readdate datetime NOT NULL default '0000-00-00 00:00:00',
+  KEY id (id)
+);
+
+CREATE TABLE news_versions (
+  id int(10) UNSIGNED NOT NULL default '0',
+  version float UNSIGNED NOT NULL default '0',
+  created datetime NOT NULL default '0000-00-00 00:00:00',
+  user_uid varchar(85) NOT NULL default '',
+  content text NOT NULL,
+  PRIMARY KEY  (id,version)
+);
diff --git a/news/scripts/upgrades/20070302_trackback.sql b/news/scripts/upgrades/20070302_trackback.sql
new file mode 100644 (file)
index 0000000..3769f3e
--- /dev/null
@@ -0,0 +1,13 @@
+ALTER TABLE `news` CHANGE `reads` `view_count` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0';
+ALTER TABLE `news` ADD `trackbacks` SMALLINT NOT NULL DEFAULT '0';
+
+CREATE TABLE `news_trackback` (
+  `id` int(11) NOT NULL,
+  `excerpt` text,
+  `created` datetime NOT NULL,
+  `title` varchar(255) NOT NULL,
+  `url` varchar(255) NOT NULL,
+  `blog_name` varchar(255) NOT NULL,
+  KEY `created` (`created`),
+  KEY `id` (`id`)
+);
diff --git a/news/scripts/upgrades/20070609_sponsored.sql b/news/scripts/upgrades/20070609_sponsored.sql
new file mode 100644 (file)
index 0000000..e86f428
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE `news2` ADD `sponsored` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `sourcelink` ;
+ALTER TABLE `news2` ADD `parents` VARCHAR( 255 ) NOT NULL AFTER `sponsored` ;
\ No newline at end of file
diff --git a/news/scripts/upgrades/20071220_tags.sql b/news/scripts/upgrades/20071220_tags.sql
new file mode 100644 (file)
index 0000000..5dc905e
--- /dev/null
@@ -0,0 +1 @@
+ALTER TABLE `news_body` ADD `tags` VARCHAR( 255 ) AFTER `picture_comment` ;
\ No newline at end of file
diff --git a/news/search.php b/news/search.php
new file mode 100644 (file)
index 0000000..5a646d6
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Search
+ *
+ * Copyright 2006 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: search.php 210 2008-01-10 12:41:43Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+require_once NEWS_BASE . '/lib/Forms/Search.php';
+
+// Default vars
+$title = _("Browse");
+$page = Util::getGet('news_page', 0);
+$per_page = $prefs->getValue('per_page');
+$news_url = Horde::applicationUrl('news.php');
+$browse_url = Horde::applicationUrl('browse.php');
+$cid = Util::getGet('cid');
+
+$vars = Variables::getDefaultVariables();
+$form = new News_Search($vars);
+$form->getInfo(null, $criteria);
+
+// Count rows
+$count = $news->countNews($criteria);
+if ($count instanceof PEAR_Error) {
+    echo $count->getMessage() . ': ' . $count->getDebugInfo();
+    exit;
+}
+
+// Select rows
+$rows = $news->listNews($criteria, $page*$per_page, $per_page, null);
+if ($rows instanceof PEAR_Error) {
+    echo $rows->getMessage() . ': ' . $rows->getDebugInfo();
+    exit;
+}
+
+$vars = Variables::getDefaultVariables();
+$pager = new Horde_UI_Pager('news_page',
+                            $vars, array('num' => $count,
+                                         'url' => 'search.php',
+                                         'perpage' => $per_page));
+
+$pager->preserve($criteria);
+
+// If we have only one row redirect ot it
+if ($count == 1 && sizeof($cats) < 2 && $page < 1) {
+    header('Location: '. Util::addParameter($news_url, 'id', $rows[0]['id'], false));
+    exit;
+}
+
+
+require_once NEWS_TEMPLATES . '/common-header.inc';
+require_once NEWS_TEMPLATES . '/menu.inc';
+
+$form->renderActive(null, null, null, 'post');
+
+$browse_template_path = News::getTemplatePath($cid, 'browse');
+require_once $browse_template_path . 'header.inc';
+foreach ($rows as $row) {
+    require $browse_template_path . 'row.inc';
+}
+require_once $browse_template_path . '/footer.inc';
+
+require_once $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/news/tags.php b/news/tags.php
new file mode 100644 (file)
index 0000000..4310956
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Browse
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://cvs.horde.org/co.php/news/LICENSE.
+ *
+ * $Id: browse.php 76 2007-12-19 13:57:35Z duck $
+ *
+ * @author Duck <duck@obala.net>
+ * @package News
+ */
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+$remove = array("!", "'", '"', "?", ".", ",", ";", ":", ')', '(', 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '«', '»', '&', '+', '-', '*');
+
+$result = $news->db->query('UPDATE news_body SET tags = ""');
+$result = $news->db->query('SELECT id, title FROM news_body WHERE tags = "" ORDER BY id ASC');
+while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
+    $row['title'] = String::lower($row['title'], true);
+    $row['title'] = str_replace($remove, '', $row['title']);
+    $tags = explode(' ', $row['title']);
+    foreach ($tags as $i => $tag) {
+        if (strlen($tag) < 4) {
+            unset($tags[$i]);
+        }
+    }
+    if (empty($tags)) {
+        continue;
+    }
+    $tags = implode(' ', $tags);
+    echo $tags . '<br />';
+    $params = array($tags, $row['id']);
+    $news->db->query('UPDATE news_body SET tags = ? WHERE id = ?', $params);
+}
+
+echo 'done';
\ No newline at end of file
diff --git a/news/templates/add/before.inc b/news/templates/add/before.inc
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/news/templates/block/news.php b/news/templates/block/news.php
new file mode 100644 (file)
index 0000000..6102bd9
--- /dev/null
@@ -0,0 +1,19 @@
+<?php if (!empty($this->news)): ?>
+
+<?php foreach ($this->news as $news_id => $news) { ?>
+<p>
+<?php
+if ($news['picture']) {
+    echo Horde::img(News::getImageUrl($news['id']), $news['title'], 'style="float: left; padding-right: 3px;"','');
+}
+echo Horde::link(Util::addParameter($this->news_url, 'id', $news['id']), $news['title']);
+echo '<strong>' . $news['title'] . '</a></strong> - ' . $news['abbreviation'] . '... (' . $news['comments'] . ')<br /> ';
+?>
+</p>
+
+<?php } ?>
+
+
+<?php else: ?>
+    <p><?php echo _("There are no news to display.") ?></p>
+<?php endif; ?>
diff --git a/news/templates/block/titles.php b/news/templates/block/titles.php
new file mode 100644 (file)
index 0000000..64324a4
--- /dev/null
@@ -0,0 +1,21 @@
+<?php if (!empty($this->news)): ?>
+
+<table>
+
+<?php foreach ($this->news as $news_id => $news) { ?>
+<tr>
+<td>
+<?php
+echo strftime($GLOBALS['prefs']->getValue('date_format'), strtotime($news['publish'])) . ' - ';
+echo Horde::link(Util::addParameter($this->news_url, 'id', $news['id']), $news['abbreviation']);
+echo $news['title'] . '</a>';
+?>
+</td>
+</tr>
+
+<?php } ?>
+</table>
+
+<?php else: ?>
+    <p><?php echo _("There are no news to display.") ?></p>
+<?php endif; ?>
diff --git a/news/templates/browse/footer.inc b/news/templates/browse/footer.inc
new file mode 100755 (executable)
index 0000000..10cc5e3
--- /dev/null
@@ -0,0 +1 @@
+<?php echo $pager->render(); ?>
diff --git a/news/templates/browse/header.inc b/news/templates/browse/header.inc
new file mode 100755 (executable)
index 0000000..7af1564
--- /dev/null
@@ -0,0 +1,3 @@
+<div class="header"><?php echo $title ?> (<?php echo $count ?>)</div>
+<?php echo $pager->render(); ?>
+
diff --git a/news/templates/browse/row.inc b/news/templates/browse/row.inc
new file mode 100755 (executable)
index 0000000..aa81470
--- /dev/null
@@ -0,0 +1,12 @@
+<p style="clear: both;">
+<img src="<?php echo News::getImageUrl($row['id'], 'small'); ?>" style="float: left; margin: 5px;" />
+<strong>
+<?php echo Horde::link(Util::addParameter($news_url, 'id', $row['id']), $row['title']) . $row['title'] . '</a>'; ?>
+</strong> - <?php echo News::dateFormat($row['publish'], false) ?>
+ <br />
+<?php echo $row['abbreviation'] ?> ...<br />
+<span class="small">
+<?php echo _("Chars") . ': ' . number_format($row['chars']) . ' | '; ?>
+<?php echo _("Comments") . ': ' . $row['comments']; ?>
+</span>
+</p>
\ No newline at end of file
diff --git a/news/templates/categories/delete.html b/news/templates/categories/delete.html
new file mode 100755 (executable)
index 0000000..7adede2
--- /dev/null
@@ -0,0 +1,9 @@
+<div id="menu"><tag:menu /></div>
+<tag:notify />
+
+<div style="float: left;">
+<div class="header"><gettext>Categories</gettext></div>
+<tag:tree />
+</div>
+
+<tag:form />
\ No newline at end of file
diff --git a/news/templates/categories/edit.html b/news/templates/categories/edit.html
new file mode 100755 (executable)
index 0000000..7adede2
--- /dev/null
@@ -0,0 +1,9 @@
+<div id="menu"><tag:menu /></div>
+<tag:notify />
+
+<div style="float: left;">
+<div class="header"><gettext>Categories</gettext></div>
+<tag:tree />
+</div>
+
+<tag:form />
\ No newline at end of file
diff --git a/news/templates/categories/index.html b/news/templates/categories/index.html
new file mode 100755 (executable)
index 0000000..c314ca7
--- /dev/null
@@ -0,0 +1,5 @@
+<div id="menu"><tag:menu /></div>
+<tag:notify />
+
+<div class="header"><gettext>Categories</gettext></div>
+<tag:tree />
diff --git a/news/templates/categories/index.php b/news/templates/categories/index.php
new file mode 100644 (file)
index 0000000..6022f7a
--- /dev/null
@@ -0,0 +1,27 @@
+<table style="width: 100%;" id="categories_list" class="sortable striped">
+<thead>
+<tr>
+<th><?php echo $this->add_url ?></th>
+<th><?php echo _("Id") ?></th>
+<th><?php echo _("Name") ?></th>
+<th><?php echo _("Parent") ?></th>
+<th><?php echo _("Description") ?></th>
+</tr>
+</thead>
+<?php foreach ($this->categories as $category_id => $category) { ?>
+<tr>
+<td><?php foreach ($category['actions'] as $action ) { echo $action . ' '; } ?></td>
+<td><?php echo $category_id ?></td>
+<td><?php echo $category['category_name'] ?></td>
+<td>
+<?php 
+if ($category['category_parentid']) {
+    echo $this->categories[$category['category_parentid']]['category_name'] .
+         ' - '  . $category['category_parentid'];
+}
+?></td>
+<td><?php echo $category['category_description'] ?></td>
+</tr>
+<?php } ?>
+
+</table>
\ No newline at end of file
diff --git a/news/templates/common-header.inc b/news/templates/common-header.inc
new file mode 100755 (executable)
index 0000000..39cc566
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+if (isset($language)) {
+    header('Content-type: text/html; charset=' . NLS::getCharset());
+    header('Vary: Accept-Language');
+}
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<!-- news: Copyright 2004-2007, The Horde Project. news is under a Horde license. -->
+<!--     Horde Project: http://www.horde.org/ | news: http://www.horde.org/horde/     -->
+<!--                 Horde Licenses: http://www.horde.org/licenses/                       -->
+<?php echo !empty($language) ? '<html lang="' . strtr($language, '_', '-') . '">' : '<html>' ?>
+<head>
+<?php
+
+$page_title = $registry->get('name');
+if (!empty($title)) $page_title .= ' :: ' . $title;
+if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) {
+    echo "<meta http-equiv=\"refresh\" excerpt=\"$refresh_time;url=$refresh_url\">\n";
+}
+
+Horde::includeScriptFiles();
+
+?>
+<title><?php echo htmlspecialchars($page_title) ?></title>
+<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
+<link rel="alternate" title="<?php echo _("Last news") ?>" href="<?php echo Horde::applicationUrl('rss/news.php', true, -1) ?>" type="application/rss+xml" />
+<link rel="alternate" title="<?php echo _("Last comments") ?>" href="<?php echo Horde::applicationUrl('rss/comments.php', true, -1) ?>" type="application/rss+xml" />
+<?php echo Horde::stylesheetLink('news') ?>
+</head>
+
+<body<?php if ($bc = Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
diff --git a/news/templates/edit/footer.inc b/news/templates/edit/footer.inc
new file mode 100755 (executable)
index 0000000..0582a5d
--- /dev/null
@@ -0,0 +1,4 @@
+</table>
+<?php echo $pager->render(); ?>
+
+<br />
diff --git a/news/templates/edit/header.inc b/news/templates/edit/header.inc
new file mode 100755 (executable)
index 0000000..1e8daf4
--- /dev/null
@@ -0,0 +1,17 @@
+<div class="header"><?php echo $title ?></div>
+<table class="striped sortable" id="news_list" style="width: 100%">
+<thead>
+<tr>
+<th><?php echo _("Action") ?></th>
+<th><?php echo _("Status") ?></th>
+<th><?php echo _("Title") ?></th>
+<th><?php echo _("Publish at") ?></th>
+<th><?php echo _("User") ?></th>
+<th><?php echo _("Reads") ?></th>
+<?php
+if ($has_comments) {
+    echo '<th>' . _("Comments") . '</th>';
+}
+?>
+</tr>
+</thead>
\ No newline at end of file
diff --git a/news/templates/edit/info.inc b/news/templates/edit/info.inc
new file mode 100755 (executable)
index 0000000..d62b555
--- /dev/null
@@ -0,0 +1,107 @@
+<tr valign="top">
+<td colspan="7">
+<img src="<?php echo News::getImageUrl($id, 'small'); ?>" style="float: right; height: 50px; width: 50px;" />
+
+<table style="width: 100%;">
+<tr valign="top">
+<td>
+<?php
+
+echo _("Primary category") . ': ' . $allowed_cats[$row['category1']] . "<br />\n";
+
+if ($row['category2']>0) {
+    echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "<br />\n";
+}
+
+if (substr($row['unpublish'], 0, 1) != 0) {
+    echo _("Unpublish date") . ': ' . $row['unpublish'] . "<br />\n";
+}
+
+if ($conf['comments']['allow']) {
+    echo _("Allow comments") . ': ' . ($row['comments']>-1  ? _("Yes") : _("No")) . "<br />\n";
+}
+
+if ($row['editor']) {
+    echo _("Editor") . ': ' . $row['editor'] . "<br />\n";
+}
+
+if ($row['sortorder']) {
+    echo _("Sort order") . ': ' . $row['sortorder'] . "<br />\n";
+}
+
+if (isset($row['parents'])) {
+    echo _("Parents") . ': ' . sizeof($row['parents']) . "<br />\n";
+}
+
+if (!empty($row['source']) && isset($GLOBALS['cfgSources'][$row['source']])) {
+    echo _("Source") . ': ' . $GLOBALS['cfgSources'][$row['source']]['title'] . '<br />';
+}
+
+if (isset($row['sourcelink'])) {
+    echo _("Source link") . ': <a href="' . $row['sourcelink'] . '" target="_blank">' . $row['sourcelink'] . '</a><br />';
+}
+
+// schedul
+if (!empty($row['selling'])) {
+    $item = explode('|', $row['selling']);
+    echo _("Selling item") . ': ' . $registry->get('name', $registry->hasInterface($item[0]));
+    $articles = $registry->call($item[0]  . '/listCostObjects');
+    foreach ($articles[0]['objects'] as $item_data) {
+        if ($item_data['id'] == $item[1]) {
+            echo ' - ' . $item_data['name'];
+            break;
+        }
+    }
+}
+
+if ($row['attachments']) {
+    echo News::format_attached($id);
+}
+
+?>
+</td>
+<td>
+<?php
+
+$versions = $news->getVerisons($id);
+if ($versions instanceof PEAR_Error) {
+    echo $versions->getMessage();
+    echo $versions->getDebugInfo();
+}
+
+unset($versions[0]); // current version
+
+if (sizeof($versions)>0) {
+    echo _("Edit history: ") . '<br />';
+
+    foreach ($versions as $version) {
+
+        switch ($version['action']) {
+        case 'update':
+            echo _("Update");
+        default:
+            echo _("Insert");
+        break;
+        }
+        echo _(" by ") . $version['user_uid'] . _(" at ") . $version['created'] . "\n(";
+
+        $url = Util::addParameter(Horde::applicationUrl('news.php'), array('id' => $id, 'version' => $version['version']));
+        echo Horde::link($url, _("View"), '', '_blank', '', _("View")) . _("View") . '</a> | ';
+
+        $url = Util::addParameter(Horde::applicationUrl('edit.php'), array('id' => $id, 'actionID' => 'renew'));
+        echo Horde::link(Util::addParameter($url,'version', $version['version']),_("Renew")) . _("Renew") . '</a> | ';
+
+        $url = Util::addParameter(Horde::applicationUrl('diff.php'), array('id' => $id, 'version' => $version['version']));
+        echo Horde::link('#', _("Diff"), '', '', "popup('$url')") . _("Diff") . '</a> ';
+
+        echo ')<br />' . "\n";
+    }
+}
+
+?>
+</td>
+</tr>
+</table>
+
+</td>
+
diff --git a/news/templates/edit/info.php b/news/templates/edit/info.php
new file mode 100644 (file)
index 0000000..bba91a6
--- /dev/null
@@ -0,0 +1,112 @@
+<tr valign="top">
+<td colspan="7">
+<img src="<?php echo News::getImageUrl($id, 'small'); ?>" style="float: right; height: 50px; width: 50px;" />
+
+<table style="width: 100%;">
+<tr valign="top">
+<td>
+<?php
+
+echo _("Primary category") . ': ' . $allowed_cats[$row['category1']] . "<br />\n";
+
+if ($row['category2']>0) {
+    echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "<br />\n";
+}
+
+if (substr($row['unpublish'], 0, 1) != 0) {
+    echo _("Unpublish date") . ': ' . $row['unpublish'] . "<br />\n";
+}
+
+if ($conf['comments']['allow']) {
+    echo _("Allow comments") . ': ' . ($row['comments']>-1  ? _("Yes") : _("No")) . "<br />\n";
+}
+
+if ($row['editor']) {
+    echo _("Editor") . ': ' . $row['editor'] . "<br />\n";
+}
+
+if ($row['sortorder']) {
+    echo _("Sort order") . ': ' . $row['sortorder'] . "<br />\n";
+}
+
+if (isset($row['parents'])) {
+    echo _("Parents") . ': ' . sizeof($row['parents']) . "<br />\n";
+}
+
+if (!empty($row['source']) && isset($GLOBALS['cfgSources'][$row['source']])) {
+    echo _("Source") . ': ' . $GLOBALS['cfgSources'][$row['source']]['title'] . '<br />';
+}
+
+if (isset($row['sourcelink'])) {
+    echo _("Source link") . ': <a href="' . $row['sourcelink'] . '" target="_blank">' . $row['sourcelink'] . '</a><br />';
+}
+
+// schedul
+if (!empty($row['selling'])) {
+    $item = explode('|', $row['selling']);
+    echo _("Selling item") . ': ' . $registry->get('name', $registry->hasInterface($item[0]));
+    $articles = $registry->call($item[0]  . '/listCostObjects');
+    foreach ($articles[0]['objects'] as $item_data) {
+        if ($item_data['id'] == $item[1]) {
+            echo ' - ' . $item_data['name'];
+            break;
+        }
+    }
+}
+
+// Form
+if (!empty($row['form'])) {
+    // 
+}
+
+if ($row['attachments']) {
+    echo News::format_attached($id);
+}
+
+?>
+</td>
+<td>
+<?php
+
+$versions = $news->getVerisons($id);
+if ($versions instanceof PEAR_Error) {
+    echo $versions->getMessage();
+    echo $versions->getDebugInfo();
+}
+
+unset($versions[0]); // current version
+
+if (sizeof($versions)>0) {
+    echo _("Edit history: ") . '<br />';
+
+    foreach ($versions as $version) {
+
+        switch ($version['action']) {
+        case 'update':
+            echo _("Update");
+        default:
+            echo _("Insert");
+        break;
+        }
+        echo _(" by ") . $version['user_uid'] . _(" at ") . $version['created'] . "\n(";
+
+        $url = Util::addParameter(Horde::applicationUrl('news.php'), array('id' => $id, 'version' => $version['version']));
+        echo Horde::link($url, _("View"), '', '_blank', '', _("View")) . _("View") . '</a> | ';
+
+        $url = Util::addParameter(Horde::applicationUrl('edit.php'), array('id' => $id, 'actionID' => 'renew'));
+        echo Horde::link(Util::addParameter($url,'version', $version['version']),_("Renew")) . _("Renew") . '</a> | ';
+
+        $url = Util::addParameter(Horde::applicationUrl('diff.php'), array('id' => $id, 'version' => $version['version']));
+        echo Horde::link('#', _("Diff"), '', '', "popup('$url')") . _("Diff") . '</a> ';
+
+        echo ')<br />' . "\n";
+    }
+}
+
+?>
+</td>
+</tr>
+</table>
+
+</td>
+
diff --git a/news/templates/edit/row.php b/news/templates/edit/row.php
new file mode 100644 (file)
index 0000000..f630403
--- /dev/null
@@ -0,0 +1,62 @@
+<tr valign="top">
+<td nowrap="nowrap">
+<?php
+
+$url = Util::addParameter($edit_url, array('page' => $page, 'id' => $row['id']));
+echo Horde::link($url,_("Edit")) .
+     Horde::img('edit.png', _("Edit"), '', $img_dir) . '</a>  &nbsp;';
+
+echo Horde::link(Util::addParameter($browse_url, 'id', $row['id']), _("Info")) .
+     Horde::img('devel.png', _("Info"), '', $img_dir). '</a>  &nbsp;';
+
+/* admins options */
+if (Auth::isAdmin() || isset($allowed_cats[$row['category1']]) || isset($allowed_cats[$row['category2']])) {
+
+    if ($row['status'] == News::CONFIRMED) {
+        $url = Util::addParameter($browse_url, array('page' => $page, 'actionID' => 'deactivate', 'id' =>  $row['id']));
+        echo Horde::link($url,_("Deactivate")) . Horde::img('cross.png', _("Deactivate"), '', $img_dir) . '</a> ';
+    } else {
+        $url = Util::addParameter($browse_url, array('page' => $page, 'actionID' => 'activate', 'id' => $row['id']));
+        echo Horde::link($url,_("Activate")) . Horde::img('tick.png', _("Activate"), '', $img_dir) . '</a> ';
+
+        $url = Util::addParameter(Horde::applicationUrl('delete.php'), 'id',  $row['id']);
+        echo Horde::link($url,_("Delete"), '', '', '', _("Delete")) . Horde::img('delete.png', _("Delete"), '', $img_dir) . '</a>  &nbsp;';
+
+        if ($row['status'] == News::LOCKED) {
+            $url = Util::addParameter($browse_url, array('page' => $page, 'actionID' => 'unlock', 'id' => $row['id']));
+            echo Horde::link($url,_("Unlock")) . Horde::img('map.png', '', '', $img_dir) . '</a> ';
+        } else {
+            $url = Util::addParameter($browse_url, array('page' => $page, 'actionID' => 'lock', 'id' => $row['id']));
+            echo Horde::link($url,_("Lock")) . Horde::img('locked.png', '', '', $img_dir) . '</a> ';
+        }
+    }
+}
+
+?>
+</td>
+<td>
+<?php
+
+switch ($row['status']) {
+
+case News::UNCONFIRMED: echo _("Unconfirmed"); break;
+case News::CONFIRMED: echo _("Confirmed"); break;
+case News::LOCKED: echo _("Locked"); break;
+
+}
+?></td>
+<td><?php echo Horde::link(Util::addParameter($news_url, 'id', $row['id']), _("Read"), '', '_blank') . $row['title']; ?></a></td>
+<td><?php echo $news->dateFormat($row['publish']) ?></td>
+<td><?php echo $row['user'] ?></td>
+<td>
+<?php
+$url = Util::addParameter($read_url, 'id', $row['id']);
+echo Horde::link('javascript:void(0)', $row['view_count'], '', '', "popup('$url')", $row['view_count']) . number_format($row['view_count']) . '</a>';
+?>
+</td>
+<?php
+if ($has_comments) {
+    echo '<td>' . $row['comments'] . '</td>';
+}
+?>
+</tr>
\ No newline at end of file
diff --git a/news/templates/menu.inc b/news/templates/menu.inc
new file mode 100755 (executable)
index 0000000..9fecbd6
--- /dev/null
@@ -0,0 +1,13 @@
+<div id="menu">
+<div style="float: right;">
+<form action="<?php echo Horde::applicationUrl('browse.php') ?>" method="get" id="menu_category" name="menu_category">
+<?php echo _("Category") ?>:
+<select id="category" name="category" onchange="document.menu_category.submit()">
+<option>- - - - - - - </option>
+<?php echo $news_cat->getSelect(); ?>
+</select>
+</form>
+</div>
+<?php echo News::getMenu('string') ?>
+</div>
+<?php $GLOBALS['notification']->notify(array('listeners' => 'status')) ?>
diff --git a/news/templates/news/attachments.php b/news/templates/news/attachments.php
new file mode 100644 (file)
index 0000000..5d04153
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+
+if ($row['attachments']) {
+    echo '<br /> <br />' . News::format_attached($id);
+}
diff --git a/news/templates/news/blog.php b/news/templates/news/blog.php
new file mode 100644 (file)
index 0000000..5ebfad7
--- /dev/null
@@ -0,0 +1,39 @@
+<br />
+<?php
+echo '<div class="header">' . _("Blogs") . '</div>';
+
+// Blogs
+if (!empty($row['trackback'])) {
+    echo _("Talkbacks to this article:") .  '<ul>';
+    foreach ($row['trackback'] as $trackback) {
+        echo '<li>' . Horde::link($trackback['url'], $trackback['excerpt']) . $trackback['title'] . '</a> '
+             . _("From: ") . $trackback['blog_name'] . ' @ ' . News::dateFormat($trackback['created']) . '</li>';
+    }
+    echo '</ul><br />';
+}
+
+$trackback_url = Util::addParameter(Horde::applicationUrl('trackback.php', true), 'id', $id);
+echo _("Use the following link to trackback from your own site: ") .
+    '<br> <input value="' . $trackback_url . '" /><br />';
+
+if ($registry->hasMethod('blogs/createUrl')) {
+    $intro = substr($plain_text, 0, 255) . '...';
+    $blog_url = $registry->callByPackage('thomas', 'createUrl', array($trackback_url, $row['title'], $intro));
+    echo Horde::link($blog_url) . '<strong>' . _("Trackback this blog on this site.") . '</strong></a><br/>';
+}
+
+$read_url = Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $id);
+?>
+
+<!--
+Auto-Discovery of TrackBack Ping URLs
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+    <rdf:Description
+        rdf:about="<?php echo $read_url; ?>"
+        dc:identifier="<?php echo $read_url; ?>"
+        dc:title="<?php echo $row['title'] ?>"
+        trackback:ping="<?php echo $trackback_url; ?>" />
+</rdf:RDF>
+-->
diff --git a/news/templates/news/comments.php b/news/templates/news/comments.php
new file mode 100644 (file)
index 0000000..b99f778
--- /dev/null
@@ -0,0 +1,21 @@
+<br />
+<?php
+// show comments only of allowd for api, for current news and if agora exists
+if ($conf['comments']['allow'] != 'never' && 
+    $row['comments']>-1 && 
+    $registry->hasMethod('forums/doComments')) {
+
+    $params = array('news', $id, 'commentCallback', true, null, null,
+                    array('message_subject' => $row['title']), $conf['comments']['comment_template']);
+
+    $comments = $registry->call('forums/doComments', $params);
+
+    if (!empty($comments['threads'])) {
+        echo $comments['threads'];
+    }
+
+    if (!empty($comments['comments'])) {
+        echo $comments['comments'];
+    }
+}
+
diff --git a/news/templates/news/gallery.php b/news/templates/news/gallery.php
new file mode 100644 (file)
index 0000000..cdf73b7
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+// output the gallery
+if (empty($row['gallery'])
+    || !is_array($images = News::getGalleyImages($row['gallery']))) {
+    return;
+}
+
+$path = $GLOBALS['registry']->get('webroot', 'horde') . '/vfs/.horde/ansel/';
+$dim = $conf['images']['image_height'] . ',' . $conf['images']['image_width'];
+
+echo '<br /><div style="text-lign: center;">';
+foreach ($images as $image_id => $image) {
+    $img_url = substr($image_id, -2) . '/%s/' . $image_id . '.jpg';
+    echo "\n" . '<div class="imggallery">' .
+            Horde::link('#', $image['name'], '', '', 'popup(\'' . $path . sprintf($img_url, 'screen') . '\',' . $dim . ')')  . "\n" .
+            '<img src="' . $path . sprintf($img_url, 'thumb') . '" />' .
+            $image['caption'].  '</a></div>';
+}
+echo '</div>';
+
diff --git a/news/templates/news/info.php b/news/templates/news/info.php
new file mode 100644 (file)
index 0000000..3bdcd13
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+echo '<div class="header">' . _("News data") . '</div>';
+echo _("By") . ': ' .  Horde::link(Util::addParameter($browse_url, 'user', $row['user'])) . $row['user'] . '</a><br />';
+echo _("On") . ': ' .  Horde::link(Util::addParameter($browse_url, 'publish', $row['publish'])) . $news->dateFormat($row['publish']) . '</a><br />';
+echo _("Category") . ': ' . Horde::link(Util::addParameter($browse_url, 'cid', $row['category1'])) . $news_cat->getName($row['category1']) . '</a><br />';
+
+$plain = preg_replace('/\s\s+/', ' ', trim(strip_tags($row['content'])));
+echo _("Chars") . ': ' . number_format(strlen($plain)) . '<br />';
+echo _("Besed") . ': ' . number_format(substr_count($plain, ' ')) . '<br />';
+
+if ($row['sourcelink']) {
+    echo _("Source news") . ': ' .  Horde::externalUrl($row['sourcelink'], true) . _("Source news") . '</a><br />';
+}
+
+if ($row['source']) {
+    $sources = $news->getSources(true);
+    echo _("Source media") . ': ' .  Horde::externalUrl($sources[$row['source']]['source_url'], true) .
+                                     $sources[$row['source']]['source_name'] . '</a><br />';
+}
\ No newline at end of file
diff --git a/news/templates/news/mail.php b/news/templates/news/mail.php
new file mode 100644 (file)
index 0000000..0fe1849
--- /dev/null
@@ -0,0 +1,7 @@
+<br />
+<div class="header"><?php echo _("Send by mail") ?></div>
+<form id="mail_send" name="mail_send" method="post" action="<?php echo Horde::applicationUrl('mail.php') ?>">
+<input type="text" name="email" id="email" size="15" />
+<input type="hidden" name="id" id="id" value="<?php echo $id ?>" />
+<input type="image" src="<?php echo $registry->getImageDir('horde') ?>/mail.png"></a>
+</form>
diff --git a/news/templates/news/news.php b/news/templates/news/news.php
new file mode 100644 (file)
index 0000000..1b7c2b1
--- /dev/null
@@ -0,0 +1,43 @@
+<br />
+<h1 class="header"><?php echo $row['title'] ?></h1>
+<table style="width: 100%">
+<tr valign="top">
+<td>
+<?php
+
+if ($row['picture'])  {
+    echo '<div id="news_picture"><img src="' . News::getImageUrl($id, 'big') . '" /><br />';
+    echo $row['picture_comment'] . '</div>';
+}
+
+$plain_text = trim(strip_tags($row['content']));
+echo '<div id="capital">' . substr($plain_text, 0, 1) . '</div>';
+echo $row['content'];
+
+if ($row['sponsored']) {
+    echo '<span class="sposored">' . _("* Sponsored news") . '</span>';
+}
+
+require NEWS_TEMPLATES . '/news/parents.php';
+require NEWS_TEMPLATES . '/news/attachments.php';
+require NEWS_TEMPLATES . '/news/ulaform.php';
+require NEWS_TEMPLATES . '/news/selling.php';
+require NEWS_TEMPLATES . '/news/gallery.php';
+require NEWS_TEMPLATES . '/news/threads.php';
+require NEWS_TEMPLATES . '/news/comments.php';
+
+?>
+</td>
+<td style="border-left: 1px solid #cccccc; padding-left: 5px; width: 150px;">
+<?php
+
+require NEWS_TEMPLATES . '/news/info.php';
+require NEWS_TEMPLATES . '/news/today.php';
+require NEWS_TEMPLATES . '/news/blog.php';
+require NEWS_TEMPLATES . '/news/tools.php';
+require NEWS_TEMPLATES . '/news/mail.php';
+
+?>
+</td>
+</tr>
+</table>
\ No newline at end of file
diff --git a/news/templates/news/parents.php b/news/templates/news/parents.php
new file mode 100644 (file)
index 0000000..76c8f6c
--- /dev/null
@@ -0,0 +1,12 @@
+<br />
+<?php
+// output the gallery
+if ($row['parents']) {
+    echo _("Parents") .  ':<ul>';
+    foreach ($row['parents'] as $parent_id => $data) {
+        echo '<li>' . $news->dateFormat($data['publish']) . ' ' 
+             . Horde::link(Util::addParameter($news_url, 'id', $parent_id), _("Read"))
+             . $data['title'] . '</a> (' . ($data['comments']> -1 ? $data['comments'] : 0) . ')';
+    }
+    echo '</ul>';
+}
diff --git a/news/templates/news/selling.php b/news/templates/news/selling.php
new file mode 100644 (file)
index 0000000..576d725
--- /dev/null
@@ -0,0 +1,14 @@
+<br />
+<br />
+<?php
+// schedul
+if ($row['selling']) {
+    $item = explode('|', $row['selling']);
+    $sell_from = $registry->call($item[0] . '/getSellingForm', $item[1]);
+    if ($sell_from instanceof PEAR_Error) {
+        echo $sell_from->getMessage();
+    } else {
+        echo $sell_from;
+    }
+}
+
diff --git a/news/templates/news/threads.php b/news/templates/news/threads.php
new file mode 100644 (file)
index 0000000..7eeb6e8
--- /dev/null
@@ -0,0 +1,14 @@
+<br />
+<?php
+// show threads
+if ($row['threads']) {
+
+    echo '<strong>' . sprintf(_("Threads in %s"), $registry->get('name', 'agora')) . ':</strong>';
+    $agore_link = $registry->get('webroot', 'agora');
+    echo '<ul>';
+    foreach ($row['threads'] as $thread_id => $thread) {
+        echo '<li>- <a href="' . $agore_link . '/messages/index.php?scope=agora&agora=' . $thread['forum_id'] . '.' . $thread_id . '">'
+                . $thread['message_subject'] . '</a> (' . $thread['message_seq'] . ')' . '</li>';
+    }
+    echo '</ul>';
+}
diff --git a/news/templates/news/today.php b/news/templates/news/today.php
new file mode 100644 (file)
index 0000000..9608650
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+echo '<br /><div class="header">' . _("On this day") . '</div>';
+$img = Horde::img('news.png', '', '', $registry->getImageDir('news'));
+echo $img . ' ' . Horde::link(Util::addParameter($browse_url, 'date', $row['publish'])) . _("News of this day.") . '</a><br />';
+
+if ($registry->hasInterface('schedul')) {
+    $img = Horde::img('schedul.png', '', '', $registry->getImageDir('schedul'));
+    $url = $registry->get('webroot', 'schedul') . '/browse.php';
+    $url = Util::addParameter($url, array('actionID' => 'date', 'date' => $row['publish']));
+    echo $img . ' ' . Horde::link($url) . _("Events on this day.") . '</a><br />';
+}
+
diff --git a/news/templates/news/tools.php b/news/templates/news/tools.php
new file mode 100644 (file)
index 0000000..0b3188e
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+echo '<br /><div class="header">' . _("Tools") . '</div>';
+
+$img = Horde::img('print.png', '', '', $registry->getImageDir('horde'));
+echo $img . ' ' . Horde::link('javascript:window.print()') . _("Printer firendly") . '</a><br />';
+
+$img = Horde::img('mime/pdf.png', '', '', $registry->getImageDir('horde'));
+echo $img . ' ' . Horde::link(Util::addParameter(Horde::applicationUrl('pdf.php'), 'id', $id)) . _("PDF") . '</a><br />';
+
+if ($registry->hasInterface('bookmarks')) {
+    $img = Horde::img('trean.png', '', '', $registry->getImageDir('trean'));
+    $url = $registry->get('webroot', 'trean') . '/add.php';
+    $url = Util::addParameter($url, array('url' => Util::addParameter($news_url, 'id', $id),
+                                          'title' => $row['title']));
+    echo $img . ' ' . Horde::link($url) . _("Add to bookmarks.") . '</a><br />';
+}
+
+if ($registry->hasInterface('notes')) {
+    $img = Horde::img('mnemo.png', '', '', $registry->getImageDir('mnemo'));
+    $url = Util::addParameter(Horde::applicationUrl('note.php', true), 'id', $id);
+    echo $img . ' ' . Horde::link($url) . _("Add to notes.") . '</a><br />';
+}
+
diff --git a/news/templates/news/ulaform.php b/news/templates/news/ulaform.php
new file mode 100644 (file)
index 0000000..f8e8369
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$row['forum_id'] = 9;
+
+if (empty($row['form_id']) || ($row['form_ttl'] > $_SERVER['REQUEST_TIME'])) {
+    return;
+}
+
+$form = $registry->callByPackage('ulaform', 'display', array($row['form_id']));
+if ($form instanceof PEAR_Error) {
+    echo $form;
+} elseif ($form === true) {
+    echo _("Thanks");
+} else {
+    echo '<h1 class="header">' . $form['title'] . '</h1>';
+    echo $form['form'];
+}
diff --git a/news/templates/print/footer.inc b/news/templates/print/footer.inc
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/news/templates/print/header.inc b/news/templates/print/header.inc
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/news/templates/reads/footer.inc b/news/templates/reads/footer.inc
new file mode 100755 (executable)
index 0000000..000ca4b
--- /dev/null
@@ -0,0 +1 @@
+</table>
diff --git a/news/templates/reads/header.inc b/news/templates/reads/header.inc
new file mode 100755 (executable)
index 0000000..c192b79
--- /dev/null
@@ -0,0 +1,10 @@
+<div class="header"><?php echo $title ?></div>
+<table class="striped sortable" style="width: 100%;">
+<thead>
+<tr>
+<th><?php echo _("News") ?></th>
+<th><?php echo _("User") ?></th>
+<th><?php echo _("IP") ?></th>
+<th><?php echo _("Date") ?></th>
+</tr>
+</thead>
diff --git a/news/templates/reads/row.inc b/news/templates/reads/row.inc
new file mode 100755 (executable)
index 0000000..38ac7cb
--- /dev/null
@@ -0,0 +1,6 @@
+<tr>
+<td><?php echo Horde::link(Util::addParameter($url, 'id', $row['id']), $row['title']) . $row['id'] . '</a>'; ?></td>
+<td><?php echo Horde::link(Util::addParameter($url, 'actionID', $row['user']), $row['user']) . $row['user'] . '</a>'; ?></td>
+<td><?php echo $row['ip'] ?></td>
+<td><?php echo $row['readdate'] ?></td>
+</tr>
diff --git a/news/templates/sources/index.php b/news/templates/sources/index.php
new file mode 100644 (file)
index 0000000..0c0f401
--- /dev/null
@@ -0,0 +1,18 @@
+<table style="width: 100%;" id="sources_list" class="sortable striped">
+<thead>
+<tr>
+<th><?php echo $this->add_url ?></th>
+<th><?php echo _("Id") ?></th>
+<th><?php echo _("Name") ?></th>
+<th><?php echo _("Url") ?></th>
+</tr>
+</thead>
+<?php foreach ($this->sources as $source_id => $source) { ?>
+<tr>
+<td><?php foreach ($source['actions'] as $action ) { echo $action . ' '; } ?></td>
+<td><?php echo $source_id ?></td>
+<td><?php echo $source['source_name'] ?></td>
+<td><?php echo $source['source_url'] ?></td>
+</tr>
+<?php } ?>
+</table>
diff --git a/news/themes/graphics/folder_open.png b/news/themes/graphics/folder_open.png
new file mode 100755 (executable)
index 0000000..a6b525b
Binary files /dev/null and b/news/themes/graphics/folder_open.png differ
diff --git a/news/themes/graphics/mkdir.png b/news/themes/graphics/mkdir.png
new file mode 100755 (executable)
index 0000000..0b4d90d
Binary files /dev/null and b/news/themes/graphics/mkdir.png differ
diff --git a/news/themes/graphics/news.png b/news/themes/graphics/news.png
new file mode 100755 (executable)
index 0000000..9009dac
Binary files /dev/null and b/news/themes/graphics/news.png differ
diff --git a/news/themes/microfila/graphics/favicon.ico b/news/themes/microfila/graphics/favicon.ico
new file mode 100755 (executable)
index 0000000..f8694d5
Binary files /dev/null and b/news/themes/microfila/graphics/favicon.ico differ
diff --git a/news/themes/screen.css b/news/themes/screen.css
new file mode 100755 (executable)
index 0000000..a3d4565
--- /dev/null
@@ -0,0 +1,82 @@
+div#capital {
+    float: left;
+    font-size: 350%;
+    font-weight: bold;
+    color: black;
+    width: 1.2em;
+    text-align: center;
+    background: #eeeeee;
+    padding: 5;
+    border-width: 0 0.1em 0.1em 0;
+    margin: 0 0.1em 0.1em 0;
+    text-transform: uppercase; 
+}
+
+div#news_picture {
+    float: right;
+    border: 1px;
+    font-style: italic;
+    background-color : rgb(238, 238, 238);
+    margin-bottom : 2px;
+    margin-left : 3px;
+    margin-right : 0px;
+    margin-top : 0px;
+    text-align : justify;
+    vertical-align : top;
+    max-width: 300px;
+    margin-left-ltr-source: physical;
+    margin-left-rtl-source: physical;
+    margin-right-ltr-source: physical;
+    margin-right-rtl-source: physical;
+}
+
+#news_picture img {
+    border: 1px solid black;
+}
+
+.imggallery {
+    margin: 5px;
+    text-align: center;
+    border: 1px solid black;
+    width: 24%;
+    display: inline;
+}
+
+.imggallery img, .imggallery a {
+    margin: 15px;
+    display: inline;
+}
+
+.blogs {
+    padding: 5px;
+    margin-top: 15px;
+    margin-bottom: 25px;
+    border: 1px solid #ccc;
+    background: #eee;
+}
+
+.sposored {
+    font-size: 80%;
+    font-style: italic;
+    clear: both;
+}
+
+/* HTMLTAG. */
+a.earliest:link, a.earliest:visited, a.earliest:hover, a.earliest:active {
+    color: #ccc;
+    font-size: 140%;
+}
+
+a.earlier:link, a.earlier:visited, a.earlier:hover, a.earlier:active {
+    color: #99c;
+    font-size: 120%;
+}
+
+a.later:link, a.later:visited, a.later:hover, a.later:active {
+    color: #99f;
+}
+
+a.latest:link, a.latest:visited, a.latest:hover, a.latest:active {
+    color: #00f;
+    font-size: 80%;
+}
\ No newline at end of file
diff --git a/news/trackback.php b/news/trackback.php
new file mode 100644 (file)
index 0000000..405611e
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * $Id: trackback.php 183 2008-01-06 17:39:50Z duck $
+ *
+ * Copyright 2007 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ */
+define('AUTH_HANDLER', true);
+define('NEWS_BASE', dirname(__FILE__));
+require_once NEWS_BASE . '/lib/base.php';
+
+if ($browser->isRobot()) {
+    exit;
+}
+
+header('Content-type: text/xml');
+
+/* Try to create object */
+$trackback_data = array(
+    'id'        => Util::getFormData('id'),
+    'host'      => $_SERVER['REMOTE_ADDR'],
+    'title'     => Util::getFormData('title'),
+    'excerpt'   => Util::getFormData('excerpt'),
+    'url'       => Util::getFormData('url'),
+    'blog_name' => Util::getFormData('blog_name')
+);
+
+$trackback = News::loadTrackback($trackback_data);
+if ($trackback instanceof PEAR_Error) {
+    echo Services_Trackback::getResponseError($trackback->getMessage(), 1);
+    exit;
+}
+
+/* Check if the needed data is posted */
+foreach ($trackback_data as $key => $value) {
+    if ($key != 'excerpt' && empty($value)) {
+        echo Services_Trackback::getResponseError($key . ' is required', 2);
+        exit;
+    }
+}
+
+/* Get the response and check if the request has all data */
+$request = $trackback->receive();
+if ($trackback instanceof PEAR_Error) {
+    echo Services_Trackback::getResponseError($request->getMessage(), 3);
+    exit;
+}
+
+/* Check if the message is a spam */
+if (!empty($conf['trackback']['spamcheck'])) {
+    foreach ($conf['trackback']['spamcheck'] as $type) {
+        $trackback->createSpamCheck($type);
+    }
+    if ($trackback->checkSpam()) {
+        echo Services_Trackback::getResponseError('SPAM', 4);
+        exit;
+    }
+}
+
+/* Check if the forum exists */
+$id = (int)$trackback->get('id');
+if ($id == 0) {
+    echo Services_Trackback::getResponseError(sprintf(_("Blog entry %s does not exist."), $id), 5);
+}
+
+$news_data = $news->get($id);
+if ($news_data instanceof PEAR_Error) {
+    echo Services_Trackback::getResponseError($news_data->getMessage(), 5);
+    exit;
+}
+
+/* Store the trackback data */
+$result = $news->saveTrackback($id,
+                               $trackback->get('title'),
+                               $trackback->get('url'),
+                               $trackback->get('excerpt'),
+                               $trackback->get('blog_name'),
+                               $trackback->get('trackback_url'));
+if ($result instanceof PEAR_Error) {
+    echo Services_Trackback::getResponseError($result->getMessage(), 6);
+    exit;
+}
+
+/* All done */
+echo Services_Trackback::getResponseSuccess();