Permalink
Browse files

Missing pieces from News module view by tag feature

  • Loading branch information...
1 parent 67ae41b commit dbe5c54cab2ba173b080d1dadb72648189da5a9a @dleffler dleffler committed Feb 17, 2011
@@ -0,0 +1,195 @@
+<?php
+
+##################################################
+#
+# Copyright (c) 2004-2006 OIC Group, Inc.
+# Written and Designed by James Hunt
+#
+# This file is part of Exponent
+#
+# Exponent is free software; you can redistribute
+# it and/or modify it under the terms of the GNU
+# General Public License as published by the Free
+# Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# GPL: http://www.gnu.org/licenses/gpl.txt
+#
+##################################################
+
+if (!defined('EXPONENT')) exit('');
+
+exponent_flow_set(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);
+
+$loc->int = ''; // remove the rouge item id
+
+$config = $db->selectObject("newsmodule_config","location_data='".serialize($loc)."'");
+if ($config == null) {
+ $config->sortorder = "DESC";
+ $config->sortfield = "Posted";
+ $config->item_limit = 10;
+ $config->enable_pagination = 0;
+}
+
+$locsql = "(location_data='".serialize($loc)."'";
+if (!empty($config->aggregate)) {
+ $locations = unserialize($config->aggregate);
+ foreach ($locations as $source) {
+ $tmploc = null;
+ $tmploc->mod = 'newsmodule';
+ $tmploc->src = $source;
+ $tmploc->int = '';
+ $locsql .= " OR location_data='".serialize($tmploc)."'";
+ }
+}
+$locsql .= ')';
+
+$canviewapproval = false;
+if ($user) $canviewapproval = exponent_permissions_check("approve",$loc) || exponent_permissions_check("manage_approval",$loc);
+if (!$canviewapproval) { // still not able to view
+// foreach($db->selectObjects("newsitem","location_data='" . serialize($loc) . "' AND (publish = 0 or publish <= " . time() . ") AND (unpublish = 0 or unpublish > " . time() . ") AND approved != 0") as $post) {
+ foreach($db->selectObjects("newsitem",$locsql . " AND (publish = 0 or publish <= " . time() . ") AND (unpublish = 0 or unpublish > " . time() . ") AND approved != 0") as $post) {
+ if ($user && $user->id == $post->poster) {
+ $canviewapproval = true;
+ break;
+ }
+ }
+}
+
+if (!defined('SYS_SORTING')) include_once(BASE.'subsystems/sorting.php');
+switch($config->sortfield) {
+ case "posted":
+ $field = "Posted";
+ break;
+ case "publish":
+ $field = "Published";
+ break;
+ case "edited":
+ $field = "Edited";
+ break;
+ default:
+ $field = "Posted";
+ break;
+}
+if ($config->sortorder == "ASC") {
+ $order = "Ascending";
+} else {
+ $order = "Descending";
+}
+$sortFunc = 'exponent_sorting_by'.$field.$order;
+
+$template = new template("newsmodule","_view_page_bytag",$loc);
+if ($template->viewconfig['featured_only']) {
+ $locsql .= " AND is_featured=1 ";
+}
+
+// //$total = $db->countObjects('newsitem',"location_data='".serialize($loc)."' AND (publish = 0 or publish <= " .
+// // time() . ") AND (unpublish = 0 or unpublish > " . time() . $featuresql . ") AND approved != 0");
+// $total = $db->countObjects('newsitem',$locsql . " AND (publish = 0 or publish <= " .
+ // time() . ") AND (unpublish = 0 or unpublish > " . time() . ") AND approved != 0");
+
+// if($config->enable_pagination == 0){
+// // $news = $db->selectObjects("newsitem","location_data='" .
+// // serialize($loc) . "' AND (publish = 0 or publish <= " .
+// // time() . ") AND (unpublish = 0 or unpublish > " . time() . $featuresql . ") AND approved != 0 ORDER BY publish ".$config->sortorder);
+ // $news = $db->selectObjects("newsitem",$locsql . " AND (publish = 0 or publish <= " .
+ // time() . ") AND (unpublish = 0 or unpublish > " . time() . ") AND approved != 0 ORDER BY ".
+ // $config->sortfield.' ' . $config->sortorder);
+// } else {
+// // $news = $db->selectObjects("newsitem","location_data='".
+// // serialize($loc) . "' AND (publish = 0 or publish <= ".
+// // time() . ') AND (unpublish = 0 or unpublish > ' . time() . $featuresql . ') AND approved != 0 ORDER BY '.
+// // $config->sortfield.' ' . $config->sortorder.
+// // $db->limit($config->item_limit,($_GET['page']*$config->item_limit)));
+ // $news = $db->selectObjects("newsitem",$locsql . " AND (publish = 0 or publish <= ".
+ // time() . ') AND (unpublish = 0 or unpublish > ' . time() . ') AND approved != 0 ORDER BY '.
+ // $config->sortfield.' ' . $config->sortorder.
+ // $db->limit($config->item_limit,($_GET['page']*$config->item_limit)));
+// }
+
+// for ($i = 0; $i < count($news); $i++) {
+ // $nloc = null;
+ // $nloc->mod = $loc->mod;
+ // $nloc->src = $loc->src;
+ // $nloc->int = $news[$i]->id;
+
+ // $news[$i]->permissions = array(
+ // "edit_item"=>((exponent_permissions_check("edit_item",$loc) || exponent_permissions_check("edit_item",$nloc)) ? 1 : 0),
+ // "delete_item"=>((exponent_permissions_check("delete_item",$loc) || exponent_permissions_check("delete_item",$nloc)) ? 1 : 0),
+ // "administrate"=>((exponent_permissions_check("administrate",$loc) || exponent_permissions_check("administrate",$nloc)) ? 1 : 0)
+ // );
+// // $news[$i]->real_posted = ($news[$i]->publish != 0 ? $news[$i]->publish : $news[$i]->posted);
+ // $news[$i]->posted = ($news[$i]->publish != 0 ? $news[$i]->publish : $news[$i]->posted);
+ // if ($news[$i]->publish == 0) {$news[$i]->publish = $news[$i]->posted;}
+// }
+
+
+
+$where = $locsql . " AND (publish = 0 or publish <= " . time() . ") AND (unpublish = 0 or unpublish > " .
+ time() . ") AND approved != 0 ORDER BY " . $config->sortfield . ' ' . $config->sortorder;
+
+$all_news = $db->selectObjects('newsitem', $where);
+$viewing_tag = $db->selectObject('tags', "id=".intval($_REQUEST['id']));
+$news = array();
+for ($i = 0; $i < count($all_news); $i++) {
+ $all_news[$i]->posted = ($all_news[$i]->publish != 0 ? $all_news[$i]->publish : $all_news[$i]->posted);
+ if ($all_news[$i]->publish == 0) {$all_news[$i]->publish = $all_news[$i]->posted;}
+ $ploc = exponent_core_makeLocation($loc->mod,$loc->src,$all_news[$i]->id);
+ $not_there = true;
+ $tags = unserialize($all_news[$i]->tags);
+ $selected_tags = $db->selectObjectsInArray('tags', $tags);
+ //eDebug($selected_tags);
+ for ($j=0; $j < count($tags); $j++){
+ if ($tags[$j] == intval($_REQUEST['id'])) $not_there = false;
+ }
+ if ($not_there == false) {
+ $newsitem = $all_news[$i];
+ $newsitem->selected_tags = $selected_tags;
+ $newsitem->permissions = array(
+ 'administrate'=>exponent_permissions_check('administrate',$ploc),
+ 'configure'=>exponent_permissions_check('configure',$ploc),
+ 'add_item'=>exponent_permissions_check('add_item',$ploc),
+ 'delete_item'=>exponent_permissions_check('delete_item',$ploc),
+ 'edit_items'=>exponent_permissions_check('edit_items',$ploc),
+ 'manage_approval'=>exponent_permissions_check('manage_approval',$ploc),
+ );
+ array_push($news, $newsitem);
+ }
+}
+
+usort($news,$sortFunc);
+$total = count($news);
+$news = array_slice($news,($_REQUEST['page'] * $config->item_limit),$config->item_limit,true);
+
+//If rss is enabled tell the view to show the RSS button
+if (!isset($config->enable_rss)) {$config->enable_rss = 0;}
+$template->assign('enable_rss', $config->enable_rss);
+
+// EVIL WORKFLOW
+//$in_approval = $db->countObjects("newsitem_wf_info","location_data='".serialize($loc)."'");
+$in_approval = $db->countObjects("newsitem_wf_info",$locsql);
+$template->assign("canview_approval_link",$canviewapproval);
+$template->assign("in_approval",$in_approval);
+$template->assign("news",$news);
+
+//pagination
+$template->assign('total_news',$total);
+$template->assign('item_limit', $config->item_limit);
+$template->assign('shownext',(($_GET['page']+1)*$config->item_limit) < $total);
+$template->assign('page',$_GET['page']);
+$template->assign('enable_pagination', $config->enable_pagination);
+$template->assign('morenews', count($news) < $total);
+
+$title = $db->selectValue('container', 'title', "internal='".serialize($loc)."'");
+//$template->assign('moduletitle',$title);
+$template->assign('moduletitle',$title." (<em>tagged with '".$viewing_tag->name."'</em>)");
+$template->assign('viewing_tag',$viewing_tag);
+$template->register_permissions(
+ array("administrate","configure","add_item","delete_item","edit_items","manage_approval"),
+ $loc
+);
+$template->assign('config', $config);
+
+$template->output();
+
+?>
@@ -0,0 +1,120 @@
+{*
+ * Copyright (c) 2004-2006 OIC Group, Inc.
+ * Written and Designed by James Hunt
+ *
+ * This file is part of Exponent
+ *
+ * Exponent is free software; you can redistribute
+ * it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free
+ * Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * GPL: http://www.gnu.org/licenses/gpl.txt
+ *
+ *}
+
+<div class="newsmodule default">
+ <h2>
+ {if $enable_rss == true}
+ <a href="{rsslink}"><img src="{$smarty.const.ICON_RELATIVE}rss-feed.gif" title="{$_TR.alt_rssfeed}" alt="{$_TR.alt_rssfeed}" /></a>
+ {/if}
+ {if $moduletitle != ""}{$moduletitle}{/if}
+ </h2>
+ {foreach from=$news item=newsitem}
+ {*if $newsitem->is_featured!=1*}
+ <div class="item {cycle values='odd,even'}">
+ {if $newsitem->title != ""}<h3><a href="{link action=view id=$newsitem->id}">{$newsitem->title}</a></h3>{/if}
+ {if $newsitem->isRss != true}
+ {permissions level=$smarty.const.UILEVEL_NORMAL}
+ <div class="itemactions">
+ {if $permissions.administrate == true || $newsitem->permissions.administrate == true}
+ <a href="{link action=userperms int=$newsitem->id _common=1}"><img src="{$smarty.const.ICON_RELATIVE}userperms.png" title="{$_TR.alt_userperm_one}" alt="{$_TR.alt_userperm_one}" /></a>&nbsp;
+ <a href="{link action=groupperms int=$newsitem->id _common=1}"><img src="{$smarty.const.ICON_RELATIVE}groupperms.png" title="{$_TR.alt_groupperm_one}" alt="{$_TR.alt_groupperm_one}" /></a>
+ {/if}
+ {if $permissions.edit_item == true || $newsitem->permissions.edit_item == true}
+ {if $newsitem->approved == 2} {* in approval *}
+ <img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}edit.disabled.png" title="{$_TR.alt_edit_disabled}" alt="{$_TR.alt_edit_disabled}" />
+ {else}
+ <a class="mngmntlink news_mngmntlink" href="{link action=edit id=$newsitem->id}"><img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}edit.png" title="{$_TR.alt_edit}" alt="{$_TR.alt_edit}" /></a>
+ {/if}
+ {/if}
+ {if $permissions.delete_item == true || $newsitem->permissions.delete_item == true}
+ {if $newsitem->approved == 2} {* in ap *}
+ <img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}delete.disabled.png" title="{$_TR.alt_delete_disabled}" alt="{$_TR.alt_delete_disabled}" />
+ {else}
+ <a onclick="return confirm('{$_TR.delete_confirm}');" class="mngmntlink news_mngmntlink" href="{link action=delete id=$newsitem->id}"><img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.alt_delete}" alt="{$_TR.alt_delete}" /></a>
+ {/if}
+ {/if}
+ {if $permissions.manage_approval == 1}
+ <a class="mngmntlink news_mngmntlink" href="{link module=workflow datatype=newsitem m=newsmodule s=$__loc->src action=revisions_view id=$newsitem->id}" title="{$_TR.alt_revisions}"><img class="mngmnt_icon" src="{$smarty.const.ICON_RELATIVE}revisions.png" title="{$_TR.alt_revisions}" alt="{$_TR.alt_revisions}"/></a>
+ {/if}
+ </div>
+ {/permissions}
+ {*/if*}
+ <div class="bodycopy">
+ {if $newsitem->image!=""}<img src="{$smarty.const.URL_FULL}/thumb.php?file={$newsitem->image}&constraint=1&width=150&height=200" alt="{$newsitem->title}">{/if}
+ {$newsitem->body|summarize:"html":"paralinks"}
+ </div>
+ <div class="post-footer">
+ {if $newsitem->edited == 0 || $config->sortfield == "publish" || $config->sortfield == "posted"}
+ {*assign var='sortdate' value=$newsitem->real_posted*}
+ {assign var='sortdate' value=$newsitem->posted}
+ {assign var='typepost' value=$_TR.posted}
+ {assign var='whopost' value=$newsitem->poster}
+ {else}
+ {assign var='sortdate' value=$newsitem->edited}
+ {assign var='typepost' value=$_TR.updated}
+ {assign var='whopost' value=$newsitem->editor}
+ {/if}
+ <a class="readmore" href="{if $newsitem->isRss}{$newsitem->rss_link}{else}{link action=view id=$newsitem->id}{/if}">{$_TR.read_more}<span> {$_TR.on} "{$newsitem->title}"</span></a>
+ | Read {$newsitem->reads} times |
+ {if $newsitem->posted > $smarty.now}
+ <b><u>{$_TR.will_be}&nbsp;
+ {elseif ($newsitem->unpublish != 0) && $newsitem->unpublish <= $smarty.now}
+ <b><u>{$_TR.was}&nbsp;
+ {/if}
+ {$typepost}{if $config->show_poster} {$_TR.by} {attribution user_id=$whopost} {$_TR.on} {/if}&nbsp;{$sortdate|format_date:$smarty.const.DISPLAY_DATE_FORMAT}
+ {if $newsitem->posted > $smarty.now}
+ </u></b>&nbsp;
+ {elseif ($newsitem->unpublish != 0) && $newsitem->unpublish <= $smarty.now}
+ {$_TR.now_unpublished}</u></b>&nbsp;
+ {/if}
+ </div>
+ <hr />
+ </div>
+ {/if}
+ {/foreach}
+ {permissions level=$smarty.const.UILEVEL_NORMAL}
+ <div class="moduleactions">
+ <p>
+ {if $enable_pagination == 1}
+ {if $page != 0}
+ {math equation="x-1" x=$page assign=prevpage}
+ <a class="news_mngmntlink" href="{link action=view_page_bytag id=$viewing_tag page=$prevpage}">{$_TR.prev}</a>&nbsp;&nbsp;
+ {else}
+ {$_TR.prev}&nbsp;&nbsp;
+ {/if}
+ {if $shownext}
+ {math equation="x+1" x=$page assign=nextpage}
+ <a class="news_mngmntlink" href="{link action=view_page_bytag id=$viewing_tag page=$nextpage}">{$_TR.next}</a>
+ {else}
+ {$_TR.next}
+ {/if}
+ {br}
+ {/if}
+ {permissions level=$smarty.const.UILEVEL_NORMAL}
+ {if $permissions.add_item == true}
+ <a class="addnews mngmntlink" href="{link action=edit}">{$_TR.create_news}</a>{br}
+ {/if}
+ {if $in_approval > 0 && $canview_approval_link == 1}
+ <a class="approvenews mngmntlink" href="{link module=workflow datatype=newsitem m=newsmodule s=$__loc->src action=summary}">{$_TR.view_approval}</a>{br}
+ {/if}
+ {if $permissions.view_unpublished == 1 }
+ <a class="expirednews mngmntlink" href="{link action=view_expired}">{$_TR.view_expired}</a>
+ {/if}
+ {/permissions}
+ </p>
+ </div>
+ {/permissions}
+</div>
@@ -0,0 +1,42 @@
+<?php
+
+return array(
+ 'alt_userperm'=>'Assign user permissions on this News Module',
+ 'alt_groupperm'=>'Assign group permissions on this News Module',
+ 'alt_configure'=>'Configure this News Module',
+
+ 'alt_userperm_one'=>'Assign user permissions on this News Item',
+ 'alt_groupperm_one'=>'Assign group permissions on this News Item',
+
+ 'alt_edit_disabled'=>'Editing Disabled - News Item in Approval',
+ 'alt_edit'=>'Edit this News Item',
+ 'alt_delete_disabled'=>'Deleting Disabled - News Item in Approval',
+ 'alt_delete'=>'Delete this News Item',
+ 'delete_confirm'=>'Are you sure you want to delete this News Item?',
+
+ 'alt_revisions'=>'View Revision History for this News Item',
+ 'revisions'=>'Revisions',
+
+ 'read_more'=>'Read More...',
+
+ 'next'=>'Next &raquo;',
+ 'prev'=>'&laquo; Previous',
+ 'view_all'=>'More News...',
+ 'create_news'=>'Create News',
+ 'view_approval'=>'View Approval',
+ 'view_expired'=>'Unpublished / Expired News',
+
+ 'posted'=>'Posted',
+ 'posted_by'=>'Posted by',
+ 'updated'=>'Updated',
+ 'by'=>'by',
+ 'on'=>'on',
+ 'to'=>'to',
+ 'will_be'=>'Will be',
+ 'was'=>'Was',
+ 'now_unpublished'=>'Now Unpublished',
+
+ 'alt_rssfeed'=>'RSS Subscription'
+);
+
+?>

0 comments on commit dbe5c54

Please sign in to comment.