idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
41,600
public function get_address_book ( $ id , $ writeable = false ) { $ contacts = null ; $ ldap_config = ( array ) $ this -> config -> get ( 'ldap_public' ) ; if ( $ id == 'sql' ) $ id = '0' ; else if ( $ id == - 1 ) { $ id = $ this -> config -> get ( 'default_addressbook' ) ; $ default = true ; } if ( isset ( $ this -> a...
Return instance of the internal address book class
41,601
public function get_address_book_id ( $ object ) { foreach ( $ this -> address_books as $ index => $ book ) { if ( $ book === $ object ) { return $ index ; } } }
Return identifier of the address book object
41,602
public function get_address_sources ( $ writeable = false , $ skip_hidden = false ) { $ abook_type = ( string ) $ this -> config -> get ( 'address_book_type' ) ; $ ldap_config = ( array ) $ this -> config -> get ( 'ldap_public' ) ; $ autocomplete = ( array ) $ this -> config -> get ( 'autocomplete_addressbooks' ) ; $ l...
Return address books list
41,603
public function get_compose_responses ( $ sorted = false , $ user_only = false ) { $ responses = array ( ) ; if ( ! $ user_only ) { foreach ( $ this -> config -> get ( 'compose_responses_static' , array ( ) ) as $ response ) { if ( empty ( $ response [ 'key' ] ) ) { $ response [ 'key' ] = substr ( md5 ( $ response [ 'n...
Getter for compose responses . These are stored in local config and user preferences .
41,604
public function load_gui ( $ framed = false ) { if ( ! ( $ this -> output instanceof rcmail_output_html ) ) { $ this -> output = new rcmail_output_html ( $ this -> task , $ framed ) ; } $ this -> output -> set_env ( 'refresh_interval' , $ this -> config -> get ( 'refresh_interval' , 0 ) ) ; $ this -> output -> set_env ...
Init output object for GUI and add common scripts . This will instantiate a rcmail_output_html object and set environment vars according to the current session and configuration
41,605
public function json_init ( ) { if ( ! ( $ this -> output instanceof rcmail_output_json ) ) { $ this -> output = new rcmail_output_json ( $ this -> task ) ; } return $ this -> output ; }
Create an output object for JSON responses
41,606
public function login_error ( ) { if ( $ this -> login_error ) { return $ this -> login_error ; } if ( $ this -> storage && $ this -> storage -> get_error_code ( ) < - 1 ) { return self :: ERROR_STORAGE ; } }
Returns error code of last login operation
41,607
public function autoselect_host ( ) { $ default_host = $ this -> config -> get ( 'default_host' ) ; $ host = null ; if ( is_array ( $ default_host ) ) { $ post_host = rcube_utils :: get_input_value ( '_host' , rcube_utils :: INPUT_POST ) ; $ post_user = rcube_utils :: get_input_value ( '_user' , rcube_utils :: INPUT_PO...
Auto - select IMAP host based on the posted login information
41,608
public function kill_session ( ) { $ this -> plugins -> exec_hook ( 'session_destroy' ) ; $ this -> session -> kill ( ) ; $ _SESSION = array ( 'language' => $ this -> user -> language , 'temp' => true , 'skin' => $ this -> config -> get ( 'skin' ) ) ; $ this -> user -> reset ( ) ; }
Destroy session data and remove cookie
41,609
public function logout_actions ( ) { $ storage = $ this -> get_storage ( ) ; $ logout_expunge = $ this -> config -> get ( 'logout_expunge' ) ; $ logout_purge = $ this -> config -> get ( 'logout_purge' ) ; $ trash_mbox = $ this -> config -> get ( 'trash_mbox' ) ; if ( $ logout_purge && ! empty ( $ trash_mbox ) ) { $ sto...
Do server side actions on logout
41,610
public function url ( $ p , $ absolute = false , $ full = false , $ secure = false ) { if ( ! is_array ( $ p ) ) { if ( strpos ( $ p , 'http' ) === 0 ) { return $ p ; } $ p = array ( '_action' => @ func_get_arg ( 0 ) ) ; } $ pre = array ( ) ; $ task = $ p [ '_task' ] ? : ( $ p [ 'task' ] ? : $ this -> task ) ; $ pre [ ...
Build a valid URL to this instance of Roundcube
41,611
public function shutdown ( ) { parent :: shutdown ( ) ; foreach ( $ this -> address_books as $ book ) { if ( is_object ( $ book ) && is_a ( $ book , 'rcube_addressbook' ) ) { $ book -> close ( ) ; } } if ( $ this -> config -> get ( 'devel_mode' ) || $ this -> config -> get ( 'performance_stats' ) ) { setlocale ( LC_NUM...
Function to be executed in script shutdown
41,612
public function request_security_check ( $ mode = rcube_utils :: INPUT_POST ) { if ( ! $ this -> check_request ( $ mode ) ) { $ error = array ( 'code' => 403 , 'message' => "Request security check failed" ) ; self :: raise_error ( $ error , false , true ) ; } if ( $ this -> config -> get ( 'referer_check' ) && ! rcube_...
CSRF attack prevention code . Raises error when check fails .
41,613
public function register_action_map ( $ map ) { if ( is_array ( $ map ) ) { foreach ( $ map as $ idx => $ val ) { $ this -> action_map [ $ idx ] = $ val ; } } }
Registers action aliases for current task
41,614
public function get_action_file ( ) { if ( ! empty ( $ this -> action_map [ $ this -> action ] ) ) { return $ this -> action_map [ $ this -> action ] ; } return strtr ( $ this -> action , '-' , '_' ) . '.inc' ; }
Returns current action filename
41,615
public function set_env_config ( $ options ) { foreach ( ( array ) $ options as $ option ) { if ( $ this -> config -> get ( $ option ) ) { $ this -> output -> set_env ( $ option , true ) ; } } }
Set environment variables for specified config options
41,616
public function user_date ( ) { try { $ tz = new DateTimeZone ( $ this -> config -> get ( 'timezone' ) ) ; $ date = new DateTime ( 'now' , $ tz ) ; } catch ( Exception $ e ) { $ date = new DateTime ( ) ; } return $ date -> format ( 'r' ) ; }
Returns RFC2822 formatted current date in user s timezone
41,617
public function table_output ( $ attrib , $ table_data , $ show_cols , $ id_col ) { $ table = new html_table ( $ attrib ) ; if ( ! $ attrib [ 'noheader' ] ) { foreach ( $ show_cols as $ col ) { $ table -> add_header ( $ col , $ this -> Q ( $ this -> gettext ( $ col ) ) ) ; } } if ( ! is_array ( $ table_data ) ) { $ db ...
Create a HTML table based on the given data
41,618
public function folder_selector ( $ p = array ( ) ) { $ realnames = $ this -> config -> get ( 'show_real_foldernames' ) ; $ p += array ( 'maxlength' => 100 , 'realnames' => $ realnames , 'is_escaped' => true ) ; $ a_mailboxes = array ( ) ; $ storage = $ this -> get_storage ( ) ; if ( empty ( $ p [ 'folder_name' ] ) ) {...
Return folders list as html_select object
41,619
public function build_folder_tree ( & $ arrFolders , $ folder , $ delm = '/' , $ path = '' ) { $ prefix = '' ; if ( ! $ path ) { $ n_folder = $ folder ; $ folder = $ this -> storage -> mod_folder ( $ folder ) ; if ( $ n_folder != $ folder ) { $ prefix = substr ( $ n_folder , 0 , - strlen ( $ folder ) ) ; } } $ pos = st...
Create a hierarchical array of the mailbox list
41,620
public function folder_classname ( $ folder_id ) { if ( $ folder_id == 'INBOX' ) { return 'inbox' ; } foreach ( array ( 'sent' , 'drafts' , 'trash' , 'junk' ) as $ smbx ) { if ( $ folder_id === $ this -> config -> get ( $ smbx . '_mbox' ) ) { return $ smbx ; } } }
Return internal name for the given folder if it matches the configured special folders
41,621
public function localize_foldername ( $ name , $ with_path = false , $ path_remove = false ) { $ realnames = $ this -> config -> get ( 'show_real_foldernames' ) ; if ( ! $ realnames && ( $ folder_class = $ this -> folder_classname ( $ name ) ) ) { return $ this -> gettext ( $ folder_class ) ; } $ storage = $ this -> ge...
Try to localize the given IMAP folder name . UTF - 7 decode it in case no localized text was found
41,622
public function localize_folderpath ( $ path ) { $ protect_folders = $ this -> config -> get ( 'protect_default_folders' ) ; $ delimiter = $ this -> storage -> get_hierarchy_delimiter ( ) ; $ path = explode ( $ delimiter , $ path ) ; $ result = array ( ) ; foreach ( $ path as $ idx => $ dir ) { $ directory = implode ( ...
Localize folder path
41,623
public static function quota_display ( $ attrib ) { $ rcmail = rcmail :: get_instance ( ) ; if ( ! $ attrib [ 'id' ] ) { $ attrib [ 'id' ] = 'rcmquotadisplay' ; } $ _SESSION [ 'quota_display' ] = ! empty ( $ attrib [ 'display' ] ) ? $ attrib [ 'display' ] : 'text' ; $ rcmail -> output -> add_gui_object ( 'quotadisplay'...
Return HTML for quota indicator object
41,624
public function html_editor ( $ mode = '' ) { $ spellcheck = intval ( $ this -> config -> get ( 'enable_spellcheck' ) ) ; $ spelldict = intval ( $ this -> config -> get ( 'spellcheck_dictionary' ) ) ; $ disabled_plugins = array ( ) ; $ disabled_buttons = array ( ) ; $ extra_plugins = array ( ) ; $ extra_buttons = array...
Output HTML editor scripts
41,625
public function upload_progress ( ) { $ params = array ( 'action' => $ this -> action , 'name' => rcube_utils :: get_input_value ( '_progress' , rcube_utils :: INPUT_GET ) , ) ; if ( function_exists ( 'uploadprogress_get_info' ) ) { $ status = uploadprogress_get_info ( $ params [ 'name' ] ) ; if ( ! empty ( $ status ) ...
File upload progress handler .
41,626
public function upload_init ( $ max_size = null ) { if ( $ seconds = $ this -> config -> get ( 'upload_progress' ) ) { if ( function_exists ( 'uploadprogress_get_info' ) ) { $ field_name = 'UPLOAD_IDENTIFIER' ; } if ( ! $ field_name && filter_var ( ini_get ( 'apc.rfc1867' ) , FILTER_VALIDATE_BOOLEAN ) ) { $ field_name ...
Initializes file uploading interface .
41,627
public function upload_form ( $ attrib , $ name , $ action , $ input_attr = array ( ) ) { $ max_filesize = $ this -> upload_init ( ) ; $ hint = html :: div ( 'hint' , $ this -> gettext ( array ( 'name' => 'maxuploadsize' , 'vars' => array ( 'size' => $ max_filesize ) ) ) ) ; if ( $ attrib [ 'mode' ] == 'hint' ) { retur...
Upload form object
41,628
public function display_uploaded_file ( $ file ) { if ( empty ( $ file ) ) { return ; } $ file = $ this -> plugins -> exec_hook ( 'attachment_display' , $ file ) ; if ( $ file [ 'status' ] ) { if ( empty ( $ file [ 'size' ] ) ) { $ file [ 'size' ] = $ file [ 'data' ] ? strlen ( $ file [ 'data' ] ) : @ filesize ( $ file...
Outputs uploaded file content ( with image thumbnails support
41,629
public function autocomplete_init ( ) { static $ init ; if ( $ init ) { return ; } $ init = 1 ; if ( ( $ threads = ( int ) $ this -> config -> get ( 'autocomplete_threads' ) ) > 0 ) { $ book_types = ( array ) $ this -> config -> get ( 'autocomplete_addressbooks' , 'sql' ) ; if ( count ( $ book_types ) > 1 ) { $ this ->...
Initializes client - side autocompletion .
41,630
public function show_bytes ( $ bytes , & $ unit = null ) { if ( $ bytes >= 1073741824 ) { $ unit = 'GB' ; $ gb = $ bytes / 1073741824 ; $ str = sprintf ( $ gb >= 10 ? "%d " : "%.1f " , $ gb ) . $ this -> gettext ( $ unit ) ; } else if ( $ bytes >= 1048576 ) { $ unit = 'MB' ; $ mb = $ bytes / 1048576 ; $ str = sprintf (...
Create a human readable string for a number of bytes
41,631
public function html2text ( $ html , $ options = array ( ) ) { $ default_options = array ( 'links' => true , 'width' => 75 , 'body' => $ html , 'charset' => RCUBE_CHARSET , ) ; $ options = array_merge ( $ default_options , ( array ) $ options ) ; $ options = $ this -> plugins -> exec_hook ( 'html2text' , $ options ) ; ...
Converts HTML content into plain text
41,632
public function storage_connect ( ) { $ storage = $ this -> get_storage ( ) ; if ( $ _SESSION [ 'storage_host' ] && ! $ storage -> is_connected ( ) ) { $ host = $ _SESSION [ 'storage_host' ] ; $ user = $ _SESSION [ 'username' ] ; $ port = $ _SESSION [ 'storage_port' ] ; $ ssl = $ _SESSION [ 'storage_ssl' ] ; $ pass = $...
Connect to the mail storage server with stored session data
41,633
public function addAction ( $ name , ActionInterface $ action , $ priority = Priority :: DEFAULT_PRIORITY ) { $ this -> actions [ ] = array ( 'name' => $ name , 'action' => $ action , 'priority' => $ priority , ) ; }
Adds action to stack .
41,634
protected function prepareConfig ( $ contentTypeIdentifier ) { if ( ! empty ( $ this -> config [ ConfigurationConstants :: CONTENT_TYPES ] [ $ contentTypeIdentifier ] ) ) { return $ this -> config [ ConfigurationConstants :: CONTENT_TYPES ] [ $ contentTypeIdentifier ] ; } if ( ! empty ( $ this -> config [ 'default' ] )...
Returns configuration for given content type identifier if exists or default one .
41,635
protected function prepareActions ( ) { usort ( $ this -> actions , function ( $ one , $ two ) { if ( $ one [ 'priority' ] === $ two [ 'priority' ] ) { return 0 ; } return ( $ one [ 'priority' ] > $ two [ 'priority' ] ) ? - 1 : 1 ; } ) ; }
Sorts actions by priority .
41,636
function get_type ( ) { if ( $ this -> subkeys [ 0 ] -> has_private ) return enigma_key :: TYPE_KEYPAIR ; else if ( ! empty ( $ this -> subkeys [ 0 ] ) ) return enigma_key :: TYPE_PUBLIC ; return enigma_key :: TYPE_UNKNOWN ; }
Returns key type
41,637
function is_expired ( ) { $ now = time ( ) ; foreach ( $ this -> subkeys as $ subkey ) if ( ! $ subkey -> expires || $ subkey -> expires > $ now ) return true ; return false ; }
Returns true if any of subkeys is not expired
41,638
function is_private ( ) { $ now = time ( ) ; foreach ( $ this -> subkeys as $ subkey ) if ( $ subkey -> has_private ) return true ; return false ; }
Returns true if any of subkeys is a private key
41,639
function find_subkey ( $ email , $ mode ) { $ now = time ( ) ; foreach ( $ this -> users as $ user ) { if ( strcasecmp ( $ user -> email , $ email ) === 0 && $ user -> valid && ! $ user -> revoked ) { foreach ( $ this -> subkeys as $ subkey ) { if ( ! $ subkey -> revoked && ( ! $ subkey -> expires || $ subkey -> expire...
Get key ID by user email
41,640
static function format_fingerprint ( $ fingerprint ) { if ( ! $ fingerprint ) { return '' ; } $ result = '' ; for ( $ i = 0 ; $ i < 40 ; $ i ++ ) { if ( $ i % 4 == 0 ) { $ result .= ' ' ; } $ result .= $ fingerprint [ $ i ] ; } return $ result ; }
Formats fingerprint string
41,641
public function getQueue ( ) { $ this -> queue = array_values ( array_diff ( array_unique ( array_merge ( $ this -> queue , array_keys ( $ this -> sitemaps ) ) ) , $ this -> history ) ) ; return $ this -> queue ; }
Sitemap URLs discovered but not yet parsed
41,642
protected function getContent ( ) { $ this -> currentURL = $ this -> urlEncode ( $ this -> currentURL ) ; if ( ! $ this -> urlValidate ( $ this -> currentURL ) ) { throw new SitemapParserException ( 'Invalid URL' ) ; } try { if ( ! isset ( $ this -> config [ 'guzzle' ] [ 'headers' ] [ 'User-Agent' ] ) ) { $ this -> con...
Request the body content of an URL
41,643
protected function parseRobotstxt ( $ robotstxt ) { $ lines = array_filter ( array_map ( 'trim' , mb_split ( '\r\n|\n|\r' , $ robotstxt ) ) ) ; foreach ( $ lines as $ line ) { $ line = mb_split ( '#' , $ line , 2 ) [ 0 ] ; $ pair = array_map ( 'trim' , mb_split ( ':' , $ line , 2 ) ) ; if ( mb_strtolower ( $ pair [ 0 ]...
Search for sitemaps in the robots . txt content
41,644
protected function addArray ( $ type , array $ array ) { if ( ! isset ( $ array [ 'loc' ] ) ) { return false ; } $ array [ 'loc' ] = $ this -> urlEncode ( trim ( $ array [ 'loc' ] ) ) ; if ( $ this -> urlValidate ( $ array [ 'loc' ] ) ) { switch ( $ type ) { case self :: XML_TAG_SITEMAP : $ this -> sitemaps [ $ array [...
Validate URL arrays and add them to their corresponding arrays
41,645
protected function generateXMLObject ( $ xml ) { try { libxml_use_internal_errors ( true ) ; return new SimpleXMLElement ( $ xml , LIBXML_NOCDATA ) ; } catch ( \ Exception $ e ) { return false ; } }
Generate the \ SimpleXMLElement object if the XML is valid
41,646
protected function parseString ( $ string ) { if ( ! isset ( $ this -> config [ 'strict' ] ) || $ this -> config [ 'strict' ] !== false ) { return false ; } $ array = array_filter ( array_map ( 'trim' , mb_split ( '\r\n|\n|\r' , $ string ) ) ) ; foreach ( $ array as $ line ) { if ( $ this -> isSitemapURL ( $ line ) ) {...
Parse line separated text string
41,647
protected function isSitemapURL ( $ url ) { $ path = parse_url ( $ this -> urlEncode ( $ url ) , PHP_URL_PATH ) ; return $ this -> urlValidate ( $ url ) && ( mb_substr ( $ path , - mb_strlen ( self :: XML_EXTENSION ) - 1 ) == '.' . self :: XML_EXTENSION || mb_substr ( $ path , - mb_strlen ( self :: XML_EXTENSION_COMPRE...
Check if the URL may contain an Sitemap
41,648
protected function parseJson ( $ type , \ SimpleXMLElement $ json ) { if ( ! isset ( $ json -> $ type ) ) { return false ; } foreach ( $ json -> $ type as $ url ) { $ this -> addArray ( $ type , ( array ) $ url ) ; } return true ; }
Parse Json object
41,649
public function Link ( $ action = null ) { if ( ! $ action && Member :: currentUserID ( ) && ! $ this -> AllowProfileEditing && $ this -> CanAddMembers ( ) ) { $ action = 'add' ; } return parent :: Link ( $ action ) ; }
If profile editing is disabled but the current user can add members just link directly to the add action .
41,650
public function Fields ( ) { $ list = $ this -> getComponents ( 'Fields' ) ; $ fields = singleton ( Member :: class ) -> getMemberFormFields ( ) -> dataFields ( ) ; $ included = array ( ) ; foreach ( $ list as $ profileField ) { if ( ! array_key_exists ( $ profileField -> MemberField , $ fields ) ) { $ profileField -> ...
Returns a list of profile field objects after synchronising them with the Member form fields .
41,651
protected function indexRegister ( ) { if ( ! $ this -> AllowRegistration ) { return Security :: permissionFailure ( $ this , _t ( 'MemberProfiles.CANNOTREGPLEASELOGIN' , 'You cannot register on this profile page. Please login to edit your profile.' ) ) ; } $ data = array ( 'Type' => 'Register' , 'Title' => $ this -> o...
Allow users to register if registration is enabled .
41,652
protected function indexProfile ( ) { if ( ! $ this -> AllowProfileEditing ) { if ( $ this -> AllowAdding && Injector :: inst ( ) -> get ( Member :: class ) -> canCreate ( ) ) { return $ this -> redirect ( $ this -> Link ( 'add' ) ) ; } return Security :: permissionFailure ( $ this , _t ( 'MemberProfiles.CANNOTEDIT' , ...
Allows users to edit their profile if they are in at least one of the groups this page is restricted to and editing isn t disabled .
41,653
public function register ( $ data , Form $ form ) { $ member = $ this -> addMember ( $ form ) ; if ( ! $ member ) { return $ this -> redirectBack ( ) ; } if ( $ member -> canLogin ( ) ) { Injector :: inst ( ) -> get ( IdentityStore :: class ) -> logIn ( $ member ) ; } if ( $ this -> RegistrationRedirect ) { if ( $ this...
Handles validation and saving new Member objects as well as sending out validation emails .
41,654
public function save ( array $ data , Form $ form ) { $ member = Member :: currentUser ( ) ; $ groupIds = $ this -> getSettableGroupIdsFrom ( $ form , $ member ) ; $ member -> Groups ( ) -> setByIDList ( $ groupIds ) ; $ form -> saveInto ( $ member ) ; try { $ member -> write ( ) ; } catch ( ValidationException $ e ) {...
Updates an existing Member s profile .
41,655
public function doAdd ( $ data , $ form ) { if ( $ this -> addMember ( $ form ) ) { $ form -> sessionMessage ( _t ( 'MemberProfiles.MEMBERADDED' , 'The new member has been added.' ) , 'good' ) ; } return $ this -> redirectBack ( ) ; }
Saves an add member form submission into a new member object .
41,656
protected function getSettableGroupIdsFrom ( Form $ form , Member $ member = null ) { $ groupField = $ form -> Fields ( ) -> dataFieldByName ( 'Groups' ) ; $ groupIds = $ allowedIds = $ this -> SelectableGroups ( ) -> map ( 'ID' , 'ID' ) -> toArray ( ) ; $ existingIds = array ( ) ; if ( $ member ) { $ existing = $ memb...
Gets the list of groups that can be set after the submission of a particular form
41,657
public function confirm ( HTTPRequest $ request ) { if ( $ this -> EmailType !== 'Confirmation' && $ this -> EmailType !== 'Validation' ) { return $ this -> httpError ( 400 , 'No confirmation required.' ) ; } $ currentMember = Member :: currentUser ( ) ; $ id = ( int ) $ request -> param ( 'ID' ) ; $ key = $ request ->...
Allows the user to confirm their account by clicking on the validation link in the confirmation email .
41,658
protected function addMember ( $ form ) { $ member = new Member ( ) ; $ groupIds = $ this -> getSettableGroupIdsFrom ( $ form ) ; $ form -> saveInto ( $ member ) ; $ member -> ProfilePageID = $ this -> ID ; $ member -> NeedsValidation = ( $ this -> EmailType === 'Validation' ) ; $ member -> NeedsApproval = $ this -> Re...
Attempts to save either a registration or add member form submission into a new member object returning NULL on validation failure .
41,659
public function saveManualEmailValidation ( $ value ) { if ( $ value === 'confirm' ) { $ this -> owner -> NeedsValidation = false ; } elseif ( $ value === 'resend' ) { $ email = MemberConfirmationEmail :: create ( $ this -> owner -> ProfilePage ( ) , $ this -> owner ) ; $ email -> send ( ) ; } }
Allows admin users to manually confirm a user .
41,660
public function handleList ( $ request ) { $ parent = $ this -> getParent ( ) ; $ fields = $ parent -> Fields ( ) -> filter ( 'MemberListVisible' , true ) ; $ groups = $ parent -> Groups ( ) ; if ( $ groups -> count ( ) > 0 ) { $ members = $ groups -> relation ( 'Members' ) ; } else { $ members = Member :: get ( ) ; } ...
Displays a list of all members on the site that belong to the selected groups .
41,661
public function handleView ( $ request ) { $ id = $ request -> param ( 'MemberID' ) ; if ( ! ctype_digit ( $ id ) ) { $ this -> httpError ( 404 ) ; } $ member = Member :: get ( ) -> byID ( $ id ) ; $ groups = $ this -> getParent ( ) -> Groups ( ) ; if ( $ groups -> count ( ) > 0 && ! $ member -> inGroups ( $ groups ) )...
Handles viewing an individual user s profile .
41,662
public function getDefaultTitle ( $ force = true ) { $ fields = $ this -> getMemberFields ( ) ; $ field = $ fields -> dataFieldByName ( $ this -> MemberField ) ; $ title = $ field -> Title ( ) ; if ( ! $ title && $ force ) { $ title = $ field -> getName ( ) ; } return $ title ; }
Get the default title for this field from the form field .
41,663
public function process ( Model $ model ) { $ hiddenOnModel = $ model -> getHidden ( ) ; foreach ( $ this -> unhidden as $ unhidden ) { if ( ( $ key = array_search ( $ unhidden , $ hiddenOnModel ) ) !== false ) { unset ( $ hiddenOnModel [ $ key ] ) ; } } $ hiddenOnModel = array_merge ( $ hiddenOnModel , $ this -> hidde...
Applies processing to a single model
41,664
protected function loadConfig ( ) { $ this -> namespace = config ( 'repository.generate.namespace' , $ this -> namespace ) ; $ this -> base = config ( 'repository.generate.base' , $ this -> base ) ; $ this -> suffix = config ( 'repository.generate.suffix' , $ this -> suffix ) ; $ this -> models = config ( 'repository.g...
Load the configuration for the command .
41,665
protected function replaceModelClass ( & $ stub , $ name ) { $ names = explode ( '\\' , $ name ) ; $ class = array_pop ( $ names ) ; $ stub = str_replace ( 'DummyModelClass' , $ class , $ stub ) ; return $ this ; }
Replace the probable model class name for the given stub .
41,666
protected function getModelClass ( $ name ) { $ modelClass = $ this -> getModelNameInput ( ) ; if ( ! $ modelClass ) { $ repositoryClass = str_replace ( $ this -> getNamespace ( $ name ) . '\\' , '' , $ name ) ; $ class = str_replace ( $ this -> suffix , '' , $ repositoryClass ) ; $ modelClass = str_singular ( $ class ...
Get the class name of the probable associated model .
41,667
protected function replaceBaseRepositoryClass ( & $ stub , $ name ) { $ baseClass = str_replace ( $ this -> getNamespace ( $ name ) . '\\' , '' , $ name ) ; $ stub = str_replace ( 'BaseRepositoryClass' , $ baseClass , $ stub ) ; return $ this ; }
Replace the default base repository class name for the given stub .
41,668
public function importCsv ( $ content , $ fields = array ( ) , $ options = array ( ) ) { $ config = $ this -> getConfig ( ) ; $ options = array_merge ( $ config , $ options ) ; if ( ! $ this -> _trigger ( 'beforeImportCsv' , array ( $ content , $ fields , $ options ) ) ) { return false ; } if ( $ options [ 'text' ] ) {...
Import public function
41,669
public function exportCsv ( $ filename , $ data , $ options = array ( ) ) { $ config = $ this -> getConfig ( ) ; $ options = array_merge ( $ config , $ options ) ; if ( ! $ this -> _trigger ( 'beforeExportCsv' , array ( $ filename , $ data , $ options ) ) ) { return false ; } if ( $ file = fopen ( $ filename , 'w' ) ) ...
Converts a data array into
41,670
public function findAllByTranslation ( $ attribute , $ value , $ locale = null , $ exact = true ) { $ this -> pushCriteriaOnce ( new WhereHasTranslation ( $ attribute , $ value , $ locale , $ exact ) ) ; return $ this -> all ( ) ; }
Finds models by a given translated property
41,671
public function addScope ( $ scope , $ parameters = [ ] ) { if ( ! in_array ( $ scope , $ this -> scopes ) ) { $ this -> scopes [ ] = $ scope ; } $ this -> scopeParameters [ $ scope ] = $ parameters ; $ this -> refreshSettingDependentCriteria ( ) ; return $ this ; }
Adds a scope to enforce overwrites with new parameters if it already exists
41,672
public function removeScope ( $ scope ) { $ this -> scopes = array_diff ( $ this -> scopes , [ $ scope ] ) ; unset ( $ this -> scopeParameters [ $ scope ] ) ; $ this -> refreshSettingDependentCriteria ( ) ; return $ this ; }
Adds a scope to enforce
41,673
protected function convertScopesToCriteriaArray ( ) { $ scopes = [ ] ; foreach ( $ this -> scopes as $ scope ) { if ( array_key_exists ( $ scope , $ this -> scopeParameters ) && ! empty ( $ this -> scopeParameters [ $ scope ] ) ) { $ scopes [ ] = [ $ scope , $ this -> scopeParameters [ $ scope ] ] ; continue ; } $ scop...
Converts the tracked scopes to an array that the Scopes Common Criteria will eat .
41,674
public function enableCache ( $ enable = true ) { $ this -> enableCache = ( bool ) $ enable ; $ this -> refreshSettingDependentCriteria ( ) ; return $ this ; }
Enables using the cache for retrieval
41,675
public function activateRecord ( $ id , $ active = true ) { if ( ! $ this -> hasActive ) return false ; $ model = $ this -> makeModel ( false ) ; if ( ! ( $ model = $ model -> find ( $ id ) ) ) return false ; $ model -> { $ this -> activeColumn } = ( boolean ) $ active ; return $ model -> save ( ) ; }
Update the active boolean for a record
41,676
public function makeModel ( $ storeModel = true ) { $ model = $ this -> app -> make ( $ this -> model ( ) ) ; if ( ! $ model instanceof Model ) { throw new RepositoryException ( "Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model" ) ; } if ( $ storeModel ) $ this -> model = $ model ; re...
Creates instance of model to start building query for
41,677
public function query ( ) { $ this -> applyCriteria ( ) ; if ( $ this -> model instanceof Model ) { return $ this -> model -> query ( ) ; } return clone $ this -> model ; }
Give unexecuted query for current criteria
41,678
public function firstOrFail ( $ columns = [ '*' ] ) { $ result = $ this -> query ( ) -> first ( $ columns ) ; if ( ! empty ( $ result ) ) return $ result ; throw ( new ModelNotFoundException ) -> setModel ( $ this -> model ( ) ) ; }
Returns first match or throws exception if not found
41,679
public function findWhere ( $ where , $ columns = [ '*' ] , $ or = false ) { $ model = $ this -> query ( ) ; foreach ( $ where as $ field => $ value ) { if ( $ value instanceof Closure ) { $ model = ( ! $ or ) ? $ model -> where ( $ value ) : $ model -> orWhere ( $ value ) ; } elseif ( is_array ( $ value ) ) { if ( cou...
Find a collection of models by the given query conditions .
41,680
public function update ( array $ data , $ id , $ attribute = null ) { $ model = $ this -> find ( $ id , [ '*' ] , $ attribute ) ; if ( empty ( $ model ) ) return false ; return $ model -> fill ( $ data ) -> save ( ) ; }
Updates a model by id
41,681
public function fill ( array $ data , $ id , $ attribute = null ) { $ model = $ this -> find ( $ id , [ '*' ] , $ attribute ) ; if ( empty ( $ model ) ) { throw ( new ModelNotFoundException ) -> setModel ( $ this -> model ( ) ) ; } return $ model -> fill ( $ data ) ; }
Finds and fills a model by id without persisting changes
41,682
protected function getCriteriaToApply ( ) { $ criteriaToApply = $ this -> getCriteria ( ) ; if ( ! $ this -> onceCriteria -> isEmpty ( ) ) { foreach ( $ this -> onceCriteria as $ onceKey => $ onceCriteria ) { if ( is_numeric ( $ onceKey ) ) { $ criteriaToApply -> push ( $ onceCriteria ) ; continue ; } if ( empty ( $ on...
Returns the criteria that must be applied for the next query
41,683
public function applyCriteria ( ) { if ( $ this -> ignoreCriteria === true ) { if ( ! $ this -> activeCriteria -> isEmpty ( ) ) { $ this -> makeModel ( ) ; $ this -> activeCriteria = new Collection ( ) ; } return $ this ; } if ( $ this -> areActiveCriteriaUnchanged ( ) ) return $ this ; $ this -> makeModel ( ) ; $ this...
Applies Criteria to the model for the upcoming query
41,684
public function pushCriteria ( CriteriaInterface $ criteria , $ key = null ) { if ( is_null ( $ key ) ) { $ this -> criteria -> push ( $ criteria ) ; return $ this ; } $ this -> criteria -> put ( $ key , $ criteria ) ; return $ this ; }
Pushes Criteria optionally by identifying key If a criteria already exists for the key it is overridden
41,685
public function pushCriteriaOnce ( CriteriaInterface $ criteria , $ key = null ) { if ( is_null ( $ key ) ) { $ this -> onceCriteria -> push ( $ criteria ) ; return $ this ; } $ this -> onceCriteria -> put ( $ key , $ criteria ) ; return $ this ; }
Pushes Criteria but only for the next call resets to default afterwards Note that this does NOT work for specific criteria exclusively it resets to default for ALL Criteria .
41,686
public function removeCriteriaOnce ( $ key ) { if ( ! $ this -> criteria -> has ( $ key ) ) return $ this ; $ this -> onceCriteria -> put ( $ key , new NullCriteria ) ; return $ this ; }
Removes Criteria but only for the next call resets to default afterwards Note that this does NOT work for specific criteria exclusively it resets to default for ALL Criteria .
41,687
protected function getDefaultPerPage ( ) { if ( is_numeric ( $ this -> perPage ) && $ this -> perPage > 0 ) { return $ this -> perPage ; } return config ( 'repository.perPage' , $ this -> makeModel ( false ) -> getPerPage ( ) ) ; }
Returns default per page count .
41,688
public function sync ( Model $ model , $ relation , $ ids , $ detaching = true ) { return $ model -> { $ relation } ( ) -> sync ( $ ids , $ detaching ) ; }
Executes a sync on the model provided
41,689
public function attach ( Model $ model , $ relation , $ id , array $ attributes = array ( ) , $ touch = true ) { return $ model -> { $ relation } ( ) -> attach ( $ id , $ attributes , $ touch ) ; }
Executes an attach on the model provided
41,690
public function detach ( Model $ model , $ relation , $ ids = array ( ) , $ touch = true ) { return $ model -> { $ relation } ( ) -> detach ( $ ids , $ touch ) ; }
Executes a detach on the model provided
41,691
public function updatePosition ( $ id , $ newPosition = 1 ) { $ model = $ this -> makeModel ( false ) ; if ( ! ( $ model = $ model -> find ( $ id ) ) ) { return false ; } $ this -> checkModelHasListify ( $ model ) ; $ model -> setListPosition ( ( int ) $ newPosition ) ; return $ model ; }
Updates the position for a record using Listify
41,692
public function postProcess ( $ result ) { if ( is_null ( $ result ) || is_a ( $ result , Collection :: class ) && $ result -> isEmpty ( ) ) { return $ result ; } if ( $ this -> postProcessors -> isEmpty ( ) ) return $ result ; if ( is_a ( $ result , Collection :: class ) ) { $ result -> transform ( function ( $ model ...
Runs the result for retrieval calls to the repository through postprocessing .
41,693
protected function applyPostProcessorsToModel ( Model $ model ) { foreach ( $ this -> postProcessors as $ processorClass => $ parameters ) { if ( is_numeric ( $ processorClass ) ) { $ processorClass = $ parameters ; $ parameters = null ; } $ processor = $ this -> makePostProcessor ( $ processorClass , $ parameters ) ; ...
Applies the currently active postprocessors to a model
41,694
function getBagInfo ( ) { $ major = $ this -> bagVersion [ 'major' ] ; $ minor = $ this -> bagVersion [ 'minor' ] ; $ info = array ( 'version' => "$major.$minor" , 'encoding' => $ this -> tagFileEncoding , 'hash' => $ this -> getHashEncoding ( ) ) ; return $ info ; }
Return the info keys
41,695
function setHashEncoding ( $ hashAlgorithm ) { $ hashAlgorithm = strtolower ( $ hashAlgorithm ) ; if ( $ hashAlgorithm != 'md5' && $ hashAlgorithm != 'sha1' ) { throw new InvalidArgumentException ( "Invalid hash algorithim: '$hashAlgorithm'." ) ; } $ this -> manifest -> setHashEncoding ( $ hashAlgorithm ) ; if ( $ this...
Sets the bag s checksum hash algorithm .
41,696
function validate ( ) { $ errors = array ( ) ; BagIt_validateExists ( $ this -> bagitFile , $ errors ) ; BagIt_validateExists ( $ this -> getDataDirectory ( ) , $ errors ) ; $ this -> manifest -> validate ( $ errors ) ; $ this -> bagErrors = $ errors ; return $ this -> bagErrors ; }
Runs the bag validator on the contents of the bag . This verifies the presence of required iles and folders and verifies the checksum for each file .
41,697
function addFile ( $ src , $ dest ) { $ dataPref = 'data' . DIRECTORY_SEPARATOR ; $ prefLen = strlen ( $ dataPref ) ; if ( ( strncasecmp ( $ dest , $ dataPref , $ prefLen ) != 0 ) && ( strncasecmp ( $ dest , $ dataPref , $ prefLen ) != 0 ) ) { $ dest = $ dataPref . $ dest ; } $ fulldest = "{$this->bagDirectory}/$dest" ...
This copies the file specified into the bag at the place given .
41,698
function package ( $ destination , $ method = 'tgz' ) { $ method = strtolower ( $ method ) ; if ( $ method != 'zip' && $ method != 'tgz' ) { throw new BagItException ( "Invalid compression method: '$method'." ) ; } if ( substr_compare ( $ destination , ".$method" , - 4 , 4 , true ) != 0 ) { $ destination = "$destinatio...
Compresses the bag into a file .
41,699
public function setBagInfoData ( $ key , $ value ) { $ this -> _ensureBagInfoData ( ) ; $ this -> bagInfoData [ $ key ] = BagIt_getAccumulatedValue ( $ this -> bagInfoData , $ key , $ value ) ; }
This inserts a value into bagInfoData .