# !!!HARDCODED DATA!!! - common data with [rebless] # Note: for ease of use hash key names are the same as # the section id used by Update Master Faqlist, if # one exists. (Note: pmdv chosen rather than pmd to # avoid confusion with [PMD] (Perl Monks Discussion) # # faq SiteDocClan documentation # tut Tutorials # pmdv pmdev documentation # cqa Categorized QandA # # array elements in $hNodetypes values: # [0] = type label for nodelet links # [1] = id of master list for nodetype # [2] = 1 if rendered using get_sitedoclet # 0 if not my $hAllDocballs = { faq => { masterlist => 481919 , altview => "SDC View" , RJEfilter => 'SDC' , usergroup => 'SiteDocClan' , listtype => 'faqlist' , stringtype => 'faqstring' , reblessable => [qw(sitedoclet sitefaqlet alphafaqlet)] , nodetypes => { sitefaqlet => ['faq',1, 48286] , sitedoclet => ['doc',1, 482316, 1] , alphafaqlet => ['alpha',1,481721] , faqlist => ['faqlist',0,481919] , faqstring => ['faqstring'] } } , tut => { masterlist => 743094 , altview => 'Pedagogue View' , RJEfilter => 'Ped' , usergroup => 'Pedagogues' , listtype => 'tutlist' , stringtype => 'tutstring' , reblessable => [] , nodetypes => { tutlist => ['list', 743094] , tutstring => ['string', 743096] , perltutorial => ['tut', 743095] } } , cqa => { masterlist => undef , altview => 'QandAEditors View' , usergroup => 'QandAEditors' , listtype => 'catqalist' , stringtype => 'catqastring' , reblessable => [] , nodetypes => { catqalist => ['list', undef] , catqastring => ['string', undef] , 'categorized question' => ['q',undef] , 'categorized answer' => ['a',undef] } } , pmdv => { masterlist => ???? , altview => "PDM View" , usergroup => 'pmdev' , listtype => 'pmdvlist' , stringtype => 'pmdvstring' , reblessable => [qw(pmdvfaqlet,pmdvdoclet)] , nodetypes => { pmdvfaqlet => ['faq',1, ????] , pmdvdoclet => ['doc',1, ????, 1] , pmdvlist => ['list', ????] , pmdvstring => ['string', ????] } } }; my $hBogus = { masterlist => undef , altview => "Abnormal View" , usergroup => undef , listtype => undef , stringtype => undef , reblessable => undef # empty nodetype hash flags this as bogus , nodetypes => {} } }; # If a user group is the assigned editor for more # than one docball, then we need to find the primary # one when $id_type = 'usergroup'. This hash keeps # track of each group's primary docball. my $hUsergroupDocballs = { SiteDocClan => 'faq' , pmdev => 'pmdv' , Pedagogues => 'tut' , QandAEditors => 'cqa' }; # END (hardcoded data) # NOTE: if docballs were set up as a nodetype, then # $keytype 'node' should also be added # # $docball_id id of docball - depends on $keytype # $id_type type of identifier # may be one of the following strings: # list - id is list nodetype # section - id is master list section # usergroup - id is user group. # primary docball for user group will # be returned # all - hash keyed by section # containing all docballs # bogus - hash for bogus docball. # (scalar keys $hBogus->{nodetypes} # is always 0) # defaults to section my ($docball_id, $id_type) = @_; $id_type = 'section' unless defined($id_type); # Returning references SHOULD work. # Even though the Everything Bible says that htmlcode # nodes must return a string, in reality # Everything::HTML::htmlcode returns in scalar context # whatever eval returns (unless there is a warning or # exception in which case it stringifies the return # result and appends the error message). if ($id_type eq 'all') { return $hAllDocballs; } elsif ($id_type eq 'section') { return $hAllDocballs->{$docball_id} if exists($hAllDocballs->{$docball_id}); } elsif ($id_type eq 'list') { # assume that each docball has its own list type # and so uniquely identifies a docball # otherwise why would we need a separate docball? foreach $k (keys %$hAllDocballs) { $v = $hAllDocballs->{$k}; return $v if ($v->{listtype} eq $docball_id); } } elsif ($id_type eq 'usergroup') { my $k = $hUsergroupDocballs->{$id_type}; return $hAllDocballs->{$docball_id} if (defined($k) && exists($hAllDocballs->{$k})); } return $hBogus; #not a docball