idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,400 | public function getDomainComponent ( ) { $ component = $ this ; while ( $ component ) { $ class = $ component -> componentClass ; if ( Kwc_Abstract :: hasSetting ( $ class , 'baseProperties' ) && in_array ( 'domain' , Kwc_Abstract :: getSetting ( $ class , 'baseProperties' ) ) ) { return $ component ; } $ component = $ component -> parent ; } } | Returns domain component for current component |
1,401 | public function getDomainComponentId ( ) { if ( ! isset ( $ this -> _domainComponentIdCache ) ) { $ this -> _domainComponentIdCache = $ this -> getDomainComponent ( ) -> componentId ; } return $ this -> _domainComponentIdCache ; } | Returns domain component id for current component |
1,402 | public function getPreviewUrl ( ) { if ( $ domain = $ this -> getBaseProperty ( 'preliminaryDomain' ) ) { $ https = Kwf_Util_Https :: domainSupportsHttps ( $ domain ) ; $ protocol = $ https ? 'https' : 'http' ; $ url = $ protocol . '://' . $ domain . $ this -> url ; } else { $ url = $ this -> getAbsoluteUrl ( ) ; } return Kwf_Setup :: getBaseUrl ( ) . '/admin/component/preview/?url=' . urlencode ( $ url . '?kwcPreview' ) ; } | Returns preview url |
1,403 | public function countChildComponents ( $ select = array ( ) ) { Kwf_Benchmark :: count ( 'countChildComponents' ) ; $ select = $ this -> _formatSelect ( $ select ) ; if ( ! $ select -> hasPart ( Kwf_Component_Select :: WHERE_GENERATOR ) ) { throw new Kwf_Exception ( "You can count only for one generator at a time" ) ; } $ generators = Kwf_Component_Generator_Abstract :: getInstances ( $ this -> componentClass , $ select ) ; return current ( $ generators ) -> countChildData ( $ this , $ select ) ; } | returns the number of child components for a single generator |
1,404 | public function getChildIds ( $ select = array ( ) ) { $ select = $ this -> _formatSelect ( $ select ) ; if ( ! $ select -> hasPart ( Kwf_Component_Select :: WHERE_GENERATOR ) ) { throw new Kwf_Exception ( 'Only one generator supported, please restrict select to a generator' ) ; } $ generator = current ( Kwf_Component_Generator_Abstract :: getInstances ( $ this , $ select ) ) ; return $ generator -> getChildIds ( $ this , $ select ) ; } | Returns child ids for a single generator |
1,405 | public function getChildComponents ( $ select = array ( ) ) { $ select = $ this -> _formatSelect ( $ select ) ; $ sc = $ select -> getHash ( ) ; if ( isset ( $ this -> _childComponentsCache [ $ sc ] ) ) { Kwf_Benchmark :: count ( 'getChildComponents cached' ) ; } else { Kwf_Benchmark :: count ( 'getChildComponents uncached' ) ; } if ( ! isset ( $ this -> _childComponentsCache [ $ sc ] ) ) { $ this -> _childComponentsCache [ $ sc ] = array ( ) ; if ( $ select -> getPart ( Kwf_Component_Select :: WHERE_COMPONENT_CLASSES ) === array ( ) ) { return $ this -> _childComponentsCache [ $ sc ] ; } if ( $ select -> hasPart ( Kwf_Component_Select :: LIMIT_COUNT ) ) { $ limitCount = $ select -> getPart ( Kwf_Component_Select :: LIMIT_COUNT ) ; } else { $ limitCount = null ; } $ generators = Kwf_Component_Generator_Abstract :: getOwnInstances ( $ this , $ select ) ; $ ret = $ this -> _getChildComponentsFromGenerators ( $ generators , $ select , $ limitCount ) ; if ( is_null ( $ limitCount ) || count ( $ ret ) < $ limitCount ) { if ( ! is_null ( $ limitCount ) ) $ limitCount -= count ( $ ret ) ; $ generators = Kwf_Component_Generator_Abstract :: getInheritedInstances ( $ this , $ select ) ; $ ret += $ this -> _getChildComponentsFromGenerators ( $ generators , $ select , $ limitCount ) ; } $ this -> _childComponentsCache [ $ sc ] = $ ret ; } return $ this -> _childComponentsCache [ $ sc ] ; } | Returns child components matching the given select |
1,406 | public function getChildPages ( $ select = array ( ) , $ childSelect = array ( 'page' => false ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } else { $ select = clone $ select ; } $ select -> wherePage ( true ) ; return $ this -> getRecursiveChildComponents ( $ select , $ childSelect ) ; } | Returns child pages matching the given select |
1,407 | public function getChildPseudoPages ( $ select = array ( ) , $ childSelect = array ( 'page' => false ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } else { $ select = clone $ select ; } $ select -> wherePseudoPage ( true ) ; return $ this -> getRecursiveChildComponents ( $ select , $ childSelect ) ; } | Returns child pseudo pages matching the given select |
1,408 | public function getChildBoxes ( $ select = array ( ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } else { $ select = clone $ select ; } $ select -> whereBox ( true ) ; return $ this -> getRecursiveChildComponents ( $ select ) ; } | Returns child boxes matching the given select |
1,409 | public function getChildPage ( $ select = array ( ) , $ childSelect = array ( 'page' => false ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } $ select -> limit ( 1 ) ; return current ( $ this -> getChildPages ( $ select , $ childSelect ) ) ; } | Returns a single child page |
1,410 | public function getChildPseudoPage ( $ select = array ( ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } $ select -> limit ( 1 ) ; $ ret = $ this -> getChildPseudoPages ( $ select ) ; if ( ! $ ret ) return null ; return current ( $ ret ) ; } | Returns a single child pseudo page |
1,411 | public function getChildComponent ( $ select = array ( ) ) { $ select = $ this -> _formatSelect ( $ select ) ; $ select -> limit ( 1 ) ; $ cc = $ this -> getChildComponents ( $ select ) ; if ( ! $ cc ) return null ; return current ( $ cc ) ; } | Returns a single direct child component |
1,412 | public function getRecursiveChildComponent ( $ select = array ( ) , $ childSelect = array ( 'page' => false ) ) { $ select = $ this -> _formatSelect ( $ select ) ; $ select -> limit ( 1 ) ; $ cc = $ this -> getRecursiveChildComponents ( $ select , $ childSelect ) ; if ( ! $ cc ) return null ; return current ( $ cc ) ; } | Returns a single child component |
1,413 | public function getComponent ( ) { if ( ! isset ( $ this -> _component ) ) { $ class = $ this -> componentClass ; $ class = strpos ( $ class , '.' ) ? substr ( $ class , 0 , strpos ( $ class , '.' ) ) : $ class ; $ component = new $ class ( $ this ) ; $ this -> _component = $ component ; } return $ this -> _component ; } | Returns the Component object of to this data |
1,414 | public function getParentPage ( ) { $ page = $ this -> getPage ( ) ; if ( $ page && $ page -> parent ) { return $ page -> parent -> getPage ( ) ; } return null ; } | Returns the parent page of this data |
1,415 | public function getParentPseudoPage ( ) { $ page = $ this -> getPseudoPage ( ) ; if ( $ page && $ page -> parent ) { return $ page -> parent -> getPseudoPage ( ) ; } return null ; } | Returns the parent pseudo page of this data |
1,416 | public function getParentByClass ( $ cls ) { if ( ! is_array ( $ cls ) ) $ cls = array ( $ cls ) ; $ d = $ this ; while ( $ d ) { foreach ( $ cls as $ i ) { if ( is_instance_of ( $ d -> componentClass , $ i ) ) { return $ d ; } } $ d = $ d -> parent ; } return $ d ; } | Returns the parent matching a given component class |
1,417 | public function getParentComponent ( $ numParent = 1 ) { if ( isset ( $ this -> _lazyParent ) ) { $ id = $ this -> _lazyParent ; for ( $ i = 0 ; $ i < $ numParent ; $ i ++ ) { $ pos = max ( strrpos ( $ id , '_' ) , strrpos ( $ id , '-' ) ) ; if ( $ pos ) { $ id = substr ( $ id , 0 , $ pos ) ; } else { $ c = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ id , array ( 'ignoreVisible' => true ) ) ; for ( $ j = 0 ; $ j < $ numParent - $ i - 1 ; $ j ++ ) { $ c = $ c -> parent ; } return $ c ; } } return Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ id , array ( 'ignoreVisible' => true ) ) ; } $ c = $ this ; for ( $ i = 0 ; $ i < $ numParent ; $ i ++ ) { $ c = $ c -> parent ; } return $ c ; } | Returns a parent component from a given depth |
1,418 | public function getTitle ( ) { $ title = array ( ) ; $ row = $ this -> getPage ( ) ; if ( ! $ row ) { return null ; } do { if ( $ row -> name != '' && $ row -> name != 'Home' ) { $ title [ ] = $ row -> name ; } } while ( $ row = $ row -> getParentPage ( ) ) ; return implode ( ' - ' , $ title ) ; } | Returns the title of the page |
1,419 | public function getChildPageByPath ( $ path ) { $ page = $ this ; $ pathParts = preg_split ( '#([/:])#' , $ path , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 ; $ i < count ( $ pathParts ) ; $ i ++ ) { $ pathPart = $ pathParts [ $ i ] ; $ i ++ ; $ nextSeparator = isset ( $ pathParts [ $ i ] ) ? $ pathParts [ $ i ] : '/' ; if ( $ nextSeparator == '/' ) { $ pages = $ page -> getRecursiveChildComponents ( array ( 'filename' => $ pathPart , 'pseudoPage' => true , 'limit' => 1 ) , array ( 'pseudoPage' => false ) ) ; } else { $ pages = $ page -> getRecursiveChildComponents ( array ( 'id' => '-' . $ pathPart , 'pseudoPage' => false , 'limit' => 1 ) , array ( 'pseudoPage' => false ) ) ; } $ page = current ( $ pages ) ; if ( ! $ page ) break ; } return $ page ; } | Searches for a child page by a given path |
1,420 | public function getLanguage ( ) { if ( ! isset ( $ this -> _languageCache ) ) { $ this -> _languageCache = $ this -> getBaseProperty ( 'language' ) ; } return $ this -> _languageCache ; } | Returns the language used by this data |
1,421 | public function getBaseProperty ( $ propertyName ) { $ ret = null ; if ( isset ( $ this -> _serializedBaseProperties [ $ propertyName ] ) ) { $ ret = $ this -> _serializedBaseProperties [ $ propertyName ] ; } $ c = $ this ; while ( is_null ( $ ret ) && $ c ) { if ( Kwc_Abstract :: getFlag ( $ c -> componentClass , 'hasBaseProperties' ) ) { $ ret = $ c -> getComponent ( ) -> getBaseProperty ( $ propertyName ) ; } $ c = $ c -> parent ; } return $ ret ; } | Retrieves a base Property for a component |
1,422 | public function isVisible ( ) { $ c = $ this ; while ( $ c ) { if ( isset ( $ c -> invisible ) && $ c -> invisible ) { return false ; } $ c = $ c -> parent ; } return true ; } | Returns if this component is visible |
1,423 | public function isShownInMenu ( ) { if ( ! $ this -> isPage ) return false ; if ( $ this -> generator instanceof Kwc_Root_Category_Generator ) { return ! $ this -> row -> hide ; } else { if ( ! $ this -> generator -> hasSetting ( 'showInMenu' ) ) return false ; return ( bool ) $ this -> generator -> getSetting ( 'showInMenu' ) ; } } | Returns if this page should be shown in menus |
1,424 | public function render ( $ enableCache = null , $ renderMaster = false , & $ hasDynamicParts = false ) { $ output = new Kwf_Component_Renderer ( ) ; if ( $ enableCache !== null ) $ output -> setEnableCache ( $ enableCache ) ; if ( $ renderMaster ) { return $ output -> renderMaster ( $ this , $ hasDynamicParts ) ; } else { return $ output -> renderComponent ( $ this , $ hasDynamicParts ) ; } } | Render the component |
1,425 | public static function findAllInstances ( ) { $ ret = array ( ) ; $ modelProviders = Kwf_Config :: getValueArray ( 'modelProviders' ) ; foreach ( $ modelProviders as $ modelProvider ) { if ( $ modelProvider ) { $ modelProvider = new $ modelProvider ; $ ret = array_merge ( $ modelProvider -> findModels ( ) , $ ret ) ; } } $ ret = array_unique ( $ ret , SORT_REGULAR ) ; return $ ret ; } | Try to find all used models in the current app |
1,426 | public static function setUp ( $ configClass = 'Kwf_Config_Web' ) { error_reporting ( E_ALL & ~ E_STRICT ) ; define ( 'APP_PATH' , getcwd ( ) ) ; Kwf_Setup :: $ configClass = $ configClass ; if ( PHP_SAPI == 'cli' ) { require_once dirname ( __FILE__ ) . '/../Kwf/Util/Setup.php' ; Kwf_Util_Setup :: minimalBootstrap ( ) ; $ setupCode = Kwf_Util_Setup :: generateCode ( ) ; Zend_Registry :: _unsetInstance ( ) ; eval ( substr ( $ setupCode , 5 ) ) ; } else if ( ! @ include ( APP_PATH . '/cache/setup' . self :: CACHE_SETUP_VERSION . '.php' ) ) { if ( ! file_exists ( APP_PATH . '/cache/setup' . self :: CACHE_SETUP_VERSION . '.php' ) ) { require_once dirname ( __FILE__ ) . '/../Kwf/Util/Setup.php' ; Kwf_Util_Setup :: minimalBootstrapAndGenerateFile ( ) ; } include ( APP_PATH . '/cache/setup' . self :: CACHE_SETUP_VERSION . '.php' ) ; } Kwf_Benchmark :: checkpoint ( 'setUp' ) ; } | increase version if incompatible changes to generated file are made |
1,427 | public final function onOwnRowUpdate ( Kwf_Events_Event_Row_Abstract $ event ) { $ cmps = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentsByDbId ( $ event -> row -> component_id , array ( 'ignoreVisible' => true ) ) ; foreach ( $ cmps as $ c ) { if ( $ c -> componentClass == $ this -> _class ) { if ( $ c -> isVisible ( ) ) { $ this -> fireEvent ( new Kwf_Component_Event_Component_ContentChanged ( $ this -> _class , $ c ) ) ; if ( Kwc_Abstract :: hasSetting ( $ this -> _class , 'throwHasContentChangedOnRowColumnsUpdate' ) ) { if ( $ event -> isDirty ( Kwc_Abstract :: getSetting ( $ this -> _class , 'throwHasContentChangedOnRowColumnsUpdate' ) ) ) { $ this -> fireEvent ( new Kwf_Component_Event_Component_HasContentChanged ( $ this -> _class , $ c ) ) ; } } $ this -> _onOwnRowUpdate ( $ c , $ event ) ; $ this -> _onOwnRowUpdateNotVisible ( $ c , $ event ) ; } else { $ this -> _onOwnRowUpdateNotVisible ( $ c , $ event ) ; } } } } | override _onOwnRowUpdate to implement custom functionality |
1,428 | protected function _onMenuChanged ( Kwf_Events_Event_Abstract $ event , Kwf_Component_Data $ menu ) { $ this -> fireEvent ( new Kwf_Component_Event_Component_ContentChanged ( $ this -> _class , $ menu ) ) ; } | overridden in Kwc_Menu_Events to fire HasContentChanged |
1,429 | protected function _getCurrentPages ( ) { $ ret = array ( ) ; $ p = $ this -> getData ( ) -> getPage ( ) ; while ( $ p ) { $ ret [ ] = $ p ; $ p = $ p -> getParentPage ( ) ; } return $ ret ; } | Array mit aktueller Seiten und Parent Pages |
1,430 | protected function _processMenuSetCurrent ( & $ ret ) { $ currentPages = array_reverse ( $ this -> _getCurrentPages ( ) ) ; $ currentPageIds = array ( ) ; foreach ( $ currentPages as $ page ) { if ( ! $ page instanceof Kwf_Component_Data_Root ) { $ currentPageIds [ ] = $ page -> componentId ; $ selected = $ page -> componentId ; } } foreach ( $ ret as $ k => $ i ) { if ( in_array ( $ i [ 'data' ] -> componentId , $ currentPageIds ) ) { $ ret [ $ k ] [ 'current' ] = true ; $ ret [ $ k ] [ 'class' ] .= ' ' . self :: getBemClass ( $ this -> _getSetting ( 'menuComponentClass' ) , 'item--current' , 'current' ) ; if ( $ selected == $ i [ 'data' ] -> componentId ) { $ ret [ $ k ] [ 'selected' ] = true ; $ ret [ $ k ] [ 'class' ] .= ' ' . self :: getBemClass ( $ this -> _getSetting ( 'menuComponentClass' ) , 'item--selected' , 'selected' ) ; } } } } | helper that sets current to current page |
1,431 | public function clearRowsCache ( $ select ) { $ cacheIds = array ( ) ; foreach ( $ this -> getIds ( $ select ) as $ id ) { $ cacheIds [ ] = $ this -> _getCacheId ( $ id ) ; } Kwf_Cache_Simple :: delete ( $ cacheIds ) ; } | called by Events when saving |
1,432 | public static function getResponsiveWidthStep ( $ width , $ widths ) { foreach ( $ widths as $ cachedWidth ) { if ( $ width <= $ cachedWidth ) { return $ cachedWidth ; } } return end ( $ widths ) ; } | Returns next supported image - width |
1,433 | public static function getResponsiveWidthSteps ( $ dim , $ imageDimensions ) { $ ret = array ( ) ; if ( is_string ( $ imageDimensions ) ) { if ( ! file_exists ( $ imageDimensions ) ) { return array ( ) ; } $ size = getimagesize ( $ imageDimensions ) ; $ imageDimensions = array ( 'width' => $ size [ 0 ] , 'height' => $ size [ 1 ] , ) ; } else if ( $ imageDimensions instanceof Kwf_Uploads_Row ) { $ imageDimensions = $ imageDimensions -> getImageDimensions ( ) ; } else if ( $ imageDimensions instanceof Imagick ) { $ imageDimensions = array ( 'width' => $ imageDimensions -> getImageWidth ( ) , 'height' => $ imageDimensions -> getImageHeight ( ) ) ; } if ( ! $ imageDimensions [ 'width' ] ) { throw new Kwf_Exception ( "Image must have a width" ) ; } $ maxWidth = $ dim [ 'width' ] * 2 ; if ( $ imageDimensions [ 'width' ] < $ dim [ 'width' ] * 2 ) { $ maxWidth = $ imageDimensions [ 'width' ] ; } $ calculateWidth = $ dim [ 'width' ] ; if ( $ imageDimensions [ 'width' ] < $ dim [ 'width' ] ) { $ calculateWidth = $ imageDimensions [ 'width' ] ; } $ width = $ calculateWidth ; do { $ ret [ ] = $ width ; $ width -= self :: _getOffsetAtWidth ( $ width ) ; } while ( $ width > 0 ) ; $ width = $ calculateWidth ; while ( true ) { $ width += self :: _getOffsetAtWidth ( $ width ) ; if ( $ width >= $ maxWidth ) { break ; } $ ret [ ] = $ width ; } $ ret [ ] = $ maxWidth ; sort ( $ ret ) ; return $ ret ; } | Returns supported image - widths of specific image with given base - dimensions |
1,434 | public static function getHandyScaleFactor ( $ original ) { $ targetSize = array ( 600 , 600 , 'cover' => false ) ; if ( is_string ( $ original ) ) { if ( ! file_exists ( $ original ) ) return 1 ; $ size = getimagesize ( $ original ) ; $ original = array ( 'width' => $ size [ 0 ] , 'height' => $ size [ 1 ] , 'rotation' => self :: getExifRotation ( $ original ) , ) ; } $ target = Kwf_Media_Image :: calculateScaleDimensions ( $ original , $ targetSize ) ; if ( abs ( $ original [ 'rotation' ] ) == 90 ) { $ original = array ( 'width' => $ original [ 'height' ] , 'height' => $ original [ 'width' ] ) ; } if ( $ original [ 'width' ] <= $ target [ 'width' ] && $ original [ 'height' ] <= $ target [ 'height' ] ) { return 1 ; } else { return $ original [ 'width' ] / $ target [ 'width' ] ; } } | Returns an image with a size which should be good to work with . Acutally this is a 600x600 max - width . If it s smaller in both dimensions it will keep it s original size . |
1,435 | public function generatePasswordSalt ( Kwf_Model_Row_Interface $ row ) { mt_srand ( ( double ) microtime ( ) * 1000000 ) ; $ row -> password_salt = substr ( md5 ( uniqid ( mt_rand ( ) , true ) ) , 0 , 10 ) ; } | not part of interface but used by Kwf_User_EditRow |
1,436 | public function renderComponent ( $ component , & $ hasDynamicParts = false ) { if ( Kwf_Component_Data_Root :: getShowInvisible ( ) ) { $ hasDynamicParts = true ; } $ helper = new Kwf_Component_View_Helper_Component ( ) ; $ helper -> setRenderer ( $ this ) ; $ content = $ helper -> component ( $ component ) ; $ content = $ this -> _renderPass2 ( $ content , $ hasDynamicParts ) ; Kwf_Component_Cache :: getInstance ( ) -> writeBuffer ( ) ; foreach ( Kwf_Component_Data_Root :: getInstance ( ) -> getPlugins ( 'Kwf_Component_PluginRoot_Interface_PostRender' ) as $ plugin ) { $ content = $ plugin -> processOutput ( $ content , $ component ) ; } return $ content ; } | Renders a single component without master |
1,437 | public function getTemplate ( Kwf_Component_Data $ component , $ type ) { if ( $ type == 'Master' ) { if ( Kwc_Abstract :: hasSetting ( $ component -> componentClass , 'masterTemplate' ) ) { return Kwc_Abstract :: getSetting ( $ component -> componentClass , 'masterTemplate' ) ; } } $ template = Kwc_Abstract :: getTemplateFile ( $ component -> componentClass , $ type ) ; if ( ! $ template ) throw new Kwf_Exception ( "No $type-Template found for '{$component->componentClass}'" ) ; return $ template ; } | overridden by Renderer_Mail to use mail templates |
1,438 | protected function _decode_digit ( $ cp ) { $ cp = ord ( $ cp ) ; return ( $ cp - 48 < 10 ) ? $ cp - 22 : ( ( $ cp - 65 < 26 ) ? $ cp - 65 : ( ( $ cp - 97 < 26 ) ? $ cp - 97 : $ this -> _base ) ) ; } | Decode a certain digit |
1,439 | public function _clean ( ) { $ be = Kwf_Cache_Simple :: getBackend ( ) ; if ( $ be == 'memcache' ) { return Kwf_Cache_Simple :: getMemcache ( ) -> flush ( ) ; } else if ( $ be == 'file' ) { foreach ( glob ( 'cache/view/*' ) as $ i ) { unlink ( $ i ) ; } return true ; } else { return self :: getZendCache ( ) -> clean ( ) ; } } | Internal function only ment to be used by unit tests |
1,440 | public static function getEncodedCallback ( $ ipnCallback , $ data = array ( ) ) { $ ret = 'kwf:' ; $ data = array ( 'data' => $ data , 'cb' => $ ipnCallback ) ; $ data = serialize ( $ data ) ; $ ret .= substr ( Kwf_Util_Hash :: hash ( $ data ) , 0 , 10 ) ; $ data = base64_encode ( $ data ) ; $ ret .= $ data ; if ( strlen ( $ ret ) > 256 ) { throw new Kwf_Exception ( "Wirecard custom field does not support more than 256 characters" ) ; } return $ ret ; } | Muss in custom von der bezahlung gespeichert werden |
1,441 | public function getChildContentWidth ( Kwf_Component_Data $ data , Kwf_Component_Data $ child ) { $ ret = $ this -> getContentWidth ( $ data ) ; if ( $ this -> _hasSetting ( 'contentWidthSubtract' ) ) { $ ret -= $ this -> _getSetting ( 'contentWidthSubtract' ) ; } return $ ret ; } | Returns the contentWidth of a given child |
1,442 | public function getBuildContents ( $ mimeType , $ language ) { if ( $ mimeType == 'text/javascript' ) $ ext = 'js' ; else if ( $ mimeType == 'text/javascript; defer' ) $ ext = 'defer.js' ; else if ( $ mimeType == 'text/css' ) $ ext = 'css' ; $ cacheId = Kwf_Assets_Dispatcher :: getInstance ( ) -> getCacheIdByPackage ( $ this , $ ext , $ language ) ; $ ret = Kwf_Assets_BuildCache :: getInstance ( ) -> load ( $ cacheId ) ; if ( $ ret === false || $ ret === 'outdated' ) { if ( $ ret === 'outdated' && Kwf_Config :: getValue ( 'assets.lazyBuild' ) == 'outdated' ) { Kwf_Assets_BuildCache :: getInstance ( ) -> building = true ; } else if ( Kwf_Config :: getValue ( 'assets.lazyBuild' ) !== true ) { if ( Kwf_Exception_Abstract :: isDebug ( ) ) { throw new Kwf_Exception ( "Building assets is disabled (assets.lazyBuild). Please include package in build." ) ; } else { throw new Kwf_Exception_NotFound ( ) ; } } $ ret = $ this -> getPackageContents ( $ mimeType , $ language ) -> getFileContents ( ) ; Kwf_Assets_BuildCache :: getInstance ( ) -> building = false ; } else { $ ret = $ ret [ 'contents' ] ; } return $ ret ; } | Get built contents of a package to be used by eg . mails |
1,443 | public static function addDefaultCssClasses ( $ dataArray , $ rowStyles ) { $ count = 0 ; $ ret = array ( ) ; foreach ( $ dataArray as $ dataItem ) { if ( ! isset ( $ dataItem [ 'cssStyle' ] ) ) { $ dataItem [ 'cssClass' ] = $ count % 2 == 0 ? 'odd' : 'even' ; $ dataItem [ 'htmlTag' ] = 'td' ; } else { $ dataItem [ 'cssClass' ] = $ dataItem [ 'cssStyle' ] . ' ' . ( $ count % 2 == 0 ? 'odd' : 'even' ) ; $ dataItem [ 'htmlTag' ] = $ rowStyles [ $ dataItem [ 'cssStyle' ] ] [ 'tag' ] ; } for ( $ i = 1 ; $ i < count ( $ dataItem [ 'data' ] ) + 1 ; $ i ++ ) { if ( empty ( $ dataItem [ 'data' ] [ 'column' . $ i ] [ 'cssClass' ] ) ) { $ dataItem [ 'data' ] [ 'column' . $ i ] [ 'cssClass' ] .= 'col' . $ i ; } else { $ dataItem [ 'data' ] [ 'column' . $ i ] [ 'cssClass' ] .= ' col' . $ i ; } if ( $ i == 1 ) { $ dataItem [ 'data' ] [ 'column' . $ i ] [ 'cssClass' ] .= ' first' ; } else if ( $ i == count ( $ dataItem [ 'data' ] ) ) { $ dataItem [ 'data' ] [ 'column' . $ i ] [ 'cssClass' ] .= ' last' ; } } $ ret [ ] = $ dataItem ; $ count ++ ; } return $ ret ; } | used from Kwc_Basic_Table_Trl_Component |
1,444 | public function itemSearch ( array $ options ) { Kwf_Benchmark :: countBt ( 'Service Amazon request' , 'itemSearch' . print_r ( $ options , true ) ) ; $ client = $ this -> getRestClient ( ) ; $ client -> setUri ( $ this -> _baseUri ) ; $ defaultOptions = array ( 'ResponseGroup' => 'Small' ) ; $ options = $ this -> _prepareOptions ( 'ItemSearch' , $ options , $ defaultOptions ) ; $ client -> getHttpClient ( ) -> resetParameters ( ) ; $ response = $ client -> restGet ( '/onca/xml' , $ options ) ; if ( $ response -> isError ( ) ) { throw new Zend_Service_Exception ( 'An error occurred sending request. Status code: ' . $ response -> getStatus ( ) ) ; } $ dom = new DOMDocument ( ) ; $ dom -> loadXML ( $ response -> getBody ( ) ) ; self :: _checkErrors ( $ dom ) ; return new Kwf_Service_Amazon_ResultSet ( $ dom ) ; } | Search for Items |
1,445 | public static function start ( $ identifier = null , $ addInfo = null ) { if ( ! self :: $ _enabled ) return null ; return new Kwf_Benchmark_Profile ( $ identifier , $ addInfo ) ; } | Startet eine Sequenz |
1,446 | public function onComponentAddedOrRemoved ( Kwf_Component_Event_Component_Abstract $ event ) { $ cacheId = 'procI-' . $ event -> component -> getPageOrRoot ( ) -> componentId ; Kwf_Cache_Simple :: delete ( $ cacheId ) ; $ log = Kwf_Events_Log :: getInstance ( ) ; if ( $ log ) { $ log -> log ( "processInput cache clear componentId=" . $ event -> component -> getPageOrRoot ( ) -> componentId , Zend_Log :: INFO ) ; } } | clear cache used in Kwf_Component_Abstract_ContentSender_Default |
1,447 | public final function getProductText ( $ orderProduct ) { $ data = Kwc_Shop_VoucherProduct_AddToCart_OrderProductData :: getInstance ( $ orderProduct -> add_component_class ) ; return $ data -> getProductText ( $ orderProduct ) ; } | override in addToCart |
1,448 | protected function _getProductPrice ( $ orderProduct ) { $ data = Kwc_Shop_VoucherProduct_AddToCart_OrderProductData :: getInstance ( $ orderProduct -> add_component_class ) ; return $ data -> getPrice ( $ orderProduct ) ; } | override to implement eg . excl . vat prices for the whole order |
1,449 | public static function getListHtml ( Kwf_Component_Renderer_Abstract $ renderer , Kwf_Component_Data $ c , $ level , $ levels , $ className ) { $ ret = '' ; $ level ++ ; $ select = new Kwf_Component_Select ( ) ; $ select -> whereShowInMenu ( true ) ; $ ret .= '<ul class="' . self :: getBemClass ( $ className , 'sitemapListLevel' . $ level ) . '">' . "\n" ; $ count = 1 ; foreach ( $ c -> getChildPages ( $ select ) as $ child ) { $ ret .= '<li class="' . self :: getBemClass ( $ className , 'sitemapListItemLevel' . $ level ) ; if ( $ count % 3 === 0 ) { $ ret .= ' ' . self :: getBemClass ( $ className , '--third' ) ; } if ( $ count % 2 === 0 ) { $ ret .= ' ' . self :: getBemClass ( $ className , '--second' ) ; } if ( ! $ child -> getChildPages ( $ select ) ) { $ ret .= ' ' . self :: getBemClass ( $ className , '--noChild' ) ; } $ ret .= '">' ; $ helper = new Kwf_Component_View_Helper_ComponentLink ( ) ; $ helper -> setRenderer ( $ renderer ) ; $ ret .= $ helper -> componentLink ( $ child ) ; $ ret .= "\n" ; if ( $ level < $ levels ) { $ ret .= self :: getListHtml ( $ renderer , $ child , $ level , $ levels , $ className ) ; } $ ret .= "</li>\n" ; $ count ++ ; } $ ret .= "</ul>\n" ; return $ ret ; } | public because for trl |
1,450 | public function addChildComponentRow ( $ type , $ childComponentRow = null ) { $ r = $ this -> createChildRow ( 'ChildComponents' ) ; $ r -> component = $ type ; $ r -> nr = $ this -> getMaxChildComponentNr ( $ type ) + 1 ; $ r -> saved = 0 ; $ r -> save ( ) ; if ( $ childComponentRow ) { $ childComponentRow -> component_id = $ this -> component_id . '-' . substr ( $ type , 0 , 1 ) . $ r -> nr ; } return $ r ; } | im Controller + in der row |
1,451 | public function dispatch ( $ action ) { $ this -> _helper -> notifyPreDispatch ( ) ; $ this -> preDispatch ( ) ; Kwf_Benchmark :: checkpoint ( 'Action::preDispatch' ) ; if ( $ this -> getRequest ( ) -> isDispatched ( ) ) { if ( null === $ this -> _classMethods ) { $ this -> _classMethods = get_class_methods ( $ this ) ; } if ( $ this -> getInvokeArg ( 'useCaseSensitiveActions' ) || in_array ( $ action , $ this -> _classMethods ) ) { if ( $ this -> getInvokeArg ( 'useCaseSensitiveActions' ) ) { trigger_error ( 'Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"' ) ; } $ this -> $ action ( ) ; } else { $ this -> __call ( $ action , array ( ) ) ; } Kwf_Benchmark :: checkpoint ( 'Action::action' ) ; $ this -> postDispatch ( ) ; Kwf_Benchmark :: checkpoint ( 'Action::postDispatch' ) ; } $ this -> _helper -> notifyPostDispatch ( ) ; } | copied from zend to insert benchmark checkpoints |
1,452 | public static function set ( $ limit ) { if ( ! is_int ( $ limit ) ) throw new Kwf_Exception ( 'Limit must be an integer' ) ; if ( $ limit <= 0 ) throw new Kwf_Exception ( 'Not allowed setting memory limit to: ' . $ limit ) ; $ currentLimit = self :: convertToMegabyte ( ini_get ( 'memory_limit' ) ) ; if ( $ limit < ( int ) $ currentLimit ) return false ; $ value = $ limit ; $ maxLimit = self :: getMaxLimit ( ) ; if ( $ maxLimit > 0 && $ maxLimit < $ limit ) { $ value = $ maxLimit ; } ini_set ( 'memory_limit' , $ value . 'M' ) ; return $ limit == $ value ; } | Sets the memory limit in megabytes |
1,453 | public static function __getProcessInputComponents ( $ data ) { $ showInvisible = Kwf_Component_Data_Root :: getShowInvisible ( ) ; $ cacheId = 'procI-' . $ data -> componentId ; $ success = false ; if ( ! $ showInvisible ) { $ cacheContents = Kwf_Cache_Simple :: fetch ( $ cacheId , $ success ) ; } if ( ! $ success ) { $ datas = array ( ) ; foreach ( self :: _findProcessInputComponents ( $ data ) as $ p ) { $ plugins = array ( ) ; $ c = $ p ; do { foreach ( $ c -> getPlugins ( 'Kwf_Component_Plugin_Interface_SkipProcessInput' ) as $ i ) { $ plugins [ ] = array ( 'pluginClass' => $ i , 'componentId' => $ c -> componentId ) ; } $ isPage = $ c -> isPage ; $ c = $ c -> parent ; } while ( $ c && ! $ isPage ) ; $ datas [ ] = array ( 'data' => $ p , 'plugins' => $ plugins , ) ; } if ( ! $ showInvisible ) { $ cacheContents = array ( ) ; foreach ( $ datas as $ p ) { $ cacheContents [ ] = array ( 'data' => $ p [ 'data' ] -> kwfSerialize ( ) , 'plugins' => $ p [ 'plugins' ] , ) ; } Kwf_Cache_Simple :: add ( $ cacheId , $ cacheContents ) ; } } else { $ datas = array ( ) ; foreach ( $ cacheContents as $ d ) { $ datas [ ] = array ( 'data' => Kwf_Component_Data :: kwfUnserialize ( $ d [ 'data' ] ) , 'plugins' => $ d [ 'plugins' ] , ) ; } } $ process = array ( ) ; foreach ( $ datas as $ d ) { foreach ( $ d [ 'plugins' ] as $ p ) { $ plugin = Kwf_Component_Plugin_Abstract :: getInstance ( $ p [ 'pluginClass' ] , $ p [ 'componentId' ] ) ; if ( $ plugin -> skipProcessInput ( $ d [ 'data' ] ) ) { continue 2 ; } } $ process [ ] = $ d [ 'data' ] ; } return $ process ; } | public for unittest |
1,454 | public function notify ( $ current , $ max , $ percent , $ timeTaken , $ timeRemaining , $ text ) { if ( ! $ this -> _lastWrittenPercent ) { $ this -> _lastWrittenPercent = ( int ) ( $ percent * 100 ) ; } if ( ! $ this -> _lastWrittenTime ) { $ this -> _lastWrittenTime = microtime ( true ) ; } if ( $ this -> _lastWrittenPercent < ( int ) ( $ percent * 100 ) && $ this -> _lastWrittenTime + 0.5 <= microtime ( true ) ) { $ arguments = array ( 'current' => $ current , 'max' => $ max , 'percent' => ( $ percent * 100 ) , 'timeTaken' => $ timeTaken , 'timeRemaining' => $ timeRemaining , 'text' => $ text , 'finished' => false ) ; $ this -> _saveStatus ( $ arguments ) ; $ this -> _lastWrittenPercent = ( int ) ( $ percent * 100 ) ; $ this -> _lastWrittenTime = microtime ( true ) ; } } | the following methods must be overwritten |
1,455 | public function indexAction ( ) { $ this -> view -> data = array ( ) ; $ s = $ this -> _getSelectIndex ( ) ; if ( $ this -> _loadColumns ) { foreach ( $ this -> _loadColumns as $ c ) { $ s -> expr ( $ c ) ; } } foreach ( $ this -> _model -> getRows ( $ s ) as $ row ) { $ this -> view -> data [ ] = $ this -> _loadDataFromRow ( $ row ) ; } $ this -> view -> total = $ this -> _model -> countRows ( $ s ) ; } | Handle GET and return a list of resources |
1,456 | public function getAction ( ) { $ s = $ this -> _getSelect ( ) ; if ( $ this -> _loadColumns ) { foreach ( $ this -> _loadColumns as $ c ) { $ s -> expr ( $ c ) ; } } $ s -> whereId ( $ this -> _getParam ( 'id' ) ) ; $ row = $ this -> _model -> getRow ( $ s ) ; if ( ! $ row ) throw new Kwf_Exception_NotFound ( ) ; $ this -> view -> data = $ this -> _loadDataFromRow ( $ row ) ; } | Handle GET and return a specific resource item |
1,457 | public function postAction ( ) { $ data = json_decode ( $ this -> getRequest ( ) -> getRawBody ( ) ) ; if ( ! is_array ( $ data ) ) $ data = array ( $ data ) ; $ ret = array ( ) ; foreach ( $ data as $ d ) { $ row = $ this -> _model -> createRow ( ) ; if ( isset ( $ d -> id ) && $ d -> id ) { $ row -> id = $ d -> id ; } $ this -> _validateInsert ( ( array ) $ d ) ; $ this -> _validateSave ( ( array ) $ d ) ; $ this -> _fillRowInsert ( $ row , $ d ) ; $ this -> _beforeInsert ( $ row ) ; $ this -> _beforeSave ( $ row ) ; $ row -> save ( ) ; $ this -> _afterSave ( $ row , $ d ) ; $ this -> _afterInsert ( $ row , $ d ) ; $ ret [ ] = $ this -> _loadDataFromRow ( $ row ) ; } if ( count ( $ ret ) == 1 ) $ ret = reset ( $ ret ) ; $ this -> view -> data = $ ret ; } | Handle POST requests to create a new resource item |
1,458 | public function putAction ( ) { $ data = json_decode ( $ this -> getRequest ( ) -> getRawBody ( ) ) ; if ( ! is_array ( $ data ) ) $ data = array ( $ data ) ; $ ret = array ( ) ; foreach ( $ data as $ d ) { $ s = $ this -> _getSelect ( ) ; $ s -> whereId ( $ d -> id ) ; $ row = $ this -> _model -> getRow ( $ s ) ; if ( ! $ row ) throw new Kwf_Exception_NotFound ( ) ; $ this -> _validateUpdate ( ( array ) $ d ) ; $ this -> _validateSave ( ( array ) $ d ) ; $ this -> _fillRow ( $ row , $ d ) ; $ this -> _beforeUpdate ( $ row ) ; $ this -> _beforeSave ( $ row ) ; $ row -> save ( ) ; $ this -> _afterSave ( $ row , $ d ) ; $ this -> _afterUpdate ( $ row , $ d ) ; $ ret [ ] = $ this -> _loadDataFromRow ( $ row ) ; } if ( count ( $ ret ) == 1 ) $ ret = reset ( $ ret ) ; $ this -> view -> data = $ ret ; } | Handle PUT requests to update a specific resource item |
1,459 | public function deleteAction ( ) { $ s = $ this -> _getSelect ( ) ; $ s -> whereId ( $ this -> _getParam ( 'id' ) ) ; $ row = $ this -> _model -> getRow ( $ s ) ; if ( ! $ row ) throw new Kwf_Exception_NotFound ( ) ; $ this -> _beforeDelete ( $ row ) ; $ row -> delete ( ) ; } | Handle DELETE requests to delete a specific item |
1,460 | public static function getFavouriteComponentIds ( $ favouritesModel ) { $ ret = array ( ) ; $ userId = Kwf_Registry :: get ( 'userModel' ) -> getAuthedUserId ( ) ; if ( $ userId ) { $ cacheIdUser = 'favCIds' . $ userId ; $ ret = Kwf_Cache_Simple :: fetch ( $ cacheIdUser , $ success ) ; if ( ! $ success ) { $ select = new Kwf_Model_Select ( ) ; $ select -> whereEquals ( 'user_id' , $ userId ) ; $ favouritesModel = Kwf_Model_Abstract :: getInstance ( $ favouritesModel ) ; $ favourites = $ favouritesModel -> getRows ( $ select ) ; $ componentIds = array ( ) ; foreach ( $ favourites as $ favourite ) { $ component = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ favourite -> component_id ) ; if ( $ component ) { $ componentIds [ ] = $ component -> componentId ; } } Kwf_Cache_Simple :: add ( $ cacheIdUser , $ componentIds ) ; $ ret = $ componentIds ; } } return $ ret ; } | returns a list of all visible favourite componentIds |
1,461 | public static function getUpdateTags ( ) { if ( ! isset ( self :: $ _updateTagsCache ) ) { self :: $ _updateTagsCache = Kwf_Registry :: get ( 'config' ) -> server -> updateTags -> toArray ( ) ; foreach ( Kwf_Component_Abstract :: getComponentClasses ( ) as $ class ) { if ( Kwc_Abstract :: hasSetting ( $ class , 'updateTags' ) ) { self :: $ _updateTagsCache = array_unique ( array_merge ( self :: $ _updateTagsCache , Kwc_Abstract :: getSetting ( $ class , 'updateTags' ) ) ) ; } } } return self :: $ _updateTagsCache ; } | Returns all udpate tags used by this webs . They are usually set in config . ini |
1,462 | public final function getLinkedData ( ) { if ( ! isset ( $ this -> _data ) ) { $ masterLinkData = $ this -> chained -> getLinkedData ( array ( 'ignoreVisible' => true ) ) ; if ( ! $ masterLinkData ) $ this -> _data = false ; if ( $ masterLinkData ) { if ( is_null ( $ this -> _type ) ) throw new Kwf_Exception ( "_type may not be null" ) ; if ( $ this -> _type == 'Trl' ) { $ linkComponent = Kwc_Chained_Trl_Component :: getChainedByMaster ( $ masterLinkData , $ this ) ; } else if ( $ this -> _type == 'Cc' ) { $ linkComponent = Kwc_Chained_Cc_Component :: getChainedByMaster ( $ masterLinkData , $ this ) ; } if ( ! $ linkComponent ) { $ this -> _data = false ; } else { $ this -> _data = $ linkComponent ; } } } $ chained = $ this -> chained ; while ( isset ( $ chained -> chained ) ) $ chained = $ chained -> chained ; $ m = Kwc_Abstract :: createModel ( $ chained -> componentClass ) ; $ result = $ m -> fetchColumnsByPrimaryId ( array ( 'anchor' ) , $ chained -> dbId ) ; if ( $ result [ 'anchor' ] ) $ this -> _anchor = $ result [ 'anchor' ] ; return $ this -> _data ; } | cc oder trl |
1,463 | protected function _getRedirectUrl ( ) { $ r = $ this -> _getRedirectRow ( ) ; if ( isset ( $ r -> type ) && $ r -> type && $ r -> type != 'redirect' ) { throw new Kwf_Exception_NotFound ( 'Invalid type' ) ; } return $ r -> value ; } | can be overridden to customize redirect url |
1,464 | public function send ( Kwc_Mail_Recipient_Interface $ recipient , $ data = null , $ toAddress = null , $ format = null , $ addViewTracker = true ) { $ mail = $ this -> createMail ( $ recipient , $ data , $ toAddress , $ format , $ addViewTracker ) ; return $ mail -> send ( ) ; } | Verschickt ein mail an |
1,465 | public function getImageDimensions ( ) { $ dimension = $ this -> _getSetting ( 'dimension' ) ; if ( $ this -> getRow ( ) -> use_crop ) { $ parentDimension = $ this -> _getImageEnlargeComponent ( ) -> getImageDimensions ( ) ; $ dimension [ 'crop' ] = $ parentDimension [ 'crop' ] ; } $ data = $ this -> getImageData ( ) ; return Kwf_Media_Image :: calculateScaleDimensions ( $ data [ 'file' ] , $ dimension ) ; } | This function is used by Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Component to get the dimension - values defined in getSettings and the crop - values if use_crop was checked . |
1,466 | public function getImageUrl ( ) { $ baseUrl = $ this -> getBaseImageUrl ( ) ; if ( $ baseUrl ) { $ dimensions = $ this -> getImageDimensions ( ) ; $ imageData = $ this -> getImageData ( ) ; $ width = Kwf_Media_Image :: getResponsiveWidthStep ( $ dimensions [ 'width' ] , Kwf_Media_Image :: getResponsiveWidthSteps ( $ dimensions , $ imageData [ 'file' ] ) ) ; $ ret = str_replace ( '{width}' , $ width , $ baseUrl ) ; $ ev = new Kwf_Component_Event_CreateMediaUrl ( $ this -> getData ( ) -> componentClass , $ this -> getData ( ) , $ ret ) ; Kwf_Events_Dispatcher :: fireEvent ( $ ev ) ; return $ ev -> url ; } return null ; } | This function is used by Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Component to get the url to show the image from parent with dimension defined through this component . |
1,467 | public static function getFreePort ( $ from , $ host = 'localhost' ) { $ socket = socket_create ( AF_INET , SOCK_STREAM , SOL_TCP ) ; $ ret = $ from ; while ( true ) { if ( @ socket_bind ( $ socket , $ host , $ ret ) ) { break ; } $ ret ++ ; if ( $ ret > $ from + 100 ) { $ this -> fail ( 'can\'t get free port number' ) ; } } socket_close ( $ socket ) ; return $ ret ; } | Get a free port number |
1,468 | protected function _fireComponentEvent ( $ eventType , Kwf_Component_Data $ c , $ flag ) { $ cls = 'Kwf_Component_Event_Component_' . $ eventType ; $ this -> fireEvent ( new $ cls ( $ c -> componentClass , $ c , $ flag ) ) ; } | overridden in Page_Events_Table to fire Page events |
1,469 | public static function getJsReplacement ( $ trlElement ) { $ b = $ trlElement [ 'before' ] ; $ fn = substr ( $ b , 0 , strpos ( $ b , '(' ) ) ; $ key = $ trlElement [ 'type' ] . '.' . $ trlElement [ 'source' ] ; if ( isset ( $ trlElement [ 'context' ] ) ) $ key .= '.' . $ trlElement [ 'context' ] ; $ key .= '.' . str_replace ( "'" , "\\'" , $ trlElement [ 'text' ] ) ; $ replace = '' ; if ( preg_match ( '#^(_?([a-z]+(2\.default)?\.))trl#i' , $ b , $ m ) ) { $ replace = substr ( $ b , 0 , strlen ( $ m [ 1 ] ) ) ; } if ( $ trlElement [ 'type' ] == 'trlp' || $ trlElement [ 'type' ] == 'trlcp' ) { $ replace .= "_kwfTrlp" ; } else { $ replace .= "_kwfTrl" ; } $ replace .= "('$key', " . substr ( $ b , strpos ( $ b , '(' ) + 1 ) ; unset ( $ trlElement [ 'before' ] ) ; unset ( $ trlElement [ 'linenr' ] ) ; unset ( $ trlElement [ 'error_short' ] ) ; return array ( 'before' => $ b , 'replace' => $ replace , 'trlElement' => ( object ) $ trlElement ) ; } | used by Kwf_Assets_Dependency_File_Js and Kwf_Assets_CommonJs_Underscore_TemplateDependency |
1,470 | public static function sync ( Kwf_Model_Abstract $ model , array $ compareColumns , array $ data , Kwf_Model_Select $ select = null ) { $ sync = new Kwf_Util_ModelSync ( $ model , $ compareColumns ) ; $ sync -> syncData ( $ data , $ select ) ; return $ sync -> getMappingForLastSync ( ) ; } | Syncs given array with given rowset |
1,471 | public function fetchRow ( $ where = null , $ order = null , $ offset = null ) { if ( ! ( $ where instanceof Kwf_Db_Table_Select ) ) { $ select = $ this -> select ( ) ; if ( $ where !== null ) { $ this -> _where ( $ select , $ where ) ; } if ( $ order !== null ) { $ this -> _order ( $ select , $ order ) ; } $ select -> limit ( 1 , ( ( is_numeric ( $ offset ) ) ? ( int ) $ offset : null ) ) ; } else { $ select = $ where -> limit ( 1 , $ where -> getPart ( Zend_Db_Select :: LIMIT_OFFSET ) ) ; } $ rows = $ this -> _fetch ( $ select ) ; if ( count ( $ rows ) == 0 ) { return null ; } $ data = array ( 'table' => $ this , 'data' => $ rows [ 0 ] , 'stored' => true ) ; $ rowClass = $ this -> _rowClass ; return new $ rowClass ( $ data ) ; } | Fetches one row in an object of type Kwf_Db_Table_Row or returns null if no row matches the specified criteria . |
1,472 | private static function _getPartialFileContent ( $ file , $ range ) { $ length = $ range [ 1 ] - $ range [ 0 ] + 1 ; if ( ! $ handle = fopen ( $ file , 'r' ) ) throw new Kwf_Exception ( sprintf ( "Could not get handle for file %s" , $ file ) ) ; if ( fseek ( $ handle , $ range [ 0 ] , SEEK_SET ) == - 1 ) throw new Kwf_Exception ( sprintf ( "Could not seek to byte offset {$rage[0]}" ) ) ; $ ret = fread ( $ handle , $ length ) ; return $ ret ; } | returns the partial content from a file |
1,473 | public static function clear ( $ cacheIdPrefix ) { if ( ! extension_loaded ( 'apc' ) || PHP_SAPI == 'cli' ) { self :: $ _cache = array ( ) ; foreach ( glob ( 'cache/simpleStatic/*' ) as $ f ) { unlink ( $ f ) ; } if ( extension_loaded ( 'apc' ) ) { Kwf_Util_Apc :: callClearCacheByCli ( array ( 'clearCacheSimpleStatic' => $ cacheIdPrefix ) ) ; } } else { if ( ! class_exists ( 'APCIterator' ) ) { throw new Kwf_Exception_NotYetImplemented ( "We don't want to clear the whole" ) ; } else { static $ prefix ; if ( ! isset ( $ prefix ) ) $ prefix = Kwf_Cache_Simple :: $ uniquePrefix . '-' ; $ it = new APCIterator ( 'user' , '#^' . preg_quote ( $ prefix . $ cacheIdPrefix ) . '#' , APC_ITER_NONE ) ; if ( $ it -> getTotalCount ( ) && ! $ it -> current ( ) ) { if ( extension_loaded ( 'apcu' ) ) { apc_clear_cache ( ) ; } else { apc_clear_cache ( 'user' ) ; } } else { apc_delete ( $ it ) ; } } } } | clear static cache with prefix don t use except in clear - cache - watcher |
1,474 | public static function _delete ( $ cacheIds ) { if ( ! is_array ( $ cacheIds ) ) $ cacheIds = array ( $ cacheIds ) ; $ ret = true ; if ( ! extension_loaded ( 'apc' ) || PHP_SAPI == 'cli' ) { foreach ( $ cacheIds as $ cacheId ) { unset ( self :: $ _cache [ $ cacheId ] ) ; $ file = self :: _getFileNameForCacheId ( $ cacheId ) ; if ( ! file_exists ( $ file ) ) { $ ret = false ; } else { if ( ! unlink ( $ file ) ) $ ret = false ; } } if ( extension_loaded ( 'apc' ) ) { $ result = Kwf_Util_Apc :: callClearCacheByCli ( array ( 'clearCacheSimpleStatic' => implode ( ',' , $ cacheIds ) ) ) ; if ( ! $ result [ 'result' ] ) $ ret = false ; } } else { $ prefix = Kwf_Cache_Simple :: $ uniquePrefix . '-' ; foreach ( $ cacheIds as $ cacheId ) { if ( ! apc_delete ( $ prefix . $ cacheId ) ) { $ ret = false ; } } } return $ ret ; } | Delete static cache don t use except in unittests |
1,475 | private static function _findFormFields ( $ data ) { $ ret = array ( ) ; foreach ( $ data -> getChildComponents ( array ( 'page' => false , 'pseudoPage' => false ) ) as $ c ) { if ( Kwc_Abstract :: getFlag ( $ c -> componentClass , 'formField' ) ) { $ ret [ ] = $ c ; } $ ret = array_merge ( $ ret , self :: _findFormFields ( $ c ) ) ; } return $ ret ; } | don t use getRecursiveChildComponents as that won t return items in an defined order |
1,476 | private static function _processValidators ( ) { foreach ( $ _SESSION [ '__KWF' ] [ 'VALID' ] as $ validator_name => $ valid_data ) { $ validator = new $ validator_name ; if ( $ validator -> validate ( ) === false ) { $ _SESSION = array ( ) ; Zend_Session :: regenerateId ( ) ; break ; } } } | instead empty session |
1,477 | public function encodeMail ( $ address ) { if ( $ this -> _getRenderer ( ) instanceof Kwf_Component_Renderer_Mail ) { return $ text ; } $ address = trim ( $ address ) ; $ address = preg_replace ( '/^(.+)@(.+)\.([^\.\s]+)$/i' , '$1' . $ this -> _atEncoding . '$2' . $ this -> _dotEncoding . '$3' , $ address ) ; return $ address ; } | wird zB in LinkTag_Mail_Data . php verwendet deshalb public |
1,478 | public function stop ( ) { $ this -> _stop = microtime ( true ) ; $ this -> duration = $ this -> _stop - $ this -> _start ; if ( function_exists ( 'memory_get_usage' ) ) { $ this -> _memoryStop = memory_get_usage ( ) ; $ this -> memory = $ this -> _memoryStop - $ this -> _memoryStart ; } if ( Zend_Registry :: get ( 'db' ) && Zend_Registry :: get ( 'db' ) -> getProfiler ( ) instanceof Kwf_Db_Profiler ) { $ this -> _queriesStop = Zend_Registry :: get ( 'db' ) -> getProfiler ( ) -> getQueryCount ( ) ; $ this -> queries = $ this -> _queriesStop - $ this -> _queriesStart ; } if ( Zend_Registry :: get ( 'config' ) -> debug -> firephp && class_exists ( 'FirePHP' ) && FirePHP :: getInstance ( ) && FirePHP :: getInstance ( ) -> detectClientExtension ( ) ) { p ( $ this -> identifier . ': ' . $ this -> addInfo . ' ' . implode ( '; ' , $ this -> getOutput ( ) ) ) ; } $ this -> stopped = true ; } | Beendet eine Sequenz |
1,479 | static public function getBadKeys ( array $ emails ) { $ cfg = Kwf_Registry :: get ( 'config' ) ; $ client = new Kwf_Srpc_Client ( array ( 'serverUrl' => $ cfg -> service -> rtrlist -> url ) ) ; return $ client -> getBadKeys ( $ emails ) ; } | Checks mail addresses against the rtr - ecg list |
1,480 | public static function _clear ( ) { if ( self :: getBackend ( ) == 'memcache' ) { if ( ! Kwf_Config :: getValue ( 'cacheSimpleNamespace' ) ) { $ mc = Kwf_Cache_Simple :: getMemcache ( ) ; if ( $ mc -> get ( Kwf_Cache_Simple :: $ uniquePrefix . 'cache_namespace' ) ) { $ mc -> increment ( Kwf_Cache_Simple :: $ uniquePrefix . 'cache_namespace' ) ; } } else { $ mc = Kwf_Cache_Simple :: getMemcache ( ) ; $ mc -> flush ( ) ; } } else if ( self :: getBackend ( ) == 'redis' ) { $ prefixLength = strlen ( self :: getRedis ( ) -> _prefix ( '' ) ) ; $ it = null ; while ( $ keys = self :: getRedis ( ) -> scan ( $ it , self :: getRedis ( ) -> _prefix ( 'simple:*' ) ) ) { foreach ( $ keys as $ k => $ i ) { $ keys [ $ k ] = substr ( $ i , $ prefixLength ) ; } self :: getRedis ( ) -> delete ( $ keys ) ; } } else if ( self :: getBackend ( ) == 'file' ) { foreach ( glob ( 'cache/simple/*' ) as $ i ) { unlink ( $ i ) ; } } else if ( self :: getBackend ( ) == 'apc' || self :: getBackend ( ) == 'apcu' ) { } else { if ( ! isset ( self :: $ _zendCache ) ) self :: getZendCache ( ) ; $ r = self :: $ _zendCache -> clean ( Zend_Cache :: CLEANING_MODE_ALL ) ; } } | only call from Kwf_Util_ClearCache_Types_SimpleCache! |
1,481 | protected function _getDefaultValues ( ) { $ teamComponent = $ this -> _data -> parent -> parent -> parent ; if ( Kwc_Abstract :: hasSetting ( $ teamComponent -> componentClass , 'defaultVcardValues' ) ) { $ setting = Kwc_Abstract :: getSetting ( $ teamComponent -> componentClass , 'defaultVcardValues' ) ; } if ( isset ( $ setting ) ) { return $ setting ; } else { return Kwc_Abstract :: getSetting ( $ this -> _data -> componentClass , 'defaultVcardValues' ) ; } } | Set default vCard settings here or in Team_Component |
1,482 | public function getRow ( $ position , $ seek = false ) { try { $ row = $ this -> _loadAndReturnRow ( $ position ) ; } catch ( Kwf_Exception $ e ) { throw new Kwf_Exception ( 'No row could be found at position ' . ( int ) $ position , 0 , $ e ) ; } if ( $ seek == true ) { $ this -> seek ( $ position ) ; } return $ row ; } | Returns a Kwf_Db_Table_Row from a known position into the Iterator |
1,483 | public function open ( $ savePath , $ sessionName ) { if ( ! isset ( $ this -> _lifeTime ) ) $ this -> _lifeTime = intval ( ini_get ( "session.gc_maxlifetime" ) ) ; if ( ! isset ( $ this -> _refreshTime ) ) $ this -> _refreshTime = ceil ( $ this -> _lifeTime / 3 ) ; $ this -> _initSessionData = null ; $ this -> _memcache = new Memcache ( ) ; if ( Kwf_Cache_Simple :: $ memcacheHost ) { $ servers = array ( array ( 'host' => Kwf_Cache_Simple :: $ memcacheHost , 'port' => Kwf_Cache_Simple :: $ memcachePort ) ) ; } else { throw new Kwf_Exception ( "no memcache configured" ) ; } foreach ( $ servers as $ s ) { if ( version_compare ( phpversion ( 'memcache' ) , '2.1.0' ) == - 1 || phpversion ( 'memcache' ) == '2.2.4' ) { $ this -> _memcache -> addServer ( $ s [ 'host' ] , $ s [ 'port' ] , true , 1 , 1 , 1 ) ; } else if ( version_compare ( phpversion ( 'memcache' ) , '3.0.0' ) == - 1 ) { $ this -> _memcache -> addServer ( $ s [ 'host' ] , $ s [ 'port' ] , true , 1 , 1 , 1 , true , null , 10000 ) ; } else { $ this -> _memcache -> addServer ( $ s [ 'host' ] , $ s [ 'port' ] , true , 1 , 1 , 1 ) ; } } return true ; } | opening of the session - mandatory arguments won t be needed |
1,484 | private function _updateDbExpiration ( $ sessionId ) { Kwf_Benchmark :: count ( 'sessionhdl' , '_updateDbExpiration' ) ; $ expiration = $ this -> _lifeTime + time ( ) ; Kwf_Registry :: get ( 'db' ) -> query ( "UPDATE kwf_sessions SET expiration=? WHERE sessionId=?" , array ( $ expiration , $ sessionId ) ) ; $ this -> _memcacheSet ( $ sessionId , $ this -> _initSessionData ) ; } | update of the expiration time of the db record |
1,485 | public function destroy ( $ sessionId ) { $ this -> _memcache -> delete ( Kwf_Cache_Simple :: getUniquePrefix ( ) . 'sess-' . $ sessionId ) ; $ this -> _memcache -> delete ( Kwf_Cache_Simple :: getUniquePrefix ( ) . 'sess-db-' . $ sessionId ) ; Kwf_Registry :: get ( 'db' ) -> query ( "DELETE FROM kwf_sessions WHERE sessionId=?" , $ sessionId ) ; return true ; } | destroy of the session |
1,486 | public function gc ( $ maxlifetime ) { foreach ( Kwf_Registry :: get ( 'db' ) -> query ( "SELECT sessionId FROM kwf_sessions WHERE expiration < ?" , time ( ) ) -> fetchAll ( ) as $ r ) { $ this -> destroy ( $ r [ 'sessionId' ] ) ; } return true ; } | called by the garbage collector |
1,487 | public function setCombobox ( $ box ) { $ this -> _combobox = $ box ; $ this -> _combobox -> setFormName ( $ this -> fields -> getFormName ( ) ) ; return $ this ; } | um zB die combobox durch radios zu ersetzen |
1,488 | public function includeTemplate ( $ name = null , $ module = null , $ model = null ) { $ name = Kwc_Abstract :: getTemplateFile ( $ this -> view -> data -> componentClass , $ name ) ; if ( ! $ module ) { $ module = $ this -> view ; } return $ this -> partial ( $ name , $ module , $ model ) ; } | Includes Template for current Component |
1,489 | public function componentToString ( Kwf_Component_Data $ data ) { $ ret = parent :: componentToString ( $ data ) ; $ punycode = new Kwf_Util_Punycode ( ) ; return $ punycode -> decode ( $ ret ) ; } | wird bei linklist verwendet damit url richtig ausgegeben wird |
1,490 | public function setProperty ( $ name , $ value ) { if ( is_null ( $ value ) ) { unset ( $ this -> _properties [ $ name ] ) ; } else { $ this -> _properties [ $ name ] = $ value ; } return $ this ; } | Set any property supported by ExtJS for this field |
1,491 | public function getFieldName ( ) { $ ret = $ this -> getName ( ) ; if ( $ this -> getNamePrefix ( ) ) { $ ret = $ this -> getNamePrefix ( ) . '_' . $ ret ; } return $ ret ; } | returns the fully qualified field name different to getName when using form in form |
1,492 | public function _getFeedEntries ( $ parentRow , $ xml , $ select = array ( ) ) { $ select = $ this -> select ( $ select ) ; $ pId = $ parentRow -> getInternalId ( ) ; $ this -> _data [ $ pId ] = array ( ) ; if ( $ parentRow -> format == Kwf_Util_Model_Feed_Row_Feed :: FORMAT_RSS ) { if ( in_array ( 'http://purl.org/rss/1.0/' , $ xml -> getNamespaces ( true ) ) ) { $ xml -> registerXPathNamespace ( 'rss' , 'http://purl.org/rss/1.0/' ) ; foreach ( $ xml -> xpath ( '//rss:item' ) as $ item ) { $ this -> _data [ $ pId ] [ ] = $ item ; if ( ( $ l = $ select -> getPart ( Kwf_Model_Select :: LIMIT_COUNT ) ) && count ( $ this -> _data [ $ pId ] ) == $ l ) { break ; } } } else { foreach ( $ xml -> channel -> item as $ item ) { $ this -> _data [ $ pId ] [ ] = $ item ; if ( ( $ l = $ select -> getPart ( Kwf_Model_Select :: LIMIT_COUNT ) ) && count ( $ this -> _data [ $ pId ] ) == $ l ) { break ; } } } } else { foreach ( $ xml -> entry as $ item ) { $ this -> _data [ $ pId ] [ ] = $ item ; if ( ( $ l = $ select -> getPart ( Kwf_Model_Select :: LIMIT_COUNT ) ) && count ( $ this -> _data [ $ pId ] ) == $ l ) { break ; } } } return new $ this -> _rowsetClass ( array ( 'model' => $ this , 'dataKeys' => array_keys ( $ this -> _data [ $ pId ] ) , 'parentRow' => $ parentRow ) ) ; } | darf nur von Kwf_Util_Model_Feed_Row_Feed aufgerufen werden! |
1,493 | public static function getMediaOutput ( $ id , $ type , $ className ) { $ c = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ id , array ( 'ignoreVisible' => true ) ) ; return call_user_func ( array ( get_class ( $ c -> chained -> getComponent ( ) ) , 'getMediaOutput' ) , $ c -> chained -> componentId , $ type , $ c -> chained -> componentClass ) ; } | if own_image getMediaOutput of image child component is used |
1,494 | public function checkUpdatesSettings ( ) { $ ret = true ; foreach ( $ this -> _updates as $ update ) { $ e = false ; try { $ update -> checkSettings ( ) ; } catch ( Exception $ e ) { throw $ e ; $ ret = false ; } } return $ ret ; } | Executes checkSettings method for all update scripts which should check if everything is set up correctly to execute the update script |
1,495 | public static function addListeners ( $ objOrClass ) { self :: getAllListeners ( ) ; if ( $ objOrClass instanceof Kwf_Events_Subscriber ) { self :: _addListenersFromSubscribers ( self :: $ _listeners , array ( $ objOrClass ) ) ; } else if ( is_string ( $ objOrClass ) ) { if ( is_instance_of ( $ objOrClass , 'Kwf_Model_Interface' ) ) { self :: _addListenersFromSubscribers ( self :: $ _listeners , self :: _getSubscribersFromModel ( $ objOrClass ) ) ; } else if ( is_instance_of ( $ objOrClass , 'Kwf_Component_Abstract' ) ) { self :: _addListenersFromSubscribers ( self :: $ _listeners , self :: _getSubscribersFromComponent ( $ objOrClass ) ) ; } } } | Add an additional event subscriber can be used by unit tests |
1,496 | protected function _getSearchSelect ( $ ret , $ searchRow ) { $ values = $ searchRow -> toArray ( ) ; unset ( $ values [ 'id' ] ) ; $ ret -> where ( new Kwf_Model_Select_Expr_SearchLike ( $ values , $ this -> _getSetting ( 'searchQueryFields' ) ) ) ; return $ ret ; } | rewrite this function if you want a specific search form select |
1,497 | public function getPartialParams ( ) { $ select = $ this -> _getSelect ( ) ; $ ret = array ( ) ; $ ret [ 'componentId' ] = $ this -> getData ( ) -> componentId ; $ ret [ 'count' ] = $ this -> getPagingCount ( $ select ) ; $ ret [ 'disableCache' ] = false ; $ ret [ 'cacheLifetime' ] = $ this -> getViewCacheLifetime ( ) ; $ ret [ 'disableCacheParams' ] = array ( ) ; $ paging = $ this -> _getPagingComponent ( ) ; if ( $ paging ) { $ ret [ 'paging' ] = $ paging -> getComponent ( ) -> getPartialParams ( ) ; $ ret [ 'disableCacheParams' ] [ ] = $ ret [ 'paging' ] [ 'paramName' ] ; } $ search = $ this -> _getSearchForm ( ) ; if ( $ search ) { $ ret [ 'disableCacheParams' ] [ ] = $ search -> componentId . '-post' ; } $ ret [ 'noEntriesFound' ] = $ this -> _getPlaceholder ( 'noEntriesFound' ) ; return $ ret ; } | for helper partialPaging |
1,498 | public function moreItemsAvailable ( ) { $ select = $ this -> _getSelect ( ) ; if ( $ this -> _hasSetting ( 'limit' ) ) { $ select -> unsetPart ( 'limitCount' ) ; } return $ this -> getPagingCount ( $ select ) > $ this -> _getSetting ( 'limit' ) ; } | if setting limit is set it will return hidden elements with paging |
1,499 | public function sendGlobalUserActivated ( ) { if ( $ this -> _sendMails ) { $ row = $ this -> getModel ( ) -> getKwfUserRowById ( $ this -> id ) ; $ mail = new Kwf_User_Mail_GlobalUserActivated ( $ row ) ; $ mail -> send ( ) ; $ this -> writeLog ( 'user_mail_GlobalUserActivation' ) ; } } | a global user that exists already in service but not in web |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.