idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
3,100 | protected static function determineHintLocation ( $ hint ) { if ( is_string ( $ hint ) && file_exists ( $ hint ) ) { $ path = $ hint ; } elseif ( is_object ( $ hint ) || class_exists ( $ hint ) ) { $ r = new \ ReflectionClass ( $ hint ) ; $ path = $ r -> getFileName ( ) ; } $ path = realpath ( $ path ) ; if ( false ===... | Convert whatever hint we got into a usable file path . |
3,101 | public function get ( $ name ) { if ( ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( self :: MSG_EXTENSION_NAME , 220 ) ; } if ( ! $ this -> offsetExists ( strtolower ( $ name ) ) ) { throw new \ LogicException ( sprintf ( self :: MSG_NO_EXTENSION_TOGET , $ name ) , 221 ) ; } return parent :: offsetG... | Get a new extension method |
3,102 | public function add ( $ collection ) { if ( ! is_array ( $ collection ) and ! ( $ collection instanceof \ Traversable ) ) { throw new \ InvalidArgumentException ( self :: MSG_NOT_ITERABLE , 230 ) ; } foreach ( $ collection as $ name => $ closure ) { $ this -> set ( $ name , $ closure ) ; } return $ this ; } | Add a list of extension |
3,103 | public function onKernelRequest ( ) { foreach ( $ this -> kernel -> getBundles ( ) as $ bundle ) { $ bundlePathPackage = new BundlePathPackage ( $ this -> versionStrategy ) ; $ bundlePathPackage -> setBundlePath ( $ bundle -> getName ( ) ) ; $ this -> assetsPackages -> addPackage ( $ bundle -> getName ( ) , $ bundlePat... | Inject custom Asset package to Kernel assets helper |
3,104 | public function getRows ( EntityDescriptor $ ed ) { $ r = array ( ) ; foreach ( $ ed -> getFieldsName ( ) as $ field ) { $ r += $ this -> getErrorsForField ( $ ed , $ field ) ; } return array_unique ( $ r ) ; } | Get all exception string this entity could generate |
3,105 | public function getErrorsForField ( EntityDescriptor $ ed , $ field ) { $ r = array ( ) ; foreach ( static :: $ testedValues as $ value ) { try { $ ed -> validateFieldValue ( $ field , $ value ) ; } catch ( InvalidFieldException $ e ) { $ r [ $ e -> getKey ( ) ] = $ e ; } } return $ r ; } | Get all exception this field could generate |
3,106 | public function all ( ) : array { $ result = [ ] ; foreach ( $ this -> headers as $ header ) { $ result [ $ header -> getName ( ) ] = $ header -> getValuesAsArray ( ) ; } return $ result ; } | Returns all values of all headers as array indexed by header name . |
3,107 | public function get ( string $ name , $ default = null ) { $ key = strtolower ( $ name ) ; if ( ! array_key_exists ( $ key , $ this -> headers ) ) { return $ default ; } return $ this -> headers [ $ key ] -> getValuesAsString ( ) ; } | Returns the value of a header as string . |
3,108 | public function getValues ( string $ name , array $ default = [ ] ) : array { $ key = strtolower ( $ name ) ; if ( ! array_key_exists ( $ key , $ this -> headers ) ) { return $ default ; } return $ this -> headers [ $ key ] -> getValuesAsArray ( ) ; } | Returns the value of a header as an array . |
3,109 | public function set ( string $ name , $ value , bool $ replace = true ) { $ key = strtolower ( $ name ) ; if ( $ replace || ! array_key_exists ( $ key , $ this -> headers ) ) { $ this -> headers [ $ key ] = new Header ( $ name , $ value ) ; } else { $ this -> headers [ $ key ] -> addValue ( $ value ) ; } } | Sets the value of a header . |
3,110 | protected function parseHeader ( $ relation , $ default = false ) { if ( false !== $ this -> header ) { $ attributes = explode ( '.' , $ this -> header ) ; foreach ( $ attributes as $ attribute ) { if ( isset ( $ relation -> { $ attribute } ) ) { $ relation = $ relation -> { $ attribute } ; } } } if ( ! is_string ( $ r... | Parses and retrieves header based on given template |
3,111 | public function validate ( $ subject ) : bool { if ( \ is_array ( $ this -> schema [ 'dependencies' ] ) && count ( $ this -> schema [ 'dependencies' ] ) > 0 ) { foreach ( $ this -> schema [ 'dependencies' ] as $ propertyName => $ dependentProperties ) { if ( \ is_int ( \ array_keys ( $ dependentProperties ) [ 0 ] ) ) {... | Validates subject against dependencies |
3,112 | private function validateClassicDependencies ( array $ subject , string $ propertyName , array $ dependentProperties ) : bool { if ( \ is_string ( $ propertyName ) && \ is_array ( $ dependentProperties ) ) { if ( \ array_key_exists ( $ propertyName , $ subject ) ) { foreach ( $ dependentProperties as $ propertyName ) {... | Checks classic dependencies |
3,113 | private function validateSchemaDependencies ( array $ subject , string $ propertyName , array $ dependencySchema ) : bool { if ( \ is_string ( $ propertyName ) && \ is_array ( $ dependencySchema ) ) { if ( \ array_key_exists ( $ propertyName , $ subject ) ) { $ dependencySchema [ 'type' ] = 'object' ; $ nodeValidator =... | Checks schema dependencies |
3,114 | public function set_config ( $ key , $ value ) { \ Arr :: set ( $ this -> config , $ key , $ value ) ; return $ this ; } | Set a driver config setting . |
3,115 | public function html_body ( $ html , $ generate_alt = null , $ auto_attach = null ) { $ this -> config [ 'is_html' ] = true ; $ generate_alt = is_bool ( $ generate_alt ) ? $ generate_alt : $ this -> config [ 'generate_alt' ] ; $ auto_attach = is_bool ( $ auto_attach ) ? $ auto_attach : $ this -> config [ 'auto_attach' ... | Sets the html body and optionally a generated alt body . |
3,116 | public function subject ( $ subject ) { if ( $ this -> config [ 'encode_headers' ] ) { $ subject = $ this -> encode_mimeheader ( ( string ) $ subject ) ; } $ this -> subject = ( string ) $ subject ; return $ this ; } | Sets the message subject |
3,117 | public function from ( $ email , $ name = false ) { $ this -> config [ 'from' ] [ 'email' ] = ( string ) $ email ; $ this -> config [ 'from' ] [ 'name' ] = ( is_string ( $ name ) ) ? $ name : false ; if ( $ this -> config [ 'encode_headers' ] and $ this -> config [ 'from' ] [ 'name' ] ) { $ this -> config [ 'from' ] [ ... | Sets the from address and name |
3,118 | protected function add_to_list ( $ list , $ email , $ name = false ) { if ( ! is_array ( $ email ) ) { $ email = ( is_string ( $ name ) ) ? array ( $ email => $ name ) : array ( $ email ) ; } foreach ( $ email as $ _email => $ name ) { if ( is_numeric ( $ _email ) ) { $ _email = $ name ; $ name = false ; } if ( $ this ... | Add to a recipients list . |
3,119 | protected function clear_list ( $ list ) { is_array ( $ list ) or $ list = array ( $ list ) ; foreach ( $ list as $ _list ) { $ this -> { $ _list } = array ( ) ; } } | Clear the a recipient list . |
3,120 | public function header ( $ header , $ value = null ) { if ( is_array ( $ header ) ) { foreach ( $ header as $ _header => $ _value ) { empty ( $ _value ) or $ this -> extra_headers [ $ _header ] = $ _value ; } } else { empty ( $ value ) or $ this -> extra_headers [ $ header ] = $ value ; } return $ this ; } | Sets custom headers . |
3,121 | protected function find_attachment ( $ file ) { foreach ( $ this -> get_config ( 'attach_paths' ) as $ path ) { if ( is_file ( $ path . $ file ) ) { return $ path . $ file ; } } throw new \ AttachmentNotFoundException ( 'Email attachment not found: ' . $ file ) ; } | Finds an attachment . |
3,122 | public function string_attach ( $ contents , $ filename , $ cid = null , $ inline = false , $ mime = null ) { $ disp = ( $ inline ) ? 'inline' : 'attachment' ; $ cid = empty ( $ cid ) ? 'cid:' . md5 ( $ filename ) : trim ( $ cid ) ; $ cid = strpos ( $ cid , 'cid:' ) === 0 ? $ cid : 'cid:' . $ cid ; $ mime or $ mime = s... | Attach a file using string input |
3,123 | protected static function attachment_mime ( $ file ) { static $ mimes = false ; if ( ! $ mimes ) { $ mimes = \ Config :: load ( 'mimes' ) ; } $ ext = pathinfo ( $ file , PATHINFO_EXTENSION ) ; $ mime = \ Arr :: get ( $ mimes , $ ext , 'application/octet-stream' ) ; is_array ( $ mime ) and $ mime = reset ( $ mime ) ; re... | Get the mimetype for an attachment |
3,124 | protected function validate_addresses ( ) { $ failed = array ( ) ; foreach ( array ( 'to' , 'cc' , 'bcc' ) as $ list ) { foreach ( $ this -> { $ list } as $ recipient ) { if ( ! filter_var ( $ recipient [ 'email' ] , FILTER_VALIDATE_EMAIL ) ) { $ failed [ $ list ] [ ] = $ recipient ; } } } if ( count ( $ failed ) === 0... | Validates all the email addresses . |
3,125 | protected function set_boundaries ( ) { $ uniq_id = md5 ( uniqid ( microtime ( true ) ) ) ; $ this -> boundaries [ 0 ] = 'B1_' . $ uniq_id ; $ this -> boundaries [ 1 ] = 'B2_' . $ uniq_id ; $ this -> boundaries [ 2 ] = 'B3_' . $ uniq_id ; } | Sets unique message boundaries |
3,126 | protected function get_header ( $ header = null , $ formatted = true ) { if ( $ header === null ) { return $ this -> headers ; } if ( array_key_exists ( $ header , $ this -> headers ) ) { $ prefix = ( $ formatted ) ? $ header . ': ' : '' ; $ suffix = ( $ formatted ) ? $ this -> config [ 'newline' ] : '' ; return $ pref... | Gets the header |
3,127 | protected function encode_mimeheader ( $ header ) { $ transfer_encoding = ( $ this -> config [ 'encoding' ] === 'quoted-printable' ) ? 'Q' : 'B' ; return mb_encode_mimeheader ( $ header , $ this -> config [ 'charset' ] , $ transfer_encoding , $ this -> config [ 'newline' ] ) ; } | Encodes a mimeheader . |
3,128 | protected function get_attachment_headers ( $ type , $ boundary ) { $ return = '' ; $ newline = $ this -> config [ 'newline' ] ; foreach ( $ this -> attachments [ $ type ] as $ attachment ) { $ return .= '--' . $ boundary . $ newline ; $ return .= 'Content-Type: ' . $ attachment [ 'mime' ] . '; name="' . $ attachment [... | Get the attachment headers |
3,129 | protected function get_mail_type ( ) { $ return = $ this -> config [ 'is_html' ] ? 'html' : 'plain' ; $ alt = trim ( $ this -> alt_body ) ; $ return .= ( $ this -> config [ 'is_html' ] and ! empty ( $ alt ) ) ? '_alt' : '' ; $ return .= ( $ this -> config [ 'is_html' ] and count ( $ this -> attachments [ 'inline' ] ) )... | Returns the mail s type |
3,130 | protected function get_content_type ( $ mail_type , $ boundary ) { $ related = $ this -> config [ 'force_mixed' ] ? 'multipart/mixed; ' : 'multipart/related; ' ; switch ( $ mail_type ) { case 'plain' : return 'text/plain' ; case 'plain_attach' : case 'html_attach' : return $ related . $ boundary ; case 'html' : return ... | Returns the content type |
3,131 | protected static function wrap_text ( $ message , $ length , $ newline , $ is_html = true ) { $ length = ( $ length > 76 ) ? 76 : $ length ; $ is_html and $ message = preg_replace ( '/[\r|\n|\t]/m' , '' , $ message ) ; $ message = wordwrap ( $ message , $ length , $ newline , false ) ; return $ message ; } | Wraps the body or alt text |
3,132 | protected static function prep_newlines ( $ string , $ newline = null ) { $ newline or $ newline = \ Config :: get ( 'email.defaults.newline' , "\n" ) ; $ replace = array ( "\r\n" => "\n" , "\n\r" => "\n" , "\r" => "\n" , "\n" => $ newline , ) ; foreach ( $ replace as $ from => $ to ) { $ string = str_replace ( $ from ... | Standardize newlines . |
3,133 | protected static function encode_string ( $ string , $ encoding , $ newline = null ) { $ newline or $ newline = \ Config :: get ( 'email.defaults.newline' , "\n" ) ; switch ( $ encoding ) { case 'quoted-printable' : return quoted_printable_encode ( $ string ) ; case '7bit' : case '8bit' : return static :: prep_newlines... | Encodes a string in the given encoding . |
3,134 | protected static function format_addresses ( $ addresses ) { $ return = array ( ) ; foreach ( $ addresses as $ recipient ) { $ recipient [ 'name' ] and $ recipient [ 'email' ] = '"' . $ recipient [ 'name' ] . '" <' . $ recipient [ 'email' ] . '>' ; $ return [ ] = $ recipient [ 'email' ] ; } return join ( ', ' , $ retur... | Returns a formatted string of email addresses . |
3,135 | protected static function generate_alt ( $ html , $ wordwrap , $ newline ) { $ html = preg_replace ( '/[ | ]{2,}/m' , ' ' , $ html ) ; $ html = trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/s' , '' , $ html ) ) ) ; $ lines = explode ( $ newline , $ html ) ; $ result = array ( ) ; $ fir... | Generates an alt body |
3,136 | public function selectChild ( $ name ) { if ( isset ( $ this -> stack [ $ this -> index ] -> value [ $ name ] ) === false ) { return false ; } $ this -> stack [ $ this -> index + 1 ] = ( object ) [ 'key' => $ name , 'value' => & $ this -> stack [ $ this -> index ] -> value [ $ name ] ] ; $ this -> index ++ ; return tru... | Select a child of the current context by name . |
3,137 | public static function forge ( $ name = 'default' , array $ config = array ( ) ) { if ( $ exists = static :: instance ( $ name ) ) { \ Error :: notice ( 'Fieldset with this name exists already, cannot be overwritten.' ) ; return $ exists ; } static :: $ _instances [ $ name ] = new static ( $ name , $ config ) ; if ( $ ... | Create Fieldset object |
3,138 | public function validation ( $ instance = true ) { if ( $ instance instanceof Validation ) { $ this -> validation = $ instance ; return $ instance ; } if ( empty ( $ this -> validation ) and $ instance === true ) { $ this -> validation = \ Validation :: forge ( $ this ) ; } return $ this -> validation ; } | Get related Validation instance or create it |
3,139 | public function form ( $ instance = true ) { if ( $ instance instanceof Form ) { $ this -> form = $ instance ; return $ instance ; } if ( empty ( $ this -> form ) and $ instance === true ) { $ this -> form = \ Form :: forge ( $ this ) ; } return $ this -> form ; } | Get related Form instance or create it |
3,140 | public function set_parent ( Fieldset $ fieldset ) { if ( ! empty ( $ this -> fieldset_parent ) ) { throw new \ RuntimeException ( 'Fieldset already has a parent, belongs to "' . $ this -> parent ( ) -> name . '".' ) ; } $ children = $ fieldset -> children ( ) ; while ( $ child = array_shift ( $ children ) ) { if ( $ c... | Set the parent Fieldset instance |
3,141 | protected function add_child ( Fieldset $ fieldset ) { if ( is_null ( $ fieldset -> fieldset_tag ) ) { $ fieldset -> fieldset_tag = 'fieldset' ; } $ this -> fieldset_children [ $ fieldset -> name ] = $ fieldset ; return $ this ; } | Add a child Fieldset instance |
3,142 | public function add ( $ name , $ label = '' , array $ attributes = array ( ) , array $ rules = array ( ) ) { if ( $ name instanceof Fieldset_Field ) { if ( $ name -> name == '' or $ this -> field ( $ name -> name ) !== false ) { throw new \ RuntimeException ( 'Fieldname empty or already exists in this Fieldset: "' . $ ... | Factory for Fieldset_Field objects |
3,143 | public function add_before ( $ name , $ label = '' , array $ attributes = array ( ) , array $ rules = array ( ) , $ fieldname = null ) { $ field = $ this -> add ( $ name , $ label , $ attributes , $ rules ) ; unset ( $ this -> fields [ $ field -> name ] ) ; if ( ! \ Arr :: insert_before_key ( $ this -> fields , array (... | Add a new Fieldset_Field before an existing field in a Fieldset |
3,144 | public function add_after ( $ name , $ label = '' , array $ attributes = array ( ) , array $ rules = array ( ) , $ fieldname = null ) { $ field = $ this -> add ( $ name , $ label , $ attributes , $ rules ) ; unset ( $ this -> fields [ $ field -> name ] ) ; if ( ! \ Arr :: insert_after_key ( $ this -> fields , array ( $... | Add a new Fieldset_Field after an existing field in a Fieldset |
3,145 | public function delete ( $ name ) { if ( isset ( $ this -> field [ $ name ] ) ) { unset ( $ this -> field [ $ name ] ) ; } return $ this ; } | Delete a field instance |
3,146 | public function field ( $ name = null , $ flatten = false , $ tabular_form = true ) { if ( $ name === null ) { $ fields = $ this -> fields ; if ( $ flatten ) { foreach ( $ this -> fieldset_children as $ fs_name => $ fieldset ) { if ( $ tabular_form or ! $ fieldset -> get_tabular_form ( ) ) { \ Arr :: insert_after_key (... | Get Field instance |
3,147 | public function add_model ( $ class , $ instance = null , $ method = 'set_form_fields' ) { $ this -> validation ( ) -> add_callable ( $ class ) ; if ( ( is_string ( $ class ) and is_callable ( $ callback = array ( '\\' . $ class , $ method ) ) ) || is_callable ( $ callback = array ( $ class , $ method ) ) ) { $ instanc... | Add a model s fields The model must have a method set_form_fields that takes this Fieldset instance and adds fields to it . |
3,148 | public function populate ( $ input , $ repopulate = false ) { $ fields = $ this -> field ( null , true , false ) ; foreach ( $ fields as $ f ) { if ( is_array ( $ input ) or $ input instanceof \ ArrayAccess ) { $ name = str_replace ( array ( '[' , ']' ) , array ( '.' , '' ) , $ f -> name ) ; $ value = \ Arr :: get ( $ ... | Populate the form s values using an input array or object |
3,149 | public function build ( $ action = null ) { $ attributes = $ this -> get_config ( 'form_attributes' ) ; if ( $ action and ( $ this -> fieldset_tag == 'form' or empty ( $ this -> fieldset_tag ) ) ) { $ attributes [ 'action' ] = $ action ; } $ open = ( $ this -> fieldset_tag == 'form' or empty ( $ this -> fieldset_tag ) ... | Build the fieldset HTML |
3,150 | public function enable ( $ name = null ) { if ( ! $ this -> field ( $ name ) ) { throw new \ RuntimeException ( 'Field "' . $ name . '" does not exist in this Fieldset.' ) ; } if ( isset ( $ this -> disabled [ $ name ] ) ) { unset ( $ this -> disabled [ $ name ] ) ; } return $ this ; } | Enable a disabled field from being build |
3,151 | public function disable ( $ name = null ) { if ( ! $ this -> field ( $ name ) ) { throw new \ RuntimeException ( 'Field "' . $ name . '" does not exist in this Fieldset.' ) ; } isset ( $ this -> disabled [ $ name ] ) or $ this -> disabled [ $ name ] = $ name ; return $ this ; } | Disable a field from being build |
3,152 | public function signinAction ( Request $ request ) { try { $ data = $ this -> getAuthClientIdentifiers ( $ request ) ; extract ( $ data ) ; if ( ! ( ( $ client = $ this -> clientProvider -> getClient ( $ client_id ) ) && $ this -> clientProvider -> isValid ( $ client , $ redirect_uri ) ) ) { throw new SoauthException (... | verify authentication request and display entry point to authenticate |
3,153 | public function generate ( ) { $ alphabetLastIndex = strlen ( $ this -> alphabet ) - 1 ; $ code = '' ; for ( $ i = 0 ; $ i < $ this -> length ; $ i ++ ) { $ code .= $ this -> alphabet [ rand ( 0 , $ alphabetLastIndex ) ] ; } return $ code ; } | Returns pseudo - random code consisting of this generator alphabet letters and it s length |
3,154 | public static function EndsWithValidTldString ( string & $ stringToCheck , bool $ convertUniCode = false ) : bool { if ( $ convertUniCode ) { $ stringToCheck = idnToASCII ( $ stringToCheck ) ; } return ( bool ) \ preg_match ( '~\.(' . static :: DOUBLE_TLDS . '|' . static :: KNOWN_FORMAT . ')\.?$~i' , $ stringToCheck ) ... | Returns if the defined string ends with a substring defined by characters usable as a TLD . |
3,155 | public function getModelPersister ( $ modelName ) { if ( ! isset ( $ this -> persisters [ $ modelName ] ) ) { $ class = $ this -> manager -> getClassMetadata ( $ modelName ) ; $ this -> persisters [ $ modelName ] = new ModelPersister ( $ this -> manager , $ this , $ class ) ; } return $ this -> persisters [ $ modelName... | Get the multi - model persister instance for the given multi - model name . |
3,156 | protected function saveSpecificModel ( $ model , $ managerName , $ id ) { $ class = $ this -> manager -> getClassMetadata ( get_class ( $ model ) ) ; $ pool = $ this -> manager -> getPool ( ) ; $ modelManager = call_user_func ( array ( $ model , 'get' . ucfirst ( $ managerName ) ) ) ; call_user_func ( array ( $ modelMa... | Persist a model his manager doctrine . |
3,157 | public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler ( $ Sender ) { if ( in_array ( $ Sender -> Application ( ) , array ( 'vanilla' , 'conversations' ) ) || ( $ Sender -> Application ( ) == 'dashboard' && in_array ( $ Sender -> Controller ( ) , array ( 'Activity' , 'Profile' , 'Search' ) ) ) ) { Gdn :: PluginMana... | Remove plugins that are not mobile friendly! |
3,158 | public function Base_Render_Before ( $ Sender ) { if ( IsMobile ( ) && is_object ( $ Sender -> Head ) ) { $ Sender -> Head -> AddTag ( 'meta' , array ( 'name' => 'viewport' , 'content' => "width=device-width,minimum-scale=1.0,maximum-scale=1.0" ) ) ; $ Sender -> Head -> AddString ( '<script type="text/javascript"> //... | Add mobile meta info . Add script to hide iPhone browser bar on pageload . |
3,159 | private function DiscussionsClickable ( $ Sender ) { if ( property_exists ( $ Sender , 'Head' ) && is_object ( $ Sender -> Head ) ) { $ Sender -> Head -> AddString ( '<script type="text/javascript"> jQuery(document).ready(function($) { $("ul.DataList li.Item").click(function() { var href = $(this).find("... | Increases clickable area on a discussions list . |
3,160 | public function startBar ( $ originalTable , $ newTable , $ collection , $ new = false ) { static $ even = false ; $ this -> bar = $ this -> output -> createProgressBar ( count ( $ collection ) ) ; $ this -> setUpLabel ( $ originalTable , $ newTable , $ new , $ even ) ; $ even = ! $ even ; } | Set up the bar and the label . |
3,161 | private function setUpLabel ( $ originalTable , $ newTable , $ new , $ even ) { $ bgColor = $ this -> getRowColor ( $ even ) ; $ new = $ new ? '<fg=green;bg=' . $ bgColor . '>NEW</> ' : '' ; $ name = $ originalTable . ' -> ' . $ newTable ; $ tabs = $ this -> getTabs ( $ name , $ new ) ; $ label = '<fg=black;bg=' . $ bg... | Set up the format for the progress bar . |
3,162 | private function getTabs ( $ string , $ new ) { $ length = strlen ( $ string ) ; $ max = $ new ? 56 : 60 ; $ range = range ( 1 , $ max - $ length ) ; $ tabs = '' ; foreach ( $ range as $ item ) { $ tabs .= " " ; } return $ tabs ; } | Determine the spacing needed after the label for the bars to appear in line . |
3,163 | public function save ( $ object ) { if ( is_array ( $ object ) ) { $ objectData = $ object ; if ( isset ( $ object [ 'id' ] ) && $ object [ 'id' ] > 0 ) { $ object = $ this -> find ( $ object [ 'id' ] ) ; } else { $ object = new Forum ( ) ; } if ( isset ( $ objectData [ 'parent' ] ) ) { $ parent = $ this -> find ( $ ob... | save a Forum you can pass the Site object or an array with the fields if you pass an array the keys must be with underscore and not with CamelCase |
3,164 | public function Base_AfterReactions_Handler ( $ Sender , $ Args ) { if ( ! $ this -> SocialReactions ( ) ) return ; echo Gdn_Theme :: BulletItem ( 'Share' ) ; $ this -> AddReactButton ( $ Sender , $ Args ) ; } | Add Facebook option to the row . |
3,165 | protected function AddReactButton ( $ Sender , $ Args ) { if ( $ this -> AccessToken ( ) ) { $ CssClass = 'ReactButton Hijack' ; } else { $ CssClass = 'ReactButton PopupWindow' ; } echo ' ' . Anchor ( Sprite ( 'ReactFacebook' , 'ReactSprite' ) , Url ( "post/facebook/{$Args['RecordType']}?id={$Args['RecordID']}" , TRUE ... | Output Quote link . |
3,166 | public function registerHandler ( string $ queryClass , string $ serviceName ) : void { if ( ! Validate :: implementsInterface ( $ queryClass , Query :: class ) ) { $ message = sprintf ( 'Invalid query class: %s' , $ queryClass ) ; throw new DomainException ( $ message ) ; } $ type = Type :: create ( $ queryClass ) -> ... | Registers a query handler |
3,167 | private function resolveFilename ( $ file ) { if ( empty ( $ file ) ) { return null ; } if ( ( $ file instanceof UploadedFileInterface && $ file -> getError ( ) === 0 ) || $ file instanceof StreamableInterface ) { return StreamWrapper :: getFilename ( $ file -> getStream ( ) ) ; } if ( is_array ( $ file ) ) { if ( ! is... | Internal method to fetch filename using multiple input formats . |
3,168 | private function isUploaded ( $ file ) : bool { if ( is_string ( $ file ) ) { return is_uploaded_file ( $ file ) ; } if ( is_array ( $ file ) ) { return isset ( $ file [ 'tmp_name' ] ) && ( is_uploaded_file ( $ file [ 'tmp_name' ] ) || isset ( $ file [ 'uploaded' ] ) ) ; } if ( $ file instanceof UploadedFileInterface )... | Check if file being uploaded . |
3,169 | public function findSupportedModelTransformer ( $ object , $ targetClass , ContextInterface $ context = null ) { if ( is_object ( $ object ) && ( $ objectTransformer = $ this -> findSupportedObjectTransformer ( get_class ( $ object ) , $ targetClass ) ) ) { return $ objectTransformer ; } foreach ( $ this -> getModelTra... | Finds and returns model transformer which supports specified object and target class . |
3,170 | private function findSupportedObjectTransformer ( $ supportedClass , $ targetClass ) { $ objectTransformers = $ this -> getObjectTransformers ( ) ; if ( isset ( $ objectTransformers [ $ supportedClass ] ) && isset ( $ objectTransformers [ $ supportedClass ] [ $ targetClass ] ) ) { return $ objectTransformers [ $ suppor... | Tries to find supported object transformer . |
3,171 | public static function json ( $ index = null , $ default = null ) { static :: $ json === null and static :: hydrate_raw_input ( 'json' ) ; return ( func_num_args ( ) === 0 ) ? static :: $ json : \ Arr :: get ( static :: $ json , $ index , $ default ) ; } | Get the request body interpreted as JSON . |
3,172 | public static function xml ( $ index = null , $ default = null ) { static :: $ xml === null and static :: hydrate_raw_input ( 'xml' ) ; return ( func_num_args ( ) === 0 ) ? static :: $ xml : \ Arr :: get ( static :: $ xml , $ index , $ default ) ; } | Get the request body interpreted as XML . |
3,173 | public static function real_ip ( $ default = '0.0.0.0' , $ exclude_reserved = false ) { static $ server_keys = null ; if ( empty ( $ server_keys ) ) { $ server_keys = array ( 'HTTP_CLIENT_IP' , 'REMOTE_ADDR' ) ; if ( \ Config :: get ( 'security.allow_x_headers' , false ) ) { $ server_keys = array_merge ( array ( 'HTTP_... | Get the real ip address of the user . Even if they are using a proxy . |
3,174 | public static function protocol ( ) { if ( static :: server ( 'HTTPS' ) == 'on' or static :: server ( 'HTTPS' ) == 1 or static :: server ( 'SERVER_PORT' ) == 443 or ( \ Config :: get ( 'security.allow_x_headers' , false ) and static :: server ( 'HTTP_X_FORWARDED_PROTO' ) == 'https' ) or ( \ Config :: get ( 'security.al... | Return s the protocol that the request was made with |
3,175 | public static function get ( $ index = null , $ default = null ) { return ( func_num_args ( ) === 0 ) ? $ _GET : \ Arr :: get ( $ _GET , $ index , $ default ) ; } | Gets the specified GET variable . |
3,176 | public static function file ( $ index = null , $ default = null ) { return ( func_num_args ( ) === 0 ) ? $ _FILES : \ Arr :: get ( $ _FILES , $ index , $ default ) ; } | Fetch an item from the FILE array |
3,177 | public static function param ( $ index = null , $ default = null ) { static :: $ input === null and static :: hydrate ( ) ; return \ Arr :: get ( static :: $ input , $ index , $ default ) ; } | Fetch an item from either the GET POST PUT PATCH or DELETE array |
3,178 | public static function server ( $ index = null , $ default = null ) { return ( func_num_args ( ) === 0 ) ? $ _SERVER : \ Arr :: get ( $ _SERVER , strtoupper ( $ index ) , $ default ) ; } | Fetch an item from the SERVER array |
3,179 | public static function headers ( $ index = null , $ default = null ) { static $ headers = null ; if ( $ headers === null ) { if ( ! function_exists ( 'getallheaders' ) ) { $ server = \ Arr :: filter_prefixed ( static :: server ( ) , 'HTTP_' , true ) ; foreach ( $ server as $ key => $ value ) { $ key = join ( '-' , arra... | Fetch a item from the HTTP request headers |
3,180 | protected static function hydrate ( ) { static :: $ input = array_merge ( $ _GET , $ _POST ) ; if ( \ Input :: method ( ) == 'PUT' or \ Input :: method ( ) == 'PATCH' or \ Input :: method ( ) == 'DELETE' ) { static :: $ php_input === null and static :: $ php_input = file_get_contents ( 'php://input' ) ; if ( strpos ( s... | Hydrates the input array |
3,181 | public function all ( string $ identifier = '' ) : array { if ( $ identifier && ! $ this -> exists ( $ identifier ) ) { return [ ] ; } return $ identifier ? $ this -> menus [ $ identifier ] : $ this -> menus ; } | Get all registered menus . |
3,182 | public function register ( string $ identifier , $ title , string $ url = '' , array $ children = [ ] , array $ fields = [ ] ) : Menu { $ this -> menus [ $ identifier ] [ ] = $ this -> parseMenuItems ( $ title , $ url , $ children , $ fields ) ; return $ this ; } | Register a new menu . |
3,183 | public function build ( string $ identifier , callable $ items ) : Menu { $ builder = new Builder ( $ identifier ) ; $ items ( $ builder ) ; if ( isset ( $ this -> menus [ $ identifier ] ) ) { $ this -> menus [ $ identifier ] = array_merge ( $ this -> menus [ $ identifier ] , $ builder -> getMenu ( ) ) ; return $ this ... | Build a complex menu . |
3,184 | public function count ( string $ identifier = '' ) : int { if ( $ identifier ) { return $ this -> countItems ( $ identifier ) ; } $ menus = $ this -> all ( ) ; $ counter = 0 ; foreach ( $ menus as $ identifier => $ menu ) { $ counter += $ this -> countItems ( $ identifier ) ; } return $ counter ; } | Count all registered menus and their elements . |
3,185 | public function toArray ( $ values = [ ] ) : array { if ( ! $ values ) { $ values = $ this -> all ( ) ; } $ array = [ ] ; if ( is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ array [ $ key ] = is_array ( $ value ) ? $ this -> toArray ( $ value ) : $ value ; if ( is_object ( $ value ) ) { $ array ... | Convert all registered menus to nested arrays . |
3,186 | private function countItems ( string $ identifier , array $ array = [ ] ) : int { if ( ! $ array ) { $ array = $ this -> toArray ( $ this -> all ( $ identifier ) ) ; $ counter = count ( $ array ) ; } else { $ counter = 0 ; } foreach ( $ array as $ value ) { $ counter += count ( $ value [ 'children' ] ) ; if ( $ value [... | Count all specified menu s items including their child elements . |
3,187 | public function init ( ) { if ( $ this -> language === null ) { $ this -> language = App :: $ Request -> getLanguage ( ) ; } if ( $ this -> targetClass === null ) { $ this -> targetClass = 'wysiwyg' ; } if ( $ this -> config === null || ! Arr :: in ( $ this -> config , [ 'config-small' , 'config-full' , 'config-medium'... | Pass init params |
3,188 | public function display ( ) { App :: $ Alias -> setCustomLibrary ( 'js' , $ this -> baseUrl . '/ckeditor.js' ) ; App :: $ Alias -> setCustomLibrary ( 'js' , $ this -> baseUrl . '/adapters/jquery.js' ) ; $ jsInitializeCode = "$('.{$this->targetClass}').ckeditor({" ; $ jsInitializeCode .= "language: '{$this->language}', ... | Add ckeditor library s to lazyload |
3,189 | public function getContentModules ( ) { return array_filter ( $ this -> getModules ( ) , function ( ModuleInterface $ module ) { return ! ( $ module instanceof AdministrationModuleInterface ) && ! ( $ module instanceof SubmoduleInterface ) ; } ) ; } | Get all modules that handle content . |
3,190 | public function getCategories ( ) { $ items = array ( array ( 'label' => Yii :: t ( 'ciims.models.theme' , 'All Posts' ) , 'url' => Yii :: app ( ) -> createUrl ( '/blog' ) ) ) ; $ categories = Yii :: app ( ) -> cache -> get ( 'CiiMS::Categories::list' ) ; if ( $ categories == false ) { $ criteria = new CDbCriteria ( ) ... | Retrieves all categories to display int he footer |
3,191 | public function getRecentPosts ( ) { $ items = array ( ) ; $ content = Yii :: app ( ) -> cache -> get ( 'CiiMS::Content::list' ) ; if ( $ content == false ) { $ criteria = Content :: model ( ) -> getBaseCriteria ( ) -> addCondition ( 'type_id = 2' ) -> addCondition ( 'password = ""' ) ; $ criteria -> order = 'published... | Retrieves the recent post items so that the view is cleaned up |
3,192 | public function getRelatedPosts ( $ id , $ category_id ) { $ items = array ( ) ; $ criteria = Content :: model ( ) -> getBaseCriteria ( ) -> addCondition ( 'category_id = :category_id' ) -> addCondition ( 'id != :id' ) -> addCondition ( 'type_id = 2' ) -> addCondition ( 'password = ""' ) ; $ criteria -> order = 'publis... | Retrieves related posts to a given post |
3,193 | public function getContentTags ( $ id ) { $ items = array ( ) ; $ tags = Content :: model ( ) -> findByPk ( $ id ) -> getTags ( ) ; foreach ( $ tags as $ item ) $ items [ ] = array ( 'label' => $ item , 'url' => Yii :: app ( ) -> createUrl ( '/search?q=' . $ item ) ) ; return $ items ; } | Retrieves the tags for a particular article and flattens them to a pretty array |
3,194 | protected function setController ( ) { $ controller = null ; if ( is_file ( $ this -> getRootPath ( ) . 'controller/' . $ this -> getMethod ( ) . '/' . $ this -> getNameSpace ( ) . '_controller.php' ) ) { $ controller = $ this -> getRootPath ( ) . 'controller/' . $ this -> getMethod ( ) . '/' . $ this -> getNameSpace (... | Set the current controller searching for it in various places . |
3,195 | protected function setView ( ) { if ( is_file ( $ this -> getRootPath ( ) . 'view/' . $ this -> getMethod ( ) . '/view.php' ) ) { $ this -> view = new View ( $ this -> getRootPath ( ) . 'view/' . $ this -> getMethod ( ) . '/view.php' ) ; } else if ( is_file ( $ this -> getRootPath ( ) . 'view/GET/view.php' ) ) { $ this... | Set the current view searching for it in various places . |
3,196 | public function getRootPath ( ) { $ folder = WebApp :: getPageFolder ( ) . $ this -> code ; if ( StringTools :: right ( $ folder , 1 ) != '/' ) { $ folder .= '/' ; } return $ folder ; } | Return the page root path based on WebApp root path and the curent code |
3,197 | public function render ( ) { $ baseContent = $ this -> view -> executeAndReturnContent ( ) ; $ content = TemplateManager :: render ( $ baseContent ) ; $ content = $ this -> controller -> render ( $ content ) ; return $ content ; } | Render the page |
3,198 | public static function countLines ( $ filepath ) { $ return = false ; if ( file_exists ( $ filepath ) ) { $ handle = fopen ( $ filepath , 'r' ) ; if ( $ handle ) { $ return = 0 ; while ( ! feof ( $ handle ) ) { $ chunk = fgets ( $ handle , 4096 ) ; $ chunk_count = substr_count ( $ chunk , "\n" ) ; $ return = $ return +... | Get line count |
3,199 | public static function safeFileWrite ( $ filepath , $ str = '' , $ opts = array ( ) ) { $ return = false ; $ opts = array_merge ( array ( 'est_size' => strlen ( $ str ) , ) , $ opts ) ; $ fh = self :: safeFopen ( $ filepath , $ opts ) ; if ( $ fh ) { if ( fwrite ( $ fh , $ str ) !== false ) { $ return = true ; } else {... | Write a string to a file .. taking care that enough diskspace etc exists |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.