diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:55:19 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:55:19 +0100 |
| commit | c105a9834fd9c5a320d41422c50fa84e5bc12084 (patch) | |
| tree | 48d0d400d6e0a4fd87485e89accfdeaf8db5c24b /includes | |
| parent | 1778d95793e4bc5d494ece84ec177b5629c830f3 (diff) | |
| download | wiki-c105a9834fd9c5a320d41422c50fa84e5bc12084.tar.gz wiki-c105a9834fd9c5a320d41422c50fa84e5bc12084.tar.bz2 wiki-c105a9834fd9c5a320d41422c50fa84e5bc12084.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/bit_setup_inc.php | 5 | ||||
| -rwxr-xr-x | includes/classes/BitBook.php | 8 | ||||
| -rwxr-xr-x | includes/classes/BitPage.php | 15 | ||||
| -rwxr-xr-x | includes/copyrights_lib.php | 1 | ||||
| -rwxr-xr-x | includes/display_bitpage_inc.php | 1 | ||||
| -rwxr-xr-x | includes/export_lib.php | 4 | ||||
| -rwxr-xr-x | includes/lookup_page_inc.php | 7 | ||||
| -rwxr-xr-x | includes/plugins_lib.php | 409 |
8 files changed, 226 insertions, 224 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index a9e3bbd..c9ee7f2 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Wiki; + use Bitweaver\KernelTools; global $gBitSystem, $gBitUser; @@ -13,9 +14,9 @@ $pRegisterHash = [ define( 'WIKI_PKG_NAME', $pRegisterHash['package_name'] ); define( 'WIKI_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'WIKI_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); -define( 'WIKI_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'WIKI_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); define( 'WIKI_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); -define( 'WIKI_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); +define( 'WIKI_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); diff --git a/includes/classes/BitBook.php b/includes/classes/BitBook.php index d66eb0b..abbd207 100755 --- a/includes/classes/BitBook.php +++ b/includes/classes/BitBook.php @@ -20,11 +20,11 @@ // // $Id: BitBook.php,v 1.14 2010/04/17 22:46:11 wjames5 Exp $ - /** * required setup */ namespace Bitweaver\Wiki; + use Bitweaver\Liberty\LibertyStructure; define('BITBOOK_CONTENT_TYPE_GUID', 'bitbook' ); @@ -42,14 +42,14 @@ class BitBook extends BitPage { public $mPageName; public function __construct( $pPageId=null, $pContentId=null ) { parent::__construct( $pPageId, $pContentId ); - $this->registerContentType( BITBOOK_CONTENT_TYPE_GUID, array( + $this->registerContentType( BITBOOK_CONTENT_TYPE_GUID, [ 'content_type_guid' => BITBOOK_CONTENT_TYPE_GUID, 'content_name' => 'Wiki Book', 'handler_class' => 'BitBook', 'handler_package' => 'wiki', 'handler_file' => 'BitBook.php', - 'maintainer_url' => 'https://www.bitweaver.org' - ) ); + 'maintainer_url' => 'https://www.bitweaver.org', + ] ); $this->mContentTypeGuid = BITBOOK_CONTENT_TYPE_GUID; // Permission setup diff --git a/includes/classes/BitPage.php b/includes/classes/BitPage.php index 30e4aef..d120120 100755 --- a/includes/classes/BitPage.php +++ b/includes/classes/BitPage.php @@ -14,6 +14,7 @@ * required setup */ namespace Bitweaver\Wiki; + use Bitweaver\BitBase; use Bitweaver\KernelTools; use Bitweaver\BitCacheable; @@ -35,7 +36,7 @@ class BitPage extends LibertyMime implements BitCacheable { 'handler_class' => 'BitPage', 'handler_package' => 'wiki', 'handler_file' => 'BitPage.php', - 'maintainer_url' => 'https://www.bitweaver.org' + 'maintainer_url' => 'https://www.bitweaver.org', ] ); $this->mPageId = (int)$pPageId; $this->mContentId = (int)$pContentId; @@ -470,7 +471,6 @@ class BitPage extends LibertyMime implements BitCacheable { return BitPage::getPageLink( $pParamHash['title'], null ); } - /** * Returns include file that will * @return string the fully specified path to file to be included @@ -479,7 +479,6 @@ class BitPage extends LibertyMime implements BitCacheable { return WIKI_PKG_INCLUDE_PATH."display_bitpage_inc.php"; } - /** * Returns the center template for the view selected */ @@ -496,7 +495,6 @@ class BitPage extends LibertyMime implements BitCacheable { return $ret; } - /** * Create the generic title for a content item * @@ -600,7 +598,6 @@ class BitPage extends LibertyMime implements BitCacheable { return $ret; } - /** * Roll back to a specific version of a page * @param int $pVersion Version number to roll back to @@ -647,7 +644,7 @@ class BitPage extends LibertyMime implements BitCacheable { 'links_asc', 'links_desc', 'backlinks_asc', - 'backlinks_desc' + 'backlinks_desc', ]; if( in_array( $pListHash['sort_mode'], $specialSort ) ) { @@ -780,8 +777,8 @@ class BitPage extends LibertyMime implements BitCacheable { while( $res = $result->fetchRow() ) { $aux = []; $aux = $res; - $aux['creator'] = 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['creator'] = $res['creator_real_name'] ?? $res['creator_user']; + $aux['editor'] = $res['modifier_real_name'] ?? $res['modifier_user']; $aux['flag'] = $res["flag"] == 'L' ? 'locked' : 'unlocked'; $aux['display_url'] = static::getDisplayUrlFromHash( $aux ); // display_link does not seem to be used when getList is called @@ -995,7 +992,7 @@ class BitPage extends LibertyMime implements BitCacheable { $pGraphViz->addNode( $pLinkStructure['name'], $pParams['node'] ); foreach( $pLinkStructure['pages'] as $node ) { - $this->linkStructureGraph( $pGraphViz,$node, $pParams ); + $this->linkStructureGraph( $pGraphViz,$node, $pParams ); $pGraphViz->addEdge( [ $pLinkStructure['name'] => $node['name'] ], $pParams['node'] ); } } diff --git a/includes/copyrights_lib.php b/includes/copyrights_lib.php index 122506c..31345db 100755 --- a/includes/copyrights_lib.php +++ b/includes/copyrights_lib.php @@ -14,6 +14,7 @@ * @subpackage CopyrightsLib */ namespace Bitweaver\Wiki; + use Bitweaver\BitBase; class CopyrightsLib extends BitBase { diff --git a/includes/display_bitpage_inc.php b/includes/display_bitpage_inc.php index 53d113f..6b5101c 100755 --- a/includes/display_bitpage_inc.php +++ b/includes/display_bitpage_inc.php @@ -14,6 +14,7 @@ * required setup */ namespace Bitweaver\Wiki; + use Bitweaver\KernelTools; use Bitweaver\Stickies\BitSticky; use Bitweaver\Liberty\LibertyContent; diff --git a/includes/export_lib.php b/includes/export_lib.php index 0146573..7f6c005 100755 --- a/includes/export_lib.php +++ b/includes/export_lib.php @@ -32,7 +32,7 @@ class ExportLib extends \Bitweaver\BitBase { $content = $this->export_wiki_page($page_id, 0); $tar->addData($page_id, $content, $gBitSystem->getUTCTime()); } - $tar->toTar( $pExportFile, false); + $tar->toTar( $pExportFile, false); return ''; } @@ -69,7 +69,7 @@ class ExportLib extends \Bitweaver\BitBase { "INNER JOIN `".BIT_DB_PREFIX."liberty_content_history` th ON (th.`page_id` = th.`page_id`) " . "INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = th.`user_id`) " . "WHERE wp.`page_id`=? order by th.".$this->mDb->convertSortmode("version_desc"); - $result = $this->mDb->query($query,array($page_id)); + $result = $this->mDb->query($query,[$page_id]); $ret = []; while ($res = $result->fetchRow()) { array_push( $ret, $res ); diff --git a/includes/lookup_page_inc.php b/includes/lookup_page_inc.php index 4d838b1..b28a1d7 100755 --- a/includes/lookup_page_inc.php +++ b/includes/lookup_page_inc.php @@ -14,6 +14,7 @@ * required setup */ namespace Bitweaver\Wiki; + use Bitweaver\Liberty\LibertyStructure; global $gContent; include_once LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php'; @@ -24,7 +25,7 @@ if( empty( $lookupHash )) { } // if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up. -if( empty( $gContent ) || !is_object( $gContent ) || strtolower( get_class( $gContent ) ) != 'bitpage' ) { +if( empty( $gContent ) || !is_object( $gContent ) || strtolower( $gContent::class ) != 'bitpage' ) { if( !empty( $lookupHash['page_id'] ) ) { $loadContentId = BitPage::findContentIdByPageId( $lookupHash['page_id'] ); } elseif( !empty( $lookupHash['content_id'] ) ) { @@ -48,10 +49,10 @@ if( empty( $gContent ) || !is_object( $gContent ) || strtolower( get_class( $gCo $gBitSmarty->assign('dupePages', $existsInfo); $gBitSystem->display('bitpackage:wiki/page_select.tpl', null, [ 'display_mode' => 'display' ]); die; - } else { + } $loadPageId = $existsInfo[0]['page_id']; $loadContentId = $existsInfo[0]['content_id']; - } + } } elseif( $loadPage ) { $gBitSmarty->assign('page', $loadPage);//to have the create page link in the error diff --git a/includes/plugins_lib.php b/includes/plugins_lib.php index 12fde9f..533c743 100755 --- a/includes/plugins_lib.php +++ b/includes/plugins_lib.php @@ -1,211 +1,212 @@ <?php - /** - * Plugin Lib - * - * A port of PhpWiki WikiPlugin class - * Principal use is port PhpWiki plugins, but can be used to make new ones. - * Use: - * - Extends PluginsLib with your class - * - add the lines - * <code> - * include "pluginslib.php"; - * - * function wikiplugin_backlinks($data, $params) { - * $plugin = new BackLinks(); - * return $plugin->run($data, $params); - * } - * function wikiplugin_backlinks_help() { - * $plugin = new BackLinks(); - * return $plugin->getDescription(); - * } * </code> - * @package wiki + /** + * Plugin Lib + * + * A port of PhpWiki WikiPlugin class + * Principal use is port PhpWiki plugins, but can be used to make new ones. + * Use: + * - Extends PluginsLib with your class + * - add the lines + * <code> + * include "pluginslib.php"; + * + * function wikiplugin_backlinks($data, $params) { + * $plugin = new BackLinks(); + * return $plugin->run($data, $params); + * } + * function wikiplugin_backlinks_help() { + * $plugin = new BackLinks(); + * return $plugin->getDescription(); + * } * </code> + * @package wiki */ /** - * @package wiki - * @subpackage PluginsLib - * @author Claudio Bustos - * @version $Revision$ - */ + * @package wiki + * @subpackage PluginsLib + * @author Claudio Bustos + * @version $Revision$ + */ - namespace Bitweaver\Wiki; - use Bitweaver\KernelTools; - - class PluginsLib extends \Bitweaver\BitBase { - public $_errors; - public $_data; - public $_params; - /** - * Array of params to be expanded as arrays. Explode the string with {@link $separator} - * @var array - */ - public $expanded_params = []; - /** - * Separator used to explote params listed on {@link $expanded_params} - * @var string - */ - public $separator = "|"; - /** - * List of fields retrieved from {@link BitBase::list_pages()} - * Keys are the name of the fields and values the names for tra(); - * @var array - */ - public $aInfoPresetNames = array( - "hits" => "Hits", "last_modified" => "Last mod", "user" => "Last author", "len" => "Size", "comment" => "Com", "creator" => "Creator", "version" => "Last ver", "flag" => "Status", "versions" => "Vers", "links" => "Links", "backlinks" => "Backlinks"); + namespace Bitweaver\Wiki; - /** - * Process the params, in this order: - * - default values, asigned on {@link PluginsLib::getDefaultArguments()} - * - request values, sended by GET or POST method, if $request is put to true - * - explicit values, asigned on the Wiki - * @param array sended to wikiplugin_name($data, $params) - * @param bool if set to true, accept values from $_REQUEST - * @param bool if set to true, assign default values from {@link PluginsLib::getDefaultArguments()} - * @return array list of params - */ - function getParams($params, $request = false, $defaults = false) { - if ($defaults === false) { - $defaults = $this->getDefaultArguments(); - } - $args = []; - foreach ($defaults as $arg => $default_val) { - if (isset($params[$arg])) { - $args[$arg] = $params[$arg]; - } elseif(isset($_REQUEST[$arg])) { - $args[$arg] = $_REQUEST[$arg]; - } else { - // maybe this kind of transformation can be grouped on a external function - if ($default_val==="[pagename]") { - $default_val=$_REQUEST["page"]; - } - $args[$arg] = $default_val; - } - if (in_array($arg, $this->expanded_params)) { - if ($args[$arg]) { - $args[$arg] = explode($this->separator, $args[$arg]); - foreach($args[$arg] as $id=>$value) { - $args[$arg][$id]=trim($value); - } - } else { - $args[$arg]=[]; - } - } - } - return $args; - } - /** - * Returns the name of the Plugin - * By default, erase the first 'WikiPlugin' - * Made for overload it. - * @return string - */ - function getName() { - return preg_replace('/^WikiPlugin/', '', get_class($this)); - } - /** - * Returns a description of the Plugin - * Made for overload it. - * @return string - */ - function getDescription() { - return $this->getName(); - } - /** - * Returns the version of the version - * Made for overload it. - * @return string - */ - function getVersion() { - return KernelTools::tra("No version indicated"); - //return preg_replace("/[Revision: $]/", '', - // "\$Revision$"); - } - /** - * Returns the default arguments for the plugin - * Use keys as the arguments and values as ... the default values - * @return array - */ - function getDefaultArguments() { - return array('description' => $this->getDescription()); - } - /** - * Run the plugin - * For sake of God, overload it! - * @param string - * @param array - */ - function run ($data, $params) { - /** - * UGLY ERROR!. - */ - return $this->error("PluginsLib::run: pure virtual function. Don't be so lazy!"); - } - function error ($message) { - return "~np~<span class='warn'>Plugin ".$this->getName()." ".KernelTools::tra("failed")." : ".tra($message)."</span>~/np~"; - } - function getErrorDetail() { - return $this->_errors; - } - function _error($message) { - $this->_errors = $message; - return false; - } - } - /** - * Class with utilities for Plugins +use Bitweaver\KernelTools; + + class PluginsLib extends \Bitweaver\BitBase { + public $_errors; + public $_data; + public $_params; + /** + * Array of params to be expanded as arrays. Explode the string with {@link $separator} + * @var array + */ + public $expanded_params = []; + /** + * Separator used to explote params listed on {@link $expanded_params} + * @var string + */ + public $separator = "|"; + /** + * List of fields retrieved from {@link BitBase::list_pages()} + * Keys are the name of the fields and values the names for tra(); + * @var array + */ + public $aInfoPresetNames = [ + "hits" => "Hits", "last_modified" => "Last mod", "user" => "Last author", "len" => "Size", "comment" => "Com", "creator" => "Creator", "version" => "Last ver", "flag" => "Status", "versions" => "Vers", "links" => "Links", "backlinks" => "Backlinks", ]; + + /** + * Process the params, in this order: + * - default values, asigned on {@link PluginsLib::getDefaultArguments()} + * - request values, sended by GET or POST method, if $request is put to true + * - explicit values, asigned on the Wiki + * @param array sended to wikiplugin_name($data, $params) + * @param bool if set to true, accept values from $_REQUEST + * @param bool if set to true, assign default values from {@link PluginsLib::getDefaultArguments()} + * @return array list of params + */ + function getParams($params, $request = false, $defaults = false) { + if ($defaults === false) { + $defaults = $this->getDefaultArguments(); + } + $args = []; + foreach ($defaults as $arg => $default_val) { + if (isset($params[$arg])) { + $args[$arg] = $params[$arg]; + } elseif(isset($_REQUEST[$arg])) { + $args[$arg] = $_REQUEST[$arg]; + } else { + // maybe this kind of transformation can be grouped on a external function + if ($default_val==="[pagename]") { + $default_val=$_REQUEST["page"]; + } + $args[$arg] = $default_val; + } + if (in_array($arg, $this->expanded_params)) { + if ($args[$arg]) { + $args[$arg] = explode($this->separator, $args[$arg]); + foreach($args[$arg] as $id=>$value) { + $args[$arg][$id]=trim($value); + } + } else { + $args[$arg]=[]; + } + } + } + return $args; + } + /** + * Returns the name of the Plugin + * By default, erase the first 'WikiPlugin' + * Made for overload it. + * @return string + */ + function getName() { + return preg_replace('/^WikiPlugin/', '', get_class($this)); + } + /** + * Returns a description of the Plugin + * Made for overload it. + * @return string + */ + function getDescription() { + return $this->getName(); + } + /** + * Returns the version of the version + * Made for overload it. + * @return string + */ + function getVersion() { + return KernelTools::tra("No version indicated"); + //return preg_replace("/[Revision: $]/", '', + // "\$Revision$"); + } + /** + * Returns the default arguments for the plugin + * Use keys as the arguments and values as ... the default values + * @return array + */ + function getDefaultArguments() { + return ['description' => $this->getDescription()]; + } + /** + * Run the plugin + * For sake of God, overload it! + * @param string + * @param array + */ + function run ($data, $params) { + /** + * UGLY ERROR!. + */ + return $this->error("PluginsLib::run: pure virtual function. Don't be so lazy!"); + } + function error ($message) { + return "~np~<span class='warn'>Plugin ".$this->getName()." ".KernelTools::tra("failed")." : ".tra($message)."</span>~/np~"; + } + function getErrorDetail() { + return $this->_errors; + } + function _error($message) { + $this->_errors = $message; + return false; + } + } + /** + * Class with utilities for Plugins * - * @package wiki - * @subpackage PluginsLib - * @author Claudio Bustos - * @version $Revision$ - */ - class PluginsLibUtil { - /** - * Create a table with information from pages - * @param array key ["data"] from one of the functions that retrieve informaci�n about pages - * @param array list of keys to show. - * @param array definition of the principal field. By default: - * array("field"=>"title","name"=>"Page") - * @return string - */ - public function createTable($aData,$aInfo=false,$aPrincipalField=false) { - // contract - if (!$aPrincipalField or !is_array($aPrincipalField)) { - $aPrincipalField=array("field"=>"title","name"=>"Page"); - } - if (!is_array($aInfo)) { - $aInfo=false; - } - // ~contract - $sOutput=""; - if ($aInfo) { - $iNumCol=count($aInfo)+1; - $sStyle=" style='width:".(floor(100/$iNumCol))."%' "; - // Header for info - $sOutput .= "<table class='normal'><tr><td class='heading' $sStyle>".KernelTools::tra($aPrincipalField["name"])."</td>"; - foreach($aInfo as $iInfo => $sHeader) { - $sOutput .= "<td class='heading' $sStyle >".KernelTools::tra($sHeader)."</td>"; - } - $sOutput .= "</tr>"; - } - $iCounter=1; - foreach($aData as $aPage) { - $sClass=($iCounter%2)?"odd":"even"; - if (!$aInfo) { - $sOutput .= "*((".$aPage[$aPrincipalField["field"]]."))\n"; - } else { - $sOutput .= "<tr><td class='$sClass'>((".$aPage[$aPrincipalField["field"]]."))</td>"; - foreach($aInfo as $sInfo) { - if (isset($aPage[$sInfo])) { - $sOutput .= "<td class='$sClass'>".$aPage[$sInfo]."</td>"; - } - } - } - $iCounter++; - } - if ($aInfo) { - $sOutput .= "</table>"; - } - return $sOutput; - } - }
\ No newline at end of file + * @package wiki + * @subpackage PluginsLib + * @author Claudio Bustos + * @version $Revision$ + */ + class PluginsLibUtil { + /** + * Create a table with information from pages + * @param array key ["data"] from one of the functions that retrieve informaci�n about pages + * @param array list of keys to show. + * @param array definition of the principal field. By default: + * array("field"=>"title","name"=>"Page") + * @return string + */ + public function createTable($aData,$aInfo=false,$aPrincipalField=false) { + // contract + if (!$aPrincipalField or !is_array($aPrincipalField)) { + $aPrincipalField=["field"=>"title","name"=>"Page"]; + } + if (!is_array($aInfo)) { + $aInfo=false; + } + // ~contract + $sOutput=""; + if ($aInfo) { + $iNumCol=count($aInfo)+1; + $sStyle=" style='width:".(floor(100/$iNumCol))."%' "; + // Header for info + $sOutput .= "<table class='normal'><tr><td class='heading' $sStyle>".KernelTools::tra($aPrincipalField["name"])."</td>"; + foreach($aInfo as $iInfo => $sHeader) { + $sOutput .= "<td class='heading' $sStyle >".KernelTools::tra($sHeader)."</td>"; + } + $sOutput .= "</tr>"; + } + $iCounter=1; + foreach($aData as $aPage) { + $sClass=($iCounter%2)?"odd":"even"; + if (!$aInfo) { + $sOutput .= "*((".$aPage[$aPrincipalField["field"]]."))\n"; + } else { + $sOutput .= "<tr><td class='$sClass'>((".$aPage[$aPrincipalField["field"]]."))</td>"; + foreach($aInfo as $sInfo) { + if (isset($aPage[$sInfo])) { + $sOutput .= "<td class='$sClass'>".$aPage[$sInfo]."</td>"; + } + } + } + $iCounter++; + } + if ($aInfo) { + $sOutput .= "</table>"; + } + return $sOutput; + } + }
\ No newline at end of file |
