idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
22,000
public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( FunctionPhaseTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = FunctionPhaseQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; }
Performs an INSERT on the database given a FunctionPhase or Criteria object .
22,001
public function getOutputPath ( ) : ? string { if ( ! $ this -> hasOutputPath ( ) ) { $ this -> setOutputPath ( $ this -> getDefaultOutputPath ( ) ) ; } return $ this -> outputPath ; }
Get output path
22,002
public function populate ( $ data ) { $ this -> userId = $ data -> userId ; $ this -> email = $ data -> email ; $ this -> firstName = $ data -> firstName ; $ this -> lastName = $ data -> lastName ; $ this -> status = $ data -> status ; $ this -> remember_token = $ data -> remember_token ; $ this -> userSessionId = $ data -> userSessionId ; $ this -> sessionCode = $ data -> sessionCode ; $ this -> ipAddress = $ data -> ipAddress ; $ this -> environment = $ data -> environment ; return $ this ; }
Fill the user attributes
22,003
public function addStripper ( $ stripper ) { if ( is_string ( $ stripper ) ) { if ( ! class_exists ( $ stripper ) ) { $ stripper = '\\' . __NAMESPACE__ . '\\Stripper\\' . $ stripper ; if ( ! class_exists ( $ stripper ) ) { throw new \ InvalidArgumentException ( 'Class ' . $ stripper . ' can not be found' ) ; } } $ stripper = new $ stripper ; if ( ! $ stripper instanceof StripperInterface ) { throw new InvalidArgumentException ( 'Class "' . get_class ( $ stripper ) . '" must implement StripperInterface' ) ; } } elseif ( ! $ stripper instanceof StripperInterface ) { throw new InvalidArgumentException ( 'Class "' . get_class ( $ stripper ) . '" must implement StripperInterface' ) ; } $ this -> _stippers [ ] = $ stripper ; }
Accept an object or class name that implements StripperInterface
22,004
public function fileExists ( $ directory = null ) { $ directory = ( $ directory ) ? : $ this -> fileDirectory ; $ fileExists = file_exists ( $ this -> publicDirectory . $ directory . $ this -> file ) ; return $ fileExists ; }
Checks to see if file exists
22,005
public function isFile ( $ directory = null ) { $ directory = ( $ directory ) ? : $ this -> fileDirectory ; $ isFile = is_file ( $ this -> publicDirectory . $ directory . $ this -> file ) ; return $ isFile ; }
Checks to see if file is a file
22,006
public function indexAction ( Request $ request ) { $ jobManager = $ this -> get ( 'phlexible_queue.job_manager' ) ; $ limit = $ request -> get ( 'limit' , 25 ) ; $ offset = $ request -> get ( 'start' , 0 ) ; $ data = [ ] ; foreach ( $ jobManager -> findBy ( [ ] , [ 'createdAt' => 'DESC' ] , $ limit , $ offset ) as $ queueItem ) { $ data [ ] = [ 'id' => $ queueItem -> getId ( ) , 'command' => $ queueItem -> getCommand ( ) , 'priority' => $ queueItem -> getPriority ( ) , 'status' => $ queueItem -> getState ( ) , 'create_time' => $ queueItem -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'start_time' => $ queueItem -> getStartedAt ( ) ? $ queueItem -> getStartedAt ( ) -> format ( 'Y-m-d H:i:s' ) : null , 'end_time' => $ queueItem -> getFinishedAt ( ) ? $ queueItem -> getFinishedAt ( ) -> format ( 'Y-m-d H:i:s' ) : null , 'output' => nl2br ( $ queueItem -> getOutput ( ) ) , ] ; } $ total = $ jobManager -> countBy ( [ ] ) ; return new JsonResponse ( [ 'data' => $ data , 'total' => $ total ] ) ; }
Job list .
22,007
public function toResponse ( ) { $ response = Http :: getInstance ( ) -> response ( ) ; $ response -> reset ( ) ; $ response -> status ( $ this -> code ) ; if ( is_string ( $ this -> details ) ) { $ response -> body ( $ this -> details ) ; } elseif ( is_string ( $ this -> message ) ) { $ response -> body ( $ this -> message ) ; } return $ response ; }
Converts the error to a response object .
22,008
public function registerHandler ( Handler $ handler , int $ chainProbability = 0 ) : void { static $ first = true ; if ( $ first ) { $ this -> handlers = [ ] ; $ first = false ; } $ this -> handlers [ ] = [ $ handler , $ chainProbability ] ; }
Register a session handler .
22,009
private function walk ( string $ method , int $ highProbability = null , array $ args = [ ] ) { $ result = false ; foreach ( $ this -> handlers as $ data ) { list ( $ handler , $ chainProbability ) = $ data ; $ probability = isset ( $ highProbability ) ? $ highProbability : $ chainProbability ; $ result = call_user_func_array ( [ $ handler , $ method ] , $ args ) ; if ( $ result and mt_rand ( 0 , 100 ) > $ probability ) { return $ result ; } } return $ result ; }
Internal method to walk the handler chain .
22,010
public function read ( $ id ) : string { if ( $ session = $ this -> walk ( 'read' , null , [ $ id ] ) ) { self :: $ session = $ session ; return self :: $ session [ 'data' ] ; } return '' ; }
Read the requested session .
22,011
public function write ( $ id , $ data ) : bool { return ( bool ) $ this -> walk ( 'write' , null , [ $ id , compact ( 'data' ) + self :: $ session ] ) ; }
Write the requested session .
22,012
protected function readMsgId ( $ index ) { $ msgId = $ this -> readStringFromTable ( $ index , $ this -> msgIdTable ) ; if ( false === $ msgId ) { $ msgId = array ( '' ) ; } return $ msgId ; }
Reads specified message id record
22,013
protected function readTranslation ( $ index ) { $ msgStr = $ this -> readStringFromTable ( $ index , $ this -> msgStrTable ) ; if ( false === $ msgStr ) { $ msgStr = array ( ) ; } return $ msgStr ; }
Reads specified translation record
22,014
protected function openFile ( $ filename ) { $ this -> filename = $ filename ; if ( ! is_file ( $ this -> filename ) ) { throw new \ Exception ( sprintf ( 'File %s does not exist' , $ this -> filename ) ) ; } $ this -> file = fopen ( $ this -> filename , 'rb' ) ; if ( false === $ this -> file ) { throw new \ Exception ( sprintf ( 'Could not open file %s for reading' , $ this -> filename ) ) ; } }
Prepare file for reading
22,015
protected function determineByteOrder ( ) { $ orderHeader = fread ( $ this -> file , 4 ) ; if ( $ orderHeader == "\x95\x04\x12\xde" ) { $ this -> littleEndian = false ; } elseif ( $ orderHeader == "\xde\x12\x04\x95" ) { $ this -> littleEndian = true ; } else { fclose ( $ this -> file ) ; throw new \ Exception ( sprintf ( '%s is not a valid gettext file' , $ this -> filename ) ) ; } }
Determines byte order
22,016
protected function readInteger ( ) { if ( $ this -> littleEndian ) { $ result = unpack ( 'Vint' , fread ( $ this -> file , 4 ) ) ; } else { $ result = unpack ( 'Nint' , fread ( $ this -> file , 4 ) ) ; } return $ result [ 'int' ] ; }
Read a single integer from the current file .
22,017
protected function readIntegerList ( $ num ) { if ( $ this -> littleEndian ) { return unpack ( 'V' . $ num , fread ( $ this -> file , 4 * $ num ) ) ; } return unpack ( 'N' . $ num , fread ( $ this -> file , 4 * $ num ) ) ; }
Read an integer from the current file .
22,018
public function widget ( $ args , $ instance ) { extract ( $ args , EXTR_SKIP ) ; echo $ before_widget ; $ title = empty ( $ instance [ 'title' ] ) ? null : apply_filters ( 'widget_title' , $ instance [ 'title' ] ) ; if ( ! empty ( $ title ) ) { echo $ before_title . $ title . $ after_title ; } ; MoufManager :: getMoufManager ( ) -> get ( $ instance [ 'instance' ] ) -> toHtml ( ) ; echo $ after_widget ; }
Display widget .
22,019
public function form ( $ instance ) { $ default = array ( 'title' => '' , 'instance' => null , ) ; $ instance = wp_parse_args ( ( array ) $ instance , $ default ) ; $ title_id = $ this -> get_field_id ( 'title' ) ; $ title_name = $ this -> get_field_name ( 'title' ) ; echo '<p> <label for="' . $ title_id . '">' . __ ( 'Title' ) . ': <input type="text" class="widefat" id="' . $ title_id . '" name="' . $ title_name . '" value="' . esc_attr ( $ instance [ 'title' ] ) . '" /> </label></p>' ; $ instance_id = $ this -> get_field_id ( 'instance' ) ; $ instance_name = $ this -> get_field_name ( 'instance' ) ; $ moufManager = MoufManager :: getMoufManager ( ) ; $ instances = $ moufManager -> findInstances ( 'Mouf\\Html\\HtmlElement\\HtmlElementInterface' ) ; sort ( $ instances ) ; echo '<p> <label for="' . $ instance_id . '">' . __ ( 'Instance' ) . ': <select class="widefat" id="' . $ instance_id . '" name="' . $ instance_name . '" > ' ; foreach ( $ instances as $ name ) { if ( $ moufManager -> isInstanceAnonymous ( $ name ) ) { continue ; } ?> <option value=" <?php echo esc_attr ( $ name ) ; ?> " <?php if ( $ name == $ instance [ 'instance' ] ) { echo "selected='selected'" ; } ?> > <?php echo esc_html ( $ name ) ; ?> </option> <?php } echo ' </select> </label></p>' ; }
admin control form .
22,020
public function offsetGet ( $ key ) { $ key = $ this -> count - $ key - 1 ; if ( ! isset ( $ this -> data [ $ key ] ) ) { throw new \ OutOfRangeException ( "Out of range." ) ; } return $ this -> data [ $ key ] ; }
Returns the element with the given offset .
22,021
public function offsetSet ( $ key , $ value ) { $ key = $ this -> count - $ key - 1 ; if ( ! isset ( $ this -> data [ $ key ] ) ) { throw new \ OutOfRangeException ( "Out of range." ) ; } $ this -> data [ $ key ] = $ value ; }
Set the element with the given offset .
22,022
public static function check ( ConfigCollection $ configCollection , CheckerCollection $ checkerCollection ) : ResultCollection { $ resultCollection = new ResultCollection ( ) ; foreach ( $ checkerCollection -> all ( ) as $ id => $ checker ) { $ resultCollection -> add ( $ checker -> check ( $ configCollection -> getConfig ( $ id ) ) ) ; } return $ resultCollection ; }
Run all the checkers according to their configs .
22,023
public function run ( ) : array { try { $ result = null ; if ( $ this -> match !== false && is_callable ( $ this -> match [ 'target' ] ) === true ) { if ( func_num_args ( ) > 0 ) { foreach ( func_get_args ( ) as $ argument ) { $ this -> match [ 'params' ] [ ] = $ argument ; } } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'POST' && empty ( $ _POST ) === false ) { $ this -> match [ 'params' ] [ ] = $ _POST ; } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'GET' && empty ( $ _GET ) === false ) { $ this -> match [ 'params' ] [ ] = $ _GET ; } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PUT' ) { $ _PUT = parse_str ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ _PUT ) === false ) { $ this -> match [ 'params' ] [ ] = $ _PUT ; } } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PATCH' ) { $ _PATCH = parse_str ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ _PATCH ) === false ) { $ this -> match [ 'params' ] [ ] = $ _PATCH ; } } $ result = call_user_func_array ( $ this -> match [ 'target' ] , $ this -> match [ 'params' ] ) ; } else { throw new \ InvalidArgumentException ( "Method not found" ) ; } return $ result ; } catch ( \ Throwable $ e ) { if ( $ e instanceof \ InvalidArgumentException ) { return [ "headers" => [ [ 'X-PHP-Response-Code: 400' , true , 400 ] ] , "response" => $ e -> getMessage ( ) ] ; } elseif ( $ e instanceof \ DomainException ) { return [ "headers" => [ [ 'X-PHP-Response-Code: 422' , true , 422 ] ] , "response" => $ e -> getMessage ( ) ] ; } else { return [ "headers" => [ [ 'X-PHP-Response-Code: 500' , true , 500 ] ] , "response" => $ e -> getMessage ( ) ] ; } } }
Runs the API function and returns the result
22,024
public function set ( string $ link = null , string $ method = null ) : \ TheCMSThread \ Classes \ API { if ( $ link === null ) { if ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) === false ) { $ _SERVER [ 'REQUEST_URI' ] = '/' ; } $ link = str_replace ( "?" . $ _SERVER [ "QUERY_STRING" ] , "" , $ _SERVER [ "REQUEST_URI" ] ) ; } $ link = '/' . trim ( $ link , '/' ) ; if ( $ method === null ) { if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) === false ) { $ _SERVER [ 'REQUEST_METHOD' ] = 'GET' ; } $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; } if ( $ method == 'POST' && empty ( $ _POST [ '_method' ] ) === false ) { $ method = $ _POST [ '_method' ] ; unset ( $ _POST [ '_method' ] ) ; } $ this -> match = $ this -> router -> match ( $ link , $ method ) ; return $ this ; }
Set the active API link
22,025
public function HTMLID ( $ lowercase = false ) { $ str = trim ( str_replace ( ' ' , '-' , ucwords ( str_replace ( [ '_' , '-' , '/' ] , ' ' , $ this -> owner -> value ) ) ) , '-' ) ; return $ lowercase ? strtolower ( $ str ) : $ str ; }
Convert value to an appropriate HTML ID
22,026
public function nl2list ( $ class = '' , $ liClass = '' , $ tag = 'ul' ) { $ val = trim ( $ this -> owner -> XML ( ) , "\n" ) ; $ val = str_replace ( "\n" , sprintf ( '</li><li%s>' , $ liClass ? 'class="' . $ liClass . '"' : '' ) , $ val ) ; $ val = $ liClass ? '<li class="' . $ liClass . '">' . $ val . '</li>' : '<li>' . $ val . '</li>' ; return $ class ? '<' . $ tag . ' class="' . $ class . '">' . $ val . '</' . $ tag . '>' : '<' . $ tag . '>' . $ val . '</' . $ tag . '>' ; }
Convert new lines to a list
22,027
public function FormatOrUnknown ( $ format = 'Nice' ) { return $ this -> owner -> value && $ this -> owner -> value != '0000-00-00 00:00:00' ? $ this -> owner -> $ format ( ) : _t ( '_UNKNOWN_' , '(unknown)' ) ; }
Format a field or return as unknown
22,028
public function FormatOrNot ( $ format = 'Nice' ) { return $ this -> owner -> value && $ this -> owner -> value != '0000-00-00 00:00:00' ? $ this -> owner -> $ format ( ) : '<span class="ui-button-icon-primary ui-icon btn-icon-decline"></span>' ; }
Format a field or return as cms false
22,029
final public function bindData ( $ data , $ ignore = array ( ) , $ strict = true , $ filter = array ( ) ) { $ validate = $ this -> validator ; if ( ! is_object ( $ data ) && ! is_array ( $ data ) ) { throw new Exception ( t ( "Data must be either an object or array" ) ) ; return false ; } $ dataArray = is_array ( $ data ) ; $ dataObject = is_object ( $ data ) ; foreach ( $ this -> schema as $ k => $ v ) { if ( ! in_array ( $ k , $ ignore ) ) { if ( $ dataArray && isset ( $ data [ $ k ] ) ) { $ this -> schema [ $ k ] -> Value = $ data [ $ k ] ; } else if ( $ dataObject && isset ( $ data -> $ k ) ) { $ this -> schema [ $ k ] -> Value = $ data -> $ k ; } } if ( isset ( $ this -> schema [ $ k ] -> Validate ) && isset ( $ this -> schema [ $ k ] -> Value ) ) { $ datatype = $ this -> schema [ $ k ] -> Validate ; $ datavalue = $ this -> schema [ $ k ] -> Value ; if ( method_exists ( $ validate , $ datatype ) ) { if ( ! \ call_user_func ( array ( $ validate , $ datatype ) , $ datavalue ) ) { unset ( $ this -> schema [ $ k ] -> Value ) ; throw new Exception ( sprintf ( t ( "%s is not a valid %2s" ) , $ k , $ datatype ) ) ; if ( $ strict ) { break ; } } } } } return ( count ( $ this -> getErrors ( ) ) > 0 ) ? false : true ; }
Binds user data to the table ;
22,030
final public function getRowFieldValue ( $ field ) { if ( array_key_exists ( $ field , $ this -> schema ) ) { return $ this -> schema [ $ field ] -> Value ; } return null ; }
Gets the value of a field in the current ROW
22,031
final public function setRowFieldValue ( $ field , $ value ) { if ( array_key_exists ( $ field , $ this -> schema ) ) { $ this -> schema [ $ field ] -> Value = $ value ; return true ; } return false ; }
Sets a field value in the current row
22,032
protected function _send ( ) { $ message = $ this -> build_message ( ) ; $ return_path = ( $ this -> config [ 'return_path' ] !== false ) ? $ this -> config [ 'return_path' ] : $ this -> config [ 'from' ] [ 'email' ] ; if ( ! @ mail ( static :: format_addresses ( $ this -> to ) , $ this -> subject , $ message [ 'body' ] , $ message [ 'header' ] , '-oi -f ' . $ return_path ) ) { throw new \ EmailSendingFailedException ( 'Failed sending email' ) ; } return true ; }
Send the email using php s mail function .
22,033
public function HtmlEntityDecode ( $ Table , $ Column , $ Limit = 100 ) { $ Model = $ this -> CreateModel ( $ Table ) ; $ Data = $ this -> SQL -> Select ( $ Model -> PrimaryKey ) -> Select ( $ Column ) -> From ( $ Table ) -> Like ( $ Column , '&%;' , 'both' ) -> Limit ( $ Limit ) -> Get ( ) -> ResultArray ( ) ; $ Result = array ( ) ; $ Result [ 'Count' ] = count ( $ Data ) ; $ Result [ 'Complete' ] = FALSE ; $ Result [ 'Decoded' ] = array ( ) ; $ Result [ 'NotDecoded' ] = array ( ) ; foreach ( $ Data as $ Row ) { $ Value = $ Row [ $ Column ] ; $ DecodedValue = HtmlEntityDecode ( $ Value ) ; $ Item = array ( 'From' => $ Value , 'To' => $ DecodedValue ) ; if ( $ Value != $ DecodedValue ) { $ Model -> SetField ( $ Row [ $ Model -> PrimaryKey ] , $ Column , $ DecodedValue ) ; $ Result [ 'Decoded' ] = $ Item ; } else { $ Result [ 'NotDecoded' ] = $ Item ; } } $ Result [ 'Complete' ] = $ Result [ 'Count' ] < $ Limit ; return $ Result ; }
Remove html entities from a column in the database .
22,034
public function PrimaryKeyRange ( $ Table ) { $ Model = $ this -> CreateModel ( $ Table ) ; $ Data = $ this -> SQL -> Select ( $ Model -> PrimaryKey , 'min' , 'MinValue' ) -> Select ( $ Model -> PrimaryKey , 'max' , 'MaxValue' ) -> From ( $ Table ) -> Get ( ) -> FirstRow ( DATASET_TYPE_ARRAY ) ; if ( $ Data ) return array ( $ Data [ 'MinValue' ] , $ Data [ 'MaxValue' ] ) ; else return array ( 0 , 0 ) ; }
Return the min and max values of a table s primary key .
22,035
private static function aggregateHeaderFromServer ( $ server = [ ] ) { $ header = [ ] ; if ( isset ( $ server [ 'HTTP_HOST' ] ) ) { $ header [ 'Host' ] = $ server [ 'HTTP_HOST' ] ; } if ( isset ( $ server [ 'HTTP_USER_AGENT' ] ) ) { $ header [ 'User-Agent' ] = $ server [ 'HTTP_USER_AGENT' ] ; } if ( isset ( $ server [ 'HTTP_CONNECTION' ] ) ) { $ header [ 'Connection' ] = $ server [ 'HTTP_CONNECTION' ] ; } if ( isset ( $ server [ 'HTTP_ACCEPT_ENCODING' ] ) ) { $ header [ 'Accept-Encoding' ] = $ server [ 'HTTP_ACCEPT_ENCODING' ] ; } if ( isset ( $ server [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { $ header [ 'Accept-Language' ] = $ server [ 'HTTP_ACCEPT_LANGUAGE' ] ; } if ( isset ( $ server [ 'HTTP_CACHE_CONTROL' ] ) ) { $ header [ 'Cache-Control' ] = $ server [ 'HTTP_CACHE_CONTROL' ] ; } if ( isset ( $ server [ 'HTTP_ACCEPT' ] ) ) { $ header [ 'Accept' ] = $ server [ 'HTTP_ACCEPT' ] ; } return $ header ; }
Aggregate request header information from server variables .
22,036
private static function aggregateHttpProtocolVersionFromServer ( $ server ) { if ( ! isset ( $ server [ 'SERVER_PROTOCOL' ] ) ) { return null ; } $ pattern = '/^(?P<scheme>HTTP)\/(?P<protocol_version>1\.(0|1))$/' ; if ( ! preg_match ( $ pattern , $ server [ 'SERVER_PROTOCOL' ] , $ q ) ) { return null ; } return $ q [ 'protocol_version' ] ; }
Get HTTP protocol version from server variables .
22,037
private static function aggregateUriFromServer ( $ server ) { $ uri = new Uri ( ) ; $ scheme = 'http' ; $ uri = $ uri -> withScheme ( $ scheme ) ; if ( isset ( $ server [ 'SERVER_NAME' ] ) ) { $ uri = $ uri -> withHost ( $ server [ 'SERVER_NAME' ] ) ; } if ( isset ( $ server [ 'SERVER_PORT' ] ) ) { $ uri = $ uri -> withPort ( ( int ) $ server [ 'SERVER_PORT' ] ) ; } if ( isset ( $ server [ 'REQUEST_URI' ] ) ) { $ q = explode ( '?' , $ server [ 'REQUEST_URI' ] ) ; if ( isset ( $ q [ 0 ] ) ) { $ uri = $ uri -> withPath ( $ q [ 0 ] ) ; } } if ( isset ( $ server [ 'QUERY_STRING' ] ) ) { $ uri = $ uri -> withQuery ( $ server [ 'QUERY_STRING' ] ) ; } return $ uri ; }
Aggregate URI component from server variables .
22,038
public function get ( $ tag ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } if ( ! isset ( $ this -> phrases [ $ tag ] ) || $ this -> phrases [ $ tag ] == '' ) { return 'LOCALIZE [' . $ this -> local . ']: ' . $ tag ; } else { return $ this -> phrases [ $ tag ] ; } }
method to display phrases
22,039
final protected function getMeta ( $ data_only = false ) { $ meta_stack = $ this -> page -> meta -> getTags ( ) ; if ( $ data_only ) { return $ meta_stack ; } $ html = '' ; foreach ( $ meta_stack as $ tag ) { $ html .= PHP_EOL . '<meta' ; foreach ( $ tag as $ attribute => $ value ) { $ html .= ' ' . $ attribute . '="' . $ value . '"' ; } $ html .= '>' ; } return $ html ; }
Creates and returns meta tags
22,040
final protected function getTitle ( $ data_only = false ) { if ( $ data_only ) { return $ this -> page -> getTitle ( ) ; } return PHP_EOL . '<title>' . $ this -> page -> getTitle ( ) . '</title>' ; }
Creates and returns the title tag
22,041
final protected function getOpenGraph ( $ data_only = false ) { $ og_stack = $ this -> page -> og -> getTags ( ) ; if ( $ data_only ) { return $ og_stack ; } $ html = '' ; foreach ( $ og_stack as $ property => $ content ) { $ html .= '<meta property="' . $ property . '" content="' . $ content . '">' . PHP_EOL ; } return $ html ; }
Creates and return OpenGraph tags
22,042
final protected function getCss ( $ data_only = false ) { $ files = $ this -> page -> css -> getFiles ( ) ; if ( $ data_only ) { return $ files ; } $ html = '' ; foreach ( $ files as $ file ) { $ html .= PHP_EOL . '<link rel="stylesheet" type="text/css" href="' . $ file . '">' ; } return $ html ; }
Creates and returns all css realted content
22,043
final protected function getScript ( $ area , $ data_only = false ) { $ files = $ this -> page -> js -> getFiles ( $ area ) ; if ( $ data_only ) { return $ files ; } $ html = '' ; foreach ( $ files as $ file ) { $ html .= PHP_EOL . '<script src="' . $ file . '"></script>' ; } return $ html ; }
Creates and returns js script stuff for the requested area .
22,044
final protected function getHeadLinks ( $ data_only = false ) { $ link_stack = $ this -> page -> link -> getLinkStack ( ) ; if ( $ data_only ) { return $ link_stack ; } $ html = '' ; foreach ( $ link_stack as $ link ) { $ html .= PHP_EOL . '<link' ; foreach ( $ link as $ attribute => $ value ) { $ html .= ' ' . $ attribute . '="' . $ value . '"' ; } $ html .= '>' ; } return $ html ; }
Create and returns head link elements
22,045
final protected function getMessages ( $ data_only = false , $ container = 'container' ) { $ messages = $ this -> page -> message -> getAll ( ) ; if ( $ data_only ) { return $ messages ; } ob_start ( ) ; echo '<div id="core-message"' , ( $ container ? ' class="' . $ container . '"' : '' ) , '>' ; foreach ( $ messages as $ msg ) { echo PHP_EOL , ' <div class="alert alert-' , $ msg -> getType ( ) , $ msg -> getDismissable ( ) ? ' alert-dismissable' : '' ; echo '"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> ' , $ msg -> getMessage ( ) , ' </div>' ; } echo '</div>' ; return ob_get_clean ( ) ; }
Creates and returns stored messages
22,046
final protected function getBreadcrumbs ( $ data_only = false ) { $ breadcrumbs = $ this -> page -> breadcrumbs -> getBreadcrumbs ( ) ; if ( $ data_only ) { return $ breadcrumbs ; } $ text = $ this -> page -> txt ( 'home' ) ; if ( $ breadcrumbs ) { $ home_crumb = $ this -> page -> breadcrumbs -> createItem ( $ text , BASEURL , $ text ) ; } else { $ home_crumb = $ this -> page -> breadcrumbs -> createActiveItem ( $ text , $ text ) ; } array_unshift ( $ breadcrumbs , $ home_crumb ) ; ob_start ( ) ; if ( $ breadcrumbs ) { echo '<ol class="breadcrumb">' ; foreach ( $ breadcrumbs as $ breadcrumb ) { echo '<li' ; if ( $ breadcrumb -> getActive ( ) ) { echo ' class="active">' . $ breadcrumb -> getText ( ) ; } else { echo '><a href="' . $ breadcrumb -> getHref ( ) . '">' . $ breadcrumb -> getText ( ) . '</a>' ; } echo '</li>' ; } echo '</ol>' ; } return ob_get_clean ( ) ; }
Creates breadcrumb html content or returns it s data -
22,047
final protected function getContent ( $ data_only = false , $ fluid = false ) { if ( $ data_only ) { return $ this -> page -> getContent ( ) ; } return '<div id="content" class="container' . ( $ fluid ? '-fluid' : '' ) . '">' . $ this -> page -> getContent ( ) . '</div>' ; }
Returns the content generated by app call
22,048
public function showAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'EcommerceBundle:Transaction' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Transaction entity.' ) ; } $ checkoutManager = $ this -> get ( 'checkout_manager' ) ; $ totals = $ checkoutManager -> calculateTotals ( $ entity , $ entity -> getDelivery ( ) ) ; return array ( 'entity' => $ entity , 'totals' => $ totals , ) ; }
Finds and displays an Transaction entity .
22,049
public function authorizePaymentAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'EcommerceBundle:Transaction' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Transaction entity.' ) ; } $ entity -> setStatus ( Transaction :: STATUS_PAID ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'core.mailer' ) -> sendBankTransferConfirmation ( $ entity ) ; $ this -> get ( 'checkout_manager' ) -> sendToTransport ( $ entity ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'order.authorized.payment' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_transaction_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; }
Authorizes the payment of a pending transfer order
22,050
public function deleteAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'EcommerceBundle:Transaction' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Transaction entity.' ) ; } $ em -> remove ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'info' , 'transaction.deleted' ) ; return array ( ) ; }
Deletes a Transaction entity .
22,051
public static function Read ( string $ folder , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FolderAccessException { return new FolderAccessException ( $ folder , FolderAccessException :: ACCESS_READ , $ message , $ code , $ previous ) ; }
Inits a new \ Niirrty \ IO \ FolderAccessException for folder read mode .
22,052
public static function Write ( string $ folder , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FolderAccessException { return new FolderAccessException ( $ folder , FolderAccessException :: ACCESS_WRITE , $ message , $ code , $ previous ) ; }
Inits a new \ UK \ IO \ FolderAccessException for folder write mode .
22,053
public function create ( ) { if ( ! $ this -> adapter -> fileExists ( $ this -> path , true ) ) { new Directory ( dirname ( $ this -> path ) , $ this -> adapter ) ; if ( $ this -> adapter -> createFile ( $ this -> path ) === false ) { $ this -> throwUnableToCreate ( ) ; } } return $ this ; }
Creates the file if it doesn t exist .
22,054
public function copyAs ( $ dest ) { $ copy = new File ( $ dest , $ this -> adapter ) ; $ copy -> content ( $ this -> content ( ) ) ; return $ copy ; }
Copies the file to the provided destination and returns the copy .
22,055
public function content ( $ content = false ) { if ( $ content === false ) { return $ this -> adapter -> fileGetContents ( $ this -> path ) ; } $ this -> adapter -> filePutContents ( $ this -> path , $ content ) ; return $ this ; }
Gets or sets the content of the file .
22,056
public function append ( $ content ) { if ( $ this -> adapter -> filePutContents ( $ this -> path , $ content , FILE_APPEND ) === false ) { throw new FilesystemException ( "Cannot append content to the file '{$this->path}'" ) ; } return $ this ; }
Appends a content to the file .
22,057
public function extension ( $ extension = false ) { if ( $ extension === false ) { return $ this -> adapter -> extension ( $ this -> path ) ; } $ newName = $ this -> name ( ) ; $ index = strrpos ( $ newName , '.' ) ; if ( $ index !== false ) { $ newName = substr ( $ newName , 0 , $ index + 1 ) ; } else { $ newName .= '.' ; } $ newName .= $ extension ; return $ this -> name ( $ newName ) ; }
Gets or sets the file extension .
22,058
function getImplementations ( $ instance ) { $ rc = new ReflectionClass ( get_class ( $ instance ) ) ; $ interfaces = $ rc -> getInterfaces ( ) ; $ i = array ( ) ; foreach ( $ interfaces as $ name => $ crap ) { $ i [ ] = $ name ; } return $ i ; }
Get all the parents classes
22,059
public function read ( $ splash , $ session , $ sessionId ) { $ ini = new Ini ( ) ; $ store = $ session -> folder . DIRECTORY_SEPARATOR ; if ( ! is_array ( $ splash ) ) return false ; $ sfile = $ store . $ sessionId . ".ini" ; if ( ! $ ini -> isFile ( $ sfile ) ) { return false ; } $ ini -> chmod ( $ sfile , 0755 ) ; if ( ! $ ini -> readParams ( $ sfile ) ) { throw new \ Exception ( "Could not read the session configuration file" ) ; return false ; } $ sess = $ ini -> getParams ( $ sfile ) ; if ( ! is_array ( $ sess ) || empty ( $ sess ) ) { throw new \ Exception ( "Invalid session file" ) ; return false ; } $ object = new \ stdClass ; $ object -> session_id = $ sessionId ; $ object -> session_key = $ sess [ 'key' ] ; $ object -> session_ip = $ sess [ 'ip' ] ; $ object -> session_host = $ sess [ 'domain' ] ; $ object -> session_agent = $ sess [ 'agent' ] ; $ object -> session_token = $ sess [ 'token' ] ; $ object -> session_expires = $ sess [ 'expiry' ] ; $ object -> session_lastactive = $ sess [ 'active' ] ; $ object -> session_registry = $ sess [ 'registry' ] ; return $ object ; }
Reads session data from file
22,060
public function write ( $ userdata , $ splash , $ session , $ sessionId , $ expiry ) { $ ini = new Ini ( ) ; $ store = $ session -> folder . DIRECTORY_SEPARATOR ; if ( ! $ ini -> is ( $ store ) ) { if ( ! $ ini -> create ( $ store ) ) { throw new \ Exception ( "Could not create the $store folder. Please create this manually and check it hass writable permissions" ) ; return false ; } } if ( ! is_array ( $ splash ) ) return false ; $ sfile = $ store . $ sessionId . ".ini" ; if ( ! ( $ sini = $ ini -> create ( $ sfile ) ) ) { throw new \ Exception ( "Could not create the session file" ) ; return false ; } $ ini -> chmod ( $ sfile , 0755 ) ; $ splash [ 'expiry' ] = $ expiry ; $ splash [ 'active' ] = time ( ) ; $ splash [ 'key' ] = $ sessionId ; $ splash [ 'registry' ] = static :: quote ( "'" . $ userdata . "'" ) ; if ( ! $ ini -> write ( $ sfile , $ ini -> toIniString ( $ splash ) ) ) { throw new \ Exception ( "Could not write out to the configuration file" ) ; return false ; } return true ; }
Writes session data to file store
22,061
public function getGroupedAttributes ( ) { return array ( AbstractVoter :: GROUP_USER => array ( self :: VIEW , self :: CREATE_POST , self :: CREATE_TOPIC , self :: UPLOAD_FILE ) , AbstractVoter :: GROUP_MOD => array ( self :: EDIT_POST , self :: EDIT_TOPIC , self :: DELETE_POST , self :: DELETE_TOPIC , self :: MOVE_POST , self :: MOVE_TOPIC , self :: SPLIT_TOPIC , ) ) ; }
this will define the groups for the acl form later
22,062
public function getAccessSets ( ) { $ default = array ( ) ; $ guest = array ( self :: VIEW ) ; $ user = array_merge ( $ guest , array ( self :: CREATE_POST , self :: CREATE_TOPIC ) ) ; $ userFull = array_merge ( $ user , array ( self :: UPLOAD_FILE ) ) ; $ mod = array_merge ( $ userFull , array ( self :: EDIT_POST , self :: EDIT_TOPIC , self :: DELETE_POST , self :: DELETE_TOPIC , self :: MOVE_POST , self :: MOVE_TOPIC , self :: SPLIT_TOPIC , ) ) ; return array ( "default_1" => $ default , "default_2" => $ guest , "default_3" => $ user , "default_4" => $ userFull , "default_5" => $ mod ) ; }
this are the list of default access lists
22,063
public function getVal ( ) { if ( isset ( $ this -> value ) ) { return $ this -> value ; } if ( defined ( $ this -> alias ) ) { return constant ( $ this -> alias ) ; } return $ this -> default ; }
Get field value . Check if the variable is defined and return value or return default data if field not defined
22,064
public function printbshtml ( ) { $ bs = BBoostrapHelper :: getInstance ( ) ; return $ bs -> formgroup_input ( $ this -> name , $ this -> alias , $ this -> getVal ( ) , '' ) ; }
Print bootstrap HTML data
22,065
public function getStringForResponseSignature ( ) { return $ this -> headers [ SONIC_HEADER__TARGET_API ] . $ this -> headers [ SONIC_HEADER__DATE ] . $ this -> headers [ SONIC_HEADER__PLATFORM_GID ] . $ this -> headers [ SONIC_HEADER__SOURCE_GID ] . $ this -> headers [ SONIC_HEADER__RANDOM ] . $ this -> body ; }
returns string for response signature
22,066
protected function verifyDataFormat ( ) { if ( ! XSDDateTime :: validateXSDDateTime ( $ this -> headers [ SONIC_HEADER__DATE ] ) ) throw new MalformedRequestHeaderException ( "Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $ this -> headers [ SONIC_HEADER__DATE ] ) ; if ( ! XSDDateTime :: validateXSDDateTime ( $ this -> headers [ SONIC_HEADER__DATE ] ) ) throw new MalformedRequestHeaderException ( "Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $ this -> headers [ SONIC_HEADER__DATE ] ) ; return true ; }
verifies the format and content of the response
22,067
public function resolve ( $ value , $ default = 'value' ) { $ callable = $ this -> getCallable ( $ value ) ; if ( is_array ( $ callable ) ) { if ( is_callable ( $ callable [ 0 ] ) ) { return call_user_func_array ( $ callable [ 0 ] , $ callable [ 1 ] ) ; } else { return $ callable [ 0 ] ; } } return $ this -> fallback -> resolve ( $ value , $ default ) ; }
Attempts to resolve through the container or fallback on CallableResolver
22,068
public function dataValid ( ) { foreach ( new \ RecursiveIteratorIterator ( $ this , \ RecursiveIteratorIterator :: SELF_FIRST ) as $ child ) { if ( $ child instanceof FormElement && ! $ child -> dataValid ( ) ) { return false ; } } return true ; }
Check for occured errors
22,069
public function getValueStored ( $ key ) { if ( isset ( $ this -> storedValues [ $ key ] ) ) { return $ this -> storedValues [ $ key ] ; } else { return null ; } }
Stored values like from database
22,070
public function setTemplate ( $ templateName ) { if ( $ templateName instanceof MailTemplate ) { $ this -> template = $ templateName ; } elseif ( ! $ this -> template = $ this -> mailerManager -> getRepository ( ) -> findOneBy ( array ( 'name' => $ templateName ) ) ) { $ this -> template = $ this -> mailerManager -> createDefault ( $ templateName ) ; } return $ this ; }
Set a template to the mail
22,071
public function addValues ( $ values , $ prefix = null ) { if ( ! is_array ( $ values ) ) { throw new MailerException ( 'KarisMailer->setValues arrays' ) ; } foreach ( $ values as $ key => $ value ) { if ( is_array ( $ value ) ) { unset ( $ values [ $ key ] ) ; } elseif ( is_object ( $ value ) ) { try { $ values [ $ key ] = $ value ; } catch ( \ Exception $ e ) { unset ( $ values [ $ key ] ) ; } } elseif ( $ prefix ) { $ values [ $ prefix . $ key ] = $ value ; unset ( $ values [ $ key ] ) ; } } $ this -> values = array_merge ( $ this -> values , $ values ) ; return $ this ; }
Add values to the mail that will be available in the template
22,072
public function send ( ) { if ( ! $ this -> getTemplate ( ) -> getIsActive ( ) ) { return $ this ; } if ( ! $ this -> isRendered ( ) ) { $ this -> render ( ) ; } $ eventParams = array ( 'mailer' => $ this -> getMailer ( ) , 'message' => $ this -> getMessage ( ) , 'template' => $ this -> getTemplate ( ) ) ; $ this -> getMailer ( ) -> send ( $ this -> getMessage ( ) ) ; $ this -> sentMailer -> createSentMail ( $ this -> getTemplate ( ) ) ; return $ this ; }
Binds the mail with available data Uses Swift to send it .
22,073
public function render ( ) { if ( ! $ this -> getTemplate ( ) ) { throw new MailerException ( 'You must call setTemplate() to set a mail template' ) ; } $ template = $ this -> getTemplate ( ) ; $ template = $ this -> mailerManager -> updateTemplate ( $ template , $ this -> getValues ( ) ) ; $ replacements = $ this -> getReplacements ( ) ; $ templateFile = 'KRSMailBundle:mailTemplate:karisMailTemplate.html.twig' ; $ templateContent = $ this -> twig -> loadTemplate ( $ templateFile ) ; $ body = $ templateContent -> render ( array ( 'body' => strtr ( $ template -> getBody ( ) , $ replacements ) ) ) ; $ message = $ this -> getMessage ( ) ; $ from = array ( $ template -> getFromEmail ( ) => "KRS" ) ; $ message -> setSubject ( strtr ( $ template -> getSubject ( ) , $ replacements ) ) -> setBody ( strtr ( $ body , $ replacements ) , 'text/html' ) -> setContentType ( "text/html" ) -> setFrom ( $ from ) -> setTo ( $ this -> emailListToArray ( strtr ( $ template -> getToEmail ( ) , $ replacements ) ) ) ; if ( $ template -> getCcEmail ( ) ) { $ message -> setCc ( $ this -> emailListToArray ( strtr ( $ template -> getCcEmail ( ) , $ replacements ) ) ) ; } if ( $ template -> getBccEmail ( ) ) { $ message -> setBcc ( $ this -> emailListToArray ( strtr ( $ template -> getBccEmail ( ) , $ replacements ) ) ) ; } if ( $ template -> getReplyToEmail ( ) ) { $ message -> setReplyTo ( $ this -> emailListToArray ( strtr ( $ template -> getReplyToEmail ( ) , $ replacements ) ) ) ; } if ( $ template -> getSenderEmail ( ) ) { $ message -> setSender ( $ this -> emailListToArray ( strtr ( $ template -> getSenderEmail ( ) , $ replacements ) ) ) ; } $ this -> isRendered = true ; return $ this ; }
Builds the Swift message inserting vars in templates
22,074
public function getAll ( ) { $ benchmarks = array ( ) ; @ reset ( $ this -> results ) ; while ( list ( $ identifier , $ elapsed_time ) = @ each ( $ this -> results ) ) { if ( ! isset ( $ this -> temporary [ $ identifier ] ) ) { $ benchmarks [ $ identifier ] = $ elapsed_time ; } } return $ benchmarks ; }
Returns all registered benchmark - results .
22,075
public function filter ( $ response ) { $ filter = $ this -> _request -> getParam ( static :: FILTER_PARAMETER ) ; if ( ! is_string ( $ filter ) ) { return $ response ; } $ filterArray = $ this -> parse ( $ filter ) ; if ( $ filterArray === null ) { return $ response ; } $ partialResponse = $ this -> applyFilter ( $ response , $ filterArray ) ; return $ partialResponse ; }
Process filter from the request and apply over response to get the partial results
22,076
protected function parse ( $ filterString ) { $ length = strlen ( $ filterString ) ; if ( $ length == 0 || preg_match ( '/[^\w\[\],]+/' , $ filterString ) ) { return null ; } $ start = null ; $ current = [ ] ; $ stack = [ ] ; $ parent = [ ] ; $ currentElement = null ; for ( $ position = 0 ; $ position < $ length ; $ position ++ ) { if ( in_array ( $ filterString [ $ position ] , [ '[' , ']' , ',' ] ) ) { if ( $ start !== null ) { $ currentElement = substr ( $ filterString , $ start , $ position - $ start ) ; $ current [ $ currentElement ] = 1 ; } $ start = null ; } switch ( $ filterString [ $ position ] ) { case '[' : array_push ( $ parent , $ currentElement ) ; array_push ( $ stack , $ current ) ; $ current = [ ] ; break ; case ']' : $ temp = $ current ; $ current = array_pop ( $ stack ) ; $ current [ array_pop ( $ parent ) ] = $ temp ; break ; case ',' : break ; default : if ( $ start === null ) { $ start = $ position ; } } } if ( ! empty ( $ stack ) ) { return null ; } if ( $ start !== null ) { $ currentElement = substr ( $ filterString , $ start , $ position - $ start ) ; $ current [ $ currentElement ] = 1 ; } return $ current ; }
Parse filter string into associative array . Field names are returned as keys with values for scalar fields as 1 .
22,077
protected function applyFilter ( array $ responseArray , array $ filter ) { $ arrayIntersect = null ; if ( ! ( bool ) count ( array_filter ( array_keys ( $ responseArray ) , 'is_string' ) ) ) { foreach ( $ responseArray as $ key => & $ item ) { $ arrayIntersect [ $ key ] = $ this -> recursiveArrayCompare ( $ item , $ filter ) ; } } else { $ arrayIntersect = $ this -> recursiveArrayCompare ( $ responseArray , $ filter ) ; } return $ arrayIntersect ; }
Apply filter array
22,078
public static function remoteAppCall ( $ appId , \ Closure $ callback , \ Closure $ filterConfigCallback = null ) { if ( $ callback === null || ! $ callback instanceof \ Closure ) { throw new InvalidParamException ( "Invalid param: `callback`." ) ; } if ( $ appId !== Yii :: $ app -> id && isset ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] ) ) { if ( ! isset ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] ) ) { throw new InvalidParamException ( "Invalid param: `appId`." ) ; } if ( ! is_array ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] ) ) { throw new InvalidConfigException ( "Invalid config: Yii::$app->params[" . static :: $ remoteAppConfigs . "][$appId]." ) ; } if ( isset ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] [ 'class' ] ) ) { $ appClass = Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] [ 'class' ] ; unset ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] [ 'class' ] ) ; } else { $ appClass = get_called_class ( ) ; } $ yiiApp = Yii :: $ app ; $ yiiAliases = Yii :: $ aliases ; $ config = [ ] ; foreach ( Yii :: $ app -> params [ static :: $ remoteAppConfigs ] [ $ appId ] as $ configPath ) { $ config = ArrayHelper :: merge ( $ config , require ( Yii :: getAlias ( $ configPath ) ) ) ; } if ( $ filterConfigCallback !== null || $ filterConfigCallback instanceof \ Closure ) { $ config = call_user_func ( $ filterConfigCallback , $ config ) ; } $ app = new $ appClass ( $ config ) ; call_user_func ( $ callback , $ app ) ; unset ( $ app ) ; Yii :: $ app = $ yiiApp ; Yii :: $ aliases = $ yiiAliases ; unset ( $ yiiApp , $ yiiAliases ) ; } else { call_user_func ( $ callback , Yii :: $ app ) ; } }
Call callback function with a remote application .
22,079
public function getBinary ( ) : string { if ( is_null ( $ this -> bin ) ) { $ paths = array ( '/usr/bin/assimp' , '/usr/local/bin/assimp' , '~/bin/assimp' ) ; foreach ( $ paths as $ path ) { try { $ this -> setBinary ( $ path ) ; } catch ( \ InvalidArgumentException $ e ) { } } if ( ! $ this -> bin ) { throw new \ RuntimeException ( 'assimp-binary not found in ' . explode ( ', ' , $ paths ) , ErrorCodes :: FILE_NOT_FOUND ) ; } if ( ! is_executable ( $ this -> bin ) ) { throw new \ RuntimeException ( 'Found a binary file, but it is not executable: ' . $ this -> bin , ErrorCodes :: FILE_NOT_EXECUTABLE ) ; } } return $ this -> bin ; }
Get the path to the assimp binary
22,080
public function setBinary ( string $ bin ) : Command { if ( ! is_file ( $ bin ) ) { throw new \ InvalidArgumentException ( 'Binary file not exists: ' . $ bin , ErrorCodes :: FILE_NOT_FOUND ) ; } if ( ! is_executable ( $ bin ) ) { throw new \ InvalidArgumentException ( 'Binary file is not executable: ' . $ bin , ErrorCodes :: FILE_NOT_EXECUTABLE ) ; } $ this -> bin = $ bin ; return $ this ; }
Set the path to the assimp binary
22,081
private static function getCached ( CacheableInterface $ verb ) : ResultInterface { $ key = $ verb -> getCacheKey ( ) ; if ( array_key_exists ( $ key , self :: $ cache ) ) { return self :: $ cache [ $ key ] ; } return null ; }
Get a cached version of the verb
22,082
private static function addCached ( CacheableInterface $ verb , ResultInterface $ result ) : void { self :: $ cache [ $ verb -> getCacheKey ( ) ] = $ result ; }
Add a verb to the cache
22,083
public static function avatar ( $ email , $ size = null ) { $ url = sprintf ( '%s/avatar/%s' , self :: $ gravatarURL , md5 ( $ email ) ) ; if ( ! is_null ( $ size ) ) { $ url .= '?s=' . $ size ; } return $ url ; }
Get user avatar
22,084
public static function profile ( $ email ) { $ url = sprintf ( '%s/%s.json' , self :: $ gravatarURL , md5 ( $ email ) ) ; $ client = new Client ( ) ; return json_decode ( $ client -> get ( $ url ) -> getBody ( ) -> getContents ( ) ) ; }
Get user profile
22,085
protected function replaceHaving ( Query \ Expr \ Andx $ having , ColumnCollection $ columns , QueryBuilder $ queryBuilder ) { foreach ( $ having -> getParts ( ) as $ part ) { if ( $ part instanceof Query \ Expr \ Comparison ) { $ this -> replaceSingleHavingClause ( $ part , $ columns , $ queryBuilder ) ; } } $ queryBuilder -> resetDQLPart ( 'having' ) ; $ queryBuilder -> resetDQLPart ( 'groupBy' ) ; }
Replaces all having clauses and resets DQL s having part
22,086
protected function replaceSingleHavingClause ( Query \ Expr \ Comparison $ comparison , ColumnCollection $ columns , QueryBuilder $ queryBuilder ) { $ source = $ columns -> get ( $ comparison -> getLeftExpr ( ) ) -> getPaginatorSource ( ) ; $ param = $ comparison -> getRightExpr ( ) ; $ operator = $ this -> getOperator ( $ comparison -> getOperator ( ) ) ; $ expression = $ queryBuilder -> expr ( ) -> { $ operator } ( $ source , $ param ) ; $ queryBuilder -> andWhere ( $ expression ) ; }
Replaces a single having clause because scalar types are not supported in doctrine paginator by default
22,087
protected function resizeImage ( array $ format , Imagick $ image ) { $ maxWidth = array_key_exists ( 'max_width' , $ format ) ? $ format [ 'max_width' ] : $ this -> maxWidth ; $ maxHeight = array_key_exists ( 'max_height' , $ format ) ? $ format [ 'max_height' ] : $ this -> maxHeight ; if ( $ maxWidth > $ this -> maxWidth ) { $ maxWidth = $ this -> maxWidth ; } if ( $ maxHeight > $ this -> maxHeight ) { $ maxHeight = $ this -> maxHeight ; } $ image -> setimagebackgroundcolor ( '#000000' ) ; $ image -> resizeImage ( $ maxWidth , $ maxHeight , Imagick :: FILTER_LANCZOS , 1 , true ) ; return $ image ; }
Resize an image keeping its ratio
22,088
protected function resize ( Imagick $ image , $ width , $ height ) { $ image -> resizeImage ( $ width , $ height , Imagick :: FILTER_LANCZOS , 1 ) ; return $ image ; }
Resize an image keeping
22,089
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ style = new SymfonyStyle ( $ input , $ output ) ; $ this -> validator -> validate ( $ input , $ output , $ style ) ; foreach ( $ this -> commands as $ command ) { $ success = $ this -> executeCommand ( $ command , $ input , $ output , $ style ) ; } $ output -> writeLn ( '' ) ; $ style -> success ( "Procedure $this completed" ) ; return true ; }
Implemented from Command
22,090
private function revert ( $ output , $ input , $ style ) { for ( $ n = count ( $ this -> commandsExecuted ) ; $ n > 0 ; $ n -- ) { $ command = $ this -> commandsExecuted [ $ n - 1 ] ; if ( $ command -> hasPublicMethod ( 'revert' ) ) { $ output -> writeLn ( "Reverting $command" ) ; $ command -> revert ( ) ; continue ; } $ style -> warning ( "Command {$command->getName()} cannot be reverted, revert method is not defined" ) ; } $ this -> commandsExecuted = [ ] ; }
Reverts executed commands
22,091
public function DeleteOverwriteTables ( ) { $ Tables = array ( 'Activity' , 'Category' , 'Comment' , 'Conversation' , 'ConversationMessage' , 'Discussion' , 'Draft' , 'Invitation' , 'Media' , 'Message' , 'Photo' , 'Permission' , 'Rank' , 'Poll' , 'PollOption' , 'PollVote' , 'Role' , 'UserAuthentication' , 'UserComment' , 'UserConversation' , 'UserDiscussion' , 'UserMeta' , 'UserRole' ) ; SaveToConfig ( array ( 'Garden.Registration.DefaultRoles' => array ( ) , 'Garden.Registration.ApplicantRoleID' => 0 ) ) ; $ CurrentSubstep = GetValue ( 'CurrentSubstep' , $ this -> Data , 0 ) ; for ( $ i = $ CurrentSubstep ; $ i < count ( $ Tables ) ; $ i ++ ) { $ Table = $ Tables [ $ i ] ; $ Exists = Gdn :: Structure ( ) -> Table ( $ Table ) -> TableExists ( ) ; Gdn :: Structure ( ) -> Reset ( ) ; if ( ! $ Exists ) continue ; $ this -> Data [ 'CurrentStepMessage' ] = $ Table ; if ( $ Table == 'Permission' ) $ this -> SQL -> Delete ( $ Table , array ( 'RoleID <>' => 0 ) ) ; else $ this -> SQL -> Truncate ( $ Table ) ; if ( $ this -> Timer -> ElapsedTime ( ) > $ this -> MaxStepTime ) { $ this -> Data [ 'CurrentSubstep' ] = $ i + 1 ; return FALSE ; } } if ( isset ( $ this -> Data [ 'CurrentSubstep' ] ) ) unset ( $ this -> Data [ 'CurrentSubstep' ] ) ; $ this -> Data [ 'CurrentStepMessage' ] = '' ; return TRUE ; }
Remove the data from the appropriate tables when we are overwriting the forum .
22,092
public function GetCountSQL ( $ Aggregate , $ ParentTable , $ ChildTable , $ ParentColumnName = '' , $ ChildColumnName = '' , $ ParentJoinColumn = '' , $ ChildJoinColumn = '' ) { if ( ! $ ParentColumnName ) { switch ( strtolower ( $ Aggregate ) ) { case 'count' : $ ParentColumnName = "Count{$ChildTable}s" ; break ; case 'max' : $ ParentColumnName = "Last{$ChildTable}ID" ; break ; case 'min' : $ ParentColumnName = "First{$ChildTable}ID" ; break ; case 'sum' : $ ParentColumnName = "Sum{$ChildTable}s" ; break ; } } if ( ! $ ChildColumnName ) $ ChildColumnName = $ ChildTable . 'ID' ; if ( ! $ ParentJoinColumn ) $ ParentJoinColumn = $ ParentTable . 'ID' ; if ( ! $ ChildJoinColumn ) $ ChildJoinColumn = $ ParentJoinColumn ; $ Result = "update :_$ParentTable p set p.$ParentColumnName = ( select $Aggregate(c.$ChildColumnName) from :_$ChildTable c where p.$ParentJoinColumn = c.$ChildJoinColumn)" ; return $ Result ; }
Return SQL for updating a count .
22,093
public function GetCustomImportModel ( ) { $ Header = $ this -> GetImportHeader ( ) ; $ Source = GetValue ( 'Source' , $ Header , '' ) ; $ Result = NULL ; if ( substr_compare ( 'vbulletin' , $ Source , 0 , 9 , TRUE ) == 0 ) $ Result = new vBulletinImportModel ( ) ; elseif ( substr_compare ( 'vanilla 1' , $ Source , 0 , 9 , TRUE ) == 0 ) $ Result = new Vanilla1ImportModel ( ) ; if ( $ Result !== NULL ) $ Result -> ImportModel = $ this ; return $ Result ; }
Get a custom import model based on the import s source .
22,094
public function ProcessImportDb ( ) { $ TableNames = $ this -> SQL -> FetchTables ( ':_z%' ) ; if ( count ( $ TableNames ) == 0 ) { throw new Gdn_UserException ( 'Your database does not contain any import tables.' ) ; } $ Tables = array ( ) ; foreach ( $ TableNames as $ TableName ) { $ TableName = StringBeginsWith ( $ TableName , $ this -> Database -> DatabasePrefix , TRUE , TRUE ) ; $ DestTableName = StringBeginsWith ( $ TableName , 'z' , TRUE , TRUE ) ; $ TableInfo = array ( 'Table' => $ DestTableName ) ; $ ColumnInfos = $ this -> SQL -> FetchTableSchema ( $ TableName ) ; $ Columns = array ( ) ; foreach ( $ ColumnInfos as $ ColumnInfo ) { $ Columns [ GetValue ( 'Name' , $ ColumnInfo ) ] = Gdn :: Structure ( ) -> ColumnTypeString ( $ ColumnInfo ) ; } $ TableInfo [ 'Columns' ] = $ Columns ; $ Tables [ $ DestTableName ] = $ TableInfo ; } $ this -> Data [ 'Tables' ] = $ Tables ; return TRUE ; }
Process the import tables from the database .
22,095
public function RunStep ( $ Step = 1 ) { $ Started = $ this -> Stat ( 'Started' ) ; if ( $ Started === NULL ) $ this -> Stat ( 'Started' , microtime ( TRUE ) , 'time' ) ; $ Steps = $ this -> Steps ( ) ; $ LastStep = end ( array_keys ( $ Steps ) ) ; if ( ! isset ( $ Steps [ $ Step ] ) || $ Step > $ LastStep ) { return 'COMPLETE' ; } if ( ! $ this -> Timer ) { $ NewTimer = TRUE ; $ this -> Timer = new Gdn_Timer ( ) ; $ this -> Timer -> Start ( '' ) ; } if ( isset ( $ Steps [ 0 ] ) ) { call_user_func ( array ( $ this , $ Steps [ 0 ] ) ) ; } $ Method = $ Steps [ $ Step ] ; $ Result = call_user_func ( array ( $ this , $ Method ) ) ; if ( $ this -> GenerateSQL ( ) ) { $ this -> SaveSQL ( $ Method ) ; } $ ElapsedTime = $ this -> Timer -> ElapsedTime ( ) ; $ this -> Stat ( 'Time Spent on Import' , $ ElapsedTime , 'add' ) ; if ( isset ( $ NewTimer ) ) $ this -> Timer -> Finish ( '' ) ; if ( $ Result && ! array_key_exists ( $ Step + 1 , $ this -> Steps ( ) ) ) $ this -> Stat ( 'Finished' , microtime ( TRUE ) , 'time' ) ; return $ Result ; }
Run the step in the import .
22,096
public function Query ( $ Sql , $ Parameters = NULL ) { $ Db = Gdn :: Database ( ) ; $ Sql = str_replace ( array ( ':_z' , ':_' ) , array ( $ Db -> DatabasePrefix . self :: TABLE_PREFIX , $ Db -> DatabasePrefix ) , $ Sql ) ; if ( StringBeginsWith ( $ Sql , 'select' ) ) $ Type = 'select' ; elseif ( StringBeginsWith ( $ Sql , 'truncate' ) ) $ Type = 'truncate' ; elseif ( StringBeginsWith ( $ Sql , 'insert' ) ) $ Type = 'insert' ; elseif ( StringBeginsWith ( $ Sql , 'update' ) ) $ Type = 'update' ; elseif ( StringBeginsWith ( $ Sql , 'delete' ) ) $ Type = 'delete' ; else $ Type = 'select' ; if ( is_array ( $ Parameters ) ) $ this -> SQL -> NamedParameters ( $ Parameters ) ; $ Result = $ this -> SQL -> Query ( $ Sql , $ Type ) ; return $ Result ; }
Run a query replacing database prefixes .
22,097
public function SetCategoryPermissionIDs ( ) { $ Permissions = $ this -> SQL -> GetWhere ( 'Permission' , array ( 'JunctionColumn' => 'PermissionCategoryID' , 'JunctionID >' => 0 ) ) -> ResultArray ( ) ; $ CategoryIDs = array ( ) ; foreach ( $ Permissions as $ Row ) { $ CategoryIDs [ $ Row [ 'JunctionID' ] ] = $ Row [ 'JunctionID' ] ; } $ Root = CategoryModel :: Categories ( - 1 ) ; $ this -> _SetCategoryPermissionIDs ( $ Root , $ Root [ 'CategoryID' ] , $ CategoryIDs ) ; }
Set the category permissions based on the permission table .
22,098
public function readParams ( $ filename ) { if ( ! array_key_exists ( $ filename , $ this -> namespace ) ) { if ( file_exists ( $ filename ) ) { if ( ( $ this -> namespace [ $ filename ] = parse_ini_file ( $ filename , true ) ) === FALSE ) { throw new Exception ( "Could not Parse the ini file {$filename}" ) ; return false ; } else { return $ this -> namespace [ $ filename ] ; } } else { return [ ] ; } } else { return $ this -> namespace [ $ filename ] ; } }
Parses an INI configuration file
22,099
public function saveParams ( array $ parameters , $ environment = "" ) { foreach ( $ parameters as $ namespace => $ section ) { $ _file = PATH_CONFIG . DS . strtolower ( $ namespace ) . ".ini" ; $ _globals = "" ; foreach ( $ section as $ key => $ params ) { if ( ! empty ( $ params ) && is_array ( $ params ) ) { $ _globals .= static :: toIniString ( $ params , $ key ) ; } } if ( ! empty ( $ _globals ) ) { if ( ! $ this -> isFile ( $ _file ) ) { if ( ! $ this -> create ( $ _file ) ) { throw new \ Exception ( "Could not create the configuration file {$_file}. Please check you have sufficient permission to do this" ) ; return false ; } } if ( ! $ this -> write ( $ _file , $ _globals ) ) { throw new \ Exception ( t ( "Could not write out to the configuration file" ) ) ; return false ; } } } return true ; }
Save configuration param section or sections to an ini file