idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
46,900
public static function search_roles ( $ group , $ role = '' ) { if ( $ role == '' ) { return false ; } $ db = \ App :: get ( 'db' ) ; $ query = "SELECT uidNumber FROM `#__xgroups_roles` as r, `#__xgroups_member_roles` as m WHERE r.id='" . $ role . "' AND r.id=m.roleid AND r.gidNumber='" . $ group -> gidNumber . "'" ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; $ result = array_intersect ( $ result , $ group -> members ) ; if ( count ( $ result ) > 0 ) { return $ result ; } }
Search group roles
46,901
public static function getPluginAccess ( $ group , $ get_plugin = '' ) { if ( ! ( $ group instanceof Group ) ) { return ; } $ hub_group_plugins = \ Event :: trigger ( 'groups.onGroupAreas' , array ( ) ) ; array_unshift ( $ hub_group_plugins , array ( 'name' => 'overview' , 'title' => 'Overview' , 'default_access' => 'anyone' ) ) ; $ active_group_plugins = array ( ) ; $ group_plugins = $ group -> get ( 'plugins' ) ; if ( $ group_plugins ) { $ group_plugins = explode ( ',' , $ group_plugins ) ; foreach ( $ group_plugins as $ plugin ) { $ temp = explode ( '=' , trim ( $ plugin ) ) ; if ( $ temp [ 0 ] ) { $ active_group_plugins [ $ temp [ 0 ] ] = trim ( $ temp [ 1 ] ) ; } } } $ group_plugin_access = array ( ) ; $ acceptable_levels = array ( 'nobody' , 'anyone' , 'registered' , 'members' ) ; if ( $ active_group_plugins ) { foreach ( $ hub_group_plugins as $ hgp ) { if ( ! isset ( $ active_group_plugins [ $ hgp [ 'name' ] ] ) || ! in_array ( $ active_group_plugins [ $ hgp [ 'name' ] ] , $ acceptable_levels ) ) { $ value = $ hgp [ 'default_access' ] ; } else { $ value = $ active_group_plugins [ $ hgp [ 'name' ] ] ; } $ group_plugin_access [ $ hgp [ 'name' ] ] = $ value ; } } else { foreach ( $ hub_group_plugins as $ hgp ) { $ value = $ hgp [ 'default_access' ] ; $ group_plugin_access [ $ hgp [ 'name' ] ] = $ value ; } } if ( $ get_plugin != '' ) { return $ group_plugin_access [ $ get_plugin ] ; } else { return $ group_plugin_access ; } }
Get the access level for a group plugin
46,902
public static function getDbo ( $ config = array ( ) , $ cname = '' ) { $ db = App :: get ( 'db' ) ; if ( ! $ group = Group :: getInstance ( \ Request :: getString ( 'cn' , $ cname ) ) ) { return $ db ; } if ( ! $ group -> isSuperGroup ( ) ) { return $ db ; } if ( empty ( $ config ) ) { $ uploadPath = \ Component :: params ( 'com_groups' ) -> get ( 'uploadpath' ) ; $ configPath = PATH_APP . DS . trim ( $ uploadPath , DS ) . DS . $ group -> get ( 'gidNumber' ) . DS . 'config' . DS . 'db.php' ; if ( ! file_exists ( $ configPath ) ) { return $ db ; } $ config = include $ configPath ; } return \ Hubzero \ Database \ Driver :: getInstance ( $ config ) ; }
Get Instance of Super Group Database
46,903
public static function getCustomParams ( $ oid = null , $ folder = null , $ element = null ) { $ result = self :: oneByPlugin ( $ oid , $ folder , $ element ) ; return new Registry ( $ result -> get ( 'params' ) ) ; }
Get the custom parameters for a plugin
46,904
public static function getDefaultParams ( $ folder = null , $ element = null ) { $ plugin = \ Plugin :: byType ( $ folder , $ element ) ; return new Registry ( $ plugin -> params ) ; }
Get the default parameters for a plugin
46,905
private function updateTrailing ( $ pos = 'lft' , $ base = 0 , $ add = true ) { $ query = $ this -> getQuery ( ) ; $ query -> update ( $ this -> getTableName ( ) ) ; $ query -> set ( [ $ pos => new Value \ Raw ( $ pos . ( $ add ? '+' : '-' ) . '2' ) , ] ) ; $ query -> where ( $ pos , '>=' , $ base ) -> where ( 'id' , '!=' , $ this -> id ) -> execute ( ) ; return $ this ; }
Updates all subsequent vars after new child insertion
46,906
private function resolveTrailing ( $ base , $ add = true ) { return $ this -> updateTrailing ( 'lft' , $ base , $ add ) -> updateTrailing ( 'rgt' , $ base , $ add ) ; }
Resolves the trailing left and right values for the new model
46,907
private function establishBaseParametersFromParent ( $ parent ) { $ this -> set ( 'parent_id' , $ parent -> id ) ; $ this -> set ( 'level' , $ parent -> level + 1 ) ; return $ this -> applyScopes ( $ parent ) ; }
Sets the default scopes on the model
46,908
private function applyScopes ( $ parent , $ method = 'set' ) { foreach ( $ this -> scopes as $ scope ) { $ this -> $ method ( $ scope , $ parent -> $ scope ) ; } return $ this ; }
Applies the scopes of the given model to the current
46,909
public function saveAsChildOf ( $ parent ) { $ this -> establishIsModel ( $ parent ) -> establishBaseParametersFromParent ( $ parent ) ; $ this -> set ( 'lft' , $ parent -> rgt ) ; $ this -> set ( 'rgt' , $ parent -> rgt + 1 ) ; if ( ! $ this -> save ( ) ) { return false ; } $ this -> resolveTrailing ( $ parent -> rgt ) ; return true ; }
Saves the current model to the database as the nth child of the given parent
46,910
public function saveAsFirstChildOf ( $ parent ) { $ this -> establishIsModel ( $ parent ) -> establishBaseParametersFromParent ( $ parent ) ; $ this -> set ( 'lft' , $ parent -> lft + 1 ) ; $ this -> set ( 'rgt' , $ parent -> lft + 2 ) ; if ( ! $ this -> save ( ) ) { return false ; } $ this -> resolveTrailing ( $ parent -> lft + 1 ) ; return true ; }
Saves the current model to the database as the first child of the given parent
46,911
public function saveAsRoot ( ) { $ this -> set ( 'parent_id' , 0 ) ; $ this -> set ( 'level' , 0 ) ; $ this -> set ( 'lft' , 0 ) ; $ this -> set ( 'rgt' , 1 ) ; return $ this -> save ( ) ; }
Saves a new root node element
46,912
public function destroy ( ) { if ( ! parent :: destroy ( ) ) { return false ; } foreach ( $ this -> getDescendants ( ) as $ descendant ) { $ descendant -> destroy ( ) ; $ this -> rgt -= 2 ; } $ this -> resolveTrailing ( $ this -> rgt , false ) ; return true ; }
Deletes a model rearranging subordinate nodes as appropriate
46,913
public function descendants ( $ level = null ) { $ instance = self :: blank ( ) ; $ instance -> where ( 'level' , '>' , $ this -> level ) -> order ( 'lft' , 'asc' ) ; if ( isset ( $ level ) ) { $ instance -> where ( 'level' , '<=' , $ this -> level + $ level ) ; } return $ instance -> where ( 'lft' , '>' , $ this -> lft ) -> where ( 'rgt' , '<' , $ this -> rgt ) -> applyScopesWhere ( $ this ) ; }
Establishes the query for all of the descendants of the current model
46,914
public function tally ( $ size ) { $ this -> size = number_format ( $ this -> size + $ size , 2 , '.' , '' ) ; $ this -> count ++ ; }
Increase cache items count .
46,915
public function construct ( ) { $ name = null ; if ( $ this -> arguments -> getOpt ( 'n' ) || $ this -> arguments -> getOpt ( 'name' ) || $ this -> arguments -> getOpt ( 4 ) ) { $ name = ( $ this -> arguments -> getOpt ( 4 ) ) ? $ this -> arguments -> getOpt ( 4 ) : $ name ; $ name = ( $ this -> arguments -> getOpt ( 'n' ) ) ? $ this -> arguments -> getOpt ( 'n' ) : $ name ; $ name = ( $ this -> arguments -> getOpt ( 'name' ) ) ? $ this -> arguments -> getOpt ( 'name' ) : $ name ; $ name = strtolower ( $ name ) ; } else { if ( $ this -> output -> isInteractive ( ) ) { $ name = $ this -> output -> getResponse ( 'What do you want the command name to be?' ) ; } else { $ this -> output -> error ( "Error: a command name should be provided." ) ; } } $ dest = PATH_CORE . DS . 'libraries' . DS . 'Hubzero' . DS . 'Console' . DS . 'Command' . DS . ucfirst ( $ name ) . '.php' ; $ this -> addTemplateFile ( "{$this->getType()}.tmpl" , $ dest ) -> addReplacement ( 'command_name' , $ name ) -> make ( ) ; }
Construct new command
46,916
private function bootAdapters ( ) { foreach ( glob ( __DIR__ . DS . 'Import' . DS . 'Adapter' . DS . '*.php' ) as $ adapter ) { require_once $ adapter ; } $ isAdapterClass = function ( $ class ) { return ( in_array ( 'Hubzero\Content\Import\Adapter' , class_implements ( $ class ) ) ) ; } ; $ this -> adapters = array_values ( array_filter ( get_declared_classes ( ) , $ isAdapterClass ) ) ; }
Method to boot import adapters
46,917
private function autoDetectAdapter ( Import $ import ) { if ( $ this -> adapter ) { return ; } $ dataPath = $ import -> getDataPath ( ) ; $ file = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ file , $ dataPath ) ; if ( $ mime == 'text/plain' ) { $ mime = pathinfo ( $ dataPath , PATHINFO_EXTENSION ) ; } $ respondsTo = function ( $ class ) use ( $ mime ) { return $ class :: accepts ( $ mime ) ; } ; $ responded = array_filter ( $ this -> adapters , $ respondsTo ) ; if ( $ adapter = array_shift ( $ responded ) ) { $ this -> setAdapter ( new $ adapter ( ) ) ; } if ( ! $ this -> adapter ) { throw new \ Exception ( \ Lang :: txt ( 'Content Import: No adapter found to count import data.' ) ) ; } }
Method auto detect adapter based on mime type
46,918
public function process ( Import $ import , array $ callbacks , $ dryRun = 1 ) { $ this -> autoDetectAdapter ( $ import ) ; $ import -> markRun ( $ dryRun ) ; return $ this -> getAdapter ( ) -> process ( $ import , $ callbacks , $ dryRun ) ; }
Process import data
46,919
public function saveas ( $ saveas = null ) { if ( ! is_null ( $ saveas ) ) { $ this -> _saveas = basename ( $ saveas ) ; } return $ this -> _saveas ; }
Set the name to save file as
46,920
public static function valid ( $ filename = null ) { if ( ! $ filename ) { return false ; } if ( preg_match ( "/^\s*http[s]{0,1}:/i" , $ filename ) ) { return false ; } if ( preg_match ( "/^\s*[\/]{0,1}index.php\?/i" , $ filename ) ) { return false ; } if ( preg_match ( "/^\s*[.]:/" , $ filename ) ) { return false ; } if ( strpos ( $ filename , '\\' ) ) { return false ; } if ( strpos ( $ filename , '..' ) ) { return false ; } return true ; }
Set the filename value
46,921
public function acceptranges ( $ acceptranges = null ) { if ( ! is_null ( $ acceptranges ) ) { $ this -> _acceptranges = ( $ acceptranges ) ? true : false ; } return $ this -> _acceptranges ; }
Set the acceptranges value
46,922
public function disposition ( $ disposition = null ) { if ( ! is_null ( $ disposition ) ) { if ( strcasecmp ( $ disposition , 'inline' ) == 0 ) { $ disposition = 'inline' ; } else if ( strcasecmp ( $ disposition , 'attachment' ) == 0 ) { $ disposition = 'attachment' ; } else { $ disposition = 'inline' ; } $ this -> _disposition = $ disposition ; } return $ this -> _disposition ; }
Set the disposition value
46,923
public function getAccessToken ( $ access_token ) { $ token = \ Components \ Developer \ Models \ Accesstoken :: oneByToken ( $ access_token ) ; if ( ! $ token -> get ( 'id' ) ) { return false ; } if ( ! $ token -> isPublished ( ) ) { return false ; } $ application = \ Components \ Developer \ Models \ Application :: oneOrFail ( $ token -> get ( 'application_id' ) ) ; $ token -> set ( 'client_id' , $ application -> get ( 'client_id' ) ) ; $ token -> set ( 'expires' , with ( new Date ( $ token -> get ( 'expires' ) ) ) -> toUnix ( ) ) ; return $ token -> toArray ( true ) ; }
Get Access token data
46,924
public function setAccessToken ( $ access_token , $ client_id , $ user_id , $ expires , $ scope = null ) { $ expires = with ( new Date ( $ expires ) ) -> toSql ( ) ; $ created = with ( new Date ( 'now' ) ) -> toSql ( ) ; $ client = $ this -> getClientDetails ( $ client_id ) ; $ model = new \ Components \ Developer \ Models \ Accesstoken ( ) ; $ model -> set ( 'application_id' , $ client [ 'id' ] ) ; $ model -> set ( 'access_token' , $ access_token ) ; $ model -> set ( 'uidNumber' , $ user_id ) ; $ model -> set ( 'expires' , $ expires ) ; $ model -> set ( 'created' , $ created ) ; return $ model -> save ( ) ; }
Store access token data
46,925
public function getClientDetails ( $ clientId ) { $ application = \ Components \ Developer \ Models \ Application :: oneByClientid ( $ clientId ) ; if ( ! $ application -> get ( 'id' ) ) { return false ; } if ( ! $ application -> isPublished ( ) ) { return false ; } return $ application -> toArray ( ) ; }
Get client details by client id
46,926
public function getClientDetailsById ( $ id ) { $ database = \ App :: get ( 'db' ) ; $ sql = "SELECT * FROM `#__developer_applications` WHERE `id`=" . $ database -> quote ( $ id ) ; $ database -> setQuery ( $ sql ) ; return $ database -> loadAssoc ( ) ; }
Get client details by id
46,927
public function checkRestrictedGrantType ( $ client_id , $ grant_type ) { $ client = $ this -> getClientDetails ( $ client_id ) ; if ( isset ( $ client [ 'grant_types' ] ) ) { $ grant_types = explode ( ' ' , $ client [ 'grant_types' ] ) ; return in_array ( $ grant_type , ( array ) $ grant_types ) ; } return true ; }
Check grant type against client id
46,928
public function isPublicClient ( $ client_id ) { $ client = $ this -> getClientDetails ( $ client_id ) ; return $ client && $ client [ 'state' ] != 2 ? true : false ; }
Is client public
46,929
public function getAuthorizationCode ( $ code ) { $ authorizationCode = \ Components \ Developer \ Models \ Authorizationcode :: oneByCode ( $ code ) ; if ( ! $ authorizationCode -> get ( 'id' ) ) { return false ; } $ application = \ Components \ Developer \ Models \ Application :: oneOrFail ( $ authorizationCode -> get ( 'application_id' ) ) ; $ authorizationCode -> set ( 'client_id' , $ application -> get ( 'client_id' ) ) ; $ authorizationCode -> set ( 'expires' , with ( new Date ( $ authorizationCode -> get ( 'expires' ) ) ) -> toUnix ( ) ) ; return $ authorizationCode -> toArray ( ) ; }
Get authorization code details by code
46,930
public function setAuthorizationCode ( $ code , $ client_id , $ user_id , $ redirect_uri , $ expires , $ scope = null ) { $ expires = with ( new Date ( $ expires ) ) -> toSql ( ) ; $ client = $ this -> getClientDetails ( $ client_id ) ; $ model = new \ Components \ Developer \ Models \ Authorizationcode ( ) ; $ model -> set ( 'application_id' , $ client [ 'id' ] ) ; $ model -> set ( 'authorization_code' , $ code ) ; $ model -> set ( 'uidNumber' , $ user_id ) ; $ model -> set ( 'redirect_uri' , $ redirect_uri ) ; $ model -> set ( 'expires' , $ expires ) ; return $ model -> save ( ) ; }
Create new authorization code
46,931
public function expireAuthorizationCode ( $ code ) { $ authorizationCode = \ Components \ Developer \ Models \ Authorizationcode :: oneByCode ( $ code ) ; if ( ! $ authorizationCode -> get ( 'id' ) ) { return false ; } return $ authorizationCode -> destroy ( ) ; }
Remove invalid authorization code
46,932
public function checkUserCredentials ( $ username , $ password ) { if ( strpos ( $ username , '@' ) ) { $ username = $ this -> getUsernameFromEmail ( $ username ) ; } $ match = Password :: passwordMatches ( $ username , $ password , true ) ; return ( bool ) $ match ; }
Check user credentials
46,933
public function getUserDetails ( $ username ) { if ( strpos ( $ username , '@' ) ) { $ username = $ this -> getUsernameFromEmail ( $ username ) ; } $ profile = \ Hubzero \ User \ User :: oneByUsername ( $ username ) ; if ( ! $ profile -> get ( 'id' ) ) { return false ; } return [ 'user_id' => $ profile -> get ( 'id' ) , 'scope' => null ] ; }
Get user information
46,934
private function getUsernameFromEmail ( $ enteredUsername ) { $ result = \ Hubzero \ User \ User :: oneByEmail ( $ enteredUsername ) ; if ( ! $ result || ! $ result -> get ( 'id' ) ) { return null ; } return $ result -> get ( 'username' ) ; }
Get username from email address
46,935
public function getRefreshToken ( $ refresh_token ) { $ token = \ Components \ Developer \ Models \ Refreshtoken :: oneByToken ( $ refresh_token ) ; if ( ! $ token -> get ( 'id' ) ) { return false ; } if ( ! $ token -> isPublished ( ) ) { return false ; } $ application = \ Components \ Developer \ Models \ Application :: oneOrFail ( $ token -> get ( 'application_id' ) ) ; $ token -> set ( 'client_id' , $ application -> get ( 'client_id' ) ) ; $ token -> set ( 'expires' , with ( new Date ( $ token -> get ( 'expires' ) ) ) -> toUnix ( ) ) ; return $ token -> toArray ( ) ; }
Load refresh token details by token
46,936
public function setRefreshToken ( $ refresh_token , $ client_id , $ user_id , $ expires , $ scope = null ) { $ expires = with ( new Date ( $ expires ) ) -> toSql ( ) ; $ created = with ( new Date ( 'now' ) ) -> toSql ( ) ; $ client = $ this -> getClientDetails ( $ client_id ) ; $ model = new \ Components \ Developer \ Models \ Refreshtoken ( ) ; $ model -> set ( 'application_id' , $ client [ 'id' ] ) ; $ model -> set ( 'refresh_token' , $ refresh_token ) ; $ model -> set ( 'uidNumber' , $ user_id ) ; $ model -> set ( 'expires' , $ expires ) ; $ model -> set ( 'created' , $ created ) ; return $ model -> save ( ) ; }
Create a refresh token
46,937
public function unsetRefreshToken ( $ refresh_token ) { $ token = \ Components \ Developer \ Models \ RefreshToken :: oneByToken ( $ refresh_token ) ; if ( ! $ token -> get ( 'id' ) ) { return false ; } return $ token -> destroy ( ) ; }
Remove refresh token
46,938
public function getSessionIdFromCookie ( ) { $ client = 'site' ; if ( isset ( $ _SERVER [ 'HTTP_REFERER' ] ) && $ _SERVER [ 'HTTP_REFERER' ] ) { $ referrer = $ _SERVER [ 'HTTP_REFERER' ] ; if ( \ Hubzero \ Utility \ Uri :: isInternal ( $ referrer ) ) { if ( substr ( $ referrer , 0 , strlen ( 'http' ) ) == 'http' ) { $ referrer = parse_url ( $ referrer , PHP_URL_PATH ) ; } $ referrer = trim ( $ referrer , '/' ) ; $ parts = explode ( '/' , $ referrer ) ; $ referrer = array_shift ( $ parts ) ; if ( $ referrer == 'administrator' ) { $ client = $ referrer ; } } } $ sessionName = md5 ( \ App :: hash ( $ client ) ) ; return ( ! empty ( $ _COOKIE [ $ sessionName ] ) ) ? $ _COOKIE [ $ sessionName ] : null ; }
Get session id from cookie
46,939
public function getUserIdFromSessionId ( $ sessionId ) { $ database = \ App :: get ( 'db' ) ; $ timeout = \ App :: get ( 'config' ) -> get ( 'timeout' ) ; $ sql = "SELECT userid FROM `#__session` WHERE `session_id`=" . $ database -> quote ( $ sessionId ) . " AND time + " . ( int ) $ timeout . " <= NOW();" ; $ database -> setQuery ( $ sql ) ; return $ database -> loadResult ( ) ; }
Get user id via session id
46,940
public function getToolSessionDataFromRequest ( RequestInterface $ request ) { $ toolSessionId = $ request -> request ( 'sessionnum' ) ; $ toolSessionToken = $ request -> request ( 'sessiontoken' ) ; if ( ! $ toolSessionId && ! $ toolSessionToken ) { $ toolSessionId = $ request -> headers ( 'sessionnum' ) ; $ toolSessionToken = $ request -> headers ( 'sessiontoken' ) ; } return compact ( 'toolSessionId' , 'toolSessionToken' ) ; }
Get tool data from request
46,941
public function validateToolSessionData ( $ toolSessionId , $ toolSessionToken ) { require_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'helpers' . DS . 'utils.php' ; $ mwdb = \ Components \ Tools \ Helpers \ Utils :: getMWDBO ( ) ; $ query = "SELECT * FROM `session` WHERE `sessnum`= " . $ mwdb -> quote ( $ toolSessionId ) . " AND `sesstoken`=" . $ mwdb -> quote ( $ toolSessionToken ) ; $ mwdb -> setQuery ( $ query ) ; if ( ! $ session = $ mwdb -> loadObject ( ) ) { return false ; } $ profile = \ Hubzero \ User \ User :: oneByUsername ( $ session -> username ) ; return $ profile -> get ( 'id' ) ; }
Validate tool session data
46,942
public function getInternalRequestClient ( ) { if ( ! $ client = $ this -> findInternalClient ( ) ) { if ( $ this -> createInternalRequestClient ( ) ) { $ client = $ this -> findInternalClient ( ) ; } } return ( $ client ) ? $ client : null ; }
Get internal client
46,943
private function findInternalClient ( ) { $ application = \ Components \ Developer \ Models \ Application :: all ( ) -> whereEquals ( 'hub_account' , 1 ) -> row ( ) ; if ( ! $ application -> get ( 'id' ) ) { return false ; } return $ application -> toArray ( ) ; }
Find Internal Client
46,944
public function createInternalRequestClient ( ) { $ clientId = md5 ( uniqid ( \ User :: get ( 'id' ) , true ) ) ; $ clientSecret = sha1 ( $ clientId ) ; $ application = new \ Components \ Developer \ Models \ Application ( ) ; $ application -> set ( 'name' , 'Hub Account' ) ; $ application -> set ( 'description' , 'Hub account for internal requests. DO NOT DELETE.' ) ; $ application -> set ( 'redirect_uri' , 'https://' . $ _SERVER [ 'HTTP_HOST' ] ) ; $ application -> set ( 'client_id' , $ clientId ) ; $ application -> set ( 'client_secret' , $ clientSecret ) ; $ application -> set ( 'grant_types' , 'client_credentials session tool' ) ; $ application -> set ( 'created' , with ( new Date ( 'now' ) ) -> toSql ( ) ) ; $ application -> set ( 'created_by' , \ User :: get ( 'id' ) ) ; $ application -> set ( 'state' , 1 ) ; $ application -> set ( 'hub_account' , 1 ) ; $ application -> save ( ) ; return true ; }
Create internal client
46,945
public function fetchId ( $ type = 'Standard' , $ name = '' , $ text = '' , $ task = '' , $ list = true , $ hideMenu = false ) { return $ this -> _parent -> getName ( ) . '-' . $ name ; }
Get the button CSS Id
46,946
public function setImageUrl ( $ imageUrl = '' ) { $ this -> imageUrl = $ imageUrl ; $ imageSizes = @ getimagesize ( $ this -> imageUrl ) ; if ( $ imageSizes ) { list ( $ this -> imageWidth , $ this -> imageHeight ) = $ imageSizes ; } else { $ this -> setError ( 'Unable to get details of image' ) ; } }
Mutator Method to set Image Url
46,947
private function _mozifyCss ( ) { $ class = $ this -> getCssClassName ( ) ; $ css = '<style type="text/css">' ; $ css .= '.ExternalClass .ecxhm1_3 { width:' . $ this -> imageWidth . 'px !important; height:' . $ this -> imageHeight . 'px !important; float:none !important }' ; $ css .= '.ExternalClass .ecxhm2_3 { display:none !important }' ; $ css .= '.' . $ class . ' td b { width:1px; height:1px; font-size:1px }' ; $ css .= '.' . $ class . '{ -webkit-text-size-adjust: none }' ; $ css .= '</style>' ; return $ css ; }
Generate CSS needed for mozify
46,948
private function _mozifyStartMsoHack ( ) { $ class = $ this -> getCssClassName ( ) ; $ mosHack = '<!--[if mso]><style>.' . $ class . '{ display:none !important }</style><table cellpadding="0" cellspacing="0" style="display:block;float:none;" align=""><tr><td>' ; $ mosHack .= '<img src="' . $ this -> imageUrl . '" alt="' . $ this -> imageAlt . '" style="display:block;" moz="3" valid="true" height="' . $ this -> imageHeight . '" width="' . $ this -> imageWidth . '"></td></tr></table><style type="text/css">/*<![endif] ; return $ mosHack ; }
Output the start of the MSO hack
46,949
private function _mozifyMosaic ( ) { $ resource = imagecreatefromstring ( file_get_contents ( $ this -> imageUrl ) ) ; $ class = $ this -> getCssClassName ( ) ; $ mosaic = '<table width="' . $ this -> imageWidth . '" height="' . $ this -> imageHeight . '" cellspacing="0" cellpadding="0" border="0" bgcolor="#fefefe" class="' . $ class . '">' ; $ mosaic .= '<tbody>' ; for ( $ y = 0 ; $ y < $ this -> imageHeight ; $ y += $ this -> mosaicSize ) { $ mosaic .= '<tr>' ; for ( $ x = 0 ; $ x < $ this -> imageWidth ; $ x += $ this -> mosaicSize ) { $ color = imagecolorat ( $ resource , $ x , $ y ) ; $ rgba = imagecolorsforindex ( $ resource , $ color ) ; $ color_string = $ this -> _rgb2hex ( $ rgba ) ; $ mosaic .= '<td width="' . $ this -> mosaicSize . '" bgcolor="' . $ color_string . '"><b></b></td>' . PHP_EOL ; } $ mosaic .= '</tr>' . PHP_EOL ; } $ mosaic .= '</tbody>' ; $ mosaic .= '</table>' ; return $ mosaic ; }
Create a mosaic
46,950
private function _rgb2hex ( array $ rgb ) { if ( isset ( $ rgb [ 'alpha' ] ) ) { unset ( $ rgb [ 'alpha' ] ) ; } $ out = "" ; foreach ( $ rgb as $ c ) { $ hex = base_convert ( $ c , 10 , 16 ) ; $ out .= ( $ c < 16 ) ? ( "0" . $ hex ) : $ hex ; } return '#' . strtoupper ( $ out ) ; }
Cinvert an RGB value to hex
46,951
public static function detectByFileExtension ( $ extension ) { static $ extensionToMimeTypeMap ; if ( ! $ extensionToMimeTypeMap ) { $ extensionToMimeTypeMap = static :: getExtensionToMimeTypeMap ( ) ; } if ( isset ( $ extensionToMimeTypeMap [ $ extension ] ) ) { return $ extensionToMimeTypeMap [ $ extension ] ; } }
Detects MIME Type based on file extension .
46,952
public function constrain ( ) { $ this -> mediate ( ) ; $ this -> related -> whereEquals ( $ this -> associativeTable . '.' . $ this -> associativeLocal , $ this -> model -> getPkValue ( ) ) ; return $ this -> related ; }
Loads the relationship content and returns the related side of the model
46,953
public function getConstrainedKeys ( $ constraint ) { $ this -> mediate ( ) ; return array_unique ( $ this -> getConstrained ( $ constraint ) -> fieldsByKey ( $ this -> associativeLocal ) ) ; }
Get keys based on a given constraint
46,954
public function join ( ) { $ this -> model -> select ( $ this -> model -> getQualifiedFieldName ( '*' ) ) -> select ( $ this -> related -> getQualifiedFieldName ( '*' ) ) -> join ( $ this -> associativeTable , $ this -> model -> getQualifiedFieldName ( $ this -> localKey ) , $ this -> associativeLocal , 'LEFT OUTER' ) -> join ( $ this -> related -> getTableName ( ) , $ this -> associativeRelated , $ this -> related -> getQualifiedFieldName ( $ this -> relatedKey ) , 'LEFT OUTER' ) ; return $ this ; }
Joins the intermediate and related tables together to the model for the pending query
46,955
protected function getResultsByRelatedKey ( $ relations ) { $ resultsByRelatedKey = [ ] ; foreach ( $ relations as $ relation ) { if ( ! isset ( $ resultsByRelatedKey [ $ relation -> { $ this -> associativeLocal } ] ) ) { $ resultsByRelatedKey [ $ relation -> { $ this -> associativeLocal } ] = new Rows ; } $ resultsByRelatedKey [ $ relation -> { $ this -> associativeLocal } ] -> push ( $ relation ) ; } return $ resultsByRelatedKey ; }
Sorts the relations into arrays keyed by the related key
46,956
private function processCommands ( ) { $ this -> getCommands ( ) ; $ commands = $ this -> _commands ; sort ( $ commands ) ; $ commands = $ this -> mergeCommands ( $ commands ) ; $ this -> addEntries ( $ commands ) ; }
Parse the commands directory in search of available commands
46,957
private function getCommands ( $ root = null , $ dir = null ) { $ root = $ root ? : __DIR__ ; $ dir = $ dir ? : '' ; $ cur = $ root . ( ( ! empty ( $ dir ) ) ? DS . $ dir : '' ) ; $ files = array_diff ( scandir ( $ cur ) , array ( '..' , '.' ) ) ; foreach ( $ files as $ file ) { if ( is_file ( $ cur . DS . $ file ) && strpos ( $ file , '.php' ) !== false ) { $ namespace = str_replace ( $ root . DS , '' , $ cur . DS . $ file ) ; $ namespace = str_replace ( DS , '\\' , $ namespace ) ; $ class = str_replace ( '.php' , '' , $ namespace ) ; if ( class_exists ( __NAMESPACE__ . '\\' . $ class ) ) { $ reflection = new \ ReflectionClass ( __NAMESPACE__ . '\\' . $ class ) ; if ( $ reflection -> implementsInterface ( __NAMESPACE__ . '\CommandInterface' ) ) { $ comment = $ reflection -> getDocComment ( ) ; if ( ! preg_match ( '/@museIgnoreHelp/' , $ comment ) ) { $ this -> _commands [ ] = $ class ; } } } } else if ( is_dir ( $ cur . DS . $ file ) ) { $ this -> getCommands ( $ root , ( ( ! empty ( $ dir ) ) ? $ dir . DS : '' ) . $ file ) ; } } }
Helper to get files in commands directy . This is used to generate a list of commands .
46,958
private function mergeCommands ( $ commands ) { $ parsed = array ( ) ; foreach ( $ commands as $ command ) { $ bits = array ( ) ; if ( strpos ( $ command , '\\' ) ) { $ bits = explode ( '\\' , $ command ) ; $ command = $ bits [ count ( $ bits ) - 1 ] ; unset ( $ bits [ count ( $ bits ) - 1 ] ) ; } $ aux = & $ parsed ; foreach ( $ bits as $ b ) { $ aux = & $ aux [ $ b ] ; } $ aux [ ] = $ command ; } return $ parsed ; }
Merge flat list of commands into dimensional array
46,959
private function addEntries ( $ entry , $ ind = 1 , $ path = '' ) { if ( is_array ( $ entry ) ) { foreach ( $ entry as $ element => $ entry ) { if ( is_string ( $ element ) && ! empty ( $ path ) ) { $ this -> output -> addLine ( $ element , array ( 'color' => 'blue' , 'indentation' => $ ind + 2 ) ) ; } $ this -> addEntries ( $ entry , $ ind + 2 , $ path . ( ( is_string ( $ element ) ) ? "\\{$element}" : '' ) ) ; } } else { $ this -> output -> addLine ( $ entry , array ( 'color' => ( ( $ ind > 3 ) ? 'blue' : 'green' ) , 'indentation' => $ ind ) ) ; $ ind += 2 ; $ reflection = new \ ReflectionClass ( __NAMESPACE__ . $ path . '\\' . $ entry ) ; $ methods = $ reflection -> getMethods ( ) ; foreach ( $ methods as $ method ) { if ( $ method -> isPublic ( ) && ! $ method -> isConstructor ( ) && $ method -> name != 'execute' && $ method -> name != 'help' ) { $ this -> output -> addLine ( $ method -> name , array ( 'color' => 'yellow' , 'indentation' => $ ind ) ) ; } } } }
Output command entries
46,960
public function clear ( ) { $ cacheDir = PATH_APP . DS . 'cache' ; $ files = array ( 'site.css' , 'site.less.cache' ) ; foreach ( $ files as $ file ) { if ( ! is_file ( $ cacheDir . DS . $ file ) ) { $ this -> output -> addLine ( $ file . ' does not exist' , 'warning' ) ; continue ; } if ( ! Filesystem :: delete ( $ cacheDir . DS . $ file ) ) { $ this -> output -> addLine ( 'Unable to delete cache file: ' . $ file , 'error' ) ; } else { $ this -> output -> addLine ( $ file . ' deleted' , 'success' ) ; } } $ this -> output -> addLine ( 'All CSS cache files removed!' , 'success' ) ; }
Clear Site . css & Site . less . cache files
46,961
public function callTransformer ( $ name , $ arguments = [ ] ) { return call_user_func_array ( array ( $ this , 'transform' . ucfirst ( $ this -> snakeToCamel ( $ name ) ) ) , $ arguments ) ; }
Calls the requested transformer passing the given arguments
46,962
public function parse ( $ field , $ as = 'parsed' ) { switch ( strtolower ( $ as ) ) { case 'parsed' : $ property = "_{$field}Parsed" ; if ( ! isset ( $ this -> $ property ) ) { $ this -> $ property = Html :: content ( 'prepare' , $ this -> get ( $ field , '' ) ) ; } return $ this -> $ property ; break ; case 'raw' : default : $ content = stripslashes ( $ this -> get ( $ field , '' ) ) ; return preg_replace ( '/^(<!-- \{FORMAT:.*\} , '' , $ content ) ; break ; } }
Parses content string as directed
46,963
public function snakeToCamel ( $ text ) { if ( strpos ( $ text , '_' ) !== false ) { $ bits = explode ( '_' , $ text ) ; $ bits = array_map ( 'ucfirst' , $ bits ) ; $ text = lcfirst ( implode ( '' , $ bits ) ) ; } return $ text ; }
Takes a snake - cased string and camel cases it
46,964
public function newQuery ( ) { $ select = ( $ this -> getTableAlias ( ) ? $ this -> getTableAlias ( ) . '.' : '' ) . '*' ; $ this -> query = $ this -> getQuery ( ) -> select ( $ select ) -> from ( $ this -> getTableName ( ) , $ this -> getTableAlias ( ) ) ; return $ this ; }
Sets a fresh query object on the model seeding it with helpful defaults
46,965
public function getPkValue ( ) { return isset ( $ this -> attributes [ $ this -> getPrimaryKey ( ) ] ) ? $ this -> attributes [ $ this -> getPrimaryKey ( ) ] : null ; }
Gets the value of the primary key
46,966
public function getQualifiedFieldName ( $ field ) { $ tbl = ( $ this -> getTableAlias ( ) ? $ this -> getTableAlias ( ) : $ this -> getTableName ( ) ) ; return $ tbl . '.' . $ field ; }
Creates the fully qualified field name by prepending the table name
46,967
public function total ( ) { $ first = $ this -> deselect ( ) -> select ( $ this -> getQualifiedFieldName ( $ this -> getPrimaryKey ( ) ) , 'count' , true ) -> unordered ( ) -> rows ( false ) -> first ( ) ; $ total = $ first ? ( int ) $ first -> count : 0 ; $ this -> reset ( ) ; return $ total ; }
Get total number of rows
46,968
public function rows ( $ parseIncludes = true ) { $ rows = $ this -> rowsFromRaw ( $ this -> query -> fetch ( 'rows' , $ this -> noCache ) ) ; if ( $ parseIncludes ) { $ rows = $ this -> parseIncluding ( $ rows ) ; } $ rows -> pagination = $ this -> pagination ; $ rows -> orderBy = $ this -> orderBy ; $ rows -> orderDir = $ this -> orderDir ; return $ rows ; }
Gets the results of the established query
46,969
public function rowsFromRaw ( $ data ) { $ rows = new Rows ; if ( $ data && count ( $ data ) > 0 ) { foreach ( $ data as $ row ) { $ rows -> push ( self :: newFromResults ( $ row ) ) ; } } return $ rows ; }
Sets the results of the query on new models and returns a Rows collection
46,970
public function offsetSet ( $ key , $ value ) { if ( is_array ( $ key ) || is_object ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> attributes [ $ k ] = $ v ; } } else { $ this -> attributes [ $ key ] = $ value ; } }
Sets the atrributes key with value
46,971
public static function one ( $ id ) { $ instance = self :: blank ( ) ; return $ instance -> whereEquals ( $ instance -> getPrimaryKey ( ) , $ id ) -> rows ( ) -> seek ( $ id ) ; }
Retrieves one row by primary key value provided
46,972
public static function oneOrFail ( $ id ) { $ row = self :: one ( $ id ) ; if ( $ row === false ) { throw new RuntimeException ( "Failed to retrieve a model with a primary key of {$id}" , 404 ) ; } return $ row ; }
Retrieves one row by primary key throwing a new exception if not found
46,973
public static function oneOrNew ( $ id ) { $ row = self :: one ( $ id ) ; if ( $ row === false ) { $ row = self :: blank ( ) ; } return $ row ; }
Retrieves one row by primary key returning an empty row if not found
46,974
public function getTableColumnsOnly ( ) { $ data = $ this -> attributes ; $ tableColumns = $ this -> getStructure ( ) -> getTableColumns ( $ this -> table ) ; if ( ! empty ( $ tableColumns ) ) { $ data = array_intersect_key ( $ data , $ tableColumns ) ; } return $ data ; }
Filters out fields that are not actually a table column
46,975
private function create ( ) { $ this -> parseAutomatics ( 'initiate' ) ; $ data = $ this -> getTableColumnsOnly ( ) ; return $ this -> query -> push ( $ this -> getTableName ( ) , $ data ) ; }
Inserts a new row into the database
46,976
private function modify ( ) { $ this -> parseAutomatics ( 'renew' ) ; $ data = $ this -> getTableColumnsOnly ( ) ; return $ this -> query -> alter ( $ this -> getTableName ( ) , $ this -> getPrimaryKey ( ) , $ this -> getPkValue ( ) , $ data ) ; }
Updates an existing item in the database
46,977
private function parseAutomatics ( $ scope = 'always' ) { $ automatics = array_merge ( $ this -> $ scope , $ this -> always ) ; if ( ! empty ( $ automatics ) ) { foreach ( $ automatics as $ field ) { if ( strpos ( $ field , '_' ) ) { $ bits = explode ( '_' , $ field ) ; $ bits = array_map ( 'ucfirst' , $ bits ) ; $ method = implode ( '' , $ bits ) ; } else { $ method = ucfirst ( $ field ) ; } $ method = 'automatic' . $ method ; $ this -> set ( $ field , $ this -> $ method ( $ this -> attributes ) ) ; } } return $ this ; }
Parses for automatically fillable fields
46,978
public function saveAndPropagate ( ) { if ( ! $ this -> save ( ) ) { return false ; } foreach ( $ this -> getRelationships ( ) as $ relationship ) { if ( ! $ relationship -> save ( ) ) { $ this -> setErrors ( $ relationship -> getErrors ( ) ) ; return false ; } } return true ; }
Saves the current model and any subsequent attached models
46,979
public function checkout ( $ userId = null ) { if ( ! $ this -> isNew ( ) ) { $ columns = $ this -> getStructure ( ) -> getTableColumns ( $ this -> getTableName ( ) ) ; $ data = [ ] ; if ( isset ( $ columns [ 'checked_out_time' ] ) ) { $ now = new Date ( 'now' ) ; $ data [ 'checked_out_time' ] = $ now -> toSql ( ) ; } if ( isset ( $ columns [ 'checked_out' ] ) ) { $ userId = $ userId ? : \ User :: get ( 'id' ) ; $ data [ 'checked_out' ] = $ userId ; } if ( empty ( $ data ) ) { return true ; } $ this -> set ( $ data ) ; $ query = $ this -> getQuery ( ) -> update ( $ this -> getTableName ( ) ) -> set ( $ data ) -> whereEquals ( $ this -> getPrimaryKey ( ) , $ this -> get ( $ this -> getPrimaryKey ( ) ) ) ; if ( ! $ query -> execute ( ) ) { $ this -> addError ( __CLASS__ . '::' . __METHOD__ . '() failed' ) ; return false ; } } return true ; }
Checks out the current model to the provided user
46,980
public function checkin ( ) { if ( ! $ this -> isNew ( ) ) { $ columns = $ this -> getStructure ( ) -> getTableColumns ( $ this -> getTableName ( ) , false ) ; $ data = [ ] ; $ orig = [ ] ; foreach ( $ columns as $ column ) { if ( $ column [ 'name' ] == 'checked_out_time' ) { $ orig [ 'checked_out_time' ] = $ this -> get ( 'checked_out_time' ) ; $ data [ 'checked_out_time' ] = $ column [ 'default' ] ; } if ( $ column [ 'name' ] == 'checked_out' ) { $ orig [ 'checked_out' ] = $ this -> get ( 'checked_out' ) ; $ data [ 'checked_out' ] = $ column [ 'default' ] ; } } if ( empty ( $ data ) ) { return true ; } $ this -> set ( $ data ) ; $ query = $ this -> getQuery ( ) -> update ( $ this -> getTableName ( ) ) -> set ( $ data ) -> whereEquals ( $ this -> getPrimaryKey ( ) , $ this -> get ( $ this -> getPrimaryKey ( ) ) ) ; if ( ! $ query -> execute ( ) ) { $ this -> set ( $ orig ) ; $ this -> addError ( __CLASS__ . '::' . __METHOD__ . '() failed' ) ; return false ; } } return true ; }
Checks back in the current model
46,981
public function whereRelatedHas ( $ relationship , $ constraint , $ depth = 0 ) { $ rel = $ this -> $ relationship ( ) ; $ keys = $ rel -> getConstrainedKeys ( $ constraint ) ; return $ this -> where ( $ rel -> getLocalKey ( ) , 'IN' , $ keys , 'and' , $ depth ) ; }
Selects applicable rows on the relation and limits current query accordingly
46,982
public function whereRelatedHasCount ( $ relationship , $ count = 1 , $ depth = 0 , $ operator = '>=' ) { $ rel = $ this -> $ relationship ( ) ; $ keys = $ rel -> getConstrainedKeysByCount ( $ count , $ operator ) ; return $ this -> where ( $ rel -> getLocalKey ( ) , 'IN' , $ keys , 'and' , $ depth ) ; }
Selects rows where related table has at least x number of entries
46,983
private function whereRelated ( $ relationship , $ constraint ) { $ this -> data = [ ] ; $ keys = null ; if ( strpos ( $ name , '.' ) ) { list ( $ name , $ subs ) = explode ( '.' , $ name , 2 ) ; $ relationship = $ this -> $ name ( ) ; $ this -> data [ $ name ] = $ relationship -> whereRelated ( $ subs , $ constraint ) ; } else { $ relationship = $ this -> $ name ( ) ; $ this -> data [ $ name ] = $ relationship -> getConstrainedRows ( $ constraint ) ; } $ keys = is_null ( $ keys ) ? $ relationship -> getRelatedKeysFromRows ( $ this -> data [ $ name ] ) : array_intersect ( $ keys , $ relationship -> getRelatedKeysFromRows ( $ this -> data [ $ name ] ) ) ; $ keys = array_unique ( $ keys ) ; if ( ! empty ( $ keys ) ) { $ this -> whereIn ( $ relationship -> getLocalKey ( ) , $ keys ) ; } return $ this ; }
Limits current model based on conditions of relationship
46,984
private function seed ( $ rows ) { foreach ( $ this -> data as $ relationship => $ data ) { $ rows = $ this -> $ relationship ( ) -> seedWithData ( $ rows , $ data , $ relationship ) ; } return $ rows ; }
Seeds the rows with any pre - fetched data
46,985
public function validate ( ) { $ validity = Rules :: validate ( $ this -> attributes , $ this -> getRules ( ) ) ; if ( $ validity === true ) { return true ; } $ this -> setErrors ( $ validity ) ; return false ; }
Validates the set data attributes against the model rules
46,986
public function paginated ( $ start = 'start' , $ limit = 'limit' ) { $ this -> pagination = Pagination :: init ( $ this -> getModelName ( ) , $ this -> copy ( ) -> total ( ) , $ start , $ limit ) ; $ this -> start ( $ this -> pagination -> start ) ; $ this -> limit ( $ this -> pagination -> limit ) ; return $ this ; }
Retrieves a chuck of data based on standard pagination parameters
46,987
public function ordered ( $ orderBy = 'orderby' , $ orderDir = 'orderdir' ) { $ this -> orderBy = \ Request :: getCmd ( $ orderBy , $ this -> getState ( 'orderby' , $ this -> orderBy ) ) ; $ this -> orderDir = \ Request :: getCmd ( $ orderDir , $ this -> getState ( 'orderdir' , $ this -> orderDir ) ) ; $ qualifiedOrderBy = $ this -> orderBy ; if ( strpos ( $ this -> orderBy , '.' ) !== false ) { list ( $ relationship , $ field ) = explode ( '.' , $ this -> orderBy ) ; $ relationship = $ this -> $ relationship ( ) -> join ( ) ; $ qualifiedOrderBy = $ relationship -> getQualifiedFieldName ( $ field ) ; } $ this -> order ( $ qualifiedOrderBy , $ this -> orderDir ) ; $ this -> setState ( 'orderby' , $ this -> orderBy ) ; $ this -> setState ( 'orderdir' , $ this -> orderDir ) ; return $ this ; }
Sets the ordering based on the established request variables
46,988
public function getState ( $ var , $ default = null ) { $ key = str_replace ( '\\' , '.' , $ this -> getModelNamespace ( ) ) . '.' . $ this -> getModelName ( ) . ".{$var}" ; return \ User :: getState ( $ key , $ default ) ; }
Retrieves state vars set in the model namespace
46,989
public function setState ( $ key , $ value ) { $ key = str_replace ( '\\' , '.' , $ this -> getModelNamespace ( ) ) . '.' . $ this -> getModelName ( ) . ".{$key}" ; \ User :: setState ( $ key , $ value ) ; }
Sets state vars on the model namespace
46,990
private function resolve ( $ name ) { if ( ! class_exists ( $ name ) ) { $ name = $ this -> getModelNamespace ( ) . '\\' . $ name ; if ( ! class_exists ( $ name ) ) { throw new RuntimeException ( "Relationship '{$name}' not found" ) ; } } return new $ name ; }
Finds the named class checking a handful of scopes
46,991
public function oneToOne ( $ model , $ childKey = null , $ thisKey = null ) { $ thisKey = $ thisKey ? : $ this -> getPrimaryKey ( ) ; $ childKey = $ childKey ? : strtolower ( $ this -> getModelName ( ) ) . '_id' ; return new OneToOne ( $ this , $ this -> resolve ( $ model ) , $ thisKey , $ childKey ) ; }
Retrieves a one to one model relationship
46,992
public function oneToMany ( $ model , $ relatedKey = null , $ thisKey = null ) { $ thisKey = $ thisKey ? : $ this -> getPrimaryKey ( ) ; $ relatedKey = $ relatedKey ? : strtolower ( $ this -> getModelName ( ) ) . '_id' ; return new OneToMany ( $ this , $ this -> resolve ( $ model ) , $ thisKey , $ relatedKey ) ; }
Retrieves a one to many model relationship
46,993
public function oneShiftsToMany ( $ model , $ relatedKey = 'scope_id' , $ shifter = 'scope' , $ thisKey = null ) { $ thisKey = $ thisKey ? : $ this -> getPrimaryKey ( ) ; return new OneShiftsToMany ( $ this , $ this -> resolve ( $ model ) , $ thisKey , $ relatedKey , $ shifter ) ; }
Retrieves a one shifts to many model relationship
46,994
public function manyToMany ( $ model , $ associativeTable = null , $ thisKey = null , $ relatedKey = null ) { $ related = $ this -> resolve ( $ model ) ; $ names = [ strtolower ( $ this -> getModelName ( ) ) , strtolower ( $ related -> getModelName ( ) ) ] ; $ namespace = ( ! $ this -> namespace ? '' : $ this -> namespace . '_' ) ; sort ( $ names ) ; $ associativeTable = $ associativeTable ? : '#__' . $ namespace . implode ( '_' , $ names ) ; $ thisKey = $ thisKey ? : strtolower ( $ this -> getModelName ( ) ) . '_id' ; $ relatedKey = $ relatedKey ? : strtolower ( $ related -> getModelName ( ) ) . '_id' ; return new ManyToMany ( $ this , $ related , $ associativeTable , $ thisKey , $ relatedKey ) ; }
Retrieves a many to many model relationship
46,995
public function manyShiftsToMany ( $ model , $ associativeTable = null , $ thisKey = 'scope_id' , $ shifter = 'scope' , $ relatedKey = null ) { $ related = $ this -> resolve ( $ model ) ; $ associativeTable = $ associativeTable ? : '#__' . strtolower ( $ related -> getModelName ( ) ) . '_object' ; $ relatedKey = $ relatedKey ? : strtolower ( $ related -> getModelName ( ) ) . '_id' ; return new ManyShiftsToMany ( $ this , $ related , $ associativeTable , $ thisKey , $ relatedKey , $ shifter ) ; }
Retrieves a many shifts to many model relationship
46,996
public function belongsToOne ( $ model , $ thisKey = null , $ parentKey = null ) { $ parent = $ this -> resolve ( $ model ) ; $ thisKey = $ thisKey ? : strtolower ( $ parent -> getModelName ( ) ) . '_id' ; $ parentKey = $ parentKey ? : $ this -> getPrimaryKey ( ) ; return new BelongsToOne ( $ this , $ parent , $ thisKey , $ parentKey ) ; }
Retrieves a belongs to one model relationship
46,997
public function oneToManyThrough ( $ model , $ through , $ relatedKey = null , $ localKey = null ) { $ related = $ this -> resolve ( $ model ) ; $ through = $ this -> resolve ( $ through ) ; $ localKey = $ localKey ? : strtolower ( $ this -> getModelName ( ) ) . '_id' ; $ relatedKey = $ relatedKey ? : strtolower ( $ through -> getModelName ( ) ) . '_id' ; return new OneToManyThrough ( $ this , $ related , $ through -> getTableName ( ) , $ localKey , $ relatedKey ) ; }
Retrieves a one to many through model relationship
46,998
public function shifter ( $ shifter = 'scope' , $ thisKey = 'scope_id' ) { $ parent = $ this -> resolve ( $ this -> $ shifter ) ; return new BelongsToOne ( $ this , $ parent , $ thisKey , 'id' ) ; }
Retrieves a belongs to one model relationship as the inverse of a oneShiftsToMany
46,999
private function parseIncluding ( $ rows ) { $ subs = null ; $ constraint = null ; foreach ( $ this -> includes as $ relationship ) { if ( is_array ( $ relationship ) ) { list ( $ relationship , $ constraint ) = $ relationship ; } if ( strpos ( $ relationship , '.' ) ) { list ( $ relationship , $ subs ) = explode ( '.' , $ relationship , 2 ) ; } if ( isset ( $ subs ) && isset ( $ constraint ) ) { $ subs = [ $ subs , $ constraint ] ; $ constraint = null ; } $ rows = $ this -> $ relationship ( ) -> seedWithRelation ( $ rows , $ relationship , $ constraint , $ subs ) ; $ subs = null ; $ constraint = null ; } return $ rows ; }
Retrieves an associated model in conjunction with the current one