idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
227,200 | public function create ( array $ aData = [ ] , $ bReturnObject = false , \ Nails \ Common \ Factory \ Locale $ oLocale = null ) { $ oDb = Factory :: service ( 'Database' ) ; if ( empty ( $ oLocale ) ) { throw new ModelException ( self :: class . ': A locale must be defined when creating a localised item' ) ; } $ aData ... | Create a new localised item |
227,201 | public static function siteUrl ( $ sUri , $ bUseSecure = false ) { if ( preg_match ( '/^(https?:\/\/|#)/' , $ sUri ) ) { return $ sUri ; } else { if ( $ bUseSecure && defined ( 'SECURE_BASE_URL' ) ) { $ sBaseUrl = rtrim ( SECURE_BASE_URL , '/' ) . '/' ; } else { $ sBaseUrl = rtrim ( BASE_URL , '/' ) . '/' ; } if ( is_f... | Prepends BASE_URL or SECURE_BASE_URL to a string |
227,202 | public function createMany ( array $ aData ) { $ oDb = Factory :: service ( 'Database' ) ; try { $ oDb -> trans_begin ( ) ; foreach ( $ aData as $ aDatum ) { if ( ! $ this -> create ( $ aDatum ) ) { throw new ModelException ( 'Failed to create item with data: ' . json_encode ( $ aDatum ) ) ; } } $ oDb -> trans_commit (... | Inserts a batch of data into the table |
227,203 | public function updateMany ( array $ aIds , array $ aData = [ ] ) : bool { $ oDb = Factory :: service ( 'Database' ) ; try { $ oDb -> trans_begin ( ) ; foreach ( $ aIds as $ iId ) { if ( ! $ this -> update ( $ iId , $ aData ) ) { throw new ModelException ( 'Failed to update item with ID ' . $ iId ) ; } } $ oDb -> trans... | Update many items with the same data |
227,204 | public function deleteMany ( array $ aIds ) : bool { $ oDb = Factory :: service ( 'Database' ) ; try { $ oDb -> trans_begin ( ) ; foreach ( $ aIds as $ iId ) { if ( ! $ this -> delete ( $ iId ) ) { throw new ModelException ( 'Failed to delete item with ID ' . $ iId ) ; } } $ oDb -> trans_commit ( ) ; return true ; } ca... | Deletes many items |
227,205 | public function getAllFlat ( $ iPage = null , $ iPerPage = null , array $ aData = [ ] , $ bIncludeDeleted = false ) { $ aItems = $ this -> getAll ( $ iPage , $ iPerPage , $ aData , $ bIncludeDeleted ) ; $ aOut = [ ] ; if ( ! $ aItems ) { return [ ] ; } $ oTest = reset ( $ aItems ) ; if ( ! property_exists ( $ oTest , $... | Fetches all objects as a flat array |
227,206 | public function getById ( $ iId , array $ aData = [ ] ) { if ( ! $ this -> tableIdColumn ) { throw new ModelException ( static :: class . '::getById() Column variable not set.' , 1 ) ; } return $ this -> getByColumn ( $ this -> tableIdColumn , $ iId , $ aData ) ; } | Fetch an object by it s ID |
227,207 | public function getByIds ( $ aIds , array $ aData = [ ] , $ bMaintainInputOrder = false ) { if ( ! $ this -> tableIdColumn ) { throw new ModelException ( static :: class . '::getByIds() Column variable not set.' , 1 ) ; } $ aItems = $ this -> getByColumn ( $ this -> tableIdColumn , $ aIds , $ aData , true ) ; if ( $ bM... | Fetch objects by their IDs |
227,208 | public function getBySlug ( $ sSlug , array $ aData = [ ] ) { if ( ! $ this -> tableSlugColumn ) { throw new ModelException ( static :: class . '::getBySlug() Column variable not set.' , 1 ) ; } return $ this -> getByColumn ( $ this -> tableSlugColumn , $ sSlug , $ aData ) ; } | Fetch an object by it s slug |
227,209 | public function getBySlugs ( $ aSlugs , array $ aData = [ ] , $ bMaintainInputOrder = false ) { if ( ! $ this -> tableSlugColumn ) { throw new ModelException ( static :: class . '::getBySlugs() Column variable not set.' , 1 ) ; } $ aItems = $ this -> getByColumn ( $ this -> tableSlugColumn , $ aSlugs , $ aData , true )... | Fetch objects by their slugs |
227,210 | public function getByIdOrSlug ( $ mIdSlug , array $ aData = [ ] ) { if ( is_numeric ( $ mIdSlug ) ) { return $ this -> getById ( $ mIdSlug , $ aData ) ; } else { return $ this -> getBySlug ( $ mIdSlug , $ aData ) ; } } | Fetch an object by it s id or slug |
227,211 | public function getByToken ( $ sToken , array $ aData = [ ] ) { if ( ! $ this -> tableTokenColumn ) { throw new ModelException ( static :: class . '::getByToken() Column variable not set.' , 1 ) ; } return $ this -> getByColumn ( $ this -> tableTokenColumn , $ sToken , $ aData ) ; } | Fetch an object by its token |
227,212 | public function getByTokens ( $ aTokens , array $ aData = [ ] , $ bMaintainInputOrder = false ) { if ( ! $ this -> tableTokenColumn ) { throw new ModelException ( static :: class . '::getByTokens() Column variable not set.' , 1 ) ; } $ aItems = $ this -> getByColumn ( $ this -> tableTokenColumn , $ aTokens , $ aData , ... | Fetch objects by an array of tokens |
227,213 | protected function sortItemsByColumn ( array $ aItems , array $ aInputOrder , $ sColumn ) { $ aOut = [ ] ; foreach ( $ aInputOrder as $ sInputItem ) { foreach ( $ aItems as $ oItem ) { if ( $ oItem -> { $ sColumn } == $ sInputItem ) { $ aOut [ ] = $ oItem ; } } } return $ aOut ; } | Sorts items into a specific order based on a specific column |
227,214 | protected function getManyAssociatedItems ( array & $ aItems , $ sItemProperty , $ sAssociatedItemIdColumn , $ sAssociatedModel , $ sAssociatedModelProvider , array $ aAssociatedModelData = [ ] ) { if ( ! empty ( $ aItems ) ) { $ oAssociatedModel = Factory :: model ( $ sAssociatedModel , $ sAssociatedModelProvider ) ; ... | Get associated content for the items in the result set where the the relationship is 1 to many |
227,215 | protected function countManyAssociatedItems ( array & $ aItems , $ sItemProperty , $ sAssociatedItemIdColumn , $ sAssociatedModel , $ sAssociatedModelProvider , array $ aAssociatedModelData = [ ] ) { if ( ! empty ( $ aItems ) ) { $ oAssociatedModel = Factory :: model ( $ sAssociatedModel , $ sAssociatedModelProvider ) ... | Count associated content for the items in the result set where the the relationship is 1 to many |
227,216 | protected function getManyAssociatedItemsWithTaxonomy ( array & $ aItems , $ sItemProperty , $ sTaxonomyModel , $ sTaxonomyModelProvider , $ sAssociatedModel , $ sAssociatedModelProvider , array $ aAssociatedModelData = [ ] , $ sTaxonomyItemIdColumn = 'item_id' , $ sTaxonomyAssociatedIdColumn = 'associated_id' ) { if (... | Get associated content for the items in the result set using a taxonomy table |
227,217 | protected function saveAssociatedItems ( $ iItemId , array $ aAssociatedItems , $ sAssociatedItemIdColumn , $ sAssociatedModel , $ sAssociatedModelProvider ) { $ oAssociatedItemModel = Factory :: model ( $ sAssociatedModel , $ sAssociatedModelProvider ) ; $ aTouchedIds = [ ] ; $ aExistingItemIds = [ ] ; $ aData = [ 'wh... | Save associated items for an object |
227,218 | public function search ( $ sKeywords , $ iPage = null , $ iPerPage = null , array $ aData = [ ] , $ bIncludeDeleted = false ) { if ( is_array ( $ iPage ) ) { $ aData = $ iPage ; $ iPage = null ; } $ this -> applySearchConditionals ( $ aData , $ sKeywords ) ; return ( object ) [ 'page' => $ iPage , 'perPage' => $ iPerPa... | Searches for objects optionally paginated . |
227,219 | protected function applySearchConditionals ( array & $ aData , $ sKeywords ) { if ( empty ( $ aData [ 'or_like' ] ) ) { $ aData [ 'or_like' ] = [ ] ; } $ sAlias = $ this -> getTableAlias ( true ) ; foreach ( $ this -> searchableFields as $ mField ) { if ( is_array ( $ mField ) ) { $ sMappedFields = array_map ( function... | Mutates the data array and adds the conditionals for searching |
227,220 | protected function generateToken ( $ sMask = null , $ sTable = null , $ sColumn = null ) { if ( is_null ( $ sMask ) ) { $ sMask = $ this -> sTokenMask ; } if ( is_null ( $ sTable ) ) { $ sTable = $ this -> getTableName ( ) ; } if ( is_null ( $ sColumn ) ) { if ( ! $ this -> tableTokenColumn ) { throw new ModelException... | Generates a unique token for a record |
227,221 | protected function addExpandableField ( array $ aOptions ) { if ( ! array_key_exists ( 'trigger' , $ aOptions ) ) { throw new ModelException ( 'Expandable fields must define a "trigger".' ) ; } if ( ! array_key_exists ( 'type' , $ aOptions ) ) { $ aOptions [ 'type' ] = static :: EXPANDABLE_TYPE_SINGLE ; } if ( $ aOptio... | Define expandable objects |
227,222 | protected function autoSaveExpandableFieldsExtract ( array & $ aData ) { $ aFields = [ ] ; $ aOut = [ ] ; $ aExpandableFields = $ this -> getExpandableFields ( ) ; foreach ( $ aExpandableFields as $ oField ) { if ( $ oField -> auto_save ) { $ aFields [ $ oField -> trigger ] = $ oField ; } } foreach ( $ aData as $ sKey ... | Extracts any autosaveable expandable fields and unsets them from the main array |
227,223 | protected function autoSaveExpandableFieldsSave ( $ iId , array $ aExpandableFields ) { foreach ( $ aExpandableFields as $ oField ) { $ aData = array_filter ( ( array ) $ oField -> data ) ; $ this -> saveAssociatedItems ( $ iId , $ aData , $ oField -> id_column , $ oField -> model , $ oField -> provider ) ; } } | Saves extracted expandable fields |
227,224 | public function getColumn ( $ sColumn , $ sDefault = null ) { $ sColumn = ucfirst ( trim ( $ sColumn ) ) ; if ( property_exists ( $ this , 'table' . $ sColumn . 'Column' ) ) { return $ this -> { 'table' . $ sColumn . 'Column' } ; } return $ sDefault ; } | Returns the column name for specific columns of interest |
227,225 | public function describeFields ( $ sTable = null ) { $ sTable = $ sTable ? : $ this -> getTableName ( ) ; $ oDb = Factory :: service ( 'Database' ) ; $ aResult = $ oDb -> query ( 'DESCRIBE `' . $ sTable . '`;' ) -> result ( ) ; $ aFields = [ ] ; if ( classUses ( $ this , Localised :: class ) ) { $ oLocale = Factory :: ... | Describes the fields for this model automatically and with some guesswork ; for more fine grained control models should overload this method . |
227,226 | protected function describeFieldsPrepareLabel ( $ sLabel ) { $ aPatterns = [ '/\bid\b/i' => 'ID' , '/\burl\b/i' => 'URL' , '/\bhtml\b/i' => 'HTML' , '/\bpdf\b/i' => 'PDF' , ] ; $ sLabel = ucwords ( preg_replace ( '/[\-_]/' , ' ' , $ sLabel ) ) ; $ sLabel = preg_replace ( array_keys ( $ aPatterns ) , array_values ( $ aP... | Generates a human friendly label from the field s key |
227,227 | protected function describeFieldsGuessType ( & $ oField , $ sType ) { preg_match ( '/^(.*?)(\((.+?)\)(.*))?$/' , $ sType , $ aMatches ) ; $ sType = ArrayHelper :: getFromArray ( 1 , $ aMatches , 'text' ) ; $ sTypeConfig = trim ( ArrayHelper :: getFromArray ( 3 , $ aMatches ) ) ; $ iLength = is_numeric ( $ sTypeConfig )... | Guesses the field s type and sets it accordingly |
227,228 | protected function describeFieldsGuessValidation ( & $ oField , $ sType ) { preg_match ( '/^(.*?)(\((.+?)\)(.*))?$/' , $ sType , $ aMatches ) ; $ sType = ArrayHelper :: getFromArray ( 1 , $ aMatches , 'text' ) ; $ iLength = ArrayHelper :: getFromArray ( 3 , $ aMatches ) ; $ sExtra = trim ( strtolower ( ArrayHelper :: g... | Guesses the field s validation rules based on it s type |
227,229 | private function getSections ( Options $ options ) : array { $ allSections = [ ] ; $ sections = $ this -> sectionService -> loadSections ( ) ; $ configuredSections = $ options [ 'sections' ] ; foreach ( $ sections as $ section ) { if ( count ( $ configuredSections ) > 0 && ! in_array ( $ section -> identifier , $ confi... | Returns the allowed sections from eZ Platform . |
227,230 | public function addRaw ( $ aAttr ) { if ( ! empty ( $ aAttr ) ) { $ sHash = md5 ( json_encode ( $ aAttr ) ) ; $ this -> aEntries [ $ sHash ] = $ aAttr ; } return $ this ; } | Adds a meta tag setting all the element keys as tag attributes . |
227,231 | public function removeRaw ( $ aAttr ) { if ( ! empty ( $ aAttr ) ) { $ sHash = md5 ( json_encode ( $ aAttr ) ) ; unset ( $ this -> aEntries [ $ sHash ] ) ; } return $ this ; } | Adds a meta tag |
227,232 | public function add ( $ sName , $ sContent , $ sTag = '' ) { $ aMeta = [ 'name' => $ sName , 'content' => $ sContent , 'tag' => $ sTag , ] ; return $ this -> addRaw ( $ aMeta ) ; } | Adds a basic meta tag setting the name and the content attributes |
227,233 | public function remove ( $ sName , $ sContent , $ sTag = '' ) { $ aMeta = [ 'name' => $ sName , 'content' => $ sContent , 'tag' => $ sTag , ] ; return $ this -> removeRaw ( $ aMeta ) ; } | Removes a basic meta tag |
227,234 | public function removeByPropertyPattern ( $ aProperties ) { foreach ( $ this -> aEntries as $ sHash => $ aEntry ) { foreach ( $ aProperties as $ aPatterns ) { foreach ( $ aPatterns as $ sProperty => $ sPattern ) { if ( ! array_key_exists ( $ sProperty , $ aEntry ) ) { continue 2 ; } elseif ( ! preg_match ( '/^' . $ sPa... | Removes items whose propeerties match a defined pattern |
227,235 | public function outputAr ( ) { $ aOut = [ ] ; foreach ( $ this -> aEntries as $ aEntry ) { $ sTemp = ! empty ( $ aEntry [ 'tag' ] ) ? '<' . $ aEntry [ 'tag' ] . ' ' : '<meta ' ; unset ( $ aEntry [ 'tag' ] ) ; foreach ( $ aEntry as $ sKey => $ sValue ) { $ sTemp .= $ sKey . '="' . $ sValue . '" ' ; } $ sTemp = trim ( $ ... | Compiles the elements into an array of strings |
227,236 | public function getAllNested ( array $ aData = [ ] , $ bIncludeDeleted = false , $ sProperty = 'children' ) { $ aAll = parent :: getAll ( null , null , $ aData , $ bIncludeDeleted ) ; return $ this -> nestItems ( $ aAll , $ sProperty ) ; } | Similar to getAll but returns the items in a nested array |
227,237 | public function getAllNestedFlat ( array $ aData = [ ] , $ sSeparator = ' › ' , $ bIncludeDeleted = false ) { $ aAllNested = $ this -> getAllNested ( $ aData , $ bIncludeDeleted , 'children' ) ; $ aFlattened = $ this -> flattenItems ( $ aAllNested ) ; foreach ( $ aFlattened as & $ aLabels ) { $ aLabels = implode... | Returns nested items but as a flat array . The item s parent s labels will be prepended to the string |
227,238 | private function loadStateIdentifiers ( ) : array { if ( $ this -> stateIdentifiers === null ) { $ this -> stateIdentifiers = $ this -> repository -> sudo ( static function ( Repository $ repository ) : array { $ stateIdentifiers = [ ] ; $ stateGroups = $ repository -> getObjectStateService ( ) -> loadObjectStateGroups... | Returns the list of object state identifiers separated by group . |
227,239 | private function buildObjectStateFilterParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'filter_by_object_state' , ParameterType \ Compound \ BooleanType :: class , [ 'groups' => $ groups , ] ) ; $ builder -> get ( 'filter_by_object_state' ) -> add ( 'object_states' ... | Builds the parameters for filtering by object states . |
227,240 | private function getObjectStateFilterCriteria ( ParameterCollectionInterface $ parameterCollection ) : ? Criterion { if ( $ parameterCollection -> getParameter ( 'filter_by_object_state' ) -> getValue ( ) !== true ) { return null ; } $ objectStates = $ parameterCollection -> getParameter ( 'object_states' ) -> getValue... | Returns the criteria used to filter content by object state . |
227,241 | private function getObjectStateIds ( array $ stateIdentifiers ) : array { $ idList = [ ] ; foreach ( $ stateIdentifiers as $ identifier ) { $ identifier = explode ( '|' , $ identifier ) ; if ( count ( $ identifier ) !== 2 ) { continue ; } try { $ stateGroup = $ this -> objectStateHandler -> loadGroupByIdentifier ( $ id... | Returns object state IDs for all provided object state identifiers . |
227,242 | private function loadLanguages ( ) : iterable { if ( method_exists ( $ this -> languageService , 'loadLanguageListByCode' ) ) { return $ this -> languageService -> loadLanguageListByCode ( $ this -> languageCodes ) ; } $ languages = [ ] ; foreach ( $ this -> languageCodes as $ languageCode ) { try { $ language = $ this... | Loads the list of eZ Platform languages from language codes available in the object . |
227,243 | private function getPosixLocale ( Language $ language ) : ? array { if ( ! $ language -> enabled ) { return null ; } $ posixLocale = $ this -> localeConverter -> convertToPOSIX ( $ language -> languageCode ) ; if ( $ posixLocale === null ) { return null ; } if ( ! Locales :: exists ( $ posixLocale ) ) { return null ; }... | Returns the array with POSIX locale code and name for provided eZ Platform language . |
227,244 | public static function init ( ) { if ( static :: $ bIsReady ) { return ; } $ aErrorHandlers = Components :: drivers ( 'nails/common' , 'ErrorHandler' ) ; $ oDefaultDriver = null ; $ aCustomDrivers = [ ] ; foreach ( $ aErrorHandlers as $ oErrorHandler ) { if ( $ oErrorHandler -> slug == static :: DEFAULT_ERROR_HANDLER )... | Sets up the appropriate error handling driver |
227,245 | public function getDefaultDriverClass ( ) { $ oDriver = $ this -> getDefaultDriver ( ) ; $ sDriverNamespace = ArrayHelper :: getFromArray ( 'namespace' , ( array ) $ oDriver -> data ) ; $ sDriverClass = ArrayHelper :: getFromArray ( 'class' , ( array ) $ oDriver -> data ) ; return '\\' . $ sDriverNamespace . $ sDriverC... | Returns the default error driver class name |
227,246 | public function triggerError ( $ iErrorNumber = 0 , $ sErrorString = '' , $ sErrorFile = '' , $ iErrorLine = 0 ) { $ sDriverClass = static :: $ sDriverClass ; $ sDriverClass :: error ( $ iErrorNumber , $ sErrorString , $ sErrorFile , $ iErrorLine ) ; } | Manually trigger an error |
227,247 | public function showFatalErrorScreen ( $ sSubject = '' , $ sMessage = '' , $ oDetails = null ) { if ( is_array ( $ sMessage ) ) { $ sMessage = implode ( "\n" , $ sMessage ) ; } if ( is_null ( $ oDetails ) ) { $ oDetails = ( object ) [ 'type' => null , 'code' => null , 'msg' => null , 'file' => null , 'line' => null , '... | Shows the fatal error screen . A diagnostic screen is shown on non - production environments |
227,248 | public function show401 ( $ bLogError = true ) { if ( function_exists ( 'isLoggedIn' ) && isLoggedIn ( ) ) { if ( $ bLogError ) { $ sPage = ArrayHelper :: getFromArray ( 'REQUEST_URI' , $ _SERVER ) ; log_message ( 'error' , '401 Unauthorised . $ sPage ) ; } $ sMessage = 'The page you are trying to view is restricted. ... | Renders the 401 page and halts script execution |
227,249 | public static function renderErrorView ( $ sView , $ aData = [ ] , $ bFlushBuffer = true ) { if ( $ bFlushBuffer ) { $ sObContents = ob_get_contents ( ) ; if ( ! empty ( $ sObContents ) ) { ob_clean ( ) ; } } $ oInput = Factory :: service ( 'Input' ) ; $ sType = $ oInput :: isCli ( ) ? 'cli' : 'html' ; $ aPaths = [ ] ;... | Renders the error view appropriate for the environment |
227,250 | public static function halt ( $ sError , $ sSubject = '' , int $ iCode = HttpCodes :: STATUS_INTERNAL_SERVER_ERROR ) { if ( php_sapi_name ( ) === 'cli' || defined ( 'STDIN' ) ) { $ sSubject = trim ( strip_tags ( $ sSubject ) ) ; $ sError = trim ( strip_tags ( $ sError ) ) ; echo "\n" ; echo $ sSubject ? 'ERROR: ' . $ s... | A very low - level error function used before the main error handling stack kicks in |
227,251 | public function unique_if_diff ( $ new , $ params ) { list ( $ table , $ column , $ old ) = explode ( "." , $ params , 3 ) ; if ( $ new == $ old ) { return true ; } if ( ! array_key_exists ( 'unique_if_diff' , $ this -> _error_messages ) ) { $ this -> set_message ( 'unique_if_diff' , lang ( 'fv_unique_if_diff_field' ) ... | Checks if a certain value is unique in a specified table if different from current value . |
227,252 | public function valid_postcode ( $ str ) { if ( ! array_key_exists ( 'valid_postcode' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_postcode' , lang ( 'fv_valid_postcode' ) ) ; } $ pattern = '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])... | Checks if a string is in a valid UK post code format . |
227,253 | public function item_count ( array $ aArray , $ sParam ) { $ aParams = preg_replace ( '/[^0-9]/' , '' , explode ( ',' , $ sParam ) ) ; $ mFloor = ArrayHelper :: getFromArray ( 0 , $ aParams , 0 ) ; $ mCeiling = ArrayHelper :: getFromArray ( 1 , $ aParams , INF ) ; if ( substr ( $ sParam , 0 , 1 ) === '(' && substr ( $ ... | Checks if an array satisfies specified count restrictions . |
227,254 | public function valid_date ( $ sDate , $ sFormat ) { if ( empty ( $ sDate ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'Y-m-d' ; } if ( ! array_key_exists ( 'valid_date' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_date' , lang ( 'fv_valid_date_field' ) ) ; } try { $ oDate = \ Date... | Check if a date is valid |
227,255 | public function date_future ( $ sDate , $ sFormat ) { if ( empty ( $ sDate ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'Y-m-d' ; } if ( ! array_key_exists ( 'date_future' , $ this -> _error_messages ) ) { $ this -> set_message ( 'date_future' , lang ( 'fv_valid_date_future_field' ) ) ; } try { $ oNow... | Checks if a date is in the future |
227,256 | public function date_before ( $ sDate , $ sParams ) { if ( empty ( $ sDate ) ) { return true ; } if ( empty ( $ sParams ) ) { return false ; } $ aParams = explode ( '.' , $ sParams ) ; $ sField = ! empty ( $ aParams [ 0 ] ) ? $ aParams [ 0 ] : null ; $ sFormat = ! empty ( $ aParams [ 1 ] ) ? $ aParams [ 1 ] : 'Y-m-d' ;... | Checks if a date is before another date field |
227,257 | public function valid_datetime ( $ sDateTime , $ sFormat ) { if ( empty ( $ sDateTime ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'Y-m-d H:i:s' ; } if ( ! array_key_exists ( 'valid_datetime' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_datetime' , lang ( 'fv_valid_datetime_field' ... | Checks if a datetime string is valid |
227,258 | public function datetime_future ( $ sDateTime , $ sFormat ) { if ( empty ( $ sDateTime ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'Y-m-d H:i:s' ; } if ( ! array_key_exists ( 'datetime_future' , $ this -> _error_messages ) ) { $ this -> set_message ( 'datetime_future' , lang ( 'fv_valid_datetime_futu... | Checks if a datetime string is in the future |
227,259 | public function valid_time ( $ sTime , $ sFormat ) { if ( empty ( $ sTime ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'H:i:s' ; } if ( ! array_key_exists ( 'valid_time' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_time' , lang ( 'fv_valid_time_field' ) ) ; } try { $ oDate = \ Date... | Checks if a time string is valid |
227,260 | public function valid_email ( $ str ) { if ( function_exists ( 'filter_var' ) ) { return ( bool ) filter_var ( $ str , FILTER_VALIDATE_EMAIL ) ; } else { return parent :: valid_email ( $ str ) ; } } | Valid Email using filter_var if possible falling back to CI s regex |
227,261 | public function cdnObjectPickerMultiObjectRequired ( $ aValues ) { $ this -> set_message ( 'cdnObjectPickerMultiObjectRequired' , 'All items must have a file set.' ) ; foreach ( $ aValues as $ aValue ) { if ( empty ( $ aValue [ 'object_id' ] ) ) { return false ; } } return true ; } | Validates that all items within a CDN Object Multi Picker have a label set |
227,262 | public function is_unique ( $ sString , $ sParameters ) { $ aParameters = explode ( '.' , $ sParameters ) ; $ sTable = ArrayHelper :: getFromArray ( 0 , $ aParameters ) ; $ sColumn = ArrayHelper :: getFromArray ( 1 , $ aParameters ) ; $ sIgnoreId = ArrayHelper :: getFromArray ( 2 , $ aParameters ) ; $ sIgnoreColumn = A... | Checks a value is uniqe in a given table |
227,263 | public function is_bool ( $ bValue ) { $ this -> set_message ( 'is_bool' , lang ( 'fv_is_bool_field' ) ) ; return is_bool ( $ bValue ) || $ bValue === '1' || $ bValue === '0' || $ bValue === 1 || $ bValue === 0 ; } | Checks whether a value is a boolean value |
227,264 | public function supportedLocale ( $ sValue ) { $ oLocale = Factory :: service ( 'Locale' ) ; $ aSupportedLocales = $ oLocale -> getSupportedLocales ( ) ; if ( ! in_array ( $ sValue , $ aSupportedLocales ) ) { $ this -> set_message ( 'supportedLocale' , 'This is not a supported locale' ) ; return false ; } return true ;... | Determines whether the vlaue is a supported locale |
227,265 | public function is ( $ sValue , $ sExpected ) { if ( $ sValue !== $ sExpected ) { $ this -> set_message ( 'is' , 'This field must be exactly "' . $ sExpected . '"' ) ; return false ; } return true ; } | Determines whether a value is specifically something |
227,266 | public static function filter ( $ sType ) : array { if ( ! isset ( static :: $ aCache [ $ sType ] ) ) { $ aComponents = static :: available ( ) ; static :: $ aCache [ $ sType ] = [ ] ; foreach ( $ aComponents as $ oComponent ) { if ( $ oComponent -> type === $ sType ) { static :: $ aCache [ $ sType ] [ ] = $ oComponent... | Returns a filtered array of components |
227,267 | public static function getBySlug ( $ sSlug ) : ? Component { $ aComponents = static :: available ( ) ; foreach ( $ aComponents as $ oComponent ) { if ( $ oComponent -> slug === $ sSlug ) { return $ oComponent ; } } return null ; } | Returns a component by its slug |
227,268 | public static function getApp ( $ bUseCache = true ) : Component { if ( $ bUseCache && isset ( static :: $ aCache [ 'APP' ] ) ) { return static :: $ aCache [ 'APP' ] ; } $ sComposer = @ file_get_contents ( NAILS_APP_PATH . 'composer.json' ) ; if ( empty ( $ sComposer ) ) { ErrorHandler :: halt ( 'Failed to get app conf... | Returns an instance of the app as a component |
227,269 | public static function exists ( $ sSlug ) : bool { $ aModules = static :: modules ( ) ; foreach ( $ aModules as $ oModule ) { if ( $ sSlug === $ oModule -> slug ) { return true ; } } return false ; } | Test whether a component is installed |
227,270 | public static function skins ( $ sModule , $ sSubType = '' ) : array { $ aSkins = static :: filter ( 'skin' ) ; $ aOut = [ ] ; foreach ( $ aSkins as $ oSkin ) { if ( Functions :: isPageSecure ( ) ) { $ oSkin -> url = SECURE_BASE_URL . $ oSkin -> relativePath ; } else { $ oSkin -> url = BASE_URL . $ oSkin -> relativePat... | Returns registered skins optionally filtered |
227,271 | public static function drivers ( $ sModule , $ sSubType = '' ) : array { $ aDrivers = static :: filter ( 'driver' ) ; $ aOut = [ ] ; foreach ( $ aDrivers as $ oDriver ) { if ( $ oDriver -> forModule == $ sModule ) { if ( ! empty ( $ sSubType ) && $ sSubType == $ oDriver -> subType ) { $ aOut [ ] = $ oDriver ; } elseif ... | Returns registered drivers optionally filtered |
227,272 | public static function getDriverInstance ( $ oDriver ) : Base { if ( is_string ( $ oDriver ) ) { $ oDriver = \ Nails \ Components :: getBySlug ( $ oDriver ) ; } if ( isset ( static :: $ aCache [ 'DRIVER_INSTANCE' ] [ $ oDriver -> slug ] ) ) { return static :: $ aCache [ 'DRIVER_INSTANCE' ] [ $ oDriver -> slug ] ; } if ... | Returns an instance of a single driver |
227,273 | public static function detectClassComponent ( $ mClass ) : ? Component { $ oReflect = new \ ReflectionClass ( $ mClass ) ; $ sPath = $ oReflect -> getFileName ( ) ; $ bIsVendor = ( bool ) preg_match ( '/^' . preg_quote ( NAILS_APP_PATH . 'vendor' , '/' ) . '/' , $ sPath ) ; if ( ! $ bIsVendor ) { return static :: getAp... | Attempt to detect which component a class belongs to |
227,274 | public static function setNailsConstants ( ) { Functions :: define ( 'NAILS_PACKAGE_NAME' , 'Nails' ) ; Functions :: define ( 'NAILS_PACKAGE_URL' , 'http://nailsapp.co.uk/' ) ; Functions :: define ( 'NAILS_BRANDING' , true ) ; Functions :: define ( 'NAILS_PATH' , static :: $ sBaseDirectory . 'vendor/nails/' ) ; Functio... | Set Nails constants |
227,275 | private static function setupModules ( ) { $ aModuleLocations = [ ] ; $ aModules = Components :: modules ( ) ; $ aAbsolutePaths = [ [ rtrim ( APPPATH , DIRECTORY_SEPARATOR ) , 'modules' ] , [ rtrim ( FCPATH , DIRECTORY_SEPARATOR ) , 'vendor' , 'nails' , 'common' ] , ] ; $ aRelativePaths = [ [ '..' , 'modules' ] , [ '..... | Looks for modules and configures CI |
227,276 | protected function setDefinitions ( ) { $ aDefinitionLocations = [ ] ; $ aDefinitionLocations [ ] = NAILS_COMMON_PATH . 'config/app_notifications.php' ; foreach ( Components :: modules ( ) as $ oModule ) { $ aDefinitionLocations [ ] = $ oModule -> path . $ oModule -> moduleName . '/config/app_notifications.php' ; } $ a... | Defines the notifications |
227,277 | public function getDefinitions ( $ grouping = null ) { if ( is_null ( $ grouping ) ) { return $ this -> notifications ; } elseif ( isset ( $ this -> notifications [ $ grouping ] ) ) { return $ this -> notifications [ $ grouping ] ; } else { return [ ] ; } } | Returns the notification defnintions optionally limited per group |
227,278 | public static function possessive ( $ sString ) { $ sLastChar = substr ( $ sString , - 1 ) ; $ bIsLowerCase = strtolower ( $ sLastChar ) === $ sLastChar ; $ sPossessionChar = $ bIsLowerCase ? 's' : 'S' ; return substr ( $ sString , - 1 ) == $ sPossessionChar ? $ sString . '\'' : $ sString . '\'' . $ sPossessionChar ; } | Correctly adds a possessive apostrophe to a word |
227,279 | public static function pluralise ( $ iValue , $ sSingular , $ sSpecified = null ) { $ sSingular = trim ( $ sSingular ) ; if ( $ iValue == 1 ) { return $ sSingular ; } else { return $ sSpecified ? : plural ( $ sSingular ) ; } } | Pluralises english words if a value is greater than 1 |
227,280 | public function detectFromFile ( string $ sFile ) : string { if ( ! file_exists ( $ sFile ) ) { return '' ; } $ rHandle = finfo_open ( FILEINFO_MIME_TYPE ) ; $ sMime = finfo_file ( $ rHandle , $ sFile ) ; if ( $ sMime === 'application/octet-stream' || empty ( $ sMime ) ) { $ sMime = $ this -> oDetector -> getType ( $ s... | Detect a file s mimetype first using the system followed by the detector |
227,281 | public function addMime ( string $ sMime , array $ aExtensions ) : self { $ this -> updateMap ( static :: $ aMapMimeToExtensions , $ sMime , $ aExtensions ) ; foreach ( $ aExtensions as $ sExtension ) { $ this -> updateMap ( static :: $ aMapExtensionToMimes , $ sExtension , [ $ sMime ] ) ; } return $ this ; } | Adds a new mime type to the map and its associated extensions |
227,282 | public function addExtension ( string $ sExtension , array $ aMimes ) : self { $ this -> updateMap ( static :: $ aMapExtensionToMimes , $ sExtension , $ aMimes ) ; foreach ( $ aMimes as $ sMime ) { $ this -> updateMap ( static :: $ aMapMimeToExtensions , $ sMime , [ $ sExtension ] ) ; } return $ this ; } | Adds a new extension to the map and its associated mime types |
227,283 | protected function updateMap ( array & $ aMap , string $ sKey , array $ aValues ) : self { if ( ! array_key_exists ( $ sKey , $ aMap ) ) { $ aMap [ $ sKey ] = [ ] ; } $ aMap [ $ sKey ] = array_values ( array_unique ( array_merge ( $ aMap [ $ sKey ] , $ aValues ) ) ) ; return $ this ; } | Updates a map array |
227,284 | public function getDefault ( ) { $ sDefault = $ this -> oCi -> config -> item ( 'languages_default' ) ; $ oLanguage = $ this -> getByCode ( $ sDefault ) ; return ! empty ( $ oLanguage ) ? $ oLanguage : false ; } | Retursn the default language object |
227,285 | public function getDefaultCode ( ) { $ oDefault = $ this -> getDefault ( ) ; return empty ( $ oDefault -> code ) ? false : $ oDefault -> code ; } | Returns the default language s code |
227,286 | public function getDefaultLabel ( ) { $ oDefault = $ this -> getDefault ( ) ; return empty ( $ oDefault -> label ) ? false : $ oDefault -> label ; } | Returns the default language s label |
227,287 | public function getAllFlat ( ) { $ aOut = [ ] ; $ aLanguages = $ this -> getAll ( ) ; foreach ( $ aLanguages as $ oLanguage ) { $ aOut [ $ oLanguage -> code ] = $ oLanguage -> label ; } return $ aOut ; } | Returns all defined languages as a flat array |
227,288 | public function getAllEnabled ( ) { $ aEnabled = $ this -> oCi -> config -> item ( 'languages_enabled' ) ; $ aOut = [ ] ; foreach ( $ aEnabled as $ sCode ) { $ aOut [ ] = $ this -> getByCode ( $ sCode ) ; } return array_filter ( $ aOut ) ; } | Returns all the enabled languages |
227,289 | public function getAllEnabledFlat ( ) { $ aOut = [ ] ; $ aLanguages = $ this -> getAllEnabled ( ) ; foreach ( $ aLanguages as $ oLanguage ) { $ aOut [ $ oLanguage -> code ] = $ oLanguage -> label ; } return $ aOut ; } | Returns all the enabled languages as a flat array |
227,290 | public function getByCode ( $ sCode ) { $ aLanguages = $ this -> getAll ( ) ; return ! empty ( $ aLanguages [ $ sCode ] ) ? $ aLanguages [ $ sCode ] : false ; } | Returns a language by it s code |
227,291 | public function site_url ( $ sUrl = '' , $ bForceSecure = false ) { if ( preg_match ( '/^(http|https|ftp|mailto)\:/' , $ sUrl ) ) { return $ sUrl ; } $ sUrl = parent :: site_url ( $ sUrl ) ; if ( preg_match ( '/^\//' , $ sUrl ) && ! empty ( $ _SERVER [ 'HTTP_HOST' ] ) ) { $ sProtocol = ! empty ( $ _SERVER [ 'REQUEST_SC... | Returns the site s URL secured if necessary |
227,292 | public function delete ( $ mKey , $ sGrouping ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> trans_begin ( ) ; if ( is_array ( $ mKey ) ) { foreach ( $ mKey as $ sKey ) { $ this -> doDelete ( $ sKey , $ sGrouping ) ; } } else { $ this -> doDelete ( $ mKey , $ sGrouping ) ; } if ( $ oDb -> trans_status ( ) ===... | Deletes a key for a particular group |
227,293 | protected function doDelete ( $ sKey , $ sGrouping ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> where ( 'key' , $ sKey ) ; $ oDb -> where ( 'grouping' , $ sGrouping ) ; return $ oDb -> delete ( $ this -> sTable ) ; } | Actually performs the deletion of the row . |
227,294 | public function deleteGroup ( $ sGrouping ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> where ( 'grouping' , $ sGrouping ) ; return $ oDb -> delete ( $ this -> sTable ) ; } | Deletes all keys for a particular group . |
227,295 | private function getContentTypes ( Options $ options ) : array { $ allContentTypes = [ ] ; $ groups = $ this -> contentTypeService -> loadContentTypeGroups ( ) ; $ configuredGroups = $ options [ 'types' ] ; foreach ( $ groups as $ group ) { $ configuredGroups += [ $ group -> identifier => true ] ; if ( $ configuredGrou... | Returns the allowed content types from eZ Platform . |
227,296 | protected function _validate_request ( $ segments ) { if ( count ( $ segments ) == 0 ) { return $ segments ; } if ( $ located = $ this -> locate ( $ segments ) ) { return $ located ; } if ( isset ( $ this -> routes [ '404_override' ] ) && $ this -> routes [ '404_override' ] ) { $ segments = explode ( '/' , $ this -> ro... | Extending method purely to change the 404 behaviour and PSR - 2 things a little . |
227,297 | public function load ( $ mAssets , $ sAssetLocation = 'APP' , $ sForceType = null ) : self { $ aAssets = ( array ) $ mAssets ; $ sAssetLocation = $ sAssetLocation === true ? 'NAILS' : $ sAssetLocation ; switch ( strtoupper ( $ sAssetLocation ) ) { case 'NAILS-BOWER' : $ sAssetLocationMethod = 'loadNailsBower' ; break ;... | Loads an asset |
227,298 | protected function loadUrl ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : $ this -> aCss [ 'URL-' . $ sAsset ] = $ sAsset ; break ; case 'JS' : $ this -> aJs [ 'URL-' . $ sAsset ] = $ sAsset ; break ; } } | Loads an asset supplied as a URL |
227,299 | protected function loadNails ( $ sAsset , $ sForceType ) { $ sType = $ this -> determineType ( $ sAsset , $ sForceType ) ; switch ( $ sType ) { case 'CSS' : $ this -> aCss [ 'NAILS-' . $ sAsset ] = NAILS_ASSETS_URL . $ this -> sCssDir . $ sAsset ; break ; case 'JS' : $ this -> aJs [ 'NAILS-' . $ sAsset ] = NAILS_ASSETS... | Loads an asset from the Nails asset module |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.