summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/bit_setup_inc.php9
-rwxr-xr-xincludes/classes/LibertyBase.php3
-rwxr-xr-xincludes/classes/LibertyComment.php34
-rwxr-xr-xincludes/classes/LibertyContent.php84
-rwxr-xr-xincludes/classes/LibertyMime.php57
-rwxr-xr-xincludes/classes/LibertyStructure.php64
-rwxr-xr-xincludes/classes/LibertySystem.php28
-rwxr-xr-xincludes/comments_inc.php3
-rwxr-xr-xincludes/get_content_list_inc.php2
-rwxr-xr-xincludes/liberty_lib.php15
-rwxr-xr-xincludes/lookup_content_inc.php1
-rwxr-xr-xincludes/structure_edit_inc.php3
12 files changed, 132 insertions, 171 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 1934883..20e86c1 100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -8,6 +8,7 @@
* @subpackage functions
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
@@ -37,8 +38,8 @@ if( $gLibertySystem->mDb->isValid() ) { // install condition check
}
}
-$gLibertySystem->registerService( 'liberty',
- LIBERTY_PKG_NAME,
+$gLibertySystem->registerService( 'liberty',
+ LIBERTY_PKG_NAME,
[
'content_edit_mini_tpl' => 'bitpackage:liberty/service_content_edit_mini_inc.tpl',
'content_edit_tab_tpl' => 'bitpackage:liberty/service_content_edit_tab_inc.tpl',
@@ -52,10 +53,10 @@ $gLibertySystem->registerService( 'liberty',
'content_list_sql_function' => 'liberty_content_list_sql',
'content_preview_function' => 'liberty_content_preview',
],
- [
+ [
'description' => KernelTools::tra( 'Provides core functionality, including enforcing some access control and dynamic layout components.' ),
'required' => true,
- ]
+ ],
);
// delete cache file if requested
diff --git a/includes/classes/LibertyBase.php b/includes/classes/LibertyBase.php
index dc585a4..7bdcbef 100755
--- a/includes/classes/LibertyBase.php
+++ b/includes/classes/LibertyBase.php
@@ -22,6 +22,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
/**
@@ -80,7 +81,7 @@ class LibertyBase extends BitBase {
$typeClass = null;
$pContentId = preg_replace( '/[\D]/', '', $pContentId );
if( empty( $pContentTypeGuid ) ) {
- $pContentTypeGuid = $gLibertySystem->mDb->getOne( "SELECT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?", array( $pContentId ), null, null, 3600 );
+ $pContentTypeGuid = $gLibertySystem->mDb->getOne( "SELECT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?", [ $pContentId ], null, null, 3600 );
}
if( !empty( $pContentTypeGuid ) && isset( $gLibertySystem->mContentTypes[$pContentTypeGuid] ) ) {
$typeClass = $gLibertySystem->getContentClassName( $pContentTypeGuid );
diff --git a/includes/classes/LibertyComment.php b/includes/classes/LibertyComment.php
index c0d7060..73c7612 100755
--- a/includes/classes/LibertyComment.php
+++ b/includes/classes/LibertyComment.php
@@ -11,6 +11,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
@@ -48,7 +49,6 @@ class LibertyComment extends LibertyMime {
}
}
-
public function __sleep() {
return array_merge( parent::__sleep(), [ 'mCommentId', 'mRootObj' ] );
}
@@ -149,10 +149,10 @@ class LibertyComment extends LibertyMime {
$this->mErrors['comment_attachments'] = KernelTools::tra( 'Files can not be uploaded with comments.' );
}
- // if we have an error we get them all by checking parent classes for additional errors
- if( count( $this->mErrors ) > 0 ){
- parent::verify( $pParamHash );
- }
+ // if we have an error we get them all by checking parent classes for additional errors
+ if( count( $this->mErrors ) > 0 ){
+ parent::verify( $pParamHash );
+ }
return count($this->mErrors) == 0;
}
@@ -179,7 +179,7 @@ class LibertyComment extends LibertyMime {
$this->mInfo['thread_forward_sequence'] = $parent_sequence_forward . sprintf("%09d.",$this->mCommentId);
$this->mInfo['thread_reverse_sequence'] = strtr($parent_sequence_forward . sprintf("%09d.",$this->mCommentId),
- '0123456789', '9876543210');
+ '0123456789', '9876543210', );
$sql = "INSERT INTO `".BIT_DB_PREFIX."liberty_comments` (`comment_id`, `content_id`, `parent_id`, `root_id`, `anon_name`, `thread_forward_sequence`, `thread_reverse_sequence`) VALUES (?,?,?,?,?,?,?)";
@@ -211,7 +211,6 @@ class LibertyComment extends LibertyMime {
return count($this->mErrors) == 0;
}
-
// This is a highly specialized method only used for emailing list synchronization. If you don't know anything about this, just move along and live in bliss
// (Hint: see mailing list integreation in boards)
function storeMessageId( $pMessageId ) {
@@ -235,7 +234,6 @@ class LibertyComment extends LibertyMime {
// $result = $this->mDb->query( $query, [ $this->getField( 'content_id' ) ] );
}
-
$sql = "DELETE FROM `".BIT_DB_PREFIX."liberty_comments` WHERE `comment_id` = ?";
$rs = $this->mDb->query($sql, [ $this->mCommentId ]);
@@ -335,11 +333,11 @@ class LibertyComment extends LibertyMime {
return $this->userCanEdit() || ($pRootContent && ($pRootContent->hasUserPermission( 'p_liberty_edit_comments' ) || $pRootContent->hasUserPermission( 'p_liberty_admin_comments' )));
}
- /**
- * @param string pLinkText name of
- * @param array pParamHash different possibilities depending on derived class
- * @return string the link to display the page.
- */
+ /**
+ * @param string pLinkText name of
+ * @param array pParamHash different possibilities depending on derived class
+ * @return string the link to display the page.
+ */
public static function getDisplayUrlFromHash( &$pParamHash ) {
$ret = null;
if( BitBase::verifyId( $pParamHash['root_id'] ) && $viewContent = LibertyBase::getLibertyObject( $pParamHash['root_id'] ) ) {
@@ -503,7 +501,6 @@ class LibertyComment extends LibertyMime {
return $ret;
}
-
function getNumComments($pContentId = null) {
$bindVars = null;
if (!$pContentId && $this->mContentId) {
@@ -556,10 +553,9 @@ class LibertyComment extends LibertyMime {
return $commentCount;
}
-
// used for direct access to view a single comment
// see usage in: liberty/comments_inc.php
- // there ought to be a better way to do this...
+ // there ought to be a better way to do this...
function getNumComments_upto($pCommentId = null, $pContentId = null) {
$comment = new LibertyComment($pCommentId, $pContentId);
@@ -655,7 +651,7 @@ class LibertyComment extends LibertyMime {
// get attachments for each comment
global $gLibertySystem;
$query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`content_id`=? ORDER BY la.`pos` ASC, la.`attachment_id` ASC";
- if( $result2 = $this->mDb->query( $query,array( (int)$row['content_id'] ))) {
+ if( $result2 = $this->mDb->query( $query,[ (int)$row['content_id'] ])) {
while( $row2 = $result2->fetchRow() ) {
if( $func = $gLibertySystem->getPluginFunction( $row2['attachment_plugin_guid'], 'load_function', 'mime' )) {
// we will pass the preferences by reference that the plugin can easily update them
@@ -690,8 +686,8 @@ class LibertyComment extends LibertyMime {
return '{quote format_guid="'.$this->mInfo['format_guid'].'" comment_id="'.$this->mCommentId.'" user="'.$this->mInfo['login'].'"}'.trim($data).'{/quote}';
}
- // Basic formatting for quoting comments
- function quoteComment($commentData) {
+ // Basic formatting for quoting comments
+ function quoteComment($commentData) {
$ret = '> '.$commentData;
$ret = mb_eregi_replace("\n", "\n>", $ret);
return $ret;
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php
index 854847c..cc8cdb7 100755
--- a/includes/classes/LibertyContent.php
+++ b/includes/classes/LibertyContent.php
@@ -22,6 +22,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\BitCacheable;
use Bitweaver\BitSystem;
@@ -132,7 +133,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return !$gBitSystem->isLive();
}
-
public function isCacheableObject() {
return parent::isCacheableObject() && !empty( $this->mContentId );
}
@@ -410,7 +410,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
// store any messages in the logs
$this->storeActionLog( $pParamHash );
-
$this->CompleteTrans();
}
return count( $this->mErrors ) == 0;
@@ -432,7 +431,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
}
}
parent::expunge();
- return;
+
}
/**
@@ -636,8 +635,8 @@ class LibertyContent extends LibertyBase implements BitCacheable {
$data = [];
while( !$result->EOF ) {
$aux = $result->fields;
- $aux['creator'] = isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'];
- $aux['editor'] = isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'];
+ $aux['creator'] = $aux['creator_real_name'] ?? $aux['creator_user'];
+ $aux['editor'] = $aux['modifier_real_name'] ?? $aux['modifier_user'];
$data[] = $aux;
//array_push( $ret, $aux );
$result->MoveNext();
@@ -676,10 +675,10 @@ class LibertyContent extends LibertyBase implements BitCacheable {
$res = $result->fetchRow();
$this->rollbackVersion( $res["version"] );
$this->expungeVersion( $res["version"] );
- } else {
+ }
// @TODO Build missing function
// $this->remove_all_versions($page);
- }
+
$action = "Removed last version";
$t = $gBitSystem->getUTCTime();
$query = "insert into `".BIT_DB_PREFIX."liberty_action_log`( `log_message`, `content_id`, `last_modified`, `user_id`, `ip`, `error_message`) values( ?, ?, ?, ?, ?, ?)";
@@ -842,7 +841,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
} elseif( $this->isValid() && @$this->verifyId( $this->mInfo['user_id'] ?? 0 ) ) {
$user_id = $this->mInfo['user_id'];
} else {
- $user_id = ANONYMOUS_USER_ID;
+ $user_id = ANONYMOUS_USER_ID;
}
return $user_id != ANONYMOUS_USER_ID && BitBase::verifyId( $user_id ) && $user_id == $gBitUser->mUserId;
}
@@ -1180,7 +1179,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
}
}
-
// -------------------------------- Content Permission Functions
/**
@@ -1370,7 +1368,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lcperm.`content_id`=lc.`content_id` )
LEFT OUTER JOIN `".BIT_DB_PREFIX."users_permissions` up ON( up.`perm_name`=lcperm.`perm_name` )
ORDER BY ".$gBitSystem->mDb->convertSortmode( 'content_type_guid_asc' ).", ".$gBitSystem->mDb->convertSortmode( 'title_asc' );
-
+
$perms = $gBitSystem->mDb->getAll( $query );
foreach( $perms as $perm ) {
$ret[$perm['content_type_guid']][$perm['content_id']][] = $perm;
@@ -1468,9 +1466,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
if( $this->hasAdminPermission( $pVerifyAccessControl ) ) {
return true;
- } else {
- $gBitSystem->fatalPermission( $this->mAdminContentPerm );
}
+ $gBitSystem->fatalPermission( $this->mAdminContentPerm );
+
return false;
}
@@ -1493,9 +1491,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
if( $this->hasExpungePermission( $pVerifyAccessControl ) ) {
return true;
- } else {
- $gBitSystem->fatalPermission( $this->mExpungeContentPerm );
}
+ $gBitSystem->fatalPermission( $this->mExpungeContentPerm );
+
return false;
}
@@ -1530,9 +1528,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
if( $this->hasUpdatePermission( $pVerifyAccessControl ) ) {
return true;
- } else {
- $gBitSystem->fatalPermission( $this->mUpdateContentPerm );
}
+ $gBitSystem->fatalPermission( $this->mUpdateContentPerm );
+
return false;
}
@@ -1565,9 +1563,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
if( !$this->isValid() && $this->hasCreatePermission( $pVerifyAccessControl ) ) {
return true;
- } else {
- $gBitSystem->fatalPermission( $this->mCreateContentPerm );
}
+ $gBitSystem->fatalPermission( $this->mCreateContentPerm );
+
return false;
}
@@ -1593,9 +1591,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
if( $this->hasViewPermission( $pVerifyAccessControl ) ) {
return true;
- } else {
- $gBitSystem->fatalPermission( $this->mViewContentPerm );
}
+ $gBitSystem->fatalPermission( $this->mViewContentPerm );
+
return false;
}
@@ -1617,7 +1615,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
*/
public function verifyPostCommentsPermission( $pVerifyAccessControl=true ) {
global $gBitSystem;
-// @TODO Missing function
+// @TODO Missing function
/* if( $this->hasPostCommentPermission( $pVerifyAccessControl ) ) {
return true;
} else {
@@ -1759,7 +1757,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return false;
}
-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Preferences Functions
/**
@@ -1832,7 +1829,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
$this->mPrefs[$pPrefName] = $pPrefValue;
}
-
/**
* Saves a preference to the liberty_content_prefs database table with the given pref name and value. If the value is null, the existing value will be delete and the value will not be saved. However, a zero will be stored. This will update the mPrefs hash.
*
@@ -1917,7 +1913,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return true;
}
-
/**
* Get Hits and Last Hit
*
@@ -2062,7 +2057,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
* Get the display name of the content type
* @param boolean $pPlural true will return the plural form of the content type display name
* @return string the display name of the content type
- */
+ */
public function getContentTypeName( $pPlural=false ){
global $gLibertySystem;
return $gLibertySystem->getContentTypeName( $this->getContentType(), $pPlural );
@@ -2091,7 +2086,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $this->getContentTypeName();
}
-
/**
* returns a path to the template type requested
* this is intended for package override. while not a requirement please use a naming convention of center_<action>_<content_type_guid>.tpl for new tpls
@@ -2233,7 +2227,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $ret;
}
-
/**
* Not-so-pure virtual function that returns Request_URI to the preview.
* @param string Text for DisplayLink function
@@ -2253,7 +2246,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $ret;
}
-
/**
* Not-so-pure virtual function that returns Request_URI to a content's thumbnail representation. It is up to the derived content what exactly this means
* If not implemented in the content's class, this class will return null, which is an acceptable case meaning no thumbnail is available.
@@ -2271,7 +2263,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return '';
}
-
public static function getThumbnailUrlFromHash( array &$pMixed, string $pSize = 'small', ?int $pSecondaryId = null, ?int $pDefault = null ): string {
$ret = '';
if( !empty( $pMixed['content_type']['handler_package'] ) ) {
@@ -2285,7 +2276,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $ret;
}
-
public function getThumbnailUri( string $pSize='small' ) {
if( $this->isValid() ) {
return $this->getThumbnailUriFromHash( $this->mInfo, $pSize );
@@ -2301,7 +2291,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $ret;
}
-
public function getThumbnailFile( $pSize='small' ) {
if( $this->isValid() ) {
return $this->getThumbnailFileFromHash( $this->mInfo, $pSize );
@@ -2317,7 +2306,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return BIT_ROOT_PATH.$ret;
}
-
/**
* Validate inbound sort_mode parameter
* @param array pParamHash hash of parameters for any getList() function
@@ -2358,7 +2346,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
return $this->mDb->convertSortmode( $pSortMode );
}
-
/**
* Liberty override to stuff content_status_id and prepares parameters with default values for any getList function
* @param array pListHash hash of parameters for any getList() function
@@ -2366,9 +2353,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
*/
public static function prepGetList( array &$pListHash ): void {
global $gBitUser;
- $pListHash['min_content_status_id'] = $gBitUser->isAdmin() ? -9999 : 1;
-// if( !empty( $this ) && is_object( $this ) ) {
-// $pListHash['min_content_status_id'] = $this->hasAdminPermission() ? -999
+ $pListHash['min_content_status_id'] = $gBitUser->isAdmin() ? -9999 : 1;
+// if( !empty( $this ) && is_object( $this ) ) {
+// $pListHash['min_content_status_id'] = $this->hasAdminPermission() ? -999
// : $this->hasUpdatePermission() ? -99 : 1;
// }
@@ -2485,7 +2472,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
}
$selectSql = !empty( $hashSql['select'] ) ? ','.implode( ',', $hashSql['select'] ) : '';
-
+
$joinSql = implode( ' ', $hashSql['join'] );
if( !empty( $pListHash['join_sql'] ) ) {
$joinSql .= $pListHash['join_sql'];
@@ -2724,7 +2711,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
$pListHash['offset'] = $pListHash['max_records'] * $lastPageNumber;
}
-
if( !empty( $hashBindVars['select'] ) ) {
$bindVars = array_merge($hashBindVars['select'], $bindVars);
}
@@ -2737,9 +2723,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
// quick alias for code readability
$type = &$contentTypes[$aux['content_type_guid']];
$aux['content_name'] = $type['content_name'];
- $aux['creator'] = isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'];
- $aux['real_name'] = isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'];
- $aux['editor'] = isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'];
+ $aux['creator'] = $aux['creator_real_name'] ?? $aux['creator_user'];
+ $aux['real_name'] = $aux['creator_real_name'] ?? $aux['creator_user'];
+ $aux['editor'] = $aux['modifier_real_name'] ?? $aux['modifier_user'];
$aux['user'] = $aux['creator_user'];
$aux['user_id'] = $aux['creator_user_id'];
if( !empty( $gBitSystem->mPackages[$type['handler_package']] ) ) {
@@ -3251,7 +3237,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitSystem;
$ret = null;
if( is_file( $pCacheFile ) && ( time() - filemtime( $pCacheFile )) < $gBitSystem->getConfig('liberty_cache') && filesize( $pCacheFile ) > 0 ) {
- // get contents from cacgmstrftime(he file
+ // get contents from cacgmstrftime(he file
$h = fopen( $pCacheFile, 'r' );
$ret = fread( $h, filesize( $pCacheFile ) );
fclose( $h );
@@ -3287,9 +3273,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
public static function getCacheFile( $pContentId = null, $pCacheExtension = null ) {
if( $ret = LibertyContent::getCachePath( $pContentId ) ) {
return $ret.$pContentId.( !empty( $pCacheExtension ) ? '.'.$pCacheExtension : '');
- } else {
- return false;
}
+ return false;
+
}
/**
@@ -3559,7 +3545,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
while( $aux = $result->fetchRow() ) {
$aux['user'] = $aux['modifier_user'];
- $aux['editor'] = isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'];
+ $aux['editor'] = $aux['modifier_real_name'] ?? $aux['modifier_user'];
$aux['display_name'] = RoleUser::getDisplayNameFromHash( $aux );
$ret[] = $aux;
}
@@ -3603,9 +3589,9 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitUser;
if( $gBitUser->hasPermission( 'p_liberty_edit_all_status' )) {
return $this->mDb->getAssoc( "SELECT `content_status_id`,`content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` ORDER BY `content_status_id`" );
- } else {
- return $this->mDb->getAssoc( "SELECT `content_status_id`, `content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` WHERE `content_status_id` > ? AND `content_status_id` < ? ORDER BY `content_status_id`", [ $pUserMinimum, $pUserMaximum ]);
}
+ return $this->mDb->getAssoc( "SELECT `content_status_id`, `content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` WHERE `content_status_id` > ? AND `content_status_id` < ? ORDER BY `content_status_id`", [ $pUserMinimum, $pUserMaximum ]);
+
}
/**
@@ -3749,10 +3735,10 @@ class LibertyContent extends LibertyBase implements BitCacheable {
public function isCommentable() {
if( $this->getPreference( 'allow_comments' ) == 'y' ) {
return true;
- } else {
+ }
$setting = $this->getField( 'allow_comments' );
return $setting == true || $setting == 'y';
- }
+
}
/**
diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php
index 30fe4d5..7dce907 100755
--- a/includes/classes/LibertyMime.php
+++ b/includes/classes/LibertyMime.php
@@ -9,6 +9,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
@@ -48,7 +49,7 @@ class LibertyMime extends LibertyContent {
}
$query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`content_id`=? ORDER BY la.`pos` ASC, la.`attachment_id` ASC";
- if( $result = $this->mDb->query( $query,array( $this->mContentId ))) {
+ if( $result = $this->mDb->query( $query,[ $this->mContentId ])) {
$this->mStorage = [];
while( $row = $result->fetchRow() ) {
if( !empty( $row['is_primary'] ) ) {
@@ -154,7 +155,7 @@ class LibertyMime extends LibertyContent {
$this->setPrimaryAttachment(
$pParamHash['liberty_attachments']['primary'],
$pParamHash['content_id'],
- empty( $pParamHash['liberty_attachments']['auto_primary'] ) || $pParamHash['liberty_attachments']['auto_primary'] ? true : false
+ empty( $pParamHash['liberty_attachments']['auto_primary'] ) || $pParamHash['liberty_attachments']['auto_primary'] ? true : false,
);
// Roll back if something went wrong
@@ -373,7 +374,7 @@ class LibertyMime extends LibertyContent {
}
function getSourceFile( $pParamHash=[] ) {
- $ret = null;
+ $ret = null;
if( empty( $pParamHash ) && !empty( $this ) ) {
$pParamHash = $this->mInfo;
}
@@ -389,7 +390,6 @@ class LibertyMime extends LibertyContent {
return $ret;
}
-
/**
* getStoragePath - get path to store files for the feature site_upload_dir. It creates a calculable hierarchy of directories
*
@@ -401,11 +401,10 @@ class LibertyMime extends LibertyContent {
* @return string full path on local filsystem to store files.
*/
function getStoragePath( $pParamHash, $pRootDir=null ) {
- $ret = liberty_mime_get_storage_path( $pParamHash, $pRootDir );
- return $ret;
+ $ret = liberty_mime_get_storage_path( $pParamHash, $pRootDir );
+ return $ret;
}
-
function getStorageUrl( $pParamHash ) {
return STORAGE_PKG_URL.liberty_mime_get_storage_branch( $pParamHash );
}
@@ -466,7 +465,6 @@ class LibertyMime extends LibertyContent {
// }}}
-
// {{{ =================== Attachment Methods ====================
/**
* Get a list of all available attachments
@@ -474,7 +472,7 @@ class LibertyMime extends LibertyContent {
* @param array $pListHash
* @access public
* @return array
- */
+ */
public function getAttachmentList( &$pListHash ): array {
global $gLibertySystem, $gBitUser, $gBitSystem;
@@ -553,27 +551,27 @@ class LibertyMime extends LibertyContent {
$ret = null;
if( @$this->verifyId( $pAttachmentId ) ) {
$sql = "SELECT `attachment_plugin_guid`, `user_id` FROM `".BIT_DB_PREFIX."liberty_attachments` WHERE `attachment_id` = ?";
- if(( $row = $this->mDb->getRow( $sql, array( $pAttachmentId ))) && ( $this->isOwner( $row ) || $gBitUser->isAdmin() )) {
+ if(( $row = $this->mDb->getRow( $sql, [ $pAttachmentId ])) && ( $this->isOwner( $row ) || $gBitUser->isAdmin() )) {
// check if we have the means available to remove this attachment
if(( $guid = $row['attachment_plugin_guid'] ) && $expungeFunc = $gLibertySystem->getPluginFunction( $guid, 'expunge_function', 'mime' )) {
// --- Do the final cleanup of liberty related tables ---
// there might be situations where we remove user images including portrait, avatar or logo
// This needs to happen before the plugin can do it's work due to constraints
- $types = array( 'portrait', 'avatar', 'logo' );
+ $types = [ 'portrait', 'avatar', 'logo' ];
foreach( $types as $type ) {
$sql = "UPDATE `".BIT_DB_PREFIX."users_users` SET `{$type}_attachment_id` = null WHERE `{$type}_attachment_id` = ?";
- $this->mDb->query( $sql, array( $pAttachmentId ));
+ $this->mDb->query( $sql, [ $pAttachmentId ]);
}
if( $expungeFunc( $pAttachmentId )) {
// Delete the attachment meta data, prefs and record.
$sql = "DELETE FROM `".BIT_DB_PREFIX."liberty_attachment_meta_data` WHERE `attachment_id` = ?";
- $this->mDb->query( $sql, array( $pAttachmentId ));
+ $this->mDb->query( $sql, [ $pAttachmentId ]);
$sql = "DELETE FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?";
- $this->mDb->query( $sql, array( $pAttachmentId ));
+ $this->mDb->query( $sql, [ $pAttachmentId ]);
$sql = "DELETE FROM `".BIT_DB_PREFIX."liberty_attachments` WHERE `attachment_id`=?";
- $this->mDb->query( $sql, array( $pAttachmentId ));
+ $this->mDb->query( $sql, [ $pAttachmentId ]);
// Remove attachment from memory
unset( $this->mStorage[$pAttachmentId] );
@@ -602,11 +600,11 @@ class LibertyMime extends LibertyContent {
if( BitBase::verifyId( $pAttachmentId )) {
$query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`attachment_id`=?";
- if( $result = $gBitSystem->mDb->query( $query, array( (int)$pAttachmentId ))) {
+ if( $result = $gBitSystem->mDb->query( $query, [ (int)$pAttachmentId ])) {
if( $row = $result->fetchRow() ) {
if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function', 'mime' )) {
$sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?";
- $prefs = $gBitSystem->mDb->getAssoc( $sql, array( $pAttachmentId ));
+ $prefs = $gBitSystem->mDb->getAssoc( $sql, [ $pAttachmentId ]);
$ret = $func( $row, $prefs, $pParams );
}
}
@@ -629,7 +627,7 @@ class LibertyMime extends LibertyContent {
if( BitBase::verifyId( $pAttachmentId )) {
$query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`attachment_id`=?";
- if( $result = $gBitSystem->mDb->query( $query, array( (int)$pAttachmentId ))) {
+ if( $result = $gBitSystem->mDb->query( $query, [ (int)$pAttachmentId ])) {
if( $row = $result->fetchRow() ) {
if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function', 'mime' )) {
$prefs = static::getAttachmentPreferences( $pAttachmentId );
@@ -682,7 +680,7 @@ class LibertyMime extends LibertyContent {
$query = "
UPDATE `".BIT_DB_PREFIX."liberty_attachments`
SET `is_primary` = ? WHERE `attachment_id` = ?";
- $this->mDb->query( $query, array( 'y', $pAttachmentId ));
+ $this->mDb->query( $query, [ 'y', $pAttachmentId ]);
$ret = true;
// Otherwise, are we supposed to clear the primary entirely?
@@ -708,7 +706,7 @@ class LibertyMime extends LibertyContent {
$query = "
UPDATE `".BIT_DB_PREFIX."liberty_attachments`
SET `is_primary` = ? WHERE `content_id` = ?";
- $this->mDb->query( $query, array( null, $pContentId ));
+ $this->mDb->query( $query, [ null, $pContentId ]);
$ret = true;
}
@@ -716,7 +714,6 @@ class LibertyMime extends LibertyContent {
}
// }}}
-
/**
* === Attachment Preferences ===
*/
@@ -757,7 +754,7 @@ class LibertyMime extends LibertyContent {
if( BitBase::verifyId( $pAttachmentId ) ) {
// if the object isn't loaded, we need to get the prefs from the database
$sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?";
- $ret = $gBitSystem->mDb->getAssoc( $sql, array( (int)$pAttachmentId ));
+ $ret = $gBitSystem->mDb->getAssoc( $sql, [ (int)$pAttachmentId ]);
}
return $ret;
@@ -857,7 +854,7 @@ class LibertyMime extends LibertyContent {
$ret = false;
if( BitBase::verifyId( $pAttachmentId ) ) {
$sql = "DELETE FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?";
- $gBitSystem->mDb->query( $sql, array( $pAttachmentId ));
+ $gBitSystem->mDb->query( $sql, [ $pAttachmentId ]);
$ret = true;
}
return $ret;
@@ -913,9 +910,9 @@ class LibertyMime extends LibertyContent {
}
$ret = true;
- } else {
- // should we recurse?
}
+ // should we recurse?
+
}
}
}
@@ -958,7 +955,7 @@ class LibertyMime extends LibertyContent {
global $gBitSystem;
$ret = [];
if( BitBase::verifyId( $pAttachmentId )) {
- $bindVars = array( $pAttachmentId );
+ $bindVars = [ $pAttachmentId ];
$whereSql = "";
if( !empty( $pType ) && !empty( $pTitle )) {
@@ -1045,7 +1042,7 @@ class LibertyMime extends LibertyContent {
global $gBitSystem;
$ret = false;
if( !empty( $pDescription ) && ( $pTable == 'type' || $pTable == 'title' )) {
- $ret = $gBitSystem->mDb->getOne( "SELECT `meta_{$pTable}_id` FROM `".BIT_DB_PREFIX."liberty_meta_{$pTable}s` WHERE `meta_{$pTable}` = ?", array( LibertyMime::normalizeMetaDescription( $pDescription )));
+ $ret = $gBitSystem->mDb->getOne( "SELECT `meta_{$pTable}_id` FROM `".BIT_DB_PREFIX."liberty_meta_{$pTable}s` WHERE `meta_{$pTable}` = ?", [ LibertyMime::normalizeMetaDescription( $pDescription )]);
}
return $ret;
}
@@ -1062,7 +1059,7 @@ class LibertyMime extends LibertyContent {
global $gBitSystem;
$ret = false;
if( BitBase::verifyId( $pId )) {
- $ret = $gBitSystem->mDb->getOne( "SELECT `meta_{$pTable}` FROM `".BIT_DB_PREFIX."liberty_meta_{$pTable}s` WHERE `meta_{$pTable}_id` = ?", array( $pId ));
+ $ret = $gBitSystem->mDb->getOne( "SELECT `meta_{$pTable}` FROM `".BIT_DB_PREFIX."liberty_meta_{$pTable}s` WHERE `meta_{$pTable}_id` = ?", [ $pId ]);
}
return $ret;
}
@@ -1188,7 +1185,7 @@ if( !function_exists( '\Bitweaver\Liberty\liberty_mime_get_source_url' )) {
function liberty_mime_get_source_url( $pParamHash ) {
$fileName = BitBase::getParameter( $pParamHash, 'file_name' );
if( empty( $pParamHash['package'] ) ) {
- $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name( array( 'mime_type' => BitBase::getParameter( $pParamHash, 'mime_type' ), 'name' => $fileName ) );
+ $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name( [ 'mime_type' => BitBase::getParameter( $pParamHash, 'mime_type' ), 'name' => $fileName ] );
}
if( empty( $pParamHash['sub_dir'] ) ) {
$pParamHash['sub_dir'] = BitBase::getParameter( $pParamHash, 'attachment_id' );
@@ -1206,7 +1203,7 @@ if( !function_exists( '\Bitweaver\Liberty\liberty_mime_get_source_file' )) {
function liberty_mime_get_source_file( $pParamHash ) {
$fileName = BitBase::getParameter( $pParamHash, 'file_name' );
if( empty( $pParamHash['package'] ) ) {
- $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name( array( 'mime_type' => BitBase::getParameter( $pParamHash, 'mime_type' ), 'name' => $fileName ) );
+ $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name( [ 'mime_type' => BitBase::getParameter( $pParamHash, 'mime_type' ), 'name' => $fileName ] );
}
if( empty( $pParamHash['sub_dir'] ) ) {
$pParamHash['sub_dir'] = BitBase::getParameter( $pParamHash, 'attachment_id' );
diff --git a/includes/classes/LibertyStructure.php b/includes/classes/LibertyStructure.php
index b645eeb..eeaf043 100755
--- a/includes/classes/LibertyStructure.php
+++ b/includes/classes/LibertyStructure.php
@@ -10,6 +10,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
@@ -107,7 +108,7 @@ class LibertyStructure extends LibertyBase {
$ret = false;
if( !empty( $this->mInfo['content_object'] ) && is_a( $this->mInfo['content_object'], 'LibertyContent' ) ) {
return $this->mInfo['content_object']->hasUpdatePermission( $pVerifyAccessControl ) || empty( $this->mInfo['content_object']->mViewContentPerm ) || $this->mInfo['content_object']->hasUserPermission( $this->mInfo['content_object']->mViewContentPerm, $pVerifyAccessControl );
- }
+ }
return $ret;
}
@@ -180,7 +181,6 @@ class LibertyStructure extends LibertyBase {
}
}
-
public function isValid() {
return $this->verifyId( $this->mStructureId );
}
@@ -383,7 +383,7 @@ class LibertyStructure extends LibertyBase {
if( !empty( $pListHash['find'] ) ) {
$findesc = '%' . $pListHash['find'] . '%';
$mid = " (`parent_id` is null or `parent_id`=0) and (lc.`title` like ?)";
- $bindVars=array($findesc);
+ $bindVars=[$findesc];
} else {
$mid = " (`parent_id` is null or `parent_id`=0) ";
$bindVars=[];
@@ -474,7 +474,6 @@ class LibertyStructure extends LibertyBase {
//vd( $storeNodes );
}
-
// deprecated flat tree store, code is unused AFAIK.-- spiderr
if( !empty( $pParamHash['structure'] ) ) {
// LibertyStructure::embellishStructureHash( $pParamHash['structure'] );
@@ -581,13 +580,13 @@ class LibertyStructure extends LibertyBase {
$pParamHash['alias'] = '';
}
$pParamHash['max'] = isset( $pParamHash['after_ref_id'] )
- ? $this->mDb->getOne("select `pos` from `".BIT_DB_PREFIX."liberty_structures` where `structure_id`=?",array((int)$pParamHash['after_ref_id']))
- : $this->mDb->getOne("select max(`pos`) from `".BIT_DB_PREFIX."liberty_structures` where `parent_id`=?",array((int)$pParamHash['parent_id']));
+ ? $this->mDb->getOne("select `pos` from `".BIT_DB_PREFIX."liberty_structures` where `structure_id`=?",[(int)$pParamHash['after_ref_id']])
+ : $this->mDb->getOne("select max(`pos`) from `".BIT_DB_PREFIX."liberty_structures` where `parent_id`=?",[(int)$pParamHash['parent_id']]);
if( $pParamHash['max'] > 0 ) {
// For example, if max is 5 then we are inserting after position 5 so we'll insert 5 and move all the others
$query = "update `".BIT_DB_PREFIX."liberty_structures` set `pos`=`pos`+1 where `pos`>? and `parent_id`=?";
- $result = $this->mDb->query($query,array((int)$pParamHash['max'], (int)$pParamHash['parent_id']));
+ $result = $this->mDb->query($query,[(int)$pParamHash['max'], (int)$pParamHash['parent_id']]);
}
$pParamHash['max']++;
@@ -625,9 +624,9 @@ class LibertyStructure extends LibertyBase {
$result = $this->mDb->query( $query, [ $pParamHash['structure_id'], $pParamHash['parent_id'], (int)$pParamHash['content_id'], (int)$pParamHash['root_structure_id'], $pParamHash['alias'], $pParamHash['max'] ] );
$this->CompleteTrans();
$ret = (int) $pParamHash['structure_id'];
- } else {
- //vd( $this->mErrors );
}
+ //vd( $this->mErrors );
+
return $ret;
}
@@ -664,11 +663,11 @@ class LibertyStructure extends LibertyBase {
if( $this->isValid() ) {
$this->StartTrans();
$query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."liberty_structures` where `pos`<? and `parent_id`=? order by `pos` desc";
- $result = $this->mDb->query($query,array($this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ $result = $this->mDb->query($query,[$this->mInfo["pos"], (int)$this->mInfo["parent_id"]]);
if ($previous = $result->fetchRow()) {
//Get last child nodes for previous sibling
$query = "select `pos` from `".BIT_DB_PREFIX."liberty_structures` where `parent_id`=? order by `pos` desc";
- $result = $this->mDb->query($query,array((int)$previous["structure_id"]));
+ $result = $this->mDb->query($query,[(int)$previous["structure_id"]]);
$pos = ($res = $result->fetchRow()) ? $res["pos"] : 0;
$query = "update `".BIT_DB_PREFIX."liberty_structures` set `parent_id`=?, `pos`=(? + 1) where `structure_id`=?";
@@ -690,13 +689,13 @@ class LibertyStructure extends LibertyBase {
if( $this->isValid() ) {
$this->StartTrans();
$query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."liberty_structures` where `pos`>? and `parent_id`=? order by `pos` asc";
- $result = $this->mDb->query($query,array((int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ $result = $this->mDb->query($query,[(int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]]);
$res = $result->fetchRow();
if ($res) {
//Swap position values
$query = "update `".BIT_DB_PREFIX."liberty_structures` set `pos`=? where `structure_id`=?";
- $this->mDb->query($query,array((int)$this->mInfo["pos"], (int)$res["structure_id"]) );
- $this->mDb->query($query,array((int)$res["pos"], (int)$this->mInfo["structure_id"]) );
+ $this->mDb->query($query,[(int)$this->mInfo["pos"], (int)$res["structure_id"]] );
+ $this->mDb->query($query,[(int)$res["pos"], (int)$this->mInfo["structure_id"]] );
}
$this->CompleteTrans();
}
@@ -711,30 +710,20 @@ class LibertyStructure extends LibertyBase {
if( $this->isValid() ) {
$this->StartTrans();
$query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."liberty_structures` where `pos`<? and `parent_id`=? order by `pos` desc";
- $result = $this->mDb->query($query,array((int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ $result = $this->mDb->query($query,[(int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]]);
$res = $result->fetchRow();
if ($res) {
//Swap position values
$query = "update `".BIT_DB_PREFIX."liberty_structures` set `pos`=? where `structure_id`=?";
- $this->mDb->query($query,array((int)$res["pos"], (int)$this->mInfo["structure_id"]) );
- $this->mDb->query($query,array((int)$this->mInfo["pos"], (int)$res["structure_id"]) );
+ $this->mDb->query($query,[(int)$res["pos"], (int)$this->mInfo["structure_id"]] );
+ $this->mDb->query($query,[(int)$this->mInfo["pos"], (int)$res["structure_id"]] );
}
$this->CompleteTrans();
}
}
-
-
-
-
-
-
-
-
// ============== OLD struct_lib STUFF
-
-
public function removeStructureNode( $structure_id, $delete=false ) {
// Now recursively remove
if( @$this->verifyId( $structure_id ) ) {
@@ -883,7 +872,6 @@ class LibertyStructure extends LibertyBase {
return $ret;
}
-
/**
* buildSubtreeToc
*
@@ -895,7 +883,7 @@ class LibertyStructure extends LibertyBase {
public function buildSubtreeToc( $id, $order='asc', $tocPrefix='', $pPrefixDepth=1, $pDepth=1 ) {
global $gLibertySystem, $gBitSystem;
$back = [];
- $cant = $this->mDb->getOne("select count(*) from `".BIT_DB_PREFIX."liberty_structures` where `parent_id`=?",array((int)$id));
+ $cant = $this->mDb->getOne("select count(*) from `".BIT_DB_PREFIX."liberty_structures` where `parent_id`=?",[(int)$id]);
if ($cant) {
$query = "SELECT `structure_id`, `root_structure_id`, `parent_id`, `page_alias`, `pos`, `structure_level`, lc.`user_id`, lc.`title`, lc.`content_type_guid`, uu.`login`, uu.`real_name`, lc.`content_id`, lc.`last_modified`, lct.*
FROM `".BIT_DB_PREFIX."liberty_structures` ls
@@ -904,7 +892,7 @@ class LibertyStructure extends LibertyBase {
LEFT JOIN `".BIT_DB_PREFIX."users_users` uu ON ( uu.`user_id` = lc.`user_id` )
WHERE `parent_id`=?
ORDER BY ".$this->mDb->convertSortmode("pos_".$order);
- $result = $this->mDb->query($query,array((int)$id));
+ $result = $this->mDb->query($query,[(int)$id]);
$prefix = 1;
$contentTypes = $gLibertySystem->mContentTypes;
while ($res = $result->fetchRow()) {
@@ -1011,7 +999,7 @@ class LibertyStructure extends LibertyBase {
* @param int $structure_id
* @param bool $deep
* @return int
- */
+ */
public function getNextStructureNode($structure_id, $deep = true) {
// If we have children then get the first child
if ($deep) {
@@ -1019,7 +1007,7 @@ class LibertyStructure extends LibertyBase {
FROM `".BIT_DB_PREFIX."liberty_structures` ls
WHERE `parent_id`=?
ORDER BY ".$this->mDb->convertSortmode("pos_asc");
- $result1 = $this->mDb->query($query,array((int)$structure_id));
+ $result1 = $this->mDb->query($query,[(int)$structure_id]);
if ($result1->numRows()) {
$res = $result1->fetchRow();
@@ -1039,15 +1027,15 @@ class LibertyStructure extends LibertyBase {
FROM `".BIT_DB_PREFIX."liberty_structures` ls
WHERE `parent_id`=? and `pos`>?
ORDER BY ".$this->mDb->convertSortmode("pos_asc");
- $result2 = $this->mDb->query($query,array((int)$parent_id, (int)$page_pos));
+ $result2 = $this->mDb->query($query,[(int)$parent_id, (int)$page_pos]);
if ($result2->numRows()) {
$res = $result2->fetchRow();
return $res["structure_id"];
}
- else {
+
return $this->getNextStructureNode($parent_id, false);
- }
+
}
/**
@@ -1064,7 +1052,7 @@ class LibertyStructure extends LibertyBase {
$query .= "from `".BIT_DB_PREFIX."liberty_structures` ls ";
$query .= "where `parent_id`=? ";
$query .= "order by ".$this->mDb->convertSortmode("pos_desc");
- $result = $this->mDb->query($query,array($structure_id));
+ $result = $this->mDb->query($query,[$structure_id]);
if ($result->numRows()) {
//There are more children
@@ -1086,7 +1074,7 @@ class LibertyStructure extends LibertyBase {
$query .= "from `".BIT_DB_PREFIX."liberty_structures` ls ";
$query .= "where `parent_id`=? and `pos`<? ";
$query .= "order by ".$this->mDb->convertSortmode("pos_desc");
- $result = $this->mDb->query($query,array((int)$parent_id, (int)$pos));
+ $result = $this->mDb->query($query,[(int)$parent_id, (int)$pos]);
if ($result->numRows()) {
//There is a previous sibling
@@ -1112,7 +1100,7 @@ class LibertyStructure extends LibertyBase {
FROM `".BIT_DB_PREFIX."liberty_structures` ls, `".BIT_DB_PREFIX."liberty_content` lc
WHERE ls.`content_id` = lc.`content_id` AND `parent_id`=? ";
$query .= "order by ".$this->mDb->convertSortmode("pos_asc");
- $result = $this->mDb->query($query,array((int)$pParentId));
+ $result = $this->mDb->query($query,[(int)$pParentId]);
while ($res = $result->fetchRow()) {
//$ret[] = $this->populate_page_info($res);
$ret[] = $res;
diff --git a/includes/classes/LibertySystem.php b/includes/classes/LibertySystem.php
index 5883041..6eca60b 100755
--- a/includes/classes/LibertySystem.php
+++ b/includes/classes/LibertySystem.php
@@ -20,6 +20,7 @@
// +----------------------------------------------------------------------+
namespace Bitweaver\Liberty;
+
use Bitweaver\BitSingleton;
use Bitweaver\KernelTools;
@@ -74,7 +75,6 @@ define( 'LIBERTY_UPLOAD', 'upload' );
#[\AllowDynamicProperties]
class LibertySystem extends BitSingleton {
-
// Hash of plugin data
public $mPlugins = [];
@@ -114,9 +114,8 @@ class LibertySystem extends BitSingleton {
$this->loadContentTypes();
}
-
public function __sleep() {
- return array_merge( parent::__sleep(), array( 'mPlugins', 'mDataTags', 'mContentStatus', 'mContentTypes', 'mPluginFileName', 'mSystem', 'mPluginPath' ) );
+ return array_merge( parent::__sleep(), [ 'mPlugins', 'mDataTags', 'mContentStatus', 'mContentTypes', 'mPluginFileName', 'mSystem', 'mPluginPath' ] );
}
// ****************************** Plugin Functions
@@ -294,7 +293,7 @@ class LibertySystem extends BitSingleton {
global $gBitSystem;
// plugins can set their own file_name. this is not mandatory but makes sure we store the path to the correct file
// this is useful for files that are included by other plugins
- $pluginPath = !empty( $pPluginParams['file_name'] )
+ $pluginPath = !empty( $pPluginParams['file_name'] )
? dirname( $this->mPluginFilePath ) . "/" . $pPluginParams['file_name']
: $this->mPluginFilePath;
@@ -311,7 +310,7 @@ class LibertySystem extends BitSingleton {
$pPluginParams['load_function'] = '\\Bitweaver\\Liberty\\' . $pPluginParams['load_function'];
}
if ( !empty( $pPluginParams['branch_function'] ) ) {
- $pPluginParams['branch_function'] = '\\Bitweaver\\Liberty\\' . $pPluginParams['branch_function'];
+ $pPluginParams['branch_function'] = '\\Bitweaver\\Liberty\\' . $pPluginParams['branch_function'];
}
if ( !empty( $pPluginParams['download_function'] ) ) {
$pPluginParams['download_function'] = '\\Bitweaver\\Liberty\\' . $pPluginParams['download_function'];
@@ -638,7 +637,7 @@ class LibertySystem extends BitSingleton {
( empty( $this->mContentTypes[$pGuid]['content_name_plural'] ) && version_compare( $gBitSystem->getVersion( LIBERTY_PKG_NAME ), '2.1.4', '>=' ) ) // temporary update condition during migration of content_description to content_name remove after april 20 2011
) {
$this->StartTrans();
- $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."liberty_content_types", $pTypeParams, array( 'content_type_guid'=>$pGuid ) );
+ $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."liberty_content_types", $pTypeParams, [ 'content_type_guid'=>$pGuid ] );
$this->CompleteTrans();
// we just ran some SQL - let's flush the loadContentTypes query cache
$this->loadContentTypes( 0 );
@@ -672,14 +671,14 @@ class LibertySystem extends BitSingleton {
* Get the display name of the content type
* @param boolean $pPlural true will return the plural form of the content type display name
* @return string the display name of the content type
- */
+ */
function getContentType( $pContentTypeGuid ){
$ret = null;
if( !isset( $this->mContentTypes ) ) {
$this->loadContentTypes();
}
if( !empty( $this->mContentTypes[$pContentTypeGuid] ) ) {
- $ret = $this->mContentTypes[$pContentTypeGuid];
+ $ret = $this->mContentTypes[$pContentTypeGuid];
}
return $ret;
}
@@ -688,14 +687,14 @@ class LibertySystem extends BitSingleton {
* Get the display name of the content type
* @param boolean $pPlural true will return the plural form of the content type display name
* @return string the display name of the content type
- */
+ */
public function getContentClassName( $pContentTypeGuid ) {
$ret = null;
if( !isset( $this->mContentTypes ) ) {
$this->loadContentTypes();
}
if( !empty( $this->mContentTypes[$pContentTypeGuid] ) && $this->requireHandlerFile( $this->mContentTypes[$pContentTypeGuid] ) ) {
- $ret = '\\Bitweaver\\'. ucfirst( $this->mContentTypes[$pContentTypeGuid]['handler_package'] ) . '\\' . $this->mContentTypes[$pContentTypeGuid]['handler_class'];
+ $ret = '\\Bitweaver\\'. ucfirst( $this->mContentTypes[$pContentTypeGuid]['handler_package'] ) . '\\' . $this->mContentTypes[$pContentTypeGuid]['handler_class'];
}
return $ret;
}
@@ -705,13 +704,13 @@ class LibertySystem extends BitSingleton {
* @param string $pContentTypeGuid
* @param boolean $pPlural true will return the plural form of the content type display name
* @return string the display name of the content type
- */
+ */
function getContentTypeName( $pContentTypeGuid, $pPlural=false ){
$ret = null;
if( $pPlural && isset( $this->mContentTypes[$pContentTypeGuid]['content_name_plural'] ) ) {
$ret = KernelTools::tra( $this->mContentTypes[$pContentTypeGuid]['content_name_plural'] );
} elseif( !empty( $this->mContentTypes[$pContentTypeGuid]['content_name'] ) ) {
- $ret = KernelTools::tra( $this->mContentTypes[$pContentTypeGuid]['content_name'] );
+ $ret = KernelTools::tra( $this->mContentTypes[$pContentTypeGuid]['content_name'] );
}
return $ret;
}
@@ -727,9 +726,6 @@ class LibertySystem extends BitSingleton {
return $this->getContentTypeName( $pContentType );
}
-
-
-
// ****************************** Service Functions
/**
* Get the service details of a given package
@@ -812,7 +808,7 @@ class LibertySystem extends BitSingleton {
$parts = explode( '/',$pMimeType );
if( count( $parts ) > 1 ) {
global $gBitSmarty, $gLibertySystem;
-
+
$ext = strtolower( $parts[1] );
$biticon = [
'ipackage' => 'liberty',
diff --git a/includes/comments_inc.php b/includes/comments_inc.php
index f2815e5..e40db09 100755
--- a/includes/comments_inc.php
+++ b/includes/comments_inc.php
@@ -35,7 +35,6 @@ use Bitweaver\KernelTools;
* @param string $comments_return_url The URL the user should be sent to after posting the comment (required)
**/
-
/**
* required setup
*/
@@ -335,7 +334,7 @@ if ($gContent->hasUserPermission( 'p_liberty_read_comments' )) {
&& (
BitBoardTopic::isLockedMsg( BitBase::verifyId( $storeComment->mInfo['parent_id'] )
? $storeComment->mInfo['parent_id'] : ( !BitBase::verifyId( $_REQUEST['post_comment_reply_id'] )
- ? $commentsParentId : $_REQUEST['post_comment_reply_id'] ))
+ ? $commentsParentId : $_REQUEST['post_comment_reply_id'] ), )
)
) {
unset( $_REQUEST['post_comment_request'] );
diff --git a/includes/get_content_list_inc.php b/includes/get_content_list_inc.php
index f89e1c6..b921b09 100755
--- a/includes/get_content_list_inc.php
+++ b/includes/get_content_list_inc.php
@@ -57,7 +57,7 @@ if( empty( $contentListHash ) ) {
'thumbnail_size' => !empty( $_REQUEST["thumbnail_size"] ) ? $_REQUEST["thumbnail_size"] : null,
];
- if( !empty( $_REQUEST['output'] ) && ( $_REQUEST['output'] == 'json' || $_REQUEST['output'] == 'ajax' ) ) {
+ if( !empty( $_REQUEST['output'] ) && ( $_REQUEST['output'] == 'json' || $_REQUEST['output'] == 'ajax' ) ) {
foreach( $_REQUEST as $key => $value ) {
if ( !is_array($value) ){
if( strstr( $value, ',' ) ) {
diff --git a/includes/liberty_lib.php b/includes/liberty_lib.php
index a223fba..810fdd0 100755
--- a/includes/liberty_lib.php
+++ b/includes/liberty_lib.php
@@ -18,6 +18,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
@@ -182,7 +183,6 @@ function parse_protect( &$pData, &$pReplace ) {
}
}
-
// ================== Liberty Plugin Helper ==================
/**
* pass in the plugin parameters and out comes a hash with usable styling information
@@ -273,7 +273,6 @@ function liberty_plugins_wrapper_style( $pParamHash ) {
return $ret;
}
-
// ================== Liberty Service Functions ==================
/**
* liberty_content_load_sql
@@ -415,7 +414,6 @@ function liberty_content_edit( $pObject, $pParamHash ) {
include_once LIBERTY_PKG_INCLUDE_PATH."edit_storage_inc.php";
}
-
// ================== Liberty File Processing Functions ==================
/**
@@ -459,7 +457,7 @@ function liberty_process_upload( &$pFileHash, $pMoveFile = true ) {
// Thumbs.db is a windows My Photos/ folder file, and seems to really piss off imagick
$canThumbFunc = liberty_get_function( 'can_thumbnail' );
- $ret = !empty( $canThumbFunc ) && $canThumbFunc( $pFileHash['type'] ) && $pFileHash['name'] != 'Thumbs.db'
+ $ret = !empty( $canThumbFunc ) && $canThumbFunc( $pFileHash['type'] ) && $pFileHash['name'] != 'Thumbs.db'
? liberty_process_image( $pFileHash, $pMoveFile )
: liberty_process_generic( $pFileHash, $pMoveFile );
@@ -559,9 +557,9 @@ function liberty_process_archive( &$pFileHash ) {
if( preg_match( "!^/+$!", $destDir || '' )) {
// obviously something went horribly wrong
return false;
- } else {
- return $destDir;
}
+ return $destDir;
+
}
/**
@@ -607,7 +605,6 @@ function liberty_process_generic( &$pFileHash, $pMoveFile = true ) {
return $ret;
}
-
/**
* liberty_process_image
*
@@ -712,7 +709,7 @@ function liberty_generate_thumbnails( $pFileHash ) {
// has a customer pdf rasterization function been defined?
if( function_exists( 'liberty_rasterize_pdf' ) && $rasteredFile = liberty_rasterize_pdf( $pFileHash['source_file'] ) ) {
$pFileHash['source_file'] = $rasteredFile;
- } else {
+ }
/* $magickWand = NewMagickWand();
if( !$pFileHash['error'] = liberty_magickwand_check_error( MagickReadImage( $magickWand, $pFileHash['source_file'] ), $magickWand )) {
MagickSetFormat( $magickWand, 'JPG' );
@@ -732,7 +729,7 @@ function liberty_generate_thumbnails( $pFileHash ) {
}
}
*/
- }
+
} else {
$pFileHash['dest_base_name'] = 'original';
$pFileHash['name'] = 'original.jpg';
diff --git a/includes/lookup_content_inc.php b/includes/lookup_content_inc.php
index 352ffa8..29e8728 100755
--- a/includes/lookup_content_inc.php
+++ b/includes/lookup_content_inc.php
@@ -12,6 +12,7 @@
* required setup
*/
namespace Bitweaver\Liberty;
+
use Bitweaver\BitBase;
global $gContent;
diff --git a/includes/structure_edit_inc.php b/includes/structure_edit_inc.php
index e6244dc..dd40020 100755
--- a/includes/structure_edit_inc.php
+++ b/includes/structure_edit_inc.php
@@ -12,11 +12,10 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
namespace Bitweaver\Liberty;
+
require_once '../kernel/includes/setup_inc.php';
use Bitweaver\BitBase;
use Bitweaver\KernelTools;
-use Bitweaver\Liberty\LibertyContent;
-use Bitweaver\Liberty\LibertyStructure;
if( !BitBase::verifyId( $_REQUEST["structure_id"] ) ) {
$gBitSystem->fatalError( KernelTools::tra( "No structure indicated" ));