idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
5,000 | public function zoomWidthTo ( $ size ) { $ ratio = round ( $ this -> width / $ size , 3 ) ; $ this -> resize ( $ size , $ this -> height / $ ratio ) ; return $ this ; } | Changes proportionally image width to new size |
5,001 | public function zoomHeightTo ( $ size ) { $ ratio = round ( $ this -> height / $ size , 3 ) ; $ this -> resize ( $ this -> width / $ ratio , $ size ) ; return $ this ; } | Changes proportionally image height to new size |
5,002 | public function decreaseTo ( $ size ) { $ currentSize = max ( $ this -> height , $ this -> width ) ; if ( $ currentSize <= $ size ) return ; $ ratio = round ( $ currentSize / $ size , 3 ) ; $ this -> resize ( $ this -> width / $ ratio , $ this -> height / $ ratio ) ; return $ this ; } | Decreases proportionally larger side to new size if needed |
5,003 | public function placeImageAt ( $ x , $ y , ImageEditor $ image ) { imagecopy ( $ this -> _image , $ image -> resource , $ x , $ y , 0 , 0 , $ image -> width , $ image -> height ) ; return $ this ; } | Places another image atop current image |
5,004 | public function rotate ( $ angle , $ bgColor = 0 ) { if ( $ angle === true ) $ angle = 90 ; elseif ( $ angle === false ) $ angle = - 90 ; $ this -> _image = imagerotate ( $ this -> _image , 360 - $ angle , $ bgColor ) ; return $ this ; } | Rotates an image |
5,005 | public function verticalFlip ( ) { if ( function_exists ( 'imageflip' ) ) { imageflip ( $ this -> _image , IMG_FLIP_VERTICAL ) ; } else { $ image = imagecreatetruecolor ( $ this -> width , $ this -> height ) ; $ dst_x = 0 ; $ src_x = 0 ; $ coordinate = ( $ this -> height - 1 ) ; foreach ( range ( $ this -> height , 0 )... | Flips an image vertically . |
5,006 | static public function createFromResource ( $ resource ) { if ( ! is_resource ( $ resource ) ) throw new Exception ( 'Invalid (resource) parameter! This is not a resource!' ) ; if ( get_resource_type ( $ resource ) != 'gd' ) throw new Exception ( 'Invalid (resource) parameter! Resource is not a gd resource!' ) ; return... | Creates an instace from gd - resource |
5,007 | public function getRegionContents ( ) { $ array = array ( ) ; $ regions = $ this -> region -> findAll ( ) ; foreach ( $ regions as $ region ) { $ first = $ this -> contentRegion -> findOneBy ( array ( 'back' => null , 'region' => $ region ) ) ; while ( $ first != null ) { $ contentType = $ this -> contentType -> findOn... | Get the content of the regions of the front page . |
5,008 | public function getRegion ( $ content ) { $ region = $ this -> contentRegion -> findOneBy ( array ( 'content' => $ content ) ) ; if ( $ region ) { return $ region -> getRegion ( ) -> getName ( ) ; } } | Determine in what region a content is . |
5,009 | public function moveContent ( $ content , $ type , $ page ) { $ contenType = $ this -> contentType -> findOneBy ( array ( 'type' => $ type , 'content' => $ content ) ) ; $ contenType -> detach ( ) ; $ contenType -> setType ( $ page ) ; $ contenType -> setFirst ( $ this -> contentType -> findOneBy ( array ( 'type' => $ ... | Move a content from a type to another |
5,010 | public function deleteContent ( $ content ) { $ this -> deleNodeEntity ( $ this -> contentType , array ( 'content' => $ content ) ) ; $ this -> deleNodeEntity ( $ this -> subContent , array ( 'father' => $ content ) , function ( $ entity ) { $ this -> deleteContent ( $ entity -> getChild ( ) ) ; } ) ; $ this -> deleNod... | Delete a content and his childs . |
5,011 | public function deleteType ( $ type ) { $ contents = $ this -> contentType -> findBy ( array ( 'type' => $ type ) ) ; foreach ( $ contents as $ content ) { $ this -> deleteContent ( $ content -> getContent ( ) ) ; } $ this -> manager -> remove ( $ type ) ; $ this -> manager -> flush ( ) ; } | Delete a type and his childs . |
5,012 | public function publishType ( $ type ) { $ publish = true ; if ( $ type instanceof Type and $ type -> getName ( ) !== 'home' and $ type -> getName ( ) !== 'menu' ) { if ( $ type -> isPublish ( ) ) { $ publish = false ; } $ type -> setPublish ( $ publish ) ; $ this -> manager -> persist ( $ type ) ; $ this -> manager ->... | Publish content type page |
5,013 | public function contentToRegion ( $ region , $ content ) { $ regions = $ this -> contentRegion -> findBy ( array ( 'content' => $ content ) ) ; if ( count ( $ regions ) === 1 and $ regions [ 0 ] -> getRegion ( ) -> getName ( ) === $ region -> getName ( ) ) { $ this -> deleteRegions ( $ content , $ regions ) ; } else { ... | Put a content in a region of home page as left right footer or header this is useful for menus . |
5,014 | public function collapse ( $ content , $ type ) { $ contentType = $ this -> contentType -> findOneBy ( array ( 'content' => $ content , 'type' => $ type ) ) ; $ contentType -> setCollapse ( ! $ contentType -> isCollapse ( ) ) ; $ this -> manager -> persist ( $ contentType ) ; $ this -> manager -> flush ( ) ; } | Update the collapse attribute of a content . |
5,015 | public function createFacet ( $ name , $ forceCreationForm = false ) { $ this -> om -> startFlushSuite ( ) ; $ facet = new Facet ( ) ; $ facet -> setName ( $ name ) ; $ facet -> setForceCreationForm ( $ forceCreationForm ) ; $ facet -> setPosition ( $ this -> om -> count ( 'Claroline\CoreBundle\Entity\Facet\Facet' ) ) ... | Creates a new facet . |
5,016 | public function removeFacet ( Facet $ facet ) { $ this -> om -> remove ( $ facet ) ; $ this -> om -> flush ( ) ; $ this -> reorderFacets ( ) ; } | Removes an existing facet . |
5,017 | public function reorderFacets ( ) { $ facets = $ this -> getFacets ( ) ; $ order = 0 ; foreach ( $ facets as $ facet ) { $ facet -> setPosition ( $ order ) ; $ order ++ ; $ this -> om -> persist ( $ facet ) ; } $ this -> om -> flush ( ) ; } | Fixes gaps beteween facet orders |
5,018 | public function reorderFields ( PanelFacet $ panelFacet ) { $ fields = $ panelFacet -> getFieldsFacet ( ) ; $ order = 0 ; foreach ( $ fields as $ field ) { $ field -> setPosition ( $ order ) ; $ order ++ ; $ this -> om -> persist ( $ field ) ; } $ this -> om -> flush ( ) ; } | Fixes gaps beteween fields orders |
5,019 | public function addField ( PanelFacet $ panelFacet , $ name , $ type ) { $ this -> om -> startFlushSuite ( ) ; $ fieldFacet = new FieldFacet ( ) ; $ fieldFacet -> setPanelFacet ( $ panelFacet ) ; $ fieldFacet -> setName ( $ name ) ; $ fieldFacet -> setType ( $ type ) ; $ fieldFacet -> setPosition ( $ this -> om -> coun... | Creates a new field for a facet |
5,020 | public function editPanel ( PanelFacet $ panel ) { $ this -> om -> persist ( $ panel ) ; $ this -> om -> flush ( ) ; return $ panel ; } | Persists and flush a panel . |
5,021 | public function removePanel ( PanelFacet $ panel ) { $ panels = $ this -> panelRepo -> findPanelsAfter ( $ panel ) ; foreach ( $ panels as $ afterPanel ) { $ afterPanel -> setPosition ( $ afterPanel -> getPosition ( ) - 1 ) ; $ this -> om -> persist ( $ afterPanel ) ; } $ this -> om -> remove ( $ panel ) ; $ this -> om... | Removes a panel . |
5,022 | public function removeField ( FieldFacet $ field ) { $ panel = $ field -> getPanelFacet ( ) ; $ this -> om -> remove ( $ field ) ; $ this -> om -> flush ( ) ; $ this -> reorderFields ( $ panel ) ; } | Removes a field from a facet |
5,023 | public function setFieldValue ( User $ user , FieldFacet $ field , $ value , $ force = false ) { if ( ! $ this -> authorization -> isGranted ( 'edit' , $ field ) && ! $ force ) { throw new AccessDeniedException ( ) ; } $ fieldFacetValue = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Facet\FieldFacetValue' ) -> ... | Set the value of a field for a user |
5,024 | public function moveFacetUp ( Facet $ facet ) { $ currentPosition = $ facet -> getPosition ( ) ; if ( $ currentPosition < $ this -> om -> count ( 'Claroline\CoreBundle\Entity\Facet\Facet' ) - 1 ) { $ nextPosition = $ currentPosition + 1 ; $ nextFacet = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Facet\Facet' )... | Moves a facet up |
5,025 | public function moveFacetDown ( Facet $ facet ) { $ currentPosition = $ facet -> getPosition ( ) ; if ( $ currentPosition > 0 ) { $ prevPosition = $ currentPosition - 1 ; $ prevFacet = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Facet\Facet' ) -> findOneBy ( array ( 'position' => $ prevPosition ) ) ; $ prevFac... | Moves a facet down |
5,026 | public function setFieldBoolProperty ( FieldFacet $ fieldFacet , array $ roles , $ property ) { $ fieldFacetsRole = $ fieldFacet -> getFieldFacetsRole ( ) ; $ setterFunc = 'set' . ucfirst ( $ property ) ; $ unknownRoles = array ( ) ; $ fieldFacetRolesToChange = array ( ) ; foreach ( $ fieldFacetsRole as $ fieldFacetRol... | This function will allow to set on of the boolean property of FieldFacetRole for a fieldFacet and an array of roles . |
5,027 | public function create ( $ permissions , Role $ role , ResourceNode $ node , $ isRecursive , array $ creations = array ( ) ) { $ rights = $ this -> rightsRepo -> findBy ( array ( 'role' => $ role , 'resourceNode' => $ node ) ) ; if ( count ( $ rights ) === 0 ) { $ isRecursive ? $ this -> recursiveCreation ( $ permissio... | Create a new ResourceRight . If the ResourceRight already exists it s edited instead . |
5,028 | public function copy ( ResourceNode $ original , ResourceNode $ node ) { $ originalRights = $ this -> rightsRepo -> findBy ( array ( 'resourceNode' => $ original ) ) ; $ this -> om -> startFlushSuite ( ) ; foreach ( $ originalRights as $ originalRight ) { $ new = $ this -> om -> factory ( 'Claroline\CoreBundle\Entity\R... | Copy the rights from the parent to its children . |
5,029 | public function canEditPwsPerm ( TokenInterface $ token ) { if ( $ this -> container -> get ( 'security.context' ) -> isGranted ( 'ROLE_ADMIN' ) ) return true ; $ roles = $ this -> roleManager -> getStringRolesFromToken ( $ token ) ; $ accesses = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Resource\PwsRightsMa... | Check if the permissions can be edited for a resource . This may change in the future because it s quite heavy ! |
5,030 | public function getRealFileSize ( $ fileSize ) { $ validUnits = array ( 'KB' , 'MB' , 'GB' , 'TB' ) ; $ value = str_replace ( ' ' , '' , $ fileSize ) ; $ replacements = array ( '' ) ; $ pattern = '/(\d+)/' ; $ data = preg_grep ( $ pattern , array ( $ value ) ) ; foreach ( $ validUnits as $ unit ) { if ( strpos ( $ file... | Take a formatted file size and returns the number of bytes |
5,031 | public function load ( ObjectManager $ manager ) { $ translator = $ this -> container -> get ( 'translator' ) ; $ infoName = $ translator -> trans ( 'informations' , array ( ) , 'platform' ) ; $ desktopHomeTab = new HomeTab ( ) ; $ desktopHomeTab -> setType ( 'admin_desktop' ) ; $ desktopHomeTab -> setName ( $ infoName... | Loads the core Home Tabs . |
5,032 | public function findWorkspaceRoot ( Workspace $ workspace ) { $ builder = new ResourceQueryBuilder ( ) ; $ builder -> selectAsEntity ( ) -> whereInWorkspace ( $ workspace ) -> whereParentIsNull ( ) ; $ query = $ this -> _em -> createQuery ( $ builder -> getDql ( ) ) ; $ query -> setParameters ( $ builder -> getParamete... | Returns the root directory of a workspace . |
5,033 | public function findWorkspaceRootsByUser ( User $ user ) { $ builder = new ResourceQueryBuilder ( ) ; $ dql = $ builder -> selectAsArray ( ) -> whereParentIsNull ( ) -> whereInUserWorkspace ( $ user ) -> orderByPath ( ) -> getDql ( ) ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameters ( $ buil... | Returns the root directories of workspaces a user is registered to . |
5,034 | public function findWorkspaceRootsByRoles ( array $ roles ) { $ builder = new ResourceQueryBuilder ( ) ; $ dql = $ builder -> selectAsArray ( ) -> whereParentIsNull ( ) -> whereHasRoleIn ( $ roles ) -> orderByName ( ) -> getDql ( ) ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameters ( $ builde... | Returns the roots directories a user is granted access |
5,035 | public function findAncestors ( ResourceNode $ resource ) { $ regex = '/-(\d+)' . ResourceNode :: PATH_SEPARATOR . '/' ; $ parts = preg_split ( $ regex , $ resource -> getPath ( ) , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ ancestors = array ( ) ; $ currentPath = '' ; for ( $ i = 0 , $ count = count ( ... | Returns the ancestors of a resource including the resource itself . |
5,036 | public function findWorkspaceInfoByIds ( array $ nodesIds ) { if ( count ( $ nodesIds ) === 0 ) { throw new \ InvalidArgumentException ( 'Resource ids array cannot be empty' ) ; } $ dql = ' SELECT r.id AS id, w.code AS code, w.name AS name FROM Claroline\CoreBundle\Entity\Resource\ResourceNode r ... | Returns the workspace name and code of the resources whose ids are passed as argument . |
5,037 | public function getDesktopToolsConfigurationArrayForAdmin ( $ type = 0 ) { $ orderedToolList = array ( ) ; $ desktopTools = $ this -> orderedToolRepo -> findDisplayableDesktopOrderedToolsByTypeForAdmin ( $ type ) ; foreach ( $ desktopTools as $ desktopTool ) { $ desktopTool -> getTool ( ) -> setVisible ( $ desktopTool ... | Returns the sorted list of OrderedTools for configuration in admin . |
5,038 | public function extractFiles ( $ archpath , $ confTools ) { $ extractPath = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . uniqid ( 'claro_ws_tmp_' , true ) ; $ archive = $ this -> om -> factory ( 'ZipArchive' ) ; $ archive -> open ( $ archpath ) ; $ archive -> extractTo ( $ extractPath ) ; $ realPaths = array ( ) ; if (... | Extract the files from a the template configuration array |
5,039 | public function findWorkspaceRolesForUser ( User $ user , Workspace $ workspace ) { $ dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.workspace ws JOIN r.users user WHERE ws.guid = '{$workspace->getGuid()}' AND r.name != 'ROLE_ADMIN' AND ... | Returns the roles of a user in a workspace . |
5,040 | private function getResourceNode ( FormInterface $ form ) { if ( $ form -> getData ( ) instanceof ResourceNode ) { return $ form -> getData ( ) ; } else if ( $ form -> getData ( ) and $ form -> getData ( ) != '' ) { return $ this -> resourceManager -> getById ( $ form -> getData ( ) ) ; } } | Get resource node |
5,041 | public function fieldFormAction ( PanelFacet $ panelFacet ) { $ form = $ this -> formFactory -> create ( new FieldFacetType ( ) , new FieldFacet ( ) ) ; return array ( 'form' => $ form -> createView ( ) , 'panelFacet' => $ panelFacet ) ; } | Returns the facet field creation form in a modal |
5,042 | public function moveFieldFacetsAction ( PanelFacet $ panel ) { $ params = $ this -> request -> query -> all ( ) ; $ ids = [ ] ; foreach ( $ params [ 'ids' ] as $ value ) { $ ids [ ] = ( int ) str_replace ( 'field-' , '' , $ value ) ; } $ this -> facetManager -> orderFields ( $ ids , $ panel ) ; return new Response ( 's... | Ajax method for ordering fields |
5,043 | public function facetRolesFormAction ( Facet $ facet ) { $ roles = $ facet -> getRoles ( ) ; $ platformRoles = $ this -> roleManager -> getPlatformNonAdminRoles ( true ) ; return array ( 'roles' => $ roles , 'facet' => $ facet , 'platformRoles' => $ platformRoles ) ; } | Returns the facet role edition in a modal |
5,044 | public function fieldRolesFormAction ( FieldFacet $ field ) { $ fieldFacetsRole = $ field -> getFieldFacetsRole ( ) ; $ platformRoles = $ this -> roleManager -> getPlatformNonAdminRoles ( true ) ; return array ( 'fieldFacetsRole' => $ fieldFacetsRole , 'field' => $ field , 'platformRoles' => $ platformRoles ) ; } | Returns the field role edition in a modal |
5,045 | public function orderPanels ( Facet $ facet ) { $ params = $ this -> request -> query -> all ( ) ; $ ids = [ ] ; foreach ( $ params [ 'ids' ] as $ value ) { $ ids [ ] = ( int ) str_replace ( 'panel-' , '' , $ value ) ; } $ this -> facetManager -> orderPanels ( $ ids , $ facet ) ; return new Response ( 'success' ) ; } | Reorder panels . |
5,046 | protected function setDefaults ( ) { $ get = $ _GET ; $ page = isset ( $ get [ 'page' ] ) ? ( int ) $ get [ 'page' ] : 1 ; $ defaults = array ( 'perPage' => 20 , 'page' => $ page , 'maximumPages' => 5 , 'infiniteScroll' => false , ) ; $ this -> config = array_merge ( $ defaults , $ this -> config ) ; } | Set default config values |
5,047 | protected function getParam ( string $ name ) { if ( ! array_key_exists ( $ name , $ this -> _params ) ) { throw new Exception ( 'Required parameter "' . $ name . '" was not set' ) ; } return $ this -> _params [ $ name ] ; } | Returns optional config parameter or throws Exception if parameter does not exist |
5,048 | public function optionsWithDefault ( string $ listName , string $ defaultLabel = '' ) : array { $ result = $ this -> getDefaultOption ( $ defaultLabel ) + $ this -> options ( $ listName ) ; return $ result ; } | Returns a list of options with default label for no selection |
5,049 | protected function getDefaultOption ( string $ label = '' ) : array { if ( $ label == '' ) { $ label = $ this -> getDefaultOptionLabel ( ) ; } return array ( '' => $ this -> translate ( $ label ) ) ; } | Helper function to return default option string like Please select |
5,050 | public function addDefinition ( string $ name , array $ definition ) { if ( isset ( $ this -> _definition [ $ name ] ) ) { throw new Exception ( 'Definition for "' . $ name . '" already exists' ) ; } $ this -> _definition [ $ name ] = $ definition ; return $ this ; } | Adds a single form field definition |
5,051 | public function changeDefinition ( string $ name , array $ changes ) { if ( ! isset ( $ this -> _definition [ $ name ] ) ) { throw new Exception ( 'Definition for "' . $ name . '" does not exist' ) ; } foreach ( $ changes as $ prop => $ val ) { if ( $ val === null ) { unset ( $ this -> _definition [ $ name ] [ $ prop ]... | Changes a single form field definition |
5,052 | public function getFieldAsArray ( string $ name ) : array { $ result = $ this -> getFieldDefinition ( $ name ) ; $ result [ 'name' ] = $ name ; if ( empty ( $ result [ 'caption' ] ) ) { $ result [ 'caption' ] = $ this -> _ ( $ result [ 'name' ] ) ; } $ value = $ this -> $ name ; $ type = @ $ result [ 'type' ] ; if ( ( ... | Returns field definition and value as JSON compatible array |
5,053 | protected function isOptional ( string $ name ) : bool { return ( $ this -> getFieldProperty ( $ name , 'checkbox' ) == true ) || ( $ this -> getFieldProperty ( $ name , 'optional' ) == true ) ; } | Returns true if the field is optional |
5,054 | protected function setOptionalValueInArray ( string $ name , & $ values ) { if ( $ this -> isOptional ( $ name ) && ! array_key_exists ( $ name , $ values ) ) { $ default = $ this -> getFieldProperty ( $ name , 'default' ) ; if ( is_null ( $ default ) ) { $ type = $ this -> getFieldProperty ( $ name , 'type' ) ; switch... | Sets the default types for values of form fields marked as optional |
5,055 | public function setDefinedValues ( array $ values ) { foreach ( $ this -> _definition as $ key => $ value ) { $ this -> setOptionalValueInArray ( $ key , $ values ) ; if ( ! array_key_exists ( $ key , $ values ) ) { throw new Exception ( 'Value is missing for "' . $ key . '"' ) ; } $ this -> $ key = $ values [ $ key ] ... | Iterates through the form definition and sets the values for fields that are present in the form definition |
5,056 | public function setWritableValues ( array $ values ) { foreach ( $ values as $ key => $ value ) { if ( $ this -> isWritable ( $ key ) ) { $ this -> $ key = $ value ; } } return $ this ; } | Iterates through the passed value array and sets the values for fields that are writable by the user |
5,057 | public function getValuesByPage ( ) : array { $ result = array ( ) ; foreach ( $ this -> _definition as $ key => $ value ) { $ page = $ this -> getFieldProperty ( $ key , 'page' ) ; if ( $ page ) { $ result [ $ page ] [ $ key ] = $ this -> $ key ; } } return $ result ; } | Returns the form values for all elements grouped by page |
5,058 | public function getValuesByTag ( string $ tag ) : array { $ result = array ( ) ; foreach ( $ this -> _definition as $ key => $ value ) { $ tags = $ this -> getFieldProperty ( $ key , 'tags' ) ; if ( is_array ( $ tags ) && in_array ( $ tag , $ tags ) ) { $ result [ $ key ] = $ this -> $ key ; } } return $ result ; } | Returns the form values for all elements by tag |
5,059 | public function getValues ( ) : array { $ result = array ( ) ; foreach ( $ this -> _definition as $ key => $ value ) { $ result [ $ key ] = $ this -> $ key ; } return $ result ; } | Returns all form field values |
5,060 | public function getWritableValues ( ) : array { $ result = array ( ) ; foreach ( $ this -> _definition as $ key => $ value ) { if ( $ this -> isWritable ( $ key ) ) { $ result [ $ key ] = $ this -> $ key ; } } return $ result ; } | Returns all writable form field values |
5,061 | public function getFieldCaption ( string $ name ) : string { $ caption = $ this -> getFieldProperty ( $ name , 'caption' ) ; if ( $ caption ) { return $ this -> translate ( $ caption ) ; } return $ name ; } | Returns a translated field caption |
5,062 | public function getFirstError ( ) : string { $ result = '' ; $ errors = $ this -> getErrors ( ) ; $ firstField = reset ( $ errors ) ; if ( $ firstField && isset ( $ firstField [ 0 ] ) ) { $ result = $ firstField [ 0 ] ; } return $ result ; } | Returns the first error as string |
5,063 | public function getErrorsAsText ( ) : string { $ result = '' ; $ fieldCounter = 0 ; $ fields = $ this -> getErrors ( ) ; foreach ( $ fields as $ fieldName => $ fieldErrors ) { $ fieldCounter ++ ; $ result .= "$fieldCounter) $fieldName\n" ; foreach ( $ fieldErrors as $ error ) { $ result .= " - $error\n" ; } } return ... | Returns all errors as indented text |
5,064 | public function clearErrors ( ) { $ this -> _validationDone = false ; if ( count ( $ this -> _errors ) != 0 ) { $ this -> _errors = array ( ) ; } return $ this ; } | Resets the validation and clears all errors |
5,065 | public function decodeMask ( $ mask , ResourceType $ type ) { $ decoders = $ this -> maskRepo -> findBy ( array ( 'resourceType' => $ type ) ) ; $ perms = array ( ) ; foreach ( $ decoders as $ decoder ) { $ perms [ $ decoder -> getName ( ) ] = ( $ mask & $ decoder -> getValue ( ) ) ? true : false ; } return $ perms ; } | Returns an array containing the permission for a mask and a resource type . |
5,066 | public function hasMenuAction ( ResourceType $ type ) { $ menuActions = $ this -> menuRepo -> findBy ( array ( 'resourceType' => $ type ) ) ; return count ( $ menuActions ) > 0 ; } | Checks if a resource type has any menu actions . |
5,067 | public function searchIcon ( $ mimeType ) { $ mimeElements = explode ( '/' , $ mimeType ) ; $ icon = $ this -> repo -> findOneByMimeType ( $ mimeType ) ; if ( $ icon === null ) { $ icon = $ this -> repo -> findOneByMimeType ( $ mimeElements [ 0 ] ) ; if ( $ icon === null ) { $ icon = $ this -> repo -> findOneByMimeType... | Return the icon of a specified mimeType . The most specific icon for the mime type will be returned . |
5,068 | public function createShortcutIcon ( ResourceIcon $ icon , Workspace $ workspace = null ) { $ this -> om -> startFlushSuite ( ) ; $ relativeUrl = $ this -> createShortcutFromRelativeUrl ( $ icon -> getRelativeUrl ( ) , $ workspace ) ; $ shortcutIcon = new ResourceIcon ( ) ; $ shortcutIcon -> setRelativeUrl ( $ relative... | Creates the shortcut icon for an existing icon . |
5,069 | public function replace ( ResourceNode $ resource , ResourceIcon $ icon ) { $ this -> om -> startFlushSuite ( ) ; $ oldIcon = $ resource -> getIcon ( ) ; if ( ! $ oldIcon -> isShortcut ( ) ) { $ oldShortcutIcon = $ oldIcon -> getShortcutIcon ( ) ; $ shortcutIcon = $ icon -> getShortcutIcon ( ) ; if ( ! is_null ( $ oldS... | Replace a node icon . |
5,070 | public function isARepeat ( LogGenericEvent $ event ) { if ( $ this -> tokenStorage -> getToken ( ) === null ) { return false ; } if ( $ event instanceof LogNotRepeatableInterface ) { $ request = $ this -> container -> get ( 'request' ) ; $ session = $ request -> getSession ( ) ; $ is = false ; $ pushInSession = true ;... | Is a repeat if the session contains a same logSignature for the same action category |
5,071 | public function create ( string $ name , array $ params = array ( ) ) { if ( empty ( $ name ) ) { throw new FactoryException ( 'create() requires a non-empty form name as first argument' ) ; } $ className = $ this -> getFactoryNamespace ( ) . '\\' . $ name . $ this -> getFactoryPostfix ( ) ; if ( ! class_exists ( $ cla... | Returns a new form instance of the given name |
5,072 | public function getFactoryNamespace ( ) { $ result = $ this -> _factoryNamespace ; if ( $ result && strpos ( $ result , '\\' ) !== 0 ) { $ result = '\\' . $ result ; } return $ result ; } | Returns absolute namespace |
5,073 | public function addDefaultProperties ( ) { $ properties = User :: getEditableProperties ( ) ; $ this -> om -> startFlushSuite ( ) ; foreach ( $ properties as $ property => $ editable ) { $ this -> addProperties ( $ property , $ editable ) ; } $ this -> om -> endFlushSuite ( ) ; } | Add the default properties accesses for each roles |
5,074 | public function addProperties ( $ property , $ editable ) { $ platformRoles = $ this -> roleManager -> getAllPlatformRoles ( ) ; foreach ( $ platformRoles as $ role ) { $ prop = $ this -> profilePropertyRepo -> findBy ( array ( 'property' => $ property , 'role' => $ role ) ) ; if ( count ( $ prop ) === 0 ) $ this -> ad... | Public function add a property for each roles |
5,075 | public function addProperty ( $ property , $ editable , Role $ role ) { $ propertyEntity = new ProfileProperty ( ) ; $ propertyEntity -> setProperty ( $ property ) ; $ propertyEntity -> setIsEditable ( $ editable ) ; $ propertyEntity -> setRole ( $ role ) ; $ this -> om -> persist ( $ propertyEntity ) ; $ this -> om ->... | Create a property entity |
5,076 | public function contentAction ( Content $ content , Type $ type , Content $ father = null ) { return $ this -> render ( 'ClarolineCoreBundle:Home/types:' . ( is_object ( $ type ) ? $ type -> getName ( ) : 'home' ) . '.html.twig' , $ this -> manager -> getContent ( $ content , $ type , $ father ) , true ) ; } | Get content by id |
5,077 | public function homeAction ( $ type ) { $ typeEntity = $ this -> manager -> getType ( $ type ) ; if ( is_null ( $ typeEntity ) ) { throw new NotFoundHttpException ( "Page not found" ) ; } else { $ typeTemplate = $ typeEntity -> getTemplate ( ) ; $ template = is_null ( $ typeTemplate ) ? 'ClarolineCoreBundle:Home:home.h... | Render the home page of the platform |
5,078 | public function renameContentAction ( $ type , $ name ) { try { $ this -> manager -> renameType ( $ type , $ name ) ; return new Response ( 'true' ) ; } catch ( \ Exeption $ e ) { return new Response ( 'false' ) ; } } | Rename a content form |
5,079 | public function changeTemplateFormAction ( Type $ type ) { $ form = $ this -> formFactory -> create ( new HomeTemplateType ( $ this -> templatesDirectory ) , $ type ) ; return array ( 'form' => $ form -> createView ( ) , 'type' => $ type ) ; } | Edit template form |
5,080 | public function collapseAction ( $ content , $ type ) { try { $ this -> manager -> collapse ( $ content , $ type ) ; return new Response ( 'true' ) ; } catch ( \ Exeption $ e ) { return new Response ( 'false' ) ; } } | Update the collapse attribute of a content |
5,081 | public function canGenerateContentAction ( ) { if ( $ this -> manager -> isValidUrl ( $ this -> request -> get ( 'url' ) ) ) { $ graph = $ this -> manager -> getGraph ( $ this -> request -> get ( 'url' ) ) ; if ( isset ( $ graph [ 'type' ] ) ) { return $ this -> render ( 'ClarolineCoreBundle:Home/graph:' . $ graph [ 't... | Check if a string is a valid URL |
5,082 | public function findOrderedToolsLockedByAdmin ( $ orderedToolType = 0 ) { $ dql = " SELECT ot FROM Claroline\CoreBundle\Entity\Tool\OrderedTool ot JOIN ot.tool t WHERE ot.user IS NULL AND ot.workspace IS NULL AND ot.type = :type AND ot.locked ... | Returns the ordered tools locked by admin . |
5,083 | private function extract ( $ extractPath , $ archive ) { $ res = $ archive -> extractTo ( $ extractPath ) ; $ archive -> close ( ) ; $ this -> setExtractPath ( $ extractPath ) ; $ resolver = new Resolver ( $ extractPath ) ; $ this -> data = $ resolver -> resolve ( ) ; } | Assume the archive is already opened . |
5,084 | private function renderWidget ( ) { $ img = $ this -> getImageSource ( ) ; echo "<div>$img</div>" ; if ( $ this -> link || is_string ( $ this -> link ) ) { echo Html :: a ( $ this -> link , $ this -> otp -> getProvisioningUri ( ) ) ; } if ( $ this -> hasModel ( ) && $ this -> model -> hasProperty ( $ this -> attribute ... | Render Image and link block |
5,085 | public function findAccessesByRoles ( array $ roles ) { $ dql = ' SELECT pp.property as property, MAX(pp.isEditable) as isEditable FROM Claroline\CoreBundle\Entity\ProfileProperty pp JOIN pp.role role WHERE role.name in (:roleNames) GROUP BY pp.property ' ; ... | Returns the accesses for a list of roles |
5,086 | public function insert ( WorkspaceTag $ tag ) { $ this -> om -> persist ( $ tag ) ; $ this -> om -> flush ( ) ; } | Persists and flush a tag . |
5,087 | private function isTagDisplayable ( WorkspaceTag $ tag , array $ tagWorkspaces , array $ hierarchy ) { $ displayable = false ; $ tagId = $ tag -> getId ( ) ; if ( ( isset ( $ tagWorkspaces [ $ tagId ] ) && count ( $ tagWorkspaces [ $ tagId ] ) > 0 ) || ! is_null ( $ tag -> getWorkspace ( ) ) ) { $ displayable = true ; ... | Checks if given tag or at least one of its children is associated to a workspace |
5,088 | public function haveSameParents ( array $ nodes ) { $ firstRes = array_pop ( $ nodes ) ; $ tmp = $ firstRes [ 'parent_id' ] ; foreach ( $ nodes as $ node ) { if ( $ tmp !== $ node [ 'parent_id' ] ) { return false ; } } return true ; } | Checks if an array of serialized resources share the same parent . |
5,089 | public function makeShortcut ( ResourceNode $ target , ResourceNode $ parent , User $ creator , ResourceShortcut $ shortcut ) { $ shortcut -> setName ( $ target -> getName ( ) ) ; if ( get_class ( $ target ) !== 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut' ) { $ shortcut -> setTarget ( $ target ) ; } else { ... | Creates a shortcut . |
5,090 | public function checkResourcePrepared ( AbstractResource $ resource ) { $ stringErrors = '' ; if ( $ resource -> getName ( ) == null ) { $ stringErrors .= 'The resource name is missing' . PHP_EOL ; } if ( $ stringErrors !== '' ) { throw new MissingResourceNameException ( $ stringErrors ) ; } } | Checks if a resource already has a name . |
5,091 | public function move ( ResourceNode $ child , ResourceNode $ parent ) { if ( $ parent === $ child ) { throw new ResourceMoveException ( "You cannot move a directory into itself" ) ; } $ this -> om -> startFlushSuite ( ) ; $ this -> setLastIndex ( $ parent , $ child ) ; $ child -> setParent ( $ parent ) ; $ child -> set... | Moves a resource . |
5,092 | public function hasLinkTo ( ResourceNode $ parent , ResourceNode $ target ) { $ nodes = $ this -> resourceNodeRepo -> findBy ( array ( 'parent' => $ parent , 'class' => 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut' ) ) ; foreach ( $ nodes as $ node ) { $ shortcut = $ this -> getResourceFromNode ( $ node ) ; i... | Checks if a resource in a node has a link to the target with a shortcut . |
5,093 | public function isPathValid ( array $ ancestors ) { $ continue = true ; for ( $ i = 0 , $ size = count ( $ ancestors ) ; $ i < $ size ; $ i ++ ) { if ( isset ( $ ancestors [ $ i + 1 ] ) ) { if ( $ ancestors [ $ i + 1 ] -> getParent ( ) === $ ancestors [ $ i ] ) { $ continue = true ; } else { $ continue = $ this -> hasL... | Checks if a path is valid . |
5,094 | public function areAncestorsDirectory ( array $ ancestors ) { array_pop ( $ ancestors ) ; foreach ( $ ancestors as $ ancestor ) { if ( $ ancestor -> getResourceType ( ) -> getName ( ) !== 'directory' ) { return false ; } } return true ; } | Checks if all the resource in the array are directories . |
5,095 | public function changeIcon ( ResourceNode $ node , File $ file ) { $ this -> om -> startFlushSuite ( ) ; $ icon = $ this -> iconManager -> createCustomIcon ( $ file , $ node -> getWorkspace ( ) ) ; $ this -> iconManager -> replace ( $ node , $ icon ) ; $ this -> logChangeSet ( $ node ) ; $ this -> om -> endFlushSuite (... | Changes a node icon . |
5,096 | public function logChangeSet ( ResourceNode $ node ) { $ uow = $ this -> om -> getUnitOfWork ( ) ; $ uow -> computeChangeSets ( ) ; $ changeSet = $ uow -> getEntityChangeSet ( $ node ) ; if ( count ( $ changeSet ) > 0 ) { $ this -> dispatcher -> dispatch ( 'log' , 'Log\LogResourceUpdate' , array ( $ node , $ changeSet ... | Logs every change on a node . |
5,097 | public function isWorkspaceOwnerOf ( ResourceNode $ node , TokenInterface $ token ) { $ workspace = $ node -> getWorkspace ( ) ; $ managerRoleName = 'ROLE_WS_MANAGER_' . $ workspace -> getGuid ( ) ; return in_array ( $ managerRoleName , $ this -> secut -> getRoles ( $ token ) ) ? true : false ; } | Returns true of the token owns the workspace of the resource node . |
5,098 | public function changeAccessibilityDate ( ResourceNode $ node , $ accessibleFrom , $ accessibleUntil ) { if ( $ node -> getResourceType ( ) -> getName ( ) === 'directory' ) { $ descendants = $ this -> resourceNodeRepo -> findDescendants ( $ node ) ; foreach ( $ descendants as $ descendant ) { $ descendant -> setAccessi... | Retrieves all descendants of given ResourceNode and updates their accessibility dates . |
5,099 | public function isResourceActionImplemented ( ResourceType $ resourceType = null , $ actionName ) { if ( $ resourceType ) { $ alwaysTrue = array ( 'rename' , 'edit-properties' , 'edit-rights' , 'open-tracking' ) ; if ( $ resourceType -> getName ( ) === 'directory' && $ actionName == 'download' ) return true ; if ( in_a... | Returns true if the listener is implemented for a resourceType and an action |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.