FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-dir.php File Reference

Common Directory Functions. More...

Go to the source code of this file.

Functions

 Isdir ($mode)
 
 Isartifact ($mode)
 
 Iscontainer ($mode)
 
 DirMode2String ($Mode)
 Convert a file mode to string values. More...
 
 DirGetNonArtifact ($UploadtreePk, $uploadtree_tablename='uploadtree')
 Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk). More...
 
 _DirCmp ($a, $b)
 Compare function for usort() on directory items. More...
 
 Dir2Path ($uploadtree_pk, $uploadtree_tablename='uploadtree')
 Return the path (without artifacts) of an uploadtree_pk. More...
 
 Dir2Browse ($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
 Get an html linked string of a file browse path. More...
 
 Dir2BrowseUpload ($Mod, $UploadPk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $uploadtree_tablename='uploadtree')
 Get an html links string of a file browse path. More...
 
 Dir2FileList (&$Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
 Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file. If the pfile is a duplicate, then indent it. More...
 
 UploadtreeFileList ($Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
 Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file. If the pfile is a duplicate, then indent it. More...
 

Variables

 $DirGetNonArtifact_Prepared =0
 

Detailed Description

Common Directory Functions.

Definition in file common-dir.php.

Function Documentation

◆ _DirCmp()

_DirCmp (   $a,
  $b 
)

Compare function for usort() on directory items.

Parameters
$a$b to compare
Returns
0 if they are equal
<0 less than
>0 greater than

Definition at line 205 of file common-dir.php.

◆ Dir2Browse()

Dir2Browse (   $Mod,
  $UploadtreePk,
  $LinkLast = NULL,
  $ShowBox = 1,
  $ShowMicro = NULL,
  $Enumerate = -1,
  $PreText = '',
  $PostText = '',
  $uploadtree_tablename = "uploadtree" 
)

Get an html linked string of a file browse path.

Parameters
string$ModModule name (e.g. "browse")
int$UploadtreePk
string$LinkLastCreate link (a href) for last item and use LinkLast as the module name
bool$ShowBoxTrue to draw a box around the string
bool$ShowMicroTrue to show micro menu
int$EnumerateIf >= zero number the folder/file path (the stuff in the yellow bar) starting with the value $Enumerate
string$PreTextOptional additional text to precede the folder path
string$PostTextOptional text to follow the folder path
string$uploadtree_tablename
Returns
string of browse paths

Definition at line 263 of file common-dir.php.

◆ Dir2BrowseUpload()

Dir2BrowseUpload (   $Mod,
  $UploadPk,
  $LinkLast = NULL,
  $ShowBox = 1,
  $ShowMicro = NULL,
  $uploadtree_tablename = 'uploadtree' 
)

Get an html links string of a file browse path.

This calls Dir2Browse().

Parameters
string$ModModule name (e.g. "browse")
int$UploadPkUpload to browse
string$LinkLastCreate link (a href) for last item and use LinkLast as the module name
bool$ShowBoxDraw a box around the string (default true)
bool$ShowMicroShow micro menu (default false)
string$uploadtree_tablename
Returns
string of browse paths

Definition at line 374 of file common-dir.php.

◆ Dir2FileList()

Dir2FileList ( $Listing,
  $IfDirPlugin,
  $IfFilePlugin,
  $Count = -1,
  $ShowPhrase = 0 
)

Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file. If the pfile is a duplicate, then indent it.

Deprecated:
Convert your code to UploadtreeFileList()
Parameters
array&$ListingArray from a database selection. The SQL query should use "ORDER BY pfile_fk" so that the listing can indent duplicate pfiles
string$IfDirPluginPlugin name to use if this is a directory or any other container
string$IfFilePluginPlugin name to use if this is a file
int$CountFirst number for indexing the entries (may be -1 for no count)
int$ShowPhraseObsolete from bsam
Returns
String containing the listing.

Definition at line 403 of file common-dir.php.

◆ Dir2Path()

Dir2Path (   $uploadtree_pk,
  $uploadtree_tablename = 'uploadtree' 
)

Return the path (without artifacts) of an uploadtree_pk.

Parameters
int$uploadtree_pk
string$uploadtree_tablename
Returns
An array containing the path (with no artifacts). Each element in the path is an array containing the uploadtree record for $uploadtree_pk and its parents. The path begins with the uploadtree_pk record.
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 222 of file common-dir.php.

◆ DirGetNonArtifact()

DirGetNonArtifact (   $UploadtreePk,
  $uploadtree_tablename = 'uploadtree' 
)

Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).

Todo:
TBD: "username" will be added in the future and it may change how this function works.
Note
This is recursive!
Parameters
int$UploadtreePkUploadtree_pk
string$uploadtree_tablenameDefaults to 'uploadtree' to not break bsam/ui
Returns
The first non-artifact directory uploadtree_pk

Definition at line 158 of file common-dir.php.

◆ DirMode2String()

DirMode2String (   $Mode)

Convert a file mode to string values.

Parameters
int$ModeFile mode (as octal integer)
Returns
String of dir mode

Definition at line 50 of file common-dir.php.

◆ Isartifact()

Isartifact (   $mode)

Check if the mode denotes artifact (a file)

Parameters
int$modeFile mode (as octal integer)
Returns
boolean True if is an artifact, false otherwise.

Definition at line 29 of file common-dir.php.

◆ Iscontainer()

Iscontainer (   $mode)

Check if the mode denotes container (fossology folder)

Parameters
int$modeFile mode (as octal integer)
Returns
boolean True if is a container, false otherwise.
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 38 of file common-dir.php.

◆ Isdir()

Isdir (   $mode)

Check if the mode denotes directory

Parameters
int$modeFile mode (as octal integer)
Returns
boolean True if is a directory, false otherwise.
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 20 of file common-dir.php.

◆ UploadtreeFileList()

UploadtreeFileList (   $Listing,
  $IfDirPlugin,
  $IfFilePlugin,
  $Count = -1,
  $ShowPhrase = 0 
)

Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file. If the pfile is a duplicate, then indent it.

Parameters
array$ListingArray from a database selection. The SQL query should use "ORDER BY pfile_fk" so that the listing can indent duplicate pfiles
string$IfDirPluginPlugin name to use if this is a directory or any other container
string$IfFilePluginPlugin name to use if this is a file
int$CountFirst number for indexing the entries (may be -1 for no count)
int$ShowPhraseObsolete from bsam
Returns
string containing the listing.

Definition at line 454 of file common-dir.php.