SproutCMS

This is the code documentation for the SproutCMS project

class Sprout

Useful functions for sprout in general

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2024-05-08
**/
class NewClassName extends Sprout {
    
    /**
    * Translate an array which may contain a page_id, filename or url into the final URL to use
    **/
    public function translateLink ($row) {
        // Method code goes here
    }
    
    /**
    * Return the last-modified date of all pages on the (sub-)site
    * Returns NULL on error.
    * 
    * The date is formatted using the php date function.
    * The default date format is &quot;d/m/Y&quot;.
    **/
    public function lastModified (string $date_format) {
        // Method code goes here
    }
    
    /**
    * Adds classes, analytics and target-blank to file links.
    * Also adds a random string, which prevents caching, solving some problems we were having with some clients.
    **/
    public function specialFileLinks ($html) {
        // Method code goes here
    }
    
    /**
    * Return true if the browser supports drag-and-drop uploads.
    **/
    public function browserDragdropUploads () {
        // Method code goes here
    }
    
    public function passwordComplexity ($str) {
        // Method code goes here
    }
    
    /**
    * Return a list of admins to send emails to.
    * 
    * The return value is an array of arrays.
    * The inner arrays contains the keys &quot;name&quot; and &quot;email&quot;.
    **/
    public function adminEmails () {
        // Method code goes here
    }
    
    /**
    * Check an IP against a list of IP addresses, with logic for CIDR ranges
    **/
    public function ipaddressInArray ($needle, $haystack) {
        // Method code goes here
    }
    
    /**
    * Returns the memory limit in bytes. If there is no limit, returns INT_MAX.
    **/
    public function getMemoryLimit () {
        // Method code goes here
    }
    
    /**
    * Gets the first key value pair of an iterable
    * 
    * This is to replace `reset` which has been deprecated in 7.2. While this lacks the
    * stateful behaviour of the original (i.e. changing the internal pointer) it does
    * recreate the most used feature: fetching the first element without knowing its key.
    **/
    public function iterableFirst (iterable $iter) {
        // Method code goes here
    }
    
    /**
    * Gets the first key of an iterable
    **/
    public function iterableFirstKey (iterable $iter) {
        // Method code goes here
    }
    
    /**
    * Gets the first value of an iterable
    **/
    public function iterableFirstValue (iterable $iter) {
        // Method code goes here
    }
    
    /**
    * Condenses an array into a string
    **/
    public function condenseArray (array $arr) {
        // Method code goes here
    }
    
    /**
    * Checks a URL that is to be used for redirection is valid.
    * 
    * Will allow remote URLs beginning with 'http://' and local URLs beginning with '/'
    **/
    public function checkRedirect ($text) {
        // Method code goes here
    }
    
    /**
    * Returns an absolute URL for the web root of this server
    * 
    * Example: 'http://thejosh.info/sprout_test/'
    **/
    public function absRoot (string $protocol) {
        // Method code goes here
    }
    
    /**
    * Takes a mysql DATETIME value (will probably also work with a TIME or DATE value)
    * and formats it according to the format codes specified by the PHP date() function.
    * 
    * The format is optional, if omittted, uses 'd/m/Y g:i a' = '7/11/2010 5:27 pm'
    **/
    public function formatMysqlDatetime ($date, $format) {
        // Method code goes here
    }
    
    /**
    * Returns a string of random numbers and letters
    **/
    public function randStr ($length, $chars) {
        // Method code goes here
    }
    
    /**
    * Returns a time in 'x minutes ago' format.
    * 
    * Very small times (0, 1 seconds) are considered 'Just now'.
    * Times are represneted in seconds, minutes, hours or days.
    **/
    public function timeAgo (int $timediff) {
        // Method code goes here
    }
    
    /**
    * Load the text for an extra page.
    * Returns NULL on error.
    **/
    public function extraPage (int $type) {
        // Method code goes here
    }
    
    /**
    * Attempts to put the handbrake on a script which is doing malicious inserts to the database
    **/
    public function checkInsertRate (string $table, string $column, string $value, string $limit, string $time, array $conds) {
        // Method code goes here
    }
    
    /**
    * Back-end for link-checking tool
    **/
    public function linkChecker () {
        // Method code goes here
    }
    
    /**
    * Takes two strings of text (which will be stripped of HTML tags)
    * and returns HTML which is a table showing the differences
    * in a nice colourful way
    **/
    public function colorisedDiff ($orig, $new) {
        // Method code goes here
    }
    
    /**
    * Set the etag header, and some expiry headers.
    * Checks if the etag matches - if it does, terminates the script with '304 Not Modified'.
    * 
    * ETag should be specified as a string.
    * Expires should be specified as a number of seconds, after that time the URL will expire.
    * 
    * ETags should be something which is unique for that version of the URL. They should use
    * something which is collission-resistant, such as MD5. They should vary based on the
    * Accept-Encoding header, or any other 'accept' headers, if you are supporting them.
    **/
    public function etag ($etag, $expires) {
        // Method code goes here
    }
    
    /**
    * Construct a new instance of a class with a given name
    **/
    public function instance (string $class_name, string|array $base_class_name) {
        // Method code goes here
    }
    
    /**
    * Returns the current version of sprout
    **/
    public function getVersion (bool $git_version) {
        // Method code goes here
    }
    
    /**
    * Returns true if the specified module is currently installed, false otherwise
    **/
    public function moduleInstalled ($module_name) {
        // Method code goes here
    }
    
    /**
    * Gets a simplified backtrace with fewer elements and no recursion
    **/
    public function simpleBacktrace (array $trace) {
        // Method code goes here
    }
    
    /**
    * Converts a variable into something human readable
    **/
    public function readableVar (mixed $var) {
        // Method code goes here
    }
    
    /**
    * Determines the file path for a class, usually for autoloading
    **/
    public function determineFilePath (string $class) {
        // Method code goes here
    }
    
    /**
    * Removes the namespaces from a class-like entity,
    * e.g. Sprout\Helpers\Text =&gt; Text
    **/
    public function removeNs (string $classlike) {
        // Method code goes here
    }
    
    /**
    * Creates an object of a class specified by a string name, with a list of possible namespaces to lookup if the
    * specified class name doesn't contain a namespace
    **/
    public function nsNew (string $class, array $possible_nses) {
        // Method code goes here
    }
    
    /**
    * Gets the full class name (including namespace) for a specified class, with a list of namespaces to search
    **/
    public function nsClass (string $class, array $possible_nses) {
        // Method code goes here
    }
    
    /**
    * Gets the full name (including namespaced class) for a specified function
    **/
    public function nsFunc (string $func, array $possible_nses) {
        // Method code goes here
    }
    
}
?>