idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
15,400 | public function isValid ( $ key = null ) { $ key = $ key ? $ this -> sanitizeKey ( $ key ) : $ this -> getKey ( ) ; return strlen ( $ key ) === 35 ; } | Checks if key is valid length after format and sanitization is done . |
15,401 | public function getSeoKeywordsByPageId ( $ pageId ) { $ pageId = $ this -> params ( ) -> fromRoute ( 'idPage' , $ this -> params ( ) -> fromQuery ( 'idPage' , '' ) ) ; $ data = array ( ) ; $ seoKeywords = $ pageId -> getSeoKeywords ( $ pageId ) ; $ data = $ seoKeywords ; return $ data ; } | Return seo keywords |
15,402 | private function cleanURL ( string $ url = '' ) { $ url = str_replace ( ' ' , '-' , $ url ) ; $ url = preg_replace ( '/[^A-Za-z0-9\/\-]+/' , '-' , $ url ) ; if ( substr ( $ url , 0 , 1 ) == '/' ) { return preg_replace ( '/\//' , '' , $ url , 1 ) ; } return $ url ; } | Rids the URL from special characters |
15,403 | public function getAttribute ( $ attribute ) { $ data = $ this -> getData ( ) ; return ! empty ( $ data [ $ attribute ] ) ? $ data [ $ attribute ] : '' ; } | Get a specific attribute of our reseller . |
15,404 | public function getData ( ) { $ data = $ this -> resellerOption ; $ data [ 'reseller_identifier' ] = ! empty ( $ data [ 'reseller_identifier' ] ) ? strtolower ( $ data [ 'reseller_identifier' ] ) : null ; $ data [ 'reseller_website_url' ] = ! empty ( $ data [ 'reseller_website_url' ] ) ? esc_url ( $ data [ 'reseller_website_url' ] ) : 'https://www.boldgrid.com/' ; $ data [ 'reseller_title' ] = ! empty ( $ data [ 'reseller_title' ] ) ? esc_html ( $ data [ 'reseller_title' ] ) : esc_html ( 'BoldGrid.com' ) ; $ data [ 'reseller_support_url' ] = ! empty ( $ data [ 'reseller_support_url' ] ) ? esc_url ( $ data [ 'reseller_support_url' ] ) : 'https://www.boldgrid.com/documentation' ; $ data [ 'reseller_amp_url' ] = ! empty ( $ data [ 'reseller_amp_url' ] ) ? esc_url ( $ data [ 'reseller_amp_url' ] ) : 'https://www.boldgrid.com/central' ; return $ data ; } | Get the reseller data . |
15,405 | protected function getMenuItems ( ) { $ data = $ this -> getData ( ) ; return array ( 'topLevel' => array ( 'id' => 'reseller-adminbar-icon' , 'title' => '<span aria-hidden="true" class="' . $ data [ 'reseller_identifier' ] . '-icon ab-icon"></span>' , 'href' => $ data [ 'reseller_website_url' ] , 'meta' => array ( 'class' => 'reseller-node-icon' , ) , ) , 'items' => array ( array ( 'id' => 'reseller-site-url' , 'parent' => 'reseller-adminbar-icon' , 'title' => $ data [ 'reseller_title' ] , 'href' => $ data [ 'reseller_website_url' ] , 'meta' => array ( 'class' => 'reseller-dropdown' , 'target' => '_blank' , 'title' => $ data [ 'reseller_title' ] , ) , ) , array ( 'id' => 'reseller-support-center' , 'parent' => 'reseller-adminbar-icon' , 'title' => esc_html__ ( 'Support Center' , 'boldgrid-library' ) , 'href' => $ data [ 'reseller_support_url' ] , 'meta' => array ( 'class' => 'reseller-dropdown' , 'target' => '_blank' , 'title' => __ ( 'Support Center' , 'boldgrid-library' ) , ) , ) , array ( 'id' => 'reseller-amp-login' , 'parent' => 'reseller-adminbar-icon' , 'title' => esc_html__ ( 'AMP Login' , 'boldgrid-library' ) , 'href' => $ data [ 'reseller_amp_url' ] , 'meta' => array ( 'class' => 'reseller-dropdown' , 'target' => '_blank' , 'title' => __ ( 'Account Management' , 'boldgrid-library' ) , ) , ) , ) , ) ; } | Get the menu items for this location . |
15,406 | protected function addRemoveFromAllTemplates ( $ eventType ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } try { if ( null !== $ object = $ this -> getExistingObject ( ) ) { $ event = new FeatureEvent ( $ object ) ; $ this -> dispatch ( $ eventType , $ event ) ; } } catch ( \ Exception $ ex ) { return $ this -> errorPage ( $ ex ) ; } return $ this -> redirectToListTemplate ( ) ; } | Add or Remove from all product templates |
15,407 | public function manipulateTreePrickerForSortOrder ( ManipulateWidgetEvent $ event ) { $ widget = $ event -> getWidget ( ) ; if ( ! ( $ widget instanceof TreePicker ) ) { return ; } $ options = ( array ) $ widget -> options ; if ( 0 === \ count ( $ options ) ) { return ; } $ model = $ event -> getModel ( ) ; if ( ! ( $ model instanceof Model ) ) { return ; } $ attribute = $ model -> getItem ( ) -> getAttribute ( $ widget -> strField ) ; if ( ! ( $ attribute instanceof AbstractTags ) ) { return ; } $ widget -> orderField = $ widget -> orderField . '__ordered' ; $ ordered = \ array_flip ( \ array_merge ( [ ] , ( array ) $ model -> getProperty ( $ widget -> strField ) ) ) ; foreach ( $ options as $ option ) { $ ordered [ $ option [ 'value' ] ] = $ option [ 'value' ] ; } $ widget -> { $ widget -> orderField } = $ ordered ; } | Manipulate the tree picker for sort order . |
15,408 | public function ajaxRedirect ( string $ destination , array $ args = [ ] ) : void { $ this -> payload -> forceRedirect = $ this -> link ( $ destination , $ args ) ; $ this -> sendPayload ( ) ; } | Presmerovani ajaxoveho pozadavku |
15,409 | public function serializeConditionCollection ( ConditionCollection $ collection ) { if ( $ collection -> count ( ) == 0 ) { $ conditionNone = $ this -> container -> get ( 'thelia.condition.match_for_everyone' ) ; $ collection [ ] = $ conditionNone ; } $ serializableConditions = [ ] ; foreach ( $ collection as $ condition ) { $ serializableConditions [ ] = $ condition -> getSerializableCondition ( ) ; } return base64_encode ( json_encode ( $ serializableConditions ) ) ; } | Serialize a collection of conditions |
15,410 | public function unserializeConditionCollection ( $ serializedConditions ) { $ unserializedConditions = json_decode ( base64_decode ( $ serializedConditions ) ) ; $ collection = new ConditionCollection ( ) ; if ( ! empty ( $ unserializedConditions ) ) { foreach ( $ unserializedConditions as $ condition ) { if ( $ this -> container -> has ( $ condition -> conditionServiceId ) ) { $ conditionManager = $ this -> build ( $ condition -> conditionServiceId , ( array ) $ condition -> operators , ( array ) $ condition -> values ) ; $ collection [ ] = clone $ conditionManager ; } } } return $ collection ; } | Unserialize a collection of conditions |
15,411 | public function build ( $ conditionServiceId , array $ operators , array $ values ) { if ( ! $ this -> container -> has ( $ conditionServiceId ) ) { return false ; } $ condition = $ this -> container -> get ( $ conditionServiceId ) ; $ condition -> setValidatorsFromForm ( $ operators , $ values ) ; return clone $ condition ; } | Build a Condition from form |
15,412 | public function getInputsFromServiceId ( $ conditionServiceId ) { if ( ! $ this -> container -> has ( $ conditionServiceId ) ) { return false ; } $ condition = $ this -> container -> get ( $ conditionServiceId ) ; return $ this -> getInputsFromConditionInterface ( $ condition ) ; } | Get Condition inputs from serviceId |
15,413 | public function getConfigValue ( $ moduleId , $ variableName , $ defaultValue = null , $ valueLocale = null ) { $ value = null ; $ configValue = self :: create ( ) -> filterByModuleId ( $ moduleId ) -> filterByName ( $ variableName ) -> findOne ( ) ; ; if ( null !== $ configValue ) { if ( null !== $ valueLocale ) { $ configValue -> setLocale ( $ valueLocale ) ; } $ value = $ configValue -> getValue ( ) ; } return $ value === null ? $ defaultValue : $ value ; } | Get a module s configuration variable |
15,414 | public function setConfigValue ( $ moduleId , $ variableName , $ variableValue , $ valueLocale = null , $ createIfNotExists = true ) { $ configValue = self :: create ( ) -> filterByModuleId ( $ moduleId ) -> filterByName ( $ variableName ) -> findOne ( ) ; ; if ( null === $ configValue ) { if ( true === $ createIfNotExists ) { $ configValue = new ModuleConfig ( ) ; $ configValue -> setModuleId ( $ moduleId ) -> setName ( $ variableName ) ; } else { throw new \ LogicException ( "Module configuration variable $variableName does not exists. Create it first." ) ; } } if ( null !== $ valueLocale ) { $ configValue -> setLocale ( $ valueLocale ) ; } $ configValue -> setValue ( $ variableValue ) -> save ( ) ; ; return $ this ; } | Set module configuration variable creating it if required |
15,415 | public function deleteConfigValue ( $ moduleId , $ variableName ) { if ( null !== $ moduleConfig = self :: create ( ) -> filterByModuleId ( $ moduleId ) -> filterByName ( $ variableName ) -> findOne ( ) ) { $ moduleConfig -> delete ( ) ; } ; return $ this ; } | Delete a module s configuration variable |
15,416 | public function auto_update_plugin ( $ update , $ item ) { if ( ! apply_filters ( 'Boldgrid\Library\Update\isEnalbed' , false ) ) { return $ update ; } $ pluginAutoupdate = \ Boldgrid \ Library \ Util \ Option :: get ( 'plugin_autoupdate' ) ; if ( ! empty ( $ pluginAutoupdate ) || ! empty ( $ this -> settings [ 'plugins' ] [ $ item -> plugin ] ) || ( ! isset ( $ this -> settings [ 'plugins' ] [ $ item -> plugin ] ) && ! empty ( $ this -> settings [ 'plugins' ] [ 'default' ] ) ) ) { $ update = true ; } return $ update ; } | Auto update plugin . |
15,417 | public function auto_update_theme ( $ update , $ item ) { if ( ! apply_filters ( 'Boldgrid\Library\Update\isEnalbed' , false ) ) { return $ update ; } $ themeAutoupdate = \ Boldgrid \ Library \ Util \ Option :: get ( 'theme_autoupdate' ) ; if ( ! empty ( $ themeAutoupdate ) || ! empty ( $ this -> settings [ 'themes' ] [ $ item -> theme ] ) || ( ! isset ( $ this -> settings [ 'themes' ] [ $ item -> theme ] ) && ! empty ( $ this -> settings [ 'themes' ] [ 'default' ] ) ) ) { $ update = true ; } return $ update ; } | Auto update theme . |
15,418 | public static function create ( $ ns = NULL ) { $ node = new RootNode ( ) ; $ node -> addChild ( Token :: openTag ( ) ) ; if ( is_string ( $ ns ) && $ ns ) { NamespaceNode :: create ( $ ns ) -> appendTo ( $ node ) -> after ( Token :: newline ( ) ) ; } return $ node ; } | Creates a new blank PHP source file . |
15,419 | public function getNamespace ( $ ns ) { $ namespaces = $ this -> getNamespaces ( ) -> filter ( function ( NamespaceNode $ node ) use ( $ ns ) { return $ node -> getName ( ) -> getPath ( ) === $ ns ; } ) ; return $ namespaces -> isEmpty ( ) ? NULL : $ namespaces [ 0 ] ; } | Returns a particular namespace if it exists . |
15,420 | public function getNamespaceNames ( $ absolute = FALSE ) { $ iterator = function ( NamespaceNode $ ns ) use ( $ absolute ) { $ name = $ ns -> getName ( ) ; return $ absolute ? $ name -> getAbsolutePath ( ) : $ name -> getPath ( ) ; } ; return array_map ( $ iterator , $ this -> getNamespaces ( ) -> toArray ( ) ) ; } | Returns the name of every namespace in this document . |
15,421 | public function getSitePages ( $ siteId ) { $ results = array ( ) ; $ arrayParameters = $ this -> makeArrayFromParameters ( __METHOD__ , func_get_args ( ) ) ; $ arrayParameters = $ this -> sendEvent ( 'meliscmssite_service_get_site_pages_start' , $ arrayParameters ) ; $ siteTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ site = $ siteTable -> getEntryById ( $ arrayParameters [ 'siteId' ] ) -> current ( ) ; if ( ! empty ( $ site ) ) { $ pages = $ siteTable -> getSiteSavedPagesById ( $ site -> site_id ) -> toArray ( ) ; if ( ! empty ( $ pages ) ) { $ site -> pages = $ pages ; } $ results = $ site ; } $ arrayParameters [ 'results' ] = $ results ; $ arrayParameters = $ this -> sendEvent ( 'meliscmssite_service_get_site_pages_start' , $ arrayParameters ) ; return $ arrayParameters [ 'results' ] ; } | This method will return the page of a site |
15,422 | private function createSitePage ( $ siteName , $ fatherId , $ siteLangId , $ pageType , $ pageId , $ templateId , $ platformId ) { $ arrayParameters = $ this -> makeArrayFromParameters ( __METHOD__ , func_get_args ( ) ) ; $ arrayParameters = $ this -> sendEvent ( 'meliscmssite_service_save_site_page_start' , $ arrayParameters ) ; $ pageTreeTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageTree' ) ; $ pageLangTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageLang' ) ; $ pageSavedTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageSaved' ) ; $ cmsPlatformTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePlatformIds' ) ; $ treePageOrder = $ pageTreeTable -> getTotalData ( 'tree_father_page_id' , $ fatherId ) ; $ pageTreeTable -> save ( array ( 'tree_page_id' => $ arrayParameters [ 'pageId' ] , 'tree_father_page_id' => $ fatherId , 'tree_page_order' => $ treePageOrder + 1 , ) ) ; $ pageLangTable -> save ( array ( 'plang_page_id' => $ arrayParameters [ 'pageId' ] , 'plang_lang_id' => $ arrayParameters [ 'siteLangId' ] , 'plang_page_id_initial' => $ arrayParameters [ 'pageId' ] ) ) ; $ pageSavedTable -> save ( array ( 'page_id' => $ arrayParameters [ 'pageId' ] , 'page_type' => $ arrayParameters [ 'pageType' ] , 'page_status' => 1 , 'page_menu' => 'LINK' , 'page_name' => $ arrayParameters [ 'siteName' ] , 'page_tpl_id' => $ arrayParameters [ 'templateId' ] , 'page_content' => '<?xml version="1.0" encoding="UTF-8"?><document type="MelisCMS" author="MelisTechnology" version="2.0"></document>' , 'page_taxonomy' => '' , 'page_creation_date' => date ( 'Y-m-d H:i:s' ) ) ) ; $ platform = array ( 'pids_page_id_current' => ++ $ arrayParameters [ 'pageId' ] ) ; $ cmsPlatformTable -> save ( $ platform , $ arrayParameters [ 'platformId' ] ) ; $ arrayParameters [ 'results' ] = $ arrayParameters [ 'pageId' ] ; $ arrayParameters = $ this -> sendEvent ( 'meliscmssite_service_save_site_page_end' , $ arrayParameters ) ; return $ arrayParameters [ 'results' ] ; } | This method creating Site page |
15,423 | private function createSitePageTemplate ( $ tplId , $ siteId , $ siteName , $ tempName , $ controler , $ action , $ platformId ) { $ cmsTemplateTbl = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableTemplate' ) ; $ cmsPlatformTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePlatformIds' ) ; $ template = array ( 'tpl_id' => $ tplId , 'tpl_site_id' => $ siteId , 'tpl_name' => $ tempName , 'tpl_type' => 'ZF2' , 'tpl_zf2_website_folder' => $ siteName , 'tpl_zf2_layout' => 'defaultLayout' , 'tpl_zf2_controller' => $ controler , 'tpl_zf2_action' => $ action , 'tpl_php_path' => '' , 'tpl_creation_date' => date ( 'Y-m-d H:i:s' ) , ) ; $ templateId = $ cmsTemplateTbl -> save ( $ template ) ; $ platform = array ( 'pids_tpl_id_current' => ++ $ tplId ) ; $ cmsPlatformTable -> save ( $ platform , $ platformId ) ; return $ templateId ; } | This method creating Site page template |
15,424 | private function mapDirectory ( $ dir , $ targetModuleName , $ newModuleName ) { $ result = array ( ) ; $ cdir = scandir ( $ dir ) ; $ fileName = '' ; foreach ( $ cdir as $ key => $ value ) { if ( ! in_array ( $ value , array ( "." , ".." ) ) ) { if ( is_dir ( $ dir . '/' . $ value ) ) { if ( $ value == $ targetModuleName ) { rename ( $ dir . '/' . $ value , $ dir . '/' . $ newModuleName ) ; $ value = $ newModuleName ; } elseif ( $ value == $ this -> moduleNameToViewName ( $ targetModuleName ) ) { $ newModuleNameSnakeCase = $ this -> moduleNameToViewName ( $ newModuleName ) ; rename ( $ dir . '/' . $ value , $ dir . '/' . $ newModuleNameSnakeCase ) ; $ value = $ newModuleNameSnakeCase ; } $ result [ $ dir . '/' . $ value ] = $ this -> mapDirectory ( $ dir . '/' . $ value , $ targetModuleName , $ newModuleName ) ; } else { $ newFileName = str_replace ( $ targetModuleName , $ newModuleName , $ value ) ; if ( $ value != $ newFileName ) { rename ( $ dir . '/' . $ value , $ dir . '/' . $ newFileName ) ; $ value = $ newFileName ; } $ result [ $ dir . '/' . $ value ] = $ value ; $ fileName = $ dir . '/' . $ value ; $ this -> replaceFileTextContent ( $ fileName , $ fileName , $ targetModuleName , $ newModuleName ) ; } } } return $ result ; } | This method will map a directory to change some specific word that match the target and replace by new word |
15,425 | private function generateModuleNameCase ( $ str ) { $ i = array ( "-" , "_" ) ; $ str = preg_replace ( '/([a-z])([A-Z])/' , "$1 $2" , $ str ) ; $ str = str_replace ( $ i , ' ' , $ str ) ; $ str = str_replace ( ' ' , '' , ucwords ( strtolower ( $ str ) ) ) ; $ str = strtolower ( substr ( $ str , 0 , 1 ) ) . substr ( $ str , 1 ) ; $ str = ucfirst ( $ str ) ; return $ str ; } | This will modified a string to valid zf2 module name |
15,426 | public function hasReturnTypes ( ) { $ doc_comment = $ this -> getDocComment ( ) ; if ( ! $ doc_comment ) { return FALSE ; } $ return_tag = $ doc_comment -> getReturn ( ) ; if ( ! $ return_tag ) { return FALSE ; } $ types = $ return_tag -> getTypes ( ) ; return ! empty ( $ types ) ; } | Return TRUE if function has phpDoc return type . |
15,427 | public function getReturnTypes ( ) { $ types = [ 'void' ] ; $ doc_comment = $ this -> getDocComment ( ) ; if ( ! $ doc_comment ) { return $ types ; } $ return_tag = $ doc_comment -> getReturn ( ) ; if ( ! $ return_tag ) { return $ types ; } $ types = Types :: normalize ( $ return_tag -> getTypes ( ) ) ; if ( empty ( $ types ) ) { $ types [ ] = 'void' ; } return $ types ; } | Get the return type of the function as defined by the doc comment . |
15,428 | protected function setDefaultTimezone ( ) { $ timezone = 'UTC' ; if ( is_link ( '/etc/localtime' ) ) { $ filename = readlink ( '/etc/localtime' ) ; if ( strpos ( $ filename , '/usr/share/zoneinfo/' ) === 0 ) { $ timezone = substr ( $ filename , 20 ) ; } } elseif ( file_exists ( '/etc/timezone' ) ) { $ data = file_get_contents ( '/etc/timezone' ) ; if ( $ data ) { $ timezone = trim ( $ data ) ; } } elseif ( file_exists ( '/etc/sysconfig/clock' ) ) { $ data = parse_ini_file ( '/etc/sysconfig/clock' ) ; if ( ! empty ( $ data [ 'ZONE' ] ) ) { $ timezone = trim ( $ data [ 'ZONE' ] ) ; } } date_default_timezone_set ( $ timezone ) ; } | Set the default timezone . |
15,429 | public function getUrl ( $ locale = null ) { if ( null === $ locale ) { $ locale = $ this -> getLocale ( ) ; } return URL :: getInstance ( ) -> retrieve ( $ this -> getRewrittenUrlViewName ( ) , $ this -> getId ( ) , $ locale ) -> toString ( ) ; } | Get the object URL for the given locale rewritten if rewriting is enabled . |
15,430 | public function generateRewrittenUrl ( $ locale ) { if ( $ this -> isNew ( ) ) { throw new \ RuntimeException ( sprintf ( 'Object %s must be saved before generating url' , $ this -> getRewrittenUrlViewName ( ) ) ) ; } $ this -> setLocale ( $ locale ) ; $ generateEvent = new GenerateRewrittenUrlEvent ( $ this , $ locale ) ; $ this -> dispatchEvent ( TheliaEvents :: GENERATE_REWRITTENURL , $ generateEvent ) ; if ( $ generateEvent -> isRewritten ( ) ) { return $ generateEvent -> getUrl ( ) ; } $ title = $ this -> getTitle ( ) ; if ( null == $ title ) { throw new \ RuntimeException ( 'Impossible to create an url if title is null' ) ; } $ string = preg_replace ( '/[^\w\-~_\.]+/u' , '-' , $ title ) ; $ cleanString = mb_strtolower ( preg_replace ( '/--+/u' , '-' , $ string ) , 'UTF-8' ) ; $ urlFilePart = rtrim ( $ cleanString , '.-~_' ) . ".html" ; try { $ i = 0 ; while ( URL :: getInstance ( ) -> resolve ( $ urlFilePart ) ) { $ i ++ ; $ urlFilePart = sprintf ( "%s-%d.html" , $ cleanString , $ i ) ; } } catch ( UrlRewritingException $ e ) { $ rewritingUrl = new RewritingUrl ( ) ; $ rewritingUrl -> setUrl ( $ urlFilePart ) -> setView ( $ this -> getRewrittenUrlViewName ( ) ) -> setViewId ( $ this -> getId ( ) ) -> setViewLocale ( $ locale ) -> save ( ) ; } return $ urlFilePart ; } | Generate a rewritten URL from the object title and store it in the rewriting table |
15,431 | public function getRewrittenUrl ( $ locale ) { $ rewritingUrl = RewritingUrlQuery :: create ( ) -> filterByViewLocale ( $ locale ) -> filterByView ( $ this -> getRewrittenUrlViewName ( ) ) -> filterByViewId ( $ this -> getId ( ) ) -> filterByRedirected ( null ) -> findOne ( ) ; if ( $ rewritingUrl ) { $ url = $ rewritingUrl -> getUrl ( ) ; } else { $ url = null ; } return $ url ; } | return the rewritten URL for the given locale |
15,432 | public function markRewrittenUrlObsolete ( ) { RewritingUrlQuery :: create ( ) -> filterByView ( $ this -> getRewrittenUrlViewName ( ) ) -> filterByViewId ( $ this -> getId ( ) ) -> update ( array ( "View" => ConfigQuery :: getObsoleteRewrittenUrlView ( ) ) ) ; } | Mark the current URL as obseolete |
15,433 | public function setRewrittenUrl ( $ locale , $ url ) { $ currentUrl = $ this -> getRewrittenUrl ( $ locale ) ; if ( $ currentUrl == $ url || null === $ url ) { return $ this ; } try { $ resolver = new RewritingResolver ( $ url ) ; if ( null === $ resolver -> redirectedToUrl ) { if ( $ resolver -> view == $ this -> getRewrittenUrlViewName ( ) && $ resolver -> viewId == $ this -> getId ( ) ) { if ( $ resolver -> locale != $ locale ) { throw new UrlRewritingException ( Translator :: getInstance ( ) -> trans ( 'URL_ALREADY_EXISTS' ) , UrlRewritingException :: URL_ALREADY_EXISTS ) ; } if ( \ count ( $ resolver -> otherParameters ) > 0 ) { throw new UrlRewritingException ( Translator :: getInstance ( ) -> trans ( 'URL_ALREADY_EXISTS' ) , UrlRewritingException :: URL_ALREADY_EXISTS ) ; } } else { throw new UrlRewritingException ( Translator :: getInstance ( ) -> trans ( 'URL_ALREADY_EXISTS' ) , UrlRewritingException :: URL_ALREADY_EXISTS ) ; } } } catch ( UrlRewritingException $ e ) { if ( $ e -> getCode ( ) !== UrlRewritingException :: URL_NOT_FOUND ) { throw $ e ; } } if ( isset ( $ resolver ) ) { $ rewritingUrl = RewritingUrlQuery :: create ( ) -> findOneByUrl ( $ url ) ; $ rewritingUrl -> setView ( $ this -> getRewrittenUrlViewName ( ) ) -> setViewId ( $ this -> getId ( ) ) -> setViewLocale ( $ locale ) -> setRedirected ( null ) -> save ( ) ; RewritingArgumentQuery :: create ( ) -> filterByRewritingUrl ( $ rewritingUrl ) -> deleteAll ( ) ; } else { $ rewritingUrl = new RewritingUrl ( ) ; $ rewritingUrl -> setUrl ( $ url ) -> setView ( $ this -> getRewrittenUrlViewName ( ) ) -> setViewId ( $ this -> getId ( ) ) -> setViewLocale ( $ locale ) -> save ( ) ; } if ( null !== $ oldRewritingUrl = RewritingUrlQuery :: create ( ) -> findOneByUrl ( $ currentUrl ) ) { $ oldRewritingUrl -> setRedirected ( $ rewritingUrl -> getId ( ) ) -> save ( ) ; } return $ this ; } | Set the rewritten URL for the given locale |
15,434 | public static function create ( $ name , ExpressionNode $ value = NULL , $ visibility = 'public' ) { $ code = $ visibility . ' $' . ltrim ( $ name , '$' ) ; if ( $ value instanceof ExpressionNode ) { $ code .= ' = ' . $ value -> getText ( ) ; } $ class_node = Parser :: parseSnippet ( 'class Foo { ' . $ code . '; }' ) ; return $ class_node -> getStatements ( ) [ 0 ] -> remove ( ) ; } | Creates a new class member . |
15,435 | public static function adminBarNode ( $ wpAdminBar , $ configs ) { $ wpAdminBar -> add_node ( $ configs [ 'topLevel' ] ) ; foreach ( $ configs [ 'items' ] as $ item ) { $ wpAdminBar -> add_menu ( $ item ) ; } } | Given a configuration of menu items to be added on |
15,436 | public static function setVal ( $ metaKey , $ elementKey , $ elementId , $ value ) { $ data = self :: create ( ) -> filterByMetaKey ( $ metaKey ) -> filterByElementKey ( $ elementKey ) -> filterByElementId ( $ elementId ) -> findOne ( ) ; if ( null === $ data ) { $ data = new MetaData ( ) ; $ data -> setMetaKey ( $ metaKey ) ; $ data -> setElementKey ( $ elementKey ) ; $ data -> setElementId ( $ elementId ) ; } $ data -> setValue ( $ value ) ; $ data -> save ( ) ; } | Add or update the MetaData element |
15,437 | public function setName ( $ name ) { $ identifier = $ this -> name -> firstChild ( ) ; $ identifier -> setText ( $ name ) ; return $ this ; } | Set the identifier name of this node . |
15,438 | public function inNamespace ( $ ns ) { if ( is_string ( $ ns ) ) { $ namespace_node = $ this -> name -> getNamespace ( ) ; $ namespace = $ namespace_node === NULL ? '' : $ namespace_node -> getName ( ) -> getAbsolutePath ( ) ; return $ ns === $ namespace ; } elseif ( $ ns instanceof NamespaceNode ) { return $ this -> name -> getNamespace ( ) === $ ns ; } else { throw new \ InvalidArgumentException ( ) ; } } | Determine if this node belongs to namespace . |
15,439 | public function renderServer ( ) : void { $ this -> addBreadcrumbLink ( 'dockbar.info.server' ) ; $ this -> template -> refresh = $ this -> refresh ; $ this -> template -> system = $ this -> app -> info -> system ; $ this -> template -> fileSystem = $ this -> app -> info -> fileSystem ; $ this -> template -> hardware = $ this -> app -> info -> hardware ; $ this -> template -> memory = $ this -> app -> info -> memory ; $ this -> template -> network = $ this -> app -> info -> network ; } | Zobrazeni informaci o serveru |
15,440 | public function renderPhp ( ) : void { $ this -> addBreadcrumbLink ( 'dockbar.info.php' ) ; $ this -> template -> php = $ this -> app -> info -> phpInfo ; } | Zobrazeni informaci o PHP |
15,441 | public function setState ( int $ id , bool $ value ) : void { if ( $ this -> isAjax ( ) ) { $ user = $ this -> orm -> users -> getById ( $ id ) ; $ user -> active = $ value ; $ this -> orm -> persistAndFlush ( $ user ) ; $ this [ 'userList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Ulozi stav uzivatele |
15,442 | protected function createComponentAddForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addProtection ( ) ; $ form -> addText ( 'username' , 'cms.user.username' ) -> setRequired ( ) ; $ form -> addText ( 'firstName' , 'cms.user.firstName' ) ; $ form -> addText ( 'surname' , 'cms.user.surname' ) ; $ form -> addText ( 'email' , 'cms.user.email' ) -> setRequired ( ) -> addRule ( Form :: EMAIL ) ; $ form -> addPhone ( 'phone' , 'cms.user.phone' ) ; $ form -> addSelectUntranslated ( 'language' , 'cms.user.language' , $ this -> localeService -> allowed , 'form.none' ) ; $ form -> addMultiSelectUntranslated ( 'roles' , 'cms.permissions.roles' , $ this -> orm -> aclRoles -> fetchPairs ( $ this -> user -> isAllowed ( 'dockbar.settings.permissions.superadmin' , 'view' ) ) ) -> setRequired ( ) ; if ( $ this -> configurator -> sendNewUserPassword ) { $ form -> addCheckbox ( 'generatePassword' , 'cms.user.generatePassword' ) -> addCondition ( $ form :: EQUAL , false ) -> toggle ( 'password' ) -> toggle ( 'passwordVerify' ) ; } else { $ form -> addHidden ( 'generatePassword' , false ) ; } $ form -> addPassword ( 'password' , 'cms.user.newPassword' ) -> setOption ( 'id' , 'password' ) -> addConditionOn ( $ form [ 'generatePassword' ] , Form :: EQUAL , false ) -> setRequired ( ) -> addRule ( Form :: MIN_LENGTH , null , $ this -> minPasswordLength ) -> endCondition ( ) ; $ form -> addPassword ( 'passwordVerify' , 'cms.user.passwordVerify' ) -> setOption ( 'id' , 'passwordVerify' ) -> addConditionOn ( $ form [ 'generatePassword' ] , Form :: EQUAL , false ) -> setRequired ( ) -> addRule ( Form :: EQUAL , null , $ form [ 'password' ] ) -> endCondition ( ) ; $ form -> addSubmit ( 'save' , 'form.save' ) ; $ form -> addLink ( 'back' , 'form.back' , $ this -> getBacklink ( ) ) ; $ form -> onSuccess [ ] = [ $ this , 'addFormSucceeded' ] ; return $ form ; } | Formular pridani uzivatele |
15,443 | public function addFormSucceeded ( Form $ form , ArrayHash $ values ) : void { if ( $ values -> generatePassword ) { $ password = Random :: generate ( $ this -> minPasswordLength , $ this -> passwordChars ) ; } else { $ password = $ values -> password ; } $ user = new User ; $ this -> orm -> users -> attach ( $ user ) ; try { $ user -> setUsername ( $ values -> username ) ; } catch ( UniqueConstraintViolationException $ ex ) { $ form -> addError ( 'cms.user.duplicityUsername' ) ; return ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidUsername' ) ; return ; } try { $ user -> setEmail ( $ values -> email ) ; } catch ( UniqueConstraintViolationException $ ex ) { $ form -> addError ( 'cms.user.duplicityEmail' ) ; return ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidUsername' ) ; return ; } try { $ user -> setPhone ( $ values -> phone ? : null ) ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidPhone' ) ; return ; } $ user -> firstName = $ values -> firstName ; $ user -> surname = $ values -> surname ; $ language = $ this -> localeService -> getById ( $ values -> language ) ; $ user -> language = $ language === null ? null : $ language -> name ; $ user -> roles -> set ( $ values -> roles ) ; $ user -> setPassword ( $ password ) ; $ this -> orm -> persistAndFlush ( $ user ) ; if ( $ this -> configurator -> sendNewUserPassword ) { $ this -> mailer -> sendNewUser ( $ user -> email , $ user -> username , $ password ) ; } $ this -> flashNotifier -> success ( 'cms.user.dataSaved' ) ; $ this -> restoreBacklink ( ) ; } | Zpracovani noveho uzivatele |
15,444 | protected function createComponentEditForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addProtection ( ) ; $ form -> addText ( 'username' , 'cms.user.username' ) -> setDefaultValue ( $ this -> currentUser -> username ) -> setRequired ( ) ; $ form -> addText ( 'firstName' , 'cms.user.firstName' ) -> setDefaultValue ( $ this -> currentUser -> firstName ) ; $ form -> addText ( 'surname' , 'cms.user.surname' ) -> setDefaultValue ( $ this -> currentUser -> surname ) ; $ form -> addText ( 'email' , 'cms.user.email' ) -> setDefaultValue ( $ this -> currentUser -> email ) -> setRequired ( ) -> addRule ( Form :: EMAIL ) ; $ form -> addPhone ( 'phone' , 'cms.user.phone' ) -> setDefaultValue ( $ this -> currentUser -> phone ) ; $ language = $ form -> addSelectUntranslated ( 'language' , 'cms.user.language' , $ this -> localeService -> allowed , 'form.none' ) ; if ( ! empty ( $ this -> currentUser -> language ) ) { $ locale = $ this -> localeService -> get ( $ this -> currentUser -> language ) ; if ( $ locale ) { $ language -> setDefaultValue ( $ locale -> id ) ; } } $ roles = $ form -> addMultiSelectUntranslated ( 'roles' , 'cms.permissions.roles' , $ this -> orm -> aclRoles -> fetchPairs ( $ this -> user -> isAllowed ( 'dockbar.settings.permissions.superadmin' , 'view' ) ) ) -> setRequired ( ) ; try { $ roles -> setDefaultValue ( $ this -> currentUser -> roles -> getRawValue ( ) ) ; } catch ( InvalidArgumentException $ ex ) { } $ form -> addSubmit ( 'save' , 'form.save' ) ; $ form -> addLink ( 'back' , 'form.back' , $ this -> getBacklink ( ) ) ; $ form -> onSuccess [ ] = [ $ this , 'editFormSucceeded' ] ; return $ form ; } | Formular editace uzivatele |
15,445 | public function editFormSucceeded ( Form $ form , ArrayHash $ values ) : void { try { $ this -> currentUser -> setUsername ( $ values -> username ) ; } catch ( UniqueConstraintViolationException $ ex ) { $ form -> addError ( 'cms.user.duplicityUsername' ) ; return ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidUsername' ) ; return ; } try { $ this -> currentUser -> setEmail ( $ values -> email ) ; } catch ( UniqueConstraintViolationException $ ex ) { $ form -> addError ( 'cms.user.duplicityEmail' ) ; return ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidUsername' ) ; return ; } try { $ this -> currentUser -> setPhone ( $ values -> phone ? : null ) ; } catch ( InvalidArgumentException $ ex ) { $ form -> addError ( 'cms.user.invalidPhone' ) ; return ; } $ this -> currentUser -> firstName = $ values -> firstName ; $ this -> currentUser -> surname = $ values -> surname ; $ this -> currentUser -> roles -> set ( $ values -> roles ) ; $ language = $ this -> localeService -> getById ( $ values -> language ) ; $ this -> currentUser -> language = $ language === null ? null : $ language -> name ; $ this -> orm -> persistAndFlush ( $ this -> currentUser ) ; $ this -> flashNotifier -> success ( 'cms.user.dataSaved' ) ; $ this -> restoreBacklink ( ) ; } | Zpracovani editace uzivatele |
15,446 | public function passwordFormSucceeded ( Form $ form , ArrayHash $ values ) : void { if ( $ values -> generatePassword ) { $ password = Random :: generate ( $ this -> minPasswordLength , $ this -> passwordChars ) ; } else { $ password = $ values -> password ; } $ this -> currentUser -> setPassword ( $ password ) ; $ this -> orm -> persistAndFlush ( $ this -> currentUser ) ; if ( $ this -> configurator -> sendChangePassword ) { $ this -> mailer -> sendNewPassword ( $ this -> currentUser -> email , $ this -> currentUser -> username , $ password ) ; } $ this -> flashNotifier -> success ( 'cms.user.passwordChanged' ) ; $ this -> restoreBacklink ( ) ; } | Zpracovani zmeny hesla |
15,447 | public static function findAllChild ( $ folderId , $ depth = 0 , $ currentPosition = 0 ) { $ result = array ( ) ; if ( \ is_array ( $ folderId ) ) { foreach ( $ folderId as $ folderSingleId ) { $ result = array_merge ( $ result , ( array ) self :: findAllChild ( $ folderSingleId , $ depth , $ currentPosition ) ) ; } } else { $ currentPosition ++ ; if ( $ depth == $ currentPosition && $ depth != 0 ) { return [ ] ; } $ categories = self :: create ( ) -> filterByParent ( $ folderId ) -> find ( ) ; foreach ( $ categories as $ folder ) { array_push ( $ result , $ folder ) ; $ result = array_merge ( $ result , ( array ) self :: findAllChild ( $ folder -> getId ( ) , $ depth , $ currentPosition ) ) ; } } return $ result ; } | find all contents for a given folder . |
15,448 | public static function generateToken ( ) { $ raw = self :: getOpenSSLRandom ( ) ; if ( false === $ raw ) { $ raw = self :: getComplexRandom ( ) ; } return md5 ( $ raw ) ; } | Same method as getToken but can be called statically |
15,449 | public function indexAction ( $ _view = 'import' ) { $ authResponse = $ this -> checkAuth ( [ AdminResources :: IMPORT ] , [ ] , [ AccessManager :: VIEW ] ) ; if ( $ authResponse !== null ) { return $ authResponse ; } $ this -> getParserContext ( ) -> set ( 'category_order' , $ this -> getRequest ( ) -> query -> get ( 'category_order' , 'manual' ) ) -> set ( 'import_order' , $ this -> getRequest ( ) -> query -> get ( 'import_order' , 'manual' ) ) ; return $ this -> render ( $ _view ) ; } | Handle default action that is list available imports |
15,450 | public function changeImportPositionAction ( ) { $ authResponse = $ this -> checkAuth ( [ AdminResources :: IMPORT ] , [ ] , [ AccessManager :: UPDATE ] ) ; if ( $ authResponse !== null ) { return $ authResponse ; } $ query = $ this -> getRequest ( ) -> query ; $ this -> dispatch ( TheliaEvents :: IMPORT_CHANGE_POSITION , new UpdatePositionEvent ( $ query -> get ( 'id' ) , $ this -> matchPositionMode ( $ query -> get ( 'mode' ) ) , $ query -> get ( 'value' ) ) ) ; return $ this -> generateRedirectFromRoute ( 'import.list' ) ; } | Handle import position change action |
15,451 | protected function matchPositionMode ( $ mode ) { if ( $ mode === 'up' ) { return UpdatePositionEvent :: POSITION_UP ; } if ( $ mode === 'down' ) { return UpdatePositionEvent :: POSITION_DOWN ; } return UpdatePositionEvent :: POSITION_ABSOLUTE ; } | Match position mode string against position mode constant value |
15,452 | public function configureAction ( $ id ) { $ importHandler = $ this -> container -> get ( 'thelia.import.handler' ) ; $ import = $ importHandler -> getImport ( $ id ) ; if ( $ import === null ) { return $ this -> pageNotFound ( ) ; } $ extensions = [ ] ; $ mimeTypes = [ ] ; foreach ( $ this -> container -> get ( RegisterSerializerPass :: MANAGER_SERVICE_ID ) -> getSerializers ( ) as $ serializer ) { $ extensions [ ] = $ serializer -> getExtension ( ) ; $ mimeTypes [ ] = $ serializer -> getMimeType ( ) ; } foreach ( $ this -> container -> get ( RegisterArchiverPass :: MANAGER_SERVICE_ID ) -> getArchivers ( true ) as $ archiver ) { $ extensions [ ] = $ archiver -> getExtension ( ) ; $ mimeTypes [ ] = $ archiver -> getMimeType ( ) ; } $ templateName = 'import-page' ; if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ templateName = 'ajax/import-modal' ; } return $ this -> render ( $ templateName , [ 'importId' => $ id , 'ALLOWED_MIME_TYPES' => implode ( ', ' , $ mimeTypes ) , 'ALLOWED_EXTENSIONS' => implode ( ', ' , $ extensions ) , ] ) ; } | Display import configuration view |
15,453 | public function importAction ( $ id ) { $ importHandler = $ this -> container -> get ( 'thelia.import.handler' ) ; $ import = $ importHandler -> getImport ( $ id ) ; if ( $ import === null ) { return $ this -> pageNotFound ( ) ; } $ form = $ this -> createForm ( AdminForm :: IMPORT ) ; try { $ validatedForm = $ this -> validateForm ( $ form ) ; $ file = $ validatedForm -> get ( 'file_upload' ) -> getData ( ) ; $ file = $ file -> move ( THELIA_CACHE_DIR . 'import' . DS . ( new \ DateTime ) -> format ( 'Ymd' ) , uniqid ( ) . '-' . $ file -> getClientOriginalName ( ) ) ; $ lang = ( new LangQuery ) -> findPk ( $ validatedForm -> get ( 'language' ) -> getData ( ) ) ; $ importEvent = $ importHandler -> import ( $ import , $ file , $ lang ) ; if ( \ count ( $ importEvent -> getErrors ( ) ) > 0 ) { $ this -> getSession ( ) -> getFlashBag ( ) -> add ( 'thelia.import.error' , $ this -> getTranslator ( ) -> trans ( 'Error(s) in import :<br />%errors' , [ '%errors' => implode ( '<br />' , $ importEvent -> getErrors ( ) ) ] ) ) ; } $ this -> getSession ( ) -> getFlashBag ( ) -> add ( 'thelia.import.success' , $ this -> getTranslator ( ) -> trans ( 'Import successfully done, %count row(s) have been changed' , [ '%count' => $ importEvent -> getImport ( ) -> getImportedRows ( ) ] ) ) ; return $ this -> generateRedirectFromRoute ( 'import.view' , [ ] , [ 'id' => $ id ] ) ; } catch ( FormValidationException $ e ) { $ form -> setErrorMessage ( $ this -> createStandardFormValidationErrorMessage ( $ e ) ) ; } catch ( \ Exception $ e ) { $ this -> getParserContext ( ) -> setGeneralError ( $ e -> getMessage ( ) ) ; } $ this -> getParserContext ( ) -> addForm ( $ form ) ; return $ this -> configureAction ( $ id ) ; } | Handle import action |
15,454 | public function getMeter ( $ meterIdentifier ) { $ item_key = $ this -> getCacheKey ( $ meterIdentifier ) ; if ( ! ( $ meter = $ this -> cacheService -> retrieve ( $ item_key ) ) ) { try { $ meter = $ this -> meterStorage -> getMeter ( $ meterIdentifier ) ; } catch ( \ Exception $ e ) { $ meter = array ( ) ; } $ this -> cacheService -> store ( $ item_key , $ meter , $ this -> cacheExpires ) ; } return $ meter ; } | Gets the pulsar meter from cache or db |
15,455 | public static function normalize ( $ types ) { $ normalized_types = [ ] ; foreach ( $ types as $ type ) { switch ( $ type ) { case 'boolean' : $ normalized_types [ ] = 'bool' ; break ; case 'integer' : $ normalized_types [ ] = 'int' ; break ; case 'double' : $ normalized_types [ ] = 'float' ; break ; case 'callback' : $ normalized_types [ ] = 'callable' ; break ; case 'scalar' : $ normalized_types [ ] = 'bool' ; $ normalized_types [ ] = 'int' ; $ normalized_types [ ] = 'float' ; $ normalized_types [ ] = 'string' ; break ; default : $ normalized_types [ ] = $ type ; break ; } } return $ normalized_types ; } | Normalize phpDoc type keywords as per PSR - 5 . |
15,456 | public function getTypes ( ) { $ types = [ 'mixed' ] ; $ doc_comment = $ this -> getDocComment ( ) ; if ( ! $ doc_comment ) { return $ types ; } $ doc_block = $ doc_comment -> getDocBlock ( ) ; $ var_tags = $ doc_block -> getTagsByName ( 'var' ) ; if ( empty ( $ var_tags ) ) { return $ types ; } $ var_tag = reset ( $ var_tags ) ; return Types :: normalize ( $ var_tag -> getTypes ( ) ) ; } | Get the type of the members as defined by doc comment . |
15,457 | public function prependItem ( Node $ item ) { if ( $ this -> getItems ( ) -> isEmpty ( ) ) { $ this -> append ( $ item ) ; } else { $ this -> prepend ( [ $ item , Token :: comma ( ) , Token :: space ( ) , ] ) ; } return $ this ; } | Prepend item . |
15,458 | public function appendItem ( Node $ item ) { if ( $ this -> getItems ( ) -> isEmpty ( ) ) { $ this -> append ( $ item ) ; } else { $ this -> append ( [ Token :: comma ( ) , Token :: space ( ) , $ item , ] ) ; } return $ this ; } | Append item . |
15,459 | public function insertItem ( Node $ item , $ index ) { $ items = $ this -> getItems ( ) ; if ( $ items -> isEmpty ( ) ) { if ( $ index !== 0 ) { throw new \ OutOfBoundsException ( 'index out of bounds' ) ; } $ this -> append ( $ item ) ; } else { $ max_index = count ( $ items ) - 1 ; if ( $ index < 0 || $ index > $ max_index ) { throw new \ OutOfBoundsException ( 'index out of bounds' ) ; } $ items [ $ index ] -> before ( [ $ item , Token :: comma ( ) , Token :: space ( ) , ] ) ; } return $ this ; } | Insert item before index . |
15,460 | public function pop ( ) { $ items = $ this -> getItems ( ) ; if ( $ items -> isEmpty ( ) ) { return NULL ; } if ( count ( $ items ) === 1 ) { $ pop_item = $ items [ 0 ] ; $ pop_item -> remove ( ) ; return $ pop_item ; } $ pop_item = $ items [ count ( $ items ) - 1 ] ; $ pop_item -> previousUntil ( function ( $ node ) { if ( $ node instanceof HiddenNode ) { return FALSE ; } if ( $ node instanceof TokenNode && $ node -> getType ( ) === ',' ) { return FALSE ; } return TRUE ; } ) -> remove ( ) ; $ pop_item -> remove ( ) ; return $ pop_item ; } | Pop an item off end of the list . |
15,461 | public function shift ( ) { $ items = $ this -> getItems ( ) ; if ( $ items -> isEmpty ( ) ) { return NULL ; } if ( count ( $ items ) === 1 ) { $ pop_item = $ items [ 0 ] ; $ pop_item -> remove ( ) ; return $ pop_item ; } $ pop_item = $ items [ 0 ] ; $ pop_item -> nextUntil ( function ( $ node ) { if ( $ node instanceof HiddenNode ) { return FALSE ; } if ( $ node instanceof TokenNode && $ node -> getType ( ) === ',' ) { return FALSE ; } return TRUE ; } ) -> remove ( ) ; $ pop_item -> remove ( ) ; return $ pop_item ; } | Shift an item off start of the list . |
15,462 | public function toArrayNode ( ) { return ( $ this -> parent instanceof ArrayNode ) ? clone $ this -> parent : Parser :: parseExpression ( '[' . $ this -> getText ( ) . ']' ) ; } | Returns this comma list as an ArrayNode . |
15,463 | public function generateGatewayFormResponse ( $ order , $ gateway_url , $ form_data ) { $ parser = $ this -> getContainer ( ) -> get ( "thelia.parser" ) ; $ parser -> setTemplateDefinition ( $ parser -> getTemplateHelper ( ) -> getActiveFrontTemplate ( ) ) ; $ renderedTemplate = $ parser -> render ( "order-payment-gateway.html" , array ( "order_id" => $ order -> getId ( ) , "cart_count" => $ this -> getRequest ( ) -> getSession ( ) -> getSessionCart ( $ this -> getDispatcher ( ) ) -> getCartItems ( ) -> count ( ) , "gateway_url" => $ gateway_url , "payment_form_data" => $ form_data ) ) ; return Response :: create ( $ renderedTemplate ) ; } | Render the payment gateway template . The module should provide the gateway URL and the form fields names and values . |
15,464 | public function getPaymentSuccessPageUrl ( $ order_id ) { $ frontOfficeRouter = $ this -> getContainer ( ) -> get ( 'router.front' ) ; return URL :: getInstance ( ) -> absoluteUrl ( $ frontOfficeRouter -> generate ( "order.placed" , array ( "order_id" => $ order_id ) , Router :: ABSOLUTE_URL ) ) ; } | Return the order payment success page URL |
15,465 | public function handleClearCacheACL ( ) : void { if ( $ this -> isAjax ( ) ) { $ this -> authorizatorFactory -> cleanCache ( ) ; $ this -> flashNotifier -> success ( 'cms.permissions.aclCacheCleared' ) ; } else { $ this -> terminate ( ) ; } } | Smazani cache ACL |
15,466 | public function setRoleName ( int $ id , string $ value ) : void { if ( $ this -> isAjax ( ) ) { $ grid = $ this [ 'rolesList' ] ; try { $ role = $ this -> orm -> aclRoles -> getById ( $ id ) ; $ role -> setName ( $ value ) ; $ this -> orm -> persistAndFlush ( $ role ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; } catch ( UniqueConstraintViolationException $ ex ) { $ this -> flashNotifier -> error ( 'cms.permissions.duplicityName' ) ; $ grid -> redrawItem ( $ id ) ; } catch ( InvalidArgumentException $ ex ) { $ this -> flashNotifier -> error ( 'cms.permissions.invalidName' ) ; $ grid -> redrawItem ( $ id ) ; } } else { $ this -> terminate ( ) ; } } | Ulozi jmeno role |
15,467 | public function setRoleParent ( int $ id , string $ value ) : void { if ( $ this -> isAjax ( ) ) { $ role = $ this -> orm -> aclRoles -> getById ( $ id ) ; $ role -> parent = $ value ; $ this -> orm -> persistAndFlush ( $ role ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; $ this [ 'rolesList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Ulozi rodice role |
15,468 | public function setPermissionRole ( int $ id , int $ value ) : void { if ( $ this -> isAjax ( ) ) { $ acl = $ this -> orm -> acl -> getById ( $ id ) ; $ acl -> role = $ value ; $ this -> orm -> persistAndFlush ( $ acl ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; $ this [ 'permissionsList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Nastavi roli pravidlu |
15,469 | public function setPermissionResource ( int $ id , int $ value ) : void { if ( $ this -> isAjax ( ) ) { $ acl = $ this -> orm -> acl -> getById ( $ id ) ; $ acl -> resource = $ value ; $ this -> orm -> persistAndFlush ( $ acl ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; $ this [ 'permissionsList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Nastavi zdroj pravidlu |
15,470 | public function setPermissionPrivilege ( int $ id , string $ value ) : void { if ( $ this -> isAjax ( ) ) { $ permission = $ this -> orm -> acl -> getById ( $ id ) ; $ permission -> privilege = $ value ; $ this -> orm -> persistAndFlush ( $ permission ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; $ this [ 'permissionsList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Ulozi operaci pravidla |
15,471 | public function setPermissionState ( int $ id , bool $ value ) : void { if ( $ this -> isAjax ( ) ) { $ permission = $ this -> orm -> acl -> getById ( $ id ) ; $ permission -> allowed = $ value ; $ this -> orm -> persistAndFlush ( $ permission ) ; $ this -> flashNotifier -> success ( 'default.dataSaved' ) ; $ this [ 'permissionsList' ] -> redrawItem ( $ id ) ; } else { $ this -> terminate ( ) ; } } | Ulozi stav pravidla |
15,472 | public static function create ( $ function_name , $ parameters = NULL ) { $ function = Parser :: parseSnippet ( "function $function_name() {}" ) ; if ( is_array ( $ parameters ) ) { foreach ( $ parameters as $ parameter ) { if ( is_string ( $ parameter ) ) { $ parameter = ParameterNode :: create ( $ parameter ) ; } $ function -> appendParameter ( $ parameter ) ; } } return $ function ; } | Create a function declaration . |
15,473 | public function setName ( $ name ) { $ function_name = $ this -> getName ( ) -> firstChild ( ) ; $ function_name -> setText ( $ name ) ; return $ this ; } | Set the name of the declared function . |
15,474 | public function updateRatesAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } try { $ event = new CurrencyUpdateRateEvent ( ) ; $ this -> dispatch ( TheliaEvents :: CURRENCY_UPDATE_RATES , $ event ) ; if ( $ event -> hasUndefinedRates ( ) ) { return $ this -> render ( 'currencies' , [ 'undefined_rates' => $ event -> getUndefinedRates ( ) ] ) ; } } catch ( \ Exception $ ex ) { return $ this -> errorPage ( $ ex ) ; } return $ this -> redirectToListTemplate ( ) ; } | Update currencies rates |
15,475 | public function setVisibleAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ changeEvent = new CurrencyUpdateEvent ( ( int ) $ this -> getRequest ( ) -> get ( 'currency_id' , 0 ) ) ; $ changeEvent -> setVisible ( ( int ) $ this -> getRequest ( ) -> get ( 'visible' , 0 ) ) ; try { $ this -> dispatch ( TheliaEvents :: CURRENCY_SET_VISIBLE , $ changeEvent ) ; } catch ( \ Exception $ ex ) { return $ this -> errorPage ( $ ex ) ; } return $ this -> redirectToListTemplate ( ) ; } | Sets if the currency is visible for Front |
15,476 | public function make ( array $ config ) { Arr :: requires ( $ config , [ 'from' , 'client' , 'token' ] ) ; $ client = new Client ( ) ; return new TwilioGateway ( $ client , $ config ) ; } | Create a new twilio gateway instance . |
15,477 | public static function fromFunction ( FunctionDeclarationNode $ function_node ) { $ method_name = $ function_node -> getName ( ) -> getText ( ) ; $ parameters = $ function_node -> getParameterList ( ) -> getText ( ) ; $ body = $ function_node -> getBody ( ) -> getText ( ) ; $ class_node = Parser :: parseSnippet ( "class Method {public function {$method_name}($parameters) $body}" ) ; FormatterFactory :: format ( $ class_node ) ; $ method_node = $ class_node -> getStatements ( ) [ 0 ] -> remove ( ) ; return $ method_node ; } | Create method from function declaration . |
15,478 | public function getMethod ( $ name ) { $ methods = $ this -> getMethods ( ) -> filter ( function ( InterfaceMethodNode $ method ) use ( $ name ) { return $ method -> getName ( ) -> getText ( ) === $ name ; } ) ; return $ methods -> isEmpty ( ) ? NULL : $ methods [ 0 ] ; } | Returns a method by name if it exists . |
15,479 | public function appendMethod ( $ method ) { if ( is_string ( $ method ) ) { $ method = InterfaceMethodNode :: create ( $ method ) ; } $ this -> statements -> lastChild ( ) -> before ( $ method ) ; FormatterFactory :: format ( $ this ) ; return $ this ; } | Adds a method to interface . |
15,480 | public function makeItDefault ( ) { AddressQuery :: create ( ) -> filterByCustomerId ( $ this -> getCustomerId ( ) ) -> update ( array ( 'IsDefault' => '0' ) ) ; $ this -> setIsDefault ( 1 ) ; $ this -> save ( ) ; } | put the the current address as default one |
15,481 | public function preInsert ( ConnectionInterface $ con = null ) { parent :: preInsert ( $ con ) ; $ this -> dispatchEvent ( TheliaEvents :: BEFORE_CREATEADDRESS , new AddressEvent ( $ this ) ) ; return true ; } | Code to be run before inserting to database |
15,482 | public function postInsert ( ConnectionInterface $ con = null ) { parent :: postInsert ( $ con ) ; $ this -> dispatchEvent ( TheliaEvents :: AFTER_CREATEADDRESS , new AddressEvent ( $ this ) ) ; } | Code to be run after inserting to database |
15,483 | public function preUpdate ( ConnectionInterface $ con = null ) { parent :: preUpdate ( $ con ) ; $ this -> dispatchEvent ( TheliaEvents :: BEFORE_UPDATEADDRESS , new AddressEvent ( $ this ) ) ; return true ; } | Code to be run before updating the object in database |
15,484 | public function postUpdate ( ConnectionInterface $ con = null ) { parent :: postUpdate ( $ con ) ; $ this -> dispatchEvent ( TheliaEvents :: AFTER_UPDATEADDRESS , new AddressEvent ( $ this ) ) ; } | Code to be run after updating the object in database |
15,485 | public function preDelete ( ConnectionInterface $ con = null ) { parent :: preDelete ( $ con ) ; if ( $ this -> getIsDefault ( ) ) { return false ; } $ this -> dispatchEvent ( TheliaEvents :: BEFORE_DELETEADDRESS , new AddressEvent ( $ this ) ) ; return true ; } | Code to be run before deleting the object in database |
15,486 | public function postDelete ( ConnectionInterface $ con = null ) { parent :: postDelete ( $ con ) ; $ this -> dispatchEvent ( TheliaEvents :: AFTER_DELETEADDRESS , new AddressEvent ( $ this ) ) ; } | Code to be run after deleting the object in database |
15,487 | private function loadPluginTextdomain ( ) { load_textdomain ( $ this -> textdomain , $ this -> configs -> get ( 'libraryDir' ) . 'languages/' . $ this -> textdomain . '-' . get_locale ( ) . '.mo' ) ; } | Load the library s text domain . |
15,488 | public function loadPluginInstaller ( ) { if ( ! did_action ( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ) ) { do_action ( 'Boldgrid\Library\Library\Start::loadPluginInstaller' ) ; if ( class_exists ( '\Boldgrid\Library\Plugin\Installer' ) ) { $ this -> pluginInstaller = new \ Boldgrid \ Library \ Plugin \ Installer ( Configs :: get ( 'pluginInstaller' ) , $ this -> getReleaseChannel ( ) ) ; } } } | Load the Plugin \ Installer class if exists . |
15,489 | public function filterConfigs ( $ configs ) { if ( ! empty ( $ configs [ 'libraryDir' ] ) ) { $ configs [ 'libraryUrl' ] = str_replace ( ABSPATH , get_site_url ( ) . '/' , $ configs [ 'libraryDir' ] ) ; } return $ configs ; } | Filter the configuration array . |
15,490 | protected function listImport ( OutputInterface $ output ) { $ table = new Table ( $ output ) ; foreach ( ( new ImportQuery ) -> find ( ) as $ import ) { $ table -> addRow ( [ $ import -> getRef ( ) , $ import -> getTitle ( ) , $ import -> getDescription ( ) ] ) ; } $ table -> setHeaders ( [ 'Reference' , 'Title' , 'Description' ] ) -> render ( ) ; } | Output available imports |
15,491 | public function _build_xml ( $ k , $ v ) { if ( is_object ( $ v ) && strtolower ( get_class ( $ v ) ) == 'simplexmlelement' ) { return preg_replace ( '/<\?xml(.*?)\?>\n*/' , '' , $ v -> asXML ( ) ) ; } $ res = '' ; $ attrs = '' ; if ( ! is_numeric ( $ k ) ) { $ res = '<' . $ k . '{{attributes}}>' ; } if ( is_object ( $ v ) ) { $ v = ( array ) $ v ; } if ( is_array ( $ v ) ) { foreach ( $ v as $ key => $ value ) { if ( is_numeric ( $ key ) && is_array ( $ value ) ) { foreach ( $ value as $ sub_key => $ sub_value ) { if ( strpos ( $ sub_key , '@' ) === 0 ) { $ attrs .= ' ' . substr ( $ sub_key , 1 ) . '="' . $ this -> _xml_entities ( $ sub_value ) . '"' ; unset ( $ value [ $ sub_key ] ) ; continue ; } } } if ( strpos ( $ key , '@' ) === 0 ) { $ attrs .= ' ' . substr ( $ key , 1 ) . '="' . $ this -> _xml_entities ( $ value ) . '"' ; continue ; } $ res .= $ this -> _build_xml ( $ key , $ value ) ; $ keys = array_keys ( $ v ) ; if ( is_numeric ( $ key ) && $ key !== array_pop ( $ keys ) ) { if ( is_array ( $ value ) ) { $ res = str_replace ( '<' . $ k . '{{attributes}}>' , '<' . $ k . $ attrs . '>' , $ res ) ; $ attrs = '' ; } $ res .= '</' . $ k . ">\n<" . $ k . '{{attributes}}>' ; } } } else { $ res .= $ this -> _xml_entities ( $ v ) ; } if ( ! is_numeric ( $ k ) ) { $ res .= '</' . $ k . ">\n" ; } $ res = str_replace ( '<' . $ k . '{{attributes}}>' , '<' . $ k . $ attrs . '>' , $ res ) ; return $ res ; } | Simple recursive function to build an XML response . |
15,492 | public function _unicode_ord ( & $ c , & $ i = 0 ) { $ l = strlen ( $ c ) ; $ index = $ i ; if ( $ index >= $ l ) { return false ; } $ o = ord ( $ c [ $ index ] ) ; if ( $ o <= 0x7F ) { return $ o ; } elseif ( $ o < 0xC2 ) { return false ; } elseif ( $ o <= 0xDF && $ index < $ l - 1 ) { $ i += 1 ; return ( $ o & 0x1F ) << 6 | ( ord ( $ c [ $ index + 1 ] ) & 0x3F ) ; } elseif ( $ o <= 0xEF && $ index < $ l - 2 ) { $ i += 2 ; return ( $ o & 0x0F ) << 12 | ( ord ( $ c [ $ index + 1 ] ) & 0x3F ) << 6 | ( ord ( $ c [ $ index + 2 ] ) & 0x3F ) ; } elseif ( $ o <= 0xF4 && $ index < $ l - 3 ) { $ i += 3 ; return ( $ o & 0x0F ) << 18 | ( ord ( $ c [ $ index + 1 ] ) & 0x3F ) << 12 | ( ord ( $ c [ $ index + 2 ] ) & 0x3F ) << 6 | ( ord ( $ c [ $ index + 3 ] ) & 0x3F ) ; } else { return false ; } } | Returns the unicode value of the string |
15,493 | public function _xml_entities ( $ s , $ hex = true ) { if ( empty ( $ s ) ) { return $ s ; } $ s = ( string ) $ s ; $ r = '' ; $ l = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { $ o = $ this -> _unicode_ord ( $ s , $ i ) ; $ v = ( ( $ o >= 9 && $ o <= 13 ) || ( $ o == 32 ) || ( $ o == 33 ) || ( $ o >= 35 && $ o <= 37 ) || ( $ o >= 40 && $ o <= 47 ) || ( $ o >= 48 && $ o <= 57 ) || ( $ o == 58 ) || ( $ o == 59 ) || ( $ o == 61 ) || ( $ o == 63 ) || ( $ o == 64 ) || ( $ o >= 65 && $ o <= 90 ) || ( $ o >= 91 && $ o <= 96 ) || ( $ o >= 97 && $ o <= 122 ) || ( $ o >= 123 && $ o <= 126 ) ) ; if ( $ v ) { $ r .= $ s [ $ i ] ; } elseif ( $ o == 38 ) { $ r .= '&' ; } elseif ( $ o == 60 ) { $ r .= '<' ; } elseif ( $ o == 62 ) { $ r .= '>' ; } elseif ( $ o == 39 ) { $ r .= ''' ; } elseif ( $ o == 34 ) { $ r .= '"' ; } elseif ( $ o > 0 ) { if ( $ hex ) { $ r .= '&#x' . strtoupper ( dechex ( $ o ) ) . ';' ; } else { $ r .= '&#' . $ o . ';' ; } } } return $ r ; } | Makes the specified string XML - safe |
15,494 | public function _fetch ( $ url , $ method , $ params ) { if ( ! extension_loaded ( 'curl' ) ) { $ this -> error = 'cURL extension not loaded.' ; return false ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_MAXREDIRS , 3 ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 0 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_VERBOSE , 0 ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 1 ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 10 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 0 ) ; if ( $ this -> user && $ this -> password ) { curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> user . ":" . $ this -> password ) ; } if ( $ this -> request_format == 'xml' ) { $ this -> request_headers = array_merge ( $ this -> request_headers , array ( "Expect:" , "Content-Type: text/xml" , "Length: " . strlen ( $ params ) ) ) ; } switch ( $ method ) { case 'POST' : curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ params ) ; break ; case 'DELETE' : curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'DELETE' ) ; break ; case 'PUT' : curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'PUT' ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ params ) ; break ; case 'GET' : default : break ; } if ( count ( $ this -> request_headers ) ) { curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ this -> request_headers ) ; } $ res = curl_exec ( $ ch ) ; $ http_code = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( $ http_code == 401 ) { $ this -> errno = $ http_code ; $ this -> error = "HTTP Basic: Access denied." ; curl_close ( $ ch ) ; return false ; } if ( $ http_code == 429 ) { if ( preg_match ( '/Retry-After: ([0-9]+)/' , $ res , $ retry_after ) ) { sleep ( intval ( $ retry_after [ 1 ] ) ) ; return $ this -> _fetch ( $ url , $ method , $ params ) ; } $ this -> errno = $ http_code ; $ this -> error = "Too Many Requests" ; curl_close ( $ ch ) ; return false ; } if ( ! $ res ) { $ this -> errno = curl_errno ( $ ch ) ; $ this -> error = curl_error ( $ ch ) ; curl_close ( $ ch ) ; return false ; } curl_close ( $ ch ) ; return $ res ; } | Fetch the specified request via cURL . |
15,495 | public function set ( $ k , $ v = false ) { if ( ! $ v && is_array ( $ k ) ) { foreach ( $ k as $ key => $ value ) { $ this -> _data [ $ key ] = $ value ; } } else { $ this -> _data [ $ k ] = $ v ; } return $ this ; } | Quick setter for chaining methods . |
15,496 | protected function getLog ( ) { if ( $ this -> log == null ) { $ this -> log = Tlog :: getNewInstance ( ) ; $ logFilePath = $ this -> getLogFilePath ( ) ; $ this -> log -> setPrefix ( "#LEVEL: #DATE #HOUR: " ) ; $ this -> log -> setDestinations ( "\\Thelia\\Log\\Destination\\TlogDestinationFile" ) ; $ this -> log -> setConfig ( "\\Thelia\\Log\\Destination\\TlogDestinationFile" , 0 , $ logFilePath ) ; $ this -> log -> setLevel ( Tlog :: INFO ) ; } return $ this -> log ; } | Returns the module - specific logger initializing it if required . |
15,497 | public function confirmPayment ( $ orderId ) { try { $ orderId = \ intval ( $ orderId ) ; if ( null !== $ order = $ this -> getOrder ( $ orderId ) ) { $ this -> getLog ( ) -> addInfo ( $ this -> getTranslator ( ) -> trans ( "Processing confirmation of order ref. %ref, ID %id" , array ( '%ref' => $ order -> getRef ( ) , '%id' => $ order -> getId ( ) ) ) ) ; $ event = new OrderEvent ( $ order ) ; $ event -> setStatus ( OrderStatusQuery :: getPaidStatus ( ) -> getId ( ) ) ; $ this -> dispatch ( TheliaEvents :: ORDER_UPDATE_STATUS , $ event ) ; $ this -> getLog ( ) -> addInfo ( $ this -> getTranslator ( ) -> trans ( "Order ref. %ref, ID %id has been successfully paid." , array ( '%ref' => $ order -> getRef ( ) , '%id' => $ order -> getId ( ) ) ) ) ; } } catch ( \ Exception $ ex ) { $ this -> getLog ( ) -> addError ( $ this -> getTranslator ( ) -> trans ( "Error occured while processing order ref. %ref, ID %id: %err" , array ( '%err' => $ ex -> getMessage ( ) , '%ref' => ! isset ( $ order ) ? "?" : $ order -> getRef ( ) , '%id' => ! isset ( $ order ) ? "?" : $ order -> getId ( ) ) ) ) ; throw $ ex ; } } | Process the confirmation of an order . This method should be called once the module has performed the required checks to confirm a valid payment . |
15,498 | protected function getOrder ( $ orderId ) { if ( null == $ order = OrderQuery :: create ( ) -> findPk ( $ orderId ) ) { $ this -> getLog ( ) -> addError ( $ this -> getTranslator ( ) -> trans ( "Unknown order ID: %id" , array ( '%id' => $ orderId ) ) ) ; } return $ order ; } | Get an order and issue a log message if not found . |
15,499 | public function redirectToSuccessPage ( $ orderId ) { $ this -> getLog ( ) -> addInfo ( "Redirecting customer to payment success page" ) ; throw new RedirectException ( $ this -> retrieveUrlFromRouteId ( 'order.placed' , [ ] , [ 'order_id' => $ orderId ] , Router :: ABSOLUTE_PATH ) ) ; } | Redirect the customer to the successful payment page . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.