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 NoticeDirectory filter : [ all ] / postnuke_official / html / modules / example / pnblocks [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
11 Aug 2002 16:51:05 | postnuke_official/html/modules/example/pnblocks | others.php,NONE,1.1 | Mike |
add example block displaying other items |
Update of /home/cvsroot/postnuke_official/html/modules/example/pnblocks In directory ns7.hostnuke.net:/tmp/cvs-serv11441/pnblocks Added Files: others.php Log Message: add example block displaying other items --- NEW FILE: others.php --- <?php // $Id: others.php,v 1.1 2002/08/11 16:51:03 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: Example Block // ---------------------------------------------------------------------- /** * initialise block */ function example_othersblock_init() { // Security pnSecAddSchema('Example:Othersblock:', 'Block title::'); } /** * get information on block */ function example_othersblock_info() { // Values return array('text_type' => 'Others', 'module' => 'example', 'text_type_long' => 'Show other example items when 1 is displayed', 'allow_multiple' => true, 'form_content' => false, 'form_refresh' => false, 'show_preview' => true); } /** * display block */ function example_othersblock_display($blockinfo) { // See if we are currently displaying an example item // (this variable is set in the user display function) if (!pnVarIsCached('Blocks.example','exid')) { // if not, we don't show this return; } $current_exid = pnVarGetCached('Blocks.example','exid'); if (empty($current_exid) || !is_numeric($current_exid)) { return; } // Security check if (!pnSecAuthAction(0, 'Example:Othersblock:', "$blockinfo[title]::", ACCESS_READ)) { return; } // Get variables from content block $vars = @unserialize($blockinfo['content']); // Defaults if (empty($vars['numitems'])) { $vars['numitems'] = 5; } // Database information pnModDBInfoLoad('example'); list($dbconn) = pnDBGetConn(); $pntable =pnDBGetTables(); $exampletable = $pntable['example']; // Query $sql = "SELECT pn_exid, pn_name FROM $exampletable WHERE pn_exid != '" . pnVarPrepForStore($current_exid) . "' ORDER by pn_exid DESC"; $result = $dbconn->SelectLimit($sql, $vars['numitems']); if ($dbconn->ErrorNo() != 0) { return; } if ($result->EOF) { return; } // Create output object $output = new pnHTML(); // Display each item, permissions permitting for (; !$result->EOF; $result->MoveNext()) { list($exid, $name) = $result->fields; if (pnSecAuthAction(0, 'Example::', "$name::$exid", ACCESS_OVERVIEW)) { if (pnSecAuthAction(0, 'Example::', "$name::$exid", ACCESS_READ)) { $output->URL(pnModURL('example', 'user', 'display', array('exid' => $exid)), $name); } else { $output->Text($name); } $output->Linebreak(); } } $output->Linebreak(); // TODO: shouldn't this stuff be BL-able too ?? // Besides the fact that title & content are placed according to some // master block template, why can't we create content via BL ? // Populate block info and pass to theme $blockinfo['content'] = $output->GetOutput(); return $blockinfo; } /** * modify block settings */ function example_othersblock_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 example_othersblock_update($blockinfo) { $vars['numitems'] = pnVarCleanFromInput('numitems'); // Define a default block title if (empty($blockinfo['title'])) { $blockinfo['title'] = pnML('Other example items'); } $blockinfo['content'] = serialize($vars); return $blockinfo; } /** * built-in block help/information system. */ function example_othersblock_help() { $output = new pnHTML(); $output->SetInputMode(_PNH_VERBATIMINPUT); $output->Text('Any related 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(); } ?>
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 |