idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
16,700
public function generate ( ) { $ html = array ( ) ; foreach ( $ this -> properties as $ property => $ value ) : if ( is_array ( $ value ) ) : foreach ( $ value as $ _value ) { $ html [ ] = strtr ( static :: OPENGRAPH_TAG , array ( '[property]' => static :: OPENGRAPH_PREFIX . $ property , '[value]' => $ _value ) ) ; } else : $ html [ ] = strtr ( static :: OPENGRAPH_TAG , array ( '[property]' => static :: OPENGRAPH_PREFIX . $ property , '[value]' => $ value ) ) ; endif ; endforeach ; return implode ( PHP_EOL , $ html ) ; }
Render the open graph tags .
16,701
public function fromRaw ( $ properties ) { $ this -> validateProperties ( $ properties ) ; foreach ( $ properties as $ property => $ value ) { $ this -> properties [ $ property ] = $ value ; } }
Set the open graph properties from a raw array .
16,702
public function fromObject ( OpenGraphAware $ object ) { $ properties = $ object -> getOpenGraphData ( ) ; $ this -> validateProperties ( $ properties ) ; foreach ( $ properties as $ property => $ value ) { $ this -> properties [ $ property ] = $ value ; } }
Use the open graph data of a open graph aware object .
16,703
protected function validateProperties ( $ properties ) { foreach ( $ this -> required as $ required ) { if ( ! array_key_exists ( $ required , $ properties ) ) { throw new \ InvalidArgumentException ( "Required open graph property [$required] is not present." ) ; } } }
Validate to make sure the properties contain all required ones .
16,704
public function jQueryDataTablesStandaloneFunction ( array $ args = [ ] ) { return $ this -> jQueryDataTablesStandalone ( ArrayHelper :: get ( $ args , "selector" , ".table" ) , ArrayHelper :: get ( $ args , "language" ) , ArrayHelper :: get ( $ args , "options" , [ ] ) ) ; }
Displays a jQuery DataTables Standalone .
16,705
public function execute ( ) { $ ch = \ curl_init ( ) ; $ this -> setAuth ( $ ch ) ; try { switch ( strtoupper ( $ this -> method ) ) { case 'GET' : $ this -> executeGet ( $ ch ) ; break ; case 'POST' : $ this -> executePost ( $ ch ) ; break ; case 'PUT' : $ this -> executePut ( $ ch ) ; break ; case 'PATCH' : $ this -> executePatch ( $ ch ) ; break ; case 'DELETE' : $ this -> executeDelete ( $ ch ) ; break ; case 'PUT_MP' : $ this -> method = 'PUT' ; $ this -> executePutMultipart ( $ ch ) ; break ; case 'POST_MP' : $ this -> method = 'POST' ; $ this -> executePostMultipart ( $ ch ) ; break ; default : throw new \ InvalidArgumentException ( 'Current method (' . $ this -> method . ') is an invalid REST method.' ) ; } } catch ( \ InvalidArgumentException $ e ) { \ curl_close ( $ ch ) ; throw $ e ; } catch ( \ Exception $ e ) { \ curl_close ( $ ch ) ; throw $ e ; } }
Execute curl request for each type of HTTP Request
16,706
public function buildPostBody ( $ data = null ) { $ reqBody = ( $ data !== null ) ? $ data : $ this -> request_body ; $ this -> request_body = ( string ) $ reqBody ; }
Build RAW post body
16,707
protected function executePutMultipart ( $ ch ) { $ xml = $ this -> request_body ; $ uri_string = $ this -> file_to_upload [ 0 ] ; $ file_name = $ this -> file_to_upload [ 1 ] ; $ post = array ( 'ResourceDescriptor' => $ xml , $ uri_string => '@' . $ file_name . ';filename=' . basename ( $ file_name ) ) ; \ curl_setopt ( $ ch , CURLOPT_TIMEOUT , 10 ) ; \ curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'PUT' ) ; \ curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ post ) ; \ curl_setopt ( $ ch , CURLOPT_URL , $ this -> url ) ; \ curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ this -> response_body = \ curl_exec ( $ ch ) ; $ this -> response_info = \ curl_getinfo ( $ ch ) ; \ curl_close ( $ ch ) ; }
Runs PUT multi - part request
16,708
protected function doExecute ( & $ curlHandle ) { $ this -> setCurlOpts ( $ curlHandle ) ; $ response = \ curl_exec ( $ curlHandle ) ; $ header_size = \ curl_getinfo ( $ curlHandle , CURLINFO_HEADER_SIZE ) ; $ this -> response_body = substr ( $ response , $ header_size ) ; $ this -> response_headers = [ ] ; $ lines = explode ( "\r\n" , substr ( $ response , 0 , $ header_size ) ) ; foreach ( $ lines as $ i => $ line ) { if ( $ i === 0 ) { $ this -> response_headers [ 'http_code' ] = $ line ; $ piece = explode ( " " , $ line ) ; if ( count ( $ piece ) > 1 ) { $ this -> response_headers [ 'protocol' ] = $ piece [ 0 ] ; $ this -> response_headers [ 'status_code' ] = $ piece [ 1 ] ; array_splice ( $ piece , 0 , 2 ) ; $ this -> response_headers [ 'reason_phrase' ] = implode ( " " , $ piece ) ; } } else { $ piece = explode ( ': ' , $ line , 2 ) ; if ( count ( $ piece ) == 2 ) { list ( $ key , $ value ) = $ piece ; if ( trim ( $ key ) !== "" ) { $ this -> response_headers [ $ key ] = trim ( $ value ) ; } } } } $ this -> response_info = \ curl_getinfo ( $ curlHandle ) ; \ curl_close ( $ curlHandle ) ; }
Perform Curl REquest
16,709
protected function setCurlOpts ( & $ curlHandle ) { \ curl_setopt ( $ curlHandle , CURLOPT_TIMEOUT , 10 ) ; \ curl_setopt ( $ curlHandle , CURLOPT_URL , $ this -> url ) ; \ curl_setopt ( $ curlHandle , CURLOPT_RETURNTRANSFER , true ) ; \ curl_setopt ( $ curlHandle , CURLOPT_VERBOSE , false ) ; \ curl_setopt ( $ curlHandle , CURLOPT_HEADER , true ) ; \ curl_setopt ( $ curlHandle , CURLOPT_COOKIEFILE , '/dev/null' ) ; \ curl_setopt ( $ curlHandle , CURLOPT_HTTPHEADER , $ this -> getDefaultHeader ( ) ) ; }
Set Curl Default Options
16,710
protected function setAuth ( & $ curlHandle ) { if ( $ this -> username !== null && $ this -> password !== null ) { \ curl_setopt ( $ curlHandle , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; \ curl_setopt ( $ curlHandle , CURLOPT_USERPWD , base64_encode ( $ this -> username . ':' . $ this -> password ) ) ; } }
Set Basic Authentication Headers to Curl Options
16,711
public function getResponseHeader ( $ key = null ) { if ( null != $ key ) { if ( array_key_exists ( $ key , $ this -> response_headers ) ) { return $ this -> response_headers [ $ key ] ; } } else { return $ this -> response_headers ; } }
Get Response Header
16,712
public static function bootTranslatable ( ) { static :: addGlobalScope ( new TranslatableScope ) ; try { $ observer = app ( TranslatableObserverContract :: class ) ; static :: observe ( $ observer ) ; } catch ( \ Exception $ exception ) { } }
Boot the soft deleting trait for a model .
16,713
public static function normalizeColumn ( DataTablesColumnInterface $ column ) { $ output = [ ] ; ArrayHelper :: set ( $ output , "cellType" , $ column -> getCellType ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "classname" , $ column -> getClassname ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "contentPadding" , $ column -> getContentPadding ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "data" , $ column -> getData ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "defaultContent" , $ column -> getDefaultContent ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "name" , $ column -> getName ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "orderable" , $ column -> getOrderable ( ) , [ null , true ] ) ; ArrayHelper :: set ( $ output , "orderData" , $ column -> getOrderData ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "orderDataType" , $ column -> getOrderDataType ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "orderSequence" , $ column -> getOrderSequence ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "searchable" , $ column -> getSearchable ( ) , [ null , true ] ) ; ArrayHelper :: set ( $ output , "type" , $ column -> getType ( ) , [ null ] ) ; ArrayHelper :: set ( $ output , "visible" , $ column -> getVisible ( ) , [ null , true ] ) ; ArrayHelper :: set ( $ output , "width" , $ column -> getWidth ( ) , [ null ] ) ; return $ output ; }
Normalize a column .
16,714
public static function normalizeResponse ( DataTablesResponseInterface $ response ) { $ output = [ ] ; $ output [ "data" ] = $ response -> getData ( ) ; $ output [ "draw" ] = $ response -> getDraw ( ) ; $ output [ "recordsFiltered" ] = $ response -> getRecordsFiltered ( ) ; $ output [ "recordsTotal" ] = $ response -> getRecordsTotal ( ) ; return $ output ; }
Normalize a response .
16,715
public static function isValidCode ( $ code ) { return strcspn ( $ code , ":/\\\000" ) === strlen ( $ code ) && ! preg_match ( Title :: getTitleInvalidRegex ( ) , $ code ) ; }
Returns true if a language code string is of a valid form whether or not it exists . This includes codes which are used solely for customisation via the MediaWiki namespace .
16,716
public static function getLocalisationCache ( ) { if ( is_null ( self :: $ dataCache ) ) { global $ wgLocalisationCacheConf ; $ class = $ wgLocalisationCacheConf [ 'class' ] ; self :: $ dataCache = new $ class ( $ wgLocalisationCacheConf ) ; } return self :: $ dataCache ; }
Get the LocalisationCache instance
16,717
function getGenderNsText ( $ index , $ gender ) { $ ns = self :: $ dataCache -> getItem ( $ this -> mCode , 'namespaceGenderAliases' ) ; return isset ( $ ns [ $ index ] [ $ gender ] ) ? $ ns [ $ index ] [ $ gender ] : $ this -> getNsText ( $ index ) ; }
Returns gender - dependent namespace alias if available .
16,718
function getLocalNsIndex ( $ text ) { $ lctext = $ this -> lc ( $ text ) ; $ ids = $ this -> getNamespaceIds ( ) ; return isset ( $ ids [ $ lctext ] ) ? $ ids [ $ lctext ] : false ; }
Get a namespace key by value case insensitive . Only matches namespace names for the current language not the canonical ones defined in Namespace . php .
16,719
function getNsIndex ( $ text ) { $ lctext = $ this -> lc ( $ text ) ; if ( ( $ ns = MWNamespace :: getCanonicalIndex ( $ lctext ) ) !== null ) { return $ ns ; } $ ids = $ this -> getNamespaceIds ( ) ; return isset ( $ ids [ $ lctext ] ) ? $ ids [ $ lctext ] : false ; }
Get a namespace key by value case insensitive . Canonical namespace names override custom ones defined for the current language .
16,720
private static function hebrewYearStart ( $ year ) { $ a = intval ( ( 12 * ( $ year - 1 ) + 17 ) % 19 ) ; $ b = intval ( ( $ year - 1 ) % 4 ) ; $ m = 32.044093161144 + 1.5542417966212 * $ a + $ b / 4.0 - 0.0031777940220923 * ( $ year - 1 ) ; if ( $ m < 0 ) { $ m -- ; } $ Mar = intval ( $ m ) ; if ( $ m < 0 ) { $ m ++ ; } $ m -= $ Mar ; $ c = intval ( ( $ Mar + 3 * ( $ year - 1 ) + 5 * $ b + 5 ) % 7 ) ; if ( $ c == 0 && $ a > 11 && $ m >= 0.89772376543210 ) { $ Mar ++ ; } elseif ( $ c == 1 && $ a > 6 && $ m >= 0.63287037037037 ) { $ Mar += 2 ; } elseif ( $ c == 2 || $ c == 4 || $ c == 6 ) { $ Mar ++ ; } $ Mar += intval ( ( $ year - 3761 ) / 100 ) - intval ( ( $ year - 3761 ) / 400 ) - 24 ; return $ Mar ; }
This calculates the Hebrew year start as days since 1 September . Based on Carl Friedrich Gauss algorithm for finding Easter date . Used for Hebrew date .
16,721
static function romanNumeral ( $ num ) { static $ table = array ( array ( '' , 'I' , 'II' , 'III' , 'IV' , 'V' , 'VI' , 'VII' , 'VIII' , 'IX' , 'X' ) , array ( '' , 'X' , 'XX' , 'XXX' , 'XL' , 'L' , 'LX' , 'LXX' , 'LXXX' , 'XC' , 'C' ) , array ( '' , 'C' , 'CC' , 'CCC' , 'CD' , 'D' , 'DC' , 'DCC' , 'DCCC' , 'CM' , 'M' ) , array ( '' , 'M' , 'MM' , 'MMM' ) ) ; $ num = intval ( $ num ) ; if ( $ num > 3000 || $ num <= 0 ) { return $ num ; } $ s = '' ; for ( $ pow10 = 1000 , $ i = 3 ; $ i >= 0 ; $ pow10 /= 10 , $ i -- ) { if ( $ num >= $ pow10 ) { $ s .= $ table [ $ i ] [ floor ( $ num / $ pow10 ) ] ; } $ num = $ num % $ pow10 ; } return $ s ; }
Roman number formatting up to 3000
16,722
function uc ( $ str , $ first = false ) { if ( function_exists ( 'mb_strtoupper' ) ) { if ( $ first ) { if ( $ this -> isMultibyte ( $ str ) ) { return mb_strtoupper ( mb_substr ( $ str , 0 , 1 ) ) . mb_substr ( $ str , 1 ) ; } else { return ucfirst ( $ str ) ; } } else { return $ this -> isMultibyte ( $ str ) ? mb_strtoupper ( $ str ) : strtoupper ( $ str ) ; } } else { if ( $ this -> isMultibyte ( $ str ) ) { $ x = $ first ? '^' : '' ; return preg_replace_callback ( "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/" , array ( $ this , 'ucCallback' ) , $ str ) ; } else { return $ first ? ucfirst ( $ str ) : strtoupper ( $ str ) ; } } }
Convert a string to uppercase
16,723
function ucwordbreaks ( $ str ) { if ( $ this -> isMultibyte ( $ str ) ) { $ str = $ this -> lc ( $ str ) ; $ breaks = "[ \-\(\)\}\{\.,\?!]" ; $ replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/" ; if ( function_exists ( 'mb_strtoupper' ) ) { return preg_replace_callback ( $ replaceRegexp , array ( $ this , 'ucwordbreaksCallbackMB' ) , $ str ) ; } else { return preg_replace_callback ( $ replaceRegexp , array ( $ this , 'ucwordsCallbackWiki' ) , $ str ) ; } } else { return preg_replace_callback ( '/\b([\w\x80-\xff]+)\b/' , array ( $ this , 'ucwordbreaksCallbackAscii' ) , $ str ) ; } }
capitalize words at word breaks
16,724
function firstChar ( $ s ) { $ matches = array ( ) ; preg_match ( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/' , $ s , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { if ( strlen ( $ matches [ 1 ] ) != 3 ) { return $ matches [ 1 ] ; } $ code = utf8ToCodepoint ( $ matches [ 1 ] ) ; if ( $ code < 0xac00 || 0xd7a4 <= $ code ) { return $ matches [ 1 ] ; } elseif ( $ code < 0xb098 ) { return "\xe3\x84\xb1" ; } elseif ( $ code < 0xb2e4 ) { return "\xe3\x84\xb4" ; } elseif ( $ code < 0xb77c ) { return "\xe3\x84\xb7" ; } elseif ( $ code < 0xb9c8 ) { return "\xe3\x84\xb9" ; } elseif ( $ code < 0xbc14 ) { return "\xe3\x85\x81" ; } elseif ( $ code < 0xc0ac ) { return "\xe3\x85\x82" ; } elseif ( $ code < 0xc544 ) { return "\xe3\x85\x85" ; } elseif ( $ code < 0xc790 ) { return "\xe3\x85\x87" ; } elseif ( $ code < 0xcc28 ) { return "\xe3\x85\x88" ; } elseif ( $ code < 0xce74 ) { return "\xe3\x85\x8a" ; } elseif ( $ code < 0xd0c0 ) { return "\xe3\x85\x8b" ; } elseif ( $ code < 0xd30c ) { return "\xe3\x85\x8c" ; } elseif ( $ code < 0xd558 ) { return "\xe3\x85\x8d" ; } else { return "\xe3\x85\x8e" ; } } else { return '' ; } }
Get the first character of a string .
16,725
function normalize ( $ s ) { global $ wgAllUnicodeFixes ; $ s = UtfNormal :: cleanUp ( $ s ) ; if ( $ wgAllUnicodeFixes ) { $ s = $ this -> transformUsingPairFile ( 'normalize-ar.ser' , $ s ) ; $ s = $ this -> transformUsingPairFile ( 'normalize-ml.ser' , $ s ) ; } return $ s ; }
Convert a UTF - 8 string to normal form C . In Malayalam and Arabic this also cleans up certain backwards - compatible sequences converting them to the modern Unicode equivalent .
16,726
function getMagic ( $ mw ) { $ this -> doMagicHook ( ) ; if ( isset ( $ this -> mMagicExtensions [ $ mw -> mId ] ) ) { $ rawEntry = $ this -> mMagicExtensions [ $ mw -> mId ] ; } else { $ magicWords = $ this -> getMagicWords ( ) ; if ( isset ( $ magicWords [ $ mw -> mId ] ) ) { $ rawEntry = $ magicWords [ $ mw -> mId ] ; } else { $ rawEntry = false ; } } if ( ! is_array ( $ rawEntry ) ) { error_log ( "\"$rawEntry\" is not a valid magic word for \"$mw->mId\"" ) ; } else { $ mw -> mCaseSensitive = $ rawEntry [ 0 ] ; $ mw -> mSynonyms = array_slice ( $ rawEntry , 1 ) ; } }
Fill a MagicWord object with data from here
16,727
function addMagicWordsByLang ( $ newWords ) { $ code = $ this -> getCode ( ) ; $ fallbackChain = array ( ) ; while ( $ code && ! in_array ( $ code , $ fallbackChain ) ) { $ fallbackChain [ ] = $ code ; $ code = self :: getFallbackFor ( $ code ) ; } if ( ! in_array ( 'en' , $ fallbackChain ) ) { $ fallbackChain [ ] = 'en' ; } $ fallbackChain = array_reverse ( $ fallbackChain ) ; foreach ( $ fallbackChain as $ code ) { if ( isset ( $ newWords [ $ code ] ) ) { $ this -> mMagicExtensions = $ newWords [ $ code ] + $ this -> mMagicExtensions ; } } }
Add magic words to the extension array
16,728
function getSpecialPageAliases ( ) { if ( is_null ( $ this -> mExtendedSpecialPageAliases ) ) { $ this -> mExtendedSpecialPageAliases = self :: $ dataCache -> getItem ( $ this -> mCode , 'specialPageAliases' ) ; wfRunHooks ( 'LanguageGetSpecialPageAliases' , array ( & $ this -> mExtendedSpecialPageAliases , $ this -> getCode ( ) ) ) ; } return $ this -> mExtendedSpecialPageAliases ; }
Get special page names as an associative array case folded alias = > real name
16,729
protected function preConvertPlural ( $ forms , $ count ) { while ( count ( $ forms ) < $ count ) { $ forms [ ] = $ forms [ count ( $ forms ) - 1 ] ; } return $ forms ; }
Checks that convertPlural was given an array and pads it to requested amount of forms by copying the last one .
16,730
static function getFileName ( $ prefix = 'Language' , $ code , $ suffix = '.php' ) { if ( ! Language :: isValidCode ( $ code ) || strcspn ( $ code , ":/\\\000" ) !== strlen ( $ code ) ) { throw new MWException ( "Invalid language code \"$code\"" ) ; } return $ prefix . str_replace ( '-' , '_' , ucfirst ( $ code ) ) . $ suffix ; }
Get the name of a file for a certain language code
16,731
public function toArray ( ) { $ return = [ ] ; foreach ( $ this as $ property => $ value ) { if ( '__' == substr ( $ property , 0 , 2 ) || '' === $ value || is_null ( $ value ) || ( is_array ( $ value ) && empty ( $ value ) ) ) { continue ; } if ( in_array ( $ property , $ this -> functions ) && substr ( $ value , 0 , 8 ) == 'function' ) { $ value = "%{$property}%" ; } $ return [ $ property ] = $ value ; } return $ return ; }
Return the array of this object
16,732
public function toJSON ( ) { $ json = json_encode ( $ this -> toArray ( ) ) ; return str_replace ( [ '"%hoverCallback%"' , '"%formatter%"' , '"%dateFormat%"' , ] , [ $ this -> hoverCallback , $ this -> formatter , $ this -> dateFormat , ] , $ json ) ; }
Return the jSON encode of this chart
16,733
public function toJavascript ( ) { ob_start ( ) ; ?> <script type="text/javascript"> jQuery( function( $ ) { "use strict"; Morris. <?php echo $ this -> __chart_type ?> ( <?php echo $ this -> toJSON ( ) ?> ); } ); </script> <?php $ buffer = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ buffer ; }
Return the HTML markup for Javascript code
16,734
private function getByClassName ( $ className ) { if ( $ className === '' ) { throw new \ InvalidArgumentException ( '$className must not be empty.' , 1331488868 ) ; } $ unifiedClassName = self :: unifyClassName ( $ className ) ; if ( ! isset ( $ this -> mappers [ $ unifiedClassName ] ) ) { if ( ! class_exists ( $ className , true ) ) { throw new \ InvalidArgumentException ( 'No mapper class "' . $ className . '" could be found.' ) ; } $ mapper = GeneralUtility :: makeInstance ( $ unifiedClassName ) ; $ this -> mappers [ $ unifiedClassName ] = $ mapper ; } else { $ mapper = $ this -> mappers [ $ unifiedClassName ] ; } if ( $ this -> testingMode ) { $ mapper -> setTestingFramework ( $ this -> testingFramework ) ; } if ( $ this -> denyDatabaseAccess ) { $ mapper -> disableDatabaseAccess ( ) ; } return $ mapper ; }
Retrieves a dataMapper by class name .
16,735
protected function renderButtons ( $ entity , $ editRoute , $ deleteRoute = null , $ enableDelete = true ) { $ titles = [ ] ; $ titles [ ] = $ this -> getTranslator ( ) -> trans ( "label.edit" , [ ] , "CoreBundle" ) ; $ titles [ ] = $ this -> getTranslator ( ) -> trans ( "label.delete" , [ ] , "CoreBundle" ) ; $ actions = [ ] ; $ actions [ ] = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonDefaultFunction ( [ "icon" => "pencil" , "title" => $ titles [ 0 ] , "size" => "xs" ] ) ; $ actions [ ] = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonDangerFunction ( [ "icon" => "trash" , "title" => $ titles [ 1 ] , "size" => "xs" ] ) ; $ routes = [ ] ; $ routes [ ] = $ this -> getRouter ( ) -> generate ( $ editRoute , [ "id" => $ entity -> getId ( ) ] ) ; $ routes [ ] = $ this -> getRouter ( ) -> generate ( "jquery_datatables_delete" , [ "name" => $ this -> getName ( ) , "id" => $ entity -> getId ( ) ] ) ; if ( null !== $ deleteRoute ) { $ routes [ 1 ] = $ this -> getRouter ( ) -> generate ( $ deleteRoute , [ "id" => $ entity -> getId ( ) ] ) ; } $ links = [ ] ; $ links [ ] = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonLinkFilter ( $ actions [ 0 ] , $ routes [ 0 ] ) ; if ( true === $ enableDelete ) { $ links [ ] = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonLinkFilter ( $ actions [ 1 ] , $ routes [ 1 ] ) ; } return implode ( " " , $ links ) ; }
Render the DataTables buttons .
16,736
protected function renderFloat ( $ number , $ decimals = 2 , $ decPoint = "." , $ thousandsSep = "," ) { if ( null === $ number ) { return "" ; } return number_format ( $ number , $ decimals , $ decPoint , $ thousandsSep ) ; }
Render a float .
16,737
protected function wrapContent ( $ prefix , $ content , $ suffix ) { $ output = [ ] ; if ( null !== $ prefix ) { $ output [ ] = $ prefix ; } $ output [ ] = $ content ; if ( null !== $ suffix ) { $ output [ ] = $ suffix ; } return implode ( "" , $ output ) ; }
Wrap a content .
16,738
public static function getInstance ( $ type ) { self :: checkType ( $ type ) ; if ( ! isset ( self :: $ instances [ $ type ] ) ) { self :: $ instances [ $ type ] = new \ Tx_Oelib_Session ( $ type ) ; } return self :: $ instances [ $ type ] ; }
Returns an instance of this class .
16,739
public static function setInstance ( $ type , \ Tx_Oelib_Session $ instance ) { self :: checkType ( $ type ) ; self :: $ instances [ $ type ] = $ instance ; }
Sets the instance for the given type .
16,740
public function validateParams ( $ p_aParams , & $ p_strError ) { if ( isset ( $ p_aParams [ 'shoppingCartType' ] ) ) { $ strShoppingCartType = trim ( $ p_aParams [ 'shoppingCartType' ] ) ; } if ( empty ( $ strShoppingCartType ) ) { $ strShoppingCartType = "MIXED" ; } if ( isset ( $ p_aParams [ 'shippingAddresseFirstName' ] ) ) { $ strFirstName = trim ( $ p_aParams [ 'shippingAddresseFirstName' ] ) ; } else { $ strFirstName = "" ; } if ( isset ( $ p_aParams [ 'shippingAddresseLastName' ] ) ) { $ strLastName = trim ( $ p_aParams [ 'shippingAddresseLastName' ] ) ; } else { $ strLastName = "" ; } if ( isset ( $ p_aParams [ 'shippingEmail' ] ) ) { $ strEmail = trim ( $ p_aParams [ 'shippingEmail' ] ) ; } else { $ strEmail = "" ; } if ( isset ( $ p_aParams [ 'shippingZipCode' ] ) ) { $ strZipCode = trim ( $ p_aParams [ 'shippingZipCode' ] ) ; } else { $ strZipCode = "" ; } if ( isset ( $ p_aParams [ 'shippingCity' ] ) ) { $ strCity = trim ( $ p_aParams [ 'shippingCity' ] ) ; } else { $ strCity = "" ; } if ( isset ( $ p_aParams [ 'shippingCountry' ] ) ) { $ strCountry = trim ( $ p_aParams [ 'shippingCountry' ] ) ; } else { $ strCountry = "" ; } if ( ! in_array ( $ strShoppingCartType , array ( 'PHYSICAL' , 'DIGITAL' , 'MIXED' , 'ANONYMOUS_DONATION' , 'AUTHORITIES_PAYMENT' , ) ) ) { $ p_strError = "Shopping cart type" ; return FALSE ; } if ( in_array ( $ strShoppingCartType , array ( 'MIXED' , 'PHYSICAL' , 'DIGITAL' ) ) ) { if ( empty ( $ strFirstName ) ) { $ p_strError = "First Name" ; return FALSE ; } if ( empty ( $ strLastName ) ) { $ p_strError = "Last Name" ; return FALSE ; } } if ( $ strShoppingCartType == 'DIGITAL' ) { if ( empty ( $ strEmail ) ) { $ p_strError = "Shipping Email" ; return FALSE ; } } elseif ( in_array ( $ strShoppingCartType , array ( 'MIXED' , 'PHYSICAL' ) ) ) { if ( empty ( $ strZipCode ) ) { $ p_strError = "Shipping Address Zip code" ; return FALSE ; } if ( empty ( $ strCity ) ) { $ p_strError = "Shipping Address City" ; return FALSE ; } if ( empty ( $ strCountry ) ) { $ p_strError = "Shipping Address Country" ; return FALSE ; } } return TRUE ; }
Do some special validations for this payment method . Used only in a few simply returns true for most .
16,741
public function loadClassMetadata ( Mapping \ ClassMetadataInterface $ metadata ) { $ reflClass = $ metadata -> getReflectionClass ( ) ; foreach ( $ reflClass -> getProperties ( ) as $ property ) { $ this -> readProperty ( $ property , $ metadata ) ; } }
Loads annotations data present in the class using a Doctrine annotation reader
16,742
public function updateColumns ( $ itemType , & $ columns ) { if ( $ itemType !== 'Pages' ) { return ; } if ( ! self :: enabled ( ) ) { return ; } $ field = Config :: inst ( ) -> get ( __CLASS__ , 'tag_field' ) ; $ columns [ 'Terms' ] = [ 'printonly' => true , 'title' => _t ( 'SilverStripe\\SiteWideContentReport\\SitewideContentReport.Tags' , 'Tags' ) , 'datasource' => function ( $ record ) use ( $ field ) { $ tags = $ record -> $ field ( ) -> column ( 'Name' ) ; return implode ( ', ' , $ tags ) ; } , ] ; }
Update columns to include taxonomy details .
16,743
public static function enabled ( ) { if ( ! class_exists ( TaxonomyTerm :: class ) ) { return false ; } $ field = Config :: inst ( ) -> get ( __CLASS__ , 'tag_field' ) ; return singleton ( 'Page' ) -> hasMethod ( $ field ) ; }
Check if this field is enabled .
16,744
public function addEntitySubject ( $ id , $ type = null , $ idKey = "id" , $ typeKey = "type" ) { if ( ! isset ( $ this -> _subscription -> subject ) ) { $ this -> _subscription -> subject = ( object ) [ "entities" => [ ] , "condition" => ( object ) [ "attrs" => [ ] ] ] ; } $ entity = ( object ) [ ] ; $ entity -> $ idKey = $ id ; if ( null != $ type ) { $ entity -> $ typeKey = ( string ) $ type ; } $ this -> _subscription -> subject -> entities [ ] = $ entity ; return $ this ; }
Add a Entity to subject . entities
16,745
public function addAttrCondition ( $ attr ) { if ( ! isset ( $ this -> _subscription -> subject ) ) { $ this -> _subscription -> subject = ( object ) [ ] ; } if ( ! isset ( $ this -> _subscription -> subject -> condition ) ) { $ this -> _subscription -> subject -> condition = ( object ) [ ] ; } if ( ! isset ( $ this -> _subscription -> subject -> condition -> attrs ) ) { $ this -> _subscription -> subject -> condition -> attrs = [ ] ; } array_push ( $ this -> _subscription -> subject -> condition -> attrs , $ attr ) ; return $ this ; }
Add a Attr to subject . condition . attr
16,746
public function addExpressionCondition ( $ expression ) { if ( ! isset ( $ this -> _subscription -> subject ) ) { $ this -> _subscription -> subject = ( object ) [ ] ; } if ( ! isset ( $ this -> _subscription -> subject -> condition ) ) { $ this -> _subscription -> subject -> condition = ( object ) [ ] ; } $ this -> _subscription -> subject -> condition -> expression = $ expression ; return $ this ; }
Add expression condition an expression composed of q georel geometry and coords
16,747
public function setOptions ( array $ options ) : BackoffInterface { $ this -> options = array_merge ( $ this -> options , $ options ) ; return $ this ; }
Allows overwrite default option values .
16,748
public function exponential ( int $ attempt ) : float { if ( ! is_int ( $ attempt ) ) { throw new InvalidArgumentException ( 'Attempt must be an integer' ) ; } if ( $ attempt < 1 ) { throw new InvalidArgumentException ( 'Attempt must be >= 1' ) ; } if ( $ this -> maxAttempsExceeded ( $ attempt ) ) { throw new BackoffException ( sprintf ( "The number of max attempts (%s) was exceeded" , $ this -> options [ 'maxAttempts' ] ) ) ; } $ wait = ( 1 << ( $ attempt - 1 ) ) * 1000 ; return ( $ this -> options [ 'cap' ] < $ wait ) ? $ this -> options [ 'cap' ] : $ wait ; }
Exponential backoff algorithm .
16,749
public function equalJitter ( int $ attempt ) : int { $ half = ( $ this -> exponential ( $ attempt ) / 2 ) ; return ( int ) floor ( $ half + $ this -> random ( 0.0 , $ half ) ) ; }
This method adds a half jitter value to exponential backoff value .
16,750
public function fullJitter ( int $ attempt ) : int { return ( int ) floor ( $ this -> random ( 0.0 , $ this -> exponential ( $ attempt ) / 2 ) ) ; }
This method adds a jitter value to exponential backoff value .
16,751
protected function random ( float $ min , float $ max ) : float { return ( $ min + lcg_value ( ) * ( abs ( $ max - $ min ) ) ) ; }
Generates a random number between min and max .
16,752
public function getRequestHeaders ( ) { $ headers = array ( 'Accept' => 'application/json' , ) ; if ( $ this -> getHttpMethod ( ) !== 'GET' ) { $ headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ; } if ( $ this -> getHttpMethod ( ) === 'POST' ) { $ headers [ 'Idempotency-Key' ] = $ this -> getIdempotencyKey ( ) ; } return $ headers ; }
Get request headers
16,753
public function sendData ( $ data ) { $ config = $ this -> httpClient -> getConfig ( ) ; $ curlOptions = $ config -> get ( 'curl.options' ) ; $ curlOptions [ CURLOPT_SSLVERSION ] = 6 ; $ config -> set ( 'curl.options' , $ curlOptions ) ; $ this -> httpClient -> setConfig ( $ config ) ; $ this -> httpClient -> getEventDispatcher ( ) -> addListener ( 'request.error' , function ( $ event ) { if ( $ event [ 'response' ] -> isClientError ( ) ) { $ event -> stopPropagation ( ) ; } } ) ; if ( $ this -> getSSLCertificatePath ( ) ) { $ this -> httpClient -> setSslVerification ( $ this -> getSSLCertificatePath ( ) ) ; } $ request = $ this -> httpClient -> createRequest ( $ this -> getHttpMethod ( ) , $ this -> getEndpoint ( ) , $ this -> getRequestHeaders ( ) , $ data ) ; $ apikey = ( $ this -> getUseSecretKey ( ) ) ? $ this -> getApiKeySecret ( ) : $ this -> getApiKeyPublic ( ) ; $ request -> setHeader ( 'Authorization' , 'Basic ' . base64_encode ( $ apikey . ':' ) ) ; $ response = $ request -> send ( ) ; $ this -> response = new Response ( $ this , $ response -> json ( ) ) ; $ this -> response -> setHttpResponseCode ( $ response -> getStatusCode ( ) ) ; $ this -> response -> setTransactionType ( $ this -> getTransactionType ( ) ) ; return $ this -> response ; }
Send data request
16,754
public function addToData ( array $ data = array ( ) , array $ parms = array ( ) ) { foreach ( $ parms as $ parm ) { $ getter = 'get' . ucfirst ( $ parm ) ; if ( method_exists ( $ this , $ getter ) && $ this -> $ getter ( ) ) { $ data [ $ parm ] = $ this -> $ getter ( ) ; } } return $ data ; }
Add multiple parameters to data
16,755
private function getByNamespace ( $ namespace ) { $ this -> checkForNonEmptyNamespace ( $ namespace ) ; if ( ! isset ( $ this -> configurations [ $ namespace ] ) ) { $ this -> configurations [ $ namespace ] = $ this -> retrieveConfigurationFromTypoScriptSetup ( $ namespace ) ; } return $ this -> configurations [ $ namespace ] ; }
Retrieves a Configuration by namespace .
16,756
public function set ( $ namespace , \ Tx_Oelib_Configuration $ configuration ) { $ this -> checkForNonEmptyNamespace ( $ namespace ) ; if ( isset ( $ this -> configurations [ $ namespace ] ) ) { $ this -> dropConfiguration ( $ namespace ) ; } $ this -> configurations [ $ namespace ] = $ configuration ; }
Sets a configuration for a certain namespace .
16,757
private function retrieveConfigurationFromTypoScriptSetup ( $ namespace ) { $ data = $ this -> getCompleteTypoScriptSetup ( ) ; $ namespaceParts = explode ( '.' , $ namespace ) ; foreach ( $ namespaceParts as $ namespacePart ) { if ( ! array_key_exists ( $ namespacePart . '.' , $ data ) ) { $ data = [ ] ; break ; } $ data = $ data [ $ namespacePart . '.' ] ; } $ configuration = GeneralUtility :: makeInstance ( \ Tx_Oelib_Configuration :: class ) ; $ configuration -> setData ( $ data ) ; return $ configuration ; }
Retrieves the configuration from TS Setup of the current page for a given namespace .
16,758
private function getCompleteTypoScriptSetup ( ) { $ pageUid = \ Tx_Oelib_PageFinder :: getInstance ( ) -> getPageUid ( ) ; if ( $ pageUid === 0 ) { return [ ] ; } if ( $ this -> existsFrontEnd ( ) ) { return $ this -> getFrontEndController ( ) -> tmpl -> setup ; } $ template = GeneralUtility :: makeInstance ( TemplateService :: class ) ; $ template -> tt_track = 0 ; $ template -> init ( ) ; $ page = GeneralUtility :: makeInstance ( PageRepository :: class ) ; $ rootline = $ page -> getRootLine ( $ pageUid ) ; $ template -> runThroughTemplates ( $ rootline , 0 ) ; $ template -> generateConfig ( ) ; return $ template -> setup ; }
Retrieves the complete TypoScript setup for the current page as a nested array .
16,759
private function existsFrontEnd ( ) { $ frontEndController = $ this -> getFrontEndController ( ) ; return ( $ frontEndController !== null ) && is_object ( $ frontEndController -> tmpl ) && $ frontEndController -> tmpl -> loaded ; }
Checks whether there is an initialized front end with a loaded TS template .
16,760
public function restrictAdminBarVisibility ( ) { if ( is_admin ( ) || ! is_user_logged_in ( ) ) { return ; } $ data = $ this -> getData ( ) ; if ( ! isset ( $ data [ 'admin_bar' ] ) || empty ( $ data [ 'admin_bar' ] ) ) { return ; } $ access = $ data [ 'admin_bar' ] ; $ user = wp_get_current_user ( ) ; $ role = $ user -> roles ; $ role = ( count ( $ role ) > 0 ) ? $ role [ 0 ] : '' ; $ isUserIncluded = in_array ( $ role , $ access [ 'roles' ] ) ; if ( ( $ access [ 'mode' ] == 'show' && ! $ isUserIncluded ) || ( $ access [ 'mode' ] == 'hide' && $ isUserIncluded ) ) { show_admin_bar ( false ) ; } }
Restrict visiblity of the admin bar
16,761
private function restrictAdminPanelAccess ( ) { if ( ( defined ( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined ( 'WP_CLI' ) && WP_CLI ) || ! is_user_logged_in ( ) ) { return ; } $ data = $ this -> getData ( ) ; if ( ! isset ( $ data [ 'admin_access' ] ) || empty ( $ data [ 'admin_access' ] ) || ! is_admin ( ) ) { return ; } $ access = $ data [ 'admin_access' ] ; $ user = wp_get_current_user ( ) ; $ role = $ user -> roles ; $ role = ( count ( $ role ) > 0 ) ? $ role [ 0 ] : '' ; $ isUserIncluded = in_array ( $ role , $ access [ 'roles' ] ) ; if ( ( $ access [ 'mode' ] == 'allow' && ! $ isUserIncluded ) || ( $ access [ 'mode' ] == 'forbid' && $ isUserIncluded ) ) { wp_redirect ( home_url ( ) ) ; exit ; } }
Restrict access to the wp - admin .
16,762
private function parseCssShorthandValue ( $ value ) { $ values = preg_split ( '/\\s+/' , $ value ) ; $ css = [ ] ; $ css [ 'top' ] = $ values [ 0 ] ; $ css [ 'right' ] = ( count ( $ values ) > 1 ) ? $ values [ 1 ] : $ css [ 'top' ] ; $ css [ 'bottom' ] = ( count ( $ values ) > 2 ) ? $ values [ 2 ] : $ css [ 'top' ] ; $ css [ 'left' ] = ( count ( $ values ) > 3 ) ? $ values [ 3 ] : $ css [ 'right' ] ; return $ css ; }
Parses a shorthand CSS value and splits it into individual values
16,763
private function clearAllCaches ( ) { $ this -> clearCache ( self :: CACHE_KEY_CSS ) ; $ this -> clearCache ( self :: CACHE_KEY_SELECTOR ) ; $ this -> clearCache ( self :: CACHE_KEY_XPATH ) ; $ this -> clearCache ( self :: CACHE_KEY_CSS_DECLARATIONS_BLOCK ) ; $ this -> clearCache ( self :: CACHE_KEY_COMBINED_STYLES ) ; }
Clears all caches .
16,764
private function clearCache ( $ key ) { $ allowedCacheKeys = [ self :: CACHE_KEY_CSS , self :: CACHE_KEY_SELECTOR , self :: CACHE_KEY_XPATH , self :: CACHE_KEY_CSS_DECLARATIONS_BLOCK , self :: CACHE_KEY_COMBINED_STYLES , ] ; if ( ! in_array ( $ key , $ allowedCacheKeys , true ) ) { throw new \ InvalidArgumentException ( 'Invalid cache key: ' . $ key , 1391822035 ) ; } $ this -> caches [ $ key ] = [ ] ; }
Clears a single cache by key .
16,765
private function normalizeStyleAttributes ( \ DOMElement $ node ) { $ normalizedOriginalStyle = preg_replace_callback ( '/[A-z\\-]+(?=\\:)/S' , function ( array $ m ) { return strtolower ( $ m [ 0 ] ) ; } , $ node -> getAttribute ( 'style' ) ) ; $ nodePath = $ node -> getNodePath ( ) ; if ( ! isset ( $ this -> styleAttributesForNodes [ $ nodePath ] ) ) { $ this -> styleAttributesForNodes [ $ nodePath ] = $ this -> parseCssDeclarationsBlock ( $ normalizedOriginalStyle ) ; $ this -> visitedNodes [ $ nodePath ] = $ node ; } $ node -> setAttribute ( 'style' , $ normalizedOriginalStyle ) ; }
Normalizes the value of the style attribute and saves it .
16,766
private function getBodyElement ( \ DOMDocument $ document ) { $ bodyElement = $ document -> getElementsByTagName ( 'body' ) -> item ( 0 ) ; if ( $ bodyElement === null ) { throw new \ BadMethodCallException ( 'getBodyElement method may only be called after ensureExistenceOfBodyElement has been called.' , 1508173775427 ) ; } return $ bodyElement ; }
Returns the BODY element .
16,767
private function createRawXmlDocument ( ) { $ xmlDocument = new \ DOMDocument ; $ xmlDocument -> encoding = 'UTF-8' ; $ xmlDocument -> strictErrorChecking = false ; $ xmlDocument -> formatOutput = true ; $ libXmlState = libxml_use_internal_errors ( true ) ; $ xmlDocument -> loadHTML ( $ this -> getUnifiedHtml ( ) ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ libXmlState ) ; $ xmlDocument -> normalizeDocument ( ) ; return $ xmlDocument ; }
Creates a DOMDocument instance with the current HTML .
16,768
private function getUnifiedHtml ( ) { $ htmlWithoutUnprocessableTags = $ this -> removeUnprocessableTags ( $ this -> html ) ; $ htmlWithDocumentType = $ this -> ensureDocumentType ( $ htmlWithoutUnprocessableTags ) ; return $ this -> addContentTypeMetaTag ( $ htmlWithDocumentType ) ; }
Returns the HTML with the unprocessable HTML tags removed and with added document type and Content - Type meta tag if needed .
16,769
public static function onlyOffline ( ) { $ instance = new static ; $ column = $ instance -> getQualifiedStatusColumn ( ) ; return $ instance -> withoutGlobalScope ( StatusScope :: class ) -> where ( $ column , false ) ; }
Get a new query builder that only includes offline items .
16,770
public function current ( ) { $ currentKey = $ this -> keys [ $ this -> position ] ; return isset ( $ this -> items [ $ currentKey ] ) ? $ this -> items [ $ currentKey ] : null ; }
Current iterator item .
16,771
public function valid ( ) { if ( ! isset ( $ this -> keys [ $ this -> position ] ) ) { return false ; } $ currentKey = $ this -> keys [ $ this -> position ] ; return isset ( $ this -> items [ $ currentKey ] ) ; }
Determines if there is some value at current iterator position .
16,772
public function getModel ( array $ data ) { if ( ! isset ( $ data [ 'uid' ] ) ) { throw new \ InvalidArgumentException ( '$data must contain an element "uid".' , 1331319491 ) ; } $ model = $ this -> find ( $ data [ 'uid' ] ) ; if ( $ model -> isGhost ( ) ) { $ this -> fillModel ( $ model , $ data ) ; } return $ model ; }
Returns a model for the provided array . If the UID provided with the array is already mapped this yet existing model will be returned irrespective of the other provided data otherwise the model will be loaded with the provided data .
16,773
public function getListOfModels ( array $ dataOfModels ) { $ list = new \ Tx_Oelib_List ( ) ; foreach ( $ dataOfModels as $ modelRecord ) { $ list -> add ( $ this -> getModel ( $ modelRecord ) ) ; } return $ list ; }
Returns a list of models for the provided two - dimensional array with model data .
16,774
public function existsModel ( $ uid , $ allowHidden = false ) { $ model = $ this -> find ( $ uid ) ; if ( $ model -> isGhost ( ) ) { $ this -> load ( $ model ) ; } return $ model -> isLoaded ( ) && ( ! $ model -> isHidden ( ) || $ allowHidden ) ; }
Checks whether a model with a certain UID actually exists in the database and could be loaded .
16,775
protected function createRelations ( array & $ data , \ Tx_Oelib_Model $ model ) { foreach ( array_keys ( $ this -> relations ) as $ key ) { if ( $ this -> isOneToManyRelationConfigured ( $ key ) ) { $ this -> createOneToManyRelation ( $ data , $ key , $ model ) ; } elseif ( $ this -> isManyToOneRelationConfigured ( $ key ) ) { $ this -> createManyToOneRelation ( $ data , $ key ) ; } else { if ( $ this -> isManyToManyRelationConfigured ( $ key ) ) { $ this -> createMToNRelation ( $ data , $ key , $ model ) ; } else { $ this -> createCommaSeparatedRelation ( $ data , $ key , $ model ) ; } } } }
Processes a model s data and creates any relations that are hidden within it using foreign key mapping .
16,776
private function getRelationConfigurationFromTca ( $ key ) { $ tca = \ Tx_Oelib_Db :: getTcaForTable ( $ this -> getTableName ( ) ) ; if ( ! isset ( $ tca [ 'columns' ] [ $ key ] ) ) { throw new \ BadMethodCallException ( 'In the table ' . $ this -> getTableName ( ) . ', the column ' . $ key . ' does not have a TCA entry.' , 1331319627 ) ; } return $ tca [ 'columns' ] [ $ key ] [ 'config' ] ; }
Retrieves the configuration of a relation from the TCA .
16,777
public function getNewGhost ( ) { $ model = $ this -> createGhost ( $ this -> map -> getNewUid ( ) ) ; $ this -> registerModelAsMemoryOnlyDummy ( $ model ) ; return $ model ; }
Creates a new registered ghost with a UID that has not been used in this data mapper yet .
16,778
public function save ( \ Tx_Oelib_Model $ model ) { if ( $ this -> isModelAMemoryOnlyDummy ( $ model ) ) { throw new \ InvalidArgumentException ( 'This model is a memory-only dummy that must not be saved.' , 1331319682 ) ; } if ( ! $ this -> hasDatabaseAccess ( ) || ! $ model -> isDirty ( ) || ! $ model -> isLoaded ( ) || $ model -> isReadOnly ( ) ) { return ; } $ data = $ this -> getPreparedModelData ( $ model ) ; $ this -> cacheModelByKeys ( $ model , $ data ) ; if ( $ model -> hasUid ( ) ) { \ Tx_Oelib_Db :: update ( $ this -> getTableName ( ) , 'uid = ' . $ model -> getUid ( ) , $ data ) ; $ this -> deleteManyToManyRelationIntermediateRecords ( $ model ) ; } else { $ this -> prepareDataForNewRecord ( $ data ) ; $ model -> setUid ( \ Tx_Oelib_Db :: insert ( $ this -> getTableName ( ) , $ data ) ) ; $ this -> map -> add ( $ model ) ; } if ( $ model -> isDeleted ( ) ) { $ model -> markAsDead ( ) ; } else { $ model -> markAsClean ( ) ; $ this -> saveOneToManyRelationRecords ( $ model ) ; $ this -> createManyToManyRelationIntermediateRecords ( $ model ) ; } }
Writes a model to the database . Does nothing if database access is denied if the model is clean if the model has status dead virgin or ghost if the model is read - only or if there is no data to set .
16,779
private function getPreparedModelData ( \ Tx_Oelib_Model $ model ) { if ( ! $ model -> hasUid ( ) ) { $ model -> setCreationDate ( ) ; } $ model -> setTimestamp ( ) ; $ data = $ model -> getData ( ) ; foreach ( $ this -> relations as $ key => $ relation ) { if ( $ this -> isOneToManyRelationConfigured ( $ key ) ) { $ functionName = 'count' ; } elseif ( $ this -> isManyToOneRelationConfigured ( $ key ) ) { $ functionName = 'getUid' ; if ( $ data [ $ key ] instanceof \ Tx_Oelib_Model ) { $ this -> saveManyToOneRelatedModels ( $ data [ $ key ] , \ Tx_Oelib_MapperRegistry :: get ( $ relation ) ) ; } } else { if ( $ this -> isManyToManyRelationConfigured ( $ key ) ) { $ functionName = 'count' ; } else { $ functionName = 'getUids' ; } if ( $ data [ $ key ] instanceof \ Tx_Oelib_List ) { $ this -> saveManyToManyAndCommaSeparatedRelatedModels ( $ data [ $ key ] , \ Tx_Oelib_MapperRegistry :: get ( $ relation ) ) ; } } $ data [ $ key ] = ( isset ( $ data [ $ key ] ) && is_object ( $ data [ $ key ] ) ) ? $ data [ $ key ] -> $ functionName ( ) : 0 ; } return $ data ; }
Prepares the model s data for the database . Changes the relations into a database - applicable format . Sets the timestamp and sets the crdate for new models .
16,780
protected function prepareDataForNewRecord ( array & $ data ) { if ( $ this -> testingFramework === null ) { return ; } $ tableName = $ this -> getTableName ( ) ; $ this -> testingFramework -> markTableAsDirty ( $ tableName ) ; $ data [ $ this -> testingFramework -> getDummyColumnName ( $ tableName ) ] = 1 ; }
Prepares the data for models that get newly inserted into the DB .
16,781
private function deleteOneToManyRelations ( \ Tx_Oelib_Model $ model ) { $ data = $ model -> getData ( ) ; foreach ( $ this -> relations as $ key => $ mapperName ) { if ( $ this -> isOneToManyRelationConfigured ( $ key ) ) { $ relatedModels = $ data [ $ key ] ; if ( ! is_object ( $ relatedModels ) ) { continue ; } $ mapper = \ Tx_Oelib_MapperRegistry :: get ( $ mapperName ) ; foreach ( $ relatedModels as $ relatedModel ) { $ mapper -> delete ( $ relatedModel ) ; } } } }
Deletes all one - to - many related models of this model .
16,782
protected function getUniversalWhereClause ( $ allowHiddenRecords = false ) { $ tableName = $ this -> getTableName ( ) ; if ( $ this -> testingFramework !== null ) { $ dummyColumnName = $ this -> testingFramework -> getDummyColumnName ( $ tableName ) ; $ leftPart = \ Tx_Oelib_Db :: tableHasColumn ( $ this -> getTableName ( ) , $ dummyColumnName ) ? $ dummyColumnName . ' = 1' : '1 = 1' ; } else { $ leftPart = '1 = 1' ; } return $ leftPart . \ Tx_Oelib_Db :: enableFields ( $ tableName , ( $ allowHiddenRecords ? 1 : - 1 ) ) ; }
Returns the WHERE clause that selects all visible records from the DB .
16,783
private function registerModelAsMemoryOnlyDummy ( \ Tx_Oelib_Model $ model ) { if ( ! $ model -> hasUid ( ) ) { return ; } $ this -> uidsOfMemoryOnlyDummyModels [ $ model -> getUid ( ) ] = true ; }
Registers a model as a memory - only dummy that must not be saved .
16,784
protected function findByWhereClause ( $ whereClause = '' , $ sorting = '' , $ limit = '' ) { $ orderBy = '' ; $ tca = \ Tx_Oelib_Db :: getTcaForTable ( $ this -> getTableName ( ) ) ; if ( $ sorting !== '' ) { $ orderBy = $ sorting ; } elseif ( isset ( $ tca [ 'ctrl' ] [ 'default_sortby' ] ) ) { $ matches = [ ] ; if ( preg_match ( '/^ORDER BY (.+)$/' , $ tca [ 'ctrl' ] [ 'default_sortby' ] , $ matches ) ) { $ orderBy = $ matches [ 1 ] ; } } $ completeWhereClause = ( $ whereClause === '' ) ? '' : $ whereClause . ' AND ' ; $ rows = \ Tx_Oelib_Db :: selectMultiple ( '*' , $ this -> getTableName ( ) , $ completeWhereClause . $ this -> getUniversalWhereClause ( ) , '' , $ orderBy , $ limit ) ; return $ this -> getListOfModels ( $ rows ) ; }
Retrieves all non - deleted non - hidden models from the DB which match the given where clause .
16,785
public function findByPageUid ( $ pageUids , $ sorting = '' , $ limit = '' ) { if ( ( $ pageUids === '' ) || ( $ pageUids === '0' ) || ( $ pageUids === 0 ) ) { return $ this -> findByWhereClause ( '' , $ sorting , $ limit ) ; } return $ this -> findByWhereClause ( $ this -> getTableName ( ) . '.pid IN (' . $ pageUids . ')' , $ sorting , $ limit ) ; }
Finds all records which are located on the given pages .
16,786
protected function findOneByKeyFromCache ( $ key , $ value ) { if ( $ key === '' ) { throw new \ InvalidArgumentException ( '$key must not be empty.' , 1416847364 ) ; } if ( ! isset ( $ this -> cacheByKey [ $ key ] ) ) { throw new \ InvalidArgumentException ( '"' . $ key . '" is not a valid key for this mapper.' , 1331319882 ) ; } if ( $ value === '' ) { throw new \ InvalidArgumentException ( '$value must not be empty.' , 1331319892 ) ; } if ( ! isset ( $ this -> cacheByKey [ $ key ] [ $ value ] ) ) { throw new \ Tx_Oelib_Exception_NotFound ( ) ; } return $ this -> cacheByKey [ $ key ] [ $ value ] ; }
Looks up a model in the cache by key .
16,787
public function findOneByCompoundKeyFromCache ( $ value ) { if ( $ value === '' ) { throw new \ InvalidArgumentException ( '$value must not be empty.' , 1331319992 ) ; } if ( ! isset ( $ this -> cacheByCompoundKey [ $ value ] ) ) { throw new \ Tx_Oelib_Exception_NotFound ( ) ; } return $ this -> cacheByCompoundKey [ $ value ] ; }
Looks up a model in the compound cache .
16,788
protected function cacheModelByCompoundKey ( \ Tx_Oelib_Model $ model , array $ data ) { if ( empty ( $ this -> compoundKeyParts ) ) { throw new \ BadMethodCallException ( 'The compound key parts are not defined.' , 1363806895 ) ; } $ values = [ ] ; foreach ( $ this -> compoundKeyParts as $ key ) { if ( isset ( $ data [ $ key ] ) ) { $ values [ ] = $ data [ $ key ] ; } } if ( count ( $ this -> compoundKeyParts ) === count ( $ values ) ) { $ value = implode ( '.' , $ values ) ; if ( $ value !== '' ) { $ this -> cacheByCompoundKey [ $ value ] = $ model ; } } }
Automatically caches a model by an additional compound key .
16,789
public function findOneByKey ( $ key , $ value ) { try { $ model = $ this -> findOneByKeyFromCache ( $ key , $ value ) ; } catch ( \ Tx_Oelib_Exception_NotFound $ exception ) { $ model = $ this -> findSingleByWhereClause ( [ $ key => $ value ] ) ; } return $ model ; }
Looks up a model by key .
16,790
public function findOneByCompoundKey ( array $ compoundKeyValues ) { if ( empty ( $ compoundKeyValues ) ) { throw new \ InvalidArgumentException ( get_class ( $ this ) . '::compoundKeyValues must not be empty.' , 1354976660 ) ; } try { $ model = $ this -> findOneByCompoundKeyFromCache ( $ this -> extractCompoundKeyValues ( $ compoundKeyValues ) ) ; } catch ( \ Tx_Oelib_Exception_NotFound $ exception ) { $ model = $ this -> findSingleByWhereClause ( $ compoundKeyValues ) ; } return $ model ; }
Looks up a model by a compound key .
16,791
protected function extractCompoundKeyValues ( array $ compoundKeyValues ) { $ values = [ ] ; foreach ( $ this -> compoundKeyParts as $ key ) { if ( ! isset ( $ compoundKeyValues [ $ key ] ) ) { throw new \ InvalidArgumentException ( get_class ( $ this ) . '::keyValue does not contain all compound keys.' , 1354976661 ) ; } $ values [ ] = $ compoundKeyValues [ $ key ] ; } return implode ( '.' , $ values ) ; }
Extracting the key value from model data .
16,792
public function countByWhereClause ( $ whereClause = '' ) { $ completeWhereClause = ( $ whereClause === '' ) ? '' : $ whereClause . ' AND ' ; return \ Tx_Oelib_Db :: count ( $ this -> getTableName ( ) , $ completeWhereClause . $ this -> getUniversalWhereClause ( ) ) ; }
Returns the number of records matching the given WHERE clause .
16,793
public function countByPageUid ( $ pageUids ) { if ( ( $ pageUids === '' ) || ( $ pageUids === '0' ) ) { return $ this -> countByWhereClause ( '' ) ; } return $ this -> countByWhereClause ( $ this -> getTableName ( ) . '.pid IN (' . $ pageUids . ')' ) ; }
Returns the number of records located on the given pages .
16,794
public static function getCreditCardLogoName ( $ visa_msc = false , $ amex = false , $ jcb = false ) { if ( $ visa_msc == false && $ amex == false && $ jcb == false ) { return null ; } $ logoName = '' ; if ( $ visa_msc ) { $ logoName .= 'visa_msc_' ; } if ( $ amex ) { $ logoName .= 'amex_' ; } if ( $ jcb ) { $ logoName .= 'jcb_' ; } $ logoName .= '40px.png' ; return $ logoName ; }
returns logname by given credit card types and size
16,795
public static function appendOrder ( QueryBuilder $ queryBuilder , DataTablesWrapperInterface $ dtWrapper ) { foreach ( $ dtWrapper -> getRequest ( ) -> getOrder ( ) as $ dtOrder ) { $ dtColumn = array_values ( $ dtWrapper -> getColumns ( ) ) [ $ dtOrder -> getColumn ( ) ] ; if ( false === $ dtColumn -> getOrderable ( ) ) { continue ; } $ queryBuilder -> addOrderBy ( $ dtColumn -> getMapping ( ) -> getAlias ( ) , $ dtOrder -> getDir ( ) ) ; } }
Append an ORDER clause .
16,796
public static function appendWhere ( QueryBuilder $ queryBuilder , DataTablesWrapperInterface $ dtWrapper ) { $ operator = static :: determineOperator ( $ dtWrapper ) ; if ( null === $ operator ) { return ; } $ wheres = [ ] ; $ params = [ ] ; $ values = [ ] ; foreach ( $ dtWrapper -> getRequest ( ) -> getColumns ( ) as $ dtColumn ) { if ( true === $ dtColumn -> getSearchable ( ) && ( "OR" === $ operator || "" !== $ dtColumn -> getSearch ( ) -> getValue ( ) ) ) { $ wheres [ ] = DataTablesMappingHelper :: getWhere ( $ dtColumn -> getMapping ( ) ) ; $ params [ ] = DataTablesMappingHelper :: getParam ( $ dtColumn -> getMapping ( ) ) ; $ values [ ] = "%" . ( "AND" === $ operator ? $ dtColumn -> getSearch ( ) -> getValue ( ) : $ dtWrapper -> getRequest ( ) -> getSearch ( ) -> getValue ( ) ) . "%" ; } } $ queryBuilder -> andWhere ( "(" . implode ( " " . $ operator . " " , $ wheres ) . ")" ) ; for ( $ i = count ( $ params ) - 1 ; 0 <= $ i ; -- $ i ) { $ queryBuilder -> setParameter ( $ params [ $ i ] , $ values [ $ i ] ) ; } }
Append a WHERE clause .
16,797
public static function determineOperator ( DataTablesWrapperInterface $ dtWrapper ) { foreach ( $ dtWrapper -> getRequest ( ) -> getColumns ( ) as $ dtColumn ) { if ( false === $ dtColumn -> getSearchable ( ) ) { continue ; } if ( "" !== $ dtColumn -> getSearch ( ) -> getValue ( ) ) { return "AND" ; } } if ( "" !== $ dtWrapper -> getRequest ( ) -> getSearch ( ) -> getValue ( ) ) { return "OR" ; } return null ; }
Determines an operator .
16,798
final public function init ( $ sName , $ xDialog ) { $ this -> sName = $ sName ; $ this -> xDialog = $ xDialog ; $ this -> setResponse ( $ xDialog -> response ( ) ) ; $ this -> sUri = $ this -> xDialog -> getOption ( 'dialogs.lib.uri' , $ this -> sUri ) ; $ this -> sUri = rtrim ( $ this -> getOption ( 'uri' , $ this -> sUri ) , '/' ) ; $ this -> sSubDir = trim ( $ this -> getOption ( 'subdir' , $ this -> sSubDir ) , '/' ) ; $ this -> sVersion = trim ( $ this -> getOption ( 'version' , $ this -> sVersion ) , '/' ) ; }
Initialize the library class instance
16,799
final public function hasOption ( $ sName ) { $ sName = 'dialogs.' . $ this -> getName ( ) . '.' . $ sName ; return $ this -> xDialog -> hasOption ( $ sName ) ; }
Check the presence of a config option