files now have a flag to hide them from the files iterator. This will
authorTony Cook <tony@develop-help.com>
Mon, 14 Aug 2006 01:51:41 +0000 (01:51 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Mon, 14 Aug 2006 01:51:41 +0000 (01:51 +0000)
require a change to the admin/filelist.tmpl template in custom
template sets.

fixed a repeated "the" in the message from attempting to delete the
store.

schema/bse.sql
site/cgi-bin/modules/ArticleFile.pm
site/cgi-bin/modules/BSE/DB/Mysql.pm
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/Generate/Article.pm
site/docs/bse.pod
site/docs/templates.pod
site/templates/admin/filelist.tmpl

index e9624455721916a14ecce1a53e3667eec6ebe1df..2f32970ee38c373cd8d2463bba42f39347a7ed56 100644 (file)
@@ -398,6 +398,8 @@ create table article_files (
   -- identifier for the file for use with filelink[]
   name varchar(80) not null default '',
 
+  hide_from_list integer not null default 0,
+
   primary key (id)
 );
 
index 6000e3a74e37967bfe4d737fc84f8c7a445da437..73e39ee0a9176a73e79c1e7c42124568b2b4e5bc 100644 (file)
@@ -9,7 +9,7 @@ use Carp 'confess';
 sub columns {
   return qw/id articleId displayName filename sizeInBytes description 
             contentType displayOrder forSale download whenUploaded
-            requireUser notes name/;
+            requireUser notes name hide_from_list/;
 }
 
 sub remove {
index 164d26d9a59d790d1ef1b273e67f643522b2162a..fd814225dcbf3627f4e952a4b73707ce83b729f3 100644 (file)
@@ -119,9 +119,9 @@ EOS
    'select * from other_parents where childId = ? or parentId = ?',
 
    addArticleFile =>
-   'insert into article_files values (null,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+   'insert into article_files values (null,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
    replaceArticleFile =>
-   'replace article_files values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+   'replace article_files values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
    deleteArticleFile => 'delete from article_files where id = ?',
    getArticleFileByArticleId =>
    'select * from article_files where articleId = ? order by displayOrder desc',
index 203ddac5b6e218350474fa4372d1d30879c0267e..f8d50d728ef3bab886ccf1fb45a309aad348792e 100644 (file)
@@ -2596,10 +2596,11 @@ sub fileadd {
 
   my %errors;
   
-  $file{forSale} = 0 + exists $file{forSale};
-  $file{articleId} = $article->{id};
-  $file{download} = 0 + exists $file{download};
-  $file{requireUser} = 0 + exists $file{requireUser};
+  $file{forSale}       = 0 + exists $file{forSale};
+  $file{articleId}     = $article->{id};
+  $file{download}      = 0 + exists $file{download};
+  $file{requireUser}   = 0 + exists $file{requireUser};
+  $file{hide_from_list} = 0 + exists $file{hide_from_list};
 
   my $downloadPath = $self->{cfg}->entryVar('paths', 'downloads');
 
@@ -2760,15 +2761,16 @@ sub filesave {
   my $cgi = $req->cgi;
   my %seen_name;
   for my $file (@files) {
-    if (defined $cgi->param("description_$file->{id}")) {
-      $file->{description} = $cgi->param("description_$file->{id}");
-      if (defined(my $type = $cgi->param("contentType_$file->{id}"))) {
+    my $id = $file->{id};
+    if (defined $cgi->param("description_$id")) {
+      $file->{description} = $cgi->param("description_$id");
+      if (defined(my $type = $cgi->param("contentType_$id"))) {
        $file->{contentType} = $type;
       }
-      if (defined(my $notes = $cgi->param("notes_$file->{id}"))) {
+      if (defined(my $notes = $cgi->param("notes_$id"))) {
        $file->{notes} = $notes;
       }
-      my $name = $cgi->param("name_$file->{id}");
+      my $name = $cgi->param("name_$id");
       defined $name or $name = $file->{name};
       if (length $name && $name !~ /^\w+$/) {
        return $self->edit_form($req, $article, $articles,
@@ -2778,10 +2780,11 @@ sub filesave {
        return $self->edit_form($req, $article, $articles,
                                "Duplicate file identifier $name");
       }
-      $file->{name} = $name;
-      $file->{download} = 0 + defined $cgi->param("download_$file->{id}");
-      $file->{forSale} = 0 + defined $cgi->param("forSale_$file->{id}");
-      $file->{requireUser} = 0 + defined $cgi->param("requireUser_$file->{id}");
+      $file->{name}          = $name;
+      $file->{download}              = 0 + defined $cgi->param("download_$id");
+      $file->{forSale}       = 0 + defined $cgi->param("forSale_$id");
+      $file->{requireUser}    = 0 + defined $cgi->param("requireUser_$id");
+      $file->{hide_from_list} = 0 + defined $cgi->param("hide_from_list_$id");
     }
   }
   for my $file (@files) {
@@ -2810,7 +2813,7 @@ sub can_remove {
     return;
   }
   if ($article->{id} == $Constants::SHOPID) {
-    $$rmsg = "Sorry, these pages are essential to the store - they cannot be deleted - you may want to hide the the store instead.";
+    $$rmsg = "Sorry, these pages are essential to the store - they cannot be deleted - you may want to hide the store instead.";
     return;
   }
 
index 4885341a2594825648e8da3a8df1356e6332abf8..0e682cdab205979166e79c67ac4771205cc2ed9c 100644 (file)
@@ -230,8 +230,9 @@ sub baseActs {
   my @iter_images;
   my $image_index = -1;
   my $had_image_tags = 0;
-  my @files = sort { $b->{displayOrder} <=> $a->{displayOrder} }
+  my @all_files = sort { $b->{displayOrder} <=> $a->{displayOrder} }
     ArticleFiles->getBy(articleId=>$article->{id});
+  my @files = grep !$_->{hide_from_list}, @all_files;
   
   my $blank = qq!<img src="$IMAGES_URI/trans_pixel.gif"  width="17" height="13" border="0" align="absbottom" alt="" />!;
 
@@ -339,7 +340,7 @@ sub baseActs {
                                 auto_images => !$had_image_tags, 
                                 templater => $templater, 
                                 images => \@images,
-                                files => \@files,
+                                files => \@all_files,
                                 articles => $articles);
      },
 
@@ -896,6 +897,75 @@ Iterates over the files attached to the article, setting the file tag.
 
 Information from the current file in the files iterator.
 
+The file fields are:
+
+=over
+
+=item *
+
+id - identifier for this file
+
+=item *
+
+articleId - article this file belongs to
+
+=item *
+
+displayName - the filename of the file as displayed
+
+=item *
+
+filename - filename of the file as stored on disk,
+
+=item *
+
+sizeInBytes - size of the file in bytes.
+
+=item *
+
+description - the entered description of the file
+
+=item *
+
+contentType - the MIME content type of the file
+
+=item *
+
+displayOrder - number used to control the listing order.
+
+=item *
+
+forSale - non-zero if the file needs to be paid for to be downloaded.
+
+=item *
+
+download - if this is non-zero BSE will attempt to make the browser
+download the file rather than display it.
+
+=item *
+
+whenUploaded - date/time when the file was uploaded.
+
+=item *
+
+requireUser - if non-zero the user must be logged on to download this
+file.
+
+=item *
+
+notes - longer descriptive text.
+
+=item *
+
+name - identifier for the file for filelink[]
+
+=item *
+
+hide_from_list - if non-zero the file won't be listed by the files
+iterator, but will still be available to filelink[].
+
+=back
+
 =back
 
 =head2 Article attributes
index feaec64a352f3f3291f500d4f21b09135f2bd30a..624641419955b874cc48aa0425d474a0b460a780 100644 (file)
@@ -34,6 +34,17 @@ added with 1 unit it will become 11 units instead of 1.
 
 add tags to display the cart on any dynamic page
 
+=item *
+
+files now have a flag to hide them from the files iterator.  This will
+require a change to the admin/filelist.tmpl template in custom
+template sets.
+
+=item *
+
+fixed a repeated "the" in the message from attempting to delete the
+store.
+
 =back
 
 =head2 0.15_40
index 8dca13adb61bec65184e7a422573147e4f2fef75..25e6139c1dc46a2bfe6a5a28bd3a9151ab1fc586 100644 (file)
@@ -31,7 +31,7 @@ iteration - repeat a section of text for each element of a list
 =back
 
 There are also the <:wrap ... :> and <:embed ... :> tags, which are
-described under L<WRAPPING> and L<Embedding tags> respectively.
+described under L</WRAPPING> and L</Embedding tags> respectively.
 
 =head2 Data tags
 
@@ -286,8 +286,8 @@ data problem.
 
 =head2 Embedding tags
 
-To embed the current child article (within an C<E<lt>:iterator begin
-... endE<gt>:> block), use:
+To embed the current child article (within an C<<E<lt>:iterator begin
+... endE<gt>:>> block), use:
 
   <:embed child:>
 
@@ -472,7 +472,7 @@ choice if it's present.
 
 Tags are documented without the <: and :>.
 
-If a tag is documented as C<iterator ...I<name>> then it's an iterator
+If a tag is documented as C<<iterator ...I<name> >> then it's an iterator
 tag and can be used:
 
   <:iterator begin I<name>:>
@@ -1235,6 +1235,75 @@ Iterates over the files attached to the article, setting the file tag.
 
 Information from the current file in the files iterator.
 
+The file fields are:
+
+=over
+
+=item *
+
+id - identifier for this file
+
+=item *
+
+articleId - article this file belongs to
+
+=item *
+
+displayName - the filename of the file as displayed
+
+=item *
+
+filename - filename of the file as stored on disk,
+
+=item *
+
+sizeInBytes - size of the file in bytes.
+
+=item *
+
+description - the entered description of the file
+
+=item *
+
+contentType - the MIME content type of the file
+
+=item *
+
+displayOrder - number used to control the listing order.
+
+=item *
+
+forSale - non-zero if the file needs to be paid for to be downloaded.
+
+=item *
+
+download - if this is non-zero BSE will attempt to make the browser
+download the file rather than display it.
+
+=item *
+
+whenUploaded - date/time when the file was uploaded.
+
+=item *
+
+requireUser - if non-zero the user must be logged on to download this
+file.
+
+=item *
+
+notes - longer descriptive text.
+
+=item *
+
+name - identifier for the file for filelink[]
+
+=item *
+
+hide_from_list - if non-zero the file won't be listed by the files
+iterator, but will still be available to filelink[].
+
+=back
+
 =back
 
 The following tags produce output only in admin mode.
index 362a58a7a50172d324491b242357e2f3583c723e..f6359ffa1b6fafa01c9716d093a28faaf3c3000d 100644 (file)
             </td>
             <td nowrap="nowrap" bgcolor="#FFFFFF"><:help file requireUser:> <:error_img requireUser:></td>
           </tr>
+          <tr> 
+            <th bgcolor="#FFFFFF" align="left">Hide from list:</th>
+            <td bgcolor="#FFFFFF"> 
+              <input type="checkbox" name="hide_from_list" value="1" />
+            </td>
+            <td nowrap="nowrap" bgcolor="#FFFFFF"><:help file hide_from_list:> <:error_img hide_from_list:></td>
+          </tr>
           <tr> 
             <td bgcolor="#FFFFFF" colspan="3" align="right"> 
               <input type="submit" name="fileadd" value="Add File" />
                   <td valign="top" align="center" nowrap="nowrap"> <:if UserCan edit_files_save:article:><input type="checkbox" name="requireUser_<:file id:>"
                     <:ifFile requireUser:> checked<:or:><:eif:> /><:or UserCan:><img src="/images/admin/<:ifFile requireUser:>checked.gif<:or:>unchecked.gif<:eif:>" width="16" height="16" /><:eif UserCan:>Require login 
                     &nbsp;&nbsp;&nbsp;</td>
+                  <td valign="top" align="center" nowrap="nowrap"> <:if UserCan edit_files_save:article:><input type="checkbox" name="hide_from_list_<:file id:>"
+                    <:ifFile hide_from_list:> checked<:or:><:eif:> /><:or UserCan:><img src="/images/admin/<:ifFile hide_from_list:>checked.gif<:or:>unchecked.gif<:eif:>" width="16" height="16" /><:eif UserCan:>Hide from file list 
+                    &nbsp;&nbsp;&nbsp;</td>
                   <td nowrap="nowrap" align="right" width="100%"> <:ifUserCan edit_files_delete:article:><b><a href="<:script:>?filedel=1&amp;id=<:article id:>&amp;file=<:file id:>&_t=file" onClick="return window.confirm('Are you sure you want to delete this File')">Delete</a></b> <:or:><:eif:>
                     <:movefiles:></td>
                 </tr>