idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
9,600 | public function addJSAction ( $ action ) { if ( is_array ( $ action ) ) { $ this -> jsActions = array_merge ( $ action , $ this -> jsActions ) ; } else { $ this -> jsActions [ ] = $ action ; } } | Add a js action to be return to server on callback . |
9,601 | public function onDelete ( $ fx = null ) { if ( is_callable ( $ fx ) ) { $ this -> hasDeleteCb = true ; if ( $ this -> cb -> triggered ( ) && @ $ _POST [ 'action' ] === 'delete' ) { $ fileName = @ $ _POST [ 'f_name' ] ; $ this -> cb -> set ( function ( ) use ( $ fx , $ fileName ) { $ this -> addJsAction ( call_user_fun... | onDelete callback . Call when user is removing an already upload file . |
9,602 | public function onUpload ( $ fx = null ) { if ( is_callable ( $ fx ) ) { $ this -> hasUploadCb = true ; if ( $ this -> cb -> triggered ( ) ) { $ action = @ $ _POST [ 'action' ] ; if ( $ files = @ $ _FILES ) { $ this -> fileId = $ files [ 'file' ] [ 'name' ] ; $ this -> setInput ( $ this -> fileId ) ; } if ( $ action ==... | onUpload callback . Call when user is uploading a file . |
9,603 | public function renderView ( ) { if ( $ this -> disabled ) { $ this -> addClass ( 'disabled' ) ; } parent :: renderView ( ) ; if ( ! $ this -> hasUploadCb || ! $ this -> hasDeleteCb ) { throw new Exception ( 'onUpload and onDelete callback must be called to use file upload' ) ; } if ( ! empty ( $ this -> accept ) ) { $... | Rendering view . |
9,604 | public function addFilter ( $ field , $ label = null ) { if ( ! $ this -> model -> hasElement ( $ field ) instanceof \ atk4 \ data \ Field ) { throw new \ atk4 \ ui \ Exception ( [ 'Unable to filter by non-existant field' , 'field' => $ field , ] ) ; } $ this -> filters [ ] = [ 'field' => $ field , 'label' => $ label ]... | Add filter dropdown . |
9,605 | public function applyFilters ( ) { if ( $ this -> filters ) { foreach ( $ this -> filters as $ k => $ filter ) { if ( isset ( $ _GET [ $ filter [ 'field' ] ] ) && ! empty ( $ _GET [ $ filter [ 'field' ] ] ) && $ _GET [ $ filter [ 'field' ] ] != $ this -> filterEmpty && @ $ _GET [ 'filter' ] != $ filter [ 'field' ] ) { ... | Check if filtering is need . |
9,606 | public function renderFilters ( ) { if ( isset ( $ _GET [ 'filter' ] ) ) { if ( isset ( $ _GET [ 'q' ] ) ) { $ this -> model -> addCondition ( $ _GET [ 'filter' ] , 'like' , '%' . $ _GET [ 'q' ] . '%' ) ; } $ this -> applyFilters ( ) ; $ action = $ this -> model -> action ( 'field' , [ $ _GET [ 'filter' ] ] ) ; $ actio... | Check if filtering is needed and terminate app execution . |
9,607 | public function createFilterJsDropdown ( ) { foreach ( $ this -> filters as $ k => $ filter ) { $ f_name = $ this -> name . '-ac_f' . $ k ; $ chain = new jQuery ( '#' . $ f_name ) ; $ options = [ 'fields' => [ 'name' => 'name' , 'value' => 'id' ] , 'match' => 'value' , 'apiSettings' => [ 'url' => $ this -> getCallbackU... | For each filters we need to create js dropdown and setup proper api settings . |
9,608 | public function getFilterQuery ( ) { $ q = [ ] ; foreach ( $ this -> filters as $ key => $ filter ) { $ q [ $ filter [ 'field' ] ] = new jsExpression ( '$([input]).parent().dropdown("get text")' , [ 'input' => 'input[name=' . $ filter [ 'field' ] . ']' ] ) ; } return $ q ; } | Will create jsExpression need to add to the dropdown apiSettings data when using filters . |
9,609 | public function addGroup ( $ label = null ) { if ( ! is_array ( $ label ) ) { $ label = [ 'label' => $ label ] ; } elseif ( isset ( $ label [ 0 ] ) ) { $ label [ 'label' ] = $ label [ 0 ] ; unset ( $ label [ 0 ] ) ; } $ label [ 'form' ] = $ this -> form ; return $ this -> add ( new static ( $ label ) ) ; } | Adds field group in form layout . |
9,610 | public function addSubLayout ( $ seed = 'Generic' , $ addDivider = true ) { $ v = $ this -> add ( $ this -> factory ( $ seed , [ 'form' => $ this -> form ] , 'FormLayout/Section' ) ) ; if ( $ v instanceof \ atk4 \ ui \ FormLayout \ Section \ Generic ) { $ v = $ v -> addSection ( ) ; } if ( $ addDivider ) { $ this -> ad... | Add a form layout section to this layout . |
9,611 | public function set ( $ value = null , $ junk = null ) { if ( $ this -> field ) { $ this -> field -> set ( $ value ) ; return $ this ; } $ this -> content = $ value ; return $ this ; } | Sets the value of this field . If field is a part of the form and is associated with the model then the model s value will also be affected . |
9,612 | public function renderView ( ) { if ( $ this -> form ) { $ this -> template -> trySet ( 'name' , $ this -> short_name ) ; } parent :: renderView ( ) ; } | It only makes sense to have name property inside a field if it was used inside a form . |
9,613 | public function getURL ( $ mode = 'callback' ) { return $ this -> owner -> url ( [ $ this -> urlTrigger => $ mode , '__atk_callback' => 1 ] , ( bool ) $ this -> postTrigger ) ; } | Return URL that will trigger action on this call - back . If you intend to request the URL loading from inside JavaScript it s always advised to use getJSURL instead . |
9,614 | public function addStep ( $ name , $ callback ) { $ step = $ this -> factory ( [ 'Step' , 'wizard' => $ this , 'template' => clone $ this -> stepTemplate , 'sequence' => count ( $ this -> steps ) , ] , $ name ) ; $ this -> steps [ ] = $ this -> add ( $ step , 'Step' ) ; if ( ! $ this -> stepCallback -> triggered ( ) ) ... | Adds step to the wizard . |
9,615 | public function addFinish ( $ callback ) { if ( count ( $ this -> steps ) == $ this -> currentStep + 1 ) { $ this -> buttonFinish -> link ( $ this -> stepCallback -> getURL ( count ( $ this -> steps ) ) ) ; } elseif ( $ this -> currentStep == count ( $ this -> steps ) ) { $ this -> buttonPrev -> destroy ( ) ; $ this ->... | Adds an extra screen to show user when he goes beyond last step . There won t be back button on this step anymore . |
9,616 | public function jsRender ( ) { $ namelessCount = 0 ; $ res = preg_replace_callback ( '/\[[a-z0-9_]*\]|{[a-z0-9_]*}/' , function ( $ matches ) use ( & $ namelessCount ) { $ identifier = substr ( $ matches [ 0 ] , 1 , - 1 ) ; if ( $ identifier === '' ) { $ identifier = $ namelessCount ++ ; } if ( ! isset ( $ this -> args... | Converts this arbitrary JavaScript expression into string . |
9,617 | public function addPopup ( $ popup = null , $ icon = 'caret square down' ) { if ( ! $ this -> app ) { throw new Exception ( 'Columns\'s popup need to have a layout.' ) ; } $ popup = $ this -> app -> add ( $ popup ? $ popup : 'Popup' ) -> setHoverable ( ) ; $ this -> setHeaderPopup ( $ popup , $ icon ) ; return $ popup ... | Add popup to header . |
9,618 | public function setHeaderPopup ( $ popup , $ icon = 'caret square down' ) { $ this -> hasHeaderAction = true ; $ id = $ this -> name . '_ac' ; $ this -> headerActionTag = [ 'div' , [ 'class' => 'atk-table-dropdown' ] , [ [ 'i' , [ 'id' => $ id , 'class' => $ icon . ' icon' ] ] , ] , ] ; $ popup -> triggerBy = '#' . $ i... | Setup popup header action . |
9,619 | public function addDropdown ( $ items , $ fx , $ icon = 'caret square down' , $ menuId = null ) { $ menuITems = [ ] ; foreach ( $ items as $ key => $ item ) { if ( is_int ( $ key ) ) { $ menuITems [ ] = [ 'name' => $ item , 'value' => $ item ] ; } else { $ menuITems [ ] = [ 'name' => $ key , 'value' => $ item ] ; } } $... | Add a dropdown header menu . |
9,620 | public function setAttr ( $ attr , $ value , $ position = 'body' ) { $ this -> attr [ $ position ] [ $ attr ] = $ value ; return $ this ; } | Adds a new attribute to the cells of this column . The optional second argument may be head body or foot . If position is not defined then attribute will be applied on all cells . |
9,621 | public function getTag ( $ position , $ value , $ attr = [ ] ) { $ attr = $ this -> getTagAttributes ( $ position , $ attr ) ; if ( isset ( $ attr [ 'class' ] ) ) { $ attr [ 'class' ] = implode ( ' ' , $ attr [ 'class' ] ) ; } return $ this -> app -> getTag ( $ position == 'body' ? 'td' : 'th' , $ attr , $ value ) ; } | Returns a suitable cell tag with the supplied value . Applies modifiers added through addClass and setAttr . |
9,622 | public function getTotalsCellHTML ( \ atk4 \ data \ Field $ f , $ value ) { return $ this -> getTag ( 'foot' , $ this -> app -> ui_persistence -> typecastSaveField ( $ f , $ value ) ) ; } | Return HTML for a total value of a specific field . |
9,623 | public function getValue ( ) { return isset ( $ this -> field ) ? $ this -> app -> ui_persistence -> typecastSaveField ( $ this -> field , $ this -> field -> get ( ) ) : ( isset ( $ this -> content ) ? $ this -> content : '' ) ; } | Returns presentable value to be inserted into input tag . |
9,624 | public function addAction ( $ defaults = [ ] ) { if ( ! is_array ( $ defaults ) ) { $ defaults = [ $ defaults ] ; } $ this -> action = $ this -> add ( new Button ( $ defaults ) , 'AfterInput' ) ; $ this -> addClass ( 'action' ) ; return $ this -> action ; } | Adds new action button . |
9,625 | public function setModel ( \ atk4 \ data \ Model $ model ) { parent :: setModel ( $ model ) ; $ this -> field = $ this -> field ? $ this -> field : $ this -> model -> title_field ; if ( $ this -> autoSave && $ this -> model -> loaded ( ) ) { if ( $ this -> cb -> triggered ( ) ) { $ value = $ _POST [ 'value' ] ? $ _POST... | Set Model of this View . |
9,626 | public function renderView ( ) { parent :: renderView ( ) ; $ type = ( $ this -> model && $ this -> field ) ? $ this -> model -> elements [ $ this -> field ] -> type : 'text' ; $ type = ( $ type === 'string' ) ? 'text' : $ type ; if ( $ type != 'text' && $ type != 'number' ) { throw new Exception ( 'Error: Only string ... | Renders View . |
9,627 | public function setModelCondition ( $ m ) { $ q = $ this -> getQuery ( ) ; if ( $ q && ( $ _GET [ '__atk_reload' ] ? $ _GET [ '__atk_reload' ] : null ) === $ this -> reload -> name ) { $ m -> addCondition ( 'name' , 'like' , '%' . $ q . '%' ) ; } return $ m ; } | Set model condition base on search request . |
9,628 | public function set ( $ fx = [ ] , $ junk = null ) { if ( ! $ fx ) { return $ this ; } if ( $ this -> fx ) { throw new Exception ( [ 'Callback for this Virtual Page is already defined' , 'vp' => $ this , 'old_fx' => $ this -> fx , 'new_fx' => $ fx , ] ) ; } $ this -> fx = $ fx ; return $ this ; } | Set callback function of virtual page . |
9,629 | public function getHTML ( ) { $ this -> cb -> set ( function ( ) { if ( $ type = $ this -> cb -> triggered ( ) ) { if ( $ this -> fx ) { call_user_func ( $ this -> fx , $ this ) ; } if ( $ type == 'popup' ) { $ this -> app -> html -> template -> set ( 'title' , $ this -> app -> title ) ; $ this -> app -> html -> templa... | VirtualPage is not rendered normally . It s invisible . Only when it is triggered it will exclusively output it s content . |
9,630 | public function setIpp ( $ ipp , $ label = 'Item per pages:' ) { if ( is_array ( $ ipp ) ) { $ this -> addItemsPerPageSelector ( $ ipp , $ label ) ; if ( @ $ _GET [ 'ipp' ] ) { $ this -> ipp = $ _GET [ 'ipp' ] ; } else { $ this -> ipp = $ ipp [ 0 ] ; } } else { $ this -> ipp = $ ipp ; } } | Set item per page value . |
9,631 | public function addItemsPerPageSelector ( $ items = [ 10 , 25 , 50 , 100 ] , $ label = 'Item per pages:' ) { if ( $ ipp = $ this -> container -> stickyGet ( 'ipp' ) ) { $ this -> ipp = $ ipp ; } else { $ this -> ipp = $ items [ 0 ] ; } $ pageLength = $ this -> paginator -> add ( [ 'ItemsPerPageSelector' , 'pageLengthIt... | Add ItemsPerPageSelector View in grid menu or paginator in order to dynamically setup number of item per page . |
9,632 | public function addJsPaginator ( $ ipp , $ options = [ ] , $ container = null , $ scrollRegion = 'Body' ) { if ( $ this -> paginator ) { $ this -> paginator -> destroy ( ) ; $ this -> paginator = null ; } if ( $ sortBy = $ this -> getSortBy ( ) ) { $ this -> stickyGet ( $ this -> name . '_sort' , $ sortBy ) ; } $ this ... | Add dynamic scrolling paginator . |
9,633 | public function addJsPaginatorInContainer ( $ ipp , $ containerHeight , $ options = [ ] , $ container = null , $ scrollRegion = 'Body' ) { $ this -> table -> hasCollapsingCssActionColumn = false ; $ options = array_merge ( $ options , [ 'hasFixTableHeader' => true , 'tableContainerHeight' => $ containerHeight , ] ) ; $... | Add dynamic scrolling paginator in container . Use this to make table headers fixed . |
9,634 | public function addAction ( $ button , $ action , $ confirm = false ) { if ( ! $ this -> actions ) { $ this -> actions = $ this -> table -> addColumn ( null , $ this -> actionDecorator ) ; } return $ this -> actions -> addAction ( $ button , $ action , $ confirm ) ; } | Adds a new button into the action column on the right . For CRUD this column will already contain delete and edit buttons . |
9,635 | public function addFilterColumn ( $ names = null ) { $ this -> menu -> addItem ( [ 'Clear Filters' ] , new \ atk4 \ ui \ jsReload ( $ this -> table -> reload , [ 'atk_clear_filter' => 1 ] ) ) ; $ this -> table -> setFilterColumn ( $ names ) ; return $ this ; } | An array of column name where filter is needed . Leave empty to include all column in grid . |
9,636 | public function addDropdown ( $ columnName , $ items , $ fx , $ icon = 'caret square down' , $ menuId = null ) { $ column = $ this -> table -> columns [ $ columnName ] ; if ( ! isset ( $ column ) ) { throw new Exception ( 'The column where you want to add dropdown does not exist: ' . $ columnName ) ; } if ( ! $ menuId ... | Add a dropdown menu to header column . |
9,637 | public function addPopup ( $ columnName , $ popup = null , $ icon = 'caret square down' ) { $ column = $ this -> table -> columns [ $ columnName ] ; if ( ! isset ( $ column ) ) { throw new Exception ( 'The column where you want to add popup does not exist: ' . $ columnName ) ; } return $ column -> addPopup ( $ popup , ... | Add a popup to header column . |
9,638 | public function setModel ( \ atk4 \ data \ Model $ model , $ columns = null ) { $ this -> model = $ this -> table -> setModel ( $ model , $ columns ) ; if ( $ this -> quickSearch && is_array ( $ this -> quickSearch ) ) { $ this -> addQuickSearch ( $ this -> quickSearch ) ; } return $ this -> model ; } | Sets data Model of Grid . |
9,639 | public function addSelection ( ) { $ this -> selection = $ this -> table -> addColumn ( null , 'CheckBox' ) ; $ k = array_search ( $ this -> selection , $ this -> table -> columns ) ; $ this -> table -> columns = [ $ k => $ this -> table -> columns [ $ k ] ] + $ this -> table -> columns ; return $ this -> selection ; } | Makes rows of this grid selectable by creating new column on the left with checkboxes . |
9,640 | public function addDragHandler ( ) { $ handler = $ this -> table -> addColumn ( null , 'DragHandler' ) ; array_unshift ( $ this -> table -> columns , array_pop ( $ this -> table -> columns ) ) ; return $ handler ; } | Add column with drag handler on each row . Drag handler allow to reorder table via drag n drop . |
9,641 | private function setModelLimitFromPaginator ( ) { $ this -> paginator -> setTotal ( ceil ( $ this -> model -> action ( 'count' ) -> getOne ( ) / $ this -> ipp ) ) ; $ this -> model -> setLimit ( $ this -> ipp , ( $ this -> paginator -> page - 1 ) * $ this -> ipp ) ; } | Will set model limit according to paginator value . |
9,642 | public function recursiveRender ( ) { if ( $ this -> paginator ) { $ this -> setModelLimitFromPaginator ( ) ; } if ( $ this -> quickSearch instanceof jsSearch ) { if ( $ sortBy = $ this -> getSortBy ( ) ) { $ this -> container -> js ( true , $ this -> quickSearch -> js ( ) -> atkJsSearch ( 'setUrlArgs' , [ $ this -> na... | Recursively renders view . |
9,643 | public function onPageLengthSelect ( $ fx = null ) { if ( is_callable ( $ fx ) ) { if ( $ this -> cb -> triggered ( ) ) { $ this -> cb -> set ( function ( ) use ( $ fx ) { $ ipp = @ $ _GET [ 'ipp' ] ; $ this -> set ( $ ipp ) ; $ reload = call_user_func ( $ fx , $ ipp ) ; if ( $ reload ) { $ this -> app -> terminate ( $... | Run callback when an item is select via dropdown menu . The callback should return a View to be reload after an item has been select . |
9,644 | protected function isJsonRequest ( ) { $ ajax = false ; if ( ! empty ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) { $ ajax = true ; } return $ ajax && ! isset ( $ _GET [ '__atk_tab' ] ) ; } | Most of the ajax request will require sending exception in json instead of html except for tab . |
9,645 | public function terminate ( $ output = null ) { if ( $ output !== null ) { echo $ output ; } $ this -> run_called = true ; $ this -> callExit ( ) ; } | Will perform a preemptive output and terminate . Do not use this directly instead call it form Callback jsCallback or similar other classes . |
9,646 | public function initLayout ( $ seed ) { $ layout = $ this -> factory ( $ seed , null , 'Layout' ) ; $ layout -> app = $ this ; if ( ! $ this -> html ) { $ this -> html = new View ( [ 'defaultTemplate' => 'html.html' ] ) ; $ this -> html -> app = $ this ; $ this -> html -> init ( ) ; } $ this -> layout = $ this -> html ... | Initializes layout . |
9,647 | public function initIncludes ( ) { $ url = isset ( $ this -> cdn [ 'jquery' ] ) ? $ this -> cdn [ 'jquery' ] : '../public' ; $ this -> requireJS ( $ url . '/jquery.min.js' ) ; $ url = isset ( $ this -> cdn [ 'semantic-ui' ] ) ? $ this -> cdn [ 'semantic-ui' ] : '../public' ; $ this -> requireJS ( $ url . '/semantic.min... | Initialize JS and CSS includes . |
9,648 | public function add ( $ seed , $ region = null ) { if ( ! $ this -> layout ) { throw new Exception ( [ 'If you use $app->add() you should first call $app->setLayout()' ] ) ; } return $ this -> layout -> add ( $ seed , $ region ) ; } | Add a new object into the app . You will need to have Layout first . |
9,649 | public function run ( ) { $ this -> run_called = true ; $ this -> hook ( 'beforeRender' ) ; $ this -> is_rendering = true ; if ( ! isset ( $ this -> html ) ) { throw new Exception ( [ 'App layout should be set.' ] ) ; } $ this -> html -> template -> set ( 'title' , $ this -> title ) ; $ this -> html -> renderAll ( ) ; ... | Runs app and echo rendered template . |
9,650 | public function loadTemplate ( $ name ) { $ template = new Template ( ) ; $ template -> app = $ this ; if ( in_array ( $ name [ 0 ] , [ '.' , '/' , '\\' ] ) || strpos ( $ name , ':\\' ) !== false ) { return $ template -> load ( $ name ) ; } else { $ dir = is_array ( $ this -> template_dir ) ? $ this -> template_dir : [... | Load template by template file name . |
9,651 | public function jsURL ( $ page = [ ] , $ needRequestUri = false , $ extra_args = [ ] ) { return $ this -> url ( $ page , $ needRequestUri , $ extra_args ) ; } | Build a URL that application can use for js call - backs . Some framework integration will use a different routing mechanism for NON - HTML response . |
9,652 | public function url ( $ page = [ ] , $ needRequestUri = false , $ extra_args = [ ] ) { if ( $ needRequestUri ) { return $ _SERVER [ 'REQUEST_URI' ] ; } $ sticky = $ this -> sticky_get_arguments ; $ result = $ extra_args ; if ( $ this -> page === null ) { $ uri = $ this -> getRequestURI ( ) ; if ( substr ( $ uri , - 1 ,... | Build a URL that application can use for loading HTML data . |
9,653 | public function stickyGet ( $ name ) { if ( isset ( $ _GET [ $ name ] ) ) { $ this -> sticky_get_arguments [ $ name ] = $ _GET [ $ name ] ; return $ _GET [ $ name ] ; } } | Make current get argument with specified name automatically appended to all generated URLs . |
9,654 | public function requireJS ( $ url , $ isAsync = false , $ isDefer = false ) { $ this -> html -> template -> appendHTML ( 'HEAD' , $ this -> getTag ( 'script' , [ 'src' => $ url , 'defer' => $ isDefer , 'async' => $ isAsync ] , '' ) . "\n" ) ; return $ this ; } | Adds additional JS script include in aplication template . |
9,655 | public function requireCSS ( $ url ) { $ this -> html -> template -> appendHTML ( 'HEAD' , $ this -> getTag ( 'link/' , [ 'rel' => 'stylesheet' , 'type' => 'text/css' , 'href' => $ url ] ) . "\n" ) ; return $ this ; } | Adds additional CSS stylesheet include in aplication template . |
9,656 | public function redirect ( $ page ) { header ( 'Location: ' . $ this -> url ( $ page ) ) ; $ this -> run_called = true ; $ this -> callExit ( ) ; } | A convenient wrapper for sending user to another page . |
9,657 | public function useSuiVue ( ) { if ( ! $ this -> is_sui_init ) { $ this -> requireJS ( 'https://unpkg.com/semantic-ui-vue/dist/umd/semantic-ui-vue.min.js' ) ; $ this -> layout -> js ( true , ( new jsVueService ( ) ) -> useComponent ( 'SemanticUIVue' ) ) ; $ this -> is_sui_init = true ; } } | Allow to use semantic - ui - vue components . |
9,658 | public function set ( $ callback , $ args = [ ] ) { if ( ! $ this -> app ) { throw new Exception ( [ 'Call-back must be part of a RenderTree' ] ) ; } if ( $ this -> app -> is_rendering ) { return parent :: set ( $ callback , $ args ) ; } $ this -> app -> addHook ( 'beforeRender' , function ( ... $ args ) use ( $ callba... | Executes user - specified action before rendering or if App is already in rendering state then before output . |
9,659 | public function setPath ( $ path ) { if ( ! is_string ( $ path ) ) { $ path = $ this -> app -> url ( $ path ) ; } $ this -> path = $ path . '#' ; return $ this ; } | Sets path for tab . |
9,660 | public function renderView ( ) { if ( $ this -> path ) { $ this -> js ( true ) -> tab ( [ 'cache' => false , 'auto' => true , 'path' => $ this -> path , 'apiSettings' => [ 'data' => [ '__atk_tab' => 1 ] ] ] ) ; } else { $ this -> js ( true ) -> tab ( ) ; } if ( $ this -> owner -> activeTabName == $ this -> name ) { $ t... | Rendering one tab view . |
9,661 | public function setSource ( array $ data , $ fields = null ) { $ this -> setModel ( new \ atk4 \ data \ Model ( new \ atk4 \ data \ Persistence_Static ( $ data ) ) , $ fields ) ; } | Sets source of the View . |
9,662 | public function init ( ) { if ( ! $ this -> name ) { if ( ! $ this -> id ) { $ this -> id = $ this -> name = 'atk' ; } else { $ this -> name = $ this -> id ; } } elseif ( ! $ this -> id ) { $ this -> id = $ this -> name ; } $ this -> _init ( ) ; if ( ! $ this -> app ) { $ this -> initDefaultApp ( ) ; } if ( $ this -> r... | Called when view becomes part of render tree . You can override it but avoid placing any heavy processing here . |
9,663 | protected function initDefaultApp ( ) { $ this -> app = new App ( [ 'skin' => $ this -> skin , 'catch_exceptions' => false , 'always_run' => false , 'catch_runaway_callbacks' => false , ] ) ; $ this -> app -> init ( ) ; } | For the absence of the application we would add a very simple one . |
9,664 | public function add ( $ seed , $ region = null ) { if ( $ this -> _rendered ) { throw new Exception ( 'You cannot add anything into the view after it was rendered' ) ; } if ( ! $ this -> app ) { $ this -> _add_later [ ] = [ $ seed , $ region ] ; return $ seed ; } if ( is_array ( $ region ) ) { $ args = $ region ; if ( ... | In addition to adding a child object sets up it s template and associate it s output with the region in our template . |
9,665 | public function getClosestOwner ( $ object , $ class ) { if ( ! isset ( $ object -> owner ) ) { return ; } if ( $ object -> owner instanceof $ class ) { return $ object -> owner ; } return $ this -> getClosestOwner ( $ object -> owner , $ class ) ; } | Get objects closest owner which is instance of particular class . |
9,666 | public function set ( $ arg1 = null , $ arg2 = null ) { if ( is_string ( $ arg1 ) && $ arg2 !== null ) { $ this -> template -> set ( $ arg1 , $ arg2 ) ; return $ this ; } if ( $ arg2 !== null ) { throw new Exception ( [ 'Second argument to set() can be only passed if the first one is a string' , 'arg1' => $ arg1 , 'arg... | Override this method without compatibility with parent if you wish to set your own things your own way for your view . |
9,667 | public function removeAttr ( $ property ) { if ( is_array ( $ property ) ) { foreach ( $ property as $ v ) { unset ( $ this -> attr [ $ v ] ) ; } return $ this ; } unset ( $ this -> attr [ $ property ] ) ; return $ this ; } | Remove attribute . |
9,668 | public function recursiveRender ( ) { foreach ( $ this -> elements as $ view ) { if ( ! $ view instanceof self ) { continue ; } $ this -> template -> appendHTML ( $ view -> region , $ view -> getHTML ( ) ) ; if ( $ view -> _js_actions ) { $ this -> _js_actions = array_merge_recursive ( $ this -> _js_actions , $ view ->... | Recursively render all children placing their output in our template . |
9,669 | public function renderAll ( ) { if ( ! $ this -> _initialized ) { $ this -> init ( ) ; } if ( ! $ this -> _rendered ) { $ this -> renderView ( ) ; $ this -> recursiveRender ( ) ; $ this -> _rendered = true ; } } | Render everything recursively render ourselves but don t return anything just yet . |
9,670 | public function render ( $ force_echo = true ) { $ this -> renderAll ( ) ; return $ this -> getJS ( $ force_echo ) . $ this -> template -> render ( ) ; } | This method is for those cases when developer want to simply render his view and grab HTML himself . |
9,671 | public function renderJSON ( $ force_echo = true , $ region = null ) { try { $ this -> renderAll ( ) ; return json_encode ( [ 'success' => true , 'message' => 'Success' , 'atkjs' => $ this -> getJS ( $ force_echo ) , 'html' => $ this -> template -> render ( $ region ) , 'id' => $ this -> name , ] ) ; } catch ( \ Except... | Render View using json format . |
9,672 | public function vue ( $ component , $ initData = [ ] , $ componentDefinition = null , $ selector = null ) { if ( ! $ selector ) { $ selector = '#' . $ this -> name ; } if ( $ componentDefinition ) { $ chain = ( new jsVueService ( ) ) -> createVue ( $ selector , $ component , $ componentDefinition , $ initData ) ; } els... | Create Vue . js instance . Vue . js instance can be create from atk4 \ ui \ View . |
9,673 | public function jsVueEmit ( $ eventName , $ eventData = [ ] ) { if ( ! $ eventData [ 'id' ] ) { $ eventData [ 'id' ] = $ this -> name ; } return ( new jsVueService ( ) ) -> emitEvent ( $ eventName , $ eventData ) ; } | Emit an event on the Vue event bus . vueService has a dedicated Vue instance for registering event that allow communication between external view like button or even separate vue component in order to communicate to each other . |
9,674 | public function getJS ( $ force_echo = false ) { $ actions = [ ] ; foreach ( $ this -> _js_actions as $ eventActions ) { foreach ( $ eventActions as $ action ) { $ actions [ ] = $ action ; } } if ( ! $ actions ) { return '' ; } $ actions [ 'indent' ] = '' ; if ( ! $ force_echo && $ this -> app && $ this -> app -> hasMe... | Get JavaScript objects from this render tree . |
9,675 | protected function initLayout ( ) { if ( $ this -> layout === null ) { $ this -> layout = 'Generic' ; } if ( is_string ( $ this -> layout ) || is_array ( $ this -> layout ) ) { $ this -> layout = $ this -> factory ( $ this -> layout , [ 'form' => $ this ] , 'FormLayout' ) ; $ this -> layout = $ this -> add ( $ this -> ... | initialize form layout . You can inject custom layout if you layout = > .. to constructor . |
9,676 | public function setGroupDisplayRules ( $ rules = [ ] , $ selector = '.atk-form-group' ) { if ( is_object ( $ selector ) && isset ( $ selector -> name ) ) { $ selector = '#' . $ selector -> name ; } $ this -> fieldsDisplayRules = $ rules ; $ this -> fieldDisplaySelector = $ selector ; return $ this ; } | Set display rule for a group collection . |
9,677 | public function setModel ( \ atk4 \ data \ Model $ model , $ fields = null ) { try { $ model = parent :: setModel ( $ model ) ; $ this -> layout -> setModel ( $ model , $ fields ) ; return $ model ; } catch ( Exception $ e ) { throw $ e -> addMoreInfo ( 'model' , $ model ) ; } } | Associates form with the model but also specifies which of Model fields should be added automatically . |
9,678 | public function error ( $ fieldName , $ str ) { if ( $ this -> hookHasCallbacks ( 'displayError' ) ) { return $ this -> hook ( 'displayError' , [ $ fieldName , $ str ] ) ; } $ jsError = [ $ this -> js ( ) -> form ( 'add prompt' , $ fieldName , $ str ) ] ; return $ jsError ; } | Causes form to generate error . |
9,679 | public function success ( $ str = 'Success' , $ sub_header = null ) { if ( $ this -> hookHasCallbacks ( 'displaySuccess' ) ) { return $ this -> hook ( 'displaySuccess' , [ $ str , $ sub_header ] ) ; } $ success = $ this -> app -> loadTemplate ( $ this -> successTemplate ) ; $ success [ 'header' ] = $ str ; if ( $ sub_h... | Causes form to generate success message . |
9,680 | public function addField ( $ name , $ decorator = null , $ field = null ) { if ( ! $ this -> model ) { $ this -> model = new \ atk4 \ ui \ misc \ ProxyModel ( ) ; } return $ this -> layout -> addField ( $ name , $ decorator , $ field ) ; } | Add field into current layout . If no layout create one . If no model create blank one . |
9,681 | public function addFields ( $ fields ) { foreach ( $ fields as $ field ) { if ( is_array ( $ field ) ) { $ this -> addField ( ... $ field ) ; } else { $ this -> addField ( $ field ) ; } } return $ this ; } | Add more than one field in one shot . |
9,682 | public function loadPOST ( ) { $ post = $ _POST ; $ this -> hook ( 'loadPOST' , [ & $ post ] ) ; $ errors = [ ] ; foreach ( $ this -> fields as $ key => $ field ) { try { $ value = isset ( $ post [ $ key ] ) ? $ post [ $ key ] : null ; if ( ! $ field -> readonly && ! $ field -> disabled ) { $ this -> model [ $ key ] = ... | Looks inside the POST of the request and loads it into a current model . |
9,683 | public function ajaxSubmit ( ) { $ this -> _add ( $ cb = new jsCallback ( ) , [ 'desired_name' => 'submit' , 'postTrigger' => true ] ) ; $ this -> add ( new View ( [ 'element' => 'input' ] ) ) -> setAttr ( 'name' , $ cb -> postTrigger ) -> setAttr ( 'value' , 'submit' ) -> setStyle ( [ 'display' => 'none' ] ) ; $ cb ->... | Does ajax submit . |
9,684 | public function addParagraph ( $ text ) { $ this -> content .= isset ( $ this -> app ) ? $ this -> app -> getTag ( 'p' , $ text ) : '<p>' . htmlspecialchars ( $ text ) . '</p>' ; return $ this ; } | Adds HTML paragraph . |
9,685 | public function getDataCellTemplate ( \ atk4 \ data \ Field $ f = null ) { $ caption = $ f ? $ f -> getCaption ( ) : $ this -> short_name ; return '<img src="' . parent :: getDataCellTemplate ( $ f ) . '" alt="' . $ caption . '" border="0" />' ; } | Extend parent method . |
9,686 | public function setOption ( $ options , $ value = null ) { if ( is_array ( $ options ) ) { foreach ( $ options as $ key => $ value ) { $ this -> args [ 'arg' ] [ $ key ] = $ value ; } } else { $ this -> args [ 'arg' ] [ $ options ] = $ value ; } return $ this ; } | Set additionnal option for this jsModal . |
9,687 | public function linkCart ( Cart $ cart , $ jsAction = null ) { $ this -> on ( 'click' , '.item' , function ( $ a , $ b ) use ( $ cart , $ jsAction ) { $ cart -> addItem ( $ b ) ; return $ jsAction ; } , [ ( new \ atk4 \ ui \ jQuery ( ) ) -> text ( ) ] ) ; } | Associate your shelf with cart so that when item is clicked the content of a cart is updated . |
9,688 | public function init ( ) { if ( $ this -> runEvent ) { $ chain = new jsChain ( ) ; $ this -> app -> html -> js ( true , $ chain -> atkServerEvent ( [ 'uri' => $ this -> getUrl ( ) ] ) ) ; $ this -> isRunning = true ; } $ this -> _initialized = true ; } | Allow chunked encoding |
9,689 | public function actionRequestPasswordReset ( ) { $ model = new PasswordResetRequest ( ) ; if ( $ model -> load ( Yii :: $ app -> getRequest ( ) -> post ( ) ) && $ model -> validate ( ) ) { if ( $ model -> sendEmail ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , 'Check your email for further instructio... | Request reset password |
9,690 | public function getRoutePrefix ( ) { if ( ! $ this -> _routePrefix ) { $ this -> _routePrefix = Configs :: instance ( ) -> advanced ? self :: PREFIX_ADVANCED : self :: PREFIX_BASIC ; } return $ this -> _routePrefix ; } | Returns route prefix depending on the configuration . |
9,691 | public function getPermissionName ( $ route ) { if ( self :: PREFIX_BASIC == $ this -> routePrefix ) { return self :: PREFIX_BASIC . trim ( $ route , self :: PREFIX_BASIC ) ; } else { return self :: PREFIX_ADVANCED . ltrim ( trim ( $ route , self :: PREFIX_BASIC ) , self :: PREFIX_ADVANCED ) ; } } | Returns the correct permission name depending on the configuration . |
9,692 | protected function getControllerActions ( $ type , $ id , $ module , & $ result ) { $ token = "Create controller with cofig=" . VarDumper :: dumpAsString ( $ type ) . " and id='$id'" ; Yii :: beginProfile ( $ token , __METHOD__ ) ; try { $ controller = Yii :: createObject ( $ type , [ $ id , $ module ] ) ; $ this -> ge... | Get list action of controller |
9,693 | protected function getActionRoutes ( $ controller , & $ result ) { $ token = "Get actions of controller '" . $ controller -> uniqueId . "'" ; Yii :: beginProfile ( $ token , __METHOD__ ) ; try { $ prefix = '/' . $ controller -> uniqueId . '/' ; foreach ( $ controller -> actions ( ) as $ id => $ value ) { $ result [ $ p... | Get route of action |
9,694 | public function getMenus ( ) { if ( $ this -> _normalizeMenus === null ) { $ mid = '/' . $ this -> getUniqueId ( ) . '/' ; $ this -> _normalizeMenus = [ ] ; $ config = components \ Configs :: instance ( ) ; $ conditions = [ 'user' => $ config -> db && $ config -> db -> schema -> getTableSchema ( $ config -> userTable )... | Get available menu . |
9,695 | public function setMenus ( $ menus ) { $ this -> _menus = array_merge ( $ this -> _menus , $ menus ) ; $ this -> _normalizeMenus = null ; } | Set or add available menu . |
9,696 | public function assign ( $ items ) { $ manager = Configs :: authManager ( ) ; $ success = 0 ; foreach ( $ items as $ name ) { try { $ item = $ manager -> getRole ( $ name ) ; $ item = $ item ? : $ manager -> getPermission ( $ name ) ; $ manager -> assign ( $ item , $ this -> id ) ; $ success ++ ; } catch ( \ Exception ... | Grands a roles from a user . |
9,697 | private static function requiredParent ( $ assigned , & $ menus ) { $ l = count ( $ assigned ) ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { $ id = $ assigned [ $ i ] ; $ parent_id = $ menus [ $ id ] [ 'parent' ] ; if ( $ parent_id !== null && ! in_array ( $ parent_id , $ assigned ) ) { $ assigned [ $ l ++ ] = $ parent_id ;... | Ensure all item menu has parent . |
9,698 | public static function filter ( $ items , $ user = null ) { if ( $ user === null ) { $ user = Yii :: $ app -> getUser ( ) ; } return static :: filterRecursive ( $ items , $ user ) ; } | Filter menu items |
9,699 | public static function getTypeName ( $ type = null ) { $ result = [ Item :: TYPE_PERMISSION => 'Permission' , Item :: TYPE_ROLE => 'Role' , ] ; if ( $ type === null ) { return $ result ; } return $ result [ $ type ] ; } | Get type name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.