]> git.imager.perl.org - bse.git/commitdiff
move Article/s modules to more appropriate location
authorAdrian Oldham <adriann@visualthought.com.au>
Sat, 30 Aug 2014 06:23:11 +0000 (16:23 +1000)
committerAdrian Oldham <adriann@visualthought.com.au>
Mon, 1 Sep 2014 11:33:57 +0000 (21:33 +1000)
58 files changed:
MANIFEST
site/cgi-bin/admin/generate.pl
site/cgi-bin/admin/move.pl
site/cgi-bin/modules/Article.pm [deleted file]
site/cgi-bin/modules/Articles.pm [deleted file]
site/cgi-bin/modules/BSE/API.pm
site/cgi-bin/modules/BSE/Admin/StepParents.pm
site/cgi-bin/modules/BSE/AdminUsers.pm
site/cgi-bin/modules/BSE/DummyArticle.pm
site/cgi-bin/modules/BSE/Dynamic/Article.pm
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/BSE/Edit/Site.pm
site/cgi-bin/modules/BSE/Formatter.pm
site/cgi-bin/modules/BSE/Generate.pm
site/cgi-bin/modules/BSE/Generate/Article.pm
site/cgi-bin/modules/BSE/ImageClean.pm
site/cgi-bin/modules/BSE/Importer/Target/Article.pm
site/cgi-bin/modules/BSE/Importer/Target/Product.pm
site/cgi-bin/modules/BSE/Index.pm
site/cgi-bin/modules/BSE/Message.pm
site/cgi-bin/modules/BSE/Permissions.pm
site/cgi-bin/modules/BSE/ProductImportXLS.pm
site/cgi-bin/modules/BSE/Regen.pm
site/cgi-bin/modules/BSE/Request/Base.pm
site/cgi-bin/modules/BSE/SubscriptionType.pm
site/cgi-bin/modules/BSE/TB/Article.pm [new file with mode: 0644]
site/cgi-bin/modules/BSE/TB/ArticleFile.pm
site/cgi-bin/modules/BSE/TB/Articles.pm [new file with mode: 0644]
site/cgi-bin/modules/BSE/TB/Image.pm
site/cgi-bin/modules/BSE/TB/SiteCommon.pm
site/cgi-bin/modules/BSE/TB/TagCategory.pm
site/cgi-bin/modules/BSE/UI/AdminEdit.pm
site/cgi-bin/modules/BSE/UI/AdminNewsletter.pm
site/cgi-bin/modules/BSE/UI/AdminPage.pm
site/cgi-bin/modules/BSE/UI/AdminPregen.pm
site/cgi-bin/modules/BSE/UI/AdminReorder.pm
site/cgi-bin/modules/BSE/UI/AdminSendEmail.pm
site/cgi-bin/modules/BSE/UI/AdminShop.pm
site/cgi-bin/modules/BSE/UI/Image.pm
site/cgi-bin/modules/BSE/UI/Page.pm
site/cgi-bin/modules/BSE/UI/Search.pm
site/cgi-bin/modules/BSE/UI/Tellafriend.pm
site/cgi-bin/modules/BSE/UserReg.pm
site/cgi-bin/modules/BSE/Util/DynamicTags.pm
site/cgi-bin/modules/BSE/Util/Tags.pm
site/cgi-bin/modules/BSE/Variables.pm
site/cgi-bin/modules/Product.pm
site/cgi-bin/printable.pl
site/docs/.gitignore
site/docs/makedocs
site/util/bse_makeindex.pl
site/util/gen.pl
site/util/initial.pl
t/050-local/010-api.t
t/050-local/020-article.t
t/050-local/040-catalog.t
t/050-local/050-dyncat.t
t/060-generate/020-catalog.t

index d3b0ba901d2ef4a183c71ddd00b1f8980de60cab..b62ca9448dadfd3ec64845540cb44e0dab9e4cfe 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -58,8 +58,8 @@ site/cgi-bin/image.pl
 site/cgi-bin/interest.pl
 site/cgi-bin/modules/Apache/Session/DBIreal.pm
 site/cgi-bin/modules/Apache/Session/Store/DBIreal.pm
-site/cgi-bin/modules/Article.pm
-site/cgi-bin/modules/Articles.pm
+site/cgi-bin/modules/BSE/TB/Article.pm
+site/cgi-bin/modules/BSE/TB/Articles.pm
 site/cgi-bin/modules/BSE/Admin/StepParents.pm
 site/cgi-bin/modules/BSE/AdminLogon.pm
 site/cgi-bin/modules/BSE/AdminMenu.pm
index ac175a129fa4173ea6510e9f7622f039472e6321..180c024acee98be1da7f2c83eb8164083a63358c 100755 (executable)
@@ -4,7 +4,7 @@ BEGIN { $ENV{DISPLAY} = '192.168.32.51:0.0' }
 use strict;
 use FindBin;
 use lib "$FindBin::Bin/../modules";
-use Articles;
+use BSE::TB::Articles;
 use CGI qw(:standard);
 use Constants;
 use BSE::Regen qw(generate_button generate_all generate_article generate_base generate_one_extra pregenerate_list);
@@ -30,13 +30,13 @@ unless ($req->check_admin_logon()) {
   exit;
 }
 
-my $articles = "Articles";
+my $articles = "BSE::TB::Articles";
 
 my $id = $cgi->param('id');
 my $fromid = $cgi->param('fromid') || $id;
 my $baseurl;
 if (defined $fromid
-    and my $fromart = Articles->getByPkey($fromid)) {
+    and my $fromart = BSE::TB::Articles->getByPkey($fromid)) {
   $baseurl = $fromart->{admin};
 }
 else {
@@ -80,7 +80,7 @@ my $good = eval {
          or die { error_code => "ACCESS", message => "Access denied - you need regen_extras access" };
       }
       else {
-       $article = Articles->getByPkey($id)
+       $article = BSE::TB::Articles->getByPkey($id)
          or die { error_code => "NOTFOUND", message => "No such article $id found" };
        $req->user_can('regen_article', $article)
          or die { error_code => "ACCESS", message => "Access denied - you don't have regen_article access on article $id" };
index 7273366d7e46534fd14eb170afbe92a4040ee394..4648e09d16fba22782f1b423a5176c345f547963 100755 (executable)
@@ -5,7 +5,7 @@
 use strict;
 use FindBin;
 use lib "$FindBin::Bin/../modules";
-use Articles;
+use BSE::TB::Articles;
 use CGI ':standard';
 use Carp 'verbose';
 use CGI::Carp 'fatalsToBrowser';
@@ -27,7 +27,7 @@ unless ($req->check_admin_logon()) {
 my $id = $cgi->param('id');
 my $direction = $cgi->param('d');
 
-my $articles = 'Articles';
+my $articles = 'BSE::TB::Articles';
   
 my $article;
 if (defined $cgi->param('stepchild')) {
@@ -35,7 +35,7 @@ if (defined $cgi->param('stepchild')) {
   if ($req->user_can(edit_reorder_stepparents=>$stepchild)) {
     # we always need a swap for this one
     
-    my $article = Articles->getByPkey($stepchild)
+    my $article = BSE::TB::Articles->getByPkey($stepchild)
       or die "Cannot find child $stepchild";
     
     my $other = $cgi->param('other');
@@ -49,7 +49,7 @@ if (defined $cgi->param('stepchild')) {
       ($two->{childDisplayOrder}, $one->{childDisplayOrder});
     $one->save;
     $two->save;
-    generate_article('Articles', $article);
+    generate_article('BSE::TB::Articles', $article);
   }
 }
 elsif (defined $cgi->param('stepparent')) {
@@ -62,20 +62,20 @@ elsif (defined $cgi->param('stepparent')) {
     my $one = OtherParents->getBy(parentId=>$stepparent, childId=>$id);
     unless ($one) {
       $onename = 'displayOrder';
-      $one = Articles->getByPkey($id)
+      $one = BSE::TB::Articles->getByPkey($id)
        or die "Could not find article $id";
     }
     my $twoname = 'parentDisplayOrder';
     my $two = OtherParents->getBy(parentId=>$stepparent, childId=>$other);
     unless ($two) {
       $twoname = 'displayOrder';
-      $two = Articles->getByPkey($other)
+      $two = BSE::TB::Articles->getByPkey($other)
        or die "Could not find article $other";
     }
     ($one->{$onename}, $two->{$twoname}) = ($two->{$twoname}, $one->{$onename});
     $one->save;
     $two->save;
-    generate_article('Articles', $article);
+    generate_article('BSE::TB::Articles', $article);
   }
 }
 else {
@@ -133,7 +133,7 @@ else {
     }
     
     $article->save();
-    generate_article('Articles', $article);
+    generate_article('BSE::TB::Articles', $article);
   }
 }
 
diff --git a/site/cgi-bin/modules/Article.pm b/site/cgi-bin/modules/Article.pm
deleted file mode 100644 (file)
index 25e98e8..0000000
+++ /dev/null
@@ -1,757 +0,0 @@
-package Article;
-use strict;
-# represents an article from the database
-use Squirrel::Row;
-use BSE::TB::SiteCommon;
-use BSE::TB::TagOwner;
-use vars qw/@ISA/;
-@ISA = qw/Squirrel::Row BSE::TB::SiteCommon BSE::TB::TagOwner/;
-use Carp 'confess';
-
-our $VERSION = "1.023";
-
-=head1 NAME
-
-Article - article objects for BSE.
-
-=head1 SYNOPSIS
-
-  use BSE::API qw(bse_make_article);
-
-  my $article = bse_make_article(...)
-
-  my $article = Articles->getByPkey($id);
-
-=head1 DESCRIPTION
-
-Implements the base article object for BSE.
-
-=head1 USEFUL METHODS
-
-=over
-
-=cut
-
-sub columns {
-  return qw/id parentid displayOrder title titleImage body
-    thumbImage thumbWidth thumbHeight imagePos
-    release expire keyword template link admin threshold
-    summaryLength generator level listed lastModified flags
-    customDate1 customDate2 customStr1 customStr2
-    customInt1 customInt2 customInt3 customInt4 
-    lastModifiedBy created createdBy author pageTitle
-    force_dynamic cached_dynamic inherit_siteuser_rights
-    metaDescription metaKeywords summary menu titleAlias linkAlias
-    category/;
-}
-
-sub db_columns {
-  my ($self) = @_;
-
-  return map { $_ eq "summary" ? "summaryx" : $_ } $self->columns;
-}
-
-=item id
-
-=item parentid
-
-=item displayOrder
-
-=item title
-
-=item titleImage
-
-=item body
-
-=item thumbImage
-
-=item thumbWidth
-
-=item thumbHeight
-
-=item imagePos
-
-=item release
-
-=item expire
-
-=item keyword
-
-=item template
-
-=item threshold
-
-=item summaryLength
-
-=item generator
-
-=item level
-
-=item listed
-
-=item lastModified
-
-=item flags
-
-=item customDate1
-
-=item customDate2
-
-=item customStr1
-
-=item customStr2
-
-=item customInt1
-
-=item customInt2
-
-=item customInt3
-
-=item customInt4
-
-=item lastModifiedBy
-
-=item created
-
-=item createdBy
-
-=item author
-
-=item pageTitle
-
-=item force_dynamic
-
-=item cached_dynamic
-
-=item inherit_siteuser_rights
-
-=item metaDescription
-
-=item metaKeywords
-
-=item summary
-
-=item menu
-
-=item titleAlias
-
-=item linkAlias
-
-=item category
-
-Simple column accessors.
-
-=cut
-
-sub table {
-  'article';
-}
-
-sub numeric {
-  qw(id listed parentid threshold summaryLength level 
-     customInt1 customInt2 customInt3 customInt4 menu);
-}
-
-=item section
-
-Return the article's section.
-
-=cut
-
-sub section {
-  my ($self) = @_;
-
-  my $section = $self;
-  while ($section->{parentid} > 0
-        and my $parent = $section->parent) {
-    $section = $parent;
-  }
-
-  return $section;
-}
-
-=item parent
-
-Return the article's parent.
-
-=cut
-
-sub parent {
-  my ($self) = @_;
-
-  my $parentid = $self->parentid;
-
-  $parentid == -1
-    and return;
-  $self->{_parent} && $self->{_parent}->id == $parentid
-    and return $self->{_parent};
-  return ($self->{_parent} = Articles->getByPkey($self->{parentid}));
-}
-
-sub update_dynamic {
-  my ($self, $cfg) = @_;
-
-  $cfg && $cfg->can('entry')
-    or confess 'update_dynamic called without $cfg';
-
-  # conditional in case something strange is in the config file
-  my $dynamic = $cfg->entry('basic', 'all_dynamic', 0) ? 1 : 0;
-
-  if (!$dynamic && $self->generator =~ /\bCatalog\b/) {
-    require Products;
-    my @tiers = Products->pricing_tiers;
-    @tiers and $dynamic = 1;
-  }
-
-  $dynamic or $dynamic = $self->{force_dynamic};
-
-  $dynamic or $dynamic = $self->is_access_controlled;
-
-  $dynamic or $dynamic = $self->force_dynamic_inherited;
-
-  $self->{cached_dynamic} = $dynamic;
-}
-
-=item is_dynamic
-
-Return true if the article is rendered dynamically.
-
-=cut
-
-sub is_dynamic {
-  $_[0]{cached_dynamic};
-}
-
-=item is_accessible_to($group)
-
-Return true if the article is accessible to the supplied siteuser
-group or group id.
-
-=cut
-
-sub is_accessible_to {
-  my ($self, $group) = @_;
-
-  my $groupid = ref $group ? $group->{id} : $group;
-
-  my @rows = BSE::DB->query(articleAccessibleToGroup => $self->{id}, $groupid);
-
-  scalar @rows;
-}
-
-sub group_ids {
-  my ($self) = @_;
-
-  map $_->{id}, BSE::DB->query(siteuserGroupsForArticle => $self->{id});
-}
-
-sub add_group_id {
-  my ($self, $id) = @_;
-
-  eval {
-    BSE::DB->single->run(articleAddSiteUserGroup => $self->{id}, $id);
-  };
-}
-
-sub remove_group_id {
-  my ($self, $id) = @_;
-
-  BSE::DB->single->run(articleDeleteSiteUserGroup => $self->{id}, $id);
-}
-
-=item is_access_controlled
-
-Return true if the article is access controlled.
-
-=cut
-
-sub is_access_controlled {
-  my ($self) = @_;
-
-  my @group_ids = $self->group_ids;
-  return 1 if @group_ids;
-
-  return 0
-    unless $self->{inherit_siteuser_rights};
-
-  my $parent = $self->parent
-    or return 0;
-
-  return $parent->is_access_controlled;
-}
-
-sub force_dynamic_inherited {
-  my ($self) = @_;
-
-  my $parent = $self->parent
-    or return 0;
-
-  $parent->{force_dynamic} && $parent->{flags} =~ /F/
-    and return 1;
-  
-  return $parent->force_dynamic_inherited;
-}
-
-sub link_to_filename {
-  my ($self, $cfg, $link) = @_;
-
-  $cfg ||= BSE::Cfg->single;
-
-  defined $link or $link = $self->{link};
-
-  length $link or return;
-
-  my $filename = $link;
-
-  # remove any appended title,
-  $filename =~ s!(.)/\w+$!$1!;
-  $filename =~ s{^\w+://[\w.-]+(?::\d+)?}{};
-  $filename = $cfg->content_base_path() . $filename;
-  if ($filename =~ m(/$)) {
-    $filename .= $cfg->entry("basic", "index_file", "index.html");
-  }
-  $filename =~ s!//+!/!;
-  
-  return $filename;
-}
-
-sub cached_filename {
-  my ($self, $cfg) = @_;
-
-  $cfg ||= BSE::Cfg->single;
-
-  my $dynamic_path = $cfg->entryVar('paths', 'dynamic_cache');
-  return $dynamic_path . "/" . $self->{id} . ".html";
-}
-
-sub html_filename {
-  my ($self, $cfg) = @_;
-
-  $cfg ||= BSE::Cfg->single;
-
-  return $self->is_dynamic
-    ? $self->cached_filename($cfg)
-      : $self->link_to_filename($cfg);
-}
-
-sub remove_html {
-  my ($self, $cfg) = @_;
-
-  my $filename = $self->html_filename($cfg)
-    or return 1;
-
-  unlink $filename
-    or return;
-
-  return 1;
-}
-
-sub remove {
-  my ($self, $cfg) = @_;
-
-  $cfg or confess "No \$cfg supplied to ", ref $self, "->remove";
-
-  $self->remove_tags;
-
-  $self->remove_images($cfg);
-
-  $self->remove_files($cfg);
-  
-  # remove any step(child|parent) links
-  require OtherParents;
-  my @steprels = OtherParents->anylinks($self->{id});
-  for my $link (@steprels) {
-    $link->remove();
-  }
-
-  # remove any site user access controls
-  BSE::DB->single->run(bseRemoveArticleSiteUserGroups => $self->id);
-
-  # remove any admin user/group access controls
-  BSE::DB->single->run(bseRemoveArticleAdminAccess => $self->id);
-
-  # remove the static page
-  $self->remove_html($cfg);
-
-  $self->SUPER::remove();
-}
-
-=item all_parents
-
-Return a list of all parents.
-
-=cut
-
-sub all_parents {
-  my ($self) = @_;
-
-  my @result = $self->step_parents;
-  if ($self->{parentid} > 0 && !grep $_->{id} eq $self->{parentid}, @result) {
-    push @result, $self->parent;
-  }
-
-  return @result;
-}
-
-sub is_step_ancestor {
-  my ($self, $other, $max) = @_;
-
-  my $other_id = ref $other ? $other->{id} : $other;
-  my %seen;
-
-  $max ||= 10;
-
-  # early exit if possible
-  return 1 if $self->{parentid} == $other_id;
-
-  my @all_parents = $self->all_parents;
-  return 1 if grep $_->{id} == $other_id, @all_parents;
-  my @work = map [ 0, $_], grep !$seen{$_}++, @all_parents;
-  while (@work) {
-    my $entry = shift @work;
-    my ($level, $workart) = @$entry;
-
-    $level++;
-    if ($level < $max) {
-      @all_parents = $workart->all_parents;
-      return 1 if grep $_->{id} == $other_id, @all_parents;
-      push @work, map [ $level, $_ ], grep !$seen{$_}++, @all_parents;
-    }
-  }
-
-  return 0;
-}
-
-sub possible_stepparents {
-  my $self = shift;
-
-  return BSE::DB->query(articlePossibleStepparents => $self->{id}, $self->{id});
-}
-
-sub possible_stepchildren {
-  my $self = shift;
-
-  return BSE::DB->query(articlePossibleStepchildren => $self->{id}, $self->{id});
-}
-
-sub link {
-  my ($self, $cfg) = @_;
-
-  if ($self->flags =~ /P/) {
-    my $parent = $self->parent;
-    $parent and return $parent->link($cfg);
-  }
-
-  $self->is_linked
-    or return "";
-
-  $cfg ||= BSE::Cfg->single;
-
-  unless ($self->{linkAlias} && $cfg->entry('basic', 'use_alias', 1)) {
-    return $self->{link};
-  }
-
-  my $prefix = $cfg->entry('basic', 'alias_prefix', '');
-  my $link;
-  if ($cfg->entry('basic', 'alias_recursive')) {
-    my @steps = $self->{linkAlias};
-    my $article = $self;
-    while ($article = $article->parent) {
-      if ($article->{linkAlias}) {
-       unshift @steps, $article->{linkAlias};
-      }
-    }
-    $link = join('/', $prefix, @steps);
-  }
-  else {
-    $link = $prefix . '/' . $self->{linkAlias};
-  }
-  if ($cfg->entry('basic', 'alias_suffix', 1)) {
-    my $title = $self->{title};
-    $title =~ tr/a-zA-Z0-9/-/cs;
-    $link .= '/' . $title;
-  }
-  return $link;
-}
-
-=item admin
-
-Return the admin link for the article.
-
-=cut
-
-sub admin {
-  my ($self) = @_;
-
-  return BSE::Cfg->single->admin_url("admin", { id => $self->id });
-}
-
-=item is_linked
-
-Return true if the article can be linked to.
-
-=cut
-
-sub is_linked {
-  my ($self) = @_;
-
-  return $self->flags !~ /D/;
-}
-
-sub tag_owner_type {
-  return "BA";
-}
-
-# the time used for expiry/release comparisons
-sub _expire_release_datetime {
-  my ($year, $month, $day) = (localtime)[5,4,3];
-  my $today = sprintf("%04d-%02d-%02d 00:00:00ZZZ", $year+1900, $month+1, $day);
-}
-
-=item is_expired
-
-Returns true if the article expiry date has passed.
-
-=cut
-
-sub is_expired {
-  my $self = shift;
-
-  return $self->expire lt _expire_release_datetime();
-}
-
-=item is_released
-
-Returns true if the article release date has passed (ie. the article
-has been released.)
-
-=cut
-
-sub is_released {
-  my $self = shift;
-
-  return $self->release le _expire_release_datetime();
-}
-
-=item listed_in_menu
-
-Return true if the article should be listed in menus.
-
-=cut
-
-sub listed_in_menu {
-  my $self = shift;
-
-  return $self->listed == 1;
-}
-
-=item ancestors
-
-Returns a list of ancestors of self.
-
-=cut
-
-sub ancestors {
-  my ($self) = @_;
-
-  unless ($self->{_ancestors}) {
-    my @ancestors;
-    my $work = $self;
-    while ($work->parentid != -1) {
-      $work = $work->parent;
-      push @ancestors, $work;
-    }
-
-    $self->{_ancestors} = \@ancestors;
-  }
-
-  return @{$self->{_ancestors}};
-}
-
-=item is_descendant_of($ancestor)
-
-Return true if self is a decsendant of the supplied article or article
-id.
-
-=cut
-
-sub is_descendant_of {
-  my ($self, $ancestor) = @_;
-
-  my $ancestor_id = ref $ancestor ? $ancestor->id : $ancestor;
-
-  for my $anc ($self->ancestors) {
-    return 1 if $anc->id == $ancestor_id;
-  }
-
-  return 0;
-}
-
-=item visible_ancestors
-
-Returns all visible ancestors.
-
-Lists the top-level ancestor C<last>.
-
-This list does not include the article itself.
-
-=cut
-
-sub visible_ancestors {
-  my ($self) = @_;
-
-  return grep $_->listed, $self->ancestors;
-}
-
-=item menu_ancestors
-
-Returns visible ancestprs that are visible for menus (ie. listed = 1).
-
-Lists the top-level ancestor C<last>.
-
-This list does not include the article itself.
-
-=cut
-
-sub menu_ancestors {
-  my ($self) = @_;
-
-  return grep $_->listed, $self->ancestors;
-}
-
-=item should_generate
-
-Return true if this article should have pages generated, either for
-static content or for dynamic.
-
-=cut
-
-sub should_generate {
-  my ($self) = @_;
-
-  return $self->is_linked && $self->listed && $self->is_released && !$self->is_expired;
-}
-
-=item should_index
-
-Returns true if the article should be indexed.
-
-=cut
-
-sub should_index {
-  my ($self) = @_;
-
-  return ($self->listed || $self->is_index_even_if_hidden)
-    && $self->is_linked
-      && !$self->is_dont_index
-       && !$self->is_dont_index_or_kids
-}
-
-=item is_index_even_if_hidden
-
-Return true if the article's index even if hidden flag is set.
-
-=cut
-
-sub is_index_even_if_hidden {
-  my ($self) = @_;
-
-  return $self->flags =~ /I/;
-}
-
-=item is_dont_index
-
-Return true if the "don't index" flag (C<N>) is set.
-
-=cut
-
-sub is_dont_index {
-  return $_[0]->flags =~ /N/;
-}
-
-=item is_dont_index_or_kids
-
-Return true if the article or any of it's parents have the "don't
-index me or my children" flag (C<C>) set.
-
-=cut
-
-sub is_dont_index_or_kids {
-  my ($self) = @_;
-
-  $self->flags =~ /C/ and return 1;
-
-  my $parent = $self->parent
-    or return 0;
-
-  return $parent->is_dont_index_or_kids;
-}
-
-sub restricted_method {
-  my ($self, $name) = @_;
-
-  return $self->SUPER::restricted_method($name)
-    || $name =~ /^(?:update_|remove_|add_|mark_modified)/;
-}
-
-sub tableClass {
-  return "Articles";
-}
-
-=item mark_modified
-
-Call by admin code to do the things we do when an article is modified.
-
-Parameters:
-
-=over
-
-=item *
-
-actor - an audit log compatible actor.
-
-=back
-
-=cut
-
-sub mark_modified {
-  my ($self, %opts) = @_;
-
-  require BSE::Util::SQL;
-  $self->set_lastModified(BSE::Util::SQL::now_sqldatetime());
-  $self->set_lastModifiedBy(ref $opts{actor} ? $opts{actor}->logon : "");
-}
-
-=item uncache
-
-Free any cached data.
-
-=cut
-
-sub uncache {
-  my ($self) = @_;
-
-  delete @{$self}{qw/_parent/};
-
-  $self->SUPER::uncache();
-}
-
-1;
-
-__END__
-
-=back
-
-=head1 BASE CLASSES
-
-L<BSE::TB::SiteCommon>
-
-L<BSE::TB::TagOwner>
-
-L<Squirrel::Row>
-
-=head1 AUTHOR
-
-Tony Cook <tony@develop-help.com>
-
-=cut
diff --git a/site/cgi-bin/modules/Articles.pm b/site/cgi-bin/modules/Articles.pm
deleted file mode 100644 (file)
index 30dd85a..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-package Articles;
-use strict;
-use Squirrel::Table;
-use vars qw(@ISA $VERSION);
-require BSE::TB::TagOwners;
-@ISA = qw(Squirrel::Table BSE::TB::TagOwners);
-use Article;
-
-our $VERSION = "1.005";
-
-=head1 NAME
-
-Articles - BSE's article collection
-
-=head1 SYNOPSIS
-
-  use Articles;
-
-  my $article = Articles->make(...);
-  my $article = Articles->getByPkey($id)
-  # etc
-
-=head1 DESCRIPTION
-
-The collective class for BSE articles.
-
-=head1 USEFUL METHODS
-
-=over
-
-=cut
-
-sub rowClass {
-  return 'Article';
-}
-
-=item sections
-
-Returns a list of articles which are sections
-
-=cut
-
-sub sections {
-  my ($self) = @_;
-
-  return $self->getBy('level', 1);
-}
-
-=item subsections
-
-Returns a list of articles which are sub sections
-
-=cut
-
-sub subsections {
-  my ($self) = @_;
-
-  return $self->getBy('level', 2);
-}
-
-=item children($id)
-
-Child articles of the given article id
-
-=cut
-
-sub children {
-  my ($self, $id) = @_;
-
-  return $self->getBy('parentid', $id);
-}
-
-=item listedChildren($id)
-
-Children of the given article id that are listed and in the display
-order
-
-=cut
-
-sub listedChildren {
-  my ($self, $id) = @_;
-  my ($year, $month, $day) = (localtime)[5,4,3];
-  my $today = sprintf("%04d-%02d-%02d 00:00:00ZZZ", $year+1900, $month+1, $day);
-  my @work = $self->children($id);
-  return sort { $b->{displayOrder} <=> $a->{displayOrder} }
-    grep { $_->{listed} && $today ge $_->{release} 
-            && $today le $_->{expire}} @work;
-}
-
-=item summary
-
-Return a list of hashes with article id and title for every article.
-
-=cut
-
-sub summary {
-  BSE::DB->query('articlesList');
-}
-
-=item allids
-
-Return a list of all article ids.
-
-=cut
-
-sub allids {
-  my ($self) = @_;
-
-  if (ref $self) {
-    return map $_->{id}, $self->all;
-  }
-  else {
-    return map $_->{id}, BSE::DB->query('Articles.ids');
-  }
-}
-
-=item visible_stepkids($id)
-
-Return a list of visible stepkids of the given article id.
-
-=cut
-
-sub visible_stepkids {
-  my ($self, $id) = @_;
-
-  use BSE::Util::SQL qw/now_sqldate/;
-  my $today = now_sqldate();
-
-  return Articles->getSpecial('visibleStepKids', $id, $today);
-}
-
-=item all_visible_kids($id)
-
-Return a list of all visible children of the given article id.
-
-=cut
-
-sub all_visible_kids {
-  my ($self, $id) = @_;
-
-  require 'OtherParents.pm';
-
-  my @otherlinks = OtherParents->getBy(parentId=>$id);
-  my @normalkids = Articles->listedChildren($id);
-  my %order = (
-              (map { $_->{id}, $_->{displayOrder} } @normalkids ),
-              (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
-             );
-  my @stepkids = $self->visible_stepkids($id);
-  my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
-
-  return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };
-}
-
-=item all_visible_kid_tags($id)
-
-Return a hash with two keys, C<tags> being all tags for all visible
-children of C<$id>, and C<members> being all tag member objects for
-all visible children of C<$id>.
-
-=cut
-
-sub all_visible_kid_tags {
-  my ($self, $id) = @_;
-
-  require BSE::TB::Tags;
-  require BSE::TB::TagMembers;
-  return
-    {
-     tags => [ BSE::TB::Tags->getSpecial(allkids => $id, $id) ],
-     members => [ BSE::TB::TagMembers->getSpecial(allkids => $id, $id) ],
-    };
-}
-
-=item global_files
-
-Return a list of global files.
-
-=cut
-
-sub global_files {
-  my ($self) = @_;
-
-  require BSE::TB::ArticleFiles;
-  return BSE::TB::ArticleFiles->getBy(articleId => -1);
-}
-
-=item allkid_summary($parent_id)
-
-Return a list of hash per child, each with id, displayOrder sorted for
-display.
-
-Entries with step_id are for step children of $parent_id.
-
-=cut
-
-sub allkid_summary {
-  my ($class, $parent_id) = @_;
-
-  my @child_order = BSE::DB->query(bseChildOrder => $parent_id);
-  my @stepchild_order = BSE::DB->query(bseStepchildOrder => $parent_id);
-
-  return sort { $b->{displayOrder} <=> $a->{displayOrder} }
-    ( @child_order, @stepchild_order );
-}
-
-=item reorder_child($parent_id, $child_id, $after_id)
-
-Move article C<$child_id> after C<$after_id> in the all children list
-of article C<$after_id>.
-
-Returns a true value on success.
-
-=cut
-
-sub reorder_child {
-  my ($class, $parent_id, $child_id, $after_id) = @_;
-
-  my @child_order = $class->allkid_summary($parent_id);
-
-  my ($child_index) = grep $child_order[$_]{id} == $child_id, 0..$#child_order
-    or return; # nothing to do, it's not a child
-  my @order = map $_->{displayOrder}, @child_order;
-
-  if ($child_index > 0 && $child_order[$child_index-1]{id} == $after_id
-      || $child_index == 0 && $after_id == 0) {
-    # trivial success
-    return 1;
-  }
-
-  # remove the child from the order
-  my ($child) = splice(@child_order, $child_index, 1);
-
-  my $start_index;
-  if ($after_id == 0) {
-    unshift @child_order, $child;
-    $start_index = 0;
-  }
-  else {
-    my ($after_index) = grep $child_order[$_]{id} == $after_id, 0..$#child_order
-      or return; # after not found, nothing to do
-
-    splice(@child_order, $after_index+1, 0, $child);
-    $start_index = $after_index + 1;
-  }
-
-  for my $index (0 .. $#order) {
-    my $child = $child_order[$index];
-    if ($child->{step_id}) {
-      BSE::DB->run(bseSetStepOrder => $order[$index], $child->{step_id});
-    }
-    else {
-      BSE::DB->run(bseSetArticleOrder => $order[$index], $child->{id});
-    }
-  }
-
-  return 1;
-}
-
-=item categories
-
-Return a list of all configured article categories.
-
-Each entry is a hash containing C<id> and C<name>.
-
-=cut
-
-sub categories {
-  my $cfg = BSE::Cfg->single;
-
-  my @cat_ids = split /,/, $cfg->entry("article categories", "ids", "");
-  grep $_ eq "", @cat_ids
-    or unshift @cat_ids, "";
-
-  my @cats;
-  for my $id (@cat_ids) {
-    my $section = length $id ? "article category $id" : "article category empty";
-    my $def_name = length $id ? ucfirst $id : "(None)";
-    my $name = $cfg->entry($section, "name",
-                          $cfg->entry("article categories", $id, $def_name));
-    push @cats, +{ id => $id, name => $name };
-  }
-  
-  return @cats;
-}
-
-1;
-
-=back
-
-=head1 AUTHOR
-
-Tony Cook <tony@develop-help.com>
-
-=cut
-
index fce7cbd80d37f5a8206a48bc08cb7a3b693f415c..f5cd75ac47fde689af32f2d8b44bc416d758b92f 100644 (file)
@@ -10,7 +10,7 @@ use Carp qw(confess croak);
 use Fcntl qw(:seek);
 use Cwd;
 
-our $VERSION = "1.008";
+our $VERSION = "1.009";
 
 =head1 NAME
 
@@ -112,8 +112,8 @@ sub _set_dynamic {
     $article->{level} = 1;
   }
   else {
-    require Articles;
-    my $parent = Articles->getByPkey($article->{parentid})
+    require BSE::TB::Articles;
+    my $parent = BSE::TB::Articles->getByPkey($article->{parentid})
       or confess "Invalid parent $article->{parentid}\n";
     $article->{level} = $parent->{level} + 1;
   }
@@ -220,7 +220,7 @@ sub bse_make_catalog {
   my $cfg = delete $opts{cfg}
     or confess "cfg option missing";
 
-  require Articles;
+  require BSE::TB::Articles;
 
   defined $opts{title} && length $opts{title}
     or confess "Missing title option\n";
@@ -239,9 +239,9 @@ sub bse_make_catalog {
 
   _set_dynamic($cfg, \%opts);
 
-  my @cols = Article->columns;
+  my @cols = BSE::TB::Article->columns;
   shift @cols;
-  my $catalog = Articles->add(@opts{@cols});
+  my $catalog = BSE::TB::Articles->add(@opts{@cols});
 
   require BSE::Edit::Catalog;
   _finalize_article($cfg, $catalog, 'BSE::Edit::Catalog');
@@ -255,7 +255,7 @@ sub bse_make_article {
   my $cfg = delete $opts{cfg}
     or confess "cfg option missing";
 
-  require Articles;
+  require BSE::TB::Articles;
 
   defined $opts{title} && length $opts{title}
     or confess "Missing title option\n";
@@ -273,9 +273,9 @@ sub bse_make_article {
 
   _set_dynamic($cfg, \%opts);
 
-  my @cols = Article->columns;
+  my @cols = BSE::TB::Article->columns;
   shift @cols;
-  my $article = Articles->add(@opts{@cols});
+  my $article = BSE::TB::Articles->add(@opts{@cols});
 
   require BSE::Edit::Article;
   _finalize_article($cfg, $article, 'BSE::Edit::Article');
@@ -403,7 +403,7 @@ sub _load_editor_class {
   my ($article, $cfg) = @_;
 
   require BSE::Edit::Base;
-  return BSE::Edit::Base->article_class($article, 'Articles', $cfg);
+  return BSE::Edit::Base->article_class($article, 'BSE::TB::Articles', $cfg);
 }
 
 # File::Copy doesn't like CGI.pm's fake fhs
index 2d8d86f9a260d077317d4de23a659af679d9f963..4636f700836f74909d2cf60a0c7989aae0794b37 100644 (file)
@@ -1,10 +1,10 @@
 package BSE::Admin::StepParents;
 use strict;
-use Articles;
+use BSE::TB::Articles;
 use OtherParents;
 use BSE::Util::SQL qw/date_to_sql/;
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 sub add {
   my ($class, $parent, $child, $release, $expire) = @_;
index 803bd1650cd949e98761cda1ba9c5d87e766f4f9..bab85222e5098be2518b2456514e39d79208fae4 100644 (file)
@@ -9,7 +9,7 @@ use BSE::TB::AdminUsers;
 use BSE::TB::AdminGroups;
 use BSE::Util::Iterate;
 
-our $VERSION = "1.008";
+our $VERSION = "1.009";
 
 my %actions =
   (
@@ -437,9 +437,9 @@ sub req_showuser {
 sub iter_get_kids {
   my ($article) = @_;
 
-  require Articles;
+  require BSE::TB::Articles;
   return sort { $b->{displayOrder} <=> $a->{displayOrder} } 
-    Articles->children($article->{id});
+    BSE::TB::Articles->children($article->{id});
 }
 
 sub iter_get_aperms {
@@ -547,8 +547,8 @@ sub get_article {
       };
   }
   else {
-    require Articles;
-    return Articles->getByPkey($id);
+    require BSE::TB::Articles;
+    return BSE::TB::Articles->getByPkey($id);
   }
 }
 
index a6bb1d87e09aa2b5d360805e075f84c117f3f0fc..0414f69c85ec585268304e9fa85d47e6d9e58cb3 100644 (file)
@@ -1,9 +1,9 @@
 package BSE::DummyArticle;
 use strict;
 use base 'BSE::TB::SiteCommon';
-use Articles;
+use BSE::TB::Articles;
 
-our $VERSION = "1.002";
+our $VERSION = "1.003";
 
 sub images {
   return;
@@ -14,7 +14,7 @@ sub files {
 }
 
 {
-  for my $name (Article->columns) {
+  for my $name (BSE::TB::Article->columns) {
     eval "sub $name { \$_[0]{$name} }";
   }
 }
index e213ce17981ce74942610cba7a93563c6d0b308d..0e8393390f51578ae1a9eed6861c80603179e182 100644 (file)
@@ -5,7 +5,7 @@ use BSE::Template;
 use BSE::Util::HTML;
 use base qw(BSE::Util::DynamicTags);
 
-our $VERSION = "1.006";
+our $VERSION = "1.007";
 
 sub new {
   my ($class, $req, %opts) = @_;
@@ -115,7 +115,7 @@ sub iter_dynchildren {
   $result
     and return $result;
 
-  $result = $self->access_filter(Articles->listedChildren($article->{id}));
+  $result = $self->access_filter(BSE::TB::Articles->listedChildren($article->{id}));
   $self->set_cached(dynchildren => $result);
 
   return $result;
index 89c974883e653179270da042fdbe1be90d42967a..5add14ddb2dc04fa0d5628167a87ff9a4710d6fa 100644 (file)
@@ -16,7 +16,7 @@ use List::Util qw(first);
 use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
 use constant ARTICLE_CUSTOM_FIELDS_CFG => "article custom fields";
 
-our $VERSION = "1.047";
+our $VERSION = "1.048";
 
 =head1 NAME
 
@@ -366,7 +366,7 @@ sub iter_get_kids {
 
   my @children;
   $article->{id} or return;
-  if (UNIVERSAL::isa($article, 'Article')) {
+  if (UNIVERSAL::isa($article, 'BSE::TB::Article')) {
     @children = $article->children;
   }
   elsif ($article->{id}) {
@@ -1542,7 +1542,7 @@ sub _dummy_article {
   }
   
   my %article;
-  my @cols = Article->columns;
+  my @cols = BSE::TB::Article->columns;
   @article{@cols} = ('') x @cols;
   $article{id} = '';
   $article{parentid} = $parentid;
@@ -1956,7 +1956,7 @@ sub save_new {
 
   my ($after_id) = $cgi->param("_after");
   if (defined $after_id) {
-    Articles->reorder_child($article->{parentid}, $article->{id}, $after_id);
+    BSE::TB::Articles->reorder_child($article->{parentid}, $article->{id}, $after_id);
     # reload, the displayOrder probably changed
     $article = $articles->getByPkey($article->{id});
   }
@@ -1996,7 +1996,7 @@ sub fill_old_data {
     $data->{body} =~ s/\x0D\x0A/\n/g;
     $data->{body} =~ tr/\r/\n/;
   }
-  for my $col (Article->columns) {
+  for my $col (BSE::TB::Article->columns) {
     next if $col =~ /^custom/;
     $article->{$col} = $data->{$col}
       if exists $data->{$col} && $col ne 'id' && $col ne 'parentid';
@@ -2258,7 +2258,7 @@ sub save {
 
   my ($after_id) = $cgi->param("_after");
   if (defined $after_id) {
-    Articles->reorder_child($article->{parentid}, $article->{id}, $after_id);
+    BSE::TB::Articles->reorder_child($article->{parentid}, $article->{id}, $after_id);
     # reload, the displayOrder probably changed
     $article = $articles->getByPkey($article->{id});
   }
@@ -2603,7 +2603,7 @@ sub add_stepkid {
 
   my $after_id = $cgi->param("_after");
   if (defined $after_id) {
-    Articles->reorder_child($article->id, $child->id, $after_id);
+    BSE::TB::Articles->reorder_child($article->id, $child->id, $after_id);
   }
 
   generate_article($articles, $article) if $Constants::AUTO_GENERATE;
@@ -2821,7 +2821,7 @@ sub req_restepkid {
   if ($newparentid) {
     $newparentid =~ /^\d+$/
       or return $self->_service_error($req, $article, $articles, "Bad new parent id", {}, "BADNEWPARENT");
-    my $new_parent = Articles->getByPkey($newparentid)
+    my $new_parent = BSE::TB::Articles->getByPkey($newparentid)
       or return $self->_service_error($req, $article, $articles, "Unknown new parent id", {}, "UNKNOWNNEWPARENT");
     my $existing = 
       OtherParents->getBy(parentId=>$newparentid, childId=>$article->id)
@@ -2833,7 +2833,7 @@ sub req_restepkid {
 
   my $after_id = $cgi->param("_after");
   if (defined $after_id) {
-    Articles->reorder_child($step->{parentId}, $article->id, $after_id);
+    BSE::TB::Articles->reorder_child($step->{parentId}, $article->id, $after_id);
   }
 
   if ($req->is_ajax) {
@@ -3250,7 +3250,7 @@ sub _service_error {
     $article = $self->_dummy_article($req, $articles, \$mymsg);
     $article ||=
       {
-       map $_ => '', Article->columns
+       map $_ => '', BSE::TB::Article->columns
       };
   }
 
@@ -5066,7 +5066,7 @@ sub default_value {
 
   if ($col eq 'threshold') {
     my $parent = defined $article->{parentid} && $article->{parentid} != -1 
-      && Articles->getByPkey($article->{parentid}); 
+      && BSE::TB::Articles->getByPkey($article->{parentid}); 
 
     $parent and return $parent->{threshold};
     
@@ -5075,7 +5075,7 @@ sub default_value {
   
   if ($col eq 'summaryLength') {
     my $parent = defined $article->{parentid} && $article->{parentid} != -1 
-      && Articles->getByPkey($article->{parentid}); 
+      && BSE::TB::Articles->getByPkey($article->{parentid}); 
 
     $parent and return $parent->{summaryLength};
     
@@ -5309,13 +5309,13 @@ sub csrf_error {
   my $msg = $req->csrf_error;
   $errors{_csrfp} = $msg;
   my $mymsg;
-  $article ||= $self->_dummy_article($req, 'Articles', \$mymsg);
+  $article ||= $self->_dummy_article($req, 'BSE::TB::Articles', \$mymsg);
   unless ($article) {
     require BSE::Edit::Site;
     my $site = BSE::Edit::Site->new(cfg=>$req->cfg, db=> BSE::DB->single);
-    return $site->edit_sections($req, 'Articles', $mymsg);
+    return $site->edit_sections($req, 'BSE::TB::Articles', $mymsg);
   }
-  return $self->_service_error($req, $article, 'Articles', $msg, \%errors);
+  return $self->_service_error($req, $article, 'BSE::TB::Articles', $msg, \%errors);
 }
 
 =item a_csrp
@@ -5338,7 +5338,7 @@ sub req_csrfp {
                                    "Only usable from Ajax", undef, "NOTAJAX");
 
   $ENV{REQUEST_METHOD} eq 'POST'
-    or return $self->_service_error($req, $article, "Articles",
+    or return $self->_service_error($req, $article, "BSE::TB::Articles",
                                    "POST required for this action", {}, "NOTPOST");
 
   my %errors;
@@ -5374,7 +5374,7 @@ sub _article_kid_summary {
   if (--$depth > 0) {
     for my $kid (@kids) {
       $kid->{children} = [ _article_kid_summary($kid->{id}, $depth) ];
-      $kid->{allkids} = [ Articles->allkid_summary($kid->{id}) ];
+      $kid->{allkids} = [ BSE::TB::Articles->allkid_summary($kid->{id}) ];
     }
   }
 
@@ -5411,7 +5411,7 @@ sub req_tree {
      ],
      allkids =>
      [
-      Articles->allkid_summary($article->id)
+      BSE::TB::Articles->allkid_summary($article->id)
      ],
     );
 }
index 2fb5bd52dbdfae27f0ed0cd69479131a74604c56..a2c8d360d039585a2a530f58fdcb799dcff090a6 100644 (file)
@@ -15,7 +15,7 @@ BSE::Edit::Site - edit interface for the site itself.
 
 =cut
 
-our $VERSION = "1.012";
+our $VERSION = "1.013";
 
 use base 'BSE::Edit::Article';
 use BSE::TB::Site;
@@ -70,7 +70,7 @@ sub get_images {
 sub get_files {
   my ($self, $article) = @_;
 
-  Articles->global_files;
+  BSE::TB::Articles->global_files;
 }
 
 sub req_tagshow {
@@ -91,7 +91,7 @@ sub req_tagshow {
       push @opts, [ like => "cat", "$cat%" ];
     }
   }
-  my @tags = Articles->all_tags(@opts);
+  my @tags = BSE::TB::Articles->all_tags(@opts);
 
   if ($req->is_ajax) {
     my @json = map $_->json_data, @tags;
@@ -99,7 +99,7 @@ sub req_tagshow {
       for my $i (0 .. $#tags) {
        my $tag = $tags[$i];
        my $json = $json[$i];
-       $json->{articles} = [ Articles->getIdsByTag($tag) ];
+       $json->{articles} = [ BSE::TB::Articles->getIdsByTag($tag) ];
       }
     }
 
@@ -134,7 +134,7 @@ sub req_tagshow {
       plural => "systagarts",
       code => sub {
        return sort { lc $a->title cmp lc $b->title }
-         Articles->getByTag($tag);
+         BSE::TB::Articles->getByTag($tag);
       },
       nocache => 1,
      ),
@@ -169,7 +169,7 @@ sub req_tagrename {
   }
 
   if ($tag && !$errors{name}) {
-    my $other = Articles->getTagByName($name);
+    my $other = BSE::TB::Articles->getTagByName($name);
     if ($other) {
       if ($other->id != $tag->id) {
        $errors{name} = "msg:bse/admin/edit/tags/duplicate:$name";
@@ -306,7 +306,7 @@ Template: C<admin/tagcats>.
 sub req_tagcats {
   my ($self, $req, $article, $articles) = @_;
 
-  my @cats = Articles->all_tag_categories;
+  my @cats = BSE::TB::Articles->all_tag_categories;
   my $filter = $req->cgi->param("cat");
   if (defined $filter and $filter =~ /\S/) {
     @cats = grep /\A\Q$filter/i, @cats;
@@ -397,7 +397,7 @@ sub req_tagcat {
     return $self->req_tagcats($req, $article, $articles, undef, \%errors);
   }
 
-  my $cat = Articles->tag_category($workcat)
+  my $cat = BSE::TB::Articles->tag_category($workcat)
     or return $self->req_tagcats($req, $article, $articles,
                                 "Cannot find or create tag category '$workcat'");
 
@@ -481,7 +481,7 @@ sub req_tagcatsave {
     return $self->req_tagcats($req, $article, $articles, undef, \%errors);
   }
 
-  my $cat = Articles->tag_category($workcat)
+  my $cat = BSE::TB::Articles->tag_category($workcat)
     or return $self->req_tagcats($req, $article, $articles,
                                 "Cannot find or create tag category '$workcat'");
 
index 699ab0d8ebb36801eb60872e61fcbaa4c3a7a9ae..4f4e928e6513a55d5b256a91f01beb9666056a08 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use BSE::Util::HTML;
 use Carp 'confess';
 
-our $VERSION = "1.007";
+our $VERSION = "1.008";
 
 use base 'DevHelp::Formatter';
 
@@ -274,7 +274,7 @@ sub gfilelink {
   my ($self, $fileid, $text, $type) = @_;
 
   unless ($self->{gfiles}) {
-    $self->{gfiles} = [ Articles->global_files ];
+    $self->{gfiles} = [ BSE::TB::Articles->global_files ];
   }
   my ($file) = grep $_->{name} eq $fileid, @{$self->{gfiles}}
     or return "** unknown file $fileid **";
@@ -468,7 +468,7 @@ sub remove_gfilelink {
   my ($self, $fileid, $text, $type) = @_;
 
   unless ($self->{gfiles}) {
-    $self->{gfiles} = [ Articles->global_files ];
+    $self->{gfiles} = [ BSE::TB::Articles->global_files ];
   }
   my ($file) = grep $_->{name} eq $fileid, @{$self->{gfiles}}
     or return "** unknown file $fileid **";
index cd70dd33931f9aa8e68a0e6b2815dad1dd057239..334f05838bd0e5c12519a5f0ebbcb5952fdebdb4 100644 (file)
@@ -1,6 +1,6 @@
 package BSE::Generate;
 use strict;
-use Articles;
+use BSE::TB::Articles;
 use Constants qw($LOCAL_FORMAT $BODY_EMBED 
                  $EMBED_MAX_DEPTH $HAVE_HTML_PARSER);
 use DevHelp::Tags;
@@ -313,7 +313,7 @@ Conditional tag, true if the current article is being embedded.
 
 =cut
 
-our $VERSION = "1.023";
+our $VERSION = "1.024";
 
 my $excerptSize = 300;
 
@@ -333,7 +333,7 @@ sub new {
     };
   $opts{varstack} = [];
   my $self = bless \%opts, $class;
-  $self->set_variable_class(articles => "Articles");
+  $self->set_variable_class(articles => "BSE::TB::Articles");
   $opts{vars}{generator} = $self;
   Scalar::Util::weaken($opts{vars}{generator});
 
@@ -441,7 +441,7 @@ sub summary {
 
   $limit ||= $article->summaryLength;
 
-  return $self->summarize("Articles", $article->body, $self->{acts}, $limit);
+  return $self->summarize("BSE::TB::Articles", $article->body, $self->{acts}, $limit);
 }
 
 # attempts to move the given position forward if it's within a HTML tag,
@@ -693,7 +693,7 @@ specified template.
 sub vembed {
   my ($self, $article, $template) = @_;
 
-  return $self->embed($article, "Articles", $template);
+  return $self->embed($article, "BSE::TB::Articles", $template);
 }
 
 sub iter_kids_of {
@@ -712,7 +712,7 @@ sub iter_kids_of {
   if (@ids == 1) {
     $state->{parentid} = $ids[0];
   }
-  $self->_do_filter($filter, map Articles->listedChildren($_), @ids);
+  $self->_do_filter($filter, map BSE::TB::Articles->listedChildren($_), @ids);
 }
 
 my $cols_re; # cache for below
@@ -727,7 +727,7 @@ my $cols_re; # cache for below
       my $expr = $1;
       my $orig_expr = $expr;
       unless ($cols_re) {
-       my $cols_expr = '(' . join('|', Article->columns) . ')';
+       my $cols_expr = '(' . join('|', BSE::TB::Article->columns) . ')';
        $cols_re = qr/\[$cols_expr\]/;
       }
       $expr =~ s/$cols_re/\$article->{$1}/g;
@@ -775,7 +775,7 @@ sub iter_all_kids_of {
   @ids = grep /^\d+$|^-1$/, @ids;
   @ids == 1 and $state->{parentid} = $ids[0];
     
-  $self->_do_filter($filter, map Articles->all_visible_kids($_), @ids);
+  $self->_do_filter($filter, map BSE::TB::Articles->all_visible_kids($_), @ids);
 }
 
 sub iter_inlines {
@@ -793,7 +793,7 @@ sub iter_inlines {
   @ids = grep /^\d+$/, @ids;
   @ids == 1 and $state->{parentid} = $ids[0];
 
-  $self->_do_filter($filter, map Articles->getByPkey($_), @ids);
+  $self->_do_filter($filter, map BSE::TB::Articles->getByPkey($_), @ids);
 }
 
 sub iter_gimages {
@@ -816,7 +816,7 @@ sub iter_gfiles {
   my ($self, $args) = @_;
 
   unless ($self->{gfiles}) {
-    my @gfiles = Articles->global_files;
+    my @gfiles = BSE::TB::Articles->global_files;
     my %gfiles = map { $_->{name} => $_ } @gfiles;
     $self->{gfiles} = \%gfiles;
   }
@@ -899,8 +899,8 @@ sub _find_image {
 
   my $article;
   if ($article_id =~ /^\d+$/) {
-    require Articles;
-    $article = Articles->getByPkey($article_id);
+    require BSE::TB::Articles;
+    $article = BSE::TB::Articles->getByPkey($article_id);
     unless ($article) {
       $$msg = "* no article $article_id found *";
       return;
@@ -908,14 +908,14 @@ sub _find_image {
   }
   elsif ($acts->{$article_id}) {
     my $id = $templater->perform($acts, $article_id, "id");
-    $article = Articles->getByPkey($id);
+    $article = BSE::TB::Articles->getByPkey($id);
     unless ($article) {
       $$msg = "* article $article_id/$id not found *";
       return;
     }
   }
   else {
-    ($article) = Articles->getBy(linkAlias => $article_id);
+    ($article) = BSE::TB::Articles->getBy(linkAlias => $article_id);
     unless ($article) {
       $$msg = "* no article $article_id found *";
       return;
@@ -1113,19 +1113,19 @@ sub _find_articles {
   my ($self, $article_id, $article, $acts, $name, $templater) = @_;
 
   if ($article_id =~ /^\d+$/) {
-    my $result = Articles->getByPkey($article_id);
+    my $result = BSE::TB::Articles->getByPkey($article_id);
     $result or print STDERR "** Unknown article id $article_id **\n";
     return $result ? $result : ();
   }
   elsif ($article_id =~ /^alias\((\w+)\)$/) {
-    my $result = Articles->getBy(linkAlias => $1);
+    my $result = BSE::TB::Articles->getBy(linkAlias => $1);
     $result or print STDERR "** Unknown article alias $article_id **\n";
     return $result ? $result : ();
   }
   elsif ($article_id =~ /^childrenof\((.*)\)$/) {
     my $id = $1;
     if ($id eq '-1') {
-      return Articles->all_visible_kids(-1);
+      return BSE::TB::Articles->all_visible_kids(-1);
     }
     else {
       my @parents = $self->_find_articles($id, $article, $acts, $name, $templater)
@@ -1136,7 +1136,7 @@ sub _find_articles {
   elsif ($acts->{$article_id}) {
     my $id = $templater->perform($acts, $article_id, 'id');
     if ($id && $id =~ /^\d+$/) {
-      return Articles->getByPkey($id);
+      return BSE::TB::Articles->getByPkey($id);
     }
   }
   print STDERR "** Unknown article identifier $article_id **\n";
@@ -1427,7 +1427,7 @@ sub excerpt {
     # we remove any formatting tags here, otherwise we get wierd table
     # rubbish or other formatting in the excerpt.
     my @files = $article->files;
-    $self->remove_block('Articles', [], \$body, \@files);
+    $self->remove_block('BSE::TB::Articles', [], \$body, \@files);
     1 while $body =~ s/[bi]\[([^\]\[]+)\]/$1/g;
   }
     
@@ -1558,7 +1558,7 @@ sub get_gfile {
   my ($self, $name) = @_;
 
   unless ($self->{gfiles}) {
-    my @gfiles = Articles->global_files;
+    my @gfiles = BSE::TB::Articles->global_files;
     my %gfiles = map { $_->{name} => $_ } @gfiles;
     $self->{gfiles} = \%gfiles;
   }
index 32ed4b53861834446a3e6cd71f4bd8b93e5acab4..8296b737282fd12e6237da4a7fe0bd37454f3c40 100644 (file)
@@ -16,7 +16,7 @@ use Carp 'confess';
 use BSE::Util::Iterate;
 use BSE::CfgInfo qw(cfg_dist_image_uri cfg_image_uri);
 
-our $VERSION = "1.014";
+our $VERSION = "1.015";
 
 =head1 NAME
 
@@ -436,7 +436,7 @@ sub baseActs {
   # used to generate a navigation list for the article
   # generate a list of ancester articles/sections
   # Jason calls these breadcrumbs
-  my @ancestors = UNIVERSAL::isa($article, 'Article') ?
+  my @ancestors = UNIVERSAL::isa($article, 'BSE::TB::Article') ?
     reverse($article->ancestors) : ();
   my @crumbs = grep $_->{listed} == 1 || $_->{level} == 1, @ancestors;
   my $current_crumb;
@@ -445,7 +445,7 @@ sub baseActs {
   my $section = @crumbs ? $crumbs[0] : $article;
 
   my @images;
-  if (UNIVERSAL::isa($article, 'Article')) {
+  if (UNIVERSAL::isa($article, 'BSE::TB::Article')) {
     @images = $article->images;
   }
   my @unnamed_images = grep $_->{name} eq '', @images;
@@ -463,13 +463,13 @@ sub baseActs {
   my $abs_urls = $self->abs_urls($article);
 
   my $dynamic = $self->{force_dynamic}
-    || (UNIVERSAL::isa($top, 'Article') ? $top->is_dynamic : 0);
+    || (UNIVERSAL::isa($top, 'BSE::TB::Article') ? $top->is_dynamic : 0);
   $self->set_variable(dynamic => $dynamic);
 
   my @stepkids;
   my @allkids;
   my @stepparents;
-  if (UNIVERSAL::isa($article, 'Article')) {
+  if (UNIVERSAL::isa($article, 'BSE::TB::Article')) {
     @stepkids    = $article->visible_stepkids;
     @allkids     = $article->all_visible_kids;
     @stepparents  = $article->visible_step_parents;
@@ -753,7 +753,7 @@ sub tag_ifDynamic {
   # this is to support pregenerated pages being handled as dynamic pages
   $self->{force_dynamic} and return 1;
 
-  UNIVERSAL::isa($top, 'Article') ? $top->is_dynamic : 0;
+  UNIVERSAL::isa($top, 'BSE::TB::Article') ? $top->is_dynamic : 0;
 }
 
 sub tag_ifAccessControlled {
@@ -762,7 +762,7 @@ sub tag_ifAccessControlled {
   if ($arg) {
     if ($acts->{$arg}) {
       my $id = $templater->perform($acts, $arg, 'id');
-      $article = Articles->getByPkey($id);
+      $article = BSE::TB::Articles->getByPkey($id);
       unless ($article) {
        print STDERR "** Unknown article $id from $arg in ifAccessControlled\n";
        return 0;
@@ -774,7 +774,7 @@ sub tag_ifAccessControlled {
     }
   }
 
-  return UNIVERSAL::isa($article, 'Article') ? 
+  return UNIVERSAL::isa($article, 'BSE::TB::Article') ? 
     $article->is_access_controlled : 0;
 }
 
index c9404a59f0a15558148680ba5ea7ae99647dcbc8..cf43b2689e60ae47790127c3afd2b8dba1d24172 100644 (file)
@@ -1,12 +1,12 @@
 package BSE::ImageClean;
 use strict;
 use BSE::TB::Images;
-use Articles;
+use BSE::TB::Articles;
 use BSE::TB::Files;
 use BSE::CfgInfo qw(cfg_image_dir);
 use File::Spec::Functions qw(catfile);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 sub scan {
   my ($class, $callback) = @_;
@@ -22,7 +22,7 @@ sub scan {
 
         unless (exists $articleIds{$image->{articleId}}) {
           $articleIds{$image->{articleId}} = 
-            defined(Articles->getByPkey($image->{articleId}));
+            defined(BSE::TB::Articles->getByPkey($image->{articleId}));
         }
         unless ($articleIds{$image->{articleId}}) {
           $orphan_files{$image->image} = 1;
@@ -43,7 +43,7 @@ sub scan {
        }
       );
   $callback->({type => "substage", stage => "index", substage => "thumbnails"});
-  Articles->iterateBy
+  BSE::TB::Articles->iterateBy
     (
      sub {
        my ($article) = @_;
index cf16d2ed18019cac9cde3871108c4d74bbd36d49..e3fd37ff7ca2f94ec3b263017268ebaac8326763 100644 (file)
@@ -2,11 +2,11 @@ package BSE::Importer::Target::Article;
 use strict;
 use base 'BSE::Importer::Target::Base';
 use BSE::API qw(bse_make_article bse_add_image bse_add_step_parent);
-use Articles;
+use BSE::TB::Articles;
 use Products;
 use OtherParents;
 
-our $VERSION = "1.008";
+our $VERSION = "1.009";
 
 =head1 NAME
 
@@ -280,10 +280,10 @@ sub row {
       or next;
     my $step;
     if ($step_id =~ /^\d+$/) {
-      $step = Articles->getByPkey($step_id);
+      $step = BSE::TB::Articles->getByPkey($step_id);
     }
     else {
-      $step = Articles->getBy(linkAlias => $step_id);
+      $step = BSE::TB::Articles->getBy(linkAlias => $step_id);
     }
     $step
       or die "Cannot find stepparent with id $step_id\n";
@@ -419,7 +419,7 @@ Utility method to find the children of a given article.
 sub children_of {
   my ($self, $parent) = @_;
 
-  Articles->children($parent);
+  BSE::TB::Articles->children($parent);
 }
 
 =item make_parent()
@@ -448,7 +448,7 @@ sub find_leaf {
   $leaf_id =~ s/\A\s+//;
   $leaf_id =~ s/\s+\z//;
 
-  my ($leaf) = Articles->getBy($self->{code_field}, $leaf_id)
+  my ($leaf) = BSE::TB::Articles->getBy($self->{code_field}, $leaf_id)
     or return;
 
   $importer->event(find_leaf => { id => $leaf_id, leaf => $leaf });
@@ -603,7 +603,7 @@ sub validate_make_leaf {
   my ($self, $importer, $entry) = @_;
 
   if (defined $entry->{linkAlias} && $entry->{linkAlias} ne '') {
-    my $other = Articles->getBy(linkAlias => $entry->{linkAlias});
+    my $other = BSE::TB::Articles->getBy(linkAlias => $entry->{linkAlias});
     $other
       and die "Duplicate linkAlias value with article ", $other->id, "\n";
   }
index df6b990b13731abf2095b08b40335df50769b46c..e83037fab03a2c7d66d61ec5cbc27c2ae4831342 100644 (file)
@@ -2,13 +2,13 @@ package BSE::Importer::Target::Product;
 use strict;
 use base 'BSE::Importer::Target::Article';
 use BSE::API qw(bse_make_product bse_make_catalog bse_add_image);
-use Articles;
+use BSE::TB::Articles;
 use Products;
 use BSE::TB::ProductOptions;
 use BSE::TB::ProductOptionValues;
 use BSE::TB::PriceTiers;
 
-our $VERSION = "1.006";
+our $VERSION = "1.007";
 
 =head1 NAME
 
@@ -183,7 +183,7 @@ sub children_of {
   my ($self, $parent) = @_;
 
   return grep $_->{generator} eq 'BSE::Generate::Catalog',
-    Articles->children($parent);
+    BSE::TB::Articles->children($parent);
 }
 
 =item make_parent()
index b02f10d3470b9bac4b088e200f7dfa0ec35f022e..e27b0ab5df7bb13b6b361213f186d27c01e153d4 100644 (file)
@@ -2,9 +2,9 @@ package BSE::Index;
 use strict;
 use Time::HiRes qw(time);
 use Constants qw(@SEARCH_EXCLUDE @SEARCH_INCLUDE);
-use Articles;
+use BSE::TB::Articles;
 
-our $VERSION = "1.004";
+our $VERSION = "1.005";
 
 my %default_scores =
   (
@@ -86,7 +86,7 @@ sub make_index {
   @dont_search{@SEARCH_EXCLUDE} = @SEARCH_EXCLUDE;
   @do_search{@SEARCH_INCLUDE} = @SEARCH_INCLUDE;
   $self->vnote("s::Loading article ids");
-  my @ids = Articles->allids;
+  my @ids = BSE::TB::Articles->allids;
   my $count = @ids;
   $self->vnote("c:$count:$count articles to index");
   my $cfg = BSE::Cfg->single;
@@ -96,7 +96,7 @@ sub make_index {
     my @files;
     my $got_files;
     # find the section
-    my $article = Articles->getByPkey($id);
+    my $article = BSE::TB::Articles->getByPkey($id);
     next unless $article;
     next unless $article->should_index;
     my $section = $article->section;
@@ -138,7 +138,7 @@ sub make_index {
       }
       #next if $text =~ m!^\<html\>!i; # I don't know how to do this (yet)
       if ($field eq 'body') {
-       $gen->remove_block("Articles", [], \$text);
+       $gen->remove_block("BSE::TB::Articles", [], \$text);
        $text =~ s/[abi]\[([^\]]+)\]/$1/g;
       }
 
index 3647fdbbdc908839abb7a3fd698e06c673ecf758..8367841a40ea80709766958edbed9bef5c111c91 100644 (file)
@@ -10,7 +10,7 @@ use overload
   "&{}" => sub { my $self = $_[0]; return sub { $self->_old_msg(@_) } },
   "bool" => sub { 1 };
 
-our $VERSION = "1.007";
+our $VERSION = "1.008";
 
 my $single;
 
@@ -91,7 +91,7 @@ sub html {
       my $gen = Generate->new(cfg => BSE::Cfg->single);
       my $templater = BSE::Template->templater(BSE::Cfg->single);
       return $gen->format_body(acts => {},
-                              articles => "Articles",
+                              articles => "BSE::TB::Articles",
                               text => $msg->{message},
                               templater => $templater);
     }
index a18331b36332889d884fe557b3557cefc03a55a7..12fb21150f78c567ba78e4f6865b2bb6cbd3413c 100644 (file)
@@ -1,7 +1,7 @@
 package BSE::Permissions;
 use strict;
 
-our $VERSION = "1.002";
+our $VERSION = "1.003";
 
 # these are the permissions that are checked beyond just whether the permissions DB allows them
 my @checks =
@@ -202,8 +202,8 @@ sub _get_article {
     return $self->{sitearticle};
   }
   else {
-    require Articles;
-    $self->{artcache}{$id} = Articles->getByPkey($id);
+    require BSE::TB::Articles;
+    $self->{artcache}{$id} = BSE::TB::Articles->getByPkey($id);
   }
 }
 
@@ -395,7 +395,7 @@ sub check_edit_delete_article {
   my ($self, $user, $article, $action, $rmsg) = @_;
 
   # can't delete an article that has children
-  if (Articles->children($article->{id})) {
+  if (BSE::TB::Articles->children($article->{id})) {
     $$rmsg = "This article has children.  You must delete the children first (or change their parents)";
     return;
   }
index 514d6a5166b80cd0eb5203c6bed6e2cd5c5c5983..d4c39f9e17c5634606fbd35b88ec38108f5b9e48 100644 (file)
@@ -2,11 +2,11 @@ package BSE::ProductImportXLS;
 use strict;
 use Spreadsheet::ParseExcel;
 use BSE::API qw(bse_make_product bse_make_catalog bse_add_image);
-use Articles;
+use BSE::TB::Articles;
 use Products;
 use Config;
 
-our $VERSION = "1.001";
+our $VERSION = "1.002";
 
 sub new {
   my ($class, $cfg, $profile, %opts) = @_;
@@ -243,7 +243,7 @@ sub _find_cat {
     or return $parent;
   unless ($cache->{$parent}) {
     my @kids = grep $_->{generator} eq 'BSE::Generate::Catalog', 
-      Articles->children($parent);
+      BSE::TB::Articles->children($parent);
     $cache->{$parent} = \@kids;
   }
 
index b8563b93ab4b025985046eef37b0c98a0a729297..ff414d360667965d238458be279fb3cc99fa1de3 100644 (file)
@@ -11,7 +11,7 @@ use BSE::WebUtil qw(refresh_to_admin);
 use BSE::Util::HTML;
 use BSE::DummyArticle;
 
-our $VERSION = "1.014";
+our $VERSION = "1.015";
 
 # returns non-zero if the Regenerate button should work
 sub generate_button {
@@ -102,8 +102,8 @@ sub _cfg_presets {
 
   my $section = "$type settings";
 
-  require Articles;
-  for my $field (Article->columns) {
+  require BSE::TB::Articles;
+  for my $field (BSE::TB::Article->columns) {
     if ($cfg->entry($section, $field)) {
       $article->{$field} = $cfg->entryVar($section, $field);
     }
@@ -115,8 +115,8 @@ sub _search_presets {
 
   # build a dummy article
   use Constants qw($SEARCH_TITLE $SEARCH_TITLE_IMAGE $CGI_URI);
-  require Articles;
-  my %article = map { $_, '' } Article->columns;
+  require BSE::TB::Articles;
+  my %article = map { $_, '' } BSE::TB::Article->columns;
   @article{qw(id parentid title titleImage displayOrder link level listed force_dynamic)} =
     (-4, -1, $SEARCH_TITLE, $SEARCH_TITLE_IMAGE, 0, $CGI_URI."/search.pl", 0, 1, 1);
 
@@ -130,8 +130,8 @@ sub _search_presets {
 sub _shop_presets {
   my ($cfg) = @_;
 
-  require Articles;
-  my $shop_base = Articles->getByPkey($SHOPID);
+  require BSE::TB::Articles;
+  my $shop_base = BSE::TB::Articles->getByPkey($SHOPID);
   my $shop = { map { $_ => $shop_base->{$_} } $shop_base->columns };
   $shop->{link} =~ /^\w+:/
     or $shop->{link} = $cfg->entryErr('site', 'url') . $shop->{link};
@@ -145,8 +145,8 @@ sub _shop_presets {
 sub _extras_presets {
   my ($cfg, $presets) = @_;
 
-  require Articles;
-  my %article = map { $_, '' } Article->columns;
+  require BSE::TB::Articles;
+  my %article = map { $_, '' } BSE::TB::Article->columns;
   $article{displayOrder} = 1;
   $article{id} = -5;
   $article{parentid} = -1;
@@ -363,7 +363,7 @@ sub generate_base {
 
   my $cfg = delete $opts{cfg} || BSE::Cfg->single;
 
-  my $articles = delete $opts{articles} || "Articles";
+  my $articles = delete $opts{articles} || "BSE::TB::Articles";
   my $extras = delete $opts{extras} || [ pregenerate_list($cfg) ];
 
   my $progress = delete $opts{progress} || sub {};
index 00e55c734da126f67d5c2cffb5eb92909f5912ea..6b638114ade4d67fdd15f74d4e17b8dadf5dc20a 100644 (file)
@@ -5,7 +5,7 @@ use BSE::Cfg;
 use BSE::Util::HTML;
 use Carp qw(cluck confess);
 
-our $VERSION = "1.028";
+our $VERSION = "1.029";
 
 =head1 NAME
 
@@ -366,8 +366,8 @@ sub user_can {
   $self->{perms} ||= BSE::Permissions->new($self->cfg);
   if ($self->cfg->entry('basic', 'access_control', 0)) {
     unless (ref $object) {
-      require Articles;
-      my $art = $object == -1 ? $site_article : Articles->getByPkey($object);
+      require BSE::TB::Articles;
+      my $art = $object == -1 ? $site_article : BSE::TB::Articles->getByPkey($object);
       if ($art) {
        $object = $art;
       }
index 99c23fca3b7e1839ea75afc1a0aa4a81f4595736..e7b7bc11de311b8965f4b4e589511c023daa385a 100644 (file)
@@ -5,7 +5,7 @@ use Squirrel::Row;
 use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row/;
 
-our $VERSION = "1.006";
+our $VERSION = "1.007";
 
 sub columns {
   return qw/id name title description frequency keyword archive 
@@ -16,13 +16,13 @@ sub columns {
 sub _build_article {
   my ($sub, $article, $opts) = @_;
 
-  my @cols = Article->columns;
+  my @cols = BSE::TB::Article->columns;
   shift @cols;
   @$article{@cols} = ('') x @cols;
   my $parent_id = $opts->{parentId} || $sub->{parentId} || -1;
   my $parent;
   if ($parent_id > 0) {
-    $parent = Articles->getByPkey($parent_id);
+    $parent = BSE::TB::Articles->getByPkey($parent_id);
     unless ($parent) {
       $parent_id = -1;
     }
@@ -136,8 +136,8 @@ sub _doclink {
     $dispid = "$id ($work)";
     $id = $work;
   }
-  require Articles;
-  my $art = Articles->getByPkey($id);
+  require BSE::TB::Articles;
+  my $art = BSE::TB::Articles->getByPkey($id);
   unless ($art) {
     return ">> Cannot find article id $dispid <<";
   }
@@ -217,7 +217,7 @@ sub _format_body {
   while ($body =~ s#(?:pop)?(doclink|link)\[([^\]\[]+)\]#_any_link($cfg, \@urls, $1, $2, \$url_index)#ie) {
   }
 
-  $gen->remove_block('Articles', [], \$body);
+  $gen->remove_block('BSE::TB::Articles', [], \$body);
   while (1) {
     $body =~ s/[bi]\[([^\[\]]+)\]/$1/g
        and next;
@@ -296,7 +296,7 @@ sub html_format {
   $gen->set_user($user);
   $gen->set_sub($sub);
 
-  return $gen->generate(\%article, 'Articles');
+  return $gen->generate(\%article, 'BSE::TB::Articles');
 }
 
 sub recipients {
@@ -351,7 +351,7 @@ sub _send {
       #print STDERR "Making HTML\n";
       $gen->set_user($user);
       my %acts;
-      %acts = $gen->baseActs("Articles", \%acts, $article);
+      %acts = $gen->baseActs("BSE::TB::Articles", \%acts, $article);
       $html = BSE::Template->get_page($article->template, $cfg, \%acts,
                                      undef, undef, $gen->variables);
       if ($cfg->utf8) {
@@ -418,13 +418,13 @@ sub send {
 
   if (exists $opts->{archive} ? $opts->{archive} : $sub->{archive}) {
     $callback->('general', undef, "Archiving article");
-    require 'Articles.pm';
+    require BSE::TB::Articles;
     $article{template} = $opts->{article_template} || $sub->{article_template};
     $article{generator} = 'BSE::Generate::Article';
     $article{parentid} = $opts->{parentId} || $sub->{parentId};
-    my @cols = Article->columns;
+    my @cols = BSE::TB::Article->columns;
     shift @cols;
-    my $article = Articles->add(@article{@cols});
+    my $article = BSE::TB::Articles->add(@article{@cols});
     use Constants qw(:edit $CGI_URI $ARTICLE_URI $LINK_TITLES);
     my $link = "$ARTICLE_URI/$article->{id}.html";
     if ($LINK_TITLES) {
@@ -437,7 +437,7 @@ sub send {
     require BSE::Regen;
     
     $callback->('general', undef, "Generating article");
-    BSE::Regen::generate_article('Articles', $article, $cfg);
+    BSE::Regen::generate_article('BSE::TB::Articles', $article, $cfg);
   }
 
   use BSE::Util::SQL qw/now_datetime/;
diff --git a/site/cgi-bin/modules/BSE/TB/Article.pm b/site/cgi-bin/modules/BSE/TB/Article.pm
new file mode 100644 (file)
index 0000000..8740819
--- /dev/null
@@ -0,0 +1,757 @@
+package BSE::TB::Article;
+use strict;
+# represents an article from the database
+use Squirrel::Row;
+use BSE::TB::SiteCommon;
+use BSE::TB::TagOwner;
+use vars qw/@ISA/;
+@ISA = qw/Squirrel::Row BSE::TB::SiteCommon BSE::TB::TagOwner/;
+use Carp 'confess';
+
+our $VERSION = "1.024";
+
+=head1 NAME
+
+Article - article objects for BSE.
+
+=head1 SYNOPSIS
+
+  use BSE::API qw(bse_make_article);
+
+  my $article = bse_make_article(...)
+
+  my $article = BSE::TB::Articles->getByPkey($id);
+
+=head1 DESCRIPTION
+
+Implements the base article object for BSE.
+
+=head1 USEFUL METHODS
+
+=over
+
+=cut
+
+sub columns {
+  return qw/id parentid displayOrder title titleImage body
+    thumbImage thumbWidth thumbHeight imagePos
+    release expire keyword template link admin threshold
+    summaryLength generator level listed lastModified flags
+    customDate1 customDate2 customStr1 customStr2
+    customInt1 customInt2 customInt3 customInt4 
+    lastModifiedBy created createdBy author pageTitle
+    force_dynamic cached_dynamic inherit_siteuser_rights
+    metaDescription metaKeywords summary menu titleAlias linkAlias
+    category/;
+}
+
+sub db_columns {
+  my ($self) = @_;
+
+  return map { $_ eq "summary" ? "summaryx" : $_ } $self->columns;
+}
+
+=item id
+
+=item parentid
+
+=item displayOrder
+
+=item title
+
+=item titleImage
+
+=item body
+
+=item thumbImage
+
+=item thumbWidth
+
+=item thumbHeight
+
+=item imagePos
+
+=item release
+
+=item expire
+
+=item keyword
+
+=item template
+
+=item threshold
+
+=item summaryLength
+
+=item generator
+
+=item level
+
+=item listed
+
+=item lastModified
+
+=item flags
+
+=item customDate1
+
+=item customDate2
+
+=item customStr1
+
+=item customStr2
+
+=item customInt1
+
+=item customInt2
+
+=item customInt3
+
+=item customInt4
+
+=item lastModifiedBy
+
+=item created
+
+=item createdBy
+
+=item author
+
+=item pageTitle
+
+=item force_dynamic
+
+=item cached_dynamic
+
+=item inherit_siteuser_rights
+
+=item metaDescription
+
+=item metaKeywords
+
+=item summary
+
+=item menu
+
+=item titleAlias
+
+=item linkAlias
+
+=item category
+
+Simple column accessors.
+
+=cut
+
+sub table {
+  'article';
+}
+
+sub numeric {
+  qw(id listed parentid threshold summaryLength level 
+     customInt1 customInt2 customInt3 customInt4 menu);
+}
+
+=item section
+
+Return the article's section.
+
+=cut
+
+sub section {
+  my ($self) = @_;
+
+  my $section = $self;
+  while ($section->{parentid} > 0
+        and my $parent = $section->parent) {
+    $section = $parent;
+  }
+
+  return $section;
+}
+
+=item parent
+
+Return the article's parent.
+
+=cut
+
+sub parent {
+  my ($self) = @_;
+
+  my $parentid = $self->parentid;
+
+  $parentid == -1
+    and return;
+  $self->{_parent} && $self->{_parent}->id == $parentid
+    and return $self->{_parent};
+  return ($self->{_parent} = BSE::TB::Articles->getByPkey($self->{parentid}));
+}
+
+sub update_dynamic {
+  my ($self, $cfg) = @_;
+
+  $cfg && $cfg->can('entry')
+    or confess 'update_dynamic called without $cfg';
+
+  # conditional in case something strange is in the config file
+  my $dynamic = $cfg->entry('basic', 'all_dynamic', 0) ? 1 : 0;
+
+  if (!$dynamic && $self->generator =~ /\bCatalog\b/) {
+    require Products;
+    my @tiers = Products->pricing_tiers;
+    @tiers and $dynamic = 1;
+  }
+
+  $dynamic or $dynamic = $self->{force_dynamic};
+
+  $dynamic or $dynamic = $self->is_access_controlled;
+
+  $dynamic or $dynamic = $self->force_dynamic_inherited;
+
+  $self->{cached_dynamic} = $dynamic;
+}
+
+=item is_dynamic
+
+Return true if the article is rendered dynamically.
+
+=cut
+
+sub is_dynamic {
+  $_[0]{cached_dynamic};
+}
+
+=item is_accessible_to($group)
+
+Return true if the article is accessible to the supplied siteuser
+group or group id.
+
+=cut
+
+sub is_accessible_to {
+  my ($self, $group) = @_;
+
+  my $groupid = ref $group ? $group->{id} : $group;
+
+  my @rows = BSE::DB->query(articleAccessibleToGroup => $self->{id}, $groupid);
+
+  scalar @rows;
+}
+
+sub group_ids {
+  my ($self) = @_;
+
+  map $_->{id}, BSE::DB->query(siteuserGroupsForArticle => $self->{id});
+}
+
+sub add_group_id {
+  my ($self, $id) = @_;
+
+  eval {
+    BSE::DB->single->run(articleAddSiteUserGroup => $self->{id}, $id);
+  };
+}
+
+sub remove_group_id {
+  my ($self, $id) = @_;
+
+  BSE::DB->single->run(articleDeleteSiteUserGroup => $self->{id}, $id);
+}
+
+=item is_access_controlled
+
+Return true if the article is access controlled.
+
+=cut
+
+sub is_access_controlled {
+  my ($self) = @_;
+
+  my @group_ids = $self->group_ids;
+  return 1 if @group_ids;
+
+  return 0
+    unless $self->{inherit_siteuser_rights};
+
+  my $parent = $self->parent
+    or return 0;
+
+  return $parent->is_access_controlled;
+}
+
+sub force_dynamic_inherited {
+  my ($self) = @_;
+
+  my $parent = $self->parent
+    or return 0;
+
+  $parent->{force_dynamic} && $parent->{flags} =~ /F/
+    and return 1;
+  
+  return $parent->force_dynamic_inherited;
+}
+
+sub link_to_filename {
+  my ($self, $cfg, $link) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  defined $link or $link = $self->{link};
+
+  length $link or return;
+
+  my $filename = $link;
+
+  # remove any appended title,
+  $filename =~ s!(.)/\w+$!$1!;
+  $filename =~ s{^\w+://[\w.-]+(?::\d+)?}{};
+  $filename = $cfg->content_base_path() . $filename;
+  if ($filename =~ m(/$)) {
+    $filename .= $cfg->entry("basic", "index_file", "index.html");
+  }
+  $filename =~ s!//+!/!;
+  
+  return $filename;
+}
+
+sub cached_filename {
+  my ($self, $cfg) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  my $dynamic_path = $cfg->entryVar('paths', 'dynamic_cache');
+  return $dynamic_path . "/" . $self->{id} . ".html";
+}
+
+sub html_filename {
+  my ($self, $cfg) = @_;
+
+  $cfg ||= BSE::Cfg->single;
+
+  return $self->is_dynamic
+    ? $self->cached_filename($cfg)
+      : $self->link_to_filename($cfg);
+}
+
+sub remove_html {
+  my ($self, $cfg) = @_;
+
+  my $filename = $self->html_filename($cfg)
+    or return 1;
+
+  unlink $filename
+    or return;
+
+  return 1;
+}
+
+sub remove {
+  my ($self, $cfg) = @_;
+
+  $cfg or confess "No \$cfg supplied to ", ref $self, "->remove";
+
+  $self->remove_tags;
+
+  $self->remove_images($cfg);
+
+  $self->remove_files($cfg);
+  
+  # remove any step(child|parent) links
+  require OtherParents;
+  my @steprels = OtherParents->anylinks($self->{id});
+  for my $link (@steprels) {
+    $link->remove();
+  }
+
+  # remove any site user access controls
+  BSE::DB->single->run(bseRemoveArticleSiteUserGroups => $self->id);
+
+  # remove any admin user/group access controls
+  BSE::DB->single->run(bseRemoveArticleAdminAccess => $self->id);
+
+  # remove the static page
+  $self->remove_html($cfg);
+
+  $self->SUPER::remove();
+}
+
+=item all_parents
+
+Return a list of all parents.
+
+=cut
+
+sub all_parents {
+  my ($self) = @_;
+
+  my @result = $self->step_parents;
+  if ($self->{parentid} > 0 && !grep $_->{id} eq $self->{parentid}, @result) {
+    push @result, $self->parent;
+  }
+
+  return @result;
+}
+
+sub is_step_ancestor {
+  my ($self, $other, $max) = @_;
+
+  my $other_id = ref $other ? $other->{id} : $other;
+  my %seen;
+
+  $max ||= 10;
+
+  # early exit if possible
+  return 1 if $self->{parentid} == $other_id;
+
+  my @all_parents = $self->all_parents;
+  return 1 if grep $_->{id} == $other_id, @all_parents;
+  my @work = map [ 0, $_], grep !$seen{$_}++, @all_parents;
+  while (@work) {
+    my $entry = shift @work;
+    my ($level, $workart) = @$entry;
+
+    $level++;
+    if ($level < $max) {
+      @all_parents = $workart->all_parents;
+      return 1 if grep $_->{id} == $other_id, @all_parents;
+      push @work, map [ $level, $_ ], grep !$seen{$_}++, @all_parents;
+    }
+  }
+
+  return 0;
+}
+
+sub possible_stepparents {
+  my $self = shift;
+
+  return BSE::DB->query(articlePossibleStepparents => $self->{id}, $self->{id});
+}
+
+sub possible_stepchildren {
+  my $self = shift;
+
+  return BSE::DB->query(articlePossibleStepchildren => $self->{id}, $self->{id});
+}
+
+sub link {
+  my ($self, $cfg) = @_;
+
+  if ($self->flags =~ /P/) {
+    my $parent = $self->parent;
+    $parent and return $parent->link($cfg);
+  }
+
+  $self->is_linked
+    or return "";
+
+  $cfg ||= BSE::Cfg->single;
+
+  unless ($self->{linkAlias} && $cfg->entry('basic', 'use_alias', 1)) {
+    return $self->{link};
+  }
+
+  my $prefix = $cfg->entry('basic', 'alias_prefix', '');
+  my $link;
+  if ($cfg->entry('basic', 'alias_recursive')) {
+    my @steps = $self->{linkAlias};
+    my $article = $self;
+    while ($article = $article->parent) {
+      if ($article->{linkAlias}) {
+       unshift @steps, $article->{linkAlias};
+      }
+    }
+    $link = join('/', $prefix, @steps);
+  }
+  else {
+    $link = $prefix . '/' . $self->{linkAlias};
+  }
+  if ($cfg->entry('basic', 'alias_suffix', 1)) {
+    my $title = $self->{title};
+    $title =~ tr/a-zA-Z0-9/-/cs;
+    $link .= '/' . $title;
+  }
+  return $link;
+}
+
+=item admin
+
+Return the admin link for the article.
+
+=cut
+
+sub admin {
+  my ($self) = @_;
+
+  return BSE::Cfg->single->admin_url("admin", { id => $self->id });
+}
+
+=item is_linked
+
+Return true if the article can be linked to.
+
+=cut
+
+sub is_linked {
+  my ($self) = @_;
+
+  return $self->flags !~ /D/;
+}
+
+sub tag_owner_type {
+  return "BA";
+}
+
+# the time used for expiry/release comparisons
+sub _expire_release_datetime {
+  my ($year, $month, $day) = (localtime)[5,4,3];
+  my $today = sprintf("%04d-%02d-%02d 00:00:00ZZZ", $year+1900, $month+1, $day);
+}
+
+=item is_expired
+
+Returns true if the article expiry date has passed.
+
+=cut
+
+sub is_expired {
+  my $self = shift;
+
+  return $self->expire lt _expire_release_datetime();
+}
+
+=item is_released
+
+Returns true if the article release date has passed (ie. the article
+has been released.)
+
+=cut
+
+sub is_released {
+  my $self = shift;
+
+  return $self->release le _expire_release_datetime();
+}
+
+=item listed_in_menu
+
+Return true if the article should be listed in menus.
+
+=cut
+
+sub listed_in_menu {
+  my $self = shift;
+
+  return $self->listed == 1;
+}
+
+=item ancestors
+
+Returns a list of ancestors of self.
+
+=cut
+
+sub ancestors {
+  my ($self) = @_;
+
+  unless ($self->{_ancestors}) {
+    my @ancestors;
+    my $work = $self;
+    while ($work->parentid != -1) {
+      $work = $work->parent;
+      push @ancestors, $work;
+    }
+
+    $self->{_ancestors} = \@ancestors;
+  }
+
+  return @{$self->{_ancestors}};
+}
+
+=item is_descendant_of($ancestor)
+
+Return true if self is a decsendant of the supplied article or article
+id.
+
+=cut
+
+sub is_descendant_of {
+  my ($self, $ancestor) = @_;
+
+  my $ancestor_id = ref $ancestor ? $ancestor->id : $ancestor;
+
+  for my $anc ($self->ancestors) {
+    return 1 if $anc->id == $ancestor_id;
+  }
+
+  return 0;
+}
+
+=item visible_ancestors
+
+Returns all visible ancestors.
+
+Lists the top-level ancestor C<last>.
+
+This list does not include the article itself.
+
+=cut
+
+sub visible_ancestors {
+  my ($self) = @_;
+
+  return grep $_->listed, $self->ancestors;
+}
+
+=item menu_ancestors
+
+Returns visible ancestprs that are visible for menus (ie. listed = 1).
+
+Lists the top-level ancestor C<last>.
+
+This list does not include the article itself.
+
+=cut
+
+sub menu_ancestors {
+  my ($self) = @_;
+
+  return grep $_->listed, $self->ancestors;
+}
+
+=item should_generate
+
+Return true if this article should have pages generated, either for
+static content or for dynamic.
+
+=cut
+
+sub should_generate {
+  my ($self) = @_;
+
+  return $self->is_linked && $self->listed && $self->is_released && !$self->is_expired;
+}
+
+=item should_index
+
+Returns true if the article should be indexed.
+
+=cut
+
+sub should_index {
+  my ($self) = @_;
+
+  return ($self->listed || $self->is_index_even_if_hidden)
+    && $self->is_linked
+      && !$self->is_dont_index
+       && !$self->is_dont_index_or_kids
+}
+
+=item is_index_even_if_hidden
+
+Return true if the article's index even if hidden flag is set.
+
+=cut
+
+sub is_index_even_if_hidden {
+  my ($self) = @_;
+
+  return $self->flags =~ /I/;
+}
+
+=item is_dont_index
+
+Return true if the "don't index" flag (C<N>) is set.
+
+=cut
+
+sub is_dont_index {
+  return $_[0]->flags =~ /N/;
+}
+
+=item is_dont_index_or_kids
+
+Return true if the article or any of it's parents have the "don't
+index me or my children" flag (C<C>) set.
+
+=cut
+
+sub is_dont_index_or_kids {
+  my ($self) = @_;
+
+  $self->flags =~ /C/ and return 1;
+
+  my $parent = $self->parent
+    or return 0;
+
+  return $parent->is_dont_index_or_kids;
+}
+
+sub restricted_method {
+  my ($self, $name) = @_;
+
+  return $self->SUPER::restricted_method($name)
+    || $name =~ /^(?:update_|remove_|add_|mark_modified)/;
+}
+
+sub tableClass {
+  return "BSE::TB::Articles";
+}
+
+=item mark_modified
+
+Call by admin code to do the things we do when an article is modified.
+
+Parameters:
+
+=over
+
+=item *
+
+actor - an audit log compatible actor.
+
+=back
+
+=cut
+
+sub mark_modified {
+  my ($self, %opts) = @_;
+
+  require BSE::Util::SQL;
+  $self->set_lastModified(BSE::Util::SQL::now_sqldatetime());
+  $self->set_lastModifiedBy(ref $opts{actor} ? $opts{actor}->logon : "");
+}
+
+=item uncache
+
+Free any cached data.
+
+=cut
+
+sub uncache {
+  my ($self) = @_;
+
+  delete @{$self}{qw/_parent/};
+
+  $self->SUPER::uncache();
+}
+
+1;
+
+__END__
+
+=back
+
+=head1 BASE CLASSES
+
+L<BSE::TB::SiteCommon>
+
+L<BSE::TB::TagOwner>
+
+L<Squirrel::Row>
+
+=head1 AUTHOR
+
+Tony Cook <tony@develop-help.com>
+
+=cut
index cad5f9bb516f011cb89980a5f41d15b306ad83d7..8b760184e240c745245499671a52ce16c0e5bb8a 100644 (file)
@@ -6,7 +6,7 @@ use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row/;
 use Carp 'confess';
 
-our $VERSION = "1.010";
+our $VERSION = "1.011";
 
 sub columns {
   return qw/id articleId displayName filename sizeInBytes description 
@@ -76,9 +76,9 @@ sub remove {
 
 sub article {
   my $self = shift;
-  require Articles;
+  require BSE::TB::Articles;
 
-  return Articles->getByPkey($self->{articleId});
+  return BSE::TB::Articles->getByPkey($self->{articleId});
 }
 
 sub url {
diff --git a/site/cgi-bin/modules/BSE/TB/Articles.pm b/site/cgi-bin/modules/BSE/TB/Articles.pm
new file mode 100644 (file)
index 0000000..da17411
--- /dev/null
@@ -0,0 +1,296 @@
+package BSE::TB::Articles;
+use strict;
+use Squirrel::Table;
+use vars qw(@ISA $VERSION);
+require BSE::TB::TagOwners;
+@ISA = qw(Squirrel::Table BSE::TB::TagOwners);
+use BSE::TB::Article;
+
+our $VERSION = "1.006";
+
+=head1 NAME
+
+Articles - BSE's article collection
+
+=head1 SYNOPSIS
+
+  use BSE::TB::Articles;
+
+  my $article = BSE::TB::Articles->make(...);
+  my $article = BSE::TB::Articles->getByPkey($id)
+  # etc
+
+=head1 DESCRIPTION
+
+The collective class for BSE articles.
+
+=head1 USEFUL METHODS
+
+=over
+
+=cut
+
+sub rowClass {
+  return 'BSE::TB::Article';
+}
+
+=item sections
+
+Returns a list of articles which are sections
+
+=cut
+
+sub sections {
+  my ($self) = @_;
+
+  return $self->getBy('level', 1);
+}
+
+=item subsections
+
+Returns a list of articles which are sub sections
+
+=cut
+
+sub subsections {
+  my ($self) = @_;
+
+  return $self->getBy('level', 2);
+}
+
+=item children($id)
+
+Child articles of the given article id
+
+=cut
+
+sub children {
+  my ($self, $id) = @_;
+
+  return $self->getBy('parentid', $id);
+}
+
+=item listedChildren($id)
+
+Children of the given article id that are listed and in the display
+order
+
+=cut
+
+sub listedChildren {
+  my ($self, $id) = @_;
+  my ($year, $month, $day) = (localtime)[5,4,3];
+  my $today = sprintf("%04d-%02d-%02d 00:00:00ZZZ", $year+1900, $month+1, $day);
+  my @work = $self->children($id);
+  return sort { $b->{displayOrder} <=> $a->{displayOrder} }
+    grep { $_->{listed} && $today ge $_->{release} 
+            && $today le $_->{expire}} @work;
+}
+
+=item summary
+
+Return a list of hashes with article id and title for every article.
+
+=cut
+
+sub summary {
+  BSE::DB->query('articlesList');
+}
+
+=item allids
+
+Return a list of all article ids.
+
+=cut
+
+sub allids {
+  my ($self) = @_;
+
+  if (ref $self) {
+    return map $_->{id}, $self->all;
+  }
+  else {
+    return map $_->{id}, BSE::DB->query('Articles.ids');
+  }
+}
+
+=item visible_stepkids($id)
+
+Return a list of visible stepkids of the given article id.
+
+=cut
+
+sub visible_stepkids {
+  my ($self, $id) = @_;
+
+  use BSE::Util::SQL qw/now_sqldate/;
+  my $today = now_sqldate();
+
+  return BSE::TB::Articles->getSpecial('visibleStepKids', $id, $today);
+}
+
+=item all_visible_kids($id)
+
+Return a list of all visible children of the given article id.
+
+=cut
+
+sub all_visible_kids {
+  my ($self, $id) = @_;
+
+  require 'OtherParents.pm';
+
+  my @otherlinks = OtherParents->getBy(parentId=>$id);
+  my @normalkids = BSE::TB::Articles->listedChildren($id);
+  my %order = (
+              (map { $_->{id}, $_->{displayOrder} } @normalkids ),
+              (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
+             );
+  my @stepkids = $self->visible_stepkids($id);
+  my %kids = map { $_->{id}, $_ } @stepkids, @normalkids;
+
+  return @kids{ sort { $order{$b} <=> $order{$a} } keys %kids };
+}
+
+=item all_visible_kid_tags($id)
+
+Return a hash with two keys, C<tags> being all tags for all visible
+children of C<$id>, and C<members> being all tag member objects for
+all visible children of C<$id>.
+
+=cut
+
+sub all_visible_kid_tags {
+  my ($self, $id) = @_;
+
+  require BSE::TB::Tags;
+  require BSE::TB::TagMembers;
+  return
+    {
+     tags => [ BSE::TB::Tags->getSpecial(allkids => $id, $id) ],
+     members => [ BSE::TB::TagMembers->getSpecial(allkids => $id, $id) ],
+    };
+}
+
+=item global_files
+
+Return a list of global files.
+
+=cut
+
+sub global_files {
+  my ($self) = @_;
+
+  require BSE::TB::ArticleFiles;
+  return BSE::TB::ArticleFiles->getBy(articleId => -1);
+}
+
+=item allkid_summary($parent_id)
+
+Return a list of hash per child, each with id, displayOrder sorted for
+display.
+
+Entries with step_id are for step children of $parent_id.
+
+=cut
+
+sub allkid_summary {
+  my ($class, $parent_id) = @_;
+
+  my @child_order = BSE::DB->query(bseChildOrder => $parent_id);
+  my @stepchild_order = BSE::DB->query(bseStepchildOrder => $parent_id);
+
+  return sort { $b->{displayOrder} <=> $a->{displayOrder} }
+    ( @child_order, @stepchild_order );
+}
+
+=item reorder_child($parent_id, $child_id, $after_id)
+
+Move article C<$child_id> after C<$after_id> in the all children list
+of article C<$after_id>.
+
+Returns a true value on success.
+
+=cut
+
+sub reorder_child {
+  my ($class, $parent_id, $child_id, $after_id) = @_;
+
+  my @child_order = $class->allkid_summary($parent_id);
+
+  my ($child_index) = grep $child_order[$_]{id} == $child_id, 0..$#child_order
+    or return; # nothing to do, it's not a child
+  my @order = map $_->{displayOrder}, @child_order;
+
+  if ($child_index > 0 && $child_order[$child_index-1]{id} == $after_id
+      || $child_index == 0 && $after_id == 0) {
+    # trivial success
+    return 1;
+  }
+
+  # remove the child from the order
+  my ($child) = splice(@child_order, $child_index, 1);
+
+  my $start_index;
+  if ($after_id == 0) {
+    unshift @child_order, $child;
+    $start_index = 0;
+  }
+  else {
+    my ($after_index) = grep $child_order[$_]{id} == $after_id, 0..$#child_order
+      or return; # after not found, nothing to do
+
+    splice(@child_order, $after_index+1, 0, $child);
+    $start_index = $after_index + 1;
+  }
+
+  for my $index (0 .. $#order) {
+    my $child = $child_order[$index];
+    if ($child->{step_id}) {
+      BSE::DB->run(bseSetStepOrder => $order[$index], $child->{step_id});
+    }
+    else {
+      BSE::DB->run(bseSetArticleOrder => $order[$index], $child->{id});
+    }
+  }
+
+  return 1;
+}
+
+=item categories
+
+Return a list of all configured article categories.
+
+Each entry is a hash containing C<id> and C<name>.
+
+=cut
+
+sub categories {
+  my $cfg = BSE::Cfg->single;
+
+  my @cat_ids = split /,/, $cfg->entry("article categories", "ids", "");
+  grep $_ eq "", @cat_ids
+    or unshift @cat_ids, "";
+
+  my @cats;
+  for my $id (@cat_ids) {
+    my $section = length $id ? "article category $id" : "article category empty";
+    my $def_name = length $id ? ucfirst $id : "(None)";
+    my $name = $cfg->entry($section, "name",
+                          $cfg->entry("article categories", $id, $def_name));
+    push @cats, +{ id => $id, name => $name };
+  }
+  
+  return @cats;
+}
+
+1;
+
+=back
+
+=head1 AUTHOR
+
+Tony Cook <tony@develop-help.com>
+
+=cut
+
index e3387bd52f393ecadff401c69146b866b6e1aa58..0a05d3dc3b9e5857160ce9fe48ce293ab80664a1 100644 (file)
@@ -8,7 +8,7 @@ use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row BSE::ThumbCommon BSE::TB::TagOwner/;
 use Carp qw(confess);
 
-our $VERSION = "1.009";
+our $VERSION = "1.010";
 
 =head1 NAME
 
@@ -283,8 +283,8 @@ sub article {
     return BSE::TB::Site->new;
   }
   else {
-    require Articles;
-    return Articles->getByPkey($self->articleId);
+    require BSE::TB::Articles;
+    return BSE::TB::Articles->getByPkey($self->articleId);
   }
 }
 
index 53f4d01d3317a7ce573527c1740dce31b3a4483b..185cfec75898e98f8e793ef38d7cef8f52646f55 100644 (file)
@@ -2,7 +2,7 @@ package BSE::TB::SiteCommon;
 use strict;
 use Carp qw(confess);
 
-our $VERSION = "1.019";
+our $VERSION = "1.020";
 
 =head1 NAME
 
@@ -26,26 +26,26 @@ Provides methods common to the Article and BSE::TB::Site objects.
 sub step_parents {
   my ($self) = @_;
 
-  Articles->getSpecial('stepParents', $self->{id});
+  BSE::TB::Articles->getSpecial('stepParents', $self->{id});
 }
 
 sub visible_step_parents {
   my ($self) = @_;
 
   my $now = now_sqldate();
-  Articles->getSpecial('visibleStepParents', $self->{id}, $now);
+  BSE::TB::Articles->getSpecial('visibleStepParents', $self->{id}, $now);
 }
 
 sub stepkids {
   my ($self) = @_;
 
-  return Articles->getSpecial('stepKids', $self->{id});
+  return BSE::TB::Articles->getSpecial('stepKids', $self->{id});
 }
 
 sub allstepkids {
   my ($self) = @_;
 
-  return Articles->getSpecial('stepKids', $self->{id});
+  return BSE::TB::Articles->getSpecial('stepKids', $self->{id});
 }
 
 sub visible_stepkids {
@@ -60,7 +60,7 @@ sub visible_stepkids {
     return Products->getSpecial('visibleStep', $self->{id}, $today);
   }
   else {
-    return Articles->getSpecial('visibleStepKids', $self->{id}, $today);
+    return BSE::TB::Articles->getSpecial('visibleStepKids', $self->{id}, $today);
   }
   
   return ();
@@ -74,7 +74,7 @@ sub allkids {
   require 'OtherParents.pm';
 
   my @otherlinks = OtherParents->getBy(parentId=>$self->{id});
-  my @normalkids = Articles->children($self->{id});
+  my @normalkids = BSE::TB::Articles->children($self->{id});
   my %order = (
               (map { $_->{id}, $_->{displayOrder} } @normalkids ),
               (map { $_->{childId}, $_->{parentDisplayOrder} } @otherlinks),
@@ -90,13 +90,13 @@ sub allkids {
 sub all_visible_kids {
   my ($self) = @_;
 
-  Articles->all_visible_kids($self->{id});
+  BSE::TB::Articles->all_visible_kids($self->{id});
 }
 
 sub all_visible_kid_tags {
   my ($self) = @_;
 
-  Articles->all_visible_kid_tags($self->{id});
+  BSE::TB::Articles->all_visible_kid_tags($self->{id});
 }
 
 sub all_visible_products {
@@ -122,7 +122,7 @@ sub all_visible_catalogs {
 sub visible_kids {
   my ($self) = @_;
 
-  return Articles->listedChildren($self->{id});
+  return BSE::TB::Articles->listedChildren($self->{id});
 }
 
 =item menu_kids
@@ -269,7 +269,7 @@ sub children {
   my ($self) = @_;
 
   return sort { $b->{displayOrder} <=> $a->{displayOrder} } 
-    Articles->children($self->{id});
+    BSE::TB::Articles->children($self->{id});
 }
 
 =item files
@@ -575,7 +575,7 @@ If $after_id is zero then $child_id becomes the first child.
 sub reorder_child {
   my ($self, $child_id, $after_id) = @_;
 
-  Articles->reorder_child($self->{id}, $child_id, $after_id);
+  BSE::TB::Articles->reorder_child($self->{id}, $child_id, $after_id);
 }
 
 sub set_image_order {
index 0d4b822c06ff818011b261ea72caba4dbf5d2ef0..6b4184f6dc497dd1214380cd214b3bfd0663f08b 100644 (file)
@@ -8,7 +8,7 @@ BSE::TB::TagCategory - represents a tag category
 
 =head1 SYNOPSIS
 
-  my $cat = Article->tag_category($name);
+  my $cat = BSE::TB::Article->tag_category($name);
 
   my @deps = $cat->deps;
 
@@ -20,7 +20,7 @@ BSE::TB::TagCategory - represents a tag category
 
 =cut
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 sub columns {
   qw(id cat owner_type);
index 0c5008a91e1ca1b0028566b0dbc8335227bc0844..aa8a80752793a26bdb45d52b9219e4ae5d53840a 100644 (file)
@@ -2,9 +2,9 @@ package BSE::UI::AdminEdit;
 use strict;
 use base 'BSE::UI::AdminDispatch';
 use BSE::Edit::Base;
-use Articles;
+use BSE::TB::Articles;
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 sub dispatch {
   my ($self, $req) = @_;
@@ -12,7 +12,7 @@ sub dispatch {
   my $cgi = $req->cgi;
   my $cfg = $req->cfg;
   my $id = $cgi->param('id');
-  my $articles = 'Articles'; # for a later switch to proper objects, I hope
+  my $articles = 'BSE::TB::Articles'; # for a later switch to proper objects, I hope
   my $result;
   if (defined $id && $id =~ /\d/ && $id == -1) {
     my $obj = get_class('BSE::Edit::Site', $cfg)
index 311ade90a33ce5b4a7fc775bf1a81b21e79eda61..806bbbb12a391115937f3f60b0ff585537272d9e 100644 (file)
@@ -2,13 +2,13 @@ package BSE::UI::AdminNewsletter;
 use strict;
 use BSE::SubscriptionTypes;
 use BSE::Util::Tags qw(tag_hash);
-use Articles;
+use BSE::TB::Articles;
 use BSE::Message;
 use BSE::Util::HTML qw(:default popup_menu);
 use BSE::Util::Iterate;
 use base 'BSE::UI::AdminDispatch';
 
-our $VERSION = "1.004";
+our $VERSION = "1.005";
 
 =head1 NAME
 
@@ -179,7 +179,7 @@ sub _parent_popup {
 
   my %valid_types = map { $_ => 1 } _valid_archive_types($req);
   my $shopid = $req->cfg->entryErr('articles', 'shop');
-  my @all = Articles->query([qw/id title generator/],
+  my @all = BSE::TB::Articles->query([qw/id title generator/],
                           [ [ '<>', 'id', $shopid ] ]);
   if ($req->cfg->entry('basic', 'access_filter_parents', 0)) {
     @all = grep($req->user_can('edit_add_child', $_->{id})
@@ -307,7 +307,7 @@ sub validate {
   if ($q->param('archive')) {
     my $id = $q->param('parentId');
     if ($id) {
-      my $article = Articles->getByPkey($id);
+      my $article = BSE::TB::Articles->getByPkey($id);
       if ($article) {
        unless ($req->user_can('edit_add_child', $article)
                || ($sub && $sub->{parentId} == $id)) {
index 651f77d265570776783240173ead5014fafc18d7..899c40f66ac79a1f8ee6fb5fde352dc77f262284 100644 (file)
@@ -1,12 +1,12 @@
 package BSE::UI::AdminPage;
 use strict;
-use Articles;
+use BSE::TB::Articles;
 use BSE::Util::HTML qw(escape_uri);
 use BSE::UI::AdminDispatch;
-use Articles;
+use BSE::TB::Articles;
 our @ISA = qw(BSE::UI::AdminDispatch);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 my %actions =
   (
@@ -36,8 +36,8 @@ sub req_adminpage {
   $admin_links = $cgi->param('admin_links')
     if defined $cgi->param('admin_links');
   
-  #my $articles = Articles->new;
-  my $articles = 'Articles';
+  #my $articles = BSE::TB::Articles->new;
+  my $articles = 'BSE::TB::Articles';
   
   my $article;
   $article = $articles->getByPkey($id) if $id =~ /^\d+$/;
index 96d65f9e1689febf3eb63c0c84f972f36120aa4c..e027024a1a2b542869b75beb42af022d17ce70c5 100644 (file)
@@ -5,7 +5,7 @@ use BSE::Util::Iterate;
 use BSE::Util::Tags qw(tag_hash);
 use BSE::Regen qw(pregenerate_list content_one_extra response_one_extra);
 
-our $VERSION = "1.002";
+our $VERSION = "1.003";
 
 my %actions =
   (
@@ -78,14 +78,14 @@ sub req_display {
     or return $self->req_list($req, { template => "Unknown pregen template $id" });
 
   if ($entry->{dynamic}) {
-    my ($content, $article) = content_one_extra("Articles", $entry);
+    my ($content, $article) = content_one_extra("BSE::TB::Articles", $entry);
 
     require BSE::Dynamic::Article;
     my $dyngen = BSE::Dynamic::Article->new($req);
     return $dyngen->generate($article, $content);
   }
   else {
-    return response_one_extra("Articles", $entry);
+    return response_one_extra("BSE::TB::Articles", $entry);
   }
 }
 
index ab0e7844f775be0260234de704b9df0858ccda13..ee6f6b9fb84ff1e901552f9f39b761a5dac1bccb 100644 (file)
@@ -1,11 +1,11 @@
 package BSE::UI::AdminReorder;
 use strict;
 use base 'BSE::UI::AdminDispatch';
-use Articles;
+use BSE::TB::Articles;
 use OtherParents;
 use List::Util ();
 
-our $VERSION = "1.001";
+our $VERSION = "1.002";
 
 =head1 NAME
 
@@ -121,7 +121,7 @@ sub req_byparent {
     (
      $req,
      [
-      map [ $_, $_, 'displayOrder' ], Articles->getBy(parentid => $parentid)
+      map [ $_, $_, 'displayOrder' ], BSE::TB::Articles->getBy(parentid => $parentid)
      ]
     );
 
@@ -169,11 +169,11 @@ sub req_bystepparent {
   $req->user_can(bse_edit_reorder_children => $stepparent)
     or return $self->access_error($req, $msg);
 
-  my $parent = Articles->getByPkey($stepparent)
+  my $parent = BSE::TB::Articles->getByPkey($stepparent)
     or return $self->error($req, "Unknown article $stepparent");
   
   my @otherlinks = OtherParents->getBy(parentId => $stepparent);
-  my @normalkids = Articles->children($stepparent);
+  my @normalkids = BSE::TB::Articles->children($stepparent);
   my @stepkids = $parent->stepkids;
   my %stepkids = map { $_->{id}, $_ } @stepkids;
   my @kids =
@@ -232,11 +232,11 @@ sub req_bystepchild {
   $req->user_can(bse_edit_reorder_children => $stepchild)
     or return $self->access_error($req, $msg);
 
-  my $child = Articles->getByPkey($stepchild)
+  my $child = BSE::TB::Articles->getByPkey($stepchild)
     or return $self->error($req, "Unknown child $stepchild");
 
   my @otherlinks = OtherParents->getBy(childId=>$stepchild);
-  my @stepparents = map Articles->getByPkey($_->{parentId}), @otherlinks;
+  my @stepparents = map BSE::TB::Articles->getByPkey($_->{parentId}), @otherlinks;
   my %stepparents = map { $_->{id}, $_ } @stepparents;
 
 
@@ -293,7 +293,7 @@ sub _sort {
     @reverse{@fields} = @reverse;
     @fields = grep exists($kids->[0][0]{$_}), @fields;
     my @num = 
-    my %num = map { $_ => 1 } Article->numeric;
+    my %num = map { $_ => 1 } BSE::TB::Article->numeric;
 
     $code =
       sub {
index c21814d7222855ee27501d8ea8e4ab4bc497066a..1e96987cb70012896f65d2dcbb1e77e70e6b373c 100644 (file)
@@ -4,7 +4,7 @@ use base 'BSE::UI::AdminDispatch';
 use SiteUsers;
 use BSE::Util::Tags qw(tag_hash_plain);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 my %actions =
   (
@@ -29,8 +29,8 @@ sub tag_ifUserCanSee {
 
   my $article;
   if ($args =~ /^\d+$/) {
-    require Articles;
-    $article = Articles->getByPkey($args);
+    require BSE::TB::Articles;
+    $article = BSE::TB::Articles->getByPkey($args);
   }
   else {
     $article = $req->get_article($args);
index 9ef18de886211bdeb26356e596f72548336f41c8..ba22a15d0f559f6874e3999d29fde0d9871c2fc2 100644 (file)
@@ -9,7 +9,7 @@ use BSE::Template;
 use Constants qw(:shop $SHOPID $PRODUCTPARENT 
                  $SHOP_URI $CGI_URI $AUTO_GENERATE);
 use BSE::TB::Images;
-use Articles;
+use BSE::TB::Articles;
 use BSE::Sort;
 use BSE::Util::Tags qw(tag_hash tag_error_img tag_object_plain tag_object tag_article);
 use BSE::Util::Iterate;
@@ -21,7 +21,7 @@ use BSE::CfgInfo qw(cfg_dist_image_uri);
 use BSE::Util::SQL qw/now_sqldate sql_to_date date_to_sql sql_date sql_datetime/;
 use BSE::Util::Valid qw/valid_date/;
 
-our $VERSION = "1.025";
+our $VERSION = "1.026";
 
 my %actions =
   (
@@ -102,7 +102,7 @@ sub embedded_catalog {
   my $subcat_index = -1;
   my @subcats = sort { $b->{displayOrder} <=> $a->{displayOrder} } 
     grep $_->{generator} eq 'BSE::Generate::Catalog', 
-    Articles->children($catalog->{id});
+    BSE::TB::Articles->children($catalog->{id});
 
   my $image_uri = cfg_dist_image_uri();
   my $blank = qq!<img src="$image_uri/trans_pixel.gif" width="17" height="13" border="0" align="absbottom" />!;
@@ -206,9 +206,9 @@ sub req_product_list {
   my $cgi = $req->cgi;
   my $session = $req->session;
   my $shopid = $req->cfg->entryErr('articles', 'shop');
-  my $shop = Articles->getByPkey($shopid);
+  my $shop = BSE::TB::Articles->getByPkey($shopid);
   my @catalogs = sort { $b->{displayOrder} <=> $a->{displayOrder} }
-    grep $_->{generator} eq 'BSE::Generate::Catalog', Articles->children($shopid);
+    grep $_->{generator} eq 'BSE::Generate::Catalog', BSE::TB::Articles->children($shopid);
   my $catalog_index = -1;
   $message = $req->message($message);
   if (defined $cgi->param('showstepkids')) {
@@ -331,7 +331,7 @@ sub product_form {
     push(@catalogs, { id=>$parent, display=>$title }) if $title;
     my @kids = sort { $b->{displayOrder} <=> $a->{displayOrder} } 
       grep $_->{generator} eq 'BSE::Generate::Catalog',
-      Articles->children($parent);
+      BSE::TB::Articles->children($parent);
     $title .= ' / ' if $title;
     unshift(@work, map [ $_->{id}, $title.$_->{title} ], @kids);
   }
index e9ad1c951128f0a235d477030d5fdfe51d722f1a..cc8beecb47c8e1394022652b182cdce5c030c7f2 100644 (file)
@@ -1,11 +1,11 @@
 package BSE::UI::Image;
 use strict;
-use Articles;
+use BSE::TB::Articles;
 use BSE::TB::Images;
 use BSE::Util::Tags qw(tag_hash);
 use BSE::Util::HTML qw(escape_uri);
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 # we don't do anything fancy on dispatch yet, so don't use the 
 # dispatch classes
@@ -16,7 +16,7 @@ sub dispatch {
   my $id = $cgi->param('id');
   $id && $id =~ /^\d+$/
     or return $class->error($req, "required id parameter not present or invalid");
-  my $article = Articles->getByPkey($id)
+  my $article = BSE::TB::Articles->getByPkey($id)
     or return $class->error($req, "unknown article id $id");
 
   my $image;
index c156d159e04f477a10cae84d7a3a1022fce661ff..a3c5b0711e6c787ce5540605ce7774c83ebae832 100644 (file)
@@ -1,12 +1,12 @@
 package BSE::UI::Page;
 use strict;
-use Articles;
+use BSE::TB::Articles;
 use BSE::Util::HTML qw(escape_uri);
 use BSE::UI::Dispatch;
 use BSE::Template;
 our @ISA = qw(BSE::UI::Dispatch);
 
-our $VERSION = "1.007";
+our $VERSION = "1.008";
 
 # we don't do anything fancy on dispatch yet, so don't use the 
 # dispatch classes
@@ -73,7 +73,7 @@ sub dispatch {
   if ($page) {
     $dump .= "Page lookup: '$page'\n";
     if ($page =~ /^[0-9]+$/) {
-      $article = Articles->getByPkey($page);
+      $article = BSE::TB::Articles->getByPkey($page);
       $dump .= "Search by id\n";
       $search_by_id = 1;
     }
@@ -89,7 +89,7 @@ sub dispatch {
        $dump .= "Removed recursive prefix\n";
       }
       $dump .= "Looking for alias: $alias\n";
-      ($article) = Articles->getBy(linkAlias => $alias);
+      ($article) = BSE::TB::Articles->getBy(linkAlias => $alias);
     }
   }
 
@@ -229,7 +229,7 @@ sub dispatch {
 sub _generate_pregen {
   my ($self, $req, $article, $srcname) = @_;
 
-  my $articles = 'Articles';
+  my $articles = 'BSE::TB::Articles';
   my $genname = $article->{generator};
   eval "use $genname";
   $@ && die $@;
index 5f18f3b74e04697d4f4332fd04a341a3cf3435b9..c90b0f47b953607b69f8dc8dc35a53a1d31b298e 100644 (file)
@@ -1,7 +1,7 @@
 package BSE::UI::Search;
 use strict;
 use base 'BSE::UI::Dispatch';
-use Articles;
+use BSE::TB::Articles;
 use BSE::DB;
 use Constants qw(:search);
 use Carp;
@@ -11,7 +11,7 @@ use BSE::Util::HTML qw':default popup_menu';
 use BSE::Util::Tags qw(tag_article);
 use BSE::Request;
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 my %actions =
   (
@@ -61,7 +61,7 @@ sub req_search {
     
     if ($cfg->entry('search', 'keep_inaccessible')) {
       for my $entry (@results[$articles_start..$articles_end]) {
-       my $article = Articles->getByPkey($entry->[0])
+       my $article = BSE::TB::Articles->getByPkey($entry->[0])
          or die "Cannot retrieve article $entry->[0]\n";
        push(@articles, $article);
       }
@@ -73,7 +73,7 @@ sub req_search {
       my $seen = 0;
       while ($index < @results && $seen <= $articles_end) {
        my $id = $results[$index][0];
-       my $article = Articles->getByPkey($id)
+       my $article = BSE::TB::Articles->getByPkey($id)
          or die "Cannot retrieve article $id\n";
        if ($req->siteuser_has_access($article)) {
          if ($seen >= $articles_start) {
@@ -108,7 +108,7 @@ sub req_search {
     sort { $b->{displayOrder} <=> $a->{displayOrder} }
       grep { ($_->{listed} || $included{$_->{id}}) 
               && !$excluded{$_->{id}} }
-       Articles->getBy('level', 1);
+       BSE::TB::Articles->getBy('level', 1);
   unshift(@sections, { ""=>$SEARCH_ALL });
   my %sections = map { %$_ } @sections;
   # now a list of values ( in the correct order
index 1a6ec8517f945293a6a3c81d6df3c6f1e6acbb05..3dfcb24d5ccaae24c91767a1749aec4163be835d 100644 (file)
@@ -4,9 +4,9 @@ use base 'BSE::UI::Dispatch';
 use BSE::Util::Secure qw/make_secret/;
 use BSE::Util::Tags qw(tag_hash tag_error_img tag_hash_plain tag_article tag_article_plain);
 use BSE::ComposeMail;
-use Articles;
+use BSE::TB::Articles;
 
-our $VERSION = "1.000";
+our $VERSION = "1.001";
 
 my %actions =
   (
@@ -32,7 +32,7 @@ sub _article {
     return;
   }
 
-  my $article = Articles->getByPkey($id);
+  my $article = BSE::TB::Articles->getByPkey($id);
   unless ($article) {
     $$error = "article $id not found";
     return;
index c457a8725960a585f6a37527e7c55c494cd101d2..2c8288e00f4e053e9ef3de9be4b95e4028d4b680 100644 (file)
@@ -18,7 +18,7 @@ use BSE::Util::Iterate;
 use base 'BSE::UI::UserCommon';
 use Carp qw(confess);
 
-our $VERSION = "1.031";
+our $VERSION = "1.032";
 
 use constant MAX_UNACKED_CONF_MSGS => 3;
 use constant MIN_UNACKED_CONF_GAP => 2 * 24 * 60 * 60;
@@ -1611,8 +1611,8 @@ sub _common_download {
   # check the user has access to this file (RT#531)
   my $article;
   if ($file->{articleId} != -1) {
-    require Articles;
-    $article ||= Articles->getByPkey($file->{articleId})
+    require BSE::TB::Articles;
+    $article ||= BSE::TB::Articles->getByPkey($file->{articleId})
       or return $self->req_show_logon($req,
                                  $msgs->('downloadarticle',
                                          "Could not load article for file"));
index 15a6707d6da2a2ab967b1f37ab4a051c6ef63787..4877db8f633590fa99729645fd01fc068862d668 100644 (file)
@@ -7,7 +7,7 @@ use base 'BSE::TagFormats';
 use BSE::CfgInfo qw(custom_class);
 use BSE::Cart;
 
-our $VERSION = "1.026";
+our $VERSION = "1.027";
 
 =head1 NAME
 
@@ -213,8 +213,8 @@ sub tag_ifUserCanSee {
 
   my $article;
   if ($args =~ /^\d+$/) {
-    require Articles;
-    $article = Articles->getByPkey($args);
+    require BSE::TB::Articles;
+    $article = BSE::TB::Articles->getByPkey($args);
   }
   else {
     $article = $req->get_article($args);
@@ -326,8 +326,8 @@ sub iter_dynlevel1s {
   $result
     and return $result;
 
-  require Articles;
-  $result = $self->access_filter(Articles->listedChildren(-1));
+  require BSE::TB::Articles;
+  $result = $self->access_filter(BSE::TB::Articles->listedChildren(-1));
   $self->set_cached(dynlevel1 => $result);
 
   return $result;
@@ -350,8 +350,8 @@ sub iter_dynlevel2s {
   $cached && $cached->[0] == $parent->{id}
     and return $cached->[1];
 
-  require Articles;
-  my $result = $self->access_filter(Articles->listedChildren($parent->{id}));
+  require BSE::TB::Articles;
+  my $result = $self->access_filter(BSE::TB::Articles->listedChildren($parent->{id}));
   $self->set_cached(dynlevel2 => [ $parent->{id}, $result ]);
 
   return $result;
@@ -374,8 +374,8 @@ sub iter_dynlevel3s {
   $cached && $cached->[0] == $parent->{id}
     and return $cached->[1];
 
-  require Articles;
-  my $result = $self->access_filter( Articles->listedChildren($parent->{id}));
+  require BSE::TB::Articles;
+  my $result = $self->access_filter( BSE::TB::Articles->listedChildren($parent->{id}));
   $self->set_cached(dynlevel3 => [ $parent->{id}, $result ]);
 
   return $result;
@@ -405,8 +405,8 @@ sub iter_dynallkids_of {
 
   @ids == 1 and $state->{parentid} = $ids[0];
 
-  require Articles;
-  return $self->access_filter(map Articles->all_visible_kids($_), @ids);
+  require BSE::TB::Articles;
+  return $self->access_filter(map BSE::TB::Articles->all_visible_kids($_), @ids);
 }
 
 sub tags_for_dynallkids_of {
@@ -424,15 +424,15 @@ sub tags_for_dynallkids_of {
   @ids
     or return { tags => [], members => [] };
 
-  require Articles;
+  require BSE::TB::Articles;
   if (@ids == 1) {
-    return Articles->all_visible_kid_tags($ids[0]);
+    return BSE::TB::Articles->all_visible_kid_tags($ids[0]);
   }
   else {
     my %tags;
     my @members;
     for my $id (@ids) {
-      my $more_tags = Articles->all_visible_kid_tags($id);
+      my $more_tags = BSE::TB::Articles->all_visible_kid_tags($id);
       for my $tag (@{$more_tags->{tags}}) {
        $tags{$tag->id} = $tag;
       }
@@ -471,8 +471,8 @@ sub iter_dynchildren_of {
   }
   @ids = grep defined && /^\d+$|^-1$/, @ids;
 
-  require Articles;
-  return $self->access_filter( map Articles->listedChildren($_), @ids);
+  require BSE::TB::Articles;
+  return $self->access_filter( map BSE::TB::Articles->listedChildren($_), @ids);
 }
 
 =item iterator dyncart
@@ -590,19 +590,19 @@ sub _find_articles {
   my ($self, $article_id) = @_;
 
   if ($article_id =~ /^\d+$/) {
-    my $result = Articles->getByPkey($article_id);
+    my $result = BSE::TB::Articles->getByPkey($article_id);
     $result or print STDERR "** Unknown article id $article_id **\n";
     return $result ? $result : ();
   }
   elsif ($article_id =~ /^alias\((\w+)\)$/) {
-    my $result = Articles->getBy(linkAlias => $1);
+    my $result = BSE::TB::Articles->getBy(linkAlias => $1);
     $result or print STDERR "** Unknown article alias $article_id **\n";
     return $result ? $result : ();
   }
   elsif ($article_id =~ /^childrenof\((.*)\)$/) {
     my $id = $1;
     if ($id eq '-1') {
-      return Articles->all_visible_kids(-1);
+      return BSE::TB::Articles->all_visible_kids(-1);
     }
     else {
       my @parents = $self->_find_articles($id)
@@ -765,9 +765,9 @@ sub iter_dynunused_tagcats {
     $tags = $self->{tags}{$iter};
   }
 
-  require Articles;
+  require BSE::TB::Articles;
 
-  return Articles->categorize_tags
+  return BSE::TB::Articles->categorize_tags
     (
      [ keys %$tags ],
      $selected_tags,
@@ -904,8 +904,8 @@ sub tag_dthumbimage {
   
   my $article;
   if ($article_id =~ /^\d+$/) {
-    require Articles;
-    $article = Articles->getByPkey($args);
+    require BSE::TB::Articles;
+    $article = BSE::TB::Articles->getByPkey($args);
   }
   else {
     $article = $self->{req}->get_article($article_id);
@@ -1281,8 +1281,8 @@ sub _get_filter {
     my $expr = $1;
     my $orig_expr = $expr;
     unless ($cols_re) {
-      require Articles;
-      my $cols_expr = '(' . join('|', Article->columns) . ')';
+      require BSE::TB::Articles;
+      my $cols_expr = '(' . join('|', BSE::TB::Article->columns) . ')';
       $cols_re = qr/\[$cols_expr\]/;
     }
     $expr =~ s/$cols_re/\$article->{$1}/g;
@@ -1363,7 +1363,7 @@ sub _do_filter {
       my $all_found = 1;
     TAGS:
       for my $tag_name (@$tags) {
-       my $tag = Articles->getTagByName($tag_name);
+       my $tag = BSE::TB::Articles->getTagByName($tag_name);
        unless ($tag) {
          # can't find a tag that doesn't exist
          $all_found = 0;
index 91b33e765aee6aadcb274db881b38bb2145806f3..7f3cd1bb09ee6d7c0a3349607224ed42aa233aad 100644 (file)
@@ -8,7 +8,7 @@ use vars qw(@EXPORT_OK @ISA);
 @ISA = qw(Exporter);
 require Exporter;
 
-our $VERSION = "1.026";
+our $VERSION = "1.027";
 
 sub _get_parms {
   my ($acts, $args) = @_;
@@ -198,7 +198,7 @@ sub static {
        require BSE::Generate;
        my $gen = BSE::Generate->new(cfg=>$cfg);
        return $gen->format_body(acts => $acts, 
-                               articles => 'Articles', 
+                               articles => 'BSE::TB::Articles', 
                                text => $value, 
                                templater => $templater);
      },
@@ -445,7 +445,7 @@ sub tag_nobodytext {
   
   require BSE::Generate;
   my $gen = BSE::Generate->new(cfg=>$cfg);
-  $gen->remove_block('Articles', $acts, \$value);
+  $gen->remove_block('BSE::TB::Articles', $acts, \$value);
   
   return escape_html($value);
 }
index 4c1c0ee2991fa4f3455be6e887c429451846c4e6..9b0c81b07364616bb4787df1fcdd0a27c403b5a6 100644 (file)
@@ -4,7 +4,7 @@ use Scalar::Util qw(blessed);
 use BSE::TB::Site;
 use BSE::Util::HTML;
 
-our $VERSION = "1.019";
+our $VERSION = "1.020";
 
 sub _base_variables {
   my ($self, %opts) = @_;
@@ -99,7 +99,7 @@ sub _url_common {
 sub _categorize_tags {
   my ($tags, $selected_tags, $opts) = @_;
 
-  require Articles;
+  require BSE::TB::Articles;
 
   if ($opts && $opts->{members} && !$opts->{counts}) {
     my %counts;
@@ -110,7 +110,7 @@ sub _categorize_tags {
     $opts->{counts} = \%counts;
   }
 
-  return Articles->categorize_tags($tags, $selected_tags, $opts);
+  return BSE::TB::Articles->categorize_tags($tags, $selected_tags, $opts);
 }
 
 sub _paged {
@@ -204,8 +204,8 @@ sub _variable_class {
   my $articles;
   sub _articles {
     unless ($articles) {
-      require Articles;
-      $articles = _variable_class("Articles");
+      require BSE::TB::Articles;
+      $articles = _variable_class("BSE::TB::Articles");
     }
 
     return $articles;
index 4bc0cf5cea9a5105fc91ded0531f5e82148e98e6..b3d0426802db39eab24740262dbf7927075cf994 100644 (file)
@@ -1,11 +1,11 @@
 package Product;
 use strict;
 # represents a product from the database
-use Articles;
+use BSE::TB::Articles;
 use vars qw/@ISA/;
-@ISA = qw/Article/;
+@ISA = qw/BSE::TB::Article/;
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 # subscription_usage values
 use constant SUBUSAGE_START_ONLY => 1;
@@ -20,7 +20,7 @@ sub columns {
 }
 
 sub bases {
-  return { articleId=>{ class=>'Article'} };
+  return { articleId=>{ class=>'BSE::TB::Article'} };
 }
 
 sub subscription_required {
index c928c0213f0965900c8ec8b2a9d63ffc41a3a995..ec522eaaab2ca04269a9de1607ea806b65cb8dfe 100755 (executable)
@@ -4,7 +4,7 @@ use FindBin;
 use lib "$FindBin::Bin/modules";
 use CGI qw(:standard);
 use Carp; # 'verbose'; # remove the 'verbose' in production
-use Articles;
+use BSE::TB::Articles;
 use BSE::Cfg;
 use BSE::DB;
 use BSE::Template;
@@ -18,14 +18,14 @@ defined $id or $id = 1;
 # loads all of the articles into memory
 # hopefully a print template won't include too many references to 
 # other articles anyway
-#my $articles = Articles->new;
+#my $articles = BSE::TB::Articles->new;
 
-my $article = Articles->getByPkey($id)
+my $article = BSE::TB::Articles->getByPkey($id)
   or error_page("No article with id $id found");
 
 eval "use $article->{generator}";
 die $@ if $@;
-my $generator = $article->{generator}->new(articles=>'Articles', cfg => $cfg,
+my $generator = $article->{generator}->new(articles=>'BSE::TB::Articles', cfg => $cfg,
                                          top => $article);
 
 my $template = param('template');
@@ -64,7 +64,7 @@ close TMPLT;
 $text =~ s/<:\s*embed\s+(?:start|end)\s*:>//g;
 
 print "Content-Type: $type\n\n";
-print $generator->generate_low($text, $article, 'Articles');
+print $generator->generate_low($text, $article, 'BSE::TB::Articles');
 
 
 sub error_page {
@@ -72,7 +72,7 @@ sub error_page {
   $error ||= "Unknown error";
 
   my %article;
-  my @cols = Article->columns;
+  my @cols = BSE::TB::Article->columns;
   @article{@cols} = ('') x @cols;
   $article{id} = -10;
   $article{title} = "Error";
@@ -83,7 +83,7 @@ sub error_page {
   my %acts;
   %acts = 
     (
-     $gen->baseActs('Articles', \%acts, \%article),
+     $gen->baseActs('BSE::TB::Articles', \%acts, \%article),
      error => sub { CGI::escapeHTML($error) },
     );
   
index ffd5b7577c7d9572af9c2dce08dc8bcdb33eea7a..cd94d4e659e28ed2fdb27673216254f911ee1874 100644 (file)
@@ -1,4 +1,4 @@
-/Article.html
+/BSE::TB::Article.html
 /BSE::TB::SiteCommon.html
 /BSE::TB::TagOwner.html
 /BSE::UI::Affiliate.html
index 78a07708b7a680d66ecd7c18472a26fdfba29a5b..b66a91a256410e54cbc03b0295adeb472118a069 100644 (file)
@@ -7,7 +7,7 @@ use strict;
 my @targets =
   (
    'access.html',
-   'Article.html',
+   'BSE::TB::Article.html',
    'bse.html',
    'BSE::TB::SiteCommon.html',
    'BSE::TB::TagOwner.html',
index 8b29694bf837fe89940db6d3deba273f047e63c8..4bafae642c64371f47da9e31e814e0381327ff3b 100644 (file)
@@ -5,7 +5,7 @@ use FindBin;
 use lib "$FindBin::Bin/../cgi-bin/modules";
 use BSE::Index;
 use BSE::API qw(bse_init bse_cfg);
-use Articles;
+use BSE::TB::Articles;
 use Encode;
 
 bse_init("../cgi-bin");
index b8d237052a32e0e71aea9a547a7fc888ffaef8d0..fcceed7a706b8e9986321661440c857eed949bb4 100644 (file)
@@ -5,7 +5,7 @@ use FindBin;
 use lib "$FindBin::Bin/../cgi-bin/modules";
 use BSE::Regen qw/generate_all generate_article generate_base pregenerate_list generate_one_extra/;
 use BSE::API qw(bse_init bse_cfg);
-use Articles;
+use BSE::TB::Articles;
 
 bse_init("../cgi-bin");
 
@@ -17,7 +17,7 @@ $verbose = defined $verbose;
 
 my $cfg = bse_cfg();
 
-my $articles = 'Articles';
+my $articles = 'BSE::TB::Articles';
 
 $| = 1;
 
index 896ec1c5b2a2c07c7f98da104d66ffc8df5d203a..6fb62cc3322a758950e2406ac0b779a786ba46bc 100644 (file)
@@ -5,7 +5,7 @@
 use strict;
 use lib '../cgi-bin/modules';
 use DBI;
-use Article;
+use BSE::TB::Article;
 use Constants qw($DSN $UN $PW $CGI_URI $SHOP_URI $ROOT_URI);
 use BSE::API qw(bse_init bse_cfg);
 use BSE::Util::SQL qw(now_sqldate now_sqldatetime);
@@ -574,7 +574,7 @@ EOS
 
 my $dbh = BSE::DB->single->dbh
   or die "Cannot connect to database: ",DBI->errstr;
-my @columns = Article->columns;
+my @columns = BSE::TB::Article->columns;
 $dbh->do('delete from article')
   or die "Cannot delete articles: ",$dbh->errstr;
 $dbh->do('delete from product')
index 370ac60ede33bc5451b1599d96fd70a00bc00267..d33b5104f487f5afcadf7845c2004b413f740fe4 100644 (file)
@@ -107,7 +107,7 @@ SKIP: {
   my $error;
   ok($art->set_tags([ "colour: red", "size: large" ], \$error),
      "set some tags should succeed");
-  my $cat = Articles->tag_category("colour");
+  my $cat = BSE::TB::Articles->tag_category("colour");
   ok($cat, "get the 'colour' tag cat");
   my @orig_deps = $cat->deps;
 
index b1abb0704511e26437055446e7ca8eb97b9836c5..1222ef2d58fe5afae0be1d0c3509c65972e8c5e7 100644 (file)
@@ -5,7 +5,7 @@ use BSE::Test ();
 use File::Spec;
 use BSE::Cfg;
 
-use_ok("Article");
+use_ok("BSE::TB::Article");
 
 {
   my $cfg = BSE::Cfg->new_from_text(text => <<'EOS');
@@ -14,13 +14,13 @@ base=/test
 public_html=$(base)/htdocs
 EOS
 
-  is(Article->link_to_filename($cfg, "/"), "/test/htdocs/index.html",
+  is(BSE::TB::Article->link_to_filename($cfg, "/"), "/test/htdocs/index.html",
      "check default link to /");
-  is(Article->link_to_filename($cfg, "/foo.html/test"), "/test/htdocs/foo.html",
+  is(BSE::TB::Article->link_to_filename($cfg, "/foo.html/test"), "/test/htdocs/foo.html",
      "check default link to filename - trailing title");
-  is(Article->link_to_filename($cfg, "/test.html"), "/test/htdocs/test.html",
+  is(BSE::TB::Article->link_to_filename($cfg, "/test.html"), "/test/htdocs/test.html",
      "check default link to filename - trailing filename");
-  is(Article->link_to_filename($cfg, "//test.html"), "/test/htdocs/test.html",
+  is(BSE::TB::Article->link_to_filename($cfg, "//test.html"), "/test/htdocs/test.html",
      "check default link to filename - doubled /");
 }
 
@@ -34,7 +34,7 @@ public_html=$(base)/htdocs
 index_file=default.htm
 EOS
 
-  is(Article->link_to_filename($cfg, "/"), "/test/htdocs/default.htm",
+  is(BSE::TB::Article->link_to_filename($cfg, "/"), "/test/htdocs/default.htm",
      "check cfg link to filename");
 }
 
index 6e68ade94129880c55c0fb6dbdfd9e3967fcc97e..0f797b1d3b5477415a4ff0175d9937d97233203d 100644 (file)
@@ -11,7 +11,7 @@ BEGIN {
 }
 #ok(chdir $cgidir, "switch to CGI directory");
 # create some articles to test with
-use Articles;
+use BSE::TB::Articles;
 use Products;
 use BSE::API qw/bse_cfg bse_init bse_make_catalog bse_make_product bse_add_step_child/;
 
index 9d3d7ebe26f7ea750e980fff533898ab310edf25..39251cb87968dae919805784cfe64bca7542d1e4 100644 (file)
@@ -10,7 +10,7 @@ push @INC, 'modules';
 require BSE::Cfg;
 my $cfg = BSE::Cfg->new;
 # create some articles to test with
-require Articles;
+require BSE::TB::Articles;
 require Products;
 require BSE::TB::ProductOptions;
 require BSE::TB::ProductOptionValues;
@@ -563,7 +563,7 @@ sub dyn_template_test($$$$) {
 sub _generate_dyn_template {
   my ($article, $template) = @_;
 
-  my $articles = 'Articles';
+  my $articles = 'BSE::TB::Articles';
   my $genname = $article->{generator};
   eval "use $genname";
   $@ && die $@;
index b8db1e049eb16c2dc955aeb51c61182650f474a4..b4cd0544b0e40be72c99285455a8cca18ebbd9ba 100644 (file)
@@ -59,7 +59,7 @@ BSE::Admin::StepParents->add($parent, $stepkid);
 sleep(2); # make sure they get a new displayOrder
 BSE::Admin::StepParents->add($parent, $stepprod);
 
-my $top = Articles->getByPkey(1);
+my $top = BSE::TB::Articles->getByPkey(1);
 ok($top, "grabbing Home page");
 
 template_test "children_of", $top, <<TEMPLATE, <<EXPECTED;