idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
2,700 | public static function createSectionAssociation ( $ parent_section_id = null , $ child_field_id = null , $ parent_field_id = null , $ show_association = true , $ interface = null , $ editor = null ) { if ( is_null ( $ parent_section_id ) && ( is_null ( $ parent_field_id ) || ! $ parent_field_id ) ) { return false ; } i... | Create an association between a section and a field . |
2,701 | public static function hash ( $ input ) { if ( Symphony :: Log ( ) ) { Symphony :: Log ( ) -> pushDeprecateWarningToLog ( 'MD5::hash()' , 'PBKDF2::hash()' , array ( 'message-format' => __ ( 'The use of `%s` is strongly discouraged due to severe security flaws.' ) , ) ) ; } return md5 ( $ input ) ; } | Uses MD5 to create a hash based on some input |
2,702 | public static function file ( $ input ) { if ( Symphony :: Log ( ) ) { Symphony :: Log ( ) -> pushDeprecateWarningToLog ( 'MD5::file()' , 'PBKDF2::hash()' , array ( 'message-format' => __ ( 'The use of `%s` is strongly discouraged due to severe security flaws.' ) , ) ) ; } return md5_file ( $ input ) ; } | Uses MD5 to create a hash from the contents of a file |
2,703 | public static function compare ( $ input , $ hash , $ isHash = false ) { if ( Symphony :: Log ( ) ) { Symphony :: Log ( ) -> pushDeprecateWarningToLog ( 'MD5::compare()' , 'PBKDF2::compare()' , array ( 'message-format' => __ ( 'The use of `%s` is strongly discouraged due to severe security flaws.' ) , ) ) ; } return ( ... | Compares a given hash with a cleantext password . |
2,704 | public static function initialiseErrorHandler ( ) { self :: initialiseLog ( ) ; GenericExceptionHandler :: initialise ( self :: Log ( ) ) ; GenericErrorHandler :: initialise ( self :: Log ( ) ) ; } | Setter for the Symphony Log and Error Handling system |
2,705 | public static function Engine ( ) { if ( class_exists ( 'Administration' , false ) ) { return Administration :: instance ( ) ; } elseif ( class_exists ( 'Frontend' , false ) ) { return Frontend :: instance ( ) ; } else { throw new Exception ( __ ( 'No suitable engine object found' ) ) ; } } | Accessor for the Symphony instance whether it be Frontend or Administration |
2,706 | public static function initialiseDatabase ( ) { self :: setDatabase ( ) ; $ details = self :: Configuration ( ) -> get ( 'database' ) ; try { if ( ! self :: Database ( ) -> connect ( $ details [ 'host' ] , $ details [ 'user' ] , $ details [ 'password' ] , $ details [ 'port' ] , $ details [ 'db' ] ) ) { return false ; }... | This will initialise the Database class and attempt to create a connection using the connection details provided in the Symphony configuration . If any errors occur whilst doing so a Symphony Error Page is displayed . |
2,707 | public static function loginFromToken ( $ token ) { $ token = self :: Database ( ) -> cleanValue ( $ token ) ; if ( strlen ( trim ( $ token ) ) == 0 ) { return false ; } if ( strlen ( $ token ) == 6 || strlen ( $ token ) == 16 ) { $ row = self :: Database ( ) -> fetchRow ( 0 , sprintf ( "SELECT `a`.`id`, `a`.`username`... | Symphony allows Authors to login via the use of tokens instead of a username and password . A token is derived from concatenating the Author s username and password and applying the sha1 hash to it from this a portion of the hash is used as the token . This is a useful feature often used when setting up other Authors a... |
2,708 | public static function isUpgradeAvailable ( ) { if ( self :: isInstallerAvailable ( ) ) { $ migration_version = self :: getMigrationVersion ( ) ; $ current_version = Symphony :: Configuration ( ) -> get ( 'version' , 'symphony' ) ; return version_compare ( $ current_version , $ migration_version , '<' ) ; } return fals... | Checks if an update is available and applicable for the current installation . |
2,709 | public static function throwCustomError ( $ message , $ heading = 'Symphony Fatal Error' , $ status = Page :: HTTP_STATUS_ERROR , $ template = 'generic' , array $ additional = array ( ) ) { GenericExceptionHandler :: $ enabled = true ; throw new SymphonyErrorPage ( $ message , $ heading , $ template , $ additional , $ ... | A wrapper for throwing a new Symphony Error page . |
2,710 | public static function render ( $ e ) { if ( ! static :: isValidThrowable ( $ e ) ) { $ e = new FrontendPageNotFoundException ( ) ; } if ( $ e -> getTemplate ( ) === false ) { Page :: renderStatusCode ( $ e -> getHttpStatusCode ( ) ) ; if ( isset ( $ e -> getAdditional ( ) -> header ) ) { header ( $ e -> getAdditional ... | The render function will take a SymphonyErrorPage exception and output a HTML page . This function first checks to see if their is a custom template for this exception otherwise it reverts to using the default usererror . generic . php |
2,711 | public static function render ( $ e ) { if ( ! static :: isValidThrowable ( $ e ) ) { $ e = new FrontendPageNotFoundException ( ) ; } $ trace = $ queries = null ; foreach ( $ e -> getTrace ( ) as $ t ) { $ trace .= sprintf ( '<li><code><em>[%s:%d]</em></code></li><li><code>    %s%s%s();</code></li>'... | The render function will take a DatabaseException and output a HTML page . |
2,712 | public function prepare ( XSLTPage $ page , array $ pagedata , $ xml , array $ param , $ output ) { $ this -> _page = $ page ; $ this -> _pagedata = $ pagedata ; $ this -> _xml = $ xml ; $ this -> _param = $ param ; $ this -> _output = $ output ; if ( is_null ( $ this -> _title ) ) { $ this -> _title = __ ( 'Utility' )... | The prepare function acts a pseudo constructor for the Devkit setting some base variables with the given parameters |
2,713 | public function build ( ) { $ this -> buildIncludes ( ) ; $ this -> _view = General :: sanitize ( $ this -> _view ) ; $ header = new XMLElement ( 'div' ) ; $ header -> setAttribute ( 'id' , 'header' ) ; $ jump = new XMLElement ( 'div' ) ; $ jump -> setAttribute ( 'id' , 'jump' ) ; $ content = new XMLElement ( 'div' ) ;... | Called when page is generated this function calls each of the other other functions in this page to build the Header the Navigation the Jump menu and finally the content . This function calls it s parent generate function |
2,714 | public function registerPHPFunction ( $ function ) { if ( is_array ( $ function ) ) { $ this -> _registered_php_functions = array_unique ( array_merge ( $ this -> _registered_php_functions , $ function ) ) ; } else { $ this -> _registered_php_functions [ ] = $ function ; } } | Allows the registration of PHP functions to be used on the Frontend by passing the function name or an array of function names |
2,715 | public function generate ( $ page = null ) { $ result = $ this -> Proc -> process ( $ this -> _xml , $ this -> _xsl , $ this -> _param , $ this -> _registered_php_functions ) ; if ( $ this -> Proc -> isErrors ( ) ) { $ this -> setHttpStatus ( Page :: HTTP_STATUS_ERROR ) ; return false ; } parent :: generate ( $ page ) ... | The generate function calls on the XsltProcess to transform the XML with the given XSLT passing any parameters or functions If no errors occur the parent generate function is called to add the page headers and a string containing the transformed result is result . |
2,716 | public function findRelatedEntries ( $ entry_id , $ parent_field_id ) { $ handles = Symphony :: Database ( ) -> fetchCol ( 'handle' , sprintf ( " SELECT `handle` FROM `tbl_entries_data_%d` WHERE `entry_id` = %d " , $ parent_field_id , $ entry_id ) ) ; $ ids = Symphony :: Database... | Find all the entries that reference this entry s tags . |
2,717 | public function findParentRelatedEntries ( $ field_id , $ entry_id ) { $ handles = Symphony :: Database ( ) -> fetchCol ( 'handle' , sprintf ( " SELECT `handle` FROM `tbl_entries_data_%d` WHERE `entry_id` = %d " , $ this -> get ( 'id' ) , $ entry_id ) ) ; $ ids = Symphony :: Data... | Find all the entries that contain the tags that have been referenced from this field own entry . |
2,718 | public static function Calendar ( $ time = true ) { $ calendar = new XMLElement ( 'div' ) ; $ calendar -> setAttribute ( 'class' , 'calendar' ) ; $ date = DateTimeObj :: convertDateToMoment ( DateTimeObj :: getSetting ( 'date_format' ) ) ; if ( $ date ) { if ( $ time === true ) { $ separator = DateTimeObj :: getSetting... | Generates a XMLElement representation of a Symphony calendar . |
2,719 | public static function setSortingField ( $ type , $ sort , $ write = true ) { Symphony :: Configuration ( ) -> set ( self :: getColumnFromType ( $ type ) . '_index_sortby' , $ sort , 'sorting' ) ; if ( $ write ) { Symphony :: Configuration ( ) -> write ( ) ; } } | Saves the new axis a given resource type will be sorted by . |
2,720 | public static function setSortingOrder ( $ type , $ order , $ write = true ) { Symphony :: Configuration ( ) -> set ( self :: getColumnFromType ( $ type ) . '_index_order' , $ order , 'sorting' ) ; if ( $ write ) { Symphony :: Configuration ( ) -> write ( ) ; } } | Saves the new sort order for a given resource type . |
2,721 | public static function __getExtensionFromHandle ( $ type , $ r_handle ) { $ manager = self :: getManagerFromType ( $ type ) ; if ( ! isset ( $ manager ) ) { throw new Exception ( __ ( 'Unable to find a Manager class for this resource.' ) ) ; } $ type = str_replace ( '_' , '-' , self :: getColumnFromType ( $ type ) ) ; ... | Given the type and handle of a resource return the extension it belongs to . |
2,722 | public static function getAttachedPages ( $ type , $ r_handle ) { $ col = self :: getColumnFromType ( $ type ) ; $ pages = PageManager :: fetch ( false , array ( 'id' ) , array ( sprintf ( '`%s` = "%s" OR `%s` REGEXP "%s"' , $ col , $ r_handle , $ col , '^' . $ r_handle . ',|,' . $ r_handle . ',|,' . $ r_handle . '$' )... | Given the resource handle this function will return an associative array of Page information filtered by the pages the resource is attached to . |
2,723 | public static function validate ( $ string ) { try { if ( is_numeric ( $ string ) && ( int ) $ string == $ string ) { $ date = new DateTime ( '@' . $ string ) ; } else { $ date = self :: parse ( $ string ) ; } } catch ( Exception $ ex ) { return false ; } if ( empty ( $ string ) || $ date === false ) { return false ; }... | Validate a given date and time string |
2,724 | public static function parse ( $ string ) { if ( $ string == 'now' || empty ( $ string ) ) { $ date = new DateTime ( ) ; } elseif ( is_numeric ( $ string ) ) { $ date = new DateTime ( '@' . $ string ) ; } else { $ string = Lang :: standardizeDate ( $ string ) ; $ date = DateTime :: createFromFormat ( self :: $ settings... | Parses the given string and returns a DateTime object . |
2,725 | protected static function __nearbyLines ( $ line , $ file , $ window = 5 ) { if ( ! file_exists ( $ file ) ) { return array ( ) ; } return array_slice ( file ( $ file ) , ( $ line - 1 ) - $ window , $ window * 2 , true ) ; } | Retrieves a window of lines before and after the line where the error occurred so that a developer can help debug the exception |
2,726 | public static function handler ( $ e ) { $ output = '' ; try { if ( self :: $ enabled !== true ) { $ e = new FrontendPageNotFoundException ( ) ; } if ( ! static :: isValidThrowable ( $ e ) ) { $ e = new FrontendPageNotFoundException ( ) ; } $ exception_type = get_class ( $ e ) ; if ( class_exists ( "{$exception_type}Ha... | The handler function is given an Throwable and will call it s render function to display the Throwable to a user . After calling the render function the output is displayed and then exited to prevent any further logic from occurring . |
2,727 | public static function render ( $ e ) { $ lines = null ; foreach ( self :: __nearByLines ( $ e -> getLine ( ) , $ e -> getFile ( ) ) as $ line => $ string ) { $ lines .= sprintf ( '<li%s><strong>%d</strong> <code>%s</code></li>' , ( ( $ line + 1 ) == $ e -> getLine ( ) ? ' class="error"' : null ) , ++ $ line , str_repl... | The render function will take an Throwable and output a HTML page |
2,728 | public static function shutdown ( ) { $ last_error = error_get_last ( ) ; if ( ! is_null ( $ last_error ) && $ last_error [ 'type' ] === E_ERROR ) { $ code = $ last_error [ 'type' ] ; $ message = $ last_error [ 'message' ] ; $ file = $ last_error [ 'file' ] ; $ line = $ last_error [ 'line' ] ; try { if ( self :: $ _Log... | The shutdown function will capture any fatal errors and format them as a usual Symphony page . |
2,729 | public function write ( $ hash , $ data , $ ttl = null , $ namespace = null ) { if ( $ this -> cacheProvider instanceof iNamespacedCache ) { return $ this -> cacheProvider -> write ( $ hash , $ data , $ ttl , $ namespace ) ; } return $ this -> cacheProvider -> write ( $ hash , $ data , $ ttl ) ; } | A wrapper for writing data in the cache . |
2,730 | public function read ( $ hash , $ namespace = null ) { if ( $ this -> cacheProvider instanceof iNamespacedCache ) { return $ this -> cacheProvider -> read ( $ hash , $ namespace ) ; } return $ this -> cacheProvider -> read ( $ hash ) ; } | Given the hash of a some data check to see whether it exists the cache . |
2,731 | public function delete ( $ hash = null , $ namespace = null ) { if ( $ this -> cacheProvider instanceof iNamespacedCache ) { return $ this -> cacheProvider -> delete ( $ hash , $ namespace ) ; } return $ this -> cacheProvider -> delete ( $ hash ) ; } | Given the hash this function will remove it from the cache . |
2,732 | public function writeToLog ( $ message , $ addbreak = true ) { if ( file_exists ( $ this -> _log_path ) && ! is_writable ( $ this -> _log_path ) ) { $ this -> pushToLog ( 'Could not write to Log. It is not readable.' ) ; return false ; } $ permissions = class_exists ( 'Symphony' , false ) ? Symphony :: Configuration ( ... | This function will write the given message to the log file . Messages will be appended the existing log file . |
2,733 | public function close ( ) { $ this -> writeToLog ( '============================================' , true ) ; $ this -> writeToLog ( 'Log Closed: ' . DateTimeObj :: get ( 'c' ) , true ) ; $ this -> writeToLog ( "============================================" . PHP_EOL . PHP_EOL , true ) ; } | Writes a end of file block at the end of the log file with a datetime stamp of when the log file was closed . |
2,734 | public static function __getClassPath ( $ handle ) { if ( is_file ( DATASOURCES . "/data.$handle.php" ) ) { return DATASOURCES ; } else { $ extensions = Symphony :: ExtensionManager ( ) -> listInstalledHandles ( ) ; if ( is_array ( $ extensions ) && ! empty ( $ extensions ) ) { foreach ( $ extensions as $ e ) { if ( is... | Finds a Datasource by name by searching the data - sources folder in the workspace and in all installed extension folders and returns the path to it s folder . |
2,735 | public static function listAll ( ) { $ result = array ( ) ; $ structure = General :: listStructure ( DATASOURCES , '/data.[\\w-]+.php/' , false , 'ASC' , DATASOURCES ) ; if ( is_array ( $ structure [ 'filelist' ] ) && ! empty ( $ structure [ 'filelist' ] ) ) { foreach ( $ structure [ 'filelist' ] as $ f ) { $ f = self ... | Finds all available Datasources by searching the data - sources folder in the workspace and in all installed extension folders . Returns an associative array of data sources . |
2,736 | public function reset ( ) { $ this -> _header_fields = array ( ) ; $ this -> _envelope_from = null ; $ this -> _recipients = array ( ) ; $ this -> _subject = null ; $ this -> _body = null ; } | Resets the headers body subject |
2,737 | public function setHost ( $ host = null ) { if ( $ host === null ) { $ host = '127.0.0.1' ; } if ( substr ( $ host , 0 , 6 ) == 'ssl://' ) { $ this -> _protocol = 'ssl' ; $ this -> _secure = 'ssl' ; $ host = substr ( $ host , 6 ) ; } $ this -> _host = $ host ; } | Sets the host to connect to . |
2,738 | public function setPort ( $ port = null ) { if ( is_null ( $ port ) ) { $ port = ( $ this -> _protocol == 'ssl' ) ? 465 : 25 ; } $ this -> _port = $ port ; } | Sets the port used in the connection . |
2,739 | public function setSecure ( $ secure = null ) { if ( $ secure == 'tls' ) { $ this -> _protocol = 'tcp' ; $ this -> _secure = 'tls' ; } elseif ( $ secure == 'ssl' ) { $ this -> _protocol = 'ssl' ; $ this -> _secure = 'ssl' ; } else { $ this -> _protocol = 'tcp' ; $ this -> _secure = 'no' ; } } | Sets the encryption used . |
2,740 | public function setEnvelopeFrom ( $ envelope_from = null ) { if ( preg_match ( '%[\r\n]%' , $ envelope_from ) ) { throw new EmailValidationException ( __ ( 'The Envelope From Address can not contain carriage return or newlines.' ) ) ; } $ this -> _envelope_from = $ envelope_from ; } | Sets the envelope_from address . This is only available via the API as it is an expert - only feature . |
2,741 | public function setConfiguration ( $ config ) { $ this -> setHeloHostname ( $ config [ 'helo_hostname' ] ) ; $ this -> setFrom ( $ config [ 'from_address' ] , $ config [ 'from_name' ] ) ; $ this -> setHost ( $ config [ 'host' ] ) ; $ this -> setPort ( $ config [ 'port' ] ) ; $ this -> setSecure ( $ config [ 'secure' ] ... | Sets all configuration entries from an array . |
2,742 | public function createFilteringInterface ( ) { $ context = $ this -> getContext ( ) ; $ handle = $ context [ 'section_handle' ] ; $ section_id = SectionManager :: fetchIDFromHandle ( $ handle ) ; $ section = SectionManager :: fetch ( $ section_id ) ; $ filter = $ section -> get ( 'filter' ) ; $ count = EntryManager :: ... | Append filtering interface |
2,743 | public function createFilteringDrawer ( $ section ) { $ this -> filteringForm = Widget :: Form ( null , 'get' , 'filtering' ) ; $ this -> createFilteringDuplicator ( $ section ) ; return $ this -> filteringForm ; } | Create filtering drawer |
2,744 | private function __wrapFieldWithDiv ( Field $ field , Entry $ entry ) { $ is_hidden = $ this -> isFieldHidden ( $ field ) ; $ div = new XMLElement ( 'div' , null , array ( 'id' => 'field-' . $ field -> get ( 'id' ) , 'class' => 'field field-' . $ field -> handle ( ) . ( $ field -> get ( 'required' ) == 'yes' ? ' requir... | Given a Field and Entry object this function will wrap the Field s displayPublishPanel result with a div that contains some contextual information such as the Field ID the Field handle and whether it is required or not . |
2,745 | public function getPrepopulateString ( ) { $ prepopulate_querystring = '' ; if ( isset ( $ _REQUEST [ 'prepopulate' ] ) && is_array ( $ _REQUEST [ 'prepopulate' ] ) ) { foreach ( $ _REQUEST [ 'prepopulate' ] as $ field_id => $ value ) { $ value = rawurlencode ( rawurldecode ( $ value ) ) ; $ prepopulate_querystring .= ... | If this entry is being prepopulated this function will return the prepopulated fields and values as a query string . |
2,746 | public function getFilterString ( ) { $ filter_querystring = '' ; if ( isset ( $ _REQUEST [ 'prepopulate' ] ) && is_array ( $ _REQUEST [ 'prepopulate' ] ) ) { foreach ( $ _REQUEST [ 'prepopulate' ] as $ field_id => $ value ) { $ handle = FieldManager :: fetchHandleFromID ( $ field_id ) ; $ value = rawurlencode ( rawurl... | If the entry is being prepopulated we may want to filter other views by this entry s value . This function will create that filter query string . |
2,747 | public function asXML ( ) { $ p = new XMLElement ( 'p' , $ this -> message , array ( 'role' => 'alert' ) ) ; $ p -> setAttribute ( 'class' , 'notice' ) ; if ( $ this -> type !== self :: NOTICE ) { $ p -> setAttribute ( 'class' , 'notice ' . $ this -> type ) ; } return $ p ; } | Generates as XMLElement representation of this Alert |
2,748 | public static function release ( $ id , $ path = '.' ) { $ lockFile = self :: __generateLockFileName ( $ id , $ path ) ; if ( ! empty ( self :: $ lockFiles [ $ lockFile ] ) ) { unset ( self :: $ lockFiles [ $ lockFile ] ) ; return General :: deleteFile ( $ lockFile , false ) ; } return false ; } | Removes a lock file . This is the only way a lock file can be removed |
2,749 | public static function refresh ( $ id , $ ttl = 5 , $ path = '.' ) { return touch ( self :: __generateLockFileName ( $ id , $ path ) , time ( ) + $ ttl , time ( ) ) ; } | Updates a lock file to keep alive for another x seconds . |
2,750 | public static function lockExists ( $ id , $ path ) { $ lockFile = self :: __generateLockFileName ( $ id , $ path ) ; return file_exists ( $ lockFile ) ; } | Checks if a lock exists purely on the presence on the lock file . This function takes the unobfuscated lock name Others should not depend on value returned by this function because by the time it returns the lock file can be created or deleted by another thread . |
2,751 | public static function __shutdownCleanup ( ) { $ now = time ( ) ; if ( is_array ( self :: $ lockFiles ) ) { foreach ( self :: $ lockFiles as $ lockFile => $ meta ) { if ( ( $ now - $ meta [ 'time' ] > $ meta [ 'ttl' ] ) && file_exists ( $ lockFile ) ) { unlink ( $ lockFile ) ; } } } } | Releases all locks on expired files . |
2,752 | public function pagesFlatView ( ) { $ pages = PageManager :: fetch ( false , array ( 'id' ) ) ; foreach ( $ pages as & $ p ) { $ p [ 'title' ] = PageManager :: resolvePageTitle ( $ p [ 'id' ] ) ; } return $ pages ; } | This function creates an array of all page titles in the system . |
2,753 | public static function create ( $ handle , array $ env = null ) { $ classname = self :: __getClassName ( $ handle ) ; $ path = self :: __getDriverPath ( $ handle ) ; if ( ! is_file ( $ path ) ) { throw new Exception ( __ ( 'Could not find Event %s.' , array ( '<code>' . $ handle . '</code>' ) ) . ' ' . __ ( 'If it was ... | Creates an instance of a given class and returns it . |
2,754 | public static function setDefaultGateway ( $ name ) { if ( self :: __getClassPath ( $ name ) ) { Symphony :: Configuration ( ) -> set ( 'default_gateway' , $ name , 'Email' ) ; Symphony :: Configuration ( ) -> write ( ) ; } else { throw new EmailGatewayException ( __ ( 'This gateway can not be found. Can not save as de... | Sets the default gateway . Will throw an exception if the gateway can not be found . |
2,755 | public static function __getClassPath ( $ name ) { if ( is_file ( EMAILGATEWAYS . "/email.$name.php" ) ) { return EMAILGATEWAYS ; } else { $ extensions = Symphony :: ExtensionManager ( ) -> listInstalledHandles ( ) ; if ( is_array ( $ extensions ) && ! empty ( $ extensions ) ) { foreach ( $ extensions as $ e ) { if ( i... | Finds the gateway by name |
2,756 | public static function create ( $ name ) { $ name = strtolower ( $ name ) ; $ classname = self :: __getClassName ( $ name ) ; $ path = self :: __getDriverPath ( $ name ) ; if ( ! is_file ( $ path ) ) { throw new Exception ( __ ( 'Could not find Email Gateway %s.' , array ( '<code>' . $ name . '</code>' ) ) . ' ' . __ (... | Creates a new object from a gateway name . |
2,757 | public static function qEncode ( $ input , $ max_length = 75 ) { if ( empty ( $ input ) ) { return $ input ; } if ( ! preg_match ( '/[\\x80-\\xff]+/' , $ input ) ) { return $ input ; } $ qpHexDigits = '0123456789ABCDEF' ; $ input_length = strlen ( $ input ) ; $ line_limit = $ max_length - 12 ; $ line_length = 0 ; $ out... | Q - encoding of a header field text token or word entity within a phrase according to RFC2047 . The output is called an encoded - word ; it must not be longer than 75 characters . |
2,758 | public static function arrayToList ( array $ array = array ( ) ) { $ return = array ( ) ; foreach ( $ array as $ name => $ email ) { $ return [ ] = empty ( $ name ) || General :: intval ( $ name ) > - 1 ? $ email : $ name . ' <' . $ email . '>' ; } return implode ( ', ' , $ return ) ; } | Implodes an associative array or straight array to a comma - separated string |
2,759 | public function read ( $ hash , $ namespace = null ) { $ data = false ; if ( ! is_null ( $ namespace ) && is_null ( $ hash ) ) { $ data = $ this -> Database -> fetch ( " SELECT SQL_NO_CACHE * FROM `tbl_cache` WHERE `namespace` = '$namespace' AND (`expiry` IS N... | Given the hash of a some data check to see whether it exists in tbl_cache . If no cached object is found this function will return false otherwise the cached object will be returned as an array . |
2,760 | public function get ( $ setting = null ) { if ( is_null ( $ setting ) ) { return $ this -> _fields ; } if ( ! isset ( $ this -> _fields [ $ setting ] ) ) { return null ; } return $ this -> _fields [ $ setting ] ; } | Accessor to the a setting by name . If no setting is provided all the settings of this Entry instance are returned . |
2,761 | public function getData ( $ field_id = null , $ asObject = false ) { $ fieldData = isset ( $ this -> _data [ $ field_id ] ) ? $ this -> _data [ $ field_id ] : array ( ) ; if ( ! $ field_id ) { return $ this -> _data ; } return ( $ asObject ? ( object ) $ fieldData : $ fieldData ) ; } | Accessor function to return data from this Entry for a particular field . Optional parameter to return this data as an object instead of an array . If a Field is not provided an associative array of all data assigned to this Entry will be returned . |
2,762 | public function fetchAllAssociatedEntryCounts ( $ associated_sections = null ) { if ( is_null ( $ this -> get ( 'section_id' ) ) ) { return null ; } if ( is_null ( $ associated_sections ) ) { $ section = SectionManager :: fetch ( $ this -> get ( 'section_id' ) ) ; $ associated_sections = $ section -> fetchChildAssociat... | Entries may link to other Entries through fields . This function will return the number of entries that are associated with the current entry as an associative array . If there are no associated entries null will be returned . |
2,763 | public function setFromPOST ( array $ settings = array ( ) ) { $ settings [ 'location' ] = ( isset ( $ settings [ 'location' ] ) ? $ settings [ 'location' ] : 'main' ) ; $ settings [ 'required' ] = ( isset ( $ settings [ 'required' ] ) && $ settings [ 'required' ] === 'yes' ? 'yes' : 'no' ) ; $ settings [ 'show_column'... | Fill the input data array with default values for known keys provided these settings are not already set . The input array is then used to set the values of the corresponding settings for this field . This function is called when a section is saved . |
2,764 | public function get ( $ setting = null ) { if ( is_null ( $ setting ) ) { return $ this -> _settings ; } if ( ! isset ( $ this -> _settings [ $ setting ] ) ) { return null ; } return $ this -> _settings [ $ setting ] ; } | Accessor to the a setting by name . If no setting is provided all the settings of this Field instance are returned . |
2,765 | public function displaySettingsPanel ( XMLElement & $ wrapper , $ errors = null ) { $ location = ( $ this -> get ( 'location' ) ? $ this -> get ( 'location' ) : 'main' ) ; $ header = new XMLElement ( 'header' , null , array ( 'class' => 'frame-header ' . $ location , 'data-name' => $ this -> name ( ) , 'title' => $ thi... | Display the default settings panel calls the buildSummaryBlock function after basic field settings are added to the wrapper . |
2,766 | public function buildSummaryBlock ( $ errors = null ) { $ div = new XMLElement ( 'div' ) ; $ label = Widget :: Label ( __ ( 'Label' ) ) ; $ label -> appendChild ( Widget :: Input ( 'fields[' . $ this -> get ( 'sortorder' ) . '][label]' , $ this -> get ( 'label' ) ) ) ; if ( isset ( $ errors [ 'label' ] ) ) { $ div -> a... | Construct the html block to display a summary of this field which is the field Label and it s location within the section . Any error messages generated are appended to the optional input error array . This function calls buildLocationSelect once it is completed |
2,767 | public function buildLocationSelect ( $ selected = null , $ name = 'fields[location]' , $ label_value = null ) { if ( ! $ label_value ) { $ label_value = __ ( 'Placement' ) ; } $ label = Widget :: Label ( $ label_value ) ; $ label -> setAttribute ( 'class' , 'column' ) ; $ options = array ( array ( 'main' , $ selected ... | Build the location select widget . This widget allows users to select whether this field will appear in the main content column or in the sidebar when creating a new entry . |
2,768 | public function buildFormatterSelect ( $ selected = null , $ name = 'fields[format]' , $ label_value ) { $ formatters = TextformatterManager :: listAll ( ) ; if ( ! $ label_value ) { $ label_value = __ ( 'Formatting' ) ; } $ label = Widget :: Label ( $ label_value ) ; $ label -> setAttribute ( 'class' , 'column' ) ; $ ... | Construct the html widget for selecting a text formatter for this field . |
2,769 | public function buildValidationSelect ( XMLElement & $ wrapper , $ selected = null , $ name = 'fields[validator]' , $ type = 'input' , array $ errors = null ) { include TOOLKIT . '/util.validators.php' ; $ rules = ( $ type == 'upload' ? $ upload : $ validators ) ; $ label = Widget :: Label ( __ ( 'Validation Rule' ) ) ... | Append a validator selector to a given XMLElement . Note that this function differs from the other two similarly named build functions in that it takes an XMLElement to append the Validator to as a parameter and does not return anything . |
2,770 | public function appendAssociationInterfaceSelect ( XMLElement & $ wrapper ) { $ wrapper -> setAttribute ( 'data-condition' , 'associative' ) ; $ interfaces = Symphony :: ExtensionManager ( ) -> getProvidersOf ( iProvider :: ASSOCIATION_UI ) ; $ editors = Symphony :: ExtensionManager ( ) -> getProvidersOf ( iProvider ::... | Append the html widget for selecting an association interface and editor for this field . |
2,771 | public function getAssociationContext ( ) { $ context = Symphony :: Engine ( ) -> Page -> getContext ( ) ; $ associations = $ context [ 'associations' ] [ 'parent' ] ; $ field_association = array ( ) ; $ count = 0 ; if ( ! empty ( $ associations ) ) { $ associationsCount = count ( $ associations ) ; for ( $ i = 0 ; $ i... | Get association data of the current field from the page context . |
2,772 | public function setAssociationContext ( XMLElement & $ wrapper ) { $ association_context = $ this -> getAssociationContext ( ) ; if ( ! empty ( $ association_context ) ) { $ wrapper -> setAttributeArray ( array ( 'data-parent-section-id' => $ association_context [ 'parent_section_id' ] , 'data-parent-section-field-id' ... | Set association data for the current field . |
2,773 | public function appendShowAssociationCheckbox ( XMLElement & $ wrapper , $ help = null ) { if ( ! $ this -> _showassociation ) { return ; } $ label = $ this -> createCheckboxSetting ( $ wrapper , 'show_association' , __ ( 'Display associations in entries table' ) , $ help ) ; $ label -> setAttribute ( 'data-condition' ... | Append the show association html widget to the input parent XML element . This widget allows fields that provide linking to hide or show the column in the linked section similar to how the Show Column functionality works but for the linked section . |
2,774 | public function appendStatusFooter ( XMLElement & $ wrapper ) { $ fieldset = new XMLElement ( 'fieldset' ) ; $ div = new XMLElement ( 'div' , null , array ( 'class' => 'two columns' ) ) ; $ this -> appendRequiredCheckbox ( $ div ) ; $ this -> appendShowColumnCheckbox ( $ div ) ; $ fieldset -> appendChild ( $ div ) ; $ ... | Append the default status footer to the field settings panel . Displays the required and show column checkboxes . |
2,775 | public function checkFields ( array & $ errors , $ checkForDuplicates = true ) { $ parent_section = $ this -> get ( 'parent_section' ) ; $ label = $ this -> get ( 'label' ) ; $ element_name = $ this -> get ( 'element_name' ) ; if ( Lang :: isUnicodeCompiled ( ) ) { $ valid_name = preg_match ( '/^[\p{L}]([0-9\p{L}\.\-\_... | Check the field s settings to ensure they are valid on the section editor |
2,776 | public function prepareTableValue ( $ data , XMLElement $ link = null , $ entry_id = null ) { $ value = $ this -> prepareReadableValue ( $ data , $ entry_id , true , __ ( 'None' ) ) ; if ( $ link ) { $ link -> setValue ( $ value ) ; return $ link -> generate ( ) ; } return $ value ; } | Format this field value for display in the publish index tables . |
2,777 | public static function createAssociationsDrawerXMLElement ( $ value , Entry $ e , array $ parent_association , $ prepopulate = '' ) { $ li = new XMLElement ( 'li' ) ; $ a = new XMLElement ( 'a' , $ value ) ; $ a -> setAttribute ( 'href' , SYMPHONY_URL . '/publish/' . $ parent_association [ 'handle' ] . '/edit/' . $ e -... | This is general purpose factory method that makes it easier to create the markup needed in order to create an Associations Drawer XMLElement . |
2,778 | public function prepareAssociationsDrawerXMLElement ( Entry $ e , array $ parent_association , $ prepopulate = '' ) { $ value = $ this -> prepareReadableValue ( $ e -> getData ( $ this -> get ( 'id' ) ) , $ e -> get ( 'id' ) ) ; if ( empty ( $ value ) ) { $ value = strip_tags ( $ this -> prepareTableValue ( $ e -> getD... | Format this field value for display in the Associations Drawer publish index . By default Symphony will use the return value of the prepareReadableValue function . |
2,779 | public function displayPublishPanel ( XMLElement & $ wrapper , $ data = null , $ flagWithError = null , $ fieldnamePrefix = null , $ fieldnamePostfix = null , $ entry_id = null ) { } | Display the publish panel for this field . The display panel is the interface shown to Authors that allow them to input data into this field for an Entry . |
2,780 | public function processRawFieldData ( $ data , & $ status , & $ message = null , $ simulate = false , $ entry_id = null ) { $ status = self :: __OK__ ; return array ( 'value' => $ data , ) ; } | Process the raw field data . |
2,781 | public function displayDatasourceFilterPanel ( XMLElement & $ wrapper , $ data = null , $ errors = null , $ fieldnamePrefix = null , $ fieldnamePostfix = null ) { $ wrapper -> appendChild ( new XMLElement ( 'header' , '<h4>' . $ this -> get ( 'label' ) . '</h4> <span>' . $ this -> name ( ) . '</span>' , array ( 'data-n... | Display the default data source filter panel . |
2,782 | public function displayFilteringOptions ( XMLElement & $ wrapper ) { $ filterTags = new XMLElement ( 'ul' ) ; $ filterTags -> setAttribute ( 'class' , 'tags singular' ) ; $ filterTags -> setAttribute ( 'data-interactive' , 'data-interactive' ) ; $ filters = $ this -> fetchFilterableOperators ( ) ; foreach ( $ filters a... | Inserts tags at the bottom of the filter panel |
2,783 | public function appendFormattedElement ( XMLElement & $ wrapper , $ data , $ encode = false , $ mode = null , $ entry_id = null ) { $ wrapper -> appendChild ( new XMLElement ( $ this -> get ( 'element_name' ) , ( $ encode ? General :: sanitize ( $ this -> prepareReadableValue ( $ data , $ entry_id ) ) : $ this -> prepa... | Append the formatted XML output of this field as utilized as a data source . |
2,784 | public function commit ( ) { $ fields = array ( ) ; $ fields [ 'label' ] = General :: sanitize ( $ this -> get ( 'label' ) ) ; $ fields [ 'element_name' ] = ( $ this -> get ( 'element_name' ) ? $ this -> get ( 'element_name' ) : Lang :: createHandle ( $ this -> get ( 'label' ) ) ) ; $ fields [ 'parent_section' ] = $ th... | Commit the settings of this field from the section editor to create an instance of this field in a section . |
2,785 | public function exists ( ) { if ( ! $ this -> get ( 'id' ) || ! $ this -> _handle ) { return false ; } $ row = Symphony :: Database ( ) -> fetch ( sprintf ( 'SELECT `id` FROM `tbl_fields_%s` WHERE `field_id` = %d' , $ this -> _handle , General :: intval ( $ this -> get ( 'id' ) ) ) ) ; if ( empty ( $ row ) ) { $ column... | Checks that we are working with a valid field handle and field id and checks that the field record exists in the settings table . |
2,786 | public function entryDataCleanup ( $ entry_id , $ data = null ) { $ where = is_array ( $ entry_id ) ? " `entry_id` IN (" . implode ( ',' , $ entry_id ) . ") " : " `entry_id` = '$entry_id' " ; Symphony :: Database ( ) -> delete ( 'tbl_entries_data_' . $ this -> get ( 'id' ) , $ where ) ; return true ; } | Remove the entry data of this field from the database . |
2,787 | public function findRelatedEntries ( $ entry_id , $ parent_field_id ) { try { $ ids = Symphony :: Database ( ) -> fetchCol ( 'entry_id' , sprintf ( " SELECT `entry_id` FROM `tbl_entries_data_%d` WHERE `relation_id` = %d AND `entry_id` IS NOT NULL " ... | Find related entries from a linking field s data table . Default implementation uses column names entry_id and relation_id as with the Select Box Link |
2,788 | public static function add ( array $ fields ) { if ( ! isset ( $ fields [ 'sortorder' ] ) ) { $ fields [ 'sortorder' ] = self :: fetchNextSortOrder ( ) ; } if ( ! Symphony :: Database ( ) -> insert ( $ fields , 'tbl_pages' ) ) { return false ; } return Symphony :: Database ( ) -> getInsertID ( ) ; } | Given an associative array of data where the key is the column name in tbl_pages and the value is the data this function will create a new Page and return a Page ID on success . |
2,789 | public static function fetchTitleFromHandle ( $ handle ) { return Symphony :: Database ( ) -> fetchVar ( 'title' , 0 , sprintf ( "SELECT `title` FROM `tbl_pages` WHERE `handle` = '%s' LIMIT 1" , Symphony :: Database ( ) -> cleanValue ( $ handle ) ) ) ; } | Return a Page title by the handle |
2,790 | public static function fetchIDFromHandle ( $ handle ) { return Symphony :: Database ( ) -> fetchVar ( 'id' , 0 , sprintf ( "SELECT `id` FROM `tbl_pages` WHERE `handle` = '%s' LIMIT 1" , Symphony :: Database ( ) -> cleanValue ( $ handle ) ) ) ; } | Return a Page ID by the handle |
2,791 | public static function addPageTypesToPage ( $ page_id = null , array $ types ) { if ( is_null ( $ page_id ) ) { return false ; } PageManager :: deletePageTypes ( $ page_id ) ; foreach ( $ types as $ type ) { Symphony :: Database ( ) -> insert ( array ( 'page_id' => $ page_id , 'type' => $ type ) , 'tbl_pages_types' ) ;... | Given a Page ID and an array of types this function will add Page types to that Page . If a Page types are stored in tbl_pages_types . |
2,792 | public static function delete ( $ page_id = null , $ delete_files = true ) { if ( ! is_int ( $ page_id ) ) { return false ; } $ can_proceed = true ; if ( $ delete_files ) { $ page = PageManager :: fetchPageByID ( $ page_id , array ( 'path' , 'handle' ) ) ; if ( empty ( $ page ) ) { return false ; } $ can_proceed = Page... | This function takes a Page ID and removes the Page from the database in tbl_pages and it s associated Page Types in tbl_pages_types . This function does not delete any of the Page s children . |
2,793 | public static function fetchAvailablePageTypes ( ) { $ system_types = array ( 'index' , 'XML' , 'JSON' , 'admin' , '404' , '403' ) ; $ types = PageManager :: fetchPageTypes ( ) ; return ( ! empty ( $ types ) ? General :: array_remove_duplicates ( array_merge ( $ system_types , $ types ) ) : $ system_types ) ; } | Returns all the page types that exist in this Symphony install . There are 6 default system page types and new types can be added by Developers via the Page Editor . |
2,794 | public static function fetchAllPagesPageTypes ( ) { $ types = Symphony :: Database ( ) -> fetch ( "SELECT `page_id`,`type` FROM `tbl_pages_types`" ) ; $ page_types = array ( ) ; if ( is_array ( $ types ) ) { foreach ( $ types as $ type ) { $ page_types [ $ type [ 'page_id' ] ] [ ] = $ type [ 'type' ] ; } } return $ pag... | Fetch an associated array with Page ID s and the types they re using . |
2,795 | public static function resolvePageByPath ( $ handle , $ path = false ) { return Symphony :: Database ( ) -> fetchRow ( 0 , sprintf ( "SELECT * FROM `tbl_pages` WHERE `path` %s AND `handle` = '%s' LIMIT 1" , ( $ path ? " = '" . Symphony :: Database ( ) -> cleanValue ( $ path ) . "'" : 'IS NULL' ) , Symphony :: Database ... | Resolve a page by it s handle and path |
2,796 | private function __isSchemaValid ( $ schema , array $ bits ) { $ schema_arr = preg_split ( '/\//' , $ schema , - 1 , PREG_SPLIT_NO_EMPTY ) ; return ( count ( $ schema_arr ) >= count ( $ bits ) ) ; } | Given the allowed params for the resolved page compare it to params provided in the URL . If the number of params provided is less than or equal to the number of URL parameters set for a page the Schema is considered valid otherwise it s considered to be false a 404 page will result . |
2,797 | private function __findDatasourceOrder ( $ dependenciesList ) { if ( ! is_array ( $ dependenciesList ) || empty ( $ dependenciesList ) ) { return ; } foreach ( $ dependenciesList as $ handle => $ dependencies ) { foreach ( $ dependencies as $ i => $ dependency ) { $ dependency = explode ( '.' , $ dependency ) ; $ depen... | The function finds the correct order Datasources need to be processed in to satisfy all dependencies that parameters can resolve correctly and in time for other Datasources to filter on . |
2,798 | private function __buildDatasourcePooledParamList ( $ datasources ) { if ( ! is_array ( $ datasources ) || empty ( $ datasources ) ) { return array ( ) ; } $ list = array ( ) ; foreach ( $ datasources as $ handle ) { $ rootelement = str_replace ( '_' , '-' , $ handle ) ; $ list [ ] = '$ds-' . $ rootelement ; } return $... | Given an array of datasource dependancies this function will translate each of them to be a valid datasource handle . |
2,799 | public function execute ( array & $ param_pool = null ) { $ result = new XMLElement ( $ this -> dsParamROOTELEMENT ) ; try { $ result = $ this -> execute ( $ param_pool ) ; } catch ( FrontendPageNotFoundException $ e ) { FrontendPageNotFoundExceptionHandler :: render ( $ e ) ; } catch ( Exception $ e ) { $ result -> ap... | The meat of the Datasource this function includes the datasource type s file that will preform the logic to return the data for this datasource It is passed the current parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.