idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
12,000
function beforeLineTitle ( $ category , $ lineStyle = ' __ ' ) { return $ this -> category -> makeLineForDepth ( $ this -> depth ( $ category ) , $ lineStyle ) ; }
make line for category show depth
12,001
public function textToCode ( array $ details ) { $ formatted = array ( ) ; if ( isset ( $ details [ 'foreground' ] ) ) { $ formatted [ 'foreground' ] = $ this -> color -> getForeground ( $ details [ 'foreground' ] ) ; } if ( isset ( $ details [ 'background' ] ) ) { $ formatted [ 'background' ] = $ this -> color -> getB...
Turns a text color ie Blue into a color code .
12,002
public function get ( $ name = null ) { if ( ! is_null ( $ name ) ) { if ( array_key_exists ( $ name , $ this -> formats ) ) { return $ this -> formats [ $ name ] ; } return false ; } else { return $ this -> formats ; } }
Gets either a single or all formats depending on the var that is passed
12,003
public function remove ( $ name ) { $ removed = false ; if ( $ this -> has ( $ name ) ) { $ this -> elements -> rewind ( ) ; while ( $ this -> elements -> valid ( ) ) { if ( $ this -> elements -> current ( ) -> getName ( ) == $ name ) { $ this -> elements -> remove ( ) ; $ removed = true ; break ; } $ this -> elements ...
Removes the element with the provided name
12,004
public function get ( $ name ) { $ found = null ; foreach ( $ this -> elements as $ element ) { if ( $ element -> getName ( ) == $ name ) { $ found = $ element ; } } return $ found ; }
Returns the element with the provided name
12,005
public function has ( $ name ) { $ found = false ; $ this -> elements -> rewind ( ) ; foreach ( $ this -> elements as $ element ) { if ( $ element -> getName ( ) == $ name ) { $ found = true ; break ; } } return $ found ; }
Check if an element with a given name exists
12,006
public function populateValues ( $ data ) { foreach ( $ this -> elements as $ element ) { if ( is_a ( $ element , '\Slick\Form\FieldsetInterface' ) ) { $ element -> populateValues ( $ data ) ; } else { foreach ( $ data as $ name => $ value ) { if ( $ element -> getName ( ) == $ name ) { $ element -> setValue ( $ value ...
Recursively populate value attributes of elements
12,007
public function beforeSave ( Save $ event ) { $ entity = $ event -> getTarget ( ) ; $ property = $ this -> getPropertyName ( ) ; $ field = $ this -> getForeignKey ( ) ; $ data = $ event -> data ; if ( isset ( $ entity -> $ property ) && ! is_null ( $ entity -> $ property ) ) { $ object = $ entity -> $ property ; $ data...
Runs before save to set the relation data to be saved
12,008
public function beforeSelect ( \ Slick \ Orm \ Events \ Select $ event ) { if ( $ this -> lazyLoad ) { return ; } $ related = Entity \ Manager :: getInstance ( ) -> get ( $ this -> getRelatedEntity ( ) ) ; $ relatedTable = $ related -> getEntity ( ) -> getTableName ( ) ; $ sql = $ event -> sqlQuery ; $ columns = $ rela...
Sets the join information on the select query when lazy load is false
12,009
public function autosetColumns ( ) { $ value = $ this -> value ; if ( empty ( $ this -> columns ) ) { $ dataValue = $ value ; if ( count ( $ dataValue ) ) { $ firstValue = ( array ) $ dataValue [ 0 ] ; foreach ( array_keys ( $ firstValue ) as $ header ) { $ this -> addColumn ( $ header ) ; } } } }
Autoset columns for simple structures based on current data
12,010
public function addTotalRow ( $ field , $ name = null , $ label = null ) { if ( $ name === null ) { $ name = $ field ; } if ( $ label === null ) { $ label = $ name ; $ name = $ field ; } $ this -> totalRow [ $ field ] = array ( 'Field' => $ field , 'Name' => $ name , 'Label' => $ label ) ; }
Add a total row at the end of the table .
12,011
public function getProperty ( $ property ) { $ values = array ( ) ; foreach ( $ this -> columns as $ key => $ col ) { if ( isset ( $ col [ $ property ] ) ) { $ values [ $ key ] = $ col [ $ property ] ; } else { $ values [ $ key ] = null ; } } }
Get a property from all columns
12,012
public function setProperty ( $ property , $ arr ) { if ( ! ArrayLib :: is_associative ( $ arr ) ) { $ arr = array_combine ( $ arr , $ arr ) ; } foreach ( $ arr as $ colName => $ value ) { if ( ! isset ( $ this -> columns [ $ colName ] ) ) { $ this -> columns [ $ colName ] = array ( ) ; } } foreach ( $ this -> columns ...
Set a property on all columns
12,013
public function getColumnProperty ( $ column , $ property , $ default = null ) { if ( ! isset ( $ this -> columns [ $ column ] ) ) { return $ default ; } if ( ! isset ( $ this -> columns [ $ column ] [ $ property ] ) ) { return $ default ; } return $ this -> columns [ $ column ] [ $ property ] ; }
Get property from a column
12,014
public function setColumnProperty ( $ column , $ property , $ value ) { if ( ! isset ( $ this -> columns [ $ column ] ) ) { $ this -> columns [ $ column ] = array ( ) ; } $ this -> columns [ $ column ] [ $ property ] = $ value ; return $ this ; }
Set property of a column
12,015
public static function get ( $ config = null ) { $ session = new static ( ) ; if ( is_null ( $ config ) ) { $ config = Configuration :: get ( 'config' ) ; } $ class = $ config -> get ( 'session.type' , 'server' ) ; $ options = $ config -> get ( 'session' , array ( ) ) ; if ( $ config -> get ( 'session.type' , false ) )...
Factory method to retrieve a session object
12,016
public function initialize ( ) { $ driver = $ this -> _class ; if ( empty ( $ driver ) ) { throw new Exception \ InvalidArgumentException ( "The session driver is invalid." ) ; } if ( class_exists ( $ driver ) ) { $ driverObj = new $ driver ( $ this -> _options ) ; if ( is_a ( $ driverObj , '\Slick\Session\Driver\Drive...
Returns a new session driver based on the class property .
12,017
public function initialize ( ) { $ adapter = null ; if ( is_null ( $ this -> _driver ) ) { throw new InvalidArgumentException ( "Trying to initialize an invalid database adapter." ) ; } if ( class_exists ( $ this -> _driver ) ) { $ reflection = new ReflectionClass ( $ this -> _driver ) ; if ( ! $ reflection -> implemen...
Initializes an adapter with provided options
12,018
public function getVideoImage ( $ version = 'default' ) { if ( strpos ( $ this -> url , 'youtu' ) !== false ) { switch ( $ version ) { case 'max' : return 'https://img.youtube.com/vi/' . $ this -> getVideoCode ( ) . '/maxresdefault.jpg' ; break ; case 'hq' : return 'https://img.youtube.com/vi/' . $ this -> getVideoCode...
Gets video thumbnail from outside server
12,019
private function create ( ) { $ filename = tempnam ( null === $ this -> tempDir ? sys_get_temp_dir ( ) : $ this -> tempDir , 'php' ) ; if ( ! $ filename ) { throw new \ Error ( 'The function tempnam() could not create a file in temporary directory.' ) ; } return $ filename ; }
Create file with unique name in temp directory
12,020
public function read ( ) { $ args = array_merge ( [ $ this -> filename ] , [ false , null ] , func_get_args ( ) ) ; return file_get_contents ( ... $ args ) ; }
Read entire file or chunk into a string
12,021
public function draw ( array $ data ) { $ lengths = $ this -> calcLength ( $ data ) ; $ this -> writeHeaders ( $ lengths ) ; $ this -> writeData ( $ data , $ lengths ) ; $ this -> writeFooter ( $ lengths ) ; }
Draws a table from the array passed to it .
12,022
public function writeData ( array $ data , array $ lengths ) { foreach ( $ data as $ row ) { $ rowOutput = $ this -> table_headerPart ; foreach ( $ row as $ key => $ value ) { $ rowOutput .= ' ' . str_pad ( $ value , $ lengths [ $ key ] , ' ' , STR_PAD_RIGHT ) . ' ' . $ this -> table_headerPart ; } $ this -> output -> ...
Writes the table
12,023
public function writeFooter ( array $ headers ) { $ bar = $ this -> table_connectorLeft ; foreach ( $ headers as $ name => $ length ) { $ bar .= str_pad ( '' , $ length + 2 , $ this -> table_barFiller ) . '' . $ this -> table_connectorRight ; } $ this -> output -> writeln ( $ bar ) ; }
Writes a decorative footer
12,024
public function writeHeaders ( array $ headers ) { $ bar = $ this -> table_connectorHeader ; $ header = $ this -> table_headerPart ; foreach ( $ headers as $ name => $ length ) { $ bar .= str_pad ( '' , $ length + 2 , $ this -> table_barFiller ) . $ this -> table_connectorHeader ; $ header .= ' ' . str_pad ( $ name , $...
Outputs the headers with padding previously calculated
12,025
public function calcLength ( array $ data ) { $ lengths = array ( ) ; foreach ( $ data as $ table ) { foreach ( $ table as $ key => $ value ) { $ len = strlen ( $ value ) ; if ( ! isset ( $ lengths [ $ key ] ) || $ len > $ lengths [ $ key ] ) { $ lengths [ $ key ] = $ len ; } if ( isset ( $ lengths [ $ key ] ) && strle...
Calculate the length of the table
12,026
public function createFromLicenseName ( $ licenseName , array $ replacements = array ( ) ) { $ replacements [ 'thisYear' ] = date ( 'Y' ) ; try { return $ this -> twig -> render ( $ licenseName , $ replacements ) ; } catch ( \ Twig_Error_Loader $ e ) { throw new \ InvalidArgumentException ( 'Invalid license name provid...
Creates a license header string from a license name
12,027
public function init ( ) { parent :: init ( ) ; $ this -> setImport ( array ( 'audit.models.*' , 'audit.components.*' , ) ) ; foreach ( $ this -> getDefaultModelMap ( ) as $ method => $ data ) foreach ( $ data as $ name => $ options ) if ( empty ( $ this -> modelMap [ $ method ] [ $ name ] ) ) $ this -> modelMap [ $ me...
Initializes the audit module .
12,028
private function _createFkData ( $ data , $ table ) { $ name = $ table . ucfirst ( Text :: singular ( $ data [ 'table' ] ) ) . 'Fk' ; $ structure = [ 'constraintType' => 'FOREIGN KEY' , 'constraintName' => $ name , 'columnName' => $ data [ 'from' ] , 'referenceTable' => $ data [ 'table' ] , 'referenceColumn' => $ data ...
Creates a known structure for foreign key constraint creation
12,029
public function isTrue ( $ condition , Blueprint $ sourceBlueprint = null ) { $ condition = $ this -> valueResolver -> resolvePlaceholders ( $ condition , $ sourceBlueprint , 'conditional_value' , $ condition ) ; if ( $ condition == 'default' ) { return true ; } if ( strpos ( $ condition , '==' ) !== false ) { list ( $...
Evaluate is key is true
12,030
public function getInvertedColor ( $ color ) { $ color = str_replace ( '#' , '' , $ this -> hex6 ( $ color ) ) ; if ( strlen ( $ color ) != 6 ) { return '#000000' ; } $ rgb = '' ; for ( $ x = 0 ; $ x < 3 ; $ x ++ ) { $ c = 255 - hexdec ( substr ( $ color , ( 2 * $ x ) , 2 ) ) ; $ c = ( $ c < 0 ) ? 0 : dechex ( $ c ) ; ...
Get inverted color
12,031
public function getLightOrDark ( $ color , $ dark = '#000000' , $ light = '#FFFFFF' ) { $ color = str_replace ( '#' , '' , $ this -> hex6 ( $ color ) ) ; $ r = hexdec ( substr ( $ color , 0 , 2 ) ) ; $ g = hexdec ( substr ( $ color , 2 , 2 ) ) ; $ b = hexdec ( substr ( $ color , 4 , 2 ) ) ; $ brightness = ( ( $ r * 299...
Get a light or dark color based on the contrast required for a good readability
12,032
public function toRgbArray ( ) { $ hex = str_replace ( "#" , "" , $ this -> getValue ( ) ) ; if ( strlen ( $ hex ) == 3 ) { $ r = hexdec ( substr ( $ hex , 0 , 1 ) . substr ( $ hex , 0 , 1 ) ) ; $ g = hexdec ( substr ( $ hex , 1 , 1 ) . substr ( $ hex , 1 , 1 ) ) ; $ b = hexdec ( substr ( $ hex , 2 , 1 ) . substr ( $ h...
Get rgb value as array
12,033
public static function update ( $ table = null ) { $ query = new Update ( ) ; if ( $ table ) { $ query -> table ( $ table ) ; } return $ query ; }
Factory Update Builder
12,034
public static function insert ( $ table = null ) { $ query = new Insert ( ) ; if ( $ table ) { $ query -> into ( $ table ) ; } return $ query ; }
Factory Insert Builder
12,035
public static function split ( $ str , $ length = 1 , $ yoon = false ) { $ chrs = preg_split ( "//u" , $ str , 0 , PREG_SPLIT_NO_EMPTY ) ; if ( $ length === 1 && ! $ yoon ) { return $ chrs ; } $ str_length = count ( $ chrs ) ; $ concatChrs = array ( ) ; for ( $ i = 0 , $ j = - 1 , $ k = - 1 ; $ i < $ str_length ; $ i +...
Enhance default splitter function to handle UTF - 8 characters .
12,036
public static function extractKanji ( $ str , $ length = 0 ) { if ( ! $ length ) { return preg_split ( self :: PREG_PATTERN_NOT_KANJI , $ str , 0 , PREG_SPLIT_NO_EMPTY ) ; } $ str = preg_replace ( self :: PREG_PATTERN_NOT_KANJI , "" , $ str ) ; return self :: split ( $ str , $ length ) ; }
Split a given string to extract kanji substrings .
12,037
public static function extractHiragana ( $ str , $ length = 0 , $ yoon = false ) { if ( ! $ length ) { return preg_split ( self :: PREG_PATTERN_NOT_HIRAGANA , $ str , 0 , PREG_SPLIT_NO_EMPTY ) ; } $ str = preg_replace ( self :: PREG_PATTERN_NOT_HIRAGANA , "" , $ str ) ; return self :: split ( $ str , $ length , $ yoon ...
Split a given string to extract hiragana substrings .
12,038
public static function extractKatakana ( $ str , $ length = 0 , $ yoon = false ) { if ( ! $ length ) { return preg_split ( self :: PREG_PATTERN_NOT_KATAKANA , $ str , 0 , PREG_SPLIT_NO_EMPTY ) ; } $ str = preg_replace ( self :: PREG_PATTERN_NOT_KATAKANA , "" , $ str ) ; return self :: split ( $ str , $ length , $ yoon ...
Split a given string to extract katakana substrings .
12,039
public static function extractKana ( $ str , $ length = 0 , $ yoon = false ) { if ( ! $ length ) { return preg_split ( self :: PREG_PATTERN_NOT_KANA , $ str , 0 , PREG_SPLIT_NO_EMPTY ) ; } $ str = preg_replace ( self :: PREG_PATTERN_NOT_KANA , "" , $ str ) ; return self :: split ( $ str , $ length , $ yoon ) ; }
Split a given string to extract kana substrings .
12,040
public static function removeMacrons ( $ str ) { if ( ! preg_match ( '/[\x80-\xff]/' , $ str ) ) { return $ str ; } $ chars = array ( chr ( 195 ) . chr ( 130 ) => 'A' , chr ( 195 ) . chr ( 162 ) => 'a' , chr ( 195 ) . chr ( 142 ) => 'I' , chr ( 195 ) . chr ( 174 ) => 'i' , chr ( 195 ) . chr ( 155 ) => 'U' , chr ( 195 )...
Remove macrons from the specified string .
12,041
public function getErrorType ( $ code ) { switch ( $ code ) { case E_ERROR : return self :: $ stack [ 'type' ] = 'Error' ; case E_WARNING : return self :: $ stack [ 'type' ] = 'Warning' ; case E_PARSE : return self :: $ stack [ 'type' ] = 'Parse' ; case E_NOTICE : return self :: $ stack [ 'type' ] = 'Notice' ; case E_C...
Convert error code to text .
12,042
protected function getPreviewCode ( ) { $ file = file ( self :: $ stack [ 'file' ] ) ; $ line = self :: $ stack [ 'line' ] ; $ start = ( $ line - 5 >= 0 ) ? $ line - 5 : $ line - 1 ; $ end = ( $ line - 5 >= 0 ) ? $ line + 4 : $ line + 8 ; for ( $ i = $ start ; $ i < $ end ; $ i ++ ) { if ( ! isset ( $ file [ $ i ] ) ) ...
Get preview of the error line .
12,043
protected function getCustomMethods ( ) { $ showDefaultView = true ; $ params = [ self :: $ stack ] ; unset ( $ params [ 0 ] [ 'trace' ] , $ params [ 0 ] [ 'preview' ] ) ; $ count = count ( self :: $ customMethods ) ; $ customMethods = self :: $ customMethods ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ custom = $ cu...
Get customs methods to renderizate .
12,044
public function first ( ) { $ limit = $ this -> _limit ; $ offset = $ this -> _offset ; $ this -> limit ( 1 ) ; $ result = $ this -> all ( ) ; $ this -> _limit = $ limit ; $ this -> _offset = $ offset ; return is_bool ( $ result ) ? [ ] : reset ( $ result ) ; }
Retrieves the first row of a given select query
12,045
public function count ( ) { $ limit = $ this -> _limit ; $ offset = $ this -> _offset ; $ this -> limit ( 0 ) ; $ joins = $ this -> getJoins ( ) ; $ copyJoins = clone ( $ joins ) ; $ keys = array_keys ( $ copyJoins -> getArrayCopy ( ) ) ; foreach ( $ keys as $ key ) { $ joins [ $ key ] [ 'fields' ] = array ( ) ; } $ th...
Count the rows for current where conditions
12,046
public function join ( $ table , $ clause , array $ fields = [ ] , $ type = self :: JOIN_LEFT ) { if ( empty ( $ fields ) ) { $ fields = array ( "*" ) ; } $ this -> getJoins ( ) -> append ( array ( 'table' => $ table , 'onClause' => $ clause , 'fields' => $ fields , 'type' => $ type ) ) ; return $ this ; }
Adds a join table to the current select statement
12,047
public function limit ( $ total , $ offset = 0 ) { $ this -> _limit = $ total ; $ this -> _offset = $ offset ; return $ this ; }
Sets the limit and the offset for this query
12,048
public function process ( $ data = array ( ) ) { try { return $ this -> twig -> render ( $ this -> _source , $ data ) ; } catch ( Twig_Error $ exp ) { throw new Exception \ ParserException ( "Error Processing Request: " . $ exp -> getMessage ( ) ) ; } }
Processes the template with data to produce the final output .
12,049
public function getTwig ( ) { if ( is_null ( $ this -> _twig ) ) { $ this -> _twig = new Twig_Environment ( new Twig_Loader_Filesystem ( $ this -> _paths ) , [ 'debug' => true , ] ) ; $ this -> _twig -> addExtension ( new Twig_Extension_Debug ( ) ) ; $ this -> _twig -> addExtension ( new SlickTwigExtension ( ) ) ; } re...
Lazy loading of twig library
12,050
public function getStem ( $ transliterationForm , $ verbalForm , $ languageForm ) { return ( $ transliterationForm === Inflector :: KANJI_FORM ) ? $ this -> stem [ Inflector :: KANJI_FORM ] : $ this -> stem [ Inflector :: KANA_FORM ] ; }
Basic getStem implementation which returns the kanji form otherwise the kana form no matter which verbal and language forms have been given .
12,051
public function getSuffix ( $ verbalForm , $ languageForm ) { return isset ( $ this -> suffixMap [ $ verbalForm ] ) && isset ( $ this -> suffixMap [ $ verbalForm ] [ $ languageForm ] ) ? $ this -> suffixMap [ $ verbalForm ] [ $ languageForm ] : null ; }
Get inflection suffix for a given verbal and language forms .
12,052
public function getFileManager ( ) { if ( $ this -> fileManager === null ) { if ( $ this -> config ( ) -> file_manager_enabled_by_default ) { return true ; } else { return false ; } } return $ this -> fileManager ; }
Get the responsive file manager state
12,053
public function setFileManager ( $ fileManager = true ) { if ( $ this -> config ( ) -> prevent_file_manager ) { return false ; } $ this -> fileManager = $ fileManager ; return $ fileManager ; }
Enable the responsive file manager for this tinymce instance
12,054
public function printApplicationDetails ( ) { $ this -> output -> writeln ( $ this -> console -> getName ( ) ) ; if ( ! is_null ( $ this -> console -> getVersion ( ) ) ) { $ this -> output -> writeln ( 'version ' . $ this -> console -> getVersion ( ) ) ; } $ this -> output -> writeln ( '' ) ; }
Prints the app name and version
12,055
public function listCommands ( ) { $ commands = $ this -> library -> getAll ( ) ; foreach ( $ commands as $ name => $ details ) { $ this -> output -> writeln ( ucwords ( $ name ) ) ; $ this -> output -> hr ( strlen ( $ details [ 'description' ] ) , '-' ) ; $ this -> output -> writeln ( $ details [ 'description' ] ) ; $...
Lists out command names and descriptions
12,056
public function current ( ) { $ fileInfo = parent :: current ( ) ; if ( $ fileInfo -> isDir ( ) ) { return new Folder ( array ( 'name' => $ fileInfo -> getRealPath ( ) ) ) ; } return new File ( $ fileInfo -> getRealPath ( ) ) ; }
Returns current element
12,057
public function getDisplayField ( ) { if ( is_null ( $ this -> _displayField ) ) { $ properties = array_keys ( $ this -> getDescriptor ( ) -> getColumns ( ) ) ; foreach ( $ properties as $ property ) { $ name = trim ( $ property , '_' ) ; $ pmk = $ this -> getDescriptor ( ) -> getEntity ( ) -> primaryKey ; if ( $ name ...
Returns the display field name
12,058
public function modelPlural ( RelationInterface $ relation ) { if ( ! isset ( $ this -> _modelPlural [ $ relation -> getPropertyName ( ) ] ) ) { $ parts = explode ( '\\' , $ relation -> getRelatedEntity ( ) ) ; $ name = Text :: camelCaseToSeparator ( end ( $ parts ) , '#' ) ; $ name = explode ( '#' , $ name ) ; $ final...
Returns the plural form of the class name
12,059
public function modelSingular ( RelationInterface $ relation ) { if ( ! isset ( $ this -> _modelSingular [ $ relation -> getPropertyName ( ) ] ) ) { $ parts = explode ( '\\' , $ relation -> getRelatedEntity ( ) ) ; $ this -> _modelSingular [ $ relation -> getPropertyName ( ) ] = lcfirst ( end ( $ parts ) ) ; } return $...
Returns the singular form of the class name
12,060
public function getPrimaryKey ( ) { if ( is_null ( $ this -> _primaryKey ) ) { $ this -> _primaryKey = $ this -> getDescriptor ( ) -> getEntity ( ) -> getPrimaryKey ( ) ; } return $ this -> _primaryKey ; }
Returns model primary key name
12,061
public function getTableName ( ) { if ( is_null ( $ this -> _tableName ) ) { $ this -> _tableName = $ this -> getDescriptor ( ) -> getEntity ( ) -> getTableName ( ) ; } return $ this -> _tableName ; }
Returns model table name
12,062
public function _after ( TestCase $ test ) { $ _SESSION = array ( ) ; $ _GET = array ( ) ; $ _POST = array ( ) ; $ _COOKIE = array ( ) ; parent :: _after ( $ test ) ; }
Runs after each test
12,063
public static function findExternalLinks ( $ content ) { $ matches = null ; preg_match_all ( '/(?:href|src)=\"([^\"]+)/' , $ content , $ matches ) ; if ( empty ( $ matches [ 1 ] ) ) { return [ ] ; } return $ matches [ 1 ] ; }
Finds external links in a given html content
12,064
public static function findTemporaryUploads ( $ content ) { $ links = self :: findExternalLinks ( $ content ) ; if ( empty ( $ links ) ) { return $ links ; } $ files = [ ] ; foreach ( $ links as $ link ) { $ strpos = strpos ( $ link , '/' . self :: TEMPORARY_FOLDER . '/' ) ; if ( $ strpos === false ) { continue ; } $ p...
Finds temporary file and image in a given html content
12,065
public static function deleteUnusedFiles ( $ originalContent , $ content ) { $ originalFiles = self :: findExternalLinks ( $ originalContent ) ; $ deleted = [ ] ; if ( empty ( $ originalFiles ) ) { return $ deleted ; } $ currentFiles = self :: findExternalLinks ( $ content ) ; $ diff = array_diff ( $ originalFiles , $ ...
Diff original and new content to find and delete removed files
12,066
public static function moveTemporaryUploads ( $ content , $ destFolder , & $ tmpFiles ) { $ replace = [ ] ; $ folder = Folder :: find_or_make ( $ destFolder ) ; foreach ( $ tmpFiles as $ file ) { $ oldURL = $ file -> getURL ( ) ; $ name = pathinfo ( $ file -> Name , PATHINFO_FILENAME ) ; $ ext = pathinfo ( $ file -> Na...
Move temporary files into a valid folder
12,067
public function getParameter ( $ index ) { $ parameter = null ; if ( $ this -> hasParameter ( $ index ) ) { $ parameter = $ this -> _parameters [ $ index ] ; } return $ parameter ; }
Returns the value at the provided position index
12,068
protected function get_home_label ( ) { $ page_on_front = get_option ( 'page_on_front' ) ; $ home_label = __ ( 'Home' , 'inc2734-wp-breadcrumbs' ) ; if ( $ page_on_front ) { $ home_label = get_the_title ( $ page_on_front ) ; } return $ home_label ; }
Return front page label
12,069
public function add ( $ input , $ name = null ) { if ( is_a ( $ input , 'Slick\Form\InputFilter\InputFilterInterface' ) && is_null ( $ name ) ) { throw new InvalidArgumentException ( "You must set a name to add an input filter to the list of " . "inputs of an input filter." ) ; } if ( ! is_a ( $ input , 'Slick\Form\Inp...
Add an input to the input filter
12,070
public function get ( $ name ) { $ input = null ; if ( $ this -> has ( $ name ) ) { $ input = $ this -> _inputs [ $ name ] ; } return $ input ; }
Retrieves the input stored with the provided name
12,071
public function remove ( $ name ) { $ removed = false ; if ( $ this -> has ( $ name ) ) { unset ( $ this -> _inputs [ $ name ] ) ; $ removed = true ; } return $ removed ; }
Removes the input that was stored with the provided name
12,072
public function setData ( $ data ) { foreach ( $ data as $ name => $ value ) { if ( $ this -> has ( $ name ) ) { $ this -> get ( $ name ) -> setValue ( $ value ) ; } } return $ this ; }
Populate data on current input list
12,073
public function isValid ( ) { $ valid = true ; $ messages = array ( ) ; foreach ( $ this -> _inputs as $ input ) { if ( ! $ input -> isValid ( ) ) { $ valid = false ; $ messages [ $ input -> name ] = $ input -> getMessages ( ) ; } } $ this -> _messages = $ messages ; return $ valid ; }
Check if all data set is valid
12,074
public function getValue ( $ name ) { $ value = null ; if ( $ this -> has ( $ name ) ) { $ value = call_user_func_array ( [ $ this -> _inputs [ $ name ] , 'getValue' ] , [ $ name ] ) ; } return $ value ; }
Get filtered value of the input with provided name
12,075
public function getValues ( ) { $ values = array ( ) ; foreach ( $ this -> _inputs as $ name => $ input ) { if ( strlen ( $ name ) > 0 ) { $ values [ $ name ] = call_user_func_array ( [ $ input , 'getValue' ] , [ $ name ] ) ; } } return $ values ; }
Returns all input values filtered
12,076
public function getRawValues ( ) { $ values = array ( ) ; foreach ( $ this -> _inputs as $ name => $ input ) { $ values [ $ name ] = call_user_func_array ( [ $ input , 'getRawValue' ] , [ $ name ] ) ; } return $ values ; }
Get all the values from data set without filtering
12,077
public function process ( $ payload ) { foreach ( $ this -> stages as $ stage ) { $ payload = call_user_func ( $ stage , $ payload ) ; } return $ payload ; }
Process the payload .
12,078
public function getNodes ( ) { if ( is_null ( $ this -> _nodes ) ) { $ this -> _nodes = new FileSystemList ( $ this -> details -> getRealPath ( ) ) ; } return $ this -> _nodes ; }
Returns an interator for this folder nodes
12,079
public function addFile ( $ name , $ mode = 'c+' ) { $ path = $ this -> details -> getRealPath ( ) ; return new File ( $ path . '/' . ltrim ( $ name , '/' ) , $ mode ) ; }
Adds a file to current folder
12,080
public function addFolder ( $ name ) { $ path = $ this -> details -> getRealPath ( ) ; return new Folder ( array ( 'name' => $ path . '/' . ltrim ( $ name , '/' ) ) ) ; }
Adds a folder to current folder
12,081
public function hasFile ( $ name ) { foreach ( $ this -> nodes as $ node ) { if ( $ node -> details -> getFilename ( ) == $ name && ! $ node -> details -> isDir ( ) ) { return true ; } } return false ; }
Searches for file existence in current folder .
12,082
public function get ( $ entity ) { $ name = is_object ( $ entity ) ? get_class ( $ entity ) : $ entity ; if ( ! isset ( $ this -> _entities [ $ name ] ) ) { $ this -> _entities [ $ name ] = new Descriptor ( [ 'entity' => $ entity ] ) ; } return $ this -> _entities [ $ name ] ; }
Returns the descriptor for the provided entity object
12,083
public function setControllerName ( $ modelName ) { $ name = end ( explode ( '/' , $ modelName ) ) ; $ this -> _controllerName = ucfirst ( Text :: plural ( lcfirst ( $ name ) ) ) ; return $ this ; }
Sets controller name
12,084
public function getModelPlural ( ) { if ( is_null ( $ this -> _modelPlural ) ) { $ name = $ this -> getModelSimpleName ( ) ; $ names = Text :: camelCaseToSeparator ( $ name , '#' ) ; $ names = explode ( '#' , $ names ) ; $ last = ucfirst ( Text :: plural ( strtolower ( array_pop ( $ names ) ) ) ) ; $ names [ ] = $ last...
Returns lowercase model name in plural form
12,085
public function getForm ( ) { if ( is_null ( $ this -> _form ) ) { $ this -> _form = new Form ( "scaffold" , $ this -> getDescriptor ( ) ) ; } return $ this -> _form ; }
Returns the default form for current controller
12,086
protected function _getFieldsAndPlaceholders ( ) { $ fields = $ this -> _sql -> getFields ( ) ; $ parts = [ ] ; foreach ( $ fields as $ field ) { $ parts [ ] = "{$field} = :{$field}" ; } return implode ( ', ' , $ parts ) ; }
Creates the fields and its placeholders
12,087
function storeSlug ( $ slug , $ title ) { if ( $ slug != '' ) $ slug = $ this -> str_slug ( $ slug ) ; else $ slug = $ this -> str_slug ( $ title ) ; return $ this -> checkSlugInCategories ( $ slug ) ; }
build slug for new category
12,088
function updateSlug ( $ category , $ slug , $ title ) { if ( $ slug != '' ) $ slug = $ this -> str_slug ( $ slug ) ; else $ slug = $ this -> str_slug ( $ title ) ; if ( $ category -> slug == $ slug ) return $ slug ; else return $ this -> checkSlugInCategories ( $ slug ) ; }
build slug for update category
12,089
function checkSlugInCategories ( $ slug ) { $ repet = true ; $ counter = 1 ; $ newSlug = $ slug ; while ( $ repet ) { if ( Categories :: where ( 'slug' , $ newSlug ) -> where ( 'model_type' , $ this -> type ) -> first ( ) ) { $ newSlug = $ slug . '-' . $ counter ; $ counter ++ ; } else $ repet = false ; } return $ newS...
search slug in database and build new slug when already exist slug
12,090
public function filter ( ) { $ requestUrl = $ this -> application -> request -> getQuery ( 'url' , '/' ) ; $ requestMethod = $ this -> application -> request -> getMethod ( ) ; $ event = new Route ( [ 'router' => $ this , 'application' => $ this -> application , 'request' => $ this -> application -> request ] ) ; $ thi...
Filter out route information
12,091
public function getForeignKey ( ) { if ( is_null ( $ this -> _foreignKey ) ) { $ this -> setForeignKey ( $ this -> _guessForeignKey ( ) ) ; } return $ this -> _foreignKey ; }
Returns the foreign key field name for this relation
12,092
public function getContainer ( ) { if ( is_null ( $ this -> _container ) ) { $ container = ContainerBuilder :: buildContainer ( [ 'sharedEventManager' => Definition :: object ( 'Zend\EventManager\SharedEventManager' ) ] ) ; $ this -> setContainer ( $ container ) ; } return $ this -> _container ; }
Returns the dependency container
12,093
public function select ( $ tableName , $ fields = [ '*' ] ) { $ sql = new Select ( $ tableName , $ fields ) ; $ sql -> setAdapter ( $ this -> _adapter ) ; return $ sql ; }
Creates a Select statement object
12,094
public function delete ( $ tableName ) { $ sql = new Delete ( $ tableName ) ; $ sql -> setAdapter ( $ this -> _adapter ) ; return $ sql ; }
Creates a Delete statement object
12,095
public function insert ( $ tableName ) { $ sql = new Insert ( $ tableName ) ; $ sql -> setAdapter ( $ this -> _adapter ) ; return $ sql ; }
Creates an Insert statement object
12,096
public function update ( $ tableName ) { $ sql = new Update ( $ tableName ) ; $ sql -> setAdapter ( $ this -> _adapter ) ; return $ sql ; }
Creates an Update statement object
12,097
protected function preTransliterate ( $ str ) { $ str = $ this -> escapeLatinCharacters ( $ str ) ; $ str = mb_convert_kana ( $ str , 'c' , 'UTF-8' ) ; return $ str ; }
Prepare given string for transliteration
12,098
public static function suite ( $ name , $ fn ) { $ suite = new Suite ( new InvocationContext ( ) , $ fn , $ name ) ; $ suite -> build ( ) ; return $ suite ; }
Begins a new test suite . The test suite instantiates a new invocation context .
12,099
public static function it ( $ name , $ fn ) { $ active_block = InvocationContext :: getAndAssertActiveBlock ( 'Matura\Blocks\Describe' ) ; $ test_method = new TestMethod ( $ active_block , $ fn , $ name ) ; $ test_method -> addToParent ( ) ; return $ test_method ; }
Begins a new test case within the active block .