idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
32,200 | public function create ( $ params = null ) { if ( $ params ) { $ this -> _params = array_merge ( $ this -> _params , $ params ) ; } $ supplied_require_params = array_intersect ( array_keys ( $ this -> _required_params ) , array_keys ( $ this -> _params ) ) ; if ( count ( $ supplied_require_params ) != count ( $ this -> _required_params ) ) { throw new InvalidArgumentException ( "The following required param(s) were not supplied -- " . join ( ',' , array_diff ( array_keys ( $ this -> _required_params ) , array_keys ( $ this -> _params ) ) ) ) ; } $ result = $ this -> executeCommand ( $ this -> _path_for_regex . "_create" , $ this -> _params ) ; $ this -> initialize ( $ result ) ; } | Calls the Create or POST method on the API resource represented by the model . |
32,201 | public function update ( $ params = null ) { if ( $ params ) { $ this -> _params = array_merge ( $ this -> _params , $ params ) ; } if ( ! $ this -> id || ! $ this -> href ) { throw new BadMethodCallException ( "This object has not yet been created, and therefore can not be updated. Try the ->create() or one of the ->findBy* methods first" ) ; } $ this -> _params [ 'id' ] = $ this -> _castIdWithClosure ( ) ; $ result = $ this -> executeCommand ( $ this -> _path_for_regex . "_update" , $ this -> _params ) ; } | Calls the Update or PUT method on the API resource represented by the model . |
32,202 | public function index ( ) { $ members = Member :: with ( 'member_category' , 'user' ) -> onTeam ( ) -> active ( ) -> orderBy ( 'preference' , 'asc' ) -> paginate ( config ( 'app.pagination_default' ) ) ; return fractal ( $ members , new MemberTransformer ( ) ) -> withResourceName ( 'member' ) -> respond ( ) ; } | List of Members with pagination headers for the Team currently selected in the User s context |
32,203 | public function show ( $ id ) { $ member = Member :: with ( 'member_category' , 'user' ) -> findOrFail ( $ id ) ; $ this -> authorize ( 'view' , $ member ) ; return fractal ( $ member , new MemberTransformer ( ) ) -> withResourceName ( 'member' ) -> respond ( ) ; } | Show a single Member |
32,204 | public function index ( $ memberId ) { $ member = Member :: findOrFail ( $ memberId ) ; $ this -> authorize ( 'view' , $ member ) ; return $ this -> respondRelatedPhones ( $ member -> user_id , 'member' ) ; } | Produce a list of Phones related to a selected Member |
32,205 | public function registerParamEncoder ( ParamEncoderInterface $ encoder ) { if ( ! in_array ( $ encoder , $ this -> encoders , true ) ) { $ this -> encoders [ ] = $ encoder ; } return $ this ; } | Register a new param encoder if it s not registered yet . |
32,206 | public function unregisterParamEncoder ( ParamEncoderInterface $ encoder ) { if ( false !== ( $ index = array_search ( $ encoder , $ this -> encoders , true ) ) ) { unset ( $ this -> encoders [ $ index ] ) ; } return $ this ; } | Unregister a param encoder if it has already been registered . |
32,207 | public function _admin_enqueue_scripts ( ) { do_action ( 'inc2734_wp_awesome_widgets_before_admin_enqueue_scripts' ) ; if ( ! did_action ( 'wp_enqueue_media' ) ) { wp_enqueue_media ( ) ; } $ relative_path = '/vendor/inc2734/wp-awesome-widgets/src/assets/admin-css/wp-awesome-widgets-admin.min.css' ; wp_enqueue_style ( 'wp-awesome-widgets-admin' , get_template_directory_uri ( ) . $ relative_path , [ ] , filemtime ( get_template_directory ( ) . $ relative_path ) ) ; $ relative_path = '/vendor/inc2734/wp-awesome-widgets/src/assets/admin-js/wp-awesome-widgets-admin.min.js' ; wp_enqueue_script ( 'wp-awesome-widgets-admin' , get_template_directory_uri ( ) . $ relative_path , [ 'jquery' , 'jquery-ui-sortable' , 'wp-color-picker' ] , filemtime ( get_template_directory ( ) . $ relative_path ) , true ) ; wp_localize_script ( 'wp-awesome-widgets-admin' , 'wp_awesome_widgets_item_selector_wp_api' , [ 'root' => esc_url_raw ( rest_url ( ) ) , ] ) ; wp_enqueue_style ( 'wp-color-picker' ) ; do_action ( 'inc2734_wp_awesome_widgets_after_admin_enqueue_scripts' ) ; } | Enqueue assets for admin |
32,208 | public function setArguments ( array $ arguments ) { foreach ( $ arguments as $ k => $ v ) { $ this -> arguments [ $ k ] = $ v ; } return $ this ; } | Replace route arguments |
32,209 | public function processGroupAction ( $ groupAction = null , $ conditions = null ) { if ( ( $ groupAction === false ) || empty ( $ conditions ) ) { return null ; } $ result = false ; switch ( $ groupAction ) { case 'group-data-del' : $ result = $ this -> deleteAll ( $ conditions , false ) ; break ; } return $ result ; } | Process group action |
32,210 | public function getBarStateInfo ( ) { $ result = [ ] ; $ fields = [ 'count(*) AS amount' , $ this -> alias . '.status' ] ; $ group = $ this -> alias . '.status' ; $ order = [ $ this -> alias . '.status' => 'asc' ] ; $ this -> recursive = - 1 ; $ data = $ this -> find ( 'all' , compact ( 'fields' , 'group' , 'order' ) ) ; if ( empty ( $ data ) ) { return $ result ; } $ taskStateList = $ this -> getListTaskState ( ) ; $ taskClassList = $ this -> getListBarStateClass ( ) ; foreach ( $ data as $ dataItem ) { $ stateId = $ dataItem [ $ this -> alias ] [ 'status' ] ; $ stateName = Hash :: get ( $ taskStateList , $ stateId ) ; $ class = Hash :: get ( $ taskClassList , $ stateId ) ; $ amount = ( int ) Hash :: get ( $ dataItem , '0.amount' ) ; $ stateUrl = [ 'controller' => 'queues' , 'action' => 'index' , 'plugin' => 'cake_settings_app' , '?' => [ 'data[FilterData][0][' . $ this -> alias . '][status]' => $ stateId ] ] ; $ result [ ] = compact ( 'stateName' , 'stateId' , 'amount' , 'stateUrl' , 'class' ) ; } return $ result ; } | Return information about queue of tasks for bar state |
32,211 | public static function belongsTo ( $ model , $ parentColumn ) { $ r = new static ( [ 'type' => DbRelations :: BELONGS_TO , 'model' => $ model ] ) ; return $ r -> columnsEqual ( $ parentColumn , $ model :: getDb ( ) -> getTablePk ( $ model :: getTableName ( ) ) ) ; } | Creates new belongsTo Relation |
32,212 | public function join ( $ tableName , $ columnsCompare , $ valueCompare = [ ] , $ type = "LEFT JOIN" ) { $ this -> joins [ ] = [ $ tableName , $ columnsCompare , $ valueCompare , $ type ] ; return $ this ; } | Creates an extra join with a new table that doesn t require a model . |
32,213 | protected function getColumnEqualWithParent ( $ condition , $ parentModel , $ fullName ) { if ( is_array ( $ condition [ 1 ] ) && is_array ( $ condition [ 2 ] ) ) { $ conditions = [ ] ; foreach ( $ condition [ 1 ] as $ c1 ) { $ conditions [ ] = $ this -> getColumnEqualWithParent ( [ $ condition [ 0 ] , $ c1 , $ condition [ 2 ] ] , $ parentModel , $ fullName ) ; } return "(" . implode ( ") OR (" , $ conditions ) . ")" ; } if ( is_array ( $ condition [ 1 ] ) ) { $ c = $ condition [ 1 ] ; $ condition [ 1 ] = $ condition [ 2 ] ; $ condition [ 2 ] = $ c ; } if ( is_string ( $ condition [ 2 ] ) ) { return $ this -> _column ( $ condition [ 1 ] , true , $ fullName ) . ' ' . $ condition [ 0 ] . ' ' . $ this -> _column ( $ condition [ 2 ] , false , $ fullName ) ; } else { foreach ( $ condition [ 2 ] as $ k => $ v ) { $ condition [ 2 ] [ $ k ] = $ this -> _column ( $ v , false , $ fullName ) ; } return $ this -> _column ( $ condition [ 1 ] , true , $ fullName ) . ( $ condition [ 0 ] == '=' ? ' IN (' : ' NOT IN (' ) . implode ( ", " , $ condition [ 2 ] ) . ')' ; } } | Creates string condition from known data |
32,214 | public function getRelationTableForJoin ( $ fullName ) { if ( ! $ this -> tableName ) { $ class = $ this -> model ; $ this -> tableName = $ class :: getTableName ( ) ; } return "`" . $ this -> tableName . "` as `" . ( $ this -> tableAlias = str_replace ( '.' , '_' , $ fullName ) ) . "`" ; } | Get table from relation join . Also calculates tableAlias ; |
32,215 | public function toString ( RequestInterface $ request ) { $ string = sprintf ( "%s %s HTTP/%s\n" , $ request -> getMethod ( ) , $ request -> getRequestTarget ( ) , $ request -> getProtocolVersion ( ) ) ; $ string .= $ this -> headersAndBody ( $ request ) ; return $ string ; } | Generate a pretty PS7 request . |
32,216 | public function get ( $ encode = true ) { return ( $ encode === true ) ? json_encode ( $ this -> rendered ) : $ this -> rendered ; } | Return JSON - encoded result! So we prevent double JSON encoding . |
32,217 | public function lookup ( $ string , $ uuid = null , $ arguments = null ) { if ( is_array ( $ string ) === true ) { $ translate = 'FAIL' ; } else { $ translate = $ string ; } $ string = gettext ( $ translate ) ; if ( $ arguments !== null ) { $ string = vsprintf ( $ string , $ arguments ) ; } return $ string ; } | This method is intend to look - up the translation of the given combination of values . |
32,218 | protected function buildTranslationtable ( $ locale , array $ namespaces ) { $ namespace = $ namespaces [ 0 ] ; return [ $ locale => $ this -> initI18n ( $ locale , $ this -> getEncoding ( ) , $ namespace , $ this -> getPath ( ) ) , ] ; } | This method is intend to build a translation - tables for giving locale and namespace . |
32,219 | protected function normalizeEncoding ( $ encoding ) { if ( $ encoding === null ) { $ encoding = '' ; } if ( $ encoding === '' ) { return $ encoding ; } return '.' . strtolower ( str_replace ( '-' , '' , $ encoding ) ) ; } | Returns a normalized encoding . |
32,220 | public function listAction ( ) { $ automaticTheme = $ this -> addAutomaticTheme ( ) ; $ themeMaper = $ this -> getAdminThemeService ( ) ; $ themesActivated = $ themeMaper -> findActiveTheme ( ) ; $ themesNotActivated = $ themeMaper -> findActiveTheme ( false ) ; return array ( 'themesActivated' => $ themesActivated , 'themesNotActivated' => $ themesNotActivated , 'automaticTheme' => $ automaticTheme , 'flashMessages' => $ this -> flashMessenger ( ) -> getMessages ( ) ) ; } | Liste des themes |
32,221 | public function editAction ( ) { $ themeId = $ this -> getEvent ( ) -> getRouteMatch ( ) -> getParam ( 'themeId' ) ; $ theme = $ this -> getAdminThemeService ( ) -> findById ( $ themeId ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'playgrounddesign_theme_form' ) ; $ request = $ this -> getRequest ( ) ; $ form -> bind ( $ theme ) ; if ( $ request -> isPost ( ) ) { $ data = array_merge ( $ request -> getPost ( ) -> toArray ( ) , $ request -> getFiles ( ) -> toArray ( ) ) ; $ theme = $ this -> getAdminThemeService ( ) -> edit ( $ data , $ theme , 'playgrounddesign_theme_form' ) ; if ( $ theme ) { $ this -> flashMessenger ( ) -> addMessage ( 'The theme "' . $ theme -> getTitle ( ) . '" was updated' ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } else { $ this -> flashMessenger ( ) -> addMessage ( 'The theme was not updated' ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } } $ viewModel = new ViewModel ( ) ; $ viewModel -> setTemplate ( 'playground-design/theme-admin/theme' ) ; return $ viewModel -> setVariables ( array ( 'form' => $ form , 'automaticTheme' => 0 ) ) ; } | Edition d un theme |
32,222 | public function newAction ( ) { $ form = $ this -> getServiceLocator ( ) -> get ( 'playgrounddesign_theme_form' ) ; $ request = $ this -> getRequest ( ) ; $ themeEntity = new themeEntity ; if ( $ request -> isPost ( ) ) { $ data = array_merge ( $ request -> getPost ( ) -> toArray ( ) , $ request -> getFiles ( ) -> toArray ( ) ) ; $ theme = $ this -> getAdminThemeService ( ) -> create ( $ data , 'playgrounddesign_theme_form' ) ; if ( $ theme ) { $ this -> flashMessenger ( ) -> addMessage ( 'The theme "' . $ theme -> getTitle ( ) . '" was created' ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } else { $ this -> flashMessenger ( ) -> addMessage ( 'The theme was not created' ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } } $ viewModel = new ViewModel ( ) ; $ viewModel -> setTemplate ( 'playground-design/theme-admin/theme' ) ; return $ viewModel -> setVariables ( array ( 'form' => $ form , 'automaticTheme' => 0 ) ) ; } | Creation d un theme |
32,223 | public function deleteAction ( ) { $ themeId = $ this -> getEvent ( ) -> getRouteMatch ( ) -> getParam ( 'themeId' ) ; $ theme = $ this -> getAdminThemeService ( ) -> findById ( $ themeId ) ; $ title = $ theme -> getTitle ( ) ; $ this -> getAdminThemeService ( ) -> remove ( $ theme ) ; $ this -> flashMessenger ( ) -> addMessage ( 'The theme "' . $ title . '"has been deleted' ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } | Suppresion d un theme |
32,224 | public function activateAction ( ) { $ themeId = $ this -> getEvent ( ) -> getRouteMatch ( ) -> getParam ( 'themeId' ) ; $ theme = $ this -> getAdminThemeService ( ) -> findById ( $ themeId ) ; $ themeActivated = $ this -> getAdminThemeService ( ) -> findActiveThemeByArea ( $ theme -> getArea ( ) ) ; if ( sizeof ( $ themeActivated ) > 0 ) { $ themeActivated [ 0 ] -> setIsActive ( false ) ; $ this -> getAdminThemeService ( ) -> update ( $ themeActivated [ 0 ] ) ; } $ theme -> setIsActive ( true ) ; $ this -> getAdminThemeService ( ) -> update ( $ theme ) ; $ this -> flashMessenger ( ) -> addMessage ( 'The theme "' . $ theme -> getTitle ( ) . '" is activate' ) ; $ eventManager = new EventManager ( ) ; $ eventManager -> trigger ( \ Zend \ ModuleManager \ ModuleEvent :: EVENT_MERGE_CONFIG ) ; return $ this -> redirect ( ) -> toRoute ( 'admin/playgrounddesign_themeadmin' ) ; } | Activation d un theme |
32,225 | public function updateMany ( array $ settings ) { foreach ( $ settings as $ k => $ v ) { if ( $ this -> update ( $ k , $ v ) === false ) { return false ; } } return true ; } | Update many settings . |
32,226 | private function getCachedSettings ( ) { if ( ! Cache :: has ( self :: CACHE_NAME ) ) { $ this -> initCachedSettings ( ) ; } return new Collection ( Cache :: get ( self :: CACHE_NAME ) ) ; } | Get the cached settings data . |
32,227 | private function setCachedSettings ( Collection $ settings ) { $ expiresAt = Carbon :: now ( ) -> addMinutes ( 15 ) ; $ settings = $ settings -> toArray ( ) ; Cache :: put ( self :: CACHE_NAME , $ settings , $ expiresAt ) ; $ this -> fireEvent ( 'cache_updated' , array ( $ settings ) ) ; } | Set new settings data to cache . |
32,228 | static function getParameters ( $ connection_name ) { if ( ! array_key_exists ( $ connection_name , self :: $ parameters ) ) { throw new RuntimeException ( "Configuration for database '$connection_name' not loaded" ) ; } return self :: $ parameters [ $ connection_name ] ; } | Get the parameters for a given connection name |
32,229 | public function display ( $ file , $ vars = [ ] ) { if ( ( DIRECTORY_SEPARATOR !== $ file [ 0 ] ) && ( ':' !== $ file [ 1 ] ) ) { $ moduleFolder = $ this -> request -> getModulePath ( ) ; $ controllerFolder = $ this -> request -> getController ( ) ; $ viewsFolder = str_replace ( [ '{APP_ROOT}' , '{MODULE_FOLDER}' , '{CONTROLLER}' , '{LIBS_FOLDER}' , '{DIRECTORY_SEPARATOR}' ] , [ APP_ROOT , $ moduleFolder , $ controllerFolder , LIBS_FOLDER , DIRECTORY_SEPARATOR ] , $ this -> viewsFolder ) ; $ file = $ viewsFolder . DIRECTORY_SEPARATOR . $ file . '.php' ; } foreach ( $ this -> _displayVars as $ k => $ v ) { $ $ k = $ v ; } foreach ( $ vars as $ k => $ v ) { $ $ k = $ v ; } require $ file ; } | Display a php file page . |
32,230 | public function canRun ( $ arguments = [ ] ) { $ action = 'action' . ucfirst ( $ this -> getActiveAction ( ) ) ; return $ this -> canCallMethod ( $ action , $ arguments ? $ arguments : ( $ this -> request ? $ this -> request -> getParams ( ) : [ ] ) ) ; } | Checks if it can call current action with the available paramteres ; |
32,231 | public function isCommented ( ) { if ( $ parts = $ this -> _getParts ( ) ) { $ d = $ parts [ 3 ] ; $ d = explode ( "\n" , $ d ) ; foreach ( $ d as $ key => & $ data ) { $ data = rtrim ( $ data ) ; if ( preg_match ( $ this -> pregcheck , $ data , $ match ) ) { return false ; } } } return true ; } | Czy blok jest zakomentowany . |
32,232 | public static function format ( $ phone ) { if ( substr ( $ phone , 0 , 3 ) == '+1 ' ) { $ phone = str_replace ( '+1 ' , '' , $ phone ) ; } if ( preg_match_all ( '/[0-9]/' , $ phone ) == 10 ) { $ phone = preg_replace ( '/[^0-9]/' , '' , $ phone ) ; $ phone = '(' . substr ( $ phone , 0 , 3 ) . ') ' . substr ( $ phone , 3 , 3 ) . '-' . substr ( $ phone , 6 ) ; } if ( empty ( $ phone ) ) { $ phone = null ; } return $ phone ; } | Format the phone number in our very special and customized manner . |
32,233 | public function getRoute ( $ name ) { if ( ! $ this -> hasRoute ( $ name ) ) { throw new \ Exception ( $ name ) ; } return $ this -> routes [ $ name ] ; } | Get a route by name |
32,234 | public function build ( $ force = false ) { if ( ( null === $ parsedUploadedFiles = $ this -> getParsedUploadedFiles ( ) ) || ( true === $ force ) ) { $ parsedUploadedFiles = [ ] ; foreach ( $ this -> getUploadedFiles ( ) as $ argumentName => $ file ) { $ parsedUploadedFiles [ $ argumentName ] = $ this -> factoryFilesTree ( $ file [ 'name' ] , $ file [ 'type' ] , $ file [ 'tmp_name' ] , $ file [ 'error' ] , $ file [ 'size' ] ) ; } $ this -> setParsedUploadedFiles ( $ parsedUploadedFiles ) ; } return $ parsedUploadedFiles ; } | Builds a PSR - 7 compatible uploaded file structure and returns it . |
32,235 | protected function factoryFilesTree ( $ fileName , $ fileType , $ fileTemporaryName , $ fileError , $ fileSize ) { if ( false === is_array ( $ fileError ) ) { return new Doozr_Request_File ( [ 'name' => $ fileName , 'type' => $ fileType , 'tmp_name' => $ fileTemporaryName , 'error' => $ fileError , 'size' => $ fileSize , ] ) ; } $ filesTree = [ ] ; foreach ( $ fileError as $ nodeName => $ errorData ) { $ filesTree [ $ nodeName ] = $ this -> factoryFilesTree ( $ fileName [ $ nodeName ] , $ fileType [ $ nodeName ] , $ fileTemporaryName [ $ nodeName ] , $ errorData , $ fileSize [ $ nodeName ] ) ; } return $ filesTree ; } | Recursive parses a passed uploaded file and builds the new structure . |
32,236 | public function process ( & $ request ) { $ authorize = $ this -> deny ; assert ( 'is_array($request)' ) ; assert ( 'array_key_exists("Attributes", $request)' ) ; $ attributes = & $ request [ 'Attributes' ] ; foreach ( $ this -> valid_attribute_values as $ name => $ patterns ) { if ( array_key_exists ( $ name , $ attributes ) ) { foreach ( $ patterns as $ pattern ) { $ values = $ attributes [ $ name ] ; if ( ! is_array ( $ values ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ value ) { if ( $ this -> regex ) { $ matched = preg_match ( $ pattern , $ value ) ; } else { $ matched = ( $ value == $ pattern ) ; } if ( $ matched ) { $ authorize = ( $ this -> deny ? false : true ) ; break 3 ; } } } } } if ( ! $ authorize ) { $ this -> unauthorized ( $ request ) ; } } | Apply filter to validate attributes . |
32,237 | public static function saltTooShort ( string $ str ) { $ length = strlen ( $ str ) ; if ( $ length === 0 ) { return new self ( sprintf ( 'The internal key salt must be at least 8 characters. You supplied an empty salt.' ) ) ; } else { return new self ( sprintf ( 'The internal key salt must be at least 8 characters. You supplied a %s character salt: %s' , $ length , $ str ) ) ; } } | Exception message when the supplied salt is too short . |
32,238 | public static function webappPrefixTooShort ( string $ str ) { $ length = strlen ( $ str ) ; if ( $ length === 0 ) { return new self ( sprintf ( 'The WebApp Prefix must be at least 3 characters. You supplied an empty Prefix.' ) ) ; } else { return new self ( sprintf ( 'The WebApp Prefix must be at least 3 characters. You supplied a %s character Prefix: %s' , $ length , $ str ) ) ; } } | Exception message when WebApp Prefix too short . |
32,239 | public function updateSubscriber ( string $ email , string $ firstName = null , string $ lastName = null , $ interests = null , array $ extras = [ ] ) : bool { $ data = array_merge ( [ 'status_if_new' => 'subscribed' , 'email_address' => $ email ] , $ extras ) ; $ mergeFields = [ ] ; if ( $ firstName !== null ) { $ mergeFields [ 'FNAME' ] = $ firstName ; } if ( $ lastName !== null ) { $ mergeFields [ 'LNAME' ] = $ lastName ; } if ( count ( $ mergeFields ) > 0 ) { $ data [ 'merge_fields' ] = ( object ) $ mergeFields ; } if ( $ interests !== null ) { $ data [ 'interests' ] = ( object ) $ interests ; } $ result = $ this -> api -> put ( 'lists/' . $ this -> id ( ) . '/members/' . $ this -> support -> hashEmail ( $ email ) , $ data ) ; return $ result -> has ( 'id' ) && strlen ( $ result -> get ( 'id' ) ) > 0 ; } | Updates a subscriber if the email address is already on the list or create the subscriber |
32,240 | public function getExpiresInterval ( ) { if ( ! $ this -> expiresAt ) return '' ; $ now = new \ DateTime ( ) ; $ interval = $ now -> diff ( $ this -> expiresAt ) ; if ( $ interval -> days == 1 ) return $ interval -> format ( '%a jour' ) ; elseif ( $ interval -> days > 1 ) return $ interval -> format ( '%a jours' ) ; elseif ( $ interval -> h == 1 ) return $ interval -> format ( '%h heure' ) ; else return $ interval -> format ( '%h heures' ) ; } | Retourne l intervalle avant l expiration |
32,241 | function _HMAC_MD5 ( $ key , $ data , $ raw_output = FALSE ) { if ( strlen ( $ key ) > 64 ) { $ key = pack ( 'H32' , md5 ( $ key ) ) ; } if ( strlen ( $ key ) < 64 ) { $ key = str_pad ( $ key , 64 , chr ( 0 ) ) ; } $ k_ipad = substr ( $ key , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ; $ k_opad = substr ( $ key , 0 , 64 ) ^ str_repeat ( chr ( 0x5C ) , 64 ) ; $ inner = pack ( 'H32' , md5 ( $ k_ipad . $ data ) ) ; $ digest = md5 ( $ k_opad . $ inner , $ raw_output ) ; return $ digest ; } | Function which implements HMAC MD5 digest |
32,242 | protected function _HMAC_SHA1 ( $ key , $ data , $ raw_output = FALSE ) { if ( strlen ( $ key ) > 64 ) { $ key = sha1 ( $ key , TRUE ) ; } if ( strlen ( $ key ) < 64 ) { $ key = str_pad ( $ key , 64 , chr ( 0 ) ) ; } $ k_ipad = substr ( $ key , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ; $ k_opad = substr ( $ key , 0 , 64 ) ^ str_repeat ( chr ( 0x5C ) , 64 ) ; $ inner = pack ( 'H40' , sha1 ( $ k_ipad . $ data ) ) ; $ digest = sha1 ( $ k_opad . $ inner , $ raw_output ) ; return $ digest ; } | Function which implements HMAC - SHA - 1 digest |
32,243 | public function delete ( ) { $ i = 0 ; foreach ( $ this -> _models as $ model ) { $ i += $ this -> dropTable ( $ model ) ; } return $ i ; } | Drop all tables from database . |
32,244 | public function hasTable ( $ tableName ) { if ( $ tableName instanceof Model ) { $ tableName = $ tableName -> tableName ( ) ; } return $ this -> connection -> getSchemaManager ( ) -> tablesExist ( [ $ tableName ] ) ; } | Check table in database . |
32,245 | public function addLabel ( Doozr_Form_Service_Component_Interface_Html $ label ) { $ index = $ this -> addChild ( $ label ) ; $ this -> index [ $ index ] = self :: LABEL ; ( ! isset ( $ this -> indexReverse [ self :: LABEL ] ) ) ? $ this -> indexReverse [ self :: LABEL ] = [ ] : null ; $ this -> indexReverse [ self :: LABEL ] [ ] = $ index ; return $ index ; } | Adds a label to the group . |
32,246 | public function addComponent ( Doozr_Form_Service_Component_Interface_Html $ element ) { $ index = $ this -> addChild ( $ element ) ; $ this -> index [ $ index ] = self :: COMPONENT ; ( ! isset ( $ this -> indexReverse [ self :: COMPONENT ] ) ) ? $ this -> indexReverse [ self :: COMPONENT ] = [ ] : null ; $ this -> indexReverse [ self :: COMPONENT ] [ ] = $ index ; return $ index ; } | Adds an element to the group . |
32,247 | public function addMessage ( Doozr_Form_Service_Component_Message $ message ) { $ index = $ this -> addChild ( $ message ) ; $ this -> index [ $ index ] = self :: MESSAGE ; ( ! isset ( $ this -> indexReverse [ self :: MESSAGE ] ) ) ? $ this -> indexReverse [ self :: MESSAGE ] = [ ] : null ; $ this -> indexReverse [ self :: MESSAGE ] [ ] = $ index ; return $ index ; } | Adds a message to the group . |
32,248 | public function getLabels ( ) { $ result = [ ] ; $ labels = ( isset ( $ this -> indexReverse [ self :: LABEL ] ) ) ? $ this -> indexReverse [ self :: LABEL ] : [ ] ; foreach ( $ labels as $ index ) { $ result [ ] = $ this -> getChild ( $ index ) ; } return $ result ; } | Returns the label of this group . |
32,249 | public function getComponents ( ) { $ components = [ ] ; foreach ( $ this -> indexReverse [ self :: COMPONENT ] as $ index ) { $ components [ ] = $ this -> getChild ( $ index ) ; } return $ components ; } | Returns the Component of this group . |
32,250 | public function getMessage ( ) { $ result = [ ] ; $ messages = ( isset ( $ this -> indexReverse [ self :: MESSAGE ] ) ) ? $ this -> indexReverse [ self :: MESSAGE ] : [ ] ; foreach ( $ messages as $ index ) { $ result [ ] = $ this -> getChild ( $ index ) ; } return $ result ; } | Returns the message of this group . |
32,251 | public function setOrder ( array $ order ) { if ( in_array ( self :: LABEL , $ order ) === false || in_array ( self :: COMPONENT , $ order ) === false || in_array ( self :: MESSAGE , $ order ) === false ) { throw new Doozr_Form_Service_Exception ( 'Alda' ) ; } $ this -> order = $ order ; } | Setter for order . |
32,252 | public function render ( $ force = false ) { $ this -> setChildren ( $ this -> sort ( $ this -> order ) ) ; return parent :: render ( $ force ) ; } | Renders a component a returns it HTML code . |
32,253 | protected function sort ( $ order ) { $ ordered = [ ] ; $ matrix = [ 'label' => 'getLabels' , 'component' => 'getComponents' , 'message' => 'getMessage' , ] ; foreach ( $ order as $ identifier ) { $ components = $ this -> { $ matrix [ $ identifier ] } ( ) ; foreach ( $ components as $ component ) { $ index = count ( $ ordered ) ; $ this -> indexReverse [ $ identifier ] [ 0 ] = $ index ; $ this -> index [ $ index ] = $ identifier ; $ ordered [ ] = $ component ; } } return $ ordered ; } | Sorts an array by passed order . |
32,254 | protected function wire ( ) { $ labels = ( isset ( $ this -> indexReverse [ self :: LABEL ] ) ) ? $ this -> indexReverse [ self :: LABEL ] : null ; $ components = ( isset ( $ this -> indexReverse [ self :: COMPONENT ] ) ) ? $ this -> indexReverse [ self :: COMPONENT ] : null ; for ( $ i = 0 ; $ i < count ( $ labels ) ; ++ $ i ) { if ( isset ( $ components [ $ i ] ) ) { $ label = $ this -> getChild ( $ labels [ $ i ] ) ; $ label -> setAttribute ( 'for' , $ this -> getChild ( $ components [ $ i ] ) -> getId ( ) ) ; $ this -> addChild ( $ label , $ labels [ $ i ] ) ; } } } | Connects the element with the for attribute of the label . |
32,255 | final protected function parseDocComment ( $ docComment , $ docType = '' ) { if ( empty ( $ docComment ) || ! is_string ( $ docComment ) ) return array ( ) ; $ annotations = array ( ) ; $ match = '#@' . stripslashes ( $ docType ) . '(.*?)\n#s' ; preg_match_all ( $ match , $ docComment , $ annotations ) ; return $ annotations [ 1 ] ; } | Parses the given docComment |
32,256 | final public function getClass ( $ docType = '' , $ forceNew = false ) { if ( ! isset ( $ this -> annotations [ 'class' ] ) || $ forceNew ) $ this -> annotations [ 'class' ] = $ this -> parseDocComment ( $ this -> reflector -> getDocComment ( ) , $ docType ) ; return ( $ this -> annotations [ 'class' ] ) ? $ this -> annotations [ 'class' ] : array ( ) ; } | Fetches the class annotations |
32,257 | final public function getAll ( $ docType = '' , $ forceNew = '' ) { $ this -> getClass ( $ docType , $ forceNew ) ; $ this -> getProperties ( $ docType , $ forceNew ) ; $ this -> getMethods ( $ docType , $ forceNew ) ; return $ this -> annotations ; } | Fetches all annotations |
32,258 | final public function getMethods ( $ docType = '' , $ forceNew = false ) { $ this -> checkExists ( 'methods' , $ docType , $ forceNew ) ; return ( $ this -> annotations [ 'methods' ] ) ? $ this -> annotations [ 'methods' ] : array ( ) ; } | Fetches all methods annotations |
32,259 | final public function getMethod ( $ method , $ docType = '' , $ forceNew = false ) { if ( ! in_array ( $ method , $ this -> annotations [ 'methods' ] ) ) throw new \ Exception ( 'Method "' . $ method . '" not found' ) ; $ this -> checkExists ( 'methods' , $ docType , $ forceNew ) ; return $ this -> annotations [ 'methods' ] [ $ method ] ; } | Fetches annotations for a particular method |
32,260 | final public function getProperties ( $ docType = '' , $ forceNew = false ) { $ this -> checkExists ( 'properties' , $ docType , $ forceNew ) ; return ( $ this -> annotations [ 'properties' ] ) ? $ this -> annotations [ 'properties' ] : array ( ) ; } | Fetches all properties annotations |
32,261 | final public function getProperty ( $ property , $ docType = '' , $ forceNew = false ) { if ( ! in_array ( $ property , $ this -> annotations [ 'properties' ] ) ) throw new \ Exception ( 'Property "' . $ property . '" not found' ) ; $ this -> checkExists ( 'properties' , $ docType , $ forceNew ) ; return ( $ this -> annotations [ 'properties' ] [ $ property ] ) ? $ this -> annotations [ 'properties' ] [ $ property ] : array ( ) ; } | Fetches annotations for a particular property |
32,262 | private function checkExists ( $ type , $ docType , $ forceNew ) { if ( ! isset ( $ this -> annotations [ strtolower ( $ type ) ] ) || $ forceNew ) $ this -> { 'parse' . ucfirst ( $ type ) } ( $ docType ) ; return isset ( $ this -> annotations [ strtolower ( $ type ) ] ) ; } | Checks whether class|properties|methods s annotations have been retrieved |
32,263 | private function parseMethods ( $ docType = '' ) { foreach ( $ this -> reflector -> getMethods ( ) as $ refMeth ) { $ this -> annotations [ 'methods' ] [ $ refMeth -> name ] = $ this -> parseDocComment ( $ refMeth -> getDocComment ( ) , $ docType ) ; } } | parses annotations for methods only |
32,264 | private function parseProperties ( $ docType = '' ) { $ parents = $ this -> parents ; foreach ( $ this -> reflector -> getProperties ( ) as $ refProp ) { if ( is_string ( $ parents [ $ refProp -> class ] ) ) $ parents [ $ refProp -> class ] = array ( ) ; $ parents [ $ refProp -> class ] [ $ refProp -> name ] = $ this -> parseDocComment ( $ refProp -> getDocComment ( ) , $ docType ) ; } $ this -> annotations [ 'properties' ] = array ( ) ; foreach ( $ parents as $ array ) { if ( is_array ( $ array ) ) $ this -> annotations [ 'properties' ] = array_merge ( $ this -> annotations [ 'properties' ] , $ array ) ; } } | parses annotations for properties only |
32,265 | public function render ( string $ format = 'actual' , string $ before = '' , string $ after = '' ) : string { $ format_allowed = [ 'actual' , 'difference' , 'mixed' ] ; $ format = \ in_array ( $ format , $ format_allowed ) ? $ format : 'actual' ; $ method = "render_{$format}" ; if ( ! \ is_callable ( [ $ this , $ method ] ) ) { return '' ; } $ time_ago = '' ; if ( $ before ) { $ time_ago .= '<span class="before">' . $ before . '</span> ' ; } $ time_ago .= $ this -> $ method ( ) ; if ( $ after ) { $ time_ago .= ' <span class="after">' . $ after . '</span>' ; } return $ time_ago ; } | Period since publishing or updating a post . |
32,266 | protected function buildS3Client ( $ attachedFile ) { return S3Client :: factory ( [ 'key' => $ attachedFile -> key , 'secret' => $ attachedFile -> secret , 'region' => $ attachedFile -> region , 'scheme' => $ attachedFile -> scheme ] ) ; } | Build an S3Client instance using the information defined in this class s attachedFile object . |
32,267 | public function initializeModuleSystem ( ) { $ activatedModules = $ this -> moduleObjectBackend -> loadObject ( ) ; if ( ! is_array ( $ activatedModules ) ) { $ activatedModules = array ( ) ; } $ this -> activatedModules = $ activatedModules ; foreach ( $ this -> activatedModules as $ activatedModule ) { $ this -> initializeModule ( $ activatedModule [ 'path' ] ) ; } } | Initializes the module system . Loads the activated modules from the object backend and loads all modules . |
32,268 | public function registerModuleDirectory ( $ directory , $ excludePattern = '/\/tests\//' ) { if ( ! isset ( $ this -> moduleDirectories [ $ directory ] ) ) { $ this -> moduleDirectories [ $ directory ] = $ excludePattern ; return true ; } return false ; } | Adds a directory as module directory |
32,269 | public function activateModule ( $ namespace , $ activateDependencies = false ) { $ namespace = Framework :: prepareNamespace ( $ namespace ) ; if ( isset ( $ this -> activatedModules [ $ namespace ] ) ) { return true ; } $ path = $ this -> searchModulePath ( $ namespace ) ; if ( $ path === false ) { throw new Exception ( 'Can not find the module "' . $ namespace . '".' ) ; } $ moduleProperties = $ this -> parseModuleJson ( $ path ) ; $ version = $ moduleProperties -> module -> version ; $ module = $ this -> initializeModule ( $ path , $ activateDependencies ) ; $ module -> activate ( $ version , 0 ) ; $ this -> activatedModules [ $ namespace ] = array ( 'version' => $ version , 'path' => $ path ) ; $ this -> saveActivatedModules ( ) ; return true ; } | Searches and activates the module with the given namespace . The register method of the module will be executed . |
32,270 | public function deactivateModule ( $ namespace ) { $ namespace = Framework :: prepareNamespace ( $ namespace ) ; if ( ! isset ( $ this -> activatedModules [ $ namespace ] ) ) { return false ; } $ namespace = Framework :: prepareNamespace ( $ namespace ) ; $ module = $ this -> getModule ( $ namespace ) ; if ( $ module === false ) { return false ; } $ module -> deactivate ( ) ; unset ( $ this -> activatedModules [ $ namespace ] ) ; unset ( $ this -> modules [ $ namespace ] ) ; $ this -> saveActivatedModules ( ) ; return true ; } | Deactivates an activated module . The deregister method of the module will be executed . |
32,271 | public function getModuleByClassName ( $ className ) { $ longest = 0 ; $ foundModule = false ; $ className = Framework :: prepareClassName ( $ className ) ; foreach ( $ this -> modules as $ moduleNamespace => $ module ) { $ moduleNamespace = Framework :: prepareNamespace ( $ moduleNamespace ) ; $ sameNamespace = strpos ( $ className , $ moduleNamespace ) ; $ length = strlen ( $ moduleNamespace ) ; if ( $ sameNamespace !== false && $ length > $ longest ) { $ longest = $ length ; $ foundModule = $ module ; } } return $ foundModule ; } | Searches the module for the given class name . |
32,272 | public function reactivateModules ( ) { foreach ( $ this -> modules as $ module ) { $ moduleProperties = $ this -> parseModuleJson ( $ module -> getDirectory ( ) ) ; $ version = $ moduleProperties -> module -> version ; $ this -> activateModule ( $ moduleProperties -> module -> namespace , true ) ; $ module -> activate ( $ version , $ version ) ; } } | Iterates trough the modules and activates each of the modules . |
32,273 | protected function parseModuleJson ( $ path ) { if ( ! file_exists ( $ path . '/Module.json' ) ) { throw new Exception ( 'Cannot find Module.json in the path "' . $ path . '".' ) ; } $ moduleProperties = json_decode ( file_get_contents ( $ path . '/Module.json' ) ) ; return $ moduleProperties ; } | Returns an object with the properties of the module from the Module . json file in the given path . |
32,274 | protected function getNamespaceFromModuleJson ( $ path ) { $ moduleProperties = $ this -> parseModuleJson ( $ path ) ; if ( ! isset ( $ moduleProperties -> module -> namespace ) ) { throw new Exception ( 'The namespace is not set in the module properties for the module in "' . $ path . '".' ) ; } return Framework :: prepareNamespace ( $ moduleProperties -> module -> namespace ) ; } | Returns the namespace for the module in the given path . |
32,275 | protected function initializeModule ( $ path , $ activateDependencies = false ) { $ moduleNamespace = $ this -> getNamespaceFromModuleJson ( $ path ) ; $ module = $ this -> getModule ( $ moduleNamespace ) ; if ( $ module instanceof ModuleAbstract ) { return $ module ; } if ( ! file_exists ( $ path . '/Module.php' ) ) { throw new Exception ( 'The module "' . $ path . '" is not valid!' ) ; } $ this -> handleModuleDependencies ( $ moduleNamespace , $ path , $ activateDependencies ) ; require_once ( $ path . '/Module.php' ) ; $ moduleClassName = Framework :: prepareClassName ( $ moduleNamespace . 'Module' ) ; $ module = new $ moduleClassName ( $ this -> framework , $ moduleNamespace , $ path ) ; $ this -> modules [ $ moduleNamespace ] = $ module ; $ module -> initialize ( ) ; return $ module ; } | Initializes the module . This creates an new Module object if the given module path is valid . The function returns the initialized module or false if the module can t be initialized . |
32,276 | protected function handleRequiredDependencies ( $ moduleNamespace , $ dependencies , $ activateDependencies ) { foreach ( $ dependencies as $ dependencyModuleNamespace => $ version ) { $ dependencyModuleNamespace = Framework :: prepareNamespace ( $ dependencyModuleNamespace ) ; $ module = $ this -> getModule ( $ dependencyModuleNamespace ) ; if ( $ module === false ) { if ( $ activateDependencies ) { $ this -> activateModule ( $ dependencyModuleNamespace , $ activateDependencies ) ; } else { throw new Exception ( 'Can not activate the module "' . $ moduleNamespace . '". The module requires the module "' . $ dependencyModuleNamespace . '" which isn\'t activated.' ) ; } } } } | Handles all required dependencies . |
32,277 | protected function searchModulePath ( $ namespace ) { $ targetPath = false ; foreach ( $ this -> moduleDirectories as $ directory => $ excludePattern ) { $ recursiveDirectoryIterator = new \ RecursiveDirectoryIterator ( $ directory , \ RecursiveDirectoryIterator :: FOLLOW_SYMLINKS ) ; $ iterator = new \ RecursiveIteratorIterator ( $ recursiveDirectoryIterator ) ; $ regexIterator = new \ RegexIterator ( $ iterator , '/^.+\/Module\.json$/i' ) ; foreach ( $ regexIterator as $ item ) { if ( $ excludePattern !== false && preg_match ( $ excludePattern , $ item -> getPath ( ) ) ) { continue ; } $ moduleNamespace = $ this -> getNamespaceFromModuleJson ( $ item -> getPath ( ) ) ; if ( $ moduleNamespace === $ namespace ) { $ targetPath = $ item -> getPath ( ) ; break 2 ; } } } return $ targetPath ; } | Iterates over the available module directories and searches the target namespace in the module directories . If the namespace is found the function return the path to the module . |
32,278 | public function _mergeWithPrevious ( $ previous ) { if ( ! $ previous ) { return $ this ; } if ( $ previous instanceof DeleteOperation ) { return new SetOperation ( $ this -> objects ) ; } if ( $ previous instanceof SetOperation ) { $ oldValue = $ previous -> getValue ( ) ; $ result = $ this -> _apply ( $ oldValue , null , null ) ; return new SetOperation ( $ result ) ; } if ( $ previous instanceof AddUniqueOperation ) { $ oldList = $ previous -> getValue ( ) ; $ result = $ this -> _apply ( $ oldList , null , null ) ; return new AddUniqueOperation ( $ result ) ; } throw new AVException ( 'Operation is invalid after previous operation.' ) ; } | Merge this operation with the previous operation and return the result . |
32,279 | public function getFormHandler ( $ scope = DOOZR_NAMESPACE , Request $ request = null , $ method = Doozr_Form_Service_Constant :: DEFAULT_METHOD , $ angularDirectives = false ) { return $ this -> formHandlerFactory ( $ scope , $ request , $ method , $ angularDirectives ) ; } | Returns FormHandler instance for scope . |
32,280 | protected function formHandlerFactory ( $ scope , Request $ request = null , $ method , $ angularDirectives ) { return self :: $ registry -> getContainer ( ) -> build ( 'doozr.form.service.handler.formhandler' , [ $ scope , $ request , $ method , $ angularDirectives , ] ) ; } | Factory for FormHandler . |
32,281 | protected function execute ( InputInterface $ input , OutputInterface $ output ) : void { $ destination = ( string ) $ input -> getOption ( 'destination' ) ; if ( ! is_readable ( dirname ( $ destination ) ) || ! is_readable ( $ destination ) && ! mkdir ( $ destination , 0755 , true ) ) { throw new \ Exception ( sprintf ( 'Unable to read output directory [%s]' , $ destination ) ) ; } $ wsdlToClass = new WsdlToClass ( new Wsdl ( ( string ) $ input -> getArgument ( 'wsdl' ) ) , $ destination , ( string ) $ input -> getOption ( 'namespace' ) , new RegexParser ( ) , new TwigGenerator ( $ input -> getOption ( 'template' ) ) , new ResourceWriter ( ) , new Printer ( new Printer \ SymfonyOutputBridge ( $ output ) ) ) ; $ wsdlToClass -> execute ( ) ; } | Execute the generate command |
32,282 | private function guardInvalidArguments ( $ field , array $ input , $ output ) { if ( ! in_array ( $ field , $ this -> getSupportedFields ( ) ) ) { throw UnsupportedFieldException :: forField ( $ field ) ; } if ( ! ( $ output instanceof IptcInterface ) ) { throw UnsupportedOutputException :: forOutput ( $ output ) ; } } | Guard function for invalid arguments |
32,283 | public function render ( $ filename , $ data ) { $ html = Twig :: render ( $ filename , $ data ) ; $ dir = sys_get_temp_dir ( ) . "/dompdf" ; $ options = new Options ( ) ; $ options -> setIsRemoteEnabled ( true ) ; $ options -> setFontDir ( $ this -> resolveDirectory ( $ dir . "/lib/fonts" ) ) ; $ options -> setFontCache ( $ this -> resolveDirectory ( $ dir . "/lib/fonts" ) ) ; $ dompdf = new Dompdf ( $ options ) ; $ dompdf -> loadHtml ( $ html ) ; $ dompdf -> render ( ) ; return $ dompdf -> output ( ) ; } | Render a file . |
32,284 | public function getApiAuthenticationEnabledDevMode ( ) { $ result = $ this -> scopeConfig -> getValue ( 'praxigento_api/authentication/enabled_dev_mode' ) ; $ result = filter_var ( $ result , FILTER_VALIDATE_BOOLEAN ) ; return $ result ; } | Return true if Developer Mode is enabled for MOBI API Authentication . |
32,285 | protected function parseRecordLabel ( $ label ) { $ table = null ; if ( false !== strpos ( $ label , '.' ) ) { list ( $ table , $ label ) = explode ( '.' , $ label , 2 ) ; } return array ( $ table , $ label ) ; } | Parses a label for its table and label name |
32,286 | public function load ( ) { foreach ( $ this -> registers as $ register ) { $ registerInstance = $ register instanceof RouteRegister ? $ register : new $ register ; $ registerInstance -> register ( $ this -> routeCollector ) ; } return $ this -> routeCollector -> setContainer ( $ this -> container ) -> getData ( ) ; } | Load routes from route register |
32,287 | function SetCheckboxAttribute ( $ optValue , $ attribute , $ value ) { if ( ! isset ( $ this -> fieldAttributes [ $ optValue ] ) ) { $ this -> fieldAttributes [ $ optValue ] = array ( ) ; } $ this -> fieldAttributes [ $ optValue ] [ $ attribute ] = $ value ; } | Sets an attribute directly to a single checkbox |
32,288 | public function getPublishedStatus ( ) { $ obj = $ this -> owner ; $ relations = Config :: inst ( ) -> get ( $ obj -> ClassName , 'versioned_child_relations' ) ; $ relations = $ relations ? : [ ] ; $ childStatuses = [ ] ; foreach ( $ relations as $ relation ) { foreach ( $ obj -> $ relation ( ) as $ item ) { $ childStatuses [ ] = $ item -> getPublishedStatus ( ) ; } } $ childStatuses = array_flip ( array_unique ( $ childStatuses ) ) ; if ( ! $ obj -> hasExtension ( Versioned :: class ) ) { return self :: STATUS_NOT_VERSIONED ; } if ( array_key_exists ( self :: STATUS_NOT_VERSIONED , $ childStatuses ) ) { return 'Child ' . lcfirst ( self :: STATUS_NOT_VERSIONED ) ; } if ( $ obj -> ID == 0 ) { return self :: STATUS_NOT_SAVED ; } if ( array_key_exists ( self :: STATUS_NOT_SAVED , $ childStatuses ) ) { return 'Child' . lcfirst ( self :: STATUS_NOT_SAVED ) ; } if ( Versioned :: get_by_stage ( $ obj -> ClassName , 'Live' ) -> byID ( $ obj -> ID ) == null ) { return self :: STATUS_DRAFT ; } if ( ! $ obj -> latestPublished ( ) || array_key_exists ( self :: STATUS_DRAFT , $ childStatuses ) || array_key_exists ( self :: STATUS_MODIFIED , $ childStatuses ) ) { return self :: STATUS_MODIFIED ; } return self :: STATUS_PUBLISHED ; } | Shows the published status of a Versioned DataObject |
32,289 | protected function newQuery ( array $ options = array ( ) , $ modelClass = null ) { $ options = array_replace ( array ( 'includes' => array ( ) , 'order_by' => array ( ) , 'where' => array ( ) , 'has' => array ( ) , ) , $ options ) ; if ( ! is_string ( $ modelClass ) ) { $ modelClass = $ this -> modelClass ; } $ query = call_user_func ( array ( new $ modelClass ( ) , 'newQuery' ) ) ; if ( is_array ( $ options [ 'includes' ] ) ) { $ includes = array_values ( $ options [ 'includes' ] ) ; foreach ( $ includes as $ include ) { if ( in_array ( $ include , $ this -> includableRelationships ) ) { $ query -> with ( $ include ) ; } } } if ( is_array ( $ options [ 'where' ] ) ) { foreach ( $ options [ 'where' ] as $ condition ) { if ( is_array ( $ condition ) && count ( $ condition ) == 3 ) { $ query -> where ( $ condition [ 0 ] , $ condition [ 1 ] , $ condition [ 2 ] ) ; } } } if ( is_array ( $ options [ 'has' ] ) ) { foreach ( $ options [ 'has' ] as $ relation => $ conditions ) { if ( is_string ( $ relation ) && is_array ( $ conditions ) ) { $ query -> whereHas ( $ relation , function ( $ q ) use ( $ conditions ) { $ i = 0 ; foreach ( $ conditions as $ condition ) { if ( is_array ( $ condition ) && count ( $ condition ) == 2 ) { $ q -> where ( $ condition [ 0 ] , $ condition [ 1 ] ) ; } } } ) ; } } } if ( is_string ( $ options [ 'order_by' ] ) ) { $ options [ 'order_by' ] = json_decode ( $ options [ 'order_by' ] , true ) ; } if ( is_array ( $ options [ 'order_by' ] ) ) { foreach ( $ options [ 'order_by' ] as $ field => $ direction ) { $ direction = strtoupper ( $ direction ) ; if ( is_string ( $ field ) && in_array ( $ direction , array ( 'ASC' , 'DESC' ) ) ) { $ query -> orderBy ( $ field , $ direction ) ; } } } return $ query ; } | Get new query instance . |
32,290 | protected function newCollectionQuery ( array & $ options = array ( ) , $ modelClass = null ) { $ options = array_replace ( array ( 'limit' => null , 'offset' => null , ) , $ options ) ; $ query = $ this -> newQuery ( $ options , $ modelClass ) ; if ( is_numeric ( $ options [ 'limit' ] ) ) { $ options [ 'limit' ] = ( int ) $ options [ 'limit' ] ; } if ( is_numeric ( $ options [ 'offset' ] ) ) { $ options [ 'offset' ] = ( int ) $ options [ 'offset' ] ; } if ( is_integer ( $ options [ 'limit' ] ) ) { $ query -> limit ( $ options [ 'limit' ] ) ; } if ( is_integer ( $ options [ 'offset' ] ) && is_integer ( $ options [ 'limit' ] ) ) { $ query -> offset ( $ options [ 'offset' ] ) ; } return $ query ; } | Get new collection query instance . |
32,291 | protected function newSearchQuery ( $ searchQuery , array $ searchableFields = null , $ statementsType = null , array $ options = array ( ) , $ modelClass = null ) { if ( ! is_string ( $ modelClass ) ) { $ modelClass = $ this -> modelClass ; } $ q = call_user_func ( array ( new $ modelClass ( ) , 'newQueryWithoutScopes' ) ) ; if ( $ searchableFields === null || empty ( $ searchableFields ) ) { $ searchableFields = $ instance -> getVisible ( ) ; } if ( is_string ( $ searchQuery ) ) { $ st = strtoupper ( $ statementsType ) === 'AND' ? 'where' : 'orWhere' ; foreach ( $ searchableFields as $ field ) { $ q -> { $ st } ( $ field , 'LIKE' , "%{$searchQuery}%" ) ; } } elseif ( is_array ( $ searchQuery ) ) { $ st = strtoupper ( $ statementsType ) === 'OR' ? 'orWhere' : 'where' ; foreach ( $ searchableFields as $ field ) { if ( isset ( $ searchQuery [ $ field ] ) ) { $ q -> { $ st } ( $ field , 'LIKE' , "%{$searchQuery[$field]}%" ) ; } } } else { throw new \ ErrorException ( sprintf ( '%s::%s() expects parameter 1 to be string or array, %s given' , __CLASS__ , __METHOD__ , gettype ( $ searchQuery ) ) ) ; } return $ this -> newCollectionQuery ( $ options , $ modelClass ) -> addNestedWhereQuery ( $ q -> getQuery ( ) ) ; } | Get new search query instance . |
32,292 | static function FromString ( $ json ) { $ jsonObj = @ \ json_decode ( $ json ) ; if ( ! is_a ( $ jsonObj , 'stdClass' ) ) { return null ; } $ result = new static ( ) ; $ class = new \ ReflectionClass ( $ result ) ; $ props = $ class -> getProperties ( \ ReflectionProperty :: IS_PUBLIC & ~ \ ReflectionProperty :: IS_STATIC ) ; foreach ( $ props as $ prop ) { $ name = $ prop -> getName ( ) ; if ( isset ( $ jsonObj -> $ name ) ) { $ prop -> setValue ( $ result , $ jsonObj -> $ name ) ; } } return $ result ; } | Creates an instance from json string |
32,293 | protected function parseMap ( ) { $ this -> finalMap = array ( ) ; foreach ( $ this -> map as $ controller => $ actions ) { $ this -> finalMap [ $ controller ] = isset ( $ this -> finalMap [ $ controller ] ) ? $ this -> finalMap [ $ controller ] : array ( ) ; foreach ( $ actions as $ action => $ rights ) { $ this -> parseMapRow ( $ controller , $ action , $ rights ) ; } } } | Parse raw map to create a script readable one . |
32,294 | protected function parseMapRow ( $ controller , $ action , $ rights ) { $ controller = explode ( ',' , $ controller ) ; $ rights = explode ( ',' , $ rights ) ; foreach ( $ rights as & $ right ) { $ right = trim ( $ right ) ; } $ actionsList = explode ( ',' , $ action ) ; foreach ( $ actionsList as $ name ) { foreach ( $ controller as $ c ) { $ this -> finalMap [ trim ( $ c ) ] [ trim ( $ name ) ] = $ rights ; } } } | Parses a single config row |
32,295 | public function canAccess ( $ controller , $ action , $ module = null ) { $ module = is_array ( $ module ) ? null : $ module ; $ rights = $ this -> getRightsFromMap ( $ controller , $ action , $ module ) ; if ( '*' == $ rights [ 0 ] ) { return true ; } if ( '@' == $ rights [ 0 ] ) { return ! \ mpf \ WebApp :: get ( ) -> user ( ) -> isGuest ( ) ; } $ hasRights = false ; foreach ( $ rights as $ right ) { $ hasRights = $ hasRights || \ mpf \ WebApp :: get ( ) -> user ( ) -> hasRight ( $ right ) ; } return $ hasRights ; } | Check access for specified controller and action . |
32,296 | protected function getRightsFromMap ( $ controller , $ action , $ module ) { list ( $ rController , $ allController ) = $ this -> getRawAndModuleControllers ( $ controller , $ module ) ; if ( isset ( $ this -> finalMap [ $ rController ] [ $ action ] ) ) { return $ this -> finalMap [ $ rController ] [ $ action ] ; } elseif ( isset ( $ this -> finalMap [ $ allController ] [ $ action ] ) ) { return $ this -> finalMap [ $ allController ] [ $ action ] ; } elseif ( isset ( $ this -> finalMap [ $ rController ] [ '*' ] ) ) { return $ this -> finalMap [ $ rController ] [ '*' ] ; } elseif ( isset ( $ this -> finalMap [ $ allController ] [ '*' ] ) ) { return $ this -> finalMap [ $ allController ] [ '*' ] ; } elseif ( isset ( $ this -> finalMap [ '*' ] [ $ action ] ) ) { return $ this -> finalMap [ '*' ] [ $ action ] ; } elseif ( isset ( $ this -> finalMap [ '*' ] [ '*' ] ) ) { return $ this -> finalMap [ '*' ] [ '*' ] ; } else { return array ( '*' ) ; } } | Get rights associated for selected controller and action . |
32,297 | private function getRawAndModuleControllers ( $ controller , $ module ) { if ( '/' == $ module || '' == $ module ) { $ rController = $ controller ; $ allController = '*' ; } elseif ( null === $ module ) { $ rController = \ mpf \ WebApp :: get ( ) -> request ( ) -> getModule ( ) . '/' . $ controller ; $ allController = \ mpf \ WebApp :: get ( ) -> request ( ) -> getModule ( ) . '/*' ; } else { $ rController = $ module . '/' . $ controller ; $ allController = $ module . '/*' ; } return array ( $ rController , $ allController ) ; } | Get variants to search in config for controller |
32,298 | public static function getType ( $ path ) { if ( ! is_file ( $ path ) ) { throw new \ InvalidArgumentException ( sprintf ( 'invalid filename or path "%s"' , $ path ) ) ; } $ info = ( new \ finfo ( FILEINFO_MIME ) ) -> file ( $ path ) ; return substr ( $ info , 0 , strpos ( $ info , ';' ) ) ; } | get file mime type |
32,299 | public function isType ( $ path , $ mimeType ) { $ mimeTypes = explode ( '|' , $ mimeType ) ; return ( in_array ( self :: getType ( $ path ) , $ mimeTypes ) ) ; } | is mime type |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.