Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_modules / articles / pnblocks [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
16 Aug 2002 14:18:11postnuke_modules/articles/pnblockstopitems.php,NONE,1.1 related.php,1.3,1.4Mike
 block stuff

Update of /home/cvsroot/postnuke_modules/articles/pnblocks
In directory ns7.hostnuke.net:/tmp/cvs-serv7188

Modified Files:
	related.php 
Added Files:
	topitems.php 
Log Message:
block stuff


--- NEW FILE: topitems.php ---
<?php // $Id: topitems.php,v 1.1 2002/08/16 14:18:09 mikespub Exp $
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// PostNuke Content Management System
// Copyright (C) 2002 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jim McDonald
// Purpose of file:  Articles administration display functions
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Original Author of file: Jim McDonald
// Purpose of file: Articles Block
// ----------------------------------------------------------------------

/**
 * initialise block
 */
function articles_topitemsblock_init()
{
    // Security
    pnSecAddSchema('Articles:Topitemsblock:', 'Block title::');
}

/**
 * get information on block
 */
function articles_topitemsblock_info()
{
    // Values
    return array('text_type' => 'Top Items',
                 'module' => 'articles',
                 'text_type_long' => 'Show top articles',
                 'allow_multiple' => false,
                 'form_content' => false,
                 'form_refresh' => false,
                 'show_preview' => true);
}

/**
 * display block
 */
function articles_topitemsblock_display($blockinfo)
{
    // Security check
    if (!pnSecAuthAction(0,
                         'Articles:Topitemsblock:',
                         "$blockinfo[title]::",
                         ACCESS_READ)) {
        return;
    }

    // Get variables from content block
    $vars = @unserialize($blockinfo['content']);

    // Defaults
    if (empty($vars['numitems'])) {
        $vars['numitems'] = 5;
    }

    // Load articles user API
    if (!pnModAPILoad('articles','user')) {
        return;
    }
    // Load hitcount user API
    if (!pnModAPILoad('hitcount','user')) {
        return;
    }
    $tophits = pnModAPIFunc('hitcount','user','tophits',
                            array('modname' => 'articles',
                                  'numitems' => $vars['numitems']));
    $aids = array();
    foreach ($tophits as $topitem) {
       $aids[] = $topitem['itemid'];
    }
    $articles = pnModAPIFunc('articles','user','getlist',
                             array('aids' => $aids));

    // see if we're currently displaying an article
    if (pnVarIsCached('Blocks.articles','aid')) {
        $curaid = pnVarGetCached('Blocks.articles','aid');
    } else {
        $curaid = -1;
    }

// TODO: shouldn't this stuff be BL-able too ??
// Besides the fact that title & content are placed according to some
// master block articles, why can't we create content via BL ?

    // Create output object
    $output = new pnHTML();

    $links = 0;
    foreach ($tophits as $topitem) {
        $aid = $topitem['itemid'];
        if ($curaid == $aid) {
            $output->Text(pnVarPrepForDisplay($articles[$aid]['title']));
        } else {
            $output->URL(pnModURL('articles',
                                  'user',
                                  'display',
                                  array('aid' => $aid,
                                       'ptid' => $articles[$aid]['pubtypeid'])),
                             pnVarPrepForDisplay($articles[$aid]['title']));
        }
        $output->Text(' (' . $topitem['hits'] . ' )');
        $output->Linebreak();
        $links++;
    }
    $output->Linebreak();

    // Populate block info and pass to theme
    if ($links > 0) {
        $blockinfo['content'] = $output->GetOutput();
        return $blockinfo;
    }
}


/**
 * modify block settings
 */
function articles_topitemsblock_modify($blockinfo)
{
    // Create output object
    $output = new pnHTML();

    // Get current content
    $vars = @unserialize($blockinfo['content']);

    // Defaults
    if (empty($vars['numitems'])) {
        $vars['numitems'] = 5;
    }

    // Create row
    $row = array();
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $row[] = $output->Text(_NUMITEMS);
    $row[] = $output->FormText('numitems',
                               pnVarPrepForDisplay($vars['numitems']),
                               5,
                               5);
    $output->SetOutputMode(_PNH_KEEPOUTPUT);

    // Add row
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->TableAddRow($row, 'left');
    $output->SetInputMode(_PNH_PARSEINPUT);

    // Return output
    return $output->GetOutput();
}

/**
 * update block settings
 */
function articles_topitemsblock_update($blockinfo)
{
    $vars['numitems'] = pnVarCleanFromInput('numitems');

    $blockinfo['content'] = serialize($vars);

    return $blockinfo;
}

/**
 * built-in block help/information system.
 */
function articles_topitemsblock_help()
{
    $output = new pnHTML();

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text('Any topitems block info should be placed in your modname_blocknameblock_help() function.');
    $output->LineBreak(2);
    $output->Text('More information.');
    $output->SetInputMode(_PNH_PARSEINPUT);

    return $output->GetOutput();
}

?>

Index: related.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnblocks/related.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** related.php	9 Aug 2002 00:00:43 -0000	1.3
--- related.php	16 Aug 2002 14:18:09 -0000	1.4
***************
*** 156,159 ****
--- 156,160 ----
              $links++;
          }
+         $output->Linebreak();
      }
      // Show categories (for now)


Directory filter : [ all ] / postnuke_modules / articles / pnblocks [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3