From b0c38e3f19a4405b01ff3bd45cede89f9ca68c79 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Wed, 3 Dec 2008 10:34:28 -0500 Subject: [PATCH] toss Duck's news app into the hatchery so it's around somewhere other than the wiki --- news/add.php | 492 ++++++++++++ news/admin/categories/delete.php | 42 + news/admin/categories/edit.php | 57 ++ news/admin/categories/index.php | 47 ++ news/admin/sources/delete.php | 43 ++ news/admin/sources/edit.php | 55 ++ news/admin/sources/index.php | 49 ++ news/admin/tabs.php | 27 + news/browse.php | 68 ++ news/cloud.php | 28 + news/config/conf.xml | 113 +++ news/config/prefs.php.dist | 51 ++ news/content.php | 26 + news/content_edit.php | 33 + news/delete.php | 68 ++ news/diff.php | 61 ++ news/edit.php | 183 +++++ news/feed.php | 36 + news/files.php | 74 ++ news/index.php | 25 + news/js/feed.js | 24 + news/lib/Block/categories.php | 35 + news/lib/Block/category.php | 65 ++ news/lib/Block/jonah.php | 60 ++ news/lib/Block/last.php | 63 ++ news/lib/Block/last_blogs.php | 51 ++ news/lib/Block/last_comments.php | 57 ++ news/lib/Block/most_commented.php | 55 ++ news/lib/Block/most_read.php | 55 ++ news/lib/Block/my_comments.php | 80 ++ news/lib/Block/sources.php | 45 ++ news/lib/Block/tags_cloud.php | 39 + news/lib/Categories.php | 599 +++++++++++++++ news/lib/Forms/Search.php | 127 +++ news/lib/News.php | 1066 ++++++++++++++++++++++++++ news/lib/TagCloud.php | 36 + news/lib/View.php | 99 +++ news/lib/api.php | 148 ++++ news/lib/base.php | 63 ++ news/lib/version.php | 1 + news/locale/sl_SI/LC_MESSAGES/news.mo | Bin 0 -> 10969 bytes news/mail.php | 67 ++ news/news.php | 59 ++ news/note.php | 48 ++ news/pdf.php | 60 ++ news/po/messages.mo | Bin 0 -> 9367 bytes news/po/news.pot | 875 +++++++++++++++++++++ news/po/sl_SI.po | 870 +++++++++++++++++++++ news/print.php | 26 + news/reads.php | 52 ++ news/rss/comments.php | 54 ++ news/rss/index.php | 56 ++ news/rss/news.php | 84 ++ news/scripts/sql/news.mysql.sql | 103 +++ news/scripts/upgrades/20070302_trackback.sql | 13 + news/scripts/upgrades/20070609_sponsored.sql | 2 + news/scripts/upgrades/20071220_tags.sql | 1 + news/search.php | 73 ++ news/tags.php | 40 + news/templates/add/before.inc | 0 news/templates/block/news.php | 19 + news/templates/block/titles.php | 21 + news/templates/browse/footer.inc | 1 + news/templates/browse/header.inc | 3 + news/templates/browse/row.inc | 12 + news/templates/categories/delete.html | 9 + news/templates/categories/edit.html | 9 + news/templates/categories/index.html | 5 + news/templates/categories/index.php | 27 + news/templates/common-header.inc | 31 + news/templates/edit/footer.inc | 4 + news/templates/edit/header.inc | 17 + news/templates/edit/info.inc | 107 +++ news/templates/edit/info.php | 112 +++ news/templates/edit/row.php | 62 ++ news/templates/menu.inc | 13 + news/templates/news/attachments.php | 5 + news/templates/news/blog.php | 39 + news/templates/news/comments.php | 21 + news/templates/news/gallery.php | 20 + news/templates/news/info.php | 20 + news/templates/news/mail.php | 7 + news/templates/news/news.php | 43 ++ news/templates/news/parents.php | 12 + news/templates/news/selling.php | 14 + news/templates/news/threads.php | 14 + news/templates/news/today.php | 13 + news/templates/news/tools.php | 24 + news/templates/news/ulaform.php | 17 + news/templates/print/footer.inc | 0 news/templates/print/header.inc | 0 news/templates/reads/footer.inc | 1 + news/templates/reads/header.inc | 10 + news/templates/reads/row.inc | 6 + news/templates/sources/index.php | 18 + news/themes/graphics/folder_open.png | Bin 0 -> 703 bytes news/themes/graphics/mkdir.png | Bin 0 -> 1008 bytes news/themes/graphics/news.png | Bin 0 -> 717 bytes news/themes/microfila/graphics/favicon.ico | Bin 0 -> 318 bytes news/themes/screen.css | 82 ++ news/trackback.php | 89 +++ 101 files changed, 7736 insertions(+) create mode 100644 news/add.php create mode 100644 news/admin/categories/delete.php create mode 100644 news/admin/categories/edit.php create mode 100644 news/admin/categories/index.php create mode 100644 news/admin/sources/delete.php create mode 100644 news/admin/sources/edit.php create mode 100644 news/admin/sources/index.php create mode 100644 news/admin/tabs.php create mode 100644 news/browse.php create mode 100644 news/cloud.php create mode 100644 news/config/conf.xml create mode 100644 news/config/prefs.php.dist create mode 100644 news/content.php create mode 100644 news/content_edit.php create mode 100644 news/delete.php create mode 100644 news/diff.php create mode 100644 news/edit.php create mode 100644 news/feed.php create mode 100644 news/files.php create mode 100644 news/index.php create mode 100644 news/js/feed.js create mode 100755 news/lib/Block/categories.php create mode 100755 news/lib/Block/category.php create mode 100755 news/lib/Block/jonah.php create mode 100755 news/lib/Block/last.php create mode 100755 news/lib/Block/last_blogs.php create mode 100755 news/lib/Block/last_comments.php create mode 100755 news/lib/Block/most_commented.php create mode 100755 news/lib/Block/most_read.php create mode 100644 news/lib/Block/my_comments.php create mode 100755 news/lib/Block/sources.php create mode 100644 news/lib/Block/tags_cloud.php create mode 100755 news/lib/Categories.php create mode 100644 news/lib/Forms/Search.php create mode 100755 news/lib/News.php create mode 100644 news/lib/TagCloud.php create mode 100755 news/lib/View.php create mode 100755 news/lib/api.php create mode 100755 news/lib/base.php create mode 100755 news/lib/version.php create mode 100755 news/locale/sl_SI/LC_MESSAGES/news.mo create mode 100644 news/mail.php create mode 100644 news/news.php create mode 100644 news/note.php create mode 100644 news/pdf.php create mode 100644 news/po/messages.mo create mode 100644 news/po/news.pot create mode 100644 news/po/sl_SI.po create mode 100644 news/print.php create mode 100644 news/reads.php create mode 100644 news/rss/comments.php create mode 100644 news/rss/index.php create mode 100755 news/rss/news.php create mode 100644 news/scripts/sql/news.mysql.sql create mode 100644 news/scripts/upgrades/20070302_trackback.sql create mode 100644 news/scripts/upgrades/20070609_sponsored.sql create mode 100644 news/scripts/upgrades/20071220_tags.sql create mode 100644 news/search.php create mode 100644 news/tags.php create mode 100755 news/templates/add/before.inc create mode 100644 news/templates/block/news.php create mode 100644 news/templates/block/titles.php create mode 100755 news/templates/browse/footer.inc create mode 100755 news/templates/browse/header.inc create mode 100755 news/templates/browse/row.inc create mode 100755 news/templates/categories/delete.html create mode 100755 news/templates/categories/edit.html create mode 100755 news/templates/categories/index.html create mode 100644 news/templates/categories/index.php create mode 100755 news/templates/common-header.inc create mode 100755 news/templates/edit/footer.inc create mode 100755 news/templates/edit/header.inc create mode 100755 news/templates/edit/info.inc create mode 100644 news/templates/edit/info.php create mode 100644 news/templates/edit/row.php create mode 100755 news/templates/menu.inc create mode 100644 news/templates/news/attachments.php create mode 100644 news/templates/news/blog.php create mode 100644 news/templates/news/comments.php create mode 100644 news/templates/news/gallery.php create mode 100644 news/templates/news/info.php create mode 100644 news/templates/news/mail.php create mode 100644 news/templates/news/news.php create mode 100644 news/templates/news/parents.php create mode 100644 news/templates/news/selling.php create mode 100644 news/templates/news/threads.php create mode 100644 news/templates/news/today.php create mode 100644 news/templates/news/tools.php create mode 100644 news/templates/news/ulaform.php create mode 100755 news/templates/print/footer.inc create mode 100755 news/templates/print/header.inc create mode 100755 news/templates/reads/footer.inc create mode 100755 news/templates/reads/header.inc create mode 100755 news/templates/reads/row.inc create mode 100644 news/templates/sources/index.php create mode 100755 news/themes/graphics/folder_open.png create mode 100755 news/themes/graphics/mkdir.png create mode 100755 news/themes/graphics/news.png create mode 100755 news/themes/microfila/graphics/favicon.ico create mode 100755 news/themes/screen.css create mode 100644 news/trackback.php diff --git a/news/add.php b/news/add.php new file mode 100644 index 000000000..73919ee46 --- /dev/null +++ b/news/add.php @@ -0,0 +1,492 @@ + + * + * 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 + * @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 index 000000000..2a1a30a95 --- /dev/null +++ b/news/admin/categories/delete.php @@ -0,0 +1,42 @@ + + * + * 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 index 000000000..41f1476cc --- /dev/null +++ b/news/admin/categories/edit.php @@ -0,0 +1,57 @@ + + * + * 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 index 000000000..fa65fa5d8 --- /dev/null +++ b/news/admin/categories/index.php @@ -0,0 +1,47 @@ + + * + * 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 . ''; + $categories[$category_id]['actions'][] = Horde::link(Util::addParameter($edit_url, 'category_id', $category_id), _("Edit")) . + $edit_img . ''; +} + +$view = new News_View(); +$view->categories = $categories; +$view->add_url = Horde::link($edit_url, _("Add New")) . _("Add New") . ''; + +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 index 000000000..59f940cd6 --- /dev/null +++ b/news/admin/sources/delete.php @@ -0,0 +1,43 @@ + + * + * 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 index 000000000..5d54270b5 --- /dev/null +++ b/news/admin/sources/edit.php @@ -0,0 +1,55 @@ + + * + * 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 index 000000000..0da38e952 --- /dev/null +++ b/news/admin/sources/index.php @@ -0,0 +1,49 @@ + + * + * 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 . ''; + $sources[$source_id]['actions'][] = Horde::link(Util::addParameter($delete_url, 'source_id', $source_id), _("Delete")) . + $delete_img . ''; + $sources[$source_id]['actions'][] = Horde::link(Util::addParameter($edit_url, 'source_id', $source_id), _("Edit")) . + $edit_img . ''; +} + +$view = new News_View(); +$view->sources = $sources; +$view->add_url = Horde::link($edit_url, _("Add New")) . _("Add New") . ''; + +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 index 000000000..398ed05d6 --- /dev/null +++ b/news/admin/tabs.php @@ -0,0 +1,27 @@ + + */ + +/* 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 index 000000000..e36d3cbbc --- /dev/null +++ b/news/browse.php @@ -0,0 +1,68 @@ + + * + * 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 + * @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 index 000000000..1062699db --- /dev/null +++ b/news/cloud.php @@ -0,0 +1,28 @@ + +* @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 index 000000000..9f4934f8d --- /dev/null +++ b/news/config/conf.xml @@ -0,0 +1,113 @@ + + + + + + + + These are the settings for storing all the News data, such as categories, + items within those categories, item options, etc. + + sql + + + + + horde_datatree + horde_datatree_attributes + + + + + + + + + + + Settings for displaying + 130 + + + + Enable optional news attributes + TRUE + TRUE + false + + + + + + + + + + Images settigns + true + horde + + horde_vfs + + + /schedul-images + png + + jpeg + png + + + 150 + 150 + 300 + 300 + + + + Comments + authenticated + + authenticated + never + all + + + + + + + + + + Trackback Settings + 1 + 30 + 30 + + + Wordlist + Regex + DNSBL + SURBL + + + + + + + + Menu Settings + + + + + + + + + + + diff --git a/news/config/prefs.php.dist b/news/config/prefs.php.dist new file mode 100644 index 000000000..50177dd08 --- /dev/null +++ b/news/config/prefs.php.dist @@ -0,0 +1,51 @@ + _("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 index 000000000..bbe1ee175 --- /dev/null +++ b/news/content.php @@ -0,0 +1,26 @@ + + */ + +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 '
 
'; +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 index 000000000..6dd244b8e --- /dev/null +++ b/news/content_edit.php @@ -0,0 +1,33 @@ + + */ + +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 index 000000000..ada3de8de --- /dev/null +++ b/news/delete.php @@ -0,0 +1,68 @@ + + * + * @author Duck + * @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 index 000000000..233aa108b --- /dev/null +++ b/news/diff.php @@ -0,0 +1,61 @@ + + * + * 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 + * @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 '
' . $nls['languages'][$k] . '
' . "\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 index 000000000..db45118ca --- /dev/null +++ b/news/edit.php @@ -0,0 +1,183 @@ + + * + * 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 + * @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 index 000000000..e454ff9e9 --- /dev/null +++ b/news/feed.php @@ -0,0 +1,36 @@ + + * + * 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 + * @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']) + . ' ' . $story['story_title'] . '
'; +} diff --git a/news/files.php b/news/files.php new file mode 100644 index 000000000..314e9fad7 --- /dev/null +++ b/news/files.php @@ -0,0 +1,74 @@ + + * + * 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 + * @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 index 000000000..8a3a7fa54 --- /dev/null +++ b/news/index.php @@ -0,0 +1,25 @@ + + * + * 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 + * @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 index 000000000..a3a786bce --- /dev/null +++ b/news/js/feed.js @@ -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 index 000000000..64e88766b --- /dev/null +++ b/news/lib/Block/categories.php @@ -0,0 +1,35 @@ +getHtml(); + } + +} diff --git a/news/lib/Block/category.php b/news/lib/Block/category.php new file mode 100755 index 000000000..330036752 --- /dev/null +++ b/news/lib/Block/category.php @@ -0,0 +1,65 @@ +_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) . ''; + + 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 index 000000000..6e74ae9e7 --- /dev/null +++ b/news/lib/Block/jonah.php @@ -0,0 +1,60 @@ +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") . ''; + } + + /** + * The content to go in this block. + * + * @return string The content + */ + function _content() + { + $html = '
'; + $html .= _("Select a feed."); + $html .= '
'; + + 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 .= '
' + . '
'; + + 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 index 000000000..1b96aa147 --- /dev/null +++ b/news/lib/Block/last.php @@ -0,0 +1,63 @@ +'; + } + + 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 index 000000000..2f52f58cb --- /dev/null +++ b/news/lib/Block/last_blogs.php @@ -0,0 +1,51 @@ + 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 index 000000000..402765512 --- /dev/null +++ b/news/lib/Block/last_comments.php @@ -0,0 +1,57 @@ + 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'] . ' ' + . ' (' . $message['message_author'] . ')
'; + } + return $html; + } + +} diff --git a/news/lib/Block/most_commented.php b/news/lib/Block/most_commented.php new file mode 100755 index 000000000..a4bfed179 --- /dev/null +++ b/news/lib/Block/most_commented.php @@ -0,0 +1,55 @@ + 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 index 000000000..aff21f382 --- /dev/null +++ b/news/lib/Block/most_read.php @@ -0,0 +1,55 @@ + 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 index 000000000..61aeacadb --- /dev/null +++ b/news/lib/Block/my_comments.php @@ -0,0 +1,80 @@ + 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 = '' + . '' + . ''; + + $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 .= ''; + } + $html .= '
' . _("Title") . '' . _("User") . '
' + . '' + . $message['message_subject'] . ' ' + . '' + . $message['message_author'] . '
'; + + $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 index 000000000..9316990c7 --- /dev/null +++ b/news/lib/Block/sources.php @@ -0,0 +1,45 @@ +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 . '
'; + } + + return $html; + } + +} diff --git a/news/lib/Block/tags_cloud.php b/news/lib/Block/tags_cloud.php new file mode 100644 index 000000000..0a66943f1 --- /dev/null +++ b/news/lib/Block/tags_cloud.php @@ -0,0 +1,39 @@ +getCloud(true); + } + +} diff --git a/news/lib/Categories.php b/news/lib/Categories.php new file mode 100755 index 000000000..e2136e308 --- /dev/null +++ b/news/lib/Categories.php @@ -0,0 +1,599 @@ + + * @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 = ''; + + 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 .= ''; + } + $url = Util::addParameter($this->_view_url, 'cid', $node_id); + $output .= Horde::link($url) . $this->_nodes[$node_id]['category_name'] . ', '; + if ($this->_nodes[$node_id]['indent'] == 0) { + $output .= '
'; + } + + 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'] . ''; + } 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 . ''; + } + + $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 index 000000000..a71895ac4 --- /dev/null +++ b/news/lib/Forms/Search.php @@ -0,0 +1,127 @@ + + * + * @author Duck + * @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 index 000000000..04dda600d --- /dev/null +++ b/news/lib/News.php @@ -0,0 +1,1066 @@ + + * @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 = '
'; + $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'dowload_zip', 'id' => $id)), _("Compress and dowload all files at once")) . $dowload_zip . ' ' . "\n"; + $html .= _("Attached files: ") . '' . "\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 . ' ' . "\n"; + $html .= Horde::link(Util::addParameter($view_url, array('actionID' => 'dowload_file', 'dir' => $dir, 'file' => $file)), sprintf(_("Dowload %s"), $file)) . $dowload_img . ' ' . "\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 . ' ' . "\n"; + + $html .= ' (' . self::format_filesize($file_data['filesize']) . ')'; + $html .= '
' . "\n"; + } + + $html .= '
'; + + 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 index 000000000..b594d9062 --- /dev/null +++ b/news/lib/TagCloud.php @@ -0,0 +1,36 @@ +%s\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 index 000000000..552c0c107 --- /dev/null +++ b/news/lib/View.php @@ -0,0 +1,99 @@ + + * @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 .= '' . $tag . ' '; + } + + return $html; + } +} diff --git a/news/lib/api.php b/news/lib/api.php new file mode 100755 index 000000000..5723e8f73 --- /dev/null +++ b/news/lib/api.php @@ -0,0 +1,148 @@ + + * + * 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 + * @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 index 000000000..e6561e80d --- /dev/null +++ b/news/lib/base.php @@ -0,0 +1,63 @@ + + * + * 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 + * @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 index 000000000..faa86efdf --- /dev/null +++ b/news/lib/version.php @@ -0,0 +1 @@ + \ 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 index 0000000000000000000000000000000000000000..8df9f2cf36208065e6bb6f1f6cae36b6851d2bc7 GIT binary patch literal 10969 zcmb7|dz2(qeaElJb9h8BD-acn=fXnw&Mwakk7ajf7bg3dac5?M5yk56nwjdZu4<~P zdzguUZxq-FQCTpc>_UtXQ4@t=M2xumhX)Qh$B5y063ibVCecL9;{+3xe7?7C^~^3S z9_!4nKUKGG-TS-0`}_Uwz4O9x2Y=FVJ%zjlIpF^OwU8!F4&Mwv3{Ql+q1t}}s{T{%{nJq2{Scl3UxCv5 zj5ikJ8HBR?MNs`+3Z>VTP~VNZ@);=mrBLI&8S1;+p!B%|o(*@yv*5E(_IeqrUGv+< zya^l$_1!5@?JS3~|G7~1UJIq)7?d7UQ0@3o?S$}Dn8Q=x-Hc+>_vGP~WYGvj0_%Q&4t%CzPIbsP<-|^i1Fh@J6Wb?}F0zVW|GU0%ebH z!QX<!q~rT3el>~j*Fge#!z|6Zv6c0l#B6RMwwp#0&h zQ1*EaO5dMBjqflfQ}!Ex^3!GTt?&$}_rp;AUE#{d;c}j@hiAfjp!F-qr=jBQyHMkJ z9!l>YIQ|eyub)8Kb}gQ~aNl|KXt0rMD?Uf*`*&pW>8_#f~z-oFCnKd0e5vgcZ;_D7-gzZRcc_-x0Jirg8FkgqV!*h@+GJg*>um1(r-Y=o@(INb3o;)ahE_19y z>GKgNd)(!CFFcv&-BA9p2TGrRfNJ;0Q2qQT)cAkl%8#P5=JSp4B6vKM{l*+8q57MG z8uu(z{S3-a=Ag#$8MqQY2G!3$LG}L<)OddmrN_Y-Rpm!Ql^+k~UvGnT)`c^n`oEpQ zi+4gBZ}9CrKMVJ`3|Uf z-07Y_1u=zr5K8}VIz9u{{@+4OVEz?KkHfv0%|<(hSFyqo&)cNvirB8 z=HWX~dVL>Szkz!HW2o={8%qCUa5C`(D7&8m_5E^4iZd&r{9prAKI*#n_dw0#E+{=7 zh3fBlsPeGL+q(fa>QNsB!)P z4#GoEFZ8_-9?bIyRC`;Y^tl#F|2Zfi-i^{q1&q1Zv(Nhsu-BK#l(&9sk|&WvG4+T3)n20A+_a zz(e7QjviDy%iZ%DD1A0U^}iXazbW?|L)q~?Q1g4ct|;PW86*{&6Cf^aE`-Vh?|=jFHmH8?f=9pyT=^qVdOYsR_qg(B;p-^Z_2~lk zS2=O%wU&nuAeSN+BcDe|iDnLY9MK%<`W&ME{}lOiMAugl&4I2E*^FF=+=}SBs({sZ zf%}$w{sz1e*@UF7>;c$D666NtQRFMg;mBVg4dla!u3HezsphMK=(@gu{rx?DZ$p%q zG#BGY7r7jH2l6Cx9-{cZ8W};(MRYw-$gdKXZdA$Y0a2H*FD@s$UIU*s>o{OJ&3L^BOgU>Ms^`%$bHB#a-i!P z3LirT+{?S6@~>j--N^pe6%_Q4X=DxZUPSp!SB^Y{JcVpU?n3?q*@k=(xfi(*(REA# zv(xctxCMEidtMGtL6#wxxw13iC*A!j$2;H??*3!&V8lbdj$DGg3(@t5$VMbazKN9A zLEMZYce;WV@LJ@4ytPS;#?(jNjGYE^GVl>!dBqr zi5JGbFb`}IPif#cynHtB;$SWt@Fv1M3WmJXvw;C`tXqr1Y&K}<*&Em##x32M72bF! ziL)dP8ulwwsd!ls1@+vkRLt6X9wxCx&(8ycK9aspy5Abi*|PDZo7Qa=uTI^WB%QbA z(#77OU@b{nZ9i>g)v_c`@}PJM)s-JvEwDqLhP5v5sMrosLBC;^r+%SP6eV+BJ!!Ww z4RzA`Y}ljow6I0ibvJWB+*)X#mtTAh|dJs3lc*fpk<$a#}b*$t~hf$CX zd1kFGP%o|x4A3v4<3&B!1zFHA>!M^PGwaf1E(^@Md9&V+>p>(iQqQl~gDkU+%lPXH zJB5tW-RgtFcHVv??w1!sX;c?$W?eNq-HoDoFY|lB(sy${1E%N2uV(#}?n=v*H=d8h zR59yzI!T(_Mv`_XmA-!5@EXZnl;B=c`#|M>6ct934<`(oYVmZKwlPZS!o%{R;lRhM ztUC?cS)s&EPH+SB%Y=BHu%0u4l=tVz-jqu zLc^c0nvL@H(P;uXt1zUEY0^fiD==L^3}1;|+kQOnQ8)8ye!V4A5+wE3n#GsW-kLbf zI*~trfH&DJ4Rshp$Dax8hcttK^}=ATNIfHCW~5<8+Il|{Pbd6jL7JP*eunKzkF`(j zWU;8sT#GMk9<=tfW&7TFHA1v#(<-gU8K$gXm87bf-RHUV7Nf*zHYfGshtIb9?Z9kR zj?<4mbhPQ!-usOP;p9z_m;*b%Wb%-3u{N~%nmI}5ZJ5=Ipz-jQa9Z!?i7LX6=d2s% zek}^BMGw@p>w@i~;pcu)oaigEoSj+wu2ZId_u)S2g1o0`E7j&50Z%GH8)>a~T5nvM zw(WI0^rrl=8apPOOiwT zw=%ZbMnv16jNdkW0fx+P7UcR37Xq({oN-nFGamRXi4NqyG-~jG%QW`UW4u`DeQ!F@ zjJZd<_UR!~HfDd(<^kK0X*9z;U^4t<~-_LvOs)~6mwufdic4>(GHW^3Cc9XG7Ba3&W7(8>*W&<;sMrJb84lD4c z6D`K_9nFz~zTbg2&ElerLSC4QJ*mP{!-uKat|-(GhO>6eiYNJBX08bk5>a7Pc2XpR zBn{be(Op{P5$!9IxN7Uo5(T)V7ucLcknB^8nQbE0dejaxYgvq|Rj%~PswuZA4b$jv zS#+<>O2f!1V9DOf5X-?FWnF7BZpPB2$xga5(x_}N=5NT$qU**-2DSy-WL36gGhw5$ zt~--eCXyjsymvXf^gOFFwnk7*(wTv=(TU1>rb$Dq3}f*jZ}s5dg_TvSDuWk#t1cKi zclFtWs|E+DSlLF#(O8z&qw2YX-l|nY=bnG|AYTq>U8~?9aTfXPHHN$`Y{(ODOBgAS zUZU-JQf=F(%afWP`PD4EjIZLEE(>#IBJkNAj7Q|4IPfmXA~cqwmkn$g*|K4AoU5vX z1M7<=sxmR(LG3)aAz#VnAdD~8qLDHwmrhP>tX#BMPg+d}X=MWrsJ;1+cTp|O2d=JM zL1%1tr0%A5el3W+Rn=9is^<+DFR5{4N*d*nX*g;4O|O>)wJ=T$Vbx;?-1BSUIru9M zr+mb+WKRPL9zrHdI3I2GGlpajOWtU$>Gz^$5Hlqlp1d)}y5RSGcVOC-w1c!B`cdrD zIaPffn!*KI4RvUmZ21djZHql_nEFk#y%TDixKyj+iN2HaMVPv~7BkGzDQvR+wcl6` z%Lnot`iD`IB^~{i7BBep(<(}GW+q~qV`elg#;Ai?d4j5kO@IH#VU&qNuf^En+)wF# zZOV~KOG_N?*+C@jeKLrMMGcg=!ygsch5gpB3rhXHyY}qxo5`LX?1%P!WV!3e;3N!= zdo6{0QRJ6JzSj)AS{V6d^Re%$EPiEoWOhhqUH_~VQZ1;ZSqn>#D&m4xguWr0A+OD; zwvB5r<7iuU&Xk%>i&pO6`sA>n>BlJ2pM=GV2T-tjpts$u6YSlExw2WDnK|$N>gKIUV@{zN2eUfUCWk6>G)>6bxDmLs-?;awI7?a&_8@N0hte^;CWi}EtX^#~5e zU-e2i;s0U{dlt4+K^pFnOg&Xolrzg6;mvp||Gzbb4@KzN%Wo&aU?4b{x33 zTbjzQvR;5&si(d7voG6ay2ti`7m+`UquOK^G~EhDzqW4b&**=Q^0?6JvPJW23S;+; zCZyZ^4L|B6B+sZxhICU=RbK3+8drzpS;U_`esc6l6wi+3)D?k4UbpLm*Rp9hG-YBg zvvARnm$M7d+G)dDuDH*w&Y?_SKd<^`LiOWjSDw@K7jULqgln0J$4Q)?Jl)oFg`7fc%t7V+m5Jv->YdwNAIMa?0s@y z4H+n1$s5A7s$pxNRj%d?PunETmyQiB{?|H&#Um!V<97eu107hYAM>9Z?O6hj3~c{$ zpMRxuXuu9^;F6xwdocwvVb&s7ldH;&L$WxF8Zz0G$=uGY(lE)Nql->7soU1{cQw+V zVK6}Z6$>wQiUtn!rid;6*Wor5i3=UVTi@Bu#FDltv`dbbCTlLYuW-B7{ZFn6ip1f^MGob} + * + * 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 + * @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 index 000000000..5ad644fe6 --- /dev/null +++ b/news/news.php @@ -0,0 +1,59 @@ + + * + * 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 + * @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'] . + ' - v.' . $version . ' from ' . $version_data['user_uid'] . + ' @ ' . $version_data['created'] . ' '; + } +} 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 index 000000000..741a16639 --- /dev/null +++ b/news/note.php @@ -0,0 +1,48 @@ + + * + * 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 + * @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 index 000000000..832eaac6b --- /dev/null +++ b/news/pdf.php @@ -0,0 +1,60 @@ + + * + * 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 + * @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 index 0000000000000000000000000000000000000000..e54f6c97a5e75fa38b49c64d410388b7cbf84c22 GIT binary patch literal 9367 zcmbuD4U8nmRmaP*apLt?Vr*gpN$M^+pB>+fZ_j7@Sl@^5ZqMh<-F|Spw?1DCre>#h zw|8c`$K5@%-i;0MXCUMPLbe5w`LGi~Kzv8WAQ3wXULim@3J4L)0TX0dMnbY9AtFGL z`2DN9XZGxighXrK{JN^Et6sf&?^X5w^A#67VYtp9KZ-nZfiW+@e}4}@TyI=#%%$+( z;8XCsP>&wJ#F+Epufq4jry+mlkNLR>z5w41{|b)4Zi-0MADoAJZy8<)bEtkl2|oxQgVO7ZQ2qQK{1LbTFN5EPKMdc3Owo)`DP9h@ zz$>BNzZqT)55Vp46yz22DX95;4oZ(FA%Er>e$>w&L5=$-PhZYm@z1O9EH;36x28ls$B$!zL1ouGcGYzH3-B9!K@OIdRvcq%m58(??cJ8uBSHaIh>Gcd` z2=gT-=Me6NB$G9Q4lLk&u=eek33<52TSpxQqOrN?7%6g~mf|6ju3Pf-284E6rE z;Z}Gdi~13G9aJ1lLfNGSwXP4s-SAhS#(xQ(hOa>NcQcJuzaMJ+V{ivNUDkgZK1}&> zsCitClQ6Wo7Rru$;dXck-U?Ts*7rA|?DacP_Wv@}cwd29=Z&)b4fwV5m=}~DPZ502 zz~6>??>LL0apoZ^n7g6$Orh4{K^WE*hPZ^m|Df7^3Ce!YLFw}~$kff>z-{nfpzMDk zPRFge80x)kP~-20dVfDuew--Fi%{!(FZ>XEqGw}i>+>3vp6|kG zHJ{7iHSnWQ_B{q=r%yoXu>jRi3N^1)DE%LRYWGW!F3snm^47CZ-#?V~Z$QoG zJSHK(yBNwIAB5898Yuhkf*R)lRJw8ds_?{0J_PYeC{647pUj=2i?NIYS1ZB6W^7+Z~`4UvTJp|=1zXjF*-$LpCO{j5S zhwA4|D82p%%1-CmqI?mQoi2x}{}9yp*FeqxAXLA{O3p*AhlA=rhU$M6s@=m-`hE^d zk0+q!^#v$DdKO{=vjO$qYf$~X1+}jK1^2=cjH!N(LOq{?((g_v{qBMC({+donO}rj z&)id&%Ow*jTs*P--$74CuGDa#-G2);~tFAVLV^n4Y{ zo^L@5{}bK{-_N3`pINB>J(OJ%DE-&V@FF)nra;J1@}s-T^2gvdq*0cC z44y*nL>@*u$hF8%BGn~-sZ|9yj*KAk*9k=aJBD0`97lBh9C8@>F!J-r)rhVc%p?H20bF*zaFs&scmo(4kkn7+sb#J zL>@wBkrY`#?nU~@6jEJ^zivfAKpqvNy}q zBwpHo=fM+G6H`aW_TErd*t?QmYV&BJ<#QWlHi_G7HuafL`@U%xlhnq^YTeE)`?A*M zQ4*_VoaDCe+ELR+i#F$ZBWky+2VJ+u>$`T_noxou}DGFs;4!Z^%j`wVy}%# znPZLW=J2wMmwZ+fx0u6G&ibEolqg>_hm)ocKVflMCmBYqwS=Yq80~PN@Yc~QR-j$Xg5=hBT!cxIUYw_>k$Q|{7lJmy$O~(7r=Bly%!~ zjVEodz5|B-R+jyJ*jtOzjTZ7=s&<>)YP{&fX1U9Ia;x#u7K0lZrK+^2qpqzi*gq){R>#F_Wo&QqzXRbJFA-4vh>RC3l$nW+Tk>Wi4xa6++T&5&GRH~U8gwCz zy21Y^C&tYr+0;zA4nO`r0!wzz%v7S}uxuNSTu!WR-Ii^|Fuk~`M^$E;N^(!zUZ;WE zDeBAYH66@8NM>bmun}ZLYi6ijD>9R|n%FurcQN`FGgGGD8TwryBH4!4sHC8*qZ>ky zbiiFk9M3E#F@-YHN;1Do}?*^p?4L0XnWMx%XcZ1gNrOuNb$E@e50uG0Ju$K zIlRbt2Cq7pkpfa7Wszk56mBjVXF03SBwHPhQ#hkrEo3b6pkLOa)A+gL( zOajx`S)J5+?Yd#VG=rVJx@j66C$O7o4z~R!_ev5?LOxmHR8X5}*5-*kR2Z{a`<~f} zkrTd45Y{HMrKnju)LY7GbIBMn*}qM`p4AD_rmrXI(#Xv8TrC_$c)Ny@e$4LLx$~A9 zf1@|s(OqLV?zw&^H8iY|J0gv8R=XQ(JNMYp(XpL3UB7dbcE??o*XB|eXKja%jM+(- zwh}uTwG&)?Z%3tiCzNhW8m{f?S+t+G;-wy&KyA*u&X}ETleA*(m~AwcqWecCCnk>! z=QIiiCVnZGu-)6YyY!u&WNq}kQ^L;1hZm;bbwv$$Do3$e`$1XC>nBCKe z@{yT#FLmu2`*w$2Gwz0Bwr}^XWNbazcWu0lsqNc0Y7f|*mL^4U7sb(G@kV?9{nex0 zJle&h8?U={!YLf-6MvBO{>@|qLuIS#WFK}diuns@0EGC z@wB)7EKj;IIY2u%A0FQFm-=-+TOy|E>-Iz_xP@rN**LO&-(GS3*zK?{o}s0C@k}pP zJr;ZM3|m=0b1V8@;bVy1xoOv__IWGmDAiCA<$aRy!4_vv23X;s*Q|bti+(bkM^Zdf zt?hRsoe62mIb(^lZi{_8V|C4Z78O;kh_4tvVt9};HI!LN7+M=zH;G%U?BJFrUDqN< z@}}nB3!g5tO5dHbiZOG}MZKJ@fZ5T`FSS?b{aCLX@qVk<9oUXJ7Agd-Ha}rR-)cuM zo{7w{YI*#oTiZyQC>e1c(yUs{XVA`>lc`^E@roasWYbfkzUw!hM!jsAg;#OB8^cXX~1wG11-5iO>!geDZ$lkghM68jxvv*jBkUGaUk(I~?(oS_*r z*Cdpj&r#biju0G|THY?V^c_Y=bkoXtzxbFLPdA?Dw+M zDSkB?>&mHgy@4;8iS<@HVL7HVd_|A2Aa%TFquu{B9nt_?O^9v=p-gawO6i>e!=C@xfEQI)%UD=sdxRGPXmxI$^;-Y%Hl~-JQL1b$gtaj@}y> zm~0wGVulT7=T<^0k^k|wMrH2G7x*>a8L6_$$NZ~^?RhbYGZGc?7{%cTM;b14Jay_+ ztrWsZ{y9jnzF&Cx#`C^&fRs@@lEaeTl$4XDHkla|DQA|q9iKo%WYlN3942av+V|^< z%<-hX6j_2TGx~CxCoK5f($`Z)Uop#6bVqK)OyBSGX*fSK-A%|-B%GYnz@{`qLN9it zcY4CGF{dWaZ2B@x;VzoJ+$G_Qq{ESjS;kQ-s#aQ$cvvb)GMrZ;X^|>=%yCojgpvYA zH&u|3V0^=wazRXCFA_)=QjL;>wwVx670;Du*$fKPYg=FmRum;OcrM7~C&;dGL!hIAMruqv~}N{d=*ym9CX z>=6WNvCcDkMv`OHaD(%NsU9$=aUA~3z<-m9@C}}vsVGFH7N1s=rvwqTE8P=XP0EVAq zeQ6M;u$xSQlgeGNgS~}^bi0I7Q2Z0EQDo~Es8HJ+n2+!h!Ourq-rqi zaH80Nf68=8QHt{-?kknI*eQLnkq^Rt$WxtdY=$TI9Wk4527_^7019LPoPuCk7|hK%5A;2OT*l>)6gB}inJ?`d`aj{ zR~nD%vyE4`Rm!N+Eh$wAyQviK$pzX=NO*WC-~bw}u+WE!qgSbq&U9Ulsu-)-EVh{A zIyT@nd^f8vd6SPh1Q*WPEY4>CzmK(mT@Svch2a4@d!h;{x2&irG;?os6E N#B>u5F65uY{4Y=ow&ef- literal 0 HcmV?d00001 diff --git a/news/po/news.pot b/news/po/news.pot new file mode 100644 index 000000000..6f01c3f73 --- /dev/null +++ b/news/po/news.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 index 000000000..2e8a84617 --- /dev/null +++ b/news/po/sl_SI.po @@ -0,0 +1,870 @@ +# translation of sl_SI.po to Slovene +# Marko Milost , 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 \n" +"Language-Team: Slovene \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 index 000000000..024ee4129 --- /dev/null +++ b/news/print.php @@ -0,0 +1,26 @@ + + * + * 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 + * @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 index 000000000..a9859669f --- /dev/null +++ b/news/reads.php @@ -0,0 +1,52 @@ + + * + * 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 + * @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 index 000000000..b687514a8 --- /dev/null +++ b/news/rss/comments.php @@ -0,0 +1,54 @@ + + */ + +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 = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower(NLS::select())) . ' + ' . date('r') . ' + ' . htmlspecialchars($title) . ' + ' . Horde::applicationUrl('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + foreach ($list as $comment) { + $rss .= ' + + ' . htmlspecialchars($comment['message_subject']) . ' + ' . $comment['read_url'] . ' + ' . $comment['read_url'] . ' + ' . date('r', strtotime($comment['message_date'])) . ' + + '; + } + + $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 index 000000000..e5b010c54 --- /dev/null +++ b/news/rss/index.php @@ -0,0 +1,56 @@ + + */ + +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 = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower(NLS::select())) . ' + ' . date('r') . ' + ' . htmlspecialchars($title) . ' + ' . Horde::applicationUrl('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + $rss .= ' + + ' . _("Last news") . ' + ' . Horde::applicationUrl('rss/news.php', true, -1) . ' + '; + + $rss .= ' + + ' . _("Last comments") . ' + ' . Horde::applicationUrl('rss/comments.php', true, -1) . ' + '; + + $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 index 000000000..961e3bea0 --- /dev/null +++ b/news/rss/news.php @@ -0,0 +1,84 @@ + + * @author McLion + */ + +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 .= ' + + ' . htmlspecialchars($news['title']) . ' + ' . htmlspecialchars($news['user']). ' + ' . $news_link . ' + ' . $news_link . ' + ' . $news_link . '#comments + + ' . date('r', strtotime($news['publish'])) . ' + + '; + + if (strtotime($news['publish']) > $lastnewstime) { + $lastnewstime = strtotime($news['publish']); + } + } + + // Wee need the last published news time + $rssheader = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower(NLS::select())) . ' + ' . date('r', $lastnewstime) . ' + ' . htmlspecialchars($title) . ' + ' . Horde::applicationUrl('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + + + $rssfooter = ' + +'; + + // 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 index 000000000..53f375a93 --- /dev/null +++ b/news/scripts/sql/news.mysql.sql @@ -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 index 000000000..3769f3ea0 --- /dev/null +++ b/news/scripts/upgrades/20070302_trackback.sql @@ -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 index 000000000..e86f428ca --- /dev/null +++ b/news/scripts/upgrades/20070609_sponsored.sql @@ -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 index 000000000..5dc905e11 --- /dev/null +++ b/news/scripts/upgrades/20071220_tags.sql @@ -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 index 000000000..5a646d6bf --- /dev/null +++ b/news/search.php @@ -0,0 +1,73 @@ + + * + * 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 + * @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 index 000000000..4310956df --- /dev/null +++ b/news/tags.php @@ -0,0 +1,40 @@ + + * + * 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 + * @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 . '
'; + $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 index 000000000..e69de29bb diff --git a/news/templates/block/news.php b/news/templates/block/news.php new file mode 100644 index 000000000..6102bd9e0 --- /dev/null +++ b/news/templates/block/news.php @@ -0,0 +1,19 @@ +news)): ?> + +news as $news_id => $news) { ?> +

+news_url, 'id', $news['id']), $news['title']); +echo '' . $news['title'] . ' - ' . $news['abbreviation'] . '... (' . $news['comments'] . ')
'; +?> +

+ + + + + +

+ diff --git a/news/templates/block/titles.php b/news/templates/block/titles.php new file mode 100644 index 000000000..64324a446 --- /dev/null +++ b/news/templates/block/titles.php @@ -0,0 +1,21 @@ +news)): ?> + + + +news as $news_id => $news) { ?> + + + + + +
+getValue('date_format'), strtotime($news['publish'])) . ' - '; +echo Horde::link(Util::addParameter($this->news_url, 'id', $news['id']), $news['abbreviation']); +echo $news['title'] . ''; +?> +
+ + +

+ diff --git a/news/templates/browse/footer.inc b/news/templates/browse/footer.inc new file mode 100755 index 000000000..10cc5e347 --- /dev/null +++ b/news/templates/browse/footer.inc @@ -0,0 +1 @@ +render(); ?> diff --git a/news/templates/browse/header.inc b/news/templates/browse/header.inc new file mode 100755 index 000000000..7af15647a --- /dev/null +++ b/news/templates/browse/header.inc @@ -0,0 +1,3 @@ +
()
+render(); ?> + diff --git a/news/templates/browse/row.inc b/news/templates/browse/row.inc new file mode 100755 index 000000000..aa814708c --- /dev/null +++ b/news/templates/browse/row.inc @@ -0,0 +1,12 @@ +

+ + +'; ?> + - +
+ ...
+ + + + +

\ No newline at end of file diff --git a/news/templates/categories/delete.html b/news/templates/categories/delete.html new file mode 100755 index 000000000..7adede239 --- /dev/null +++ b/news/templates/categories/delete.html @@ -0,0 +1,9 @@ + + + +
+
Categories
+ +
+ + \ No newline at end of file diff --git a/news/templates/categories/edit.html b/news/templates/categories/edit.html new file mode 100755 index 000000000..7adede239 --- /dev/null +++ b/news/templates/categories/edit.html @@ -0,0 +1,9 @@ + + + +
+
Categories
+ +
+ + \ No newline at end of file diff --git a/news/templates/categories/index.html b/news/templates/categories/index.html new file mode 100755 index 000000000..c314ca778 --- /dev/null +++ b/news/templates/categories/index.html @@ -0,0 +1,5 @@ + + + +
Categories
+ diff --git a/news/templates/categories/index.php b/news/templates/categories/index.php new file mode 100644 index 000000000..6022f7a0d --- /dev/null +++ b/news/templates/categories/index.php @@ -0,0 +1,27 @@ + + + + + + + + + + +categories as $category_id => $category) { ?> + + + + + + + + + +
add_url ?>
+categories[$category['category_parentid']]['category_name'] . + ' - ' . $category['category_parentid']; +} +?>
\ No newline at end of file diff --git a/news/templates/common-header.inc b/news/templates/common-header.inc new file mode 100755 index 000000000..39cc566ae --- /dev/null +++ b/news/templates/common-header.inc @@ -0,0 +1,31 @@ + + + + + +' : '' ?> + +get('name'); +if (!empty($title)) $page_title .= ' :: ' . $title; +if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) { + echo "\n"; +} + +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + +" href="" type="application/rss+xml" /> +" href="" type="application/rss+xml" /> + + + +> diff --git a/news/templates/edit/footer.inc b/news/templates/edit/footer.inc new file mode 100755 index 000000000..0582a5d8f --- /dev/null +++ b/news/templates/edit/footer.inc @@ -0,0 +1,4 @@ + +render(); ?> + +
diff --git a/news/templates/edit/header.inc b/news/templates/edit/header.inc new file mode 100755 index 000000000..1e8daf490 --- /dev/null +++ b/news/templates/edit/header.inc @@ -0,0 +1,17 @@ +
+ + + + + + + + + +' . _("Comments") . ''; +} +?> + + \ No newline at end of file diff --git a/news/templates/edit/info.inc b/news/templates/edit/info.inc new file mode 100755 index 000000000..d62b55593 --- /dev/null +++ b/news/templates/edit/info.inc @@ -0,0 +1,107 @@ + + + diff --git a/news/templates/edit/info.php b/news/templates/edit/info.php new file mode 100644 index 000000000..bba91a6c4 --- /dev/null +++ b/news/templates/edit/info.php @@ -0,0 +1,112 @@ + + + diff --git a/news/templates/edit/row.php b/news/templates/edit/row.php new file mode 100644 index 000000000..f63040334 --- /dev/null +++ b/news/templates/edit/row.php @@ -0,0 +1,62 @@ + + + + + + + +' . $row['comments'] . ''; +} +?> + \ No newline at end of file diff --git a/news/templates/menu.inc b/news/templates/menu.inc new file mode 100755 index 000000000..9fecbd66d --- /dev/null +++ b/news/templates/menu.inc @@ -0,0 +1,13 @@ + +notify(array('listeners' => 'status')) ?> diff --git a/news/templates/news/attachments.php b/news/templates/news/attachments.php new file mode 100644 index 000000000..5d04153a1 --- /dev/null +++ b/news/templates/news/attachments.php @@ -0,0 +1,5 @@ +
' . News::format_attached($id); +} diff --git a/news/templates/news/blog.php b/news/templates/news/blog.php new file mode 100644 index 000000000..5ebfad716 --- /dev/null +++ b/news/templates/news/blog.php @@ -0,0 +1,39 @@ +
+' . _("Blogs") . ''; + +// Blogs +if (!empty($row['trackback'])) { + echo _("Talkbacks to this article:") . '
    '; + foreach ($row['trackback'] as $trackback) { + echo '
  • ' . Horde::link($trackback['url'], $trackback['excerpt']) . $trackback['title'] . ' ' + . _("From: ") . $trackback['blog_name'] . ' @ ' . News::dateFormat($trackback['created']) . '
  • '; + } + echo '

'; +} + +$trackback_url = Util::addParameter(Horde::applicationUrl('trackback.php', true), 'id', $id); +echo _("Use the following link to trackback from your own site: ") . + '

'; + +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) . '' . _("Trackback this blog on this site.") . '
'; +} + +$read_url = Util::addParameter(Horde::applicationUrl('news.php', true), 'id', $id); +?> + + diff --git a/news/templates/news/comments.php b/news/templates/news/comments.php new file mode 100644 index 000000000..b99f7786d --- /dev/null +++ b/news/templates/news/comments.php @@ -0,0 +1,21 @@ +
+-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 index 000000000..cdf73b773 --- /dev/null +++ b/news/templates/news/gallery.php @@ -0,0 +1,20 @@ +get('webroot', 'horde') . '/vfs/.horde/ansel/'; +$dim = $conf['images']['image_height'] . ',' . $conf['images']['image_width']; + +echo '
'; +foreach ($images as $image_id => $image) { + $img_url = substr($image_id, -2) . '/%s/' . $image_id . '.jpg'; + echo "\n" . '
' . + Horde::link('#', $image['name'], '', '', 'popup(\'' . $path . sprintf($img_url, 'screen') . '\',' . $dim . ')') . "\n" . + '' . + $image['caption']. '
'; +} +echo '
'; + diff --git a/news/templates/news/info.php b/news/templates/news/info.php new file mode 100644 index 000000000..3bdcd13b2 --- /dev/null +++ b/news/templates/news/info.php @@ -0,0 +1,20 @@ +' . _("News data") . ''; +echo _("By") . ': ' . Horde::link(Util::addParameter($browse_url, 'user', $row['user'])) . $row['user'] . '
'; +echo _("On") . ': ' . Horde::link(Util::addParameter($browse_url, 'publish', $row['publish'])) . $news->dateFormat($row['publish']) . '
'; +echo _("Category") . ': ' . Horde::link(Util::addParameter($browse_url, 'cid', $row['category1'])) . $news_cat->getName($row['category1']) . '
'; + +$plain = preg_replace('/\s\s+/', ' ', trim(strip_tags($row['content']))); +echo _("Chars") . ': ' . number_format(strlen($plain)) . '
'; +echo _("Besed") . ': ' . number_format(substr_count($plain, ' ')) . '
'; + +if ($row['sourcelink']) { + echo _("Source news") . ': ' . Horde::externalUrl($row['sourcelink'], true) . _("Source news") . '
'; +} + +if ($row['source']) { + $sources = $news->getSources(true); + echo _("Source media") . ': ' . Horde::externalUrl($sources[$row['source']]['source_url'], true) . + $sources[$row['source']]['source_name'] . '
'; +} \ No newline at end of file diff --git a/news/templates/news/mail.php b/news/templates/news/mail.php new file mode 100644 index 000000000..0fe1849bd --- /dev/null +++ b/news/templates/news/mail.php @@ -0,0 +1,7 @@ +
+
+ + + + + diff --git a/news/templates/news/news.php b/news/templates/news/news.php new file mode 100644 index 000000000..1b7c2b182 --- /dev/null +++ b/news/templates/news/news.php @@ -0,0 +1,43 @@ +
+

+
+ + + + + + + +
+\n"; + +if ($row['category2']>0) { + echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "
\n"; +} + +if (substr($row['unpublish'], 0, 1) != 0) { + echo _("Unpublish date") . ': ' . $row['unpublish'] . "
\n"; +} + +if ($conf['comments']['allow']) { + echo _("Allow comments") . ': ' . ($row['comments']>-1 ? _("Yes") : _("No")) . "
\n"; +} + +if ($row['editor']) { + echo _("Editor") . ': ' . $row['editor'] . "
\n"; +} + +if ($row['sortorder']) { + echo _("Sort order") . ': ' . $row['sortorder'] . "
\n"; +} + +if (isset($row['parents'])) { + echo _("Parents") . ': ' . sizeof($row['parents']) . "
\n"; +} + +if (!empty($row['source']) && isset($GLOBALS['cfgSources'][$row['source']])) { + echo _("Source") . ': ' . $GLOBALS['cfgSources'][$row['source']]['title'] . '
'; +} + +if (isset($row['sourcelink'])) { + echo _("Source link") . ': ' . $row['sourcelink'] . '
'; +} + +// 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); +} + +?> +
+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: ") . '
'; + + 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") . ' | '; + + $url = Util::addParameter(Horde::applicationUrl('edit.php'), array('id' => $id, 'actionID' => 'renew')); + echo Horde::link(Util::addParameter($url,'version', $version['version']),_("Renew")) . _("Renew") . ' | '; + + $url = Util::addParameter(Horde::applicationUrl('diff.php'), array('id' => $id, 'version' => $version['version'])); + echo Horde::link('#', _("Diff"), '', '', "popup('$url')") . _("Diff") . ' '; + + echo ')
' . "\n"; + } +} + +?> +
+ +
+ + + + + + + +
+\n"; + +if ($row['category2']>0) { + echo _("Secondary category") . ': ' . $allowed_cats[$row['category2']] . "
\n"; +} + +if (substr($row['unpublish'], 0, 1) != 0) { + echo _("Unpublish date") . ': ' . $row['unpublish'] . "
\n"; +} + +if ($conf['comments']['allow']) { + echo _("Allow comments") . ': ' . ($row['comments']>-1 ? _("Yes") : _("No")) . "
\n"; +} + +if ($row['editor']) { + echo _("Editor") . ': ' . $row['editor'] . "
\n"; +} + +if ($row['sortorder']) { + echo _("Sort order") . ': ' . $row['sortorder'] . "
\n"; +} + +if (isset($row['parents'])) { + echo _("Parents") . ': ' . sizeof($row['parents']) . "
\n"; +} + +if (!empty($row['source']) && isset($GLOBALS['cfgSources'][$row['source']])) { + echo _("Source") . ': ' . $GLOBALS['cfgSources'][$row['source']]['title'] . '
'; +} + +if (isset($row['sourcelink'])) { + echo _("Source link") . ': ' . $row['sourcelink'] . '
'; +} + +// 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); +} + +?> +
+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: ") . '
'; + + 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") . ' | '; + + $url = Util::addParameter(Horde::applicationUrl('edit.php'), array('id' => $id, 'actionID' => 'renew')); + echo Horde::link(Util::addParameter($url,'version', $version['version']),_("Renew")) . _("Renew") . ' | '; + + $url = Util::addParameter(Horde::applicationUrl('diff.php'), array('id' => $id, 'version' => $version['version'])); + echo Horde::link('#', _("Diff"), '', '', "popup('$url')") . _("Diff") . ' '; + + echo ')
' . "\n"; + } +} + +?> +
+ +
+ $page, 'id' => $row['id'])); +echo Horde::link($url,_("Edit")) . + Horde::img('edit.png', _("Edit"), '', $img_dir) . '  '; + +echo Horde::link(Util::addParameter($browse_url, 'id', $row['id']), _("Info")) . + Horde::img('devel.png', _("Info"), '', $img_dir). '  '; + +/* 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) . ' '; + } 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) . ' '; + + $url = Util::addParameter(Horde::applicationUrl('delete.php'), 'id', $row['id']); + echo Horde::link($url,_("Delete"), '', '', '', _("Delete")) . Horde::img('delete.png', _("Delete"), '', $img_dir) . '  '; + + 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) . ' '; + } 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) . ' '; + } + } +} + +?> + +dateFormat($row['publish']) ?> +'; +?> +
+ + + + +
+
'; + echo $row['picture_comment'] . ''; +} + +$plain_text = trim(strip_tags($row['content'])); +echo '
' . substr($plain_text, 0, 1) . '
'; +echo $row['content']; + +if ($row['sponsored']) { + echo '' . _("* Sponsored news") . ''; +} + +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'; + +?> +
+ +
\ No newline at end of file diff --git a/news/templates/news/parents.php b/news/templates/news/parents.php new file mode 100644 index 000000000..76c8f6c5f --- /dev/null +++ b/news/templates/news/parents.php @@ -0,0 +1,12 @@ +
+'; + foreach ($row['parents'] as $parent_id => $data) { + echo '
  • ' . $news->dateFormat($data['publish']) . ' ' + . Horde::link(Util::addParameter($news_url, 'id', $parent_id), _("Read")) + . $data['title'] . ' (' . ($data['comments']> -1 ? $data['comments'] : 0) . ')'; + } + echo ''; +} diff --git a/news/templates/news/selling.php b/news/templates/news/selling.php new file mode 100644 index 000000000..576d72553 --- /dev/null +++ b/news/templates/news/selling.php @@ -0,0 +1,14 @@ +
    +
    +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 index 000000000..7eeb6e8f4 --- /dev/null +++ b/news/templates/news/threads.php @@ -0,0 +1,14 @@ +
    +' . sprintf(_("Threads in %s"), $registry->get('name', 'agora')) . ':'; + $agore_link = $registry->get('webroot', 'agora'); + echo ''; +} diff --git a/news/templates/news/today.php b/news/templates/news/today.php new file mode 100644 index 000000000..96086508d --- /dev/null +++ b/news/templates/news/today.php @@ -0,0 +1,13 @@ +
    ' . _("On this day") . '
    '; +$img = Horde::img('news.png', '', '', $registry->getImageDir('news')); +echo $img . ' ' . Horde::link(Util::addParameter($browse_url, 'date', $row['publish'])) . _("News of this day.") . '
    '; + +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.") . '
    '; +} + diff --git a/news/templates/news/tools.php b/news/templates/news/tools.php new file mode 100644 index 000000000..0b3188e7b --- /dev/null +++ b/news/templates/news/tools.php @@ -0,0 +1,24 @@ +
    ' . _("Tools") . '
    '; + +$img = Horde::img('print.png', '', '', $registry->getImageDir('horde')); +echo $img . ' ' . Horde::link('javascript:window.print()') . _("Printer firendly") . '
    '; + +$img = Horde::img('mime/pdf.png', '', '', $registry->getImageDir('horde')); +echo $img . ' ' . Horde::link(Util::addParameter(Horde::applicationUrl('pdf.php'), 'id', $id)) . _("PDF") . '
    '; + +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.") . '
    '; +} + +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.") . '
    '; +} + diff --git a/news/templates/news/ulaform.php b/news/templates/news/ulaform.php new file mode 100644 index 000000000..f8e836956 --- /dev/null +++ b/news/templates/news/ulaform.php @@ -0,0 +1,17 @@ + $_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 '

    ' . $form['title'] . '

    '; + echo $form['form']; +} diff --git a/news/templates/print/footer.inc b/news/templates/print/footer.inc new file mode 100755 index 000000000..e69de29bb diff --git a/news/templates/print/header.inc b/news/templates/print/header.inc new file mode 100755 index 000000000..e69de29bb diff --git a/news/templates/reads/footer.inc b/news/templates/reads/footer.inc new file mode 100755 index 000000000..000ca4b01 --- /dev/null +++ b/news/templates/reads/footer.inc @@ -0,0 +1 @@ + diff --git a/news/templates/reads/header.inc b/news/templates/reads/header.inc new file mode 100755 index 000000000..c192b7959 --- /dev/null +++ b/news/templates/reads/header.inc @@ -0,0 +1,10 @@ +
    + + + + + + + + + diff --git a/news/templates/reads/row.inc b/news/templates/reads/row.inc new file mode 100755 index 000000000..38ac7cbea --- /dev/null +++ b/news/templates/reads/row.inc @@ -0,0 +1,6 @@ + + + + + + diff --git a/news/templates/sources/index.php b/news/templates/sources/index.php new file mode 100644 index 000000000..0c0f40193 --- /dev/null +++ b/news/templates/sources/index.php @@ -0,0 +1,18 @@ +
    '; ?>'; ?>
    + + + + + + + + +sources as $source_id => $source) { ?> + + + + + + + +
    add_url ?>
    diff --git a/news/themes/graphics/folder_open.png b/news/themes/graphics/folder_open.png new file mode 100755 index 0000000000000000000000000000000000000000..a6b525b65a0833ebc33ee49457b4e0eca73a5529 GIT binary patch literal 703 zcmb`Di%U~+6vuxy!JAW>6iD`98;)d>3>AYYFmvi?KBqT@hIhDGzS!JDGg?V3&4O@K zG|Or}LYwoEd$#g;Bn5Kq_tp#$IZg#%x{oKI6uR(g17R476y zT$GWTM?3347=zw1XOBo|V`x%D`51;Rf6HD)DCkg*I9~_=`}_NQdwaXPyE{8O)HVbH z0l(i*Q4~p%^XuUA`Nmh^{a098T5`MHE|+U?5&AvQ;{vl2Ud%)19CUnw_E{L2{$ZMi z<|%mm5gtuK(*)S<_Qnrjv)K&eaOWM=*`d}3x-rna1&hVfZgp0UK>0A-7y?t@Z0R7B z41ml6(tap<1y_5apa*izko^)`TU)O@hxBJ4?10C!C6(+!7J8ATd|Lj4B{O0gzBp^rSRuuv;emTGHdY6Z%am8g|f z3VE4~omQq+)GE~#8g^zOJ6<42Y^<>^&;f@i^-})L&JrRy#N=R`XC1*uv4&=Er@%7FJ#DCJC&qtu09L!)>R4aL&(6O-wn?Acn6pEDUkp V@B)UXpS$R1kVu%7I+Q}(`v-Z@g$w`y literal 0 HcmV?d00001 diff --git a/news/themes/graphics/mkdir.png b/news/themes/graphics/mkdir.png new file mode 100755 index 0000000000000000000000000000000000000000..0b4d90dc666b159a08dac47015732a3efc5234b2 GIT binary patch literal 1008 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl4m>B|mLR`Op|Nj5^l<&`{{C_{? z`}-;Xzfbx8eag9W$y25;rexI}U zy;Jfv!=Q7TUgsn%j|FAl^Gd$v6m?D0>6oU|IYrB391=?p95?{9ZWN4$z@QC*%g)Xr zK*uSR1o;L3#}61{Vx->!)iNe|ySw~f%Kqsnki%Kv5m^kRJ;2!QWVRiU5$oyV7$R{w z_WVJ?0}3227k!QT6kIRVPi5&5`YLZ@QxdWwD8;HtsB1dYs`y%Y)`XQ&4kzacuM>X9 zd*(J{E~|WV?azbysd>}*Hy_hc;>$9gR+m!e#r*5JP}06bFIbzun`V~XuWAQc#Ng@b K=d#Wzp$P!E+nyi* literal 0 HcmV?d00001 diff --git a/news/themes/graphics/news.png b/news/themes/graphics/news.png new file mode 100755 index 0000000000000000000000000000000000000000..9009dac9e32ba4467a177e737662f8fff4653530 GIT binary patch literal 717 zcmV;;0y6!HP)^{rdg<{QUg?`TzO*`}z6#`1<NT@$K;U?(gvM?(^&I^zH8N?d|XE?C$I9?CR?5=<4z5>Fe(2^6uyO=;`q1=F4L^<>&9>*M6?;p6J!EGe!-{I-r-{#%k=G@)n@7DS4*7w`p=G)xk z+T7#n)%EDq^W53!*V*9L+2ZHZ@#E3()YjhN(C**Q?A^}l+RW(8%*@ru<;%;<$jHdL zy1Kc!xwf{pwY9ahv$L|Yv9PePuCA`EtgNf6s;Q}|sHdlXD6!2rR2C7hs zaB_;!5l#dO_%qvpRR9I_MU#L60W5Yv6&fG`1BqmyKp?w4P=zMQ3{$BTpg<6(15kyw zww|7eiF7JZAcV^is6q?m7E8G_pg=IUvxTm%v9Yn0m8~*JAhbkY3}#o<8jx`jo;L6|!OK!5=N?N>bT5u$|w00000NkvXXu0mjf-13o) literal 0 HcmV?d00001 diff --git a/news/themes/microfila/graphics/favicon.ico b/news/themes/microfila/graphics/favicon.ico new file mode 100755 index 0000000000000000000000000000000000000000..f8694d53c78c8bff0e21a2e007695069d0c7617d GIT binary patch literal 318 ncmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#31oefIS2N_ + */ +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(); -- 2.11.0