idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
15,900
public function getData ( ) { if ( $ this -> data instanceof Arrayable ) { $ this -> data = $ this -> data -> toArray ( ) ; } if ( ! is_array ( $ this -> data ) ) { $ this -> data = null ; } return $ this -> data ; }
Get exception data
15,901
public static function format ( array $ record ) { $ seconds = ( int ) $ record [ 'time' ] ; $ millis = floor ( ( $ record [ 'time' ] - $ seconds ) * 1000 ) ; $ timestamp = date ( 'Y-m-d H:i:s' , $ seconds ) ; $ timestamp .= sprintf ( '.%03d ' , $ millis ) ; $ timestamp .= date ( 'P' ) ; $ level = '[' . $ record [ 'level' ] . ']' ; $ message = '' ; $ message .= Logger :: interpolate ( $ record [ 'message' ] , $ record [ 'context' ] ) ; if ( isset ( $ record [ 'context' ] [ 'file' ] ) ) { $ message .= ' in ' . $ record [ 'context' ] [ 'file' ] ; } if ( isset ( $ record [ 'context' ] [ 'line' ] ) ) { $ message .= ' on line ' . $ record [ 'context' ] [ 'line' ] ; } return $ timestamp . ' ' . $ level . ' ' . $ message . PHP_EOL ; }
Format a log message for a log file .
15,902
public static function select ( ) { $ result = null ; switch ( static :: getDriver ( ) ) { case self :: DRIVER_MYSQL : $ result = new \ pwf \ components \ querybuilder \ adapters \ MySQL \ SelectBuilder ( ) ; break ; case self :: DRIVER_PG : $ result = new \ pwf \ components \ querybuilder \ adapters \ PostgreSQL \ SelectBuilder ( ) ; break ; default : throw new \ Exception ( 'Wrong query builder driver' ) ; } return $ result ; }
Get query builder
15,903
public static function insert ( ) { $ result = null ; switch ( static :: getDriver ( ) ) { case self :: DRIVER_MYSQL : $ result = new \ pwf \ components \ querybuilder \ adapters \ MySQL \ InsertBuilder ( ) ; break ; case self :: DRIVER_PG : $ result = new \ pwf \ components \ querybuilder \ adapters \ PostgreSQL \ InsertBuilder ( ) ; break ; default : throw new \ Exception ( 'Wrong query builder driver' ) ; } return $ result ; }
Get insert builder
15,904
public static function update ( ) { $ result = null ; switch ( static :: getDriver ( ) ) { case self :: DRIVER_MYSQL : $ result = new \ pwf \ components \ querybuilder \ adapters \ MySQL \ UpdateBuilder ( ) ; break ; case self :: DRIVER_PG : $ result = new \ pwf \ components \ querybuilder \ adapters \ PostgreSQL \ UpdateBuilder ( ) ; break ; default : throw new \ Exception ( 'Wrong query builder driver' ) ; } return $ result ; }
Get update builder
15,905
public static function delete ( ) { $ result = null ; switch ( static :: getDriver ( ) ) { case self :: DRIVER_MYSQL : $ result = new \ pwf \ components \ querybuilder \ adapters \ MySQL \ DeleteBuilder ( ) ; break ; case self :: DRIVER_PG : $ result = new \ pwf \ components \ querybuilder \ adapters \ PostgreSQL \ DeleteBuilder ( ) ; break ; default : throw new \ Exception ( 'Wrong query builder driver' ) ; } return $ result ; }
Get delete builder
15,906
public static function getConditionBuilder ( ) { $ result = null ; switch ( static :: getDriver ( ) ) { default : $ result = new \ pwf \ components \ querybuilder \ adapters \ SQL \ ConditionBuilder ( ) ; } return $ result ; }
Get condition builder
15,907
public function primaryKey ( $ tableName ) { if ( ! isset ( $ this -> primaryKeys [ $ tableName ] ) ) { $ sql = "SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name WHERE tc.CONSTRAINT_TYPE = 'Primary Key' AND tc.TABLE_NAME = " . $ this -> quote ( $ tableName ) ; $ keyResult = $ this -> query ( $ sql ) ; $ key = $ keyResult -> fetchRow ( ) ; $ this -> primaryKeys [ $ tableName ] = $ key [ 'COLUMN_NAME' ] ; } return $ this -> primaryKeys [ $ tableName ] ; }
primaryKey function .
15,908
public function isEmpty ( $ key = null ) { if ( $ key === null ) { return empty ( $ this -> data ) ; } return empty ( $ this -> data [ $ key ] ) ; }
is empty will return if the specified key is empty if no key provided it will check itself .
15,909
public function merge ( $ arr = [ ] ) { $ newData = array_merge ( $ this -> toArray ( ) , $ arr ) ; return $ this -> reset ( $ newData ) ; }
array then rebuilds the data array . Returns itself
15,910
public function resetAllInvoiceOptions ( ) : Client { $ this -> sendInvoiceByPost = null ; $ this -> invoiceMaturityDays = null ; $ this -> stopServiceDue = null ; $ this -> stopServiceDueDays = null ; return $ this ; }
Resets all Invoice Options for this Client .
15,911
public static function createResidential ( string $ firstName , string $ lastName ) : Client { $ organization = Organization :: getByDefault ( ) ; $ client = new Client ( [ "clientType" => Client :: CLIENT_TYPE_RESIDENTIAL , "isLead" => false , "invoiceAddressSameAsContact" => true , "organizationId" => $ organization -> getId ( ) , "registrationDate" => ( new \ DateTime ( ) ) -> format ( "c" ) , "firstName" => $ firstName , "lastName" => $ lastName ] ) ; return $ client ; }
Creates the minimal Residential Client to be used as a starting point for a new Client .
15,912
public static function createCommercial ( string $ companyName ) : Client { $ organization = Organization :: getByDefault ( ) ; $ client = new Client ( [ "clientType" => Client :: CLIENT_TYPE_COMMERCIAL , "isLead" => false , "invoiceAddressSameAsContact" => true , "organizationId" => $ organization -> getId ( ) , "registrationDate" => ( new \ DateTime ( ) ) -> format ( "c" ) , "companyName" => $ companyName ] ) ; return $ client ; }
Creates the minimal Commericial Client to be used as a starting point for a new Client .
15,913
public static function getByUserIdent ( string $ userIdent ) : ? Client { $ client = Client :: get ( "" , [ ] , [ "userIdent" => $ userIdent ] ) -> first ( ) ; return $ client ; }
Sends an HTTP GET Request using the calling class s annotated information for an object given the Custom ID .
15,914
public static function getByCustomAttribute ( string $ key , string $ value ) : ClientCollection { $ key = lcfirst ( $ key ) ; $ clients = Client :: get ( "" , [ ] , [ "customAttributeKey" => $ key , "customAttributeValue" => $ value ] ) ; return new ClientCollection ( $ clients -> elements ( ) ) ; }
Sends an HTTP GET Request using the calling class s annotated information for objects given an Attribute pair .
15,915
public function joinSlugs ( array $ urlParts ) { $ urlParts = array_map ( function ( $ urlPart ) { return trim ( $ urlPart , '/' ) ; } , $ urlParts ) ; return implode ( '/' , $ urlParts ) ; }
Join URL parts without double slashes
15,916
public function getAssociation ( $ name , $ autoLoad = true ) { if ( isset ( $ this -> loadedAssociations [ $ name ] ) ) { return $ this -> loadedAssociations [ $ name ] ; } elseif ( $ autoLoad && $ this -> getAssociations ( ) -> exists ( $ name ) ) { $ this -> loadedAssociations [ $ name ] = $ this -> getAssociations ( ) -> load ( $ this , $ name ) ; return $ this -> loadedAssociations [ $ name ] ; } return null ; }
If the association isn t yet loaded it is loaded and returned . If the association doesn t exist null is returned . Note that unset one - to - one associations return false .
15,917
public function setAssociation ( $ name , $ value , $ raw = false ) { if ( $ raw ) { $ this -> loadedAssociations [ $ name ] = $ value ; } else { return ( new Setter ( ) ) -> set ( $ this , $ name , $ value ) ; } }
Associates an object to a one - to - one association . Other associations are done in CollectionProxy .
15,918
public function make ( $ key ) { if ( ! isset ( $ this -> keys [ $ key ] ) ) { throw new \ InvalidArgumentException ( 'Identifier "' . $ key . '" is not defined.' ) ; } if ( ! is_object ( $ this -> raw [ $ key ] ) || ! method_exists ( $ this -> raw [ $ key ] , '__invoke' ) ) { return $ this -> raw [ $ key ] ; } if ( $ this -> types [ $ key ] === self :: TYPE_SINGLETON ) { if ( isset ( $ this -> resolved [ $ key ] ) ) { return $ this -> resolved [ $ key ] ; } $ this -> locked [ $ key ] = true ; return $ this -> resolved [ $ key ] = $ this -> raw [ $ key ] ( $ this ) ; } return $ this -> raw [ $ key ] ( $ this ) ; }
Get something from the container
15,919
public function addVisitAction ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitAction $ visitAction ) { $ this -> visitAction [ ] = $ visitAction ; return $ this ; }
Add visitAction .
15,920
public function removeVisitAction ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitAction $ visitAction ) { return $ this -> visitAction -> removeElement ( $ visitAction ) ; }
Remove visitAction .
15,921
public function setVisitor ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitor $ visitor = null ) { $ this -> visitor = $ visitor ; return $ this ; }
Set visitor .
15,922
public function setSearchEngine ( \ BlackForest \ PiwikBundle \ Entity \ PiwikSearchEngine $ searchEngine = null ) { $ this -> searchEngine = $ searchEngine ; return $ this ; }
Set searchEngine .
15,923
public function setDevice ( \ BlackForest \ PiwikBundle \ Entity \ PiwikDevice $ device = null ) { $ this -> device = $ device ; return $ this ; }
Set device .
15,924
public function setOperatingSystem ( \ BlackForest \ PiwikBundle \ Entity \ PiwikOperatingSystem $ operatingSystem = null ) { $ this -> operatingSystem = $ operatingSystem ; return $ this ; }
Set operatingSystem .
15,925
public function setBrowser ( \ BlackForest \ PiwikBundle \ Entity \ PiwikBrowser $ browser = null ) { $ this -> browser = $ browser ; return $ this ; }
Set browser .
15,926
public function setLocation ( \ BlackForest \ PiwikBundle \ Entity \ PiwikLocation $ location = null ) { $ this -> location = $ location ; return $ this ; }
Set location .
15,927
public function setResolution ( \ BlackForest \ PiwikBundle \ Entity \ PiwikResolution $ resolution = null ) { $ this -> resolution = $ resolution ; return $ this ; }
Set resolution .
15,928
public function setPlugin ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitPlugin $ plugin = null ) { $ this -> plugin = $ plugin ; return $ this ; }
Set plugin .
15,929
public function setOptions ( AbstractOptions $ options ) { $ optionsClass = Conversion :: getOptionsFullQualifiedClassName ( $ this ) ; $ inputOptionsClass = get_class ( $ options ) ; if ( $ inputOptionsClass !== $ optionsClass ) { throw new Exception \ DomainException ( sprintf ( '"%s" expects that options set are an array or a valid "%s" instance; received "%s"' , __METHOD__ , $ optionsClass , $ inputOptionsClass ) ) ; } $ this -> options = $ options ; return $ this ; }
Set the adapter options instance
15,930
public function getOptions ( ) { if ( ! $ this -> options ) { throw new Exception \ RuntimeException ( sprintf ( 'No options instance set for the adapter "%s"' , get_class ( $ this ) ) ) ; } return $ this -> options ; }
Retrieve the adapter options instance
15,931
public function setMiddleParagraphLayoutId ( $ layoutParagraphId = null ) { $ middleLayout = $ this -> middleLayoutModel -> findMiddleParagraphLayoutById ( $ layoutParagraphId ) ; if ( ! empty ( $ middleLayout ) ) { $ controller = $ this -> getController ( ) ; if ( ! method_exists ( $ controller , 'plugin' ) ) { throw new Exception \ LogicException ( 'Controller used with paragraphLayout plugin must be pluggable' ) ; } $ controller -> plugin ( 'layout' ) -> setMiddleLayout ( $ middleLayout ) ; } return $ this ; }
Set middle - layout for paragraph - layout
15,932
protected function _setTransition ( $ transition ) { if ( $ transition !== null && ! is_string ( $ transition ) && ! ( $ transition instanceof Stringable ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Argument is not a valid transition' ) , null , null , $ transition ) ; } $ this -> transition = $ transition ; }
Sets the transition for this instance .
15,933
public static function getDBO ( ) { if ( ! empty ( self :: $ db ) ) { return self :: $ db ; } BLog :: addToLog ( '[BFactory] Connecting to the database "' . MYSQL_DB_HOST . '"...' ) ; self :: $ db = BMySQL :: getInstanceAndConnect ( ) ; if ( empty ( self :: $ db ) ) { BLog :: addToLog ( '[BFactory] Could not connect to the MySQL database!' , LL_ERROR ) ; return NULL ; } return self :: $ db ; }
Get BMySQL instance
15,934
public static function getTempFn ( ) { $ tempFileName = BROOTPATH . 'temp' . DIRECTORY_SEPARATOR ; $ characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ charactersLength = strlen ( $ characters ) ; for ( $ i = 0 ; $ i < 15 ; $ i ++ ) { $ tempFileName .= $ characters [ rand ( 0 , $ charactersLength - 1 ) ] ; } $ tempFileName .= '.tmp' ; return $ tempFileName ; }
Get temporary filename
15,935
public static function getInstance ( ) { if ( is_null ( self :: $ _oInstance ) ) { $ c = __CLASS__ ; self :: $ _oInstance = new $ c ; } return self :: $ _oInstance ; }
get a valid instance of this class
15,936
protected function addViolation ( $ value , Constraint $ constraint ) { $ this -> context -> addViolation ( $ constraint -> message , [ '{{ id_field }}' => $ constraint -> getIdField ( ) , '{{ value }}' => $ value ] , $ value ) ; }
Add violation with error message
15,937
public function addSources ( array $ sources ) { foreach ( $ sources as $ s ) { if ( ! file_exists ( $ s ) ) { throw new \ Exception ( sprintf ( 'Unable to compress %s because the destination doesn\'t exist.' , $ s ) ) ; } $ this -> sources [ ] = $ s ; } }
Add one or more file or folders to the archive .
15,938
protected function getLayoutId ( ) { $ paragraph = $ this -> findParagraph ( ) ; if ( empty ( $ paragraph ) ) { $ structure = $ this -> getServiceLocator ( ) -> get ( 'Grid\Core\Model\SubDomain\Model' ) -> findActual ( ) ; return $ structure -> defaultLayoutId ; } else { return $ paragraph -> layoutId ; } }
Get actual layout ID
15,939
public function localAction ( ) { $ success = null ; $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'Form' ) -> create ( 'Grid\Paragraph\ChangeLayout\Local' , array ( 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ; $ form -> setAttribute ( 'action' , $ this -> url ( ) -> fromRoute ( 'Grid\Paragraph\ChangeLayout\Local' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'paragraphId' => $ this -> paragraphId , 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ) ; if ( empty ( $ this -> paragraphId ) ) { $ form -> get ( 'layoutId' ) -> setEmptyOption ( null ) ; } $ paragraph = $ this -> findParagraph ( ) ; if ( ! empty ( $ paragraph ) ) { $ form -> setHydrator ( $ paragraph -> getMapper ( ) ) -> bind ( $ paragraph ) ; } if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ success = $ this -> saveLayout ( $ data [ 'layoutId' ] ) ; } else { $ success = false ; } } if ( true === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.changeLayout.success' , 'paragraph' , Message :: LEVEL_INFO ) ; } if ( false === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.changeLayout.failed' , 'paragraph' , Message :: LEVEL_ERROR ) ; } if ( null !== $ success ) { return $ this -> redirect ( ) -> toUrl ( $ form -> get ( 'returnUri' ) -> getValue ( ) ) ; } $ view = new ViewModel ( array ( 'form' => $ form , ) ) ; return $ view -> setTerminal ( true ) ; }
Change to local layout
15,940
public function importAction ( ) { $ success = null ; $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'Form' ) -> create ( 'Grid\Paragraph\ChangeLayout\Import' , array ( 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ; $ form -> setAttribute ( 'action' , $ this -> url ( ) -> fromRoute ( 'Grid\Paragraph\ChangeLayout\Import' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'paragraphId' => $ this -> paragraphId , 'returnUri' => $ request -> getQuery ( 'returnUri' ) , ) ) ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ beforeId = $ this -> getLayoutId ( ) ; $ clonedId = $ this -> getParagraphModel ( ) -> cloneFrom ( $ data [ 'importId' ] , '_central' ) ; $ success = $ this -> saveLayout ( $ clonedId ) ; $ this -> getServiceLocator ( ) -> get ( 'Grid\Menu\Model\Menu\Model' ) -> interleaveParagraphs ( $ clonedId , $ beforeId ) ; } else { $ success = false ; } } if ( true === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.importLayout.success' , 'paragraph' , Message :: LEVEL_INFO ) ; } if ( false === $ success ) { $ this -> messenger ( ) -> add ( 'paragraph.action.importLayout.failed' , 'paragraph' , Message :: LEVEL_ERROR ) ; } if ( null !== $ success ) { return $ this -> redirect ( ) -> toUrl ( $ form -> get ( 'returnUri' ) -> getValue ( ) ) ; } $ view = new ViewModel ( array ( 'form' => $ form , ) ) ; return $ view -> setTerminal ( true ) ; }
Import layout & change to it
15,941
public function actorlistJsonAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ actor = $ em -> getRepository ( 'CoreBundle:Actor' ) -> find ( $ id ) ; if ( ! $ actor ) { throw $ this -> createNotFoundException ( 'Unable to find Actor entity.' ) ; } $ jsonList = $ this -> get ( 'json_list' ) ; $ jsonList -> setRepository ( $ em -> getRepository ( 'EcommerceBundle:Contract' ) ) ; $ jsonList -> setActor ( $ actor ) ; $ response = $ jsonList -> get ( ) ; return new JsonResponse ( $ response ) ; }
Returns a list of Brand entities in JSON format .
15,942
public function createAction ( Request $ request ) { $ entity = new Contract ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; $ planForm = $ this -> createForm ( new PlanType ( ) , new Plan ( ) , array ( 'action' => $ this -> generateUrl ( 'ecommerce_plan_new' ) , 'method' => 'POST' , ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getNormData ( ) ; print_r ( $ data ) ; die ( ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ agreement = $ entity -> getAgreement ( ) ; $ agreement -> setContract ( $ entity ) ; $ agreement -> setStatus ( 'Created' ) ; try { $ em -> persist ( $ entity ) ; $ em -> persist ( $ entity -> getAgreement ( ) ) ; $ em -> flush ( ) ; } catch ( \ Exception $ exc ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'danger' , 'contract.duplicated' ) ; } $ checkoutManager = $ this -> get ( 'checkout_manager' ) ; $ creditCard = $ form -> getNormData ( ) -> getAgreement ( ) -> getCreditCard ( ) ; $ cc = array ( "number" => $ creditCard [ 'cardNo' ] , "type" => $ creditCard [ 'cardType' ] , "expire_month" => $ creditCard [ 'expirationDate' ] -> format ( 'm' ) , "expire_year" => $ creditCard [ 'expirationDate' ] -> format ( 'Y' ) , "cvv2" => $ creditCard [ 'CVV' ] , "first_name" => $ creditCard [ 'firstname' ] , "last_name" => $ creditCard [ 'lastname' ] ) ; $ payPalAgreement = $ checkoutManager -> createPaypalAgreement ( $ entity -> getAgreement ( ) , $ cc ) ; if ( $ entity -> getAgreement ( ) -> getPaymentMethod ( ) == 'paypal' ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'contract.created.approval' ) ; $ transactions = $ entity -> getAgreement ( ) -> getTransactions ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_transaction_show' , array ( 'id' => $ transactions -> last ( ) -> getId ( ) ) ) ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'contract.created' ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_contract_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'planForm' => $ planForm -> createView ( ) , ) ; }
Creates a new Contract entity .
15,943
private function createCreateForm ( Contract $ entity ) { $ form = $ this -> createForm ( new ContractType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'ecommerce_contract_create' ) , 'method' => 'POST' , ) ) ; return $ form ; }
Creates a form to create a Contract entity .
15,944
public function newAction ( ) { $ entity = new Contract ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; $ planForm = $ this -> createForm ( new PlanType ( ) , new Plan ( ) , array ( 'action' => $ this -> generateUrl ( 'ecommerce_plan_new' ) , 'method' => 'POST' , ) ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'planForm' => $ planForm -> createView ( ) , ) ; }
Displays a form to create a new Contract entity .
15,945
public function showAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'EcommerceBundle:Contract' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Contract entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ id ) ; $ agreement = $ entity -> getAgreement ( ) ; $ paypalAgreement = $ this -> get ( 'checkout_manager' ) -> getPaypalAgreement ( $ agreement -> getPaypalId ( ) ) ; $ transactions = $ this -> get ( 'checkout_manager' ) -> searchPaypalAgreementTransactions ( $ agreement ) ; return array ( 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , 'transactions' => $ transactions , 'paypalAgreement' => $ paypalAgreement ) ; }
Finds and displays a Contract entity .
15,946
private function createEditForm ( Contract $ entity ) { $ form = $ this -> createForm ( new ContractType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'ecommerce_contract_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; return $ form ; }
Creates a form to edit a Contract entity .
15,947
public function offsetGet ( $ offset ) { if ( ! array_key_exists ( $ offset , $ this -> _data ) ) { return false ; } return $ this -> _data [ $ offset ] ; }
Returns the value at specified offset or false if not exists .
15,948
public function set ( $ collection , $ value = null ) { if ( func_num_args ( ) === 1 ) { return parent :: merge ( $ collection , true ) ; } $ this -> _data [ $ collection ] = $ value ; return $ this ; }
Sets an array of variables .
15,949
public static function normalize ( $ env ) { $ env += [ 'PHP_SAPI' => PHP_SAPI ] ; if ( isset ( $ env [ 'SCRIPT_URI' ] ) ) { $ env [ 'HTTPS' ] = strpos ( $ env [ 'SCRIPT_URI' ] , 'https://' ) === 0 ; } elseif ( isset ( $ env [ 'HTTPS' ] ) ) { $ env [ 'HTTPS' ] = ( ! empty ( $ env [ 'HTTPS' ] ) && $ env [ 'HTTPS' ] !== 'off' ) ; } if ( isset ( $ env [ 'HTTP_X_HTTP_METHOD_OVERRIDE' ] ) ) { $ env [ 'REQUEST_METHOD' ] = $ env [ 'HTTP_X_HTTP_METHOD_OVERRIDE' ] ; } if ( isset ( $ env [ 'REDIRECT_HTTP_AUTHORIZATION' ] ) ) { $ env [ 'HTTP_AUTHORIZATION' ] = $ env [ 'REDIRECT_HTTP_AUTHORIZATION' ] ; } foreach ( [ 'HTTP_X_FORWARDED_FOR' , 'HTTP_PC_REMOTE_ADDR' , 'HTTP_X_REAL_IP' ] as $ key ) { if ( isset ( $ env [ $ key ] ) ) { $ addrs = explode ( ', ' , $ env [ $ key ] ) ; $ env [ 'REMOTE_ADDR' ] = reset ( $ addrs ) ; break ; } } if ( empty ( $ env [ 'SERVER_ADDR' ] ) && ! empty ( $ env [ 'LOCAL_ADDR' ] ) ) { $ env [ 'SERVER_ADDR' ] = $ env [ 'LOCAL_ADDR' ] ; } if ( $ env [ 'PHP_SAPI' ] === 'isapi' && isset ( $ env [ 'PATH_TRANSLATED' ] ) && isset ( $ env [ 'SCRIPT_NAME' ] ) ) { $ env [ 'SCRIPT_FILENAME' ] = str_replace ( '\\\\' , '\\' , $ env [ 'PATH_TRANSLATED' ] ) ; $ env [ 'DOCUMENT_ROOT' ] = substr ( $ env [ 'SCRIPT_FILENAME' ] , 0 , - strlen ( $ env [ 'SCRIPT_NAME' ] ) ) ; } return $ env ; }
Normalizes a couple of well known PHP environment variables .
15,950
final public function to_a ( ) { foreach ( $ this -> attributes as & $ value ) { if ( $ value instanceof \ DateTime ) $ value = $ value -> format ( self :: $ DATETIME_FORMAT ) ; } return $ this -> attributes ; }
Returns the attributes array .
15,951
public function tabBuilder ( \ samsoncms \ app \ material \ form \ Form & $ form ) { if ( count ( $ form -> navigationIDs ) ) { $ galleryFields = $ this -> query -> entity ( \ samsoncms \ api \ Field :: class ) -> where ( 'Type' , 9 ) -> join ( 'structurefield' ) -> where ( 'structurefield_StructureID' , $ form -> navigationIDs ) -> exec ( ) ; foreach ( $ galleryFields as $ field ) { $ form -> tabs [ ] = new Gallery ( $ this , $ this -> query , $ form -> entity , $ field ) ; } } }
Render all gallery additional fields as material form tabs
15,952
public function __async_getCount ( $ materialFieldId ) { $ response = array ( 'status' => 1 ) ; $ response [ 'count' ] = $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( MaterialField :: F_PRIMARY , $ materialFieldId ) -> count ( ) ; return $ response ; }
Controller for getting quantity image in gallery .
15,953
public function __async_updateAlt ( $ imageId ) { $ result = array ( 'status' => false ) ; $ image = null ; $ data = json_decode ( file_get_contents ( 'php://input' ) , true ) ; $ value = trim ( $ data [ 'value' ] ) ; if ( $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( 'PhotoID' , $ imageId ) -> first ( $ image ) ) { $ image -> Description = $ value ; $ image -> save ( ) ; $ result [ 'status' ] = true ; $ result [ 'description' ] = utf8_limit_string ( $ value , 25 , '...' ) ; $ result [ 'value' ] = $ value ; } return $ result ; }
Controller for update material image properties alt from gallery .
15,954
private function verifyExtensionFile ( ) { $ supported_image = array ( 'gif' , 'jpg' , 'jpeg' , 'png' ) ; $ fileName = $ _SERVER [ 'HTTP_X_FILE_NAME' ] ; $ ext = strtolower ( pathinfo ( $ fileName , PATHINFO_EXTENSION ) ) ; if ( in_array ( $ ext , $ supported_image ) ) { return true ; } return false ; }
method for verify extension file
15,955
public function __async_priority ( ) { $ result = array ( 'status' => true ) ; if ( isset ( $ _POST [ 'ids' ] ) ) { for ( $ i = 0 ; $ i < count ( $ _POST [ 'ids' ] ) ; $ i ++ ) { $ photo = null ; if ( $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( 'PhotoID' , $ _POST [ 'ids' ] [ $ i ] ) -> first ( $ photo ) ) { $ photo -> priority = $ i ; $ photo -> save ( ) ; } else { $ result [ 'status' ] = false ; $ result [ 'message' ] = 'Can not find images with specified ids!' ; } } } else { $ result [ 'status' ] = false ; $ result [ 'message' ] = 'There are no images to sort!' ; } return $ result ; }
Function to save image priority
15,956
public function __async_show_edit ( $ imageId ) { $ result = array ( 'status' => false ) ; $ image = null ; if ( $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( 'PhotoID' , $ imageId ) -> first ( $ image ) ) { $ path = $ this -> formImagePath ( $ image -> Path , $ image -> Src ) ; if ( $ this -> imageExists ( $ path ) ) { $ result [ 'status' ] = true ; $ result [ 'html' ] = $ this -> view ( 'editor/index' ) -> set ( $ image , 'image' ) -> set ( $ path , 'path' ) -> output ( ) ; } } return $ result ; }
Asynchronous function to get image editor
15,957
public function __async_edit ( $ imageId ) { $ result = array ( 'status' => false ) ; $ image = null ; $ imageResource = null ; $ croppedImage = null ; if ( $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( 'PhotoID' , $ imageId ) -> first ( $ image ) ) { $ path = $ this -> formImagePath ( $ image -> Path , $ image -> Src ) ; switch ( pathinfo ( $ path , PATHINFO_EXTENSION ) ) { case 'jpeg' : case 'jpg' : $ imageResource = imagecreatefromjpeg ( $ path ) ; $ croppedImage = $ this -> cropImage ( $ imageResource ) ; $ result [ 'status' ] = imagejpeg ( $ croppedImage , $ path ) ; break ; case 'png' : $ imageResource = imagecreatefrompng ( $ path ) ; $ croppedImage = $ this -> cropTransparentImage ( $ imageResource ) ; $ result [ 'status' ] = imagepng ( $ croppedImage , $ path ) ; break ; case 'gif' : $ imageResource = imagecreatefromgif ( $ path ) ; $ croppedImage = $ this -> cropTransparentImage ( $ imageResource ) ; $ result [ 'status' ] = imagegif ( $ croppedImage , $ path ) ; break ; } imagedestroy ( $ croppedImage ) ; imagedestroy ( $ imageResource ) ; } return $ result ; }
Applies all changes with the image and save it
15,958
public function getHTML ( $ materialFieldId ) { $ items_html = '' ; $ images = null ; if ( $ this -> query -> entity ( CMS :: MATERIAL_IMAGES_RELATION_ENTITY ) -> where ( 'materialFieldId' , $ materialFieldId ) -> orderBy ( 'priority' ) -> exec ( $ images ) ) { foreach ( $ images as $ image ) { $ size = ', ' ; $ path = $ this -> formImagePath ( $ image -> Path , $ image -> Src ) ; if ( ! $ this -> imageExists ( $ path ) ) { $ path = ResourceMap :: find ( 'www/img/no-img.png' , $ this ) ; } $ size = ( $ image -> size == 0 ) ? '' : $ size . $ this -> humanFileSize ( $ image -> size ) ; $ items_html .= $ this -> view ( 'tumbs/item' ) -> set ( $ image , 'image' ) -> set ( utf8_limit_string ( $ image -> Description , 25 , '...' ) , 'description' ) -> set ( utf8_limit_string ( $ image -> Name , 18 , '...' ) , 'name' ) -> set ( $ path , 'imgpath' ) -> set ( $ size , 'size' ) -> set ( $ materialFieldId , 'material_id' ) -> output ( ) ; } } return $ this -> view ( 'tumbs/index' ) -> set ( $ items_html , 'images' ) -> set ( $ materialFieldId , 'material_id' ) -> output ( ) ; }
Render gallery images list
15,959
public function humanFileSize ( $ bytes , $ decimals = 2 ) { $ sizeLetters = 'BKBMBGBTBPB' ; $ factor = ( int ) ( floor ( ( strlen ( $ bytes ) - 1 ) / 3 ) ) ; $ sizeLetter = ( $ factor <= 0 ) ? substr ( $ sizeLetters , 0 , 1 ) : substr ( $ sizeLetters , $ factor * 2 - 1 , 2 ) ; return sprintf ( "%.{$decimals}f" , $ bytes / pow ( 1024 , $ factor ) ) . $ sizeLetter ; }
Function to form image size
15,960
private function imageExists ( $ imagePath , $ imageSrc = null ) { if ( isset ( $ imageSrc ) ) { $ imageFullPath = $ this -> formImagePath ( $ imagePath , $ imageSrc ) ; } else { $ imageFullPath = $ imagePath ; } return $ this -> fs -> exists ( $ imageFullPath ) ; }
Checks if image exists supports old database structure
15,961
private function formImagePath ( $ imagePath , $ imageSrc ) { if ( empty ( $ imagePath ) ) { $ path = $ imageSrc ; } else { $ path = $ imagePath . $ imageSrc ; } $ dir = quotemeta ( __SAMSON_BASE__ ) ; if ( strpos ( $ path , 'http://' ) === false ) { if ( $ dir == '/' ) { return substr ( $ path , 1 ) ; } else { return preg_replace ( '/' . addcslashes ( $ dir , '/' ) . '/' , '' , $ path ) ; } } return $ path ; }
Function to form image path correctly also supports old database structure
15,962
public function get ( $ name , $ default = null ) { if ( isset ( $ this -> dataContainer [ $ name ] ) ) { return $ this -> dataContainer [ $ name ] ; } return $ default ; }
Get value by key . If value does not exists then return default value
15,963
public function handle ( ServerRequestInterface $ request ) : ResponseInterface { $ path = realpath ( __DIR__ . '/../../templates' ) ; $ engine = new Engine ( $ path ) ; $ contents = $ engine -> render ( 'simple' ) ; $ response = $ this -> factory -> createResponse ( 500 ) -> withHeader ( 'Content-type' , 'text/html' ) ; $ response -> getBody ( ) -> write ( $ contents ) ; return $ response ; }
Return a simple html response for the exception .
15,964
public static function version ( $ version = null , $ name = 'default' , $ type = 'app' , $ all = false ) { $ all or $ current = \ Config :: get ( 'migrations.version.' . $ type . '.' . $ name ) ; if ( ! empty ( $ current ) ) { if ( preg_match ( '/^(.*?)_(.*)$/' , end ( $ current ) , $ match ) ) { $ direction = ( is_null ( $ version ) or $ match [ 1 ] < $ version ) ? 'up' : 'down' ; if ( $ direction == 'up' ) { $ migrations = static :: find_migrations ( $ name , $ type , $ match [ 1 ] , $ version ) ; } else { $ migrations = static :: find_migrations ( $ name , $ type , $ version , $ match [ 1 ] , $ direction ) ; $ migrations = array_reverse ( $ migrations , true ) ; } return static :: run ( $ migrations , $ name , $ type , $ direction ) ; } else { throw new \ UnexpectedValueException ( 'Could not determine a valid version from ' . $ current . '.' ) ; } } return static :: run ( static :: find_migrations ( $ name , $ type , null , $ version ) , $ name , $ type , 'up' ) ; }
migrate to a specific version range of versions or all
15,965
public static function current ( $ name = 'default' , $ type = 'app' ) { $ current = \ Config :: get ( 'migrations.version.' . $ type . '.' . $ name ) ; if ( ! empty ( $ current ) ) { if ( preg_match ( '/^(.*?)_(.*)$/' , end ( $ current ) , $ match ) ) { return static :: run ( static :: find_migrations ( $ name , $ type , null , $ match [ 1 ] ) , $ name , $ type , 'up' ) ; } } return array ( ) ; }
migrate to the version defined in the config file
15,966
public static function up ( $ version = null , $ name = 'default' , $ type = 'app' ) { $ current = \ Config :: get ( 'migrations.version.' . $ type . '.' . $ name ) ; $ current = empty ( $ current ) ? null : end ( $ current ) ; $ migrations = static :: find_migrations ( $ name , $ type , $ current , $ version ) ; if ( ! empty ( $ migrations ) ) { is_null ( $ version ) and $ migrations = array ( reset ( $ migrations ) ) ; return static :: run ( $ migrations , $ name , $ type , 'up' ) ; } return array ( ) ; }
migrate up to the next version
15,967
protected static function run ( $ migrations , $ name , $ type , $ method = 'up' ) { $ done = array ( ) ; static :: $ connection === null or \ DBUtil :: set_connection ( static :: $ connection ) ; foreach ( $ migrations as $ ver => $ migration ) { logger ( Fuel :: L_INFO , 'Migrating to version: ' . $ ver ) ; $ result = call_user_func ( array ( new $ migration [ 'class' ] , $ method ) ) ; if ( $ result === false ) { logger ( Fuel :: L_INFO , 'Skipped migration to ' . $ ver . '.' ) ; return false ; } $ file = basename ( $ migration [ 'path' ] , '.php' ) ; $ method == 'up' ? static :: write_install ( $ name , $ type , $ file ) : static :: write_revert ( $ name , $ type , $ file ) ; $ done [ ] = $ file ; } static :: $ connection === null or \ DBUtil :: set_connection ( null ) ; empty ( $ done ) or logger ( Fuel :: L_INFO , 'Migrated to ' . $ ver . ' successfully.' ) ; return $ done ; }
run the action migrations found
15,968
protected static function write_install ( $ name , $ type , $ file ) { \ DB :: insert ( static :: $ table ) -> set ( array ( 'name' => $ name , 'type' => $ type , 'migration' => $ file , ) ) -> execute ( static :: $ connection ) ; static :: $ migrations [ $ type ] [ $ name ] [ ] = $ file ; sort ( static :: $ migrations [ $ type ] [ $ name ] ) ; \ Config :: set ( 'migrations.version.' . $ type . '.' . $ name , static :: $ migrations [ $ type ] [ $ name ] ) ; \ Config :: save ( \ Fuel :: $ env . DS . 'migrations' , 'migrations' ) ; }
add an installed migration to the database
15,969
protected static function write_revert ( $ name , $ type , $ file ) { \ DB :: delete ( static :: $ table ) -> where ( 'name' , $ name ) -> where ( 'type' , $ type ) -> where ( 'migration' , $ file ) -> execute ( static :: $ connection ) ; if ( ( $ key = array_search ( $ file , static :: $ migrations [ $ type ] [ $ name ] ) ) !== false ) { unset ( static :: $ migrations [ $ type ] [ $ name ] [ $ key ] ) ; } sort ( static :: $ migrations [ $ type ] [ $ name ] ) ; \ Config :: set ( 'migrations.version.' . $ type . '.' . $ name , static :: $ migrations [ $ type ] [ $ name ] ) ; \ Config :: save ( \ Fuel :: $ env . DS . 'migrations' , 'migrations' ) ; }
remove a reverted migration from the database
15,970
protected static function _find_app ( $ name = null ) { $ found = array ( ) ; $ files = new \ GlobIterator ( APPPATH . \ Config :: get ( 'migrations.folder' ) . '*_*.php' ) ; foreach ( $ files as $ file ) { $ found [ ] = $ file -> getPathname ( ) ; } return $ found ; }
finds migrations for the given app
15,971
protected static function table_version_check ( ) { static :: $ connection === null or \ DBUtil :: set_connection ( static :: $ connection ) ; if ( ! \ DBUtil :: table_exists ( static :: $ table ) ) { \ DBUtil :: create_table ( static :: $ table , static :: $ table_definition ) ; } elseif ( ! \ DBUtil :: field_exists ( static :: $ table , array ( 'migration' ) ) ) { $ current = \ DB :: select ( ) -> from ( static :: $ table ) -> order_by ( 'type' , 'ASC' ) -> order_by ( 'name' , 'ASC' ) -> execute ( static :: $ connection ) -> as_array ( ) ; \ DBUtil :: drop_table ( static :: $ table ) ; \ DBUtil :: create_table ( static :: $ table , static :: $ table_definition ) ; if ( ! empty ( $ current ) ) { if ( isset ( $ current [ 0 ] [ 'current' ] ) ) { $ current = array ( 0 => array ( 'name' => 'default' , 'type' => 'app' , 'version' => $ current [ 0 ] [ 'current' ] ) ) ; } $ configs = array ( ) ; foreach ( $ current as $ migration ) { $ migrations = static :: find_migrations ( $ migration [ 'name' ] , $ migration [ 'type' ] , null , $ migration [ 'version' ] ) ; $ config = array ( ) ; foreach ( $ migrations as $ file ) { $ file = pathinfo ( $ file [ 'path' ] ) ; \ DB :: insert ( static :: $ table ) -> set ( array ( 'name' => $ migration [ 'name' ] , 'type' => $ migration [ 'type' ] , 'migration' => $ file [ 'filename' ] , ) ) -> execute ( static :: $ connection ) ; $ config [ ] = $ file [ 'filename' ] ; } isset ( $ configs [ $ migration [ 'type' ] ] ) or $ configs [ $ migration [ 'type' ] ] = array ( ) ; $ configs [ $ migration [ 'type' ] ] [ $ migration [ 'name' ] ] = $ config ; } \ Config :: set ( 'migrations.version' , $ configs ) ; \ Config :: save ( \ Fuel :: $ env . DS . 'migrations' , 'migrations' ) ; } is_file ( APPPATH . 'config' . DS . 'migrations.php' ) and unlink ( APPPATH . 'config' . DS . 'migrations.php' ) ; } static :: $ connection === null or \ DBUtil :: set_connection ( null ) ; }
installs or upgrades the migration table to the current schema
15,972
protected function getName ( $ name ) { $ renames = $ this -> getRenames ( ) ; if ( isset ( $ renames [ $ name ] ) ) { return $ renames [ $ name ] ; } return $ name ; }
Return property name
15,973
public function save ( ) { if ( $ this -> _isSaved ) { $ this -> update ( $ this -> id ) ; } else { $ this -> id = $ this -> insert ( ) ; $ this -> _isSaved = true ; } }
Saves this record .
15,974
public function validate ( $ subject ) : bool { if ( \ is_numeric ( $ this -> schema [ 'exclusiveMinimum' ] ) ) { if ( $ subject <= $ this -> schema [ 'exclusiveMinimum' ] ) { return false ; } } return true ; }
Validates subject against exclusiveMinimum
15,975
public function getAllLanguages ( ) { if ( is_array ( $ this -> alllanguages ) ) { return $ this -> alllanguages ; } $ langfile = $ this -> localespath . 'languages.txt' ; if ( ! file_exists ( $ langfile ) ) { $ langfile = dirname ( __FILE__ ) . '/languages.txt' ; } if ( ! file_exists ( $ langfile ) ) { if ( $ this -> errorondatamissed ) { throw new \ Exception ( 'No languages file found' ) ; } return array ( ) ; } $ list = @ file_get_contents ( $ langfile ) ; if ( ! $ list ) { if ( $ this -> errorondatamissed ) { throw new \ Exception ( 'Can not load languages list' ) ; } return array ( ) ; } $ languages = array ( ) ; foreach ( preg_split ( '!\\r?\\n!' , $ list ) as $ line ) { list ( $ code , $ name ) = explode ( '=' , $ line ) ; $ code = trim ( $ code ) ; $ name = trim ( $ name ) ; if ( $ code == '' || $ name == '' ) { continue ; } $ origname = $ name ; $ tags = array ( ) ; $ splitsettings = explode ( ':' , $ name , 3 ) ; if ( count ( $ splitsettings ) > 1 ) { $ name = $ splitsettings [ 0 ] ; $ origname = $ splitsettings [ 1 ] ; if ( isset ( $ splitsettings [ 2 ] ) && $ splitsettings [ 2 ] != '' ) { $ tags = explode ( ',' , $ splitsettings [ 2 ] ) ; } } $ flagfile = $ this -> localespath . 'flags/small/' . $ code . '.png' ; $ hasflag = file_exists ( $ flagfile ) ; $ languages [ $ code ] = array ( 'code' => $ code , 'name' => $ name , 'origname' => $ origname , 'hasflag' => $ hasflag , 'tags' => $ tags ) ; } return $ languages ; }
Returns all languages with all attributes installed on the system
15,976
public function getLanguagesFromList ( $ list ) { $ alllanguages = $ this -> getAllLanguages ( ) ; $ languages = array ( ) ; foreach ( $ alllanguages as $ code => $ lang ) { if ( in_array ( $ code , $ list ) ) { $ languages [ $ code ] = $ lang ; } } return $ languages ; }
Return languages listed in the argument array . Is used for case when it is needed to get list of specified languages
15,977
public function getHTMLSelect ( $ attributes = '' , $ currentlang = '' , $ orignames = false ) { $ html = '<select ' . $ attributes . '>' ; foreach ( $ this -> getUsedLanguages ( ) as $ code => $ lang ) { $ html .= '<option value="' . $ code . '" ' ; if ( $ currentlang == $ code ) { $ html .= 'selected' ; } $ html .= '>' ; if ( $ orignames ) { $ html .= $ lang [ 'origname' ] ; } else { $ html .= $ lang [ 'name' ] ; } } $ html .= '</select>' ; return $ html ; }
Build HTML select consruction with used languages Can be used on a web site to show a Language change dropbox
15,978
public function or_on ( $ c1 , $ op , $ c2 ) { $ this -> _on [ ] = array ( $ c1 , $ op , $ c2 , 'OR' ) ; return $ this ; }
Adds a new OR condition for joining .
15,979
public function on ( $ c1 , $ op , $ c2 ) { $ this -> _on [ ] = array ( $ c1 , $ op , $ c2 , 'AND' ) ; return $ this ; }
Adds a new AND condition for joining .
15,980
public function compile ( $ db = null ) { if ( ! $ db instanceof \ Database_Connection ) { $ db = \ Database_Connection :: instance ( $ db ) ; } if ( $ this -> _type ) { $ sql = strtoupper ( $ this -> _type ) . ' JOIN' ; } else { $ sql = 'JOIN' ; } $ sql .= ' ' . $ db -> quote_table ( $ this -> _table ) ; $ conditions = array ( ) ; foreach ( $ this -> _on as $ condition ) { list ( $ c1 , $ op , $ c2 , $ chaining ) = $ condition ; $ conditions [ ] = ' ' . $ chaining . ' ' ; if ( $ op ) { $ op = ' ' . strtoupper ( $ op ) ; } $ conditions [ ] = $ db -> quote_identifier ( $ c1 ) . $ op . ' ' . ( is_null ( $ c2 ) ? 'NULL' : $ db -> quote_identifier ( $ c2 ) ) ; } array_shift ( $ conditions ) ; empty ( $ conditions ) or $ sql .= ' ON (' . implode ( '' , $ conditions ) . ')' ; return $ sql ; }
Compile the SQL partial for a JOIN statement and return it .
15,981
function send_to ( $ mail ) { $ mail [ 'subject' ] .= ' [' . $ mail [ 'to' ] . ']' ; if ( 'staging' == WP_ENV ) $ mail [ 'to' ] = get_option ( 'admin_email' ) ; else if ( defined ( 'TP_DEV_MAIL' ) ) $ mail [ 'to' ] = TP_DEV_MAIL ; else $ mail [ 'to' ] = '' ; return $ mail ; }
Don t send e - mails in development and staging environments
15,982
public static function illegal ( object $ collection , string $ key ) : CannotDeserialize { return new IllegalInputKey ( withMessage ( 'Invalid collection deserialization input: Unexpected key `%s` for the `%s` class.' , $ key , classOfThe ( $ collection ) ) ) ; }
Produces a deserialization exception to throw when a collection input key is not considered valid .
15,983
protected function sortByScore ( $ a , $ b ) { if ( $ a -> score == $ b -> score ) { return 0 ; } return ( $ a -> score > $ b -> score ) ? - 1 : 1 ; }
Sorting function uses the score of a object to determine the order of the array
15,984
protected function registerTraslator ( ) { $ this -> app -> singleton ( 'translator' , function ( $ app ) { $ loader = $ app [ 'translation.loader' ] ; $ locale = $ app [ 'config' ] [ 'app.locale' ] ; $ trans = new Translator ( $ loader , $ locale ) ; $ trans -> setFallback ( $ app [ 'config' ] [ 'app.fallback_locale' ] ) ; return $ trans ; } ) ; }
Register translator .
15,985
public static function keyval_to_assoc ( $ array , $ key_field , $ val_field ) { if ( ! is_array ( $ array ) and ! $ array instanceof \ Iterator ) { throw new \ InvalidArgumentException ( 'The first parameter must be an array.' ) ; } $ output = array ( ) ; foreach ( $ array as $ key => $ value ) { $ output [ ] = array ( $ key_field => $ key , $ val_field => $ value ) ; } return $ output ; }
Converts an array of key = > values into a multi - dimensional associative array with the provided field names
15,986
public static function is_assoc ( $ arr ) { if ( ! is_array ( $ arr ) ) { throw new \ InvalidArgumentException ( 'The parameter must be an array.' ) ; } $ counter = 0 ; foreach ( $ arr as $ key => $ unused ) { if ( ! is_int ( $ key ) or $ key !== $ counter ++ ) { return true ; } } return false ; }
Checks if the given array is an assoc array .
15,987
public static function multisort ( $ array , $ conditions , $ ignore_case = false ) { $ temp = array ( ) ; $ keys = array_keys ( $ conditions ) ; foreach ( $ keys as $ key ) { $ temp [ $ key ] = static :: pluck ( $ array , $ key , true ) ; is_array ( $ conditions [ $ key ] ) or $ conditions [ $ key ] = array ( $ conditions [ $ key ] ) ; } $ args = array ( ) ; foreach ( $ keys as $ key ) { $ args [ ] = $ ignore_case ? array_map ( 'strtolower' , $ temp [ $ key ] ) : $ temp [ $ key ] ; foreach ( $ conditions [ $ key ] as $ flag ) { $ args [ ] = $ flag ; } } $ args [ ] = & $ array ; call_fuel_func_array ( 'array_multisort' , $ args ) ; return $ array ; }
Sorts an array on multitiple values with deep sorting support .
15,988
protected function setBreadcrumbEditUpload ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Dashboard' ) , 'url' => $ this -> url ( 'admin' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Modules' ) , 'url' => $ this -> url ( 'admin/module/list' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Set breadcrumbs on the module upload page
15,989
protected function validateUpload ( ) { $ file = $ this -> request -> file ( 'file' ) ; if ( empty ( $ file ) ) { $ this -> setError ( 'file' , $ this -> text ( 'Nothing to install' ) ) ; return false ; } $ result = $ this -> file_transfer -> upload ( $ file , 'zip' , gplcart_file_private_module ( 'installer' ) ) ; if ( $ result !== true ) { $ this -> setError ( 'file' , $ result ) ; return false ; } $ this -> setSubmitted ( 'file' , $ this -> file_transfer -> getTransferred ( ) ) ; return ! $ this -> hasErrors ( ) ; }
Validate a submitted data
15,990
protected function installModuleUpload ( ) { $ this -> controlAccess ( 'file_upload' ) ; $ this -> controlAccess ( 'module_installer_upload' ) ; $ file = $ this -> getSubmitted ( 'file' ) ; $ result = $ this -> install -> fromZip ( $ file ) ; if ( $ result !== true ) { $ this -> redirect ( '' , $ result , 'warning' ) ; } if ( $ this -> install -> isUpdate ( ) ) { $ message = $ this -> text ( 'Module has been updated. Previous version has been saved to a <a href="@url">backup</a> file' , array ( '@url' => $ this -> url ( 'admin/report/backup' ) ) ) ; } else { $ message = $ this -> text ( 'Module has been uploaded. You should <a href="@url">enable</a> it manually' , array ( '@url' => $ this -> url ( 'admin/module/list' ) ) ) ; } $ this -> redirect ( '' , $ message , 'success' ) ; }
Install uploaded module
15,991
public function getVersion ( $ version_key ) { if ( is_null ( $ this -> version ) ) { $ headers = \ getallheaders ( ) ; if ( isset ( $ headers [ $ version_key ] ) && is_numeric ( $ headers [ $ version_key ] ) && in_array ( $ headers [ $ version_key ] , $ this -> api_versions ) ) { $ version = 'V' . str_replace ( '.' , '_' , $ headers [ $ version_key ] ) ; } else { $ version = 'V1' ; } $ this -> version = $ version ; } return $ this -> version ; }
Creates the version of the API we re expected to use
15,992
protected function init ( ) { $ uri = $ this -> token ; if ( ( $ pos = strpos ( $ uri , ':' ) ) !== false ) { $ this -> scheme = substr ( $ uri , 0 , $ pos ) ; $ rest = substr ( $ uri , $ pos + 1 ) ; } else { $ rest = $ uri ; } if ( ( $ pos = strrpos ( $ rest , '#' ) ) !== false ) { $ this -> fragment = substr ( $ rest , $ pos + 1 ) ; $ rest = substr ( $ rest , 0 , $ pos ) ; } $ this -> schemeSpecificPart = $ rest ; if ( ( $ this -> isAbsolute ( ) && $ this -> schemeSpecificPart { 0 } == '/' ) || ! $ this -> isAbsolute ( ) ) { $ parts = array ( ) ; if ( preg_match ( '/^(\/\/([^\/]*))?(\/?[^\?]+)?(\?(.*?))?$/S' , $ this -> schemeSpecificPart , $ parts ) ) { if ( isset ( $ parts [ 2 ] ) ) { $ this -> setAuthority ( $ parts [ 2 ] ) ; } if ( isset ( $ parts [ 3 ] ) && $ parts [ 3 ] ) { $ this -> path = $ parts [ 3 ] ; } if ( isset ( $ parts [ 5 ] ) && $ parts [ 5 ] ) { $ this -> query = $ parts [ 5 ] ; } } else { throw new \ DomainException ( "Hierarchical URI scheme-specific part syntax error" ) ; } } $ this -> hash = null ; }
Constructs a URI by parsing the given string .
15,993
public function resolve ( Uri $ uri ) { static $ resolve = array ( ) ; return ( isset ( $ resolve [ $ hash = $ this -> hashCode ( ) . $ uri -> hashCode ( ) ] ) ) ? $ resolve [ $ hash ] : ( $ resolve [ $ hash ] = $ this -> createResolve ( $ uri ) ) ; }
Resolves the given URI against this URI .
15,994
public function normalize ( ) { if ( $ this -> isOpaque ( ) || ! $ this -> path ) { return clone $ this ; } else { $ uri = clone $ this ; $ uri -> path = self :: normalizePath ( $ this -> path ) ; return $ uri ; } }
Normalizes this URI s path .
15,995
protected function buildStr ( ) { $ uri = ( $ this -> scheme != null ) ? ( $ this -> scheme . ':' ) : '' ; if ( $ this -> isOpaque ( ) ) { $ uri .= $ this -> schemeSpecificPart ; } else { $ uri .= $ this -> buildAuthorityStr ( ) ; if ( $ this -> path !== null ) { $ uri .= $ this -> path ; } if ( ! empty ( $ this -> query ) ) { $ uri .= '?' . $ this -> query ; } } if ( ! empty ( $ this -> fragment ) ) { $ uri .= '#' . $ this -> fragment ; } return $ uri ; }
Returns the content of this URI as a string .
15,996
protected function setAuthority ( $ authority ) { $ aparts = [ ] ; if ( preg_match ( '/^(([^\@]+)\@)?(.*?)(\:(.+))?$/S' , $ authority , $ aparts ) ) { $ this -> authority = $ authority ; $ this -> hash = null ; if ( isset ( $ aparts [ 2 ] ) && $ aparts [ 2 ] ) { $ this -> userInfo = $ aparts [ 2 ] ; } if ( isset ( $ aparts [ 3 ] ) && $ aparts [ 3 ] ) { $ this -> host = $ aparts [ 3 ] ; } if ( isset ( $ aparts [ 5 ] ) && $ aparts [ 5 ] ) { $ this -> port = ( int ) $ aparts [ 5 ] ; } } else { throw new \ DomainException ( "Hierarchical URL authority part syntax error" ) ; } return $ this ; }
Set authority component of this URI .
15,997
public function getRelated ( Uri $ baseUri ) { $ path = $ baseUri -> getPath ( ) ; if ( substr ( $ this -> getPath ( ) , 0 , strlen ( $ path ) ) == $ path ) { $ class = get_called_class ( ) ; $ uri = new $ class ( '' ) ; $ uri -> fragment = $ this -> fragment ; $ uri -> path = substr ( $ this -> getPath ( ) , strlen ( $ path ) ) ; $ uri -> query = $ this -> query ; return $ uri ; } return $ this ; }
Get new uri instance related to provided base
15,998
protected function buildAuthorityStr ( ) { if ( $ this -> host != null ) { $ authority = '//' ; if ( $ this -> userInfo != null ) { $ authority .= $ this -> userInfo . '@' ; } $ flag = ( strpos ( $ this -> host , ':' ) !== false ) && ! ( substr ( $ this -> host , 0 , 1 ) == '[' ) && ! ( substr ( $ this -> host , - 1 ) == ']' ) ; if ( $ flag ) { $ authority .= '[' ; } $ authority .= $ this -> host ; if ( $ flag ) { $ authority .= ']' ; } if ( $ this -> port != null ) { $ authority .= ':' . $ this -> port ; } return $ authority ; } else { if ( $ this -> scheme ) { return '//' . $ this -> authority ; } else { return $ this -> authority ; } } }
Returns the authority parts string of url
15,999
public function withHost ( $ host ) { $ url = clone $ this ; $ url -> host = $ host ; $ url -> hash = null ; return $ url ; }
Create a new instance with the specified host .