diff options
| -rw-r--r-- | LibertyContent.php | 81 | ||||
| -rwxr-xr-x | LibertySystem.php | 10 | ||||
| -rw-r--r-- | edit_structure_inc.php | 40 | ||||
| -rw-r--r-- | get_content_list_inc.php | 6 | ||||
| -rw-r--r-- | list_content.php | 3 | ||||
| -rw-r--r-- | modules/mod_last_changes.php | 5 | ||||
| -rw-r--r-- | modules/mod_last_changes.tpl | 6 | ||||
| -rw-r--r-- | plugins/data.code.php | 62 | ||||
| -rw-r--r-- | plugins/data.example.php | 203 | ||||
| -rw-r--r-- | plugins/format.pearwiki.php | 4 | ||||
| -rw-r--r-- | plugins/format.pearwiki_tiki.php | 4 | ||||
| -rw-r--r-- | plugins/format.tikihtml.php | 4 | ||||
| -rw-r--r-- | plugins/format.tikiwiki.php | 4 | ||||
| -rw-r--r-- | templates/edit_structure_content.tpl | 20 | ||||
| -rw-r--r-- | templates/list_content_inc.tpl | 27 |
15 files changed, 197 insertions, 282 deletions
diff --git a/LibertyContent.php b/LibertyContent.php index 207e14f..5093c97 100644 --- a/LibertyContent.php +++ b/LibertyContent.php @@ -3,7 +3,7 @@ * Management of Liberty content * * @author spider <spider@steelsun.com> -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @package Liberty */ @@ -19,7 +19,7 @@ // | Authors: spider <spider@steelsun.com> // +----------------------------------------------------------------------+ // -// $Id: LibertyContent.php,v 1.3 2005/06/28 07:45:47 spiderr Exp $ +// $Id: LibertyContent.php,v 1.4 2005/07/25 20:02:12 squareing Exp $ // define( 'CONTENT_TYPE_WIKI', '1' ); // define( 'CONTENT_TYPE_COMMENT', '3' ); @@ -582,42 +582,65 @@ class LibertyContent extends LibertyBase { $gateFrom = ''; if (is_array($find)) { // you can use an array of pages - $mid = " WHERE tc.`title` IN (".implode(',',array_fill(0,count($find),'?')).")"; + $mid = " tc.`title` IN (".implode(',',array_fill(0,count($find),'?')).")"; $bindVars[] = $find; } elseif (!empty($find) && is_string($find)) { // or a string - $mid = " WHERE UPPER(tc.`title`) like ? "; + $mid = " UPPER(tc.`title`) like ? "; $bindVars[] = ('%' . strtoupper( $find ) . '%'); } - if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) { - empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND '; - $gateSelect .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` '; - $gateFrom .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` )"; - $mid .= ' (tcs.`security_id` IS NULL OR tc.`user_id`=?) '; - $bindVars[] = $gBitUser->mUserId; - } - if( !empty( $pUserId ) ) { - empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND '; - $mid .= " tc.`user_id` = ? "; + $mid .= " AND tc.`user_id` = ? "; $bindVars[] = $pUserId; } if( !empty( $pContentGuid ) ) { - empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND '; - $mid .= ' `content_type_guid`=? '; + $mid .= ' AND `content_type_guid`=? '; $bindVars[] = $pContentGuid; } + if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) { + $gateSelect .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` '; + $gateFrom .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` )"; + $mid .= ' AND (tcs.`security_id` IS NULL OR tc.`user_id`=?) '; + $bindVars[] = $gBitUser->mUserId; + if( $gBitSystem->isPackageActive( 'fisheye' ) ) { + // This is really ugly to have in here, and really would be better off somewhere else. + // However, because of the specific nature of the current implementation of fisheye galleries, I am afraid + // this is the only place it can go to properly enforce gatekeeper protections. Hopefully a new content generic + // solution will be available in ReleaseTwo - spiderr + if( $this->mDb->isAdvancedPostgresEnabled() ) { +// $gateFrom .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim ON (tfgim.`item_content_id`=tc.`content_id`)"; + $mid .= " AND (SELECT ts.`security_id` FROM connectby('tiki_fisheye_gallery_image_map', 'gallery_content_id', 'item_content_id', tc.`content_id`, 0, '/') AS t(`cb_gallery_content_id` int, `cb_item_content_id` int, level int, branch text), `".BIT_DB_PREFIX."tiki_content_security_map` tcsm, `".BIT_DB_PREFIX."tiki_security` ts + WHERE ts.`security_id`=tcsm.`security_id` AND tcsm.`content_id`=`cb_gallery_content_id` LIMIT 1) IS NULL"; + } + } + } + + if( in_array( $sort_mode, array( + 'modifier_user_desc', + 'modifier_user_asc', + 'modifier_real_name_desc', + 'modifier_real_name_asc', + 'creator_user_desc', + 'creator_user_asc', + 'creator_real_name_desc', + 'creator_real_name_asc', + ))) { + $orderTable = ''; + } else { + $orderTable = 'tc.'; + } + // If sort mode is versions then offset is 0, maxRecords is -1 (again) and sort_mode is nil // If sort mode is links then offset is 0, maxRecords is -1 (again) and sort_mode is nil // If sort mode is backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil $query = "SELECT uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name`, uue.`user_id` AS `modifier_user_id`, uuc.`login` AS`creator_user`, uuc.`real_name` AS `creator_real_name`, uuc.`user_id` AS `creator_user_id`, `hits`, tc.`title`, tc.`last_modified`, tc.`content_type_guid`, `ip`, tc.`content_id` $gateSelect FROM `".BIT_DB_PREFIX."tiki_content` tc $gateFrom, `".BIT_DB_PREFIX."users_users` uue, `".BIT_DB_PREFIX."users_users` uuc - ".(!empty( $mid ) ? $mid.' AND ' : ' WHERE ')." tc.`modifier_user_id`=uue.`user_id` AND tc.`user_id`=uuc.`user_id` - ORDER BY tc.".$this->convert_sortmode($sort_mode); + WHERE tc.`modifier_user_id`=uue.`user_id` AND tc.`user_id`=uuc.`user_id` $mid + ORDER BY ".$orderTable.$this->convert_sortmode($sort_mode); $query_cant = "select count(*) FROM `".BIT_DB_PREFIX."tiki_content` tc $gateFrom $mid"; // previous cant query - updated by xing // $query_cant = "select count(*) from `".BIT_DB_PREFIX."tiki_pages` tp INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tp.`content_id`) $mid"; @@ -629,26 +652,26 @@ class LibertyContent extends LibertyBase { $aux = array(); $aux = $res; if( !empty( $contentTypes[$res['content_type_guid']] ) ) { - $contentHash = &$contentTypes[$res['content_type_guid']]; - if( empty( $contentHash['content_object'] ) ) { - include_once( $gBitSystem->mPackages[$contentHash['handler_package']]['path'].$contentHash['handler_file'] ); - $contentHash['content_object'] = new $contentHash['handler_class'](); + // quick alias for code readability + $type = &$contentTypes[$res['content_type_guid']]; + if( empty( $type['content_object'] ) ) { + // create *one* object for each object *type* to call virtual methods. + include_once( $gBitSystem->mPackages[$type['handler_package']]['path'].$type['handler_file'] ); + $type['content_object'] = new $type['handler_class'](); } $aux['creator'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] ); $aux['real_name'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] ); $aux['editor'] = (isset( $res['modifier_real_name'] ) ? $res['modifier_real_name'] : $res['modifier_user'] ); - $aux['content_description'] = $contentHash['content_description']; + $aux['content_description'] = $type['content_description']; //WIKI_PKG_URL."index.php?page_d=".$res['page_id']; $aux['user'] = $res['creator_user']; $aux['real_name'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] ); $aux['user_id'] = $res['creator_user_id']; require_once $smarty->_get_plugin_filepath( 'modifier', 'bit_long_date' ); - $aux['display_link'] = - '<a title="'.tra( 'Last modified by' ).': '.$gBitUser->getDisplayName( FALSE, $aux ).' - '.smarty_modifier_bit_long_date( $aux['last_modified'], $smarty ). - '" href="'.BIT_ROOT_URL.'index.php?content_id='.$aux['content_id'].'">'. - $contentHash['content_object']->getTitle( $aux ). - '</a>'; -// $aux['display_url'] = $contentType['content_object']->getDisplayUrl( $aux['title'], $aux ); + $aux['display_link'] = $type['content_object']->getDisplayLink( $aux['title'], $aux ); + // getDisplayUrl is currently a pure virtual method in LibertyContent, so this cannot be called currently +// $aux['display_url'] = $type['content_object']->getDisplayUrl( $aux['title'], $aux ); + $aux['title'] = $type['content_object']->getTitle( $aux ); $ret[] = $aux; } } diff --git a/LibertySystem.php b/LibertySystem.php index 64cd8f6..06febba 100755 --- a/LibertySystem.php +++ b/LibertySystem.php @@ -3,7 +3,7 @@ * System class for handling the liberty package * * @author spider <spider@steelsun.com> -* @version $Revision: 1.2 $ +* @version $Revision: 1.3 $ * @package Liberty */ @@ -19,7 +19,7 @@ // | Authors: spider <spider@steelsun.com> // +----------------------------------------------------------------------+ // -// $Id: LibertySystem.php,v 1.2 2005/06/28 07:45:47 spiderr Exp $ +// $Id: LibertySystem.php,v 1.3 2005/07/25 20:02:13 squareing Exp $ /** * Local base defines */ @@ -40,7 +40,7 @@ require_once( LIBERTY_PKG_PATH.'LibertyBase.php' ); * System class for handling the liberty package * * @author spider <spider@steelsun.com> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @package Liberty * @subpackage LibertySystem */ @@ -283,11 +283,11 @@ function parse_data_plugins(&$data, &$preparsed, &$noparsed, &$pParser ) { if( $ret = $loadFunc( $plugin_data, $arguments ) ) { // temporarily replace end of lines so tables and other things render properly // $ret = preg_replace( "/\n/", '#EOL', $ret ); + // Handle pre- & no-parse sections and plugins inserted by this plugin if( is_object( $pParser ) ) { // we were passed in a parser object, assume tikiwiki that has parse_first method - // SPIDERKILL - this was causing apache segfaults. ~np~'s are caught on the way out of parse_first anyway -// $pParser->parse_pp_np( $ret, $preparsed, $noparsed ); + $pParser->parse_pp_np( $ret, $preparsed, $noparsed ); } else { // just nuke all np/pp for now in non tikiwiki formats $ret = preg_replace( "/\~(\/?)[np]p\~/", '', $ret ); diff --git a/edit_structure_inc.php b/edit_structure_inc.php index 3288d23..3b21d73 100644 --- a/edit_structure_inc.php +++ b/edit_structure_inc.php @@ -3,7 +3,7 @@ * edit_structure_inc * * @author Christian Fowler - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Liberty * @subpackage functions */ @@ -39,48 +39,32 @@ if( empty( $_REQUEST["structure_id"] ) ) { $rootStructure->loadPath(); } - if( ($gBitUser->mUserId!=$rootStructure->mInfo['user_id']) ) { - $gBitSystem->verifyPermission( 'bit_p_admin_books' ); + if( ( $gBitUser->mUserId != $rootStructure->mInfo['user_id'] ) ) { + $gBitSystem->verifyPermission( !empty( $verifyStructurePermission ) ? $verifyStructurePermission : 'bit_p_admin' ); } $smarty->assign_by_ref( 'gStructure', $gStructure ); $smarty->assign('structureInfo', $gStructure->mInfo); - if (isset($_REQUEST["find_objects"])) { - $find_objects = $_REQUEST["find_objects"]; - } else { - $find_objects = ''; - } - // Store the actively stored structure name $gBitUser->storePreference( 'edit_structure_name', $rootStructure->mInfo['title'] ); $gBitUser->storePreference( 'edit_structure_id', $rootStructure->mStructureId ); - // Get all wiki pages for the dropdown menu - $contentSelect = !isset( $_REQUEST['content_type'] ) ? 'bitpage' : $_REQUEST['content_type']; -if( empty( $gContent ) ) { - require_once( WIKI_PKG_PATH.'lookup_page_inc.php' ); -} - - $listpages = $gContent->getContentList( $contentSelect, 0, 500, 'title_asc', $find_objects); - $smarty->assign_by_ref('listContent', $listpages["data"]); - $smarty->assign('contentSelect', $contentSelect); - - $contentTypes = array(); - foreach( $gLibertySystem->mContentTypes as $cType ) { - $contentTypes[$cType['content_type_guid']] = $cType['content_description']; + include_once( LIBERTY_PKG_PATH.'get_content_list_inc.php' ); + foreach( $contentList['data'] as $cItem ) { + $cList[$contentTypes[$cItem['content_type_guid']]][$cItem['content_id']] = $cItem['title'].' [id: '.$cItem['content_id'].']'; } - $smarty->assign_by_ref('contentTypes', $contentTypes); - - + $smarty->assign( 'contentList', $cList ); + $smarty->assign( 'contentSelect', $contentSelect ); + $smarty->assign( 'contentTypes', $contentTypes ); + $smarty->assign( 'contentTypes', $contentTypes ); $subpages = $gStructure->s_get_pages($_REQUEST["structure_id"]); $max = count($subpages); $smarty->assign_by_ref('subpages', $subpages); if ($max != 0) { - $last_child = $subpages[$max - 1]; - $smarty->assign('insert_after', $last_child["structure_id"]); + $last_child = $subpages[$max - 1]; + $smarty->assign('insert_after', $last_child["structure_id"]); } - $smarty->assign('find_objects', $find_objects); if( ( isset( $_REQUEST["action"] ) && ( $_REQUEST["action"] == 'remove' ) ) || isset( $_REQUEST["confirm"] ) ) { diff --git a/get_content_list_inc.php b/get_content_list_inc.php index 1ecb259..b23622b 100644 --- a/get_content_list_inc.php +++ b/get_content_list_inc.php @@ -3,7 +3,7 @@ * get_content_list * * @author Christian Fowler> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @package Liberty * @subpackage functions */ @@ -19,12 +19,12 @@ if( empty( $gContent ) || !is_object( $gContent ) ) { $gContent = new LibertyContent(); } -$contentSelect = empty( $_REQUEST['content_type'] ) ? NULL : $_REQUEST['content_type']; +$contentSelect = empty( $_REQUEST['content_type_guid'] ) ? NULL : $_REQUEST['content_type_guid']; // get_content_list_inc doesn't use $_REQUEST parameters as it might not be the only list in the page that needs sorting and limiting $contentList = $gContent->getContentList( $contentSelect, isset( $offset_content ) ? $offset_content : 0, isset( $max_content ) ? $max_content : 500, isset( $content_sort_mode ) ? $content_sort_mode : 'title_asc', empty( $_REQUEST["find_objects"] ) ? NULL : $_REQUEST["find_objects"], isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : NULL ); -$contentTypes = array(); +$contentTypes = array( '' => tra( 'All Content' ) ); foreach( $gLibertySystem->mContentTypes as $cType ) { $contentTypes[$cType['content_type_guid']] = $cType['content_description']; } diff --git a/list_content.php b/list_content.php index 52ade1d..a7bff96 100644 --- a/list_content.php +++ b/list_content.php @@ -3,7 +3,7 @@ * list_content * * @author spider <spider@steelsun.com> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Liberty * @subpackage functions */ @@ -36,6 +36,7 @@ $smarty->assign( 'numPages', $numPages ); $smarty->assign( 'contentSelect', $contentSelect ); $smarty->assign( 'contentTypes', $contentTypes ); $smarty->assign( 'contentList', $contentList['data'] ); +$smarty->assign( 'contentCount', $contentList['cant'] ); $gBitSystem->setBrowserTitle( 'List Content' ); $gBitSystem->display( 'bitpackage:liberty/list_content.tpl' ); diff --git a/modules/mod_last_changes.php b/modules/mod_last_changes.php index b3f3050..2866506 100644 --- a/modules/mod_last_changes.php +++ b/modules/mod_last_changes.php @@ -1,5 +1,5 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.php,v 1.2 2005/06/28 07:45:48 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.php,v 1.3 2005/07/25 20:02:13 squareing Exp $ /** * Params: * - content_type_guid : if set, show only those content_type_guid's @@ -20,8 +20,9 @@ if( !empty( $gQueryUser->mUserId ) ) { if( empty( $module_title ) ) { if( !empty( $module_params['content_type_guid'] ) && !empty( $gLibertySystem->mContentTypes[$module_params['content_type_guid']] ) ) { $title = tra( "Last Changes" ).': '.tra( $gLibertySystem->mContentTypes[$module_params['content_type_guid']]['content_description'] ); + $smarty->assign( 'contentType', $module_params['content_type_guid'] ); } else { - $smarty->assign( 'showContentType', TRUE ); + $smarty->assign( 'contentType', FALSE ); $title = tra( "Last Changes" ); } $smarty->assign( 'moduleTitle', $title ); diff --git a/modules/mod_last_changes.tpl b/modules/mod_last_changes.tpl index b1b52ce..28edb99 100644 --- a/modules/mod_last_changes.tpl +++ b/modules/mod_last_changes.tpl @@ -1,11 +1,11 @@ -{* $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.tpl,v 1.1 2005/06/19 04:55:51 bitweaver Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.tpl,v 1.2 2005/07/25 20:02:13 squareing Exp $ *} {strip} {if $modLastContent} {bitmodule title="$moduleTitle" name="last_changes"} <ol> {section name=ix loop=$modLastContent} <li> - {if $showContentType } + {if !$contentType } <strong>{tr}{$modLastContent[ix].content_description}{/tr}: </strong> {/if} {$modLastContent[ix].display_link} @@ -17,7 +17,7 @@ <li></li> {/section} </ol> - <a href="{$gBitLoc.LIBERTY_PKG_URL}list_content.php?user_id={$gQueryUserId}&sort_mode=last_modified_desc">{tr}View more{/tr}…</a> + <a href="{$gBitLoc.LIBERTY_PKG_URL}list_content.php?user_id={$gQueryUserId}&sort_mode=last_modified_desc{if $contentType}&content_type_guid={$contentType}{/if}">{tr}View more{/tr}…</a> {/bitmodule} {/if} {/strip} diff --git a/plugins/data.code.php b/plugins/data.code.php index f825dc7..cb0a32f 100644 --- a/plugins/data.code.php +++ b/plugins/data.code.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Liberty * @subpackage plugins_data */ @@ -17,7 +17,7 @@ // | Reworked for Bitweaver (& Undoubtedly Screwed-Up) // | by: StarRider <starrrider@users.sourceforge.net> // +----------------------------------------------------------------------+ -// $Id: data.code.php,v 1.3 2005/07/17 17:36:09 squareing Exp $ +// $Id: data.code.php,v 1.4 2005/07/25 20:02:13 squareing Exp $ /** * definitions @@ -50,13 +50,29 @@ function data_code_help() { .'<tr class="odd">' .'<td>source</td>' .'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Defines the format of the Source Code Snippet. Possible values are:") . ' <strong>HTML or PHP</strong>. ' - . tra("The Default = ") . '<strong>HTML</strong></td>' + .'<td>' . tra( "Defines the format of the Source Code Snippet. Possible values are:"); + if( file_exists( UTIL_PKG_PATH.'geshi/geshi.php' ) ) { + $help = $help . '<br /><strong>ActionScript / Ada / Apache Log File=Apache / ASM (NASM based)=Asm / ASP / Bash / C ' + .'/ C for Macs=C_Mac / AutoCAD DCL=CadDcl / AutoCAD LISP=CadLisp / C++=Cpp / C#=CSharp / CSS / D ' + .'/ Delphi / Diff Output=Diff / HTML (4.0.1)=Html4Strict / Java / JavaScript / Lisp / Lua / MatLab ' + .'/ MpAsm / NullSoft Installer=Niss / Objective C=ObjC / OpenOffice.org Basic=OoBas / Oracle8' + .'/ Pascal / Perl / Php / Php_Brief / Python / QuickBasic=QBasic / Smarty / SQL / VisualBasic=Vb ' + .'/ VB.NET=VbNet / VHDL / VisualFoxPro / XML</strong>. '; + } else { + $help = $help .'HTML or PHP</strong>. '; + } + $help = $help . '<br />' . tra("The Default = ") . '<strong>PHP</strong></td>' .'</tr>' .'<tr class="even">' .'<td>num</td>' - .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Determins if line numbers are displayed. Passing") . ' <strong>TRUE, ON, or YES</strong> ' . tra("in this parameter will make it") . ' <strong>TRUE</strong>. ' . tra("Any ohter value will make it") . ' <strong>FALSE</strong>' . tra("The Default =") . ' <strong>FALSE</strong> ' . tra("so Line Numbers are not displayed.") . '</td>' + .'<td>' .tra( "boolean/number") .'<br />'. tra("(optional)") . '</td>' + .'<td>' .tra( "Determins if Line Numbers are displayed with the code. Specifing:") + .'<strong>TRUE / ON / YES /</strong> or a <strong>Number</strong> ' + .tra("will turn <strong>Line Numbering On</strong>. When a Number is specified - the Number is used for the first ") + .tra("line instead of <strong>1</strong>. Any ohter value will turn <strong>Line Numbering OFF</strong> ") + .tra("and only the <strong>Code</strong> will be displayed.") + .'<br />' . tra("The Default =") .' <strong>FALSE</strong> ' .tra("Line Numbers are <strong>Not</strong> displayed.") + .'</td>' .'</tr>' .'</table>' . tra("Example: ") . "{CODE source='php' num='on' }" . tra("Sorce Code Snippet") . "{code}"; @@ -73,41 +89,46 @@ function decodeHTML($string) { function data_code( $data, $params ) { // Pre-Clyde Changes // Parameters were $In & $Colors // Added testing to maintain Pre-Clyde compatability - $num = NULL; +// $num = NULL; $add_tags = false; extract ($params); // This maintains Pre-Clyde Parameters - if (isset($colors) and ($colors == 'php') ) $source = 'HTML'; + if (isset($colors) and ($colors == 'php') ) $source = 'php'; if (isset($in) ) $source = $in; - $source = isset($source) ? strtoupper($source) : 'HTML'; // if not specified the default is HTML - if (isset($in) and ($in == 1) ) $num = 'ON'; // This maintains Pre-Clyde Parameters - switch (strtoupper($num)) { - case 'TRUE': case 'ON': case 'YES': - $num = 1; - break; - default: // could have done FALSE/OFF/NO but we want any other value to be False - $num = 0; - break; - } + $source = isset($source) ? strtolower($source) : 'php'; // if not specified the default is HTML + if (isset($in)) $num = $in; // This maintains Pre-Clyde Parameters + if (isset($num) && (!is_numeric ($num))) { + switch (strtoupper($num)) { + case 'TRUE': case 'ON': case 'YES': + $num = 1; + break; + default: // could have done FALSE/OFF/NO but we want any other value to be False + $num = 0; + break; + } } + $num = (isset($num)) ? $num : FALSE; + $code = ''; // Lets make it pretty by eliminating all empty lines $lines = explode("\n", $data); foreach ($lines as $line) { if (strlen($line) > 1) $code .= rtrim($line) . "\n"; // The Strings length is > 1 } + if( file_exists( UTIL_PKG_PATH.'geshi/geshi.php' ) ) { // Include the GeSHi library include_once( UTIL_PKG_PATH.'geshi/geshi.php' ); $geshi = new GeSHi($code, $source, UTIL_PKG_PATH.'geshi/geshi' ); if ($num) { // Line Numbering has been requested $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + if (is_numeric($num)) $geshi->start_line_numbers_at($num); } - $code = $geshi->parse_code(); + $code = decodeHTML(htmlentities($geshi->parse_code())); } else { if ($num) { // Line Numbering has been requested $lines = explode("\n", $code); $code = ''; - $i = 1; // The current line number + $i = (is_numeric($num)) ? $num : 1; //Line Number foreach ($lines as $line) { if (strlen($line) > 1) { $code .= sprintf("%3d", $i) . ": " . $line . "\n"; @@ -119,7 +140,6 @@ function data_code( $data, $params ) { // Pre-Clyde Changes $code = "<?php\n".$code."\n?>"; // The require these tags to function $add_tags = true; } - // To Here switch ($source) { // I used a switch here to make it easy to expand this plugin for other kinds of source code case 'HTML': $code = highlight_string(decodeHTML($code),true); diff --git a/plugins/data.example.php b/plugins/data.example.php index d7f210b..e7a6c90 100644 --- a/plugins/data.example.php +++ b/plugins/data.example.php @@ -1,60 +1,38 @@ <?php +// $id: data.example.php,v 1.4.2.9 2005/07/14 09:03:36 starrider Exp $ /** - * @version $Revision: 1.5 $ - * @package Liberty + * assigned_modules + * + * @author StarRider starrrider@sourceforge.net + * @version $Revision: 1.6 $ + * @package liberty * @subpackage plugins_data + * @copyright Copyright (c) 2004, bitweaver.org + * All Rights Reserved. See copyright.txt for details and a complete list of authors. + * @license Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. */ -// +----------------------------------------------------------------------+ -// | Copyright (c) 2004, bitweaver.org -// +----------------------------------------------------------------------+ -// | All Rights Reserved. See copyright.txt for details and a complete list of authors. -// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details -// | -// | For comments, please use phpdocu.sourceforge.net documentation standards!!! -// | -> see http://phpdocu.sourceforge.net/ -// +----------------------------------------------------------------------+ -// | Author: StarRider <starrrider@users.sourceforge.net> -// | Note: A plugin with this name did exist as a TikiWiki Plugin -// | This is not that plugin. -// +----------------------------------------------------------------------+ -// $Id: data.example.php,v 1.5 2005/06/28 07:45:48 spiderr Exp $ - -/** - * definitions - */ +/****************** + * Initialization * + ******************/ define( 'PLUGIN_GUID_DATAEXAMPLE', 'dataexample' ); -// NOTE: The GUID is used as a link to a help page on bitweaver.org -// Please be sure to create this page when the plugin is created. -// In this case - the pagename should be "DataPluginExample" - global $gLibertySystem; -$pluginParams = array ( 'tag' => 'EXAMPLE', - 'auto_activate' => FALSE, - 'requires_pair' => FALSE, // Make this TRUE if the plugin needs to operate on free form text - 'load_function' => 'data_example', // Points to the Load Function - 'title' => 'Example', // Name of the Plugin - 'help_page' => 'DataPluginExample', // Name of Help Page on Bitweaver.org - 'description' => tra("This plugin is an example to show how plugins operate. It can also function as a template for the creation of new plugins since it contains a lot of spare code and explanations about how - and when - they should be used."), // What it does - 'help_function' => 'data_example_help', // Points to the Help Function - 'syntax' => "{EXAMPLE p1= p2= }", // A listing of parameters - 'plugin_type' => DATA_PLUGIN // Don't Touch - ); +$pluginParams = array ( 'tag' => 'EXAM', + 'auto_activate' => FALSE, + 'requires_pair' => FALSE, + 'load_function' => 'data_example', + 'title' => 'Example (EXAM)', + 'help_page' => 'DataPluginExample', + 'description' => tra("This Plugin is an Example that does nothing. It functions as a template for the creation of new plugins."), + 'help_function' => 'data_example_help', + 'syntax' => "{EXAM x1= x2= }", + 'plugin_type' => DATA_PLUGIN +); $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAEXAMPLE, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAEXAMPLE ); - -/**************** Lets talk about what all of this means. -The GUID ----> define( 'PLUGIN_GUID_DATAEXAMPLE', 'dataexample' ); <------- Line 17 -The GUID does several thing. First - it identifies the plugin to the Liberty System so that it can be found -Second - The GUID (in this case 'dataexample') is used as a link to a help page on bitweaver.org -The pagename should be "DataPluginExample" -// Please be sure to create this page when the plugin is created. -*/ - - - - -// Help Function -function data_example_help() { // Specified by $pluginParams['help_function'] +/***************** + * Help Function * + *****************/ +function data_example_help() { $help = '<table class="data help">' .'<tr>' @@ -63,122 +41,31 @@ function data_example_help() { // Specified by $pluginParams['help_function'] .'<th>' . tra( "Comments" ) . '</th>' .'</tr>' .'<tr class="odd">' - .'<td>p1</td>' - .'<td>' . tra( "anything") . '<br />' . tra("(Manditory)") . '</td>' - .'<td>' . tra( "The first parameter. There is no Default") . '</td>' + .'<td>x1</td>' + .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>' + .'<td>' . tra( "Specifies something / probably to be displayed.") + .'<br />' . tra( "The Default = <strong>Sorry About That</strong>") + .'</td>' .'</tr>' .'<tr class="even">' - .'<td>p2</td>' - .'<td>' . tra( "anything") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "The second parameter. There is no Default") . '</td>' - -// At times there is more reference data available than the Help Function can readilly display -// When this happens - we provide a link in the Help Function. Each of the following snippets -// Creates a link that opens a new window (so the user is not taken from his work) - HTML Compliant - -// This creates a link for ISO Country Codes -/* - . tra("<br /><strong>Note:</strong> 2-Digit ISO Country Codes are available from ") - . '<a href="http://www.bcpl.net/~j1m5path/isocodes-table.html" title="Launch BCPL.net in New Window" onkeypress="popUpWin(this.href,\'standard\',800,800);" onclick="popUpWin(this.href,\'standard\',800,800);return false;">' . tra( "ISO Country Codes" ) . '</a>' -*/ - -// This creates 2 links / 1- to a BitWeaver.org Page 2- to PageTutor.com's Color Picker II -/* - . tra("<strong>Note:</strong> Browser Safe Colornames are available on the ") - . '<a href="http://www.bitweaver.org/wiki/index.php?page=Web-Safe+HTML+Colors" title="Launch BitWeaver.Org in New Window" onkeypress="popUpWin(this.href,\'standard\',800,800);" onclick="popUpWin(this.href,\'standard\',800,800);return false;">' . tra( "BitWeaver Web Site" ) . '</a>' - . tra(" Another useful site for obtaining HTML colors is ") - . '<a href="http://www.pagetutor.com/pagetutor/makapage/picker" title="Launch PageTutor.com in New Window" onkeypress="popUpWin(this.href,\'standard\',800,800);" onclick="popUpWin(this.href,\'standard\',800,800);return false;">' . tra( "The Color Picker II" ) . '</a>'; -*/ - -// This creates a link to the user's site to get BitWeaver's Content ID Numbers -/* - . tra("This a Numeric Content Id. This allows blog posts, images, wiki pages . . . (and more) to be added.") - . tra("<br /><strong>Note 1:</strong> A listing of Content Id's can be found ") - . '<a href="'.LIBERTY_PKG_URL.'list_content.php" title="Launch BitWeaver Content Browser in New Window" onkeypress="popUpWin(this.href,\'standard\',800,800);" onclick="popUpWin(this.href,\'standard\',800,800);return false;">' . tra( "Here" ) . '</a>' -*/ - + .'<td>XXX</td>' + .'<td>' . tra( "number") . '<br />' . tra("(optional)") . '</td>' + .'<td>' . tra( "Specifies something / probably to be displayed.") + .'<br />' . tra( "The Default =") . ' <strong>3</strong> ' . tra( "Which means - What") + .'</td>' .'</tr>' .'</table>' - . tra("Example: ") . "{EXAMPLE p1='7' p2='8' }<br />" - . tra("This will display - P1 was set to = 7 & P2 was set to = 8"); + . tra("Example: ") . "{EXAM x1=' ' x2=5 }<br />" + . tra("This will display"); return $help; } +/**************** +* Load Function * + ****************/ +function data_example($data, $params) { + extract ($params); + $ret = ' '; -// Load Function -function data_example($data, $params) { // Specified by $pluginParams['load_function'] - extract ($params); // This extracts any parameter and creates a variable with the same name - -// Use this if you need to a Manditory Parameter - if (!isset($p1) ) { // The Manditory Parameter is missing - $ret = tra("The parameter ") . "__p1__" . tra(" was missing from the plugin ") . "__~np~{EXAMPLE}~/np~__."; - $ret.= data_example_help(); - return $ret; - } - -// Of course - any Manditory Parameter needs to be tested to see if it is valid - and provide an error message if it isn't - if( $p1 == 5) { - $ret = '<strong>Error</strong> ' . tra("- The plugin ") . '<strong>~np~{EXAMPLE}~/np~</strong>' . tra(" was given the parameter ") . '<strong>p1=' . $p1 . '</strong> ' . tra("which is not valid."); - return $ret; - } - -// Some plugin are designed to opperate with a lot of text. To do this the 'requires_pair' should be set to TRUE -// Use this if the plugin needs to operate on text - the 'requires_pair' should be set to TRUE - so the text will be between {plugin()} Blocks {plugin} - if (!isset($data)) { // There is no data between the Plugin Blocks - $ret = tra("__Error__ - There was no data between the ") . "__~np~{EXAMPLE}~/np~__" . tra(" blocks for the plugin to operate on."); - return $ret; - } -// There are several ways of testing to ensure that a parameter has a value - if (!isset($p1)) { // Always test each parameter to be sure it has a value before you use it. - $p1 = 5; - } -// Of course - this is another way - $ret = isset($p1) ? "P1 was set to = $p1" : "This should never be seen - it should be caught by the test for the Manditory Parameter"; - $ret = isset($p2) ? $ret." & P2 was set to = $p2" : $ret." & P2 was not set"; return $ret; - -// This is not seen by this plugin but it works - comment out the last 3 lines to see -// There are many times when you have several possible values for a given key - a case statemenmt works wonders - switch (strtoupper ($p2)) { - case 'ABC': - $ret = "P2 was ABC"; - return $ret; - case 'DEF': - $ret = "P2 was DEF"; - return $ret; - default: - $ret = "P2 was Something Else"; - return $ret; - } - -// Boolean values (with a default) can be handled like this - $p1 = FALSE; // Ensure that $p1 starts with your default value before the extract - extract ($params); - $ret = $p1 ? "P1 was TRUE = $p1" : "P1 was FALSE = $p1"; - return $ret; // Parameter values can be False / True or 0=False / >0=True } -/****************************************************************************** -This plugin was made to simplify the creation of new plugins. -As an example - lets say I wanted to create a new plugin called DOGS (Hope you know what it will do because I don't) -The first step would be to copy this file and rename it data.dogs.php in the same directory (Liberty\Plugins) -Next - in your editor do 2 case sensitive search and replace - changing EXAMPLE to DOGS / AND / example to dogs -The next changes are in the pluginParams array - Change the Title to "Dogs" - Change the description to briefly explain what your plugin will do - Decide on the number of parameters and parameter names to be passed to the plugin and place them in syntax. - The format we are currently using is {pluginname parameter='strings are OK'} - NOTE: If your plugin will operate on text that is entered at the same time the plugin is called - then you will probably want - to use the format {pluginname any-parameter-needed='3'} Text to be operated on {pluginname} - if this is the case - be sure - to change the requires_pair to TRUE -Next - Change the Help Function so that all of the parameters are all listed / what each one does / and any default value it may -have - be sure to mention if it is a Manditory Parameter or an Optional Parameter -NOTE: The Help Function uses Wiki-Syntax to improve the appearance of the help message. By this point, you should be able to -see your plugin in the Wiki Page Editor / Plugin Tab of Help - so make it look good. -NOTE 2: Part of the reason the help routine looks as complex as it does is the fact that bitWeaver is an international program. The -tra( function is used to convert text from one language to another. Most of the text can be changed for clarity - but some like the name -of the plugin / the parameter names and some specific values can not be change - so keep that in mind when adding to the Help - -Function. This also applies to Error Messages. -Finally - Change the Load Function so that it does what you want it to do -NOTE: I added a bunch of simple tests to the Load Function that should help a novice - this is not all inclusive listing but it does -show what I am using to standardize these plugins - use them or blow them away - as you will - StarRider -*/ ?> diff --git a/plugins/format.pearwiki.php b/plugins/format.pearwiki.php index bb6afed..87bf76f 100644 --- a/plugins/format.pearwiki.php +++ b/plugins/format.pearwiki.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Liberty * @subpackage plugins_format */ @@ -52,7 +52,7 @@ function pearwiki_parse_data( &$pData, &$pCommonObject ) { global $gLibertySystem; // create a table of contents for this page // this function is called manually, since it processes the HTML code - if( preg_match( "/\{maketoc.*?\}/", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { + if( preg_match( "/\{maketoc.*?\}/i", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { $xhtml= data_maketoc($xhtml); } return $xhtml; diff --git a/plugins/format.pearwiki_tiki.php b/plugins/format.pearwiki_tiki.php index 9269567..8ac015f 100644 --- a/plugins/format.pearwiki_tiki.php +++ b/plugins/format.pearwiki_tiki.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Liberty * @subpackage plugins_format */ @@ -62,7 +62,7 @@ function pearwiki_tiki_parse_data( &$pData, &$pCommonObject ) { global $gLibertySystem; // create a table of contents for this page // this function is called manually, since it processes the HTML code - /*if( preg_match( "/\{maketoc.*?\}/", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { + /*if( preg_match( "/\{maketoc.*?\}/i", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { $xhtml= data_maketoc($xhtml); }*/ return $xhtml; diff --git a/plugins/format.tikihtml.php b/plugins/format.tikihtml.php index 2d11104..8521664 100644 --- a/plugins/format.tikihtml.php +++ b/plugins/format.tikihtml.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @package Liberty * @subpackage plugins_format */ @@ -86,7 +86,7 @@ function bithtml_parse_data( &$pData, &$pCommonObject ) { // eventually we should strip tags, maybe tikilink, or other things. parse_data_plugins( $pData, $foo, $bar, $empty ); // this function is called manually, since it processes the HTML code - if( preg_match( "/\{maketoc.*?\}/", $pData ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { + if( preg_match( "/\{maketoc.*?\}/i", $pData ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { $pData = data_maketoc( $pData ); } return $pData; diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php index 8bd6ccc..c5a9870 100644 --- a/plugins/format.tikiwiki.php +++ b/plugins/format.tikiwiki.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ * @package Liberty */ global $gLibertySystem; @@ -1338,7 +1338,7 @@ $this->debug(0); global $gLibertySystem; // create a table of contents for this page // this function is called manually, since it processes the HTML code - if( preg_match( "/\{maketoc.*?\}/", $data ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { + if( preg_match( "/\{maketoc.*?\}/i", $data ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) { $data = data_maketoc($data); } diff --git a/templates/edit_structure_content.tpl b/templates/edit_structure_content.tpl index f7ebdcb..07c3c75 100644 --- a/templates/edit_structure_content.tpl +++ b/templates/edit_structure_content.tpl @@ -19,30 +19,26 @@ {/if} <div class="row"> - {formlabel label="Add" for="content_type"} + {formlabel label="Content" for="content"} {forminput} - <select name="content_type" id="content_type" onchange="submit();"> + <select name="content_type" onchange="submit();"> <option {if !$contentSelect}selected="selected"{/if} value="">All Content</option> {foreach from=$contentTypes key=guid item=description} - <option value="{$guid}" {if $contentSelect == $guid}selected="selected"{assign var=selectDescription value=$description}{/if}>{$description}</option> + <option value="{$guid}" {if $contentSelect eq $guid}selected="selected"{assign var=selectDescription value=$description}{/if}>{$description}</option> {/foreach} </select> + <noscript> + <div><input type="submit" name="content_switch" value="{tr}change content type{/tr}" /></div> + </noscript> {/forminput} {forminput} - <select name="content[]" multiple="multiple" size="8"> - {section name=list loop=$listContent} - {assign var=guid value=$listContent[list].content_type_guid} - <option value="{$listContent[list].content_id}">{$contentTypes.$guid} {$listContent[list].content_id}{if $listContent[list]}: "{$listContent[list].title|truncate:40:"(...)":true}"{/if}</option> - {sectionelse} - <option disabled="disabled">{tr}No {$selectDescription} content found{/tr}</option> - {/section} - </select> + {html_options multiple="multiple" id="content" size="12" name="content[]" values=$contentList options=$contentList selected=$pigeonInfo.selected_content} {/forminput} {forminput} <input type="text" name="find_objects" /> - <input type="submit" value="{tr}filter{/tr}" name="search_objects" /> + <input type="submit" value="{tr}Apply filter{/tr}" name="search_objects" /> {formhelp note=""} {/forminput} </div> diff --git a/templates/list_content_inc.tpl b/templates/list_content_inc.tpl index 3d8c763..74386ce 100644 --- a/templates/list_content_inc.tpl +++ b/templates/list_content_inc.tpl @@ -2,14 +2,9 @@ {form legend="Select Content Type"} <input type="hidden" name="user_id" value="{$user_id}" /> <div class="row"> - {formlabel label="Restrict listing" for="content_type"} + {formlabel label="Restrict listing" for="content_type_guid"} {forminput} - <select name="content_type" id="content_type" onchange="submit();"> - <option {if !$contentSelect}selected="selected"{/if} value="">All Content</option> - {foreach from=$contentTypes key=guid item=description} - <option value="{$guid}" {if $contentSelect eq $guid}selected="selected"{assign var=selectDescription value=$description}{/if}>{$description}</option> - {/foreach} - </select> + {html_options onchange="submit();" values=$contentTypes options=$contentTypes name=content_type_guid id=content_type selected=$contentSelect} <noscript> <div><input type="submit" name="content_switch" value="{tr}change content type{/tr}" /></div> </noscript> @@ -23,14 +18,22 @@ </div> {/form} +{* assign the correct sort columns for user name sorting *} +{if $gBitSystem->isFeatureActive( 'display_name' ) eq login} + {assign var=isort_author value=creator_user} + {assign var=isort_editor value=modifier_user} +{else} + {assign var=isort_author value=creator_real_name} + {assign var=isort_editor value=modifier_real_name} +{/if} + <table class="data"> - <caption>{tr}Available Content{/tr}</caption> + <caption>{tr}Available Content{/tr} <span class="total">[ {$contentCount} ]</span></caption> <tr> <th>{smartlink ititle="Title" isort=title page=$page user_id=$user_id idefault=1}</th> <th>{smartlink ititle="Content Type" isort=content_type_guid page=$page user_id=$user_id}</th> - <th>{tr}Author{/tr}</th> - <th>{tr}Most Recent Editor{/tr}</th> - <th> </th> + <th>{smartlink ititle="Author" isort=$isort_author page=$page}</th> + <th colspan="2">{smartlink ititle="Most recent editor" isort=$isort_editor page=$page}</th> </tr> {foreach from=$contentList item=item} <tr class="{cycle values='odd,even'}"> @@ -38,7 +41,7 @@ <td>{assign var=content_type_guid value=`$item.content_type_guid`}{$contentTypes.$content_type_guid}</td> <td>{displayname real_name=$item.creator_real_name user=$item.creator_user}</td> <td>{displayname real_name=$item.modifier_real_name user=$item.modifier_user}</td> - <td>{$item.last_modified|bit_short_date}</td> + <td style="text-align:right;">{$item.last_modified|bit_short_date}</td> </tr> {/foreach} </table> |
