idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
19,400 | public function display ( $ content , $ options = [ ] ) { if ( ! empty ( $ options [ 'form' ] ) ) { $ view = ! empty ( $ options [ 'view' ] ) ? $ options [ 'view' ] : '' ; return FormWrap :: view ( $ this -> _block , $ options , $ this -> displayView ( $ view , '-form' ) ) ; } $ options = $ options + [ 'random' => fals... | Display repeater view |
19,401 | protected function _renderRepeatedDisplayView ( $ options , $ repeaterRows = [ ] ) { $ repeaterBlocks = BlockRepeater :: getRepeaterBlocks ( $ this -> _block -> id ) ; if ( ( $ repeaterRows && $ repeaterBlocks ) || ( isset ( $ repeaterRows [ 0 ] ) && $ repeaterRows [ 0 ] === 0 ) ) { if ( ! empty ( $ options [ 'per_page... | Check per page values and load block info to pass to repeated view |
19,402 | public function submission ( $ formData ) { $ formRules = BlockFormRule :: get_rules ( $ this -> _block -> name . '-form' ) ; $ v = Validator :: make ( $ formData , $ formRules ) ; if ( $ v -> passes ( ) ) { foreach ( $ formData as $ blockName => $ content ) { $ fieldBlock = Block :: preload ( $ blockName ) ; if ( $ fi... | Repeater form submission |
19,403 | public function edit ( $ content , $ newRow = false ) { $ repeaterId = $ content ? : PageBlockRepeaterRows :: nextFreeRepeaterId ( ) ; $ this -> _editViewData [ 'renderedRows' ] = '' ; $ this -> _editViewData [ 'itemName' ] = '' ; $ this -> _editViewData [ 'maxRows' ] = '' ; if ( $ repeaterBlocks = BlockRepeater :: get... | Admin view for editing repeater data Can return an individual repeater row with default block data ) |
19,404 | public function submit ( $ postContent ) { $ existingRepeaterRows = PageBlockRepeaterData :: loadRepeaterData ( $ postContent [ 'repeater_id' ] , $ this -> _block -> getVersionId ( ) ) ; $ submittedRepeaterRows = Request :: input ( 'repeater.' . $ postContent [ 'repeater_id' ] ) ? : [ ] ; $ postContent [ 'repeater_id' ... | Save submitted repeater data |
19,405 | public function generateSearchText ( $ content ) { $ searchText = '' ; $ repeaterRows = PageBlockRepeaterData :: loadRepeaterData ( $ content , $ this -> _block -> getVersionId ( ) ) ; $ repeaterBlocks = BlockRepeater :: getRepeaterBlocks ( $ this -> _block -> id ) ; foreach ( $ repeaterRows as $ rowId => $ repeaterRow... | Get search text from repeater blocks |
19,406 | public function edit ( $ content ) { $ users = [ ] ; foreach ( User :: all ( ) as $ user ) { $ users [ $ user -> id ] = $ user -> getName ( ) . ' (#' . $ user -> id . ')' ; } $ this -> _editViewData [ 'customName' ] = array_key_exists ( $ content , $ users ) ? '' : $ content ; $ this -> _editViewData [ 'selectOptions' ... | Display user select plus custom input |
19,407 | public function generateSearchText ( $ content ) { $ userAliases = $ content ? User :: userAliases ( ) : [ ] ; $ userName = ( is_numeric ( $ content ) && ! empty ( $ userAliases [ $ content ] ) ) ? $ userAliases [ $ content ] : $ content ; return parent :: generateSearchText ( $ userName ) ; } | Convert user id to name if not custom |
19,408 | protected function loadCss ( $ css , $ options = array ( ) ) { $ location = ( isset ( $ options [ 'location' ] ) ) ? $ options [ 'location' ] : 'internal' ; $ position = ( isset ( $ options [ 'position' ] ) ) ? $ options [ 'position' ] : 'last' ; if ( ! in_array ( $ css , $ this -> data [ 'css' ] [ $ location ] ) ) { i... | enqueue css asset to be loaded |
19,409 | protected function removeCss ( $ css ) { $ key = array_keys ( $ this -> data [ 'css' ] [ 'internal' ] , $ css ) ; if ( $ key ) { array_splice ( $ this -> data [ 'css' ] [ 'internal' ] , $ key [ 0 ] , 1 ) ; } $ key = array_keys ( $ this -> data [ 'css' ] [ 'external' ] , $ css ) ; if ( $ key ) { array_splice ( $ this ->... | remove individual css file from queue list |
19,410 | protected function removeJs ( $ js ) { $ key = array_keys ( $ this -> data [ 'js' ] [ 'internal' ] , $ js ) ; if ( $ key ) { array_splice ( $ this -> data [ 'js' ] [ 'internal' ] , $ key [ 0 ] , 1 ) ; } $ key = array_keys ( $ this -> data [ 'js' ] [ 'external' ] , $ js ) ; if ( $ key ) { array_splice ( $ this -> data [... | remove individual js file from queue list |
19,411 | public function display ( $ content , $ options = [ ] ) { $ pages = [ ] ; $ page_ids = [ ] ; if ( isset ( $ options [ 'reverse' ] ) ) { $ currentPageId = PageBuilder :: pageId ( true ) ; if ( $ currentPageId ) { $ same_blocks = PageBlock :: where ( 'block_id' , '=' , $ this -> _block -> id ) -> get ( ) ; foreach ( $ sa... | Display pages selected with view Also reverse lookup option find pages with the current page selected |
19,412 | protected function _renderRepeatedDisplayViewItem ( $ displayView , $ data = [ ] ) { $ pageOverride = PageBuilder :: getData ( 'pageOverride' ) ; $ item = reset ( $ data ) ; PageBuilder :: setData ( 'pageOverride' , $ item -> page ) ; $ renderedView = parent :: _renderRepeatedDisplayViewItem ( $ displayView , $ data ) ... | Set default page id to selected page in the repeated view |
19,413 | public function checkPermission ( $ user , $ ability , $ arguments ) { if ( $ user -> role === 'admin' ) { return true ; } $ roles = $ this -> getRoles ( ) ; if ( ! isset ( $ roles [ $ user -> role ] ) ) { return null ; } $ role = $ roles [ $ user -> role ] ; $ permissions = $ this -> getPermissions ( ) ; $ current = $... | Checking permission for choosed user |
19,414 | public function getModel ( $ class , $ id ) { if ( $ id instanceof $ class ) { return $ id ; } elseif ( ctype_digit ( strval ( $ id ) ) ) { return $ class :: findOrFail ( $ id ) ; } else { throw new \ Exception ( "Can't get model." , 1 ) ; } } | Return model of given class or exception if can t |
19,415 | public function getAggregatedBlock ( $ blockName , $ scopes = [ ] ) { $ aggregatedData = new Block ( [ 'name' => $ blockName ] ) ; if ( array_key_exists ( $ blockName , $ this -> _blocks ) ) { $ scopes = $ this -> _getScopes ( $ scopes ) ; arsort ( $ scopes ) ; foreach ( $ scopes as $ scope => $ scopeOrder ) { if ( arr... | Ignores template data from db scope |
19,416 | protected function _getScopes ( $ scopes = [ ] ) { if ( $ scopes ) { $ returnScopes = [ ] ; foreach ( $ scopes as $ scope ) { $ returnScopes [ $ scope ] = $ this -> _scopes [ $ scope ] ; } return $ returnScopes ; } else { return $ this -> _scopes ; } } | Return scopes with order values |
19,417 | public function getBlockListInfo ( ) { $ blockList = [ ] ; foreach ( $ this -> getBlockNames ( ) as $ blockName ) { $ importBlock = $ this -> getAggregatedBlock ( $ blockName ) ; $ currentBlock = $ this -> getBlock ( $ importBlock -> blockData [ 'name' ] , 'db' ) ; $ blockList [ $ blockName ] = [ 'block_name' => $ bloc... | Used in theme review view Caches aggregated blocks as they are heavily used in other functions |
19,418 | public static function add ( $ status = null , $ message = null , $ uID = 0 ) { $ model = Yii :: createObject ( __CLASS__ ) ; $ model -> user_id = ( ( int ) $ uID !== 0 ) ? ( int ) $ uID : ( int ) $ model -> getUserID ( ) ; $ model -> user_remote = $ _SERVER [ 'REMOTE_ADDR' ] ; $ model -> action = Yii :: $ app -> reque... | Adds a message to ActionLog model |
19,419 | public static function getUserID ( ) { $ user = Yii :: $ app -> getUser ( ) ; return $ user && ! $ user -> getIsGuest ( ) ? $ user -> getId ( ) : 0 ; } | Get the current user ID |
19,420 | public function initialize ( ) { @ $ this -> _dom -> loadXML ( $ this -> content ( ) ) ; $ this -> _dom -> encoding = 'utf-8' ; $ this -> _xpath = new Driver_Simple_Xpath ( $ this -> _dom ) ; $ this -> _forms = new Driver_Simple_Forms ( $ this -> _xpath ) ; } | Initialze the dom xpath and forms objects based on the content string |
19,421 | protected function getNested ( $ key ) { $ segments = explode ( '.' , $ key ) ; $ data = $ this -> getMenu ( array_shift ( $ segments ) ) ; if ( ! $ data ) return null ; foreach ( $ segments as $ key ) { if ( $ data instanceof Nodes \ SubmenuNode ) { $ data = $ data -> getSubmenu ( ) ; } if ( $ data instanceof Collecti... | Get a nested menu . |
19,422 | public function render ( $ key , RendererInterface $ renderer = null ) { if ( ! $ this -> hasMenu ( $ key ) ) { return '' ; } return $ this -> renderMenu ( $ this -> getMenu ( $ key ) , $ renderer ) ; } | Render a menu if it exists . |
19,423 | public function renderMenu ( Collection $ menu , RendererInterface $ renderer = null ) { if ( $ renderer === null ) { $ renderer = $ this -> getDefaultRenderer ( ) ; } return $ renderer -> render ( $ menu ) ; } | Render a menu collection instance . |
19,424 | public function start ( $ pid_file = NULL , $ log_file = '/dev/null' ) { if ( $ pid_file ) { $ this -> _pid_file = $ pid_file ; if ( is_file ( $ this -> _pid_file ) ) { Phantomjs :: kill ( file_get_contents ( $ pid_file ) ) ; unlink ( $ this -> _pid_file ) ; } } $ this -> _pid = Phantomjs :: start ( 'phantom.js' , $ th... | Start a new phantomjs server optionally provide pid_file and log file . If you provide a pid_file it will kill the process currently running on that pid before starting the new one If the start is unsuccessfull it will return FALSE |
19,425 | public function stop ( ) { if ( $ this -> is_started ( ) ) { $ this -> delete ( 'session' ) ; $ this -> _pid = NULL ; } if ( $ this -> _pid_file AND is_file ( $ this -> _pid_file ) ) { unlink ( $ this -> _pid_file ) ; } $ self = $ this ; return Attempt :: make ( function ( ) use ( $ self ) { return ! $ self -> is_runni... | Gracefully stop the phantomjs server . Return FALSE on failure . Clear the pid_file if set |
19,426 | protected function call ( $ command , array $ options = array ( ) ) { $ curl = curl_init ( ) ; $ options [ CURLOPT_URL ] = $ this -> command_url ( $ command ) ; $ options [ CURLOPT_RETURNTRANSFER ] = TRUE ; $ options [ CURLOPT_FOLLOWLOCATION ] = TRUE ; curl_setopt_array ( $ curl , $ options ) ; $ raw = '' ; Attempt :: ... | Perform a custom request on the phantomjs server using curl |
19,427 | public function login ( ) { if ( Sentry :: check ( ) ) { Response :: redirect ( $ this -> siteUrl ( 'admin' ) ) ; } else { $ this -> data [ 'redirect' ] = ( Input :: get ( 'redirect' ) ) ? base64_decode ( Input :: get ( 'redirect' ) ) : '' ; View :: display ( 'admin/login.twig' , $ this -> data ) ; } } | display the login form |
19,428 | public function doLogin ( ) { $ remember = Input :: post ( 'remember' , false ) ; $ email = Input :: post ( 'email' ) ; $ redirect = Input :: post ( 'redirect' ) ; $ redirect = ( $ redirect ) ? $ redirect : 'admin' ; try { $ credential = array ( 'email' => $ email , 'password' => Input :: post ( 'password' ) ) ; $ user... | Process the login |
19,429 | public function editOwnPost ( $ user , $ post ) { $ post = $ this -> getModel ( \ App \ Post :: class , $ post ) ; return $ user -> id === $ post -> user_id ; } | Methods which checking permissions . Methods should be present only if additional checking needs . |
19,430 | public function exportFiles ( $ content ) { $ uploadFiles = [ ] ; if ( $ content ) { $ dom = new DOMDocument ; libxml_use_internal_errors ( true ) ; $ dom -> loadHTML ( $ content ) ; $ tags = [ 'a' => 'href' , 'img' => 'src' ] ; foreach ( $ tags as $ tag => $ attribute ) { foreach ( $ dom -> getElementsByTagName ( $ ta... | Return files for exporting with theme data |
19,431 | public function find ( $ expression , $ contextnode = NULL ) { if ( $ expression instanceof \ DOMNode ) return $ expression ; @ $ items = $ contextnode ? $ this -> query ( $ expression , $ contextnode ) : $ this -> query ( $ expression ) ; if ( ! $ items ) throw new Exception_Xpath ( 'Error in expression: ":expression"... | Find a DOMElement wit ha given xpath expression optionally provide parent DOMNode to use as context . |
19,432 | public function render ( $ menu , $ tag = 'ul' , $ options ) { return $ this -> renderMenu ( $ this -> menuCollection [ $ menu ] , $ tag , $ options , $ this -> menuCollection [ $ menu ] -> getActiveMenu ( ) , 0 ) ; } | Render specific menu to html |
19,433 | public function addItemInstance ( Nodes \ NodeInterface $ item , $ location = null ) { $ location = ( int ) $ location ; $ this -> items [ $ location ] [ ] = $ item ; if ( $ id = $ item -> getId ( ) ) { $ this -> ids [ $ id ] = $ item ; } return $ item ; } | Add a new node instance to the collection . |
19,434 | public function addItem ( $ title , $ url , array $ attributes = array ( ) , $ location = null ) { return $ this -> addItemInstance ( $ this -> makeItem ( $ title , $ url , $ attributes ) , $ location ) ; } | Add a regular item to the menu collection . |
19,435 | public function addSubmenu ( $ title , array $ attributes = array ( ) , $ location = null ) { return $ this -> addItemInstance ( $ this -> makeSubmenu ( $ title , $ attributes ) , $ location ) ; } | Add a submenu to the menu collection . |
19,436 | public function makeSubmenu ( $ title , array $ attributes = array ( ) ) { $ collection = new static ( $ this -> builder , [ 'id' => StringUtils :: slug ( $ title ) ] ) ; return new Nodes \ SubmenuNode ( $ title , $ collection , $ attributes ) ; } | Make a new submenu item instance . |
19,437 | public function addDivider ( $ location = null ) { $ node = new Nodes \ DividerNode ( 'divider-' . ( ++ $ this -> dividerCount ) ) ; $ this -> addItemInstance ( $ node , $ location ) ; } | Add a divider to the items . |
19,438 | public function getItem ( $ id ) { return array_key_exists ( $ id , $ this -> ids ) ? $ this -> ids [ $ id ] : null ; } | Get an item from the collection . |
19,439 | public function removeItem ( $ id ) { if ( ! array_key_exists ( $ id , $ this -> ids ) ) { return false ; } $ item = $ this -> ids [ $ id ] ; unset ( $ this -> ids [ $ id ] ) ; foreach ( $ this -> items as $ k1 => $ v1 ) { foreach ( $ v1 as $ k2 => $ v2 ) { if ( $ item === $ v2 ) { unset ( $ this -> items [ $ k1 ] [ $ ... | Remove an item from the collection . |
19,440 | public static function preloadPageBlock ( $ pageId , $ blockId , $ version = 0 , $ preloadBy = 'page_id' ) { ( $ preloadBy == 'page_id' ) ? static :: _preloadDataByPage ( $ pageId , $ version ) : static :: _preloadDataByBlock ( $ blockId , $ version ) ; return static :: _preloadGet ( 'byVersionPage' , [ $ version , $ p... | Load all page block data for block on page |
19,441 | public static function preloadPageBlockLanguage ( $ pageId , $ blockId , $ version = 0 , $ preloadBy = 'page_id' ) { ( $ preloadBy == 'page_id' ) ? static :: _preloadDataByPage ( $ pageId , $ version ) : static :: _preloadDataByBlock ( $ blockId , $ version ) ; return static :: _preloadGet ( 'byVersionPage' , [ $ versi... | Load page block data for block on page in current language |
19,442 | public static function livePageBlocksForBlock ( $ blockId , $ reload = false ) { if ( $ reload ) { static :: _preloadClear ( 'liveBlocks' ) ; } if ( ! static :: _preloadIsset ( 'liveBlocks' , $ blockId ) ) { $ pageBlocks = Block :: getDataForVersion ( new static , - 1 , [ 'block_id' => $ blockId , 'language_id' => Lang... | Load page block data for all live versions of a block across all pages |
19,443 | protected function _defaultData ( $ content ) { $ content = @ unserialize ( $ content ) ; if ( empty ( $ content ) || ! is_a ( $ content , \ stdClass :: class ) ) { $ content = new \ stdClass ; } $ content -> selected = isset ( $ content -> selected ) ? $ content -> selected : '' ; $ content -> price = isset ( $ conten... | Get valid selectwprice data |
19,444 | public function generateSearchText ( $ content ) { $ content = $ this -> _defaultData ( $ content ) ; $ searchText = $ this -> _generateSearchText ( $ content -> selected , $ content -> price ) ; return parent :: generateSearchText ( $ searchText ) ; } | Add select option and price data to search |
19,445 | public function analyse ( $ file , array & $ classes = [ ] ) { $ tokens = token_get_all ( file_get_contents ( $ file ) ) ; $ namespace = '' ; $ buildingNs = false ; $ buildingClass = false ; foreach ( $ tokens as $ token ) { if ( $ token [ 0 ] == T_NAMESPACE ) { $ buildingNs = true ; $ buildingClass = false ; $ namespa... | Given a file name search and extract all class names in the file . |
19,446 | public function analysePaths ( Finder $ finder ) { $ classes = [ ] ; foreach ( $ finder as $ file ) { $ this -> analyse ( $ file , $ classes ) ; } return $ classes ; } | Find all class names by a finder instance . |
19,447 | public function index ( $ page = 1 ) { $ user = Sentry :: getUser ( ) ; $ this -> data [ 'title' ] = 'Users List' ; $ this -> data [ 'users' ] = User :: where ( 'id' , '<>' , $ user -> id ) -> get ( ) -> toArray ( ) ; $ this -> loadJs ( 'app/user.js' ) ; $ this -> publish ( 'baseUrl' , $ this -> data [ 'baseUrl' ] ) ; ... | display list of resource |
19,448 | public function show ( $ id ) { if ( Request :: isAjax ( ) ) { $ user = null ; $ message = '' ; try { $ user = Sentry :: findUserById ( $ id ) ; } catch ( Exception $ e ) { $ message = $ e -> getMessage ( ) ; } Response :: headers ( ) -> set ( 'Content-Type' , 'application/json' ) ; Response :: setBody ( json_encode ( ... | display resource with specific id |
19,449 | public function edit ( $ id ) { try { $ user = Sentry :: findUserById ( $ id ) ; $ this -> data [ 'title' ] = 'Edit User' ; $ this -> data [ 'user' ] = $ user -> toArray ( ) ; View :: display ( '@usergroup/user/edit.twig' , $ this -> data ) ; } catch ( UserNotFoundException $ e ) { App :: notFound ( ) ; } catch ( Excep... | show edit from resource with specific id |
19,450 | public function update ( $ id ) { $ success = false ; $ message = '' ; $ user = null ; $ code = 0 ; try { $ input = Input :: put ( ) ; $ input = is_null ( $ input ) ? Input :: post ( ) : $ input ; if ( $ input [ 'password' ] != $ input [ 'confirm_password' ] ) { throw new Exception ( "Password and confirmation password... | update resource with specific id |
19,451 | public function store ( ) { $ user = null ; $ message = '' ; $ success = false ; try { $ input = Input :: post ( ) ; if ( $ input [ 'password' ] != $ input [ 'confirm_password' ] ) { throw new Exception ( "Password and confirmation password not match" , 1 ) ; } $ user = Sentry :: createUser ( array ( 'email' => $ input... | create new resource |
19,452 | public function destroy ( $ id ) { $ id = ( int ) $ id ; $ deleted = false ; $ message = '' ; $ code = 0 ; try { $ user = Sentry :: findUserById ( $ id ) ; $ deleted = $ user -> delete ( ) ; $ code = 200 ; } catch ( UserNotFoundException $ e ) { $ message = $ e -> getMessage ( ) ; $ code = 404 ; } catch ( Exception $ e... | destroy resource with specific id |
19,453 | public function generateSearchText ( $ content ) { $ content = @ unserialize ( $ content ) ? : [ ] ; $ searchText = $ this -> _generateSearchText ( ... $ content ) ; return parent :: generateSearchText ( $ searchText ) ; } | Unserialize string before generating search text |
19,454 | public function filter ( $ content , $ search , $ type ) { $ items = ! empty ( $ content ) ? unserialize ( $ content ) : [ ] ; switch ( $ type ) { case 'in' : foreach ( $ items as $ item ) { if ( strpos ( $ item , $ search ) !== false ) { return true ; } } return false ; break ; default : return in_array ( $ search , $... | Filter in now an array search |
19,455 | public function getFlatSubItems ( ) { $ key = $ this -> getKey ( ) ; $ itemIds = Arr :: get ( $ this -> _tree , $ key ) ; $ flatItemIds = $ this -> _dot ( $ itemIds , $ key ? $ key . '.' : '' ) ; $ items = [ ] ; foreach ( $ flatItemIds as $ itemId => $ value ) { $ items [ $ itemId ] = $ this -> _itemData [ $ itemId ] ;... | Recursive and flatten |
19,456 | public static function getOrderedPages ( $ pageIds ) { $ pages = [ ] ; foreach ( $ pageIds as $ pageId ) { $ pages [ $ pageId ] = static :: preload ( $ pageId ) ; } uasort ( $ pages , [ 'self' , '_orderAsc' ] ) ; return $ pages ; } | returns ordered pages |
19,457 | public function display ( $ content , $ options = [ ] ) { $ imageData = $ this -> _defaultData ( $ content ) ; if ( empty ( $ imageData -> file ) ) { return '' ; } if ( empty ( $ imageData -> title ) ) { if ( empty ( $ options [ 'title' ] ) ) { $ fileName = substr ( strrchr ( $ imageData -> file , '/' ) , 1 ) ; $ image... | Display image image can be cropped with croppa |
19,458 | public function edit ( $ content ) { $ imageData = $ this -> _defaultData ( $ content ) ; $ imageData -> file = str_replace ( URL :: to ( '/' ) , '' , $ imageData -> file ) ; return parent :: edit ( $ imageData ) ; } | Load image block data with domain relative paths |
19,459 | public function submit ( $ postContent ) { if ( ! empty ( $ postContent [ 'alt' ] ) || ! empty ( $ postContent [ 'source' ] ) ) { $ imageData = $ this -> _defaultData ( '' ) ; $ imageData -> title = ! empty ( $ postContent [ 'alt' ] ) ? $ postContent [ 'alt' ] : '' ; $ imageData -> file = ! empty ( $ postContent [ 'sou... | Save image block data |
19,460 | public function generateSearchText ( $ content ) { $ content = $ this -> _defaultData ( $ content ) ; $ searchText = $ this -> _generateSearchText ( $ content -> title , basename ( $ content -> file ) ) ; return parent :: generateSearchText ( $ searchText ) ; } | Add image filename and image title data to search |
19,461 | protected function _defaultData ( $ content ) { $ content = @ unserialize ( $ content ) ; if ( empty ( $ content ) || ! is_a ( $ content , \ stdClass :: class ) ) { $ content = new \ stdClass ; } $ content -> file = empty ( $ content -> file ) ? '' : $ content -> file ; $ content -> title = empty ( $ content -> title )... | Return valid image data |
19,462 | public function exportFiles ( $ content ) { $ content = $ this -> _defaultData ( $ content ) ; if ( $ content -> file && ( strpos ( $ content -> file , '/' ) === 0 || strpos ( $ content -> file , URL :: to ( '/' ) ) === 0 ) ) { return [ str_replace ( URL :: to ( '/' ) , '' , $ content -> file ) ] ; } else { return [ ] ... | Return image file for exporting with theme data |
19,463 | public function displayView ( $ view = '' , $ suffix = '' ) { $ viewTag = $ view . ( $ suffix ? '#' . $ suffix : '' ) ; if ( ! array_key_exists ( $ viewTag , $ this -> _displayViewCache ) ) { $ this -> _displayViewCache [ $ viewTag ] = '' ; $ viewRootPath = 'themes.' . PageBuilder :: getData ( 'theme' ) . '.blocks.' ; ... | Return display block view path |
19,464 | protected function _renderDisplayView ( $ options , $ data = [ ] , $ returnRaw = false ) { if ( array_key_exists ( 'repeated_view' , $ options ) && $ options [ 'repeated_view' ] ) { return $ this -> _renderRepeatedDisplayView ( $ options , $ data ) ; } elseif ( $ displayView = $ this -> displayViewOptions ( $ options )... | Return rendered display block view |
19,465 | public function edit ( $ content ) { $ dotName = str_replace ( [ '[' , ']' ] , [ '.' , '' ] , $ this -> _getInputHTMLKey ( ) ) ; $ submittedData = Request :: input ( $ dotName ) ; return CmsBlockInput :: make ( $ this -> _block -> type , $ this -> _editViewData + [ 'label' => $ this -> _block -> label , 'name' => $ thi... | Admin display for the block |
19,466 | protected function _getInputHTMLKey ( $ altKey = '' ) { if ( $ this -> _block -> getRepeaterId ( ) && $ this -> _block -> getRepeaterRowId ( ) ) { $ inputHTMLKey = 'repeater[' . $ this -> _block -> getRepeaterId ( ) . '][' . $ this -> _block -> getRepeaterRowId ( ) . ']' ; } else { $ inputHTMLKey = 'block' ; } return $... | Create the html key to be used in the block view |
19,467 | public function save ( $ content ) { $ this -> _isSaved = true ; $ this -> _contentSaved = ( string ) $ content ; $ this -> _block -> updateContent ( $ this -> _contentSaved ) ; return $ this ; } | Update block raw data should be string |
19,468 | public function publish ( ) { if ( $ this -> _block -> getPageId ( ) && $ this -> _isSaved ) { $ searchText = $ this -> _block -> search_weight > 0 ? $ this -> generateSearchText ( $ this -> _contentSaved ) : '' ; $ this -> _block -> publishContent ( $ searchText ) ; } return $ this ; } | Should only be called after save By default updates search text and publishes a new page version |
19,469 | protected function _generateSearchText ( ... $ contentParts ) { $ searchText = '' ; foreach ( $ contentParts as $ contentPart ) { $ contentPart = trim ( ( string ) $ contentPart ) ; if ( $ contentPart !== '' ) { $ searchText .= $ contentPart . ' ' ; } } $ searchText = trim ( strip_tags ( $ searchText ) ) ; return ( $ s... | Joins all non whitespace parameters passed through as and returns string or null if only whitespace Also removes HTML tags |
19,470 | public function filter ( $ content , $ search , $ type ) { switch ( $ type ) { case 'in' : return ( strpos ( $ content , $ search ) !== false ) ; break ; default : return ( $ content == $ search ) ; } } | Used by the PageBuilder filter functions to filter block data |
19,471 | public function setFilter ( $ filter = null ) { $ this -> filter = is_callable ( $ filter ) ? $ filter : null ; return $ this ; } | Set the filter to be applied to the matches . |
19,472 | private function fetch ( array $ matchLine ) { $ result = array ( ) ; foreach ( $ this -> getSelector ( ) -> getConfig ( ) as $ match ) { if ( isset ( $ match [ 'apply' ] ) ) { $ result [ $ match [ 'name' ] ] = $ match [ 'apply' ] ( $ matchLine [ $ match [ 'name' ] ] , $ this -> getSelector ( ) -> getSourceKey ( ) ) ; ... | Fetch the values from a match . |
19,473 | public function getNextLinkQueryStringParams ( ) { $ nextLink = $ this -> getNextLink ( ) ; if ( ! isset ( $ nextLink ) ) { throw new \ Exception ( 'No HATEOAS \"next\" link provided.' ) ; } $ parsedUrl = parse_url ( $ nextLink -> getUrl ( ) ) ; $ qsArray = [ ] ; parse_str ( $ parsedUrl [ 'query' ] , $ qsArray ) ; retu... | QS params parsed from the HATEOAS next link |
19,474 | public function addUrl ( $ url ) { $ page = new Page ( $ url ) ; $ this -> addContent ( $ page -> getHTML ( ) , $ url ) ; return $ this ; } | Add URL to scrape . |
19,475 | public function addContent ( $ content , $ key = null ) { if ( ! is_null ( $ key ) ) { $ this -> contents [ $ key ] = $ content ; } else { $ this -> contents [ ] = $ content ; } return $ this ; } | Add content to scrape . |
19,476 | public function orderBy ( $ name , $ order = 'asc' , $ projection = null ) { $ order = strtolower ( $ order ) == 'desc' ? SORT_DESC : SORT_ASC ; $ this -> orderBy [ ] = array ( $ name , $ order , $ projection ) ; return $ this ; } | Order the matches . |
19,477 | public function get ( $ columns = array ( '*' ) ) { $ columns = is_array ( $ columns ) ? $ columns : func_get_args ( ) ; return $ this -> scrape ( $ columns ) ; } | Get all the matches . |
19,478 | public function first ( $ columns = array ( '*' ) ) { $ columns = is_array ( $ columns ) ? $ columns : func_get_args ( ) ; $ results = $ this -> scrape ( $ columns ) ; return current ( $ results ) ; } | Get the first match . |
19,479 | public function last ( $ columns = array ( '*' ) ) { $ columns = is_array ( $ columns ) ? $ columns : func_get_args ( ) ; $ results = $ this -> scrape ( $ columns ) ; return end ( $ results ) ; } | Get the last match . |
19,480 | protected function scrape ( $ columns ) { if ( ! $ this -> contents ) { throw new ContentNotFoundException ( ) ; } $ results = array ( ) ; foreach ( $ this -> contents as $ id => $ content ) { $ results = array_merge ( $ results , $ this -> getMatcher ( ) -> getMatches ( $ content , $ id ) ) ; } if ( $ results ) { if (... | The actual scraping . |
19,481 | private function endElement ( $ parser , $ name ) { $ meta = $ this -> metaStack -> pop ( ) ; if ( ! $ this -> metaStack -> isEmpty ( ) ) { if ( $ meta -> propertyName !== '' ) { $ parentObject = $ this -> getParentObject ( ) ; if ( $ parentObject ) { if ( ! $ meta -> unbound ) { $ parentObject -> { $ meta -> propertyN... | Handler for the parser that is called at the end of each XML element . |
19,482 | private function getPhpMeta ( $ elementName , $ attributes ) { $ meta = new \ StdClass ( ) ; $ meta -> propertyName = '' ; $ meta -> phpType = '' ; $ meta -> unbound = false ; $ meta -> attribute = false ; $ meta -> elementName = '' ; $ meta -> strData = '' ; if ( ! $ this -> metaStack -> isEmpty ( ) ) { $ parentObject... | Looks up the PHP meta data for the element . |
19,483 | private function setByValue ( $ meta ) { return ( is_subclass_of ( $ meta -> phpObject , '\DTS\eBaySDK\Types\Base64BinaryType' , false ) || is_subclass_of ( $ meta -> phpObject , '\DTS\eBaySDK\Types\BooleanType' , false ) || is_subclass_of ( $ meta -> phpObject , '\DTS\eBaySDK\Types\DecimalType' , false ) || is_subclas... | Determines if the the property of an object is set by a _value_ property . |
19,484 | protected function handleFailedJob ( JobInterface $ job , \ Exception $ exception ) { if ( $ job instanceof TrackableJobInterface ) { $ job -> setState ( JobInterface :: STATE_FAILED ) ; } $ this -> getLogger ( ) -> error ( 'Perform failure on {job}, {message}' , array ( 'job' => $ job , 'message' => $ exception -> get... | Handle failed job |
19,485 | public function halt ( ) { if ( $ this -> getProcess ( ) -> getPid ( ) == getmypid ( ) ) { $ this -> stop ( ) ; $ this -> haltCurrentJob ( ) ; } else { $ this -> getProcess ( ) -> kill ( SIGINT ) ; } } | Force an immediate shutdown of the worker killing any child jobs currently running or the job it is currently working on . |
19,486 | public function reset ( ) { $ this -> setId ( null ) ; $ this -> shutdown = false ; $ this -> getLogger ( ) -> notice ( 'Worker {worker} reset' , array ( 'worker' => $ this ) ) ; } | Get worker ready to start again . |
19,487 | public function setCurrentJob ( JobInterface $ job = null ) { if ( null !== $ job && null !== $ this -> getCurrentJob ( ) ) { throw new ResqueRuntimeException ( sprintf ( 'Cannot set current job to %s when current job is not null, current job is %s' , $ job , $ this -> getCurrentJob ( ) ) ) ; } $ this -> currentJob = $... | Set current job |
19,488 | protected function call ( ) { $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , array ( CURLOPT_RETURNTRANSFER => 1 , CURLOPT_URL => $ this -> requestUrl [ $ this -> format ] . $ this -> param , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_FAILONERROR => true , ) ) ; $ request = curl_exec ( $ curl ) ; if ( empty ( $ r... | Make cURL call |
19,489 | public function elementMeta ( $ elementName ) { $ class = get_class ( $ this ) ; if ( array_key_exists ( $ elementName , self :: $ properties [ $ class ] ) ) { $ info = self :: $ properties [ $ class ] [ $ elementName ] ; $ nameKey = $ info [ 'attribute' ] ? 'attributeName' : 'elementName' ; if ( array_key_exists ( $ n... | Returns the meta data for a property . |
19,490 | protected function setValues ( $ class , array $ values = array ( ) ) { foreach ( $ values as $ property => $ value ) { $ actualValue = self :: determineActualValueToAssign ( $ class , $ property , $ value ) ; $ this -> set ( $ class , $ property , $ actualValue ) ; } } | Assign multiple values to an object . |
19,491 | private function getValue ( $ class , $ name ) { $ info = self :: propertyInfo ( $ class , $ name ) ; if ( $ info [ 'unbound' ] && ! array_key_exists ( $ name , $ this -> values ) ) { $ this -> values [ $ name ] = new Types \ UnboundType ( $ class , $ name , $ info [ 'type' ] ) ; } return array_key_exists ( $ name , $ ... | Get the value of a property . Assumes property exists . |
19,492 | private function setValue ( $ class , $ name , $ value ) { $ info = self :: propertyInfo ( $ class , $ name ) ; if ( ! $ info [ 'unbound' ] ) { $ this -> values [ $ name ] = $ value ; } else { $ actualType = self :: getActualType ( $ value ) ; if ( 'array' !== $ actualType ) { throw new Exceptions \ InvalidPropertyType... | Set the value of a property . Assumes property exists . |
19,493 | private function attributesToXml ( ) { $ attributes = array ( ) ; foreach ( self :: $ properties [ get_class ( $ this ) ] as $ name => $ info ) { if ( ! $ info [ 'attribute' ] ) { continue ; } if ( ! array_key_exists ( $ name , $ this -> values ) ) { continue ; } $ attributes [ ] = self :: attributeToXml ( $ info [ 'at... | Returns an XML string of the object s attributes . |
19,494 | private function propertiesToXml ( ) { $ properties = array ( ) ; foreach ( self :: $ properties [ get_class ( $ this ) ] as $ name => $ info ) { if ( $ info [ 'attribute' ] ) { continue ; } if ( ! array_key_exists ( $ name , $ this -> values ) ) { continue ; } $ value = $ this -> values [ $ name ] ; if ( ! array_key_e... | Returns an XML string of the object s properties . |
19,495 | private static function ensurePropertyExists ( $ class , $ name ) { if ( ! array_key_exists ( $ name , self :: $ properties [ $ class ] ) ) { throw new Exceptions \ UnknownPropertyException ( get_called_class ( ) , $ name ) ; } } | Determines if the property is a member of the class . |
19,496 | private static function encodeValueXml ( $ value ) { if ( $ value instanceof \ DateTime ) { return $ value -> format ( 'Y-m-d\TH:i:s.000\Z' ) ; } else if ( is_bool ( $ value ) ) { return $ value ? 'true' : 'false' ; } else { return $ value ; } } | Helper function to convert a value into XML |
19,497 | private static function propertyToArrayValue ( $ value ) { if ( is_subclass_of ( $ value , '\DTS\eBaySDK\Types\BaseType' , false ) ) { return $ value -> toArray ( ) ; } else if ( $ value instanceof \ DateTime ) { return $ value -> format ( 'Y-m-d\TH:i:s.000\Z' ) ; } else { return $ value ; } } | Helper function to convert a property in a value that we want in an array . |
19,498 | private static function actualValue ( $ info , $ class , $ property , $ value ) { if ( is_object ( $ value ) ) { return $ value ; } switch ( $ info [ 'type' ] ) { case 'integer' : case 'string' : case 'double' : case 'boolean' : return $ value ; case 'DateTime' : return new \ DateTime ( $ value , new \ DateTimeZone ( '... | Helper function when assigning values via the ctor . |
19,499 | public function setLocale ( string $ locale ) { if ( ! in_array ( $ locale , $ this -> getAvailableLanguages ( ) ) ) { throw new LanguageNotFoundException ( "Language $locale not found." ) ; } $ this -> translator -> setLocale ( $ locale ) ; } | Set new locale . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.