Catalog

 view release on metacpan or  search on metacpan

lib/Catalog.pm  view on Meta::CPAN

			my($count) = $rows->{$letter};
			my($html);
			if($count > 0) {
			    $html = "<a href='$url&letter=$letter'>$letter</a> ($count)";
			} else {
			    $html = $letter;
			}
			$assoc->{$tag} = $html;
		    }
		} else {
		    $assoc->{$tag} = '';
		}
	    }
	}
	
	return $self->stemplate_build($template);
    } else {
	$self->cerror("no entries for this letter in $name") if($letter eq 'none');
	return $self->catalog_searcher("calpha", $catalog->{'tablename'}, { 'mode' => 'cbrowse'}, " $catalog->{'fieldname'} like '$letter\%' ", "letter");
	
    }
}

#
# HTML force recalculation of the cached data for alpha catalog
#
sub calpha_count {
    my($self, $cgi) = @_;
    $self->{'cgi'} = $cgi;

    my($name) = $cgi->param('name');

    #
    # Force recalculation at first browsing action
    #
    $self->calpha_count_api($name);

    return $self->ccontrol_panel(Catalog::tools::cgi->new({'context' => 'ccontrol_panel'}));
}

#
# HTML display a date catalog
#
sub cdate {
    my($self, $cgi) = @_;
    $self->{'cgi'} = $cgi;
    my($ccatalog) = $self->cinfo();

    my($name) = $cgi->param('name');
    my($catalog) = $ccatalog->{$name};

    my(%intervals) = $self->cdate_cgi2intervals($cgi);

    my($day) = 24 * 60 * 60;
    if((($catalog->{'updated'} || 0) < time() - $day) ||
       ($self->db()->exec_select_one("select count(*) as count from catalog_date_$name")->{'count'} <= 0)) {
	$self->cdate_count_1_api($name);
    }

    #
    # Try to load the most specific template first, then backup to
    # cdate_default if none is found.
    #
    my($prefix) = $cgi->param('template') ? "cdate_" . $cgi->param('template') : "cdate_default";
    my($template) = template_load("$prefix.html", $self->{'templates'}, $cgi->param('style'));
    if(!defined($template)) {
	$template = $self->template("cdate_default");
    }

    #
    # Format the index
    #
    if(exists($template->{'children'}->{'years'})) {
	$self->cdate_index($template->{'children'}->{'years'}, $intervals{'index'},
			   {
			       'complement' => '0101',
			       'length' => 4,
			       'format' => '%Y',
			       'order' => 'tag desc',
			       'tag_ftag' => 'YEARFORMATED',
			       'tag_link' => 'YEARLINK',
			       'tag_date' => 'YEARDATE',
			       'next_period' => 'months',
			       },
			   {
			       'complement' => '01',
			       'length' => 6,
			       'format' => '%M %Y',
			       'order' => 'tag desc',
			       'tag_ftag' => 'MONTHFORMATED',
			       'tag_link' => 'MONTHLINK',
			       'tag_date' => 'MONTHDATE',
			       'next_period' => 'days',
			       },
			   {
			       'complement' => '',
			       'length' => 8,
			       'format' => '%d %M %Y',
			       'tag_ftag' => 'DAYFORMATED',
			       'tag_link' => 'DAYLINK',
			       'tag_date' => 'DAYDATE',
			       'order' => 'tag desc',
			       });
    }

    #
    # Format the record list
    #
    if(exists($template->{'children'}->{'records'})) {
	$self->cdate_records($template->{'children'}->{'records'}, $intervals{'records'});
    }
    
    return $self->stemplate_build($template);
}

#
# HTML display a data catalog calendar
#
sub cdate_index {
    my($self, $template, $interval, $spec, @specs) = @_;



( run in 1.026 second using v1.01-cache-2.11-cpan-39bf76dae61 )