idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
58,800
|
public function doFrontEndLogin ( $ user = null , $ password = null ) { if ( is_null ( $ user ) ) { $ user = $ this -> config [ 'username' ] ; } if ( is_null ( $ password ) ) { $ password = $ this -> config [ 'password' ] ; } $ this -> debug ( 'I open Joomla Frontend Login Page' ) ; $ this -> amOnPage ( $ this -> locator -> frontEndLoginUrl ) ; $ this -> debug ( 'Fill Username Text Field' ) ; $ this -> fillField ( $ this -> locator -> loginUserName , $ user ) ; $ this -> debug ( 'Fill Password Text Field' ) ; $ this -> fillField ( $ this -> locator -> loginPassword , $ password ) ; $ this -> debug ( 'I click Login button' ) ; $ this -> click ( $ this -> locator -> loginButton ) ; $ this -> debug ( 'I wait to see Frontend Member Profile Form with the Logout button in the module' ) ; $ this -> waitForElement ( $ this -> locator -> frontEndLoginSuccess , TIMEOUT ) ; }
|
Function to Do Frontend Login In Joomla!
|
58,801
|
public function doFrontendLogout ( ) { $ this -> debug ( 'I open Joomla Frontend Login Page' ) ; $ this -> amOnPage ( $ this -> locator -> frontEndLoginUrl ) ; $ this -> debug ( 'I click Logout button' ) ; $ this -> click ( $ this -> locator -> frontEndLogoutButton ) ; $ this -> amOnPage ( '/index.php?option=com_users&view=login' ) ; $ this -> debug ( 'I wait to see Login form' ) ; $ this -> waitForElement ( $ this -> locator -> frontEndLoginForm , 30 ) ; $ this -> seeElement ( $ this -> locator -> frontEndLoginForm ) ; }
|
Function to Do frontend Logout in Joomla!
|
58,802
|
public function installJoomlaRemovingInstallationFolder ( $ databaseName = null , $ databasePrefix = null ) { $ this -> installJoomla ( $ databaseName , $ databasePrefix ) ; $ this -> debug ( 'Removing Installation Folder' ) ; $ this -> click ( array ( 'xpath' => "//input[@value='Remove \"installation\" folder']" ) ) ; $ this -> debug ( 'I wait for Removing Installation Folder button to become disabled' ) ; $ this -> waitForJS ( "return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';" , TIMEOUT ) ; $ this -> debug ( 'Joomla is now installed' ) ; $ this -> see ( 'Congratulations! Joomla! is now installed.' , '//h3' ) ; }
|
Install Joomla removing the Installation folder at the end of the execution
|
58,803
|
public function installJoomlaMultilingualSite ( $ languages = array ( ) , $ databaseName = null , $ databasePrefix = null ) { if ( ! $ languages ) { $ languages [ ] = 'French' ; } $ this -> installJoomla ( $ databaseName , $ databasePrefix ) ; $ this -> debug ( 'I go to Install Languages page' ) ; $ this -> click ( array ( 'id' => 'instLangs' ) ) ; $ this -> waitForText ( 'Install Language packages' , TIMEOUT , array ( 'xpath' => '//h3' ) ) ; foreach ( $ languages as $ language ) { $ this -> debug ( 'I mark the checkbox of the language: ' . $ language ) ; $ this -> click ( array ( 'xpath' => "//label[contains(text()[normalize-space()], '$language')]" ) ) ; } $ this -> click ( array ( 'link' => 'Next' ) ) ; $ this -> waitForText ( 'Multilingual' , TIMEOUT , array ( 'xpath' => '//h3' ) ) ; $ this -> selectOptionInRadioField ( 'Activate the multilingual feature' , 'Yes' ) ; $ this -> waitForElementVisible ( array ( 'id' => 'jform_activatePluginLanguageCode-lbl' ) ) ; $ this -> selectOptionInRadioField ( 'Install localised content' , 'Yes' ) ; $ this -> selectOptionInRadioField ( 'Enable the language code plugin' , 'Yes' ) ; $ this -> click ( array ( 'link' => 'Next' ) ) ; $ this -> waitForText ( 'Congratulations! Joomla! is now installed.' , TIMEOUT , array ( 'xpath' => '//h3' ) ) ; $ this -> debug ( 'Removing Installation Folder' ) ; $ this -> click ( array ( 'xpath' => "//input[@value='Remove \"installation\" folder']" ) ) ; $ this -> wait ( 2 ) ; $ this -> debug ( 'Joomla is now installed' ) ; $ this -> see ( 'Congratulations! Joomla! is now installed.' , '//h3' ) ; }
|
Installs Joomla with Multilingual Feature active
|
58,804
|
public function installExtensionFromFolder ( $ path , $ type = 'Extension' ) { $ this -> amOnPage ( '/administrator/index.php?option=com_installer' ) ; $ this -> waitForText ( 'Extensions: Install' , '30' , array ( 'css' => 'H1' ) ) ; $ this -> click ( array ( 'link' => 'Install from Folder' ) ) ; $ this -> debug ( 'I enter the Path' ) ; $ this -> fillField ( array ( 'id' => 'install_directory' ) , $ path ) ; $ this -> click ( array ( 'id' => 'installbutton_directory' ) ) ; $ this -> waitForText ( 'was successful' , TIMEOUT , array ( 'id' => 'system-message-container' ) ) ; $ this -> debug ( "$type successfully installed from $path" ) ; }
|
Installs a Extension in Joomla that is located in a folder inside the server
|
58,805
|
public function installExtensionFromUrl ( $ url , $ type = 'Extension' ) { $ this -> amOnPage ( '/administrator/index.php?option=com_installer' ) ; $ this -> waitForText ( 'Extensions: Install' , '30' , array ( 'css' => 'H1' ) ) ; $ this -> click ( array ( 'link' => 'Install from URL' ) ) ; $ this -> debug ( 'I enter the url' ) ; $ this -> fillField ( array ( 'id' => 'install_url' ) , $ url ) ; $ this -> click ( array ( 'id' => 'installbutton_url' ) ) ; $ this -> waitForText ( 'was successful' , '30' , array ( 'id' => 'system-message-container' ) ) ; if ( $ type == 'Extension' ) { $ this -> debug ( 'Extension successfully installed from ' . $ url ) ; } if ( $ type == 'Plugin' ) { $ this -> debug ( 'Installing plugin was successful.' . $ url ) ; } if ( $ type == 'Package' ) { $ this -> debug ( 'Installation of the package was successful.' . $ url ) ; } }
|
Installs a Extension in Joomla that is located in a url
|
58,806
|
public function installExtensionFromFileUpload ( $ file , $ type = 'Extension' ) { $ this -> amOnPage ( '/administrator/index.php?option=com_installer' ) ; $ this -> waitForText ( 'Extensions: Install' , '30' , array ( 'css' => 'H1' ) ) ; $ this -> click ( array ( 'link' => 'Upload Package File' ) ) ; $ this -> debug ( 'I make sure legacy uploader is visible' ) ; $ this -> executeJS ( 'document.getElementById("legacy-uploader").style.display="block";' ) ; $ this -> debug ( 'I enter the file input' ) ; $ this -> attachFile ( array ( 'id' => 'install_package' ) , $ file ) ; $ this -> waitForText ( 'was successful' , '30' , array ( 'id' => 'system-message-container' ) ) ; if ( $ type == 'Extension' ) { $ this -> debug ( 'Extension successfully installed.' ) ; } if ( $ type == 'Plugin' ) { $ this -> debug ( 'Installing plugin was successful.' ) ; } if ( $ type == 'Package' ) { $ this -> debug ( 'Installation of the package was successful.' ) ; } }
|
Installs a Extension in Joomla using the file upload option
|
58,807
|
public function checkForPhpNoticesOrWarnings ( $ page = null ) { if ( $ page ) { $ this -> amOnPage ( $ page ) ; } $ this -> dontSeeInPageSource ( 'Notice:' ) ; $ this -> dontSeeInPageSource ( '<b>Notice</b>:' ) ; $ this -> dontSeeInPageSource ( 'Warning:' ) ; $ this -> dontSeeInPageSource ( '<b>Warning</b>:' ) ; $ this -> dontSeeInPageSource ( 'Strict standards:' ) ; $ this -> dontSeeInPageSource ( '<b>Strict standards</b>:' ) ; $ this -> dontSeeInPageSource ( 'The requested page can\'t be found' ) ; }
|
Function to check for PHP Notices or Warnings
|
58,808
|
public function selectOptionInRadioField ( $ label , $ option ) { $ this -> debug ( "Trying to select the $option from the $label" ) ; $ label = $ this -> findField ( array ( 'xpath' => "//label[contains(normalize-space(string(.)), '$label')]" ) ) ; $ radioId = $ label -> getAttribute ( 'for' ) ; $ this -> click ( "//fieldset[@id='$radioId']/label[contains(normalize-space(string(.)), '$option')]" ) ; }
|
Selects an option in a Joomla Radio Field based on its label
|
58,809
|
public function selectOptionInChosen ( $ label , $ option ) { $ select = $ this -> findField ( $ label ) ; $ selectID = $ select -> getAttribute ( 'id' ) ; $ chosenSelectID = $ selectID . '_chzn' ; $ this -> debug ( "I open the $label chosen selector" ) ; $ this -> click ( array ( 'xpath' => "//div[@id='$chosenSelectID']/a/div/b" ) ) ; $ this -> debug ( "I select $option" ) ; $ this -> click ( array ( 'xpath' => "//div[@id='$chosenSelectID']//li[text()='$option']" ) ) ; $ this -> wait ( 1 ) ; }
|
Selects an option in a Chosen Selector based on its label
|
58,810
|
public function selectOptionInChosenWithTextField ( $ label , $ option ) { $ select = $ this -> findField ( $ label ) ; $ selectID = $ select -> getAttribute ( 'id' ) ; $ chosenSelectID = $ selectID . '_chzn' ; $ this -> debug ( "I open the $label chosen selector" ) ; $ this -> click ( array ( 'css' => 'div#' . $ chosenSelectID ) ) ; $ this -> debug ( "I select $option" ) ; $ this -> fillField ( array ( 'xpath' => "//div[@id='$chosenSelectID']/div/div/input" ) , $ option ) ; $ this -> click ( array ( 'xpath' => "//div[@id='$chosenSelectID']/div/ul/li[1]" ) ) ; $ this -> wait ( 1 ) ; }
|
Selects an option in a Chosen Selector based on its label with filling the textfield
|
58,811
|
public function selectMultipleOptionsInChosen ( $ label , $ options ) { $ select = $ this -> findField ( $ label ) ; $ selectID = $ select -> getAttribute ( 'id' ) ; $ chosenSelectID = $ selectID . '_chzn' ; foreach ( $ options as $ option ) { $ this -> debug ( "I open the $label chosen selector" ) ; $ this -> click ( array ( 'xpath' => "//div[@id='$chosenSelectID']/ul" ) ) ; $ this -> debug ( "I select $option" ) ; $ this -> click ( array ( 'xpath' => "//div[@id='$chosenSelectID']//li[contains(text()[normalize-space()], '$option')]" ) ) ; $ this -> wait ( 1 ) ; } }
|
Selects one or more options in a Chosen Multiple Select based on its label
|
58,812
|
public function doAdministratorLogout ( ) { $ this -> click ( array ( 'xpath' => "//ul[@class='nav nav-user pull-right']//li//a[@class='dropdown-toggle']" ) ) ; $ this -> debug ( "I click on Top Right corner toggle to Logout from Admin" ) ; $ this -> waitForElement ( array ( 'xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']" ) , TIMEOUT ) ; $ this -> click ( array ( 'xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']" ) ) ; $ this -> waitForElement ( array ( 'id' => 'mod-login-username' ) , TIMEOUT ) ; $ this -> waitForText ( 'Log in' , TIMEOUT , array ( 'xpath' => "//fieldset[@class='loginform']//button" ) ) ; }
|
Function to Logout from Administrator Panel in Joomla!
|
58,813
|
public function enablePlugin ( $ pluginName ) { $ this -> amOnPage ( '/administrator/index.php?option=com_plugins' ) ; $ this -> debug ( 'I check for Notices and Warnings' ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> searchForItem ( $ pluginName ) ; $ this -> waitForElement ( $ this -> searchResultPluginName ( $ pluginName ) , 30 ) ; $ this -> checkExistenceOf ( $ pluginName ) ; $ this -> click ( array ( 'xpath' => "//input[@id='cb0']" ) ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-publish']/button" ) ) ; $ this -> see ( ' enabled' , '#system-message-container' ) ; }
|
Function to Enable a Plugin
|
58,814
|
public function uninstallExtension ( $ extensionName ) { $ this -> amOnPage ( '/administrator/index.php?option=com_installer&view=manage' ) ; $ this -> waitForText ( 'Extensions: Manage' , '30' , array ( 'css' => 'H1' ) ) ; $ this -> searchForItem ( $ extensionName ) ; $ this -> waitForElement ( array ( 'id' => 'manageList' ) , '30' ) ; $ this -> click ( array ( 'xpath' => "//input[@id='cb0']" ) ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-delete']/button" ) ) ; $ this -> acceptPopup ( ) ; $ this -> waitForText ( 'was successful' , '30' , array ( 'id' => 'system-message-container' ) ) ; $ this -> see ( 'was successful' , '#system-message-container' ) ; $ this -> searchForItem ( $ extensionName ) ; $ this -> waitForText ( 'There are no extensions installed matching your query.' , TIMEOUT , array ( 'class' => 'alert-no-items' ) ) ; $ this -> see ( 'There are no extensions installed matching your query.' , '.alert-no-items' ) ; $ this -> debug ( 'Extension successfully uninstalled' ) ; }
|
Uninstall Extension based on a name
|
58,815
|
public function searchForItem ( $ name = null ) { if ( $ name ) { $ this -> debug ( "Searching for $name" ) ; $ this -> fillField ( array ( 'id' => "filter_search" ) , $ name ) ; $ this -> click ( array ( 'xpath' => "//button[@type='submit' and @data-original-title='Search']" ) ) ; return ; } $ this -> debug ( 'clearing search filter' ) ; $ this -> click ( array ( 'xpath' => "//button[@type='button' and @data-original-title='Clear']" ) ) ; }
|
Function to Search For an Item in Joomla! Administrator Lists views
|
58,816
|
public function installLanguage ( $ languageName ) { $ this -> amOnPage ( 'administrator/index.php?option=com_installer&view=languages' ) ; $ this -> debug ( 'I check for Notices and Warnings' ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( 'Refreshing languages' ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-refresh']/button" ) ) ; $ this -> waitForElement ( array ( 'id' => 'j-main-container' ) , 30 ) ; $ this -> searchForItem ( $ languageName ) ; $ this -> waitForElement ( $ this -> searchResultLanguageName ( $ languageName ) , 30 ) ; $ this -> click ( array ( 'id' => "cb0" ) ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-upload']/button" ) ) ; $ this -> waitForText ( 'was successful.' , TIMEOUT , array ( 'id' => 'system-message-container' ) ) ; $ this -> see ( 'No Matching Results' , '.alert-no-items' ) ; $ this -> debug ( $ languageName . ' successfully installed' ) ; }
|
Function to install a language through the interface
|
58,817
|
public function setModulePosition ( $ module , $ position = 'position-7' ) { $ this -> amOnPage ( 'administrator/index.php?option=com_modules' ) ; $ this -> searchForItem ( $ module ) ; $ this -> click ( array ( 'link' => $ module ) ) ; $ this -> waitForText ( "Modules: $module" , 30 , array ( 'css' => 'h1.page-title' ) ) ; $ this -> click ( array ( 'link' => 'Module' ) ) ; $ this -> waitForElement ( array ( 'id' => 'general' ) , 30 ) ; $ this -> selectOptionInChosen ( 'Position' , $ position ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-apply']/button" ) ) ; $ this -> waitForText ( 'Module saved' , 30 , array ( 'id' => 'system-message-container' ) ) ; }
|
Publishes a module on frontend in given position
|
58,818
|
public function publishModule ( $ module ) { $ this -> amOnPage ( 'administrator/index.php?option=com_modules' ) ; $ this -> searchForItem ( $ module ) ; $ this -> checkAllResults ( ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-publish']/button" ) ) ; $ this -> waitForText ( ' published.' , 30 , array ( 'id' => 'system-message-container' ) ) ; }
|
Publishes a module on all frontend pages
|
58,819
|
public function displayModuleOnAllPages ( $ module ) { $ this -> amOnPage ( 'administrator/index.php?option=com_modules' ) ; $ this -> searchForItem ( $ module ) ; $ this -> click ( array ( 'link' => $ module ) ) ; $ this -> waitForElement ( array ( 'link' => 'Menu Assignment' ) , 30 ) ; $ this -> click ( array ( 'link' => 'Menu Assignment' ) ) ; $ this -> waitForElement ( array ( 'id' => 'jform_menus-lbl' ) , 30 ) ; $ this -> click ( array ( 'id' => 'jform_assignment_chzn' ) ) ; $ this -> click ( array ( 'xpath' => "//li[@data-option-array-index='0']" ) ) ; $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-apply']/button" ) ) ; $ this -> waitForText ( 'Module saved' , 30 , array ( 'id' => 'system-message-container' ) ) ; }
|
Changes the module Menu assignment to be shown on all the pages of the website
|
58,820
|
public function clickToolbarButton ( $ button ) { $ input = strtolower ( $ button ) ; $ screenSize = explode ( "x" , $ this -> config [ 'window_size' ] ) ; if ( $ screenSize [ 0 ] <= 480 ) { $ this -> click ( 'Toolbar' ) ; } switch ( $ input ) { case "new" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-new']//button" ) ) ; break ; case "edit" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-edit']//button" ) ) ; break ; case "publish" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-publish']//button" ) ) ; break ; case "unpublish" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-unpublish']//button" ) ) ; break ; case "archive" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-archive']//button" ) ) ; break ; case "check-in" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-checkin']//button" ) ) ; break ; case "batch" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-batch']//button" ) ) ; break ; case "rebuild" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-refresh']//button" ) ) ; break ; case "trash" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-trash']//button" ) ) ; break ; case "save" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-apply']//button" ) ) ; break ; case "save & close" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-save']//button" ) ) ; break ; case "save & new" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-save-new']//button" ) ) ; break ; case "cancel" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-cancel']//button" ) ) ; break ; case "options" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-options']//button" ) ) ; break ; case "empty trash" : $ this -> click ( array ( 'xpath' => "//div[@id='toolbar-delete']//button" ) ) ; break ; } }
|
Function to select Toolbar buttons in Joomla! Admin Toolbar Panel
|
58,821
|
public function createMenuItem ( $ menuTitle , $ menuCategory , $ menuItem , $ menu = 'Main Menu' , $ language = 'All' ) { $ this -> debug ( "I open the menus page" ) ; $ this -> amOnPage ( 'administrator/index.php?option=com_menus&view=menus' ) ; $ this -> waitForText ( 'Menus' , TIMEOUT , array ( 'css' => 'H1' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( "I click in the menu: $menu" ) ; $ this -> click ( array ( 'link' => $ menu ) ) ; $ this -> waitForText ( 'Menus: Items' , TIMEOUT , array ( 'css' => 'H1' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( "I click new" ) ; $ this -> click ( "New" ) ; $ this -> waitForText ( 'Menus: New Item' , TIMEOUT , array ( 'css' => 'h1' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> fillField ( array ( 'id' => 'jform_title' ) , $ menuTitle ) ; $ this -> debug ( "Open the menu types iframe" ) ; $ this -> click ( array ( 'link' => "Select" ) ) ; $ this -> waitForElement ( array ( 'id' => 'menuTypeModal' ) , TIMEOUT ) ; $ this -> wait ( 1 ) ; $ this -> switchToIFrame ( "Menu Item Type" ) ; $ this -> debug ( "Open the menu category: $menuCategory" ) ; $ this -> wait ( 1 ) ; $ this -> waitForElement ( array ( 'link' => $ menuCategory ) , TIMEOUT ) ; $ this -> click ( array ( 'link' => $ menuCategory ) ) ; $ this -> debug ( "Choose the menu item type: $menuItem" ) ; $ this -> wait ( 1 ) ; $ this -> waitForElement ( array ( 'xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]" ) , TIMEOUT ) ; $ this -> click ( array ( 'xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]" ) ) ; $ this -> debug ( 'I switch back to the main window' ) ; $ this -> switchToIFrame ( ) ; $ this -> debug ( 'I leave time to the iframe to close' ) ; $ this -> wait ( 2 ) ; $ this -> selectOptionInChosen ( 'Language' , $ language ) ; $ this -> waitForText ( 'Menus: New Item' , '30' , array ( 'css' => 'h1' ) ) ; $ this -> debug ( 'I save the menu' ) ; $ this -> click ( "Save" ) ; $ this -> waitForText ( 'Menu item saved' , TIMEOUT , array ( 'id' => 'system-message-container' ) ) ; }
|
Creates a menu item with the Joomla menu manager only working for menu items without additional required fields
|
58,822
|
public function setFilter ( $ label , $ value ) { $ label = strtolower ( $ label ) ; $ filters = array ( "select status" => "filter_published" , "select access" => "filter_access" , "select language" => "filter_language" , "select tag" => "filter_tag" , "select max levels" => "filter_level" ) ; $ this -> click ( array ( 'xpath' => "//button[@data-original-title='Filter the list items.']" ) ) ; $ this -> debug ( 'I try to select the filters' ) ; foreach ( $ filters as $ fieldName => $ id ) { if ( $ fieldName == $ label ) { $ this -> selectOptionInChosenByIdUsingJs ( $ id , $ value ) ; } } $ this -> debug ( 'Applied filters' ) ; }
|
Function to filter results in Joomla! Administrator .
|
58,823
|
public function verifyAvailableTabs ( $ expectedTabs , $ tabsLocator = array ( 'xpath' => "//ul[@id='myTabTabs']/li/a" ) ) { $ actualArrayOfTabs = $ this -> grabMultiple ( $ tabsLocator ) ; $ this -> debug ( "Fetch the current list of Tabs in the edit view which is: " . implode ( ", " , $ actualArrayOfTabs ) ) ; $ url = $ this -> grabFromCurrentUrl ( ) ; $ this -> assertEquals ( $ expectedTabs , $ actualArrayOfTabs , "Tab Labels do not match on edit view of" . $ url ) ; $ this -> debug ( 'Verify the Tabs' ) ; }
|
Function to Verify the Tabs on a Joomla! screen
|
58,824
|
public function disableStatistics ( ) { $ this -> debug ( 'I click on never' ) ; $ this -> wait ( 1 ) ; $ this -> waitForElement ( array ( 'link' => 'Never' ) , TIMEOUT ) ; $ this -> click ( array ( 'link' => 'Never' ) ) ; }
|
Hide the statistics info message
|
58,825
|
public function createCategory ( $ title , $ extension = '' ) { $ this -> debug ( 'Category creation in /administrator/' ) ; $ this -> doAdministratorLogin ( ) ; if ( ! empty ( $ extension ) ) { $ extension = '&extension=' . $ extension ; } $ this -> amOnPage ( 'administrator/index.php?option=com_categories' . $ extension ) ; $ this -> waitForElement ( array ( 'class' => 'page-title' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( 'Click new category button' ) ; $ this -> click ( $ this -> locator -> adminToolbarButtonNew ) ; $ this -> waitForElement ( array ( 'class' => 'page-title' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> fillField ( array ( 'id' => 'jform_title' ) , $ title ) ; $ this -> debug ( 'Click new category apply button' ) ; $ this -> click ( $ this -> locator -> adminToolbarButtonApply ) ; $ this -> debug ( 'see a success message after saving the category' ) ; $ this -> see ( 'Category saved' , '#system-message-container' ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; }
|
Create a new category
|
58,826
|
public function createUser ( $ name , $ username , $ password , $ email , $ userGroup = 'Super Users' ) { $ this -> debug ( 'User creation' ) ; $ this -> doAdministratorLogin ( ) ; $ this -> amOnPage ( 'administrator/index.php?option=com_users' ) ; $ this -> waitForElement ( array ( 'class' => 'page-title' ) ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( 'Click new user button' ) ; $ this -> click ( $ this -> locator -> adminToolbarButtonNew ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; $ this -> debug ( 'I fill up the new user information' ) ; $ this -> fillField ( array ( 'id' => 'jform_name' ) , $ name ) ; $ this -> fillField ( array ( 'id' => 'jform_username' ) , $ username ) ; $ this -> fillField ( array ( 'id' => 'jform_password' ) , $ password ) ; $ this -> fillField ( array ( 'id' => 'jform_password2' ) , $ password ) ; $ this -> fillField ( array ( 'id' => 'jform_email' ) , $ email ) ; $ this -> debug ( 'I open the Assigned User Groups Tab and assign the user group' ) ; $ this -> click ( array ( 'link' => 'Assigned User Groups' ) ) ; $ this -> click ( array ( 'xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]" ) ) ; $ this -> debug ( 'Click new user apply button' ) ; $ this -> click ( $ this -> locator -> adminToolbarButtonApply ) ; $ this -> debug ( 'see a success message after saving the user' ) ; $ this -> see ( 'User saved' , '#system-message-container' ) ; $ this -> checkForPhpNoticesOrWarnings ( ) ; }
|
Create a user in the administrator site
|
58,827
|
public function table ( $ content , $ options = array ( ) ) { if ( 'text' == $ this -> getType ( ) ) { return $ content ; } if ( false === $ options ) { return $ this -> config ( 'templates.tableend' ) ; } $ tag = 'table' ; if ( is_null ( $ content ) ) { $ tag = 'tablestart' ; } $ templater = $ this -> templater ( ) ; return $ templater -> format ( 'table' , [ 'attrs' => $ templater -> formatAttributes ( $ this -> _mergeAttributes ( $ options , $ this -> config ( 'attributes.table' ) ) ) , 'content' => $ content ] ) ; }
|
Creates table .
|
58,828
|
public function viewport ( $ content = null ) { if ( empty ( $ content ) ) { $ content = 'width=device-width, initial-scale=1.0' ; } if ( is_array ( $ content ) ) { $ content = implode ( ', ' , $ content ) ; } return $ this -> meta ( array ( 'name' => 'viewport' , 'content' => $ content ) ) ; }
|
Viewport meta .
|
58,829
|
public function deleteCode ( Entity $ userCode ) { $ entityManager = $ this -> entityManager ; $ entityManager -> remove ( $ userCode ) ; $ entityManager -> flush ( ) ; }
|
delete a userCode from database
|
58,830
|
private function parse ( \ WP_Query $ query = null ) { ( is_null ( $ query ) && isset ( $ GLOBALS [ 'wp_query' ] ) ) and $ query = $ GLOBALS [ 'wp_query' ] ; $ data = ( object ) [ 'hierarchy' => [ ] , 'templates' => [ ] , 'query' => $ query ] ; $ branches = self :: $ branches ; if ( $ this -> flags & self :: FILTERABLE ) { $ branches = array_filter ( ( array ) apply_filters ( 'brain.hierarchy.branches' , $ branches ) , function ( $ branch ) { return is_subclass_of ( $ branch , Branch \ BranchInterface :: class , true ) ; } ) ; } $ branches = array_values ( $ branches ) ; if ( $ query instanceof \ WP_Query ) { $ data = array_reduce ( $ branches , [ $ this , 'parseBranch' ] , $ data ) ; } $ data -> hierarchy = $ this -> addIndexLeaves ( $ data -> hierarchy ) ; $ data -> templates [ ] = 'index' ; $ data -> templates = array_values ( array_unique ( $ data -> templates ) ) ; return $ data ; }
|
Parse all branches .
|
58,831
|
public function outputCurrentPlayerImage ( ) { $ playerNumber = $ this -> getCurrentPlayer ( ) ; $ image = imagecreate ( 250 , 50 ) ; $ color = $ this -> collectionOptions -> getGeneralOptions ( ) -> getImagePlayer ( ) [ 'background_color' ] ; imagecolorallocate ( $ image , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ color = $ this -> collectionOptions -> getGeneralOptions ( ) -> getImagePlayer ( ) [ 'font_color' ] ; $ fontColor = imagecolorallocate ( $ image , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ maxPlayer = $ this -> collectionOptions -> getGeneralOptions ( ) -> getMaxPlayer ( ) ; if ( $ maxPlayer > 0 ) { $ text = sprintf ( '%s/%s Player Online' , $ playerNumber , $ maxPlayer ) ; } else { $ text = sprintf ( '%s Player Online' , $ playerNumber ) ; } $ this -> imageCenterString ( $ image , 5 , $ text , $ fontColor ) ; imagepng ( $ image ) ; imagedestroy ( $ image ) ; }
|
output the player online image
|
58,832
|
public function delete ( ) { $ query = $ this -> createQuery ( ) ; $ query -> setAction ( 'delete' ) ; $ query -> where ( $ query -> buildAndSet ( [ $ this -> getTableKey ( ) , '=' , $ this -> id ] ) ) ; $ result = $ this -> database -> query ( $ query ) ; return $ result ? true : false ; }
|
Deletes the current model from the database .
|
58,833
|
public function populate ( array $ data ) { foreach ( $ data as $ property => $ value ) { if ( property_exists ( $ this , $ property ) ) { $ this -> { $ property } = $ value ; } } return $ this ; }
|
Populates the current model with the data provided .
|
58,834
|
public function toArray ( $ keepNullValue = false ) { $ reflection = new \ ReflectionClass ( static :: class ) ; $ arrayData = [ ] ; foreach ( $ reflection -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ property ) { $ value = $ property -> getValue ( $ this ) ; if ( $ property -> isStatic ( ) ) { continue ; } if ( ! $ keepNullValue && $ value === \ Parable \ ORM \ Database :: NULL_VALUE ) { $ value = null ; } $ arrayData [ $ property -> getName ( ) ] = $ value ; } if ( $ this -> getMapper ( ) ) { $ arrayData = $ this -> toMappedArray ( $ arrayData ) ; } return $ arrayData ; }
|
Generates an array of the current model without the protected values .
|
58,835
|
public function toArrayWithoutEmptyValues ( ) { $ array = $ this -> removeEmptyValues ( $ this -> toArray ( true ) ) ; foreach ( $ array as $ key => $ value ) { if ( $ value === \ Parable \ ORM \ Database :: NULL_VALUE ) { $ array [ $ key ] = null ; } } return $ array ; }
|
Generates an array of the current model but removes empty values .
|
58,836
|
public function toMappedArray ( array $ array ) { $ mappedArray = [ ] ; foreach ( $ this -> getMapper ( ) as $ from => $ to ) { $ mappedArray [ $ to ] = $ array [ $ from ] ; } return $ mappedArray ; }
|
Attempts to use stored mapper array to map fields from the current model s properties to what is set in the array .
|
58,837
|
public function exportToArray ( ) { $ data = $ this -> toArray ( ) ; if ( count ( $ this -> exportable ) === 0 ) { return $ data ; } $ exportData = [ ] ; foreach ( $ data as $ key => $ value ) { if ( in_array ( $ key , $ this -> exportable ) ) { $ exportData [ $ key ] = $ data [ $ key ] ; } } return $ exportData ; }
|
Export to array which will exclude unexportable keys
|
58,838
|
public function reset ( ) { $ reflection = new \ ReflectionClass ( static :: class ) ; foreach ( $ reflection -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ property ) { if ( ! $ property -> isStatic ( ) ) { $ this -> { $ property -> getName ( ) } = null ; } } return $ this ; }
|
Reset all public properties to null .
|
58,839
|
public function setRequired ( $ required ) { if ( ! in_array ( $ required , [ \ Parable \ Console \ Parameter :: PARAMETER_REQUIRED , \ Parable \ Console \ Parameter :: PARAMETER_OPTIONAL , ] ) ) { throw new \ Parable \ Console \ Exception ( 'Required must be one of the PARAMETER_* constants.' ) ; } $ this -> required = $ required ; return $ this ; }
|
Set whether this argument is required .
|
58,840
|
public function init ( ) { parent :: init ( ) ; self :: $ plugin = $ this ; Craft :: $ app -> getView ( ) -> registerTwigExtension ( new EnvironmentLabelTwigExtension ( ) ) ; Event :: on ( View :: class , View :: EVENT_BEFORE_RENDER_PAGE_TEMPLATE , function ( Event $ event ) { EnvironmentLabel :: $ plugin -> label -> doItBaby ( ) ; } ) ; }
|
Initializes the plugin sets its static self - reference registers the Twig extension and adds the environment label as appropriate .
|
58,841
|
public function send ( $ to , $ subject , $ body , $ headers ) { return mail ( $ to , $ subject , $ body , $ headers ) ; }
|
Send using PHPs built - in Mail interface
|
58,842
|
protected function loadCommands ( PackageInterface $ package ) { if ( ! $ package -> getCommands ( ) || APP_CONTEXT !== 'console' ) { return $ this ; } $ commandLoader = \ Parable \ DI \ Container :: create ( \ Parable \ Framework \ Loader \ CommandLoader :: class ) ; $ commandLoader -> load ( $ package -> getCommands ( ) ) ; return $ this ; }
|
Load all Commands from package .
|
58,843
|
public function registerPackages ( ) { foreach ( $ this -> packages as $ packageName ) { $ package = \ Parable \ DI \ Container :: create ( $ packageName ) ; $ this -> loadCommands ( $ package ) ; $ this -> loadInits ( $ package ) ; } return $ this ; }
|
Register all packages with Parable .
|
58,844
|
protected function loadInits ( PackageInterface $ package ) { if ( ! $ package -> getInits ( ) ) { return $ this ; } $ initLoader = \ Parable \ DI \ Container :: create ( \ Parable \ Framework \ Loader \ InitLoader :: class ) ; $ initLoader -> load ( $ package -> getInits ( ) ) ; return $ this ; }
|
Load all Inits from package .
|
58,845
|
public function load ( array $ commandClasses ) { foreach ( $ commandClasses as $ commandClass ) { $ command = \ Parable \ DI \ Container :: create ( $ commandClass ) ; $ this -> consoleApp -> addCommand ( $ command ) ; } return $ this ; }
|
Add all commands passed to the console app .
|
58,846
|
public function addCommand ( \ Parable \ Console \ Command $ command ) { $ command -> prepare ( $ this , $ this -> output , $ this -> input , $ this -> parameter ) ; $ this -> commands [ $ command -> getName ( ) ] = $ command ; return $ this ; }
|
Add a command to the application .
|
58,847
|
public function setDefaultCommand ( \ Parable \ Console \ Command $ command ) { $ this -> addCommand ( $ command ) ; $ this -> setDefaultCommandByName ( $ command -> getName ( ) ) ; return $ this ; }
|
Set the default command to use if no command is given . Also adds the command .
|
58,848
|
public function getOrder ( ) { $ request = $ this -> getRequestHandler ( ) ; $ listener = new PayPalListener ( $ request ) ; $ listener -> setMode ( $ this -> getEnvironment ( ) ) ; if ( $ listener -> verifyIpn ( ) ) { return $ this -> store ( $ request -> getData ( ) ) ; } else { throw new InvalidIpnException ( "PayPal as responded with INVALID" ) ; } }
|
Listens for and stores PayPal IPN requests .
|
58,849
|
public function getRequestHandler ( ) { $ config = Config :: get ( 'paypal-ipn-laravel::request_handler' , 'auto' ) ; if ( $ config == 'curl' || ( $ config == 'auto' && is_callable ( 'curl_init' ) ) ) { return new CurlRequest ( Input :: all ( ) ) ; } else { return new SocketRequest ( Input :: all ( ) ) ; } }
|
Get the request handler .
|
58,850
|
private function store ( $ data ) { if ( array_key_exists ( 'txn_id' , $ data ) ) { $ order = IpnOrder :: firstOrNew ( array ( 'txn_id' => $ data [ 'txn_id' ] ) ) ; $ order -> fill ( $ data ) ; } else { $ order = new IpnOrder ( $ data ) ; } $ order -> full_ipn = json_encode ( Input :: all ( ) ) ; $ order -> save ( ) ; $ this -> storeOrderItems ( $ order , $ data ) ; return $ order ; }
|
Stores the IPN contents and returns the IpnOrder object .
|
58,851
|
private function storeOrderItems ( $ order , $ data ) { $ cart = isset ( $ data [ 'num_cart_items' ] ) ; $ numItems = ( isset ( $ data [ 'num_cart_items' ] ) ) ? $ data [ 'num_cart_items' ] : 1 ; for ( $ i = 0 ; $ i < $ numItems ; $ i ++ ) { $ suffix = ( $ numItems > 1 || $ cart ) ? ( $ i + 1 ) : '' ; $ suffixUnderscore = ( $ numItems > 1 || $ cart ) ? '_' . $ suffix : $ suffix ; $ item = new IpnOrderItem ( ) ; if ( isset ( $ data [ 'item_name' . $ suffix ] ) ) $ item -> item_name = $ data [ 'item_name' . $ suffix ] ; if ( isset ( $ data [ 'item_number' . $ suffix ] ) ) $ item -> item_number = $ data [ 'item_number' . $ suffix ] ; if ( isset ( $ data [ 'quantity' . $ suffix ] ) ) $ item -> quantity = $ data [ 'quantity' . $ suffix ] ; if ( isset ( $ data [ 'mc_gross' . $ suffixUnderscore ] ) ) $ item -> mc_gross = $ data [ 'mc_gross' . $ suffixUnderscore ] ; if ( isset ( $ data [ 'mc_handling' . $ suffix ] ) ) $ item -> mc_handling = $ data [ 'mc_handling' . $ suffix ] ; if ( isset ( $ data [ 'mc_shipping' . $ suffix ] ) ) $ item -> mc_shipping = $ data [ 'mc_shipping' . $ suffix ] ; if ( isset ( $ data [ 'tax' . $ suffix ] ) ) $ item -> tax = $ data [ 'tax' . $ suffix ] ; $ order -> items ( ) -> save ( $ item ) ; for ( $ ii = 1 , $ count = 7 ; $ ii < $ count ; $ ii ++ ) { if ( isset ( $ data [ 'option_name' . $ ii . '_' . $ suffix ] ) ) { $ option = new IpnOrderItemOption ( ) ; $ option -> option_name = $ data [ 'option_name' . $ ii . '_' . $ suffix ] ; if ( isset ( $ data [ 'option_selection' . $ ii . '_' . $ suffix ] ) ) { $ option -> option_selection = $ data [ 'option_selection' . $ ii . '_' . $ suffix ] ; } $ item -> options ( ) -> save ( $ option ) ; } } } }
|
Stores the order items from the IPN contents .
|
58,852
|
public function add ( $ cacheKey , $ content , $ status = 200 , $ headers = [ ] , $ expires = Cache :: HOUR ) { $ file = File :: create ( ) ; $ file -> setStatus ( $ status ) ; $ file -> setContent ( $ content ) ; $ file -> setRoute ( $ cacheKey ) ; $ file -> setHeaders ( $ headers ) ; if ( $ expires > 0 ) { $ file -> setExpires ( time ( ) + $ expires ) ; } else { $ file -> setExpires ( $ expires ) ; } $ this -> fileHandler -> write ( $ file ) ; }
|
Adds a cache entry with a given key content and for a set amount of time The time by default for the cache is an hour
|
58,853
|
public function setShouldCompareFields ( $ shouldCompareFields ) { $ this -> shouldQuoteValues = ! $ shouldCompareFields ; $ this -> shouldCompareFields = ( bool ) $ shouldCompareFields ; return $ this ; }
|
Set whether the fields should be compared rather than values . If so quoteValues is set to inverted value .
|
58,854
|
public function build ( ) { $ value = $ this -> getValue ( ) ; $ this -> uppercaseComparator ( ) ; if ( $ this -> isComparatorIsNotNullIsNull ( ) ) { $ value = null ; } if ( ! $ this -> isComparatorIsNotNullIsNull ( ) && $ this -> isComparatorInNotIn ( ) && is_array ( $ value ) ) { $ this -> uppercaseComparator ( ) ; $ valueArray = [ ] ; foreach ( $ value as $ valueItem ) { if ( $ this -> shouldQuoteValues ( ) ) { $ valueArray [ ] = $ this -> query -> quote ( $ valueItem ) ; } else { $ valueArray [ ] = $ valueItem ; } } $ value = '(' . implode ( ',' , $ valueArray ) . ')' ; } if ( ! $ this -> isComparatorIsNotNullIsNull ( ) && ! $ this -> isComparatorInNotIn ( ) && $ this -> shouldQuoteValues ( ) ) { $ value = $ this -> query -> quote ( $ value ) ; } if ( $ this -> shouldCompareFields ( ) ) { $ valueBuild = [ $ this -> query -> quoteIdentifier ( $ this -> getTableName ( ) ) , '.' , $ this -> query -> quoteIdentifier ( $ value ) , ] ; $ value = implode ( $ valueBuild ) ; } $ tableName = $ this -> getTableName ( ) ; if ( $ this -> getJoinTableName ( ) ) { $ tableName = $ this -> getJoinTableName ( ) ; } $ tableName = $ this -> query -> quoteIdentifier ( $ tableName ) ; $ returnArray = [ $ tableName . '.' . $ this -> query -> quoteIdentifier ( $ this -> getKey ( ) ) , $ this -> getComparator ( ) , $ value , ] ; $ returnString = implode ( ' ' , $ returnArray ) ; return trim ( $ returnString ) ; }
|
Build the condition to a string .
|
58,855
|
public function load ( array $ initClasses ) { foreach ( $ initClasses as $ initClass ) { \ Parable \ DI \ Container :: create ( $ initClass ) ; } return $ this ; }
|
Load array of init classes .
|
58,856
|
public function doAuthentication ( UserInterface $ user ) { $ repository = $ this -> entityManager -> getRepository ( $ this -> getUserEntityClassName ( ) ) ; $ username = $ user -> getUsername ( ) ; $ repository -> clear ( ) ; $ userNew = $ repository -> getUser4UserName ( $ username ) ; $ authService = $ this -> getAuthService ( ) ; $ authService -> getStorage ( ) -> write ( $ userNew ) ; }
|
Login with a User
|
58,857
|
protected function bCrypt ( $ password ) { if ( $ this -> isSamePasswordOption ( ) ) { $ result = $ this -> gameDataService -> hashPassword ( $ password ) ; } else { $ bCrypt = new Bcrypt ( ) ; $ result = $ bCrypt -> create ( $ password ) ; } return $ result ; }
|
We want to crypt a password = )
|
58,858
|
public static function get ( $ className , $ parentClassName = '' ) { $ className = self :: cleanName ( $ className ) ; if ( $ parentClassName ) { self :: $ relations [ $ className ] [ $ parentClassName ] = true ; } if ( $ parentClassName && isset ( self :: $ relations [ $ parentClassName ] ) && isset ( self :: $ relations [ $ parentClassName ] [ $ className ] ) ) { $ message = "Cyclical dependency found: {$className} depends on {$parentClassName}" ; $ message .= " but is itself a dependency of {$parentClassName}." ; throw new \ Parable \ DI \ Exception ( $ message ) ; } if ( ! self :: isStored ( $ className ) ) { self :: store ( self :: create ( $ className , $ parentClassName ) ) ; } return self :: $ instances [ $ className ] ; }
|
Return an already instantiated instance or create a new one .
|
58,859
|
protected static function createInstance ( $ className , $ parentClassName = '' , $ createAll = false ) { $ className = self :: cleanName ( $ className ) ; try { $ dependencies = self :: getDependenciesFor ( $ className , $ createAll ) ; } catch ( \ Parable \ DI \ Exception $ e ) { $ message = $ e -> getMessage ( ) ; if ( $ parentClassName ) { $ message .= ", required by '{$parentClassName}'" ; } throw new \ Parable \ DI \ Exception ( $ message ) ; } return new $ className ( ... $ dependencies ) ; }
|
Instantiate a class and fulfill its dependency requirements .
|
58,860
|
public static function clearExcept ( array $ keepInstanceNames ) { foreach ( self :: $ instances as $ name => $ instance ) { if ( ! in_array ( $ name , $ keepInstanceNames ) ) { self :: clear ( $ name ) ; } } }
|
Remove all stored instances but KEEP the passed instance names .
|
58,861
|
public function discardUpperMigrations ( Bundle $ bundle ) { $ drivers = array_keys ( $ this -> getAvailablePlatforms ( ) ) ; $ currentVersion = $ this -> migrator -> getCurrentVersion ( $ bundle ) ; $ this -> log ( "Deleting migration classes above version {$currentVersion} for '{$bundle->getName()}'..." ) ; $ hasDeleted = false ; foreach ( $ drivers as $ driver ) { $ deletedVersions = $ this -> writer -> deleteUpperMigrationClasses ( $ bundle , $ driver , $ currentVersion ) ; if ( count ( $ deletedVersions ) > 0 ) { $ hasDeleted = true ; foreach ( $ deletedVersions as $ version ) { $ this -> log ( " - Deleted {$version} for driver {$driver}" ) ; } } } if ( ! $ hasDeleted ) { $ this -> log ( 'Nothing to discard: there are no migrations classes above the current version' ) ; } }
|
Deletes migration classes which are above the current version of a bundle .
|
58,862
|
public function getAvailablePlatforms ( ) { $ platforms = array ( ) ; foreach ( $ this -> getSupportedDrivers ( ) as $ driverName => $ driverClass ) { $ driver = new $ driverClass ; $ platforms [ $ driverName ] = $ driver -> getDatabasePlatform ( ) ; } return $ platforms ; }
|
Returns the list of available driver platforms .
|
58,863
|
public function getHeader ( $ key ) { foreach ( $ this -> headers as $ header => $ content ) { if ( strtolower ( $ key ) === strtolower ( $ header ) ) { return $ content ; } } return null ; }
|
Return header by key if it exists .
|
58,864
|
public function getScheme ( ) { if ( isset ( $ _SERVER [ 'REQUEST_SCHEME' ] ) ) { return $ _SERVER [ 'REQUEST_SCHEME' ] ; } if ( isset ( $ _SERVER [ 'REDIRECT_REQUEST_SCHEME' ] ) ) { return $ _SERVER [ 'REDIRECT_REQUEST_SCHEME' ] ; } if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ; } if ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] !== 'off' ) { return 'https' ; } if ( isset ( $ _SERVER [ 'SERVER_PORT' ] ) && $ _SERVER [ 'SERVER_PORT' ] == 443 ) { return 'https' ; } return 'http' ; }
|
Return the current scheme .
|
58,865
|
public function getHttpHost ( ) { if ( isset ( $ _SERVER [ 'HTTP_HOST' ] ) && isset ( $ _SERVER [ 'SERVER_NAME' ] ) && $ _SERVER [ 'HTTP_HOST' ] === $ _SERVER [ 'SERVER_NAME' ] ) { return $ _SERVER [ 'HTTP_HOST' ] ; } if ( isset ( $ _SERVER [ 'HTTP_HOST' ] ) ) { return $ _SERVER [ 'HTTP_HOST' ] ; } if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { return $ _SERVER [ 'SERVER_NAME' ] ; } return null ; }
|
Return the http host if possible .
|
58,866
|
public function getAll ( ) { if ( ! $ this -> getResource ( ) ) { return [ ] ; } if ( $ this -> useLocalResource ) { return $ this -> localResource ; } if ( ! isset ( $ GLOBALS [ $ this -> getResource ( ) ] ) ) { throw new \ Parable \ GetSet \ Exception ( "Attempting to use global resource '{$this->getResource()}' but resource not available." ) ; } return $ GLOBALS [ $ this -> getResource ( ) ] ; }
|
Return all from resource if resource is set .
|
58,867
|
public function get ( $ key , $ default = null ) { $ resource = $ this -> getAll ( ) ; $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ resource [ $ key ] ) ) { $ resource = $ default ; break ; } $ resource = & $ resource [ $ key ] ; } return $ resource ; }
|
Return specific value by key if resource set . If not found return default .
|
58,868
|
public function getAndRemove ( $ key ) { $ data = $ this -> get ( $ key ) ; if ( $ data ) { $ this -> remove ( $ key ) ; } return $ data ; }
|
Return specific value by key and then clear it .
|
58,869
|
public function set ( $ key , $ value ) { $ keys = explode ( '.' , $ key ) ; $ data = $ this -> getAll ( ) ; $ resource = & $ data ; foreach ( $ keys as $ key ) { if ( ! isset ( $ resource [ $ key ] ) || ! is_array ( $ resource [ $ key ] ) ) { $ resource [ $ key ] = [ ] ; } $ resource = & $ resource [ $ key ] ; } $ resource = $ value ; $ this -> setAll ( $ data ) ; return $ this ; }
|
Set specific value by key if resource set . It s possible to set using . to separate keys by depth .
|
58,870
|
public function setAll ( array $ values ) { if ( $ this -> getResource ( ) ) { if ( $ this -> useLocalResource ) { $ this -> localResource = $ values ; } else { $ GLOBALS [ $ this -> getResource ( ) ] = $ values ; } } return $ this ; }
|
Set entire array onto the resource
|
58,871
|
public function checkCodestyle ( $ sniffersPath = null ) { if ( is_null ( $ sniffersPath ) ) { $ sniffersPath = __DIR__ . '/.tmp/coding-standards' ; } $ this -> taskCodeChecks ( ) -> setBaseRepositoryPath ( __DIR__ ) -> setCodeStyleStandardsFolder ( $ sniffersPath ) -> setCodeStyleCheckFolders ( array ( 'src' ) ) -> checkCodeStyle ( ) -> run ( ) -> stopOnFail ( ) ; }
|
Check the code style of the project against a passed sniffers using PHP_CodeSniffer_CLI
|
58,872
|
public function closeTag ( ) { $ result = '</label>' ; if ( $ this -> element -> hasAttribute ( 'required' ) && $ this -> element -> getAttribute ( 'required' ) ) { $ result = sprintf ( '<span class="required-mark">*</span> %s' , $ result ) ; } return $ result ; }
|
Return a closing label tag
|
58,873
|
public function doItBaby ( ) { if ( EnvironmentLabel :: $ plugin -> getSettings ( ) -> showLabel && Craft :: $ app -> getRequest ( ) -> isCpRequest && Craft :: $ app -> getUser ( ) -> getIdentity ( ) ) { $ view = Craft :: $ app -> getView ( ) ; $ view -> registerCss ( $ this -> getCss ( ) ) ; $ view -> registerCss ( "{$this->getTargetSelector()} { content: '{$this->getRenderedText()}'; }" ) ; $ view -> registerJs ( $ this -> getJs ( ) ) ; } }
|
If we re in an authenticated CP request the label is added to the CP and some JS variables are injected for convenience debugging things in the console .
|
58,874
|
public function init ( array $ frontendData ) : void { $ this -> _frontendData = Hash :: merge ( $ this -> _frontendData , $ frontendData ) ; $ this -> _includeAppController ( ) ; $ this -> _includeComponents ( ) ; }
|
Initialize the helper . Needs to be called before running it .
|
58,875
|
public static function getAssetCompressFiles ( ) : array { $ helper = new FrontendBridgeHelper ( new View ( ) ) ; $ dependencies = $ helper -> compileDependencies ( ) ; $ plugins = array_map ( '\Cake\Utility\Inflector::underscore' , Plugin :: loaded ( ) ) ; foreach ( $ dependencies as $ n => $ dependency ) { $ parts = explode ( '/' , $ dependency ) ; if ( empty ( $ parts [ 0 ] ) && in_array ( $ parts [ 1 ] , $ plugins ) ) { $ prefix = '/' . $ parts [ 1 ] . '/' ; $ dependency = preg_replace ( '/^' . str_replace ( '/' , '\/' , $ prefix ) . '/' , 'plugin:' . Inflector :: camelize ( $ parts [ 1 ] ) . ':' , $ dependency ) ; } if ( substr ( $ dependency , 0 , 4 ) == '/js/' ) { $ dependency = substr ( $ dependency , 4 ) ; } $ dependencies [ $ n ] = $ dependency ; } return $ dependencies ; }
|
Compiles an AssetCompress - compatible list of assets to be used in asset_compress . ini files as a callback method
|
58,876
|
public function subControllerElement ( array $ url , array $ data = [ ] , array $ options = [ ] ) : string { $ options = Hash :: merge ( [ 'htmlElement' => 'div' ] , $ options ) ; $ name = '../' . $ url [ 'controller' ] . '/' . Inflector :: underscore ( $ url [ 'action' ] ) ; $ markup = '<' . $ options [ 'htmlElement' ] . ' class="controller subcontroller ' ; $ markup .= Inflector :: underscore ( $ url [ 'controller' ] ) . '-' . Inflector :: underscore ( $ url [ 'action' ] ) ; $ markup .= '" data-controller="' . $ url [ 'controller' ] . '" data-action="' . $ url [ 'action' ] . '" ' ; $ markup .= $ this -> getInstanceIdDataAttribute ( ) . '>' ; $ markup .= $ this -> _View -> element ( $ name , $ data , $ options ) ; $ markup .= '</' . $ options [ 'htmlElement' ] . '>' ; return $ markup ; }
|
Renders a subcontroller element which gets an js controller instance assigned
|
58,877
|
public function getMainContentClasses ( array $ additionalClasses = null ) : string { $ classes = [ 'controller' ] ; if ( ! empty ( $ additionalClasses ) ) { $ classes = Hash :: merge ( $ classes , $ additionalClasses ) ; } $ classes [ ] = Inflector :: underscore ( $ this -> _View -> request -> controller ) . '-' . Inflector :: underscore ( $ this -> _View -> request -> action ) ; return h ( implode ( ' ' , $ classes ) ) ; }
|
Constructs the classes for the element that represents the frontend controller s DOM reference .
|
58,878
|
public function run ( ) : string { $ out = '' ; $ this -> _dependencies = array_unique ( $ this -> _dependencies ) ; $ out .= $ this -> getNamespaceDefinitions ( ) ; $ this -> addCurrentController ( ) ; foreach ( $ this -> _dependencies as $ dependency ) { if ( strpos ( $ dependency , DS ) !== false ) { $ dependency = str_replace ( DS , '/' , $ dependency ) ; } $ jsFile = $ this -> Html -> script ( $ dependency ) ; $ out .= $ jsFile . "\n" ; } $ out .= $ this -> getAppDataJs ( $ this -> _frontendData ) ; $ out .= $ this -> Html -> script ( '/frontend_bridge/js/bootstrap.js' ) ; return $ out ; }
|
Includes the configured JS dependencies and appData - should be called from the layout
|
58,879
|
public function getNamespaceDefinitions ( ) : string { $ script = 'var Frontend = {};' ; $ script .= 'var App = { Controllers: {}, Components: {}, Lib: {} };' ; $ tpl = 'App.Controllers.%s = {};' ; foreach ( $ this -> _pluginJsNamespaces as $ pluginName ) { $ script .= sprintf ( $ tpl , $ pluginName ) ; } return $ this -> Html -> scriptBlock ( $ script ) ; }
|
Returns a script block containing namespace definitions for plugin controllers .
|
58,880
|
public function addComponent ( $ componentName ) : bool { if ( is_array ( $ componentName ) ) { foreach ( $ componentName as $ cn ) { $ this -> addComponent ( $ cn ) ; } return true ; } $ componentFile = 'app/components/' . Inflector :: underscore ( $ componentName ) . '.js' ; if ( file_exists ( JS . DS . $ componentFile ) ) { $ this -> _addDependency ( $ componentFile ) ; return true ; } return false ; }
|
Include one or more JS components
|
58,881
|
public function setFrontendData ( $ key , $ value = null ) : void { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> setFrontendData ( $ k , $ v ) ; } return ; } $ this -> _frontendData [ 'jsonData' ] [ $ key ] = $ value ; }
|
Allows manipulating frontend data
|
58,882
|
public function dialogBackButton ( string $ title = null ) : string { $ button = '<button class="modal-back btn btn-default btn-xs">' ; $ button .= '<i class="fa fa-fw fa-arrow-left"></i>' ; $ button .= $ title ?? __ ( 'back' ) ; $ button .= '</button>' ; return $ button ; }
|
Get the back button for modal dialogs if dialog_header is not used
|
58,883
|
protected function _addDependency ( string $ file ) : void { $ file = str_replace ( '\\' , '/' , $ file ) ; if ( ! in_array ( $ file , $ this -> _dependencies ) ) { $ this -> _dependencies [ ] = $ file ; } }
|
Add a file to the frontend dependencies
|
58,884
|
protected function _includeAppController ( ) : void { $ controller = null ; if ( file_exists ( WWW_ROOT . 'js/app/app_controller.js' ) ) { $ controller = 'app/app_controller.js' ; } else { $ controller = '/frontend_bridge/js/lib/app_controller.js' ; } $ this -> _dependencies [ ] = $ controller ; }
|
Check if we have an AppController if not include a stub
|
58,885
|
protected function _includeComponents ( ) : void { $ appComponentFolder = WWW_ROOT . 'js/app/components/' ; $ folder = new Folder ( $ appComponentFolder ) ; $ files = $ folder -> find ( '.*\.js' ) ; if ( ! empty ( $ files ) ) { foreach ( $ files as $ file ) { $ this -> _dependencies [ ] = 'app/components/' . $ file ; } } foreach ( Plugin :: loaded ( ) as $ pluginName ) { $ pluginJsComponentsFolder = Plugin :: path ( $ pluginName ) . '/webroot/js/app/components/' ; if ( is_dir ( $ pluginJsComponentsFolder ) ) { $ folder = new Folder ( $ pluginJsComponentsFolder ) ; $ files = $ folder -> find ( '.*\.js' ) ; foreach ( $ files as $ file ) { $ this -> _dependencies [ ] = '/' . Inflector :: underscore ( $ pluginName ) . '/js/app/components/' . $ file ; } } } }
|
Includes the needed components
|
58,886
|
public function setDataFromArray ( array $ data ) { foreach ( $ data as $ property => $ value ) { $ method = 'set' . ucfirst ( $ property ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> { $ method } ( $ value ) ; } else { throw new \ Parable \ Routing \ Exception ( "Tried to set non-existing property '{$property}' with value '{$value}' on " . get_class ( $ this ) ) ; } } $ this -> checkValidProperties ( ) ; $ this -> parseUrlParameters ( ) ; return $ this ; }
|
Set data from array . Can only set values that have a corresponding setProperty method .
|
58,887
|
public function setUrl ( $ url ) { if ( strpos ( $ url , '/' ) !== 0 ) { $ url = '/' . $ url ; } $ this -> url = $ url ; return $ this ; }
|
Set the url this route is matched on .
|
58,888
|
public function checkValidProperties ( ) { if ( ! $ this -> controller && ! $ this -> action && ! $ this -> callable ) { throw new \ Parable \ Routing \ Exception ( 'Either a controller/action combination or callable is required.' ) ; } if ( empty ( $ this -> methods ) ) { throw new \ Parable \ Routing \ Exception ( 'Methods are required and must be passed as an array.' ) ; } return $ this ; }
|
Check whether a valid set of properties is set .
|
58,889
|
public function isPartCountSame ( $ url ) { return count ( explode ( '/' , rtrim ( $ url , '/' ) ) ) === count ( explode ( '/' , rtrim ( $ this -> url , '/' ) ) ) ; }
|
Verify whether this route s url has the same part count .
|
58,890
|
public function getValue ( $ key ) { if ( ! isset ( $ this -> values [ $ key ] ) ) { return null ; } return $ this -> values [ $ key ] ; }
|
Return a value if it exists .
|
58,891
|
protected function extractAndSetData ( $ data ) { $ data_parsed = json_decode ( $ data , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { parse_str ( $ data , $ data_parsed ) ; } if ( is_array ( $ data_parsed ) ) { $ this -> setAll ( $ data_parsed ) ; } }
|
Attempt to get the data from a string which can be either json or array data .
|
58,892
|
protected function build ( $ withParentheses ) { $ builtConditions = [ ] ; foreach ( $ this -> conditions as $ condition ) { if ( $ condition instanceof \ Parable \ ORM \ Query \ ConditionSet ) { $ builtConditions [ ] = $ condition -> buildWithParentheses ( ) ; } else { $ builtConditions [ ] = $ condition -> build ( ) ; } } $ glue = ' ' . static :: TYPE . ' ' ; $ string = implode ( $ glue , $ builtConditions ) ; if ( $ withParentheses ) { $ string = "({$string})" ; } return $ string ; }
|
Build the conditions into a string . Can be done either with parentheses or without .
|
58,893
|
public function bake ( $ controllerName , $ actionName , $ content = '' ) { if ( $ content === true ) { $ content = $ this -> getContent ( $ action ) ; } if ( empty ( $ content ) ) { return false ; } $ this -> out ( "\n" . sprintf ( 'Baking `%s%s/%s` JS controller file...' , ( $ this -> plugin ? $ this -> plugin . '.' : '' ) , $ controllerName , $ actionName ) , 1 , Shell :: QUIET ) ; $ path = $ this -> getPath ( ) ; $ filename = $ path . Inflector :: underscore ( $ controllerName ) . '/' . Inflector :: underscore ( $ actionName ) . '_controller.js' ; $ this -> createFile ( $ filename , $ content ) ; return $ content ; }
|
Bakes the JS file
|
58,894
|
public function write ( $ message ) { if ( ! $ this -> logFile ) { throw new \ Parable \ Log \ Exception ( "No log file set. \Log\Writer\File requires a valid target file." ) ; } $ this -> writeToFile ( $ message ) ; return $ this ; }
|
Write a message to the log file configured .
|
58,895
|
public function setLogFile ( $ logFile ) { if ( ! $ this -> createfile ( $ logFile ) ) { throw new \ Parable \ Log \ Exception ( "Log file is not writable." ) ; } $ this -> logFile = $ logFile ; return $ this ; }
|
Set the log file to write to .
|
58,896
|
protected function writeToFile ( $ message ) { $ message = $ message . PHP_EOL ; return @ file_put_contents ( $ this -> logFile , $ message , FILE_APPEND ) ; }
|
Write the message to the log file .
|
58,897
|
public function setErrorMode ( $ errorMode ) { if ( in_array ( $ errorMode , [ \ PDO :: ERRMODE_SILENT , \ PDO :: ERRMODE_WARNING , \ PDO :: ERRMODE_EXCEPTION ] ) ) { $ this -> errorMode = $ errorMode ; } return $ this ; }
|
Set the error mode .
|
58,898
|
public function getInstance ( ) { if ( ! $ this -> instance && $ this -> getType ( ) && $ this -> getLocation ( ) ) { switch ( $ this -> getType ( ) ) { case static :: TYPE_SQLITE : $ instance = $ this -> createPDOSQLite ( $ this -> getLocation ( ) , $ this -> getErrorMode ( ) ) ; $ this -> setInstance ( $ instance ) ; break ; case static :: TYPE_MYSQL : if ( ! $ this -> getUsername ( ) || ! $ this -> getPassword ( ) || ! $ this -> getDatabase ( ) ) { return null ; } $ instance = $ this -> createPDOMySQL ( $ this -> getLocation ( ) , $ this -> getDatabase ( ) , $ this -> getUsername ( ) , $ this -> getPassword ( ) , $ this -> getErrorMode ( ) , $ this -> getCharSet ( ) ) ; $ this -> setInstance ( $ instance ) ; break ; default : throw new \ Parable \ ORM \ Exception ( "Database type was invalid: {$this->getType()}" ) ; } } return $ this -> instance ; }
|
Return the instance and start one if needed .
|
58,899
|
protected function createPDOSQLite ( $ location , $ errorMode ) { $ dsn = 'sqlite:' . $ location ; $ db = new \ Parable \ ORM \ Database \ PDOSQLite ( $ dsn ) ; $ db -> setAttribute ( \ PDO :: ATTR_ERRMODE , $ errorMode ) ; return $ db ; }
|
Create and return a sqlite PDO instance .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.