Overview

Packages

  • admin
  • classes
    • media
  • CodeIgniter
    • Libraries
  • core
  • functions
  • JSMin
  • None
  • OpenID
  • PHP
  • PHPMailer
  • plugins
    • admin
    • development
    • feed
    • mail
    • media
    • misc
    • seo
    • spam
    • uploader
    • users
    • zenpage
    • zenphoto
      • news
  • Services
    • JSON

Classes

  • _zp_captcha
  • _zp_HTML_cache
  • admin_approval
  • Album
  • AlbumBase
  • AlbumZip
  • AMFReader
  • AMFStream
  • AnyFile
  • AnyFile_Options
  • Auth_OpenID
  • Auth_OpenID_AlreadySigned
  • Auth_OpenID_AssociateRequest
  • Auth_OpenID_Association
  • Auth_OpenID_AuthRequest
  • Auth_OpenID_AX
  • Auth_OpenID_AX_AttrInfo
  • Auth_OpenID_AX_Error
  • Auth_OpenID_AX_FetchRequest
  • Auth_OpenID_AX_FetchResponse
  • Auth_OpenID_AX_KeyValueMessage
  • Auth_OpenID_AX_Message
  • Auth_OpenID_AX_StoreRequest
  • Auth_OpenID_AX_StoreResponse
  • Auth_OpenID_BcMathWrapper
  • Auth_OpenID_CancelResponse
  • Auth_OpenID_CheckAuthRequest
  • Auth_OpenID_CheckIDRequest
  • Auth_OpenID_Consumer
  • Auth_OpenID_ConsumerResponse
  • Auth_OpenID_CryptUtil
  • Auth_OpenID_DatabaseConnection
  • Auth_OpenID_Decoder
  • Auth_OpenID_DiffieHellman
  • Auth_OpenID_DiffieHellmanSHA1ConsumerSession
  • Auth_OpenID_DiffieHellmanSHA1ServerSession
  • Auth_OpenID_DiffieHellmanSHA256ConsumerSession
  • Auth_OpenID_DiffieHellmanSHA256ServerSession
  • Auth_OpenID_DumbStore
  • Auth_OpenID_Encoder
  • Auth_OpenID_EncodingError
  • Auth_OpenID_Extension
  • Auth_OpenID_FailureResponse
  • Auth_OpenID_FileStore
  • Auth_OpenID_GenericConsumer
  • Auth_OpenID_GmpMathWrapper
  • Auth_OpenID_KVForm
  • Auth_OpenID_MalformedReturnURL
  • Auth_OpenID_MalformedTrustRoot
  • Auth_OpenID_Mapping
  • Auth_OpenID_MathLibrary
  • Auth_OpenID_MDB2Store
  • Auth_OpenID_MemcachedStore
  • Auth_OpenID_Message
  • Auth_OpenID_MySQLStore
  • Auth_OpenID_NamespaceMap
  • Auth_OpenID_NoReturnToError
  • Auth_OpenID_OpenIDStore
  • Auth_OpenID_PAPE_Request
  • Auth_OpenID_PAPE_Response
  • Auth_OpenID_Parse
  • Auth_OpenID_PlainTextConsumerSession
  • Auth_OpenID_PlainTextServerSession
  • Auth_OpenID_PostgreSQLStore
  • Auth_OpenID_Request
  • Auth_OpenID_Server
  • Auth_OpenID_ServerError
  • Auth_OpenID_ServerErrorContainer
  • Auth_OpenID_ServerRequest
  • Auth_OpenID_ServerResponse
  • Auth_OpenID_ServiceEndpoint
  • Auth_OpenID_ServiceEndpointLoader
  • Auth_OpenID_SessionNegotiator
  • Auth_OpenID_SetupNeededResponse
  • Auth_OpenID_Signatory
  • Auth_OpenID_SigningEncoder
  • Auth_OpenID_SQLiteStore
  • Auth_OpenID_SQLStore
  • Auth_OpenID_SRegBase
  • Auth_OpenID_SRegRequest
  • Auth_OpenID_SRegResponse
  • Auth_OpenID_SuccessResponse
  • Auth_OpenID_TrustRoot
  • Auth_OpenID_TypeURIMismatch
  • Auth_OpenID_UntrustedReturnURL
  • Auth_OpenID_WebResponse
  • Auth_Yadis_Discovery
  • Auth_Yadis_DiscoveryResult
  • Auth_Yadis_dom
  • Auth_Yadis_domxml
  • Auth_Yadis_HTTPFetcher
  • Auth_Yadis_HTTPResponse
  • Auth_Yadis_Manager
  • Auth_Yadis_ManagerLoader
  • Auth_Yadis_ParanoidHTTPFetcher
  • Auth_Yadis_ParseHTML
  • Auth_Yadis_PHPSession
  • Auth_Yadis_PlainHTTPFetcher
  • Auth_Yadis_ProxyResolver
  • Auth_Yadis_Service
  • Auth_Yadis_SessionLoader
  • Auth_Yadis_XMLParser
  • Auth_Yadis_XRDS
  • Auth_Yadis_Yadis
  • auto_backup
  • AVCSequenceParameterSetReader
  • bxslider
  • cacheManager
  • cacheManagerFeed
  • CI_jsmin
  • CI_load
  • cloneZenphoto
  • codeIgniter_kludge
  • colorbox
  • Comment
  • comment_form
  • contactformOptions
  • crop_image
  • cycle
  • defaultCodeblocks
  • deprecated_functions
  • DownloadList
  • dynamic_locale
  • dynamicAlbum
  • elFinder_options
  • email_new_user
  • exampleMacros
  • external_auth
  • ExternalFeed
  • externalFeed_options
  • favorites
  • favoritesOptions
  • federated_logon
  • feed
  • fieldExtender
  • flag_thumbnail
  • Gallery
  • galleryArticles
  • getID3
  • getid3_aac
  • getid3_apetag
  • getid3_flv
  • getid3_handler
  • getid3_id3v1
  • getid3_id3v2
  • getid3_lib
  • getid3_lyrics3
  • getid3_mp3
  • getid3_mpeg
  • getid3_quicktime
  • getid3_swf
  • GoogleMap
  • Googlemaps
  • googleVerifyOptions
  • hitcounter
  • HTML
  • htmlmetatags
  • http_auth
  • Image
  • image_effects
  • internal_deprecations
  • ipBlocker
  • jcarousel
  • jPlayer
  • jplayer_options
  • jquery_rating
  • JSMin
  • lib_GD_Options
  • lib_Imagick_Options
  • lib_NoGraphics
  • MediaObject
  • menu_manager
  • MergedRSS
  • MergedRSSOptions
  • mobile
  • Mobile_Detect
  • mobileTheme
  • multipleLayoutOptions
  • null_seo
  • OAuthConsumer
  • OAuthDataStore
  • OAuthRequest
  • OAuthServer
  • OAuthSignatureMethod
  • OAuthSignatureMethod_HMAC_SHA1
  • OAuthSignatureMethod_PLAINTEXT
  • OAuthSignatureMethod_RSA_SHA1
  • OAuthToken
  • OAuthUtil
  • pagedThumbsNav
  • pagedthumbsOptions
  • PclZip
  • PersistentObject
  • PHPMailer
  • PlainText
  • POP3
  • print_album_menu
  • pseudoPlayer
  • publishContent
  • quota_manager
  • reCaptcha
  • ReCaptchaResponse
  • register_user
  • rewriteRules
  • rewriteTokens
  • RSS
  • RSS_internal_deprecations
  • rss_options
  • search_statistics
  • SearchEngine
  • security_logger
  • seo_locale
  • Services_JSON
  • Services_JSON_Error
  • setupexternalFeed
  • setupRSS
  • show_not_loggedin
  • sitemap
  • slideshow
  • SMTP
  • static_html_cache
  • tagsuggest
  • TextObject
  • TextObject_internal_deprecations
  • TextObject_Options
  • ThemeObject
  • themeSwitcher
  • tinymce4Options
  • tinyURL
  • Transientimage
  • tweet
  • TwitterOAuth
  • UploadHandler
  • user_expiry
  • user_groups
  • user_logout_options
  • userAddressFields
  • utf8
  • Video
  • Video_internal_deprecations
  • VideoObject_Options
  • viewer_size_image_options
  • WEBdocs
  • WEBdocs_Options
  • xmpMetadata
  • Zenpage
  • Zenpage_internal_deprecations
  • ZenpageCategory
  • zenpagecms
  • ZenpageItems
  • ZenpageNews
  • ZenpagePage
  • ZenpageRoot
  • Zenphoto_Administrator
  • Zenphoto_Authority
  • zenphoto_org_news
  • zenphoto_seo
  • zenphotoDonate
  • ZipStream
  • zp_PHPMailer
  • zpCaptcha
  • zpFunctions
  • zpLegacySpam
  • zpMutex
  • zpSimpleSpam
  • zpTrivialSpam

Exceptions

  • BadFunctionCallException
  • BadMethodCallException
  • Exception
  • getid3_exception
  • JSMin_UnterminatedCommentException
  • JSMin_UnterminatedRegExpException
  • JSMin_UnterminatedStringException
  • LogicException
  • OAuthExcept
  • phpmailerException

Functions

  • __autoload
  • _escape_xref
  • _recaptcha_aes_encrypt
  • _recaptcha_aes_pad
  • _recaptcha_http_post
  • _recaptcha_mailhide_email_parts
  • _recaptcha_mailhide_urlbase64
  • _recaptcha_qsencode
  • accessAllAlbums
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addGeoCoord
  • addItem
  • addPagesToDatabase
  • addPluginScript
  • addPluginType
  • addSubalbumMenus
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • Auth_OpenID_arrangeByType
  • Auth_OpenID_AX_checkAlias
  • Auth_OpenID_AX_toTypeURIs
  • Auth_OpenID_bestMatchingService
  • Auth_OpenID_checkFieldName
  • Auth_OpenID_checkSessionType
  • Auth_OpenID_checkTimestamp
  • Auth_OpenID_detectMathLibrary
  • Auth_OpenID_discover
  • Auth_OpenID_discoverURI
  • Auth_OpenID_discoverWithoutYadis
  • Auth_OpenID_discoverWithYadis
  • Auth_OpenID_discoverXRI
  • Auth_OpenID_extractReturnURL
  • Auth_OpenID_findOPLocalIdentifier
  • Auth_OpenID_getAllAssociationTypes
  • Auth_OpenID_getAllowedReturnURLs
  • Auth_OpenID_getAuthorityPattern
  • Auth_OpenID_getAvailableSessionTypes
  • Auth_OpenID_getDefaultAssociationOrder
  • Auth_OpenID_getDefaultGen
  • Auth_OpenID_getDefaultMod
  • Auth_OpenID_getDefaultNegotiator
  • Auth_OpenID_getEncodedPattern
  • Auth_OpenID_getEncryptedNegotiator
  • Auth_OpenID_getEscapeRE
  • Auth_OpenID_getMathLib
  • Auth_OpenID_getOnlyEncryptedOrder
  • Auth_OpenID_getOpenIDConsumerTypeURIs
  • Auth_OpenID_getOpenIDTypeName
  • Auth_OpenID_getOpenIDTypeURIs
  • Auth_OpenID_getOPOrUserServices
  • Auth_OpenID_getSecretSize
  • Auth_OpenID_getSessionTypes
  • Auth_OpenID_getSupportedAssociationTypes
  • Auth_OpenID_getUnreserved
  • Auth_OpenID_getURIPattern
  • Auth_OpenID_getURLIllegalCharRE
  • Auth_OpenID_HMACSHA1
  • Auth_OpenID_HMACSHA256
  • Auth_OpenID_include_init
  • Auth_OpenID_isError
  • Auth_OpenID_isOpenID1
  • Auth_OpenID_legacy_discover
  • Auth_OpenID_makeOpenIDEndpoints
  • Auth_OpenID_math_extensions
  • Auth_OpenID_mkNonce
  • Auth_OpenID_noMathSupport
  • Auth_OpenID_pct_encoded_replace
  • Auth_OpenID_pct_encoded_replace_unreserved
  • Auth_OpenID_registerNamespaceAlias
  • Auth_OpenID_remove_dot_segments
  • Auth_OpenID_removeNamespaceAlias
  • Auth_OpenID_returnToMatches
  • Auth_OpenID_setNoMathSupport
  • Auth_OpenID_SHA1
  • Auth_OpenID_SHA256
  • Auth_OpenID_splitNonce
  • Auth_OpenID_supportsSReg
  • Auth_OpenID_urinorm
  • Auth_OpenID_verifyReturnTo
  • Auth_Yadis_array_scramble
  • Auth_Yadis_escapeForIRI
  • Auth_Yadis_getCanonicalID
  • Auth_Yadis_getDefaultProxy
  • Auth_Yadis_getEscapeRE
  • Auth_Yadis_getIPrivateChars
  • Auth_Yadis_getNSMap
  • Auth_Yadis_getServiceEndpoints
  • Auth_Yadis_getSupportedExtensions
  • Auth_Yadis_getUCSChars
  • Auth_Yadis_getXMLParser
  • Auth_Yadis_getXRDExpiration
  • Auth_Yadis_getXrefRE
  • Auth_Yadis_getXRIAuthorities
  • Auth_Yadis_identifierScheme
  • Auth_Yadis_iriToURI
  • Auth_Yadis_pct_escape_unicode
  • Auth_Yadis_providerIsAuthoritative
  • Auth_Yadis_rootAuthority
  • Auth_Yadis_setDefaultParser
  • Auth_Yadis_startswith
  • Auth_Yadis_toIRINormal
  • Auth_Yadis_toURINormal
  • Auth_Yadis_XRI
  • Auth_Yadis_XRIAppendArgs
  • authorSelector
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForPassword
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkNewsAccess
  • checkNewsCategoryPassword
  • checkObjectsThumb
  • checkPagePassword
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSelectedAlbum
  • checkSignature
  • cleanAlbum
  • cleanHTML
  • clearSitemapCache
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • countArticles
  • countCombiNews
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • cron_starter
  • currentRelativeURL
  • customOptions
  • dateDiff
  • datepickerJS
  • dateTimeConvert
  • db_affected_rows
  • db_close
  • db_collation
  • db_connect
  • db_count
  • db_create
  • db_create_table
  • db_error
  • db_fetch_assoc
  • db_fetch_row
  • db_free_result
  • db_getSQLmode
  • db_insert_id
  • db_LIKE_escape
  • db_list_fields
  • db_name
  • db_num_rows
  • db_permissions
  • db_quote
  • db_setSQLmode
  • db_show
  • db_software
  • db_table_update
  • db_truncate_table
  • debug404
  • debugLog
  • debugLogBacktrace
  • debugLogVar
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • detect_fetcher
  • detect_math
  • detect_query_corruption
  • detect_random
  • detect_stores
  • detect_xml
  • dircopy
  • displayError
  • doIncludes
  • elFinder_admin_tabs
  • elFinder_tinymce
  • enableExtension
  • escape
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • filter_extractReturnURL
  • filter_MatchesAnyOpenIDConsumerType
  • filter_MatchesAnyOpenIDType
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • genAlbumList
  • generateCaptcha
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateSitemapCacheFile
  • generateSitemapIndexCacheFile
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminThumb
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumId
  • getAlbumInherited
  • getAlbumLinkURL
  • getAlbumLocation
  • getAlbumPage
  • getAlbumPlace
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllArticleDates
  • getAllCategories
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllSubalbums
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getArticles
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsAlbumTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCategory
  • getCategoryID
  • getCategoryLink
  • getCategoryParentID
  • getCategorySortOrder
  • getCategoryTitle
  • getCheckboxState
  • getCodeblock
  • getCombiNews
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDate
  • getCommentDateTime
  • getCommentErrors
  • getCommentsAllowed
  • getCommentStored
  • getCommentTime
  • getConsumer
  • getContentShorten
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentNewsCategory
  • getCurrentNewsCategoryID
  • getCurrentNewsCategoryParentID
  • getCurrentNewsPage
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDefaultHeight
  • getDefaultSizedImage
  • getDefaultWidth
  • getDownloadLink
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFirstImageURL
  • getFullHeight
  • getFullImageURL
  • getFullNewsImage
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageEXIFData
  • getImageGeodata
  • getImageID
  • getImageLinkURL
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageSortOrder
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLanguageArray
  • getLanguageFlag
  • getLastImageURL
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLink
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsAlbumName
  • getNewsAlbumTitle
  • getNewsAlbumURL
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryPath
  • getNewsCategoryURL
  • getNewsContent
  • getNewsContentShorten
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsImageTags
  • getNewsIndexURL
  • getNewsLink
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsTitleLink
  • getNewsTitlePath
  • getNewsType
  • getNewsURL
  • getNewsVideoContent
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getNumSubalbums
  • getOpenIDURL
  • getOption
  • getOptionFromDB
  • getOptionList
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageLinkPath
  • getPageLinkURL
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPages
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentItems
  • getParentMenuItems
  • getParentNewsCategories
  • getParentPages
  • getPasswordProtectImage
  • getPHPFiles
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getRelatedItems
  • getRequestURI
  • getReturnTo
  • getRSSHeaderLink
  • getRSSLink
  • getScheme
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSitemapAlbumList
  • getSitemapAlbums
  • getSitemapGoogleImageVideoExtras
  • getSitemapGoogleLoopIndex
  • getSitemapImages
  • getSitemapIndexLinks
  • getSitemapZenpageNewsArticles
  • getSitemapZenpageNewsCategories
  • getSitemapZenpageNewsIndex
  • getSitemapZenpagePages
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getStore
  • getSubCategories
  • getSubtabs
  • getSuffix
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext_pl
  • gettext_th
  • getTheme
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalArticles
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getTrustRoot
  • getUnprotectedImageURL
  • getUrAlbum
  • getURL
  • getUserIP
  • getUserLocale
  • getVersion
  • getViewerImageSize
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpageHitcounter
  • getZenpageRSSHeaderLink
  • getZenpageRSSLink
  • getZenpageStatistic
  • googleVerifyHead
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextPage
  • hasPrevImage
  • hasPrevPage
  • hitcounter
  • html_decode
  • html_encode
  • html_encodeTagged
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • imageBlurGD
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • inNewsCategory
  • inProtectedNewsCategory
  • installSignature
  • instrument
  • inSubNewsCategoryOf
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_GalleryNewsType
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_NewsType
  • is_Pages
  • is_valid_email_zp
  • is_valid_image
  • is_valid_other_type
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isLandscape
  • isMyAlbum
  • isMyNews
  • isMyPage
  • isolate
  • isProtectedAlbum
  • isProtectedNewsCategory
  • isProtectedPage
  • isSubNewsCategoryOf
  • isValidURL
  • jQueryUpload_head
  • jQueryUpload_headers
  • jQueryUploadHandler
  • jQueryUploadHandler_admin_tabs
  • js_encode
  • json_decode
  • json_encode
  • kses
  • kses_array_lc
  • kses_attr
  • kses_bad_protocol
  • kses_bad_protocol_once
  • kses_bad_protocol_once2
  • kses_check_attr_val
  • kses_decode_entities
  • kses_hair
  • kses_hook
  • kses_html_error
  • kses_js_entities
  • kses_no_null
  • kses_normalize_entities
  • kses_normalize_entities2
  • kses_split
  • kses_split2
  • kses_stripslashes
  • kses_version
  • ksesProcess
  • layoutSelector
  • layoutSelector_album
  • listDBUses
  • listDirectoryFiles
  • listUses
  • load_zenpage_news
  • load_zenpage_pages
  • loadLocalOptions
  • log_message
  • lookupSortKey
  • macro_admin_tabs
  • macroList_show
  • makeAlbumCurrent
  • makeImageCurrent
  • makeSpecialImageName
  • markRelease_button
  • mb_strlen
  • mb_strpos
  • mb_strrpos
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • menu_admin_toolbox_global
  • menu_tabs
  • minDiff
  • mkdir_recursive
  • my_truncate_string
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext_pl
  • ngettext_th
  • normalizeColumns
  • omsAdditions
  • openedForComments
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • passAlbums
  • passImages
  • pathurlencode
  • PclZipUtilCopyBlock
  • PclZipUtilOptionText
  • PclZipUtilPathInclusion
  • PclZipUtilPathReduction
  • PclZipUtilRename
  • PclZipUtilTranslateWinPath
  • PHPMailerAutoload
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminToolbox
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLink
  • printAlbumLocation
  • printAlbumMap
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumPlace
  • printAlbumRating
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAlbumZip
  • printAllDates
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBulkActions
  • printCaptcha
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxHeight
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printDownloadLink
  • printDownloadLinkAlbumZip
  • printdownloadList
  • printDownloadURL
  • printEditable
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesLink
  • printFavoritesURL
  • printField
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageDiv
  • printImageEXIFData
  • printImageID
  • printImageLink
  • printImageMap
  • printImageMetadata
  • printImageRating
  • printImageSortOrder
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjCarouselThumbNav
  • printjPlayerPlaylist
  • printLanguageSelector
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLatestZenpageComments
  • printLink
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsImageTags
  • printNewsIndexURL
  • printNewsLink
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsReadMoreLink
  • printNewsStatistic
  • printNewsTitle
  • printNewsTitleLink
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageLink
  • printNextPageURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageLinkURL
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printParentPagesBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPreloadScript
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageLink
  • printPrevPageURL
  • printPublished
  • printPublishIconLink
  • printRandomImages
  • printRating
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printSearchBreadcrumb
  • printSearchForm
  • printSiteHomeURL
  • printSizedImageLink
  • printSizedImageURL
  • printSlideShow
  • printSlideShowJS
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSizeImage
  • printUserSizeSelector
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePagesSelector
  • printZenpageRSSHeaderLink
  • printZenpageRSSLink
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExpired
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • publishItem
  • purgeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • recaptcha_check_answer
  • recaptcha_get_html
  • recaptcha_get_signup_url
  • recaptcha_mailhide_html
  • recaptcha_mailhide_url
  • reconfigureAction
  • reconfigureCS
  • reconfigurePage
  • recordMissing
  • rem_context
  • removeParentAlbumNames
  • resetCurrentAlbum
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewrite_path_zenpage
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • run
  • safe_fnmatch
  • safe_glob
  • sanitize
  • sanitize_numeric
  • sanitize_path
  • sanitize_script
  • sanitize_string
  • sanitizeRedirect
  • save_context
  • saveLayoutSelection
  • saveZenphotoLayoutSelection
  • search_quote
  • secureServer
  • seo_cleanup_button
  • seoFriendly
  • seoFriendlyJS
  • set_context
  • setAlbumCustomData
  • setAlbumSubtabs
  • setImageCustomData
  • setMainDomain
  • setOption
  • setOptionDefault
  • setPluginDomain
  • setThemeColumns
  • setThemeDomain
  • setThemeOption
  • setThemeOptionDefault
  • setupAllowedMaps
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • showOrNotShowField
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • sitemap_echonl
  • sitemap_getChangefreq
  • sitemap_getDateformat
  • sitemap_getDBLimit
  • sitemap_getISO8601Date
  • skipScheduledPublishing
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • themeIsEditable
  • themeSetup
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • wordpress_import_button
  • wp_prefix
  • wp_query_full_array
  • wpimport_TryAgainError
  • XSRFdefender
  • XSRFToken
  • zenJavascript
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageHitcounter
  • zenpageJSCSS
  • zenpageOpenedForComments
  • zenpagePublish
  • zenphoto_PHPMailer
  • zenphoto_sendmail
  • zenPhotoTheme
  • zp_apply_filter
  • zp_clearCookie
  • zp_colorAllocate
  • zp_cookieEncode
  • zp_copyCanvas
  • zp_createImage
  • zp_drawRectangle
  • zp_error
  • zp_filter_slot
  • zp_filter_unique_id
  • zp_getCookie
  • zp_getFonts
  • zp_graphicsLibInfo
  • zp_handle_password
  • zp_handle_password_single
  • zp_has_filter
  • zp_image_types
  • zp_imageCanRotate
  • zp_imageColorTransparent
  • zp_imageDims
  • zp_imageFill
  • zp_imageFontHeight
  • zp_imageFontWidth
  • zp_imageFromString
  • zp_imageGet
  • zp_imageGray
  • zp_imageHeight
  • zp_imageIPTC
  • zp_imageKill
  • zp_imageLoadFont
  • zp_imageMerge
  • zp_imageOutput
  • zp_imageResizeAlpha
  • zp_imageUnsharpMask
  • zp_imageWidth
  • zp_load_album
  • zp_load_gallery
  • zp_load_image
  • zp_load_page
  • zp_load_request
  • zp_load_search
  • zp_loggedin
  • zp_mail
  • zp_register_filter
  • zp_remove_filter
  • zp_resampleImage
  • zp_rotateImage
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
   1: <?php
   2: /**
   3:  * zenpage template functions
   4:  *
   5:  * @author Malte Müller (acrylian), Stephen Billard (sbillard)
   6:  * @package plugins
   7:  * @subpackage zenpage
   8:  */
   9: /* * ********************************************* */
  10: /* ZENPAGE TEMPLATE FUNCTIONS
  11:     /*********************************************** */
  12: 
  13: 
  14: /* * ********************************************* */
  15: /* General functions
  16:     /*********************************************** */
  17: 
  18: /**
  19:  * Checks if the current page is in news context.
  20:  *
  21:  * @return bool
  22:  */
  23: function is_News() {
  24:     global $_zp_current_zenpage_news;
  25:     return(!is_null($_zp_current_zenpage_news));
  26: }
  27: 
  28: /**
  29:  * Checks if the current page is the news page in general.
  30:  *
  31:  * @return bool
  32:  */
  33: function is_NewsPage() {
  34:     global $_zp_gallery_page;
  35:     return $_zp_gallery_page == 'news.php';
  36: }
  37: 
  38: /**
  39:  * Checks if the current page is a single news article page
  40:  *
  41:  * @return bool
  42:  */
  43: function is_NewsArticle() {
  44:     return is_News() && in_context(ZP_ZENPAGE_SINGLE);
  45: }
  46: 
  47: /**
  48:  * Checks if the current page is a news category page
  49:  *
  50:  * @return bool
  51:  */
  52: function is_NewsCategory() {
  53:     return in_context(ZP_ZENPAGE_NEWS_CATEGORY);
  54: }
  55: 
  56: /**
  57:  * Checks if the current page is a news archive page
  58:  *
  59:  * @return bool
  60:  */
  61: function is_NewsArchive() {
  62:     return in_context(ZP_ZENPAGE_NEWS_DATE);
  63: }
  64: 
  65: /**
  66:  * Checks if the current page is a zenpage page
  67:  *
  68:  * @return bool
  69:  */
  70: function is_Pages() {
  71:     return in_context(ZP_ZENPAGE_PAGE);
  72: }
  73: 
  74: /**
  75:  * returns the "sticky" value of the news article
  76:  * @param obj $newsobj optional news object to check directly outside news context
  77:  * @return bool
  78:  */
  79: function stickyNews($newsobj = NULL) {
  80:     global $_zp_current_zenpage_news;
  81:     if (is_null($newsobj)) {
  82:         $newsobj = $_zp_current_zenpage_news;
  83:     }
  84:     return $newsobj->getSticky();
  85: 
  86:     return false;
  87: }
  88: 
  89: /**
  90:  * Wrapper function to get the author of a news article or page: Used by getNewsAuthor() and getPageAuthor().
  91:  *
  92:  * @param bool $fullname False for the user name, true for the full name
  93:  *
  94:  * @return string
  95:  */
  96: function getAuthor($fullname = false) {
  97:     global $_zp_current_zenpage_page, $_zp_current_zenpage_news;
  98: 
  99:     if (is_Pages()) {
 100:         $obj = $_zp_current_zenpage_page;
 101:     } else if (is_News()) {
 102:         $obj = $_zp_current_zenpage_news;
 103:     } else {
 104:         $obj = false;
 105:     }
 106:     if ($obj) {
 107:         if ($fullname) {
 108:             $admin = Zenphoto_Authority::getAnAdmin(array('`user`=' => $obj->getAuthor(), '`valid`=' => 1));
 109:             if (is_object($admin) && $admin->getName()) {
 110:                 return $admin->getName();
 111:             }
 112:         }
 113:         return $obj->getAuthor();
 114:     }
 115:     return false;
 116: }
 117: 
 118: /* * ********************************************* */
 119: /* News article functions
 120:     /*********************************************** */
 121: 
 122: /**
 123:  * Gets the latest news either only news articles or with the latest images or albums
 124:  *
 125:  * NOTE: This function excludes articles that are password protected via a category for not logged in users!
 126:  *
 127:  * @param int $number The number of news items to get
 128:  * @param string $category Optional news articles by category (only "none" option)
 129:  * @param bool $sticky place sticky articles at the front of the list
 130:  * @param string $sortdirection 'asc' ascending otherwise descending
 131:  * @return array
 132:  */
 133: function getLatestNews($number = 2, $category = '', $sticky = true, $sortdirection = 'desc') {
 134:     global $_zp_zenpage, $_zp_current_zenpage_news;
 135:     //check if things are deprecated
 136:     $args = func_get_args();
 137:     $deprecated = array(
 138:                     "none",
 139:                     "with_latest_images",
 140:                     "with_latest_images_date",
 141:                     "with_latest_images_mtime",
 142:                     "with_latest_images_publishdate",
 143:                     "with_latest_albums",
 144:                     "with_latest_albums_date",
 145:                     "with_latest_albums_mtime",
 146:                     "with_latest_albums_publishdate",
 147:                     "with_latestupdated_albums");
 148:     if (in_array($category, $deprecated)) {
 149:         // there must be the old options parameter!
 150:         Zenpage_internal_deprecations::getLatestNews();
 151:         list($number, $category, $sticky, $sortdirection ) = array_merge($args, array(NULL, NULL, NULL, NULL, NULL));
 152:     }
 153:     $sortdir = strtolower($sortdirection) != 'asc';
 154:     if (empty($category)) {
 155:         $latest = $_zp_zenpage->getArticles($number, NULL, true, NULL, $sortdir, $sticky, NULL);
 156:     } else {
 157:         $catobj = new ZenpageCategory($category);
 158:         $latest = $catobj->getArticles($number, NULL, true, NULL, $sortdir, $sticky);
 159:     }
 160:     return $latest;
 161: }
 162: 
 163: /**
 164:  * Prints the latest news either only news articles or with the latest images or albums as a unordered html list
 165:  *
 166:  * NOTE: Latest images and albums require the image_album_statistic plugin
 167:  *
 168:  * @param int $number The number of news items to get
 169:  * @param string $category Optional news articles by category (only "none" option"
 170:  * @param bool $showdate If the date should be shown
 171:  * @param bool $showcontent If the content should be shown
 172:  * @param int $contentlength The lengths of the content
 173:  * @param bool $showcat If the categories should be shown
 174:  * @param string $readmore Text for the read more link, if empty the option value for "zenpage_readmore" is used
 175:  * @param bool $sticky place sticky articles at the front of the list
 176:  * @return string
 177:  */
 178: function printLatestNews($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true, $readmore = NULL, $sticky = true) {
 179:     global $_zp_gallery, $_zp_current_zenpage_news;
 180:     //check if things are deprecated
 181:     $args = func_get_args();
 182:     $deprecated = array(
 183:                     "none",
 184:                     "with_latest_images",
 185:                     "with_latest_images_date",
 186:                     "with_latest_images_mtime",
 187:                     "with_latest_images_publishdate",
 188:                     "with_latest_albums",
 189:                     "with_latest_albums_date",
 190:                     "with_latest_albums_mtime",
 191:                     "with_latest_albums_publishdate",
 192:                     "with_latestupdated_albums");
 193:     if (in_array($category, $deprecated)) {
 194:         // there must be the old options parameter!
 195:         Zenpage_internal_deprecations::printLatestNews();
 196:         list($number, $option, $category, $showdate, $showcontent, $contentlength, $showcat, $readmore, $sticky) = array_merge($args, array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
 197:     }
 198: 
 199:     $latest = getLatestNews($number, $category, $sticky);
 200:     echo "\n<ul id=\"latestnews\">\n";
 201:     $count = "";
 202:     foreach ($latest as $item) {
 203:         $count++;
 204:         $category = "";
 205:         $categories = "";
 206: 
 207:         $obj = new ZenpageNews($item['titlelink']);
 208:         $title = html_encode($obj->getTitle());
 209:         $link = html_encode(getNewsURL($item['titlelink']));
 210:         $count2 = 0;
 211:         $category = $obj->getCategories();
 212:         foreach ($category as $cat) {
 213:             $catobj = new ZenpageCategory($cat['titlelink']);
 214:             $count2++;
 215:             if ($count2 != 1) {
 216:                 $categories = $categories . ", ";
 217:             }
 218:             $categories = $categories . $catobj->getTitle();
 219:         }
 220:         $thumb = "";
 221:         $content = $obj->getContent();
 222:         if ($obj->getTruncation()) {
 223:             $shorten = true;
 224:         }
 225:         $date = zpFormattedDate(DATE_FORMAT, strtotime($item['date']));
 226:         echo "<li>";
 227:         echo "<h3><a href=\"" . $link . "\" title=\"" . getBare(html_encode($title)) . "\">" . $title . "</a></h3>\n";
 228:         if ($showdate) {
 229:             echo "<span class=\"latestnews-date\">" . $date . "</span>\n";
 230:         }
 231:         if ($showcontent) {
 232:             echo "<span class=\"latestnews-desc\">" . getContentShorten($content, $contentlength, '', $readmore, $link) . "</span>\n";
 233:         }
 234:         if ($showcat && !empty($categories)) {
 235:             echo "<span class=\"latestnews-cats\">(" . html_encode($categories) . ")</span>\n";
 236:         }
 237:         echo "</li>\n";
 238:         if ($count == $number) {
 239:             break;
 240:         }
 241:     }
 242:     echo "</ul>\n";
 243: }
 244: 
 245: /**
 246:  * Returns the number of news articles.
 247:  *
 248:  * When in search context this is the count of the articles found. Otherwise
 249:  * it is the count of articles that match the criteria.
 250:  *
 251:  * @param bool $total
 252:  * @return int
 253:  */
 254: function getNumNews($total = false) {
 255:     global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_news_restore, $_zp_zenpage_articles, $_zp_gallery, $_zp_current_search;
 256:     if ($total) {
 257:         return count($_zp_zenpage->getArticles(0));
 258:     } else if (in_context(ZP_SEARCH)) {
 259:         return count($_zp_current_search->getArticles());
 260:     } else {
 261:         return count($_zp_zenpage->getArticles(0));
 262:     }
 263: }
 264: 
 265: /**
 266:  * Returns the next news item on a page.
 267:  * sets $_zp_current_zenpage_news to the next news item
 268:  * Returns true if there is an new item to be shown
 269:  *
 270:  * @return bool
 271:  */
 272: function next_news() {
 273:     global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_news_restore, $_zp_zenpage_articles, $_zp_current_category, $_zp_gallery, $_zp_current_search;
 274:     if (func_num_args() != 0) {
 275:         //  These parameters are deprecated
 276:         Zenpage_internal_deprecations::next_news();
 277:     }
 278: 
 279:     if (is_null($_zp_zenpage_articles)) {
 280:         if (in_context(ZP_SEARCH)) {
 281:             //note: we do not know how to paginate the search page, so for now we will return all news articles
 282:             $_zp_zenpage_articles = $_zp_current_search->getArticles(ZP_ARTICLES_PER_PAGE, NULL, true, NULL, NULL);
 283:         } else {
 284:             if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
 285:                 $_zp_zenpage_articles = $_zp_current_category->getArticles(ZP_ARTICLES_PER_PAGE, NULL, false, NULL, NULL);
 286:             } else {
 287:                 $_zp_zenpage_articles = $_zp_zenpage->getArticles(ZP_ARTICLES_PER_PAGE, NULL, false, NULL, NULL);
 288:             }
 289:             if (empty($_zp_zenpage_articles)) {
 290:                 return NULL;
 291:             }
 292:         }
 293:         $_zp_current_zenpage_news_restore = $_zp_current_zenpage_news;
 294:     }
 295:     if (!empty($_zp_zenpage_articles)) {
 296:         $news = array_shift($_zp_zenpage_articles);
 297:         if (is_array($news)) {
 298:             add_context(ZP_ZENPAGE_NEWS_ARTICLE);
 299:             $_zp_current_zenpage_news = new ZenpageNews($news['titlelink']);
 300:             return true;
 301:         }
 302:     }
 303: 
 304:     $_zp_zenpage_articles = NULL;
 305:     $_zp_current_zenpage_news = $_zp_current_zenpage_news_restore;
 306:     rem_context(ZP_ZENPAGE_NEWS_ARTICLE);
 307:     return false;
 308: }
 309: 
 310: /**
 311:  * Gets the id of a news article/item
 312:  *
 313:  * @return int
 314:  */
 315: function getNewsID() {
 316:     global $_zp_current_zenpage_news;
 317:     if (!is_null($_zp_current_zenpage_news)) {
 318:         return $_zp_current_zenpage_news->getID();
 319:     }
 320: }
 321: 
 322: /**
 323:  * Gets the news article title
 324:  *
 325:  * @return string
 326:  */
 327: function getNewsTitle() {
 328:     global $_zp_current_zenpage_news;
 329:     if (!is_null($_zp_current_zenpage_news)) {
 330:         return $_zp_current_zenpage_news->getTitle();
 331:     }
 332: }
 333: 
 334: /**
 335:  * prints the news article title
 336:  *
 337:  * @param string $before insert if you want to use for the breadcrumb navigation or in the html title tag
 338:  */
 339: function printNewsTitle($before = '') {
 340:     if ($title = getNewsTitle()) {
 341:         if ($before) {
 342:             echo '<span class="beforetext">' . html_encode($before) . '</span>';
 343:         }
 344:         echo html_encode($title);
 345:     }
 346: }
 347: 
 348: /**
 349:  * Returns the raw title of a news article.
 350:  *
 351:  *
 352:  * @return string
 353:  */
 354: function getBareNewsTitle() {
 355:     return getBare(getNewsTitle());
 356: }
 357: 
 358: function printBareNewsTitle() {
 359:     echo html_encode(getBareNewsTitle());
 360: }
 361: 
 362: /**
 363:  * Returns the link (url) of the current news article.
 364:  * or of the titlelink passed if not empty
 365:  *
 366:  * @param string $titlelink
 367:  * @return string
 368:  */
 369: function getNewsURL($titlelink = NULL) {
 370:     global $_zp_current_zenpage_news;
 371:     if (empty($titlelink)) {
 372:         $obj = $_zp_current_zenpage_news;
 373:     } else {
 374:         $obj = new ZenpageNews($titlelink);
 375:     }
 376:     if (!is_null($obj))
 377:         return $obj->getLink();
 378: }
 379: 
 380: /**
 381:  * Prints the title of a news article as a full html link
 382:  *
 383:  * @param string $before insert what you want to be show before the titlelink.
 384:  */
 385: function printNewsURL($before = '') {
 386:     if (getNewsTitle()) {
 387:         if ($before) {
 388:             $before = '<span class="beforetext">' . html_encode($before) . '</span>';
 389:         }
 390:         echo "<a href=\"" . html_encode(getNewsURL()) . "\" title=\"" . getBareNewsTitle() . "\">" . $before . html_encodeTagged(getNewsTitle()) . "</a>";
 391:     }
 392: }
 393: 
 394: /**
 395:  * Gets the content of a news article
 396:  *
 397:  * If using the CombiNews feature this returns the description for gallery items (see printNewsContent for more)
 398:  *
 399:  * @param int $shorten The optional length of the content for the news list for example, will override the plugin option setting if set, "" (empty) for full content (not used for image descriptions!)
 400:  * @param string $shortenindicator The placeholder to mark the shortening (e.g."(...)"). If empty the Zenpage option for this is used.
 401:  * @param string $readmore The text for the "read more" link. If empty the term set in Zenpage option is used.
 402:  *
 403:  * @return string
 404:  */
 405: function getNewsContent($shorten = false, $shortenindicator = NULL, $readmore = NULL) {
 406:     global $_zp_current_image, $_zp_gallery, $_zp_current_zenpage_news, $_zp_page;
 407:     if (!$_zp_current_zenpage_news->checkAccess()) {
 408:         return '<p>' . gettext('<em>This entry belongs to a protected category.</em>') . '</p>';
 409:     }
 410:     $excerptbreak = false;
 411:     if (!$shorten && !is_NewsArticle()) {
 412:         $shorten = ZP_SHORTEN_LENGTH;
 413:     }
 414: 
 415:     $articlecontent = $_zp_current_zenpage_news->getContent();
 416:     if (!is_NewsArticle()) {
 417:         if ($_zp_current_zenpage_news->getTruncation()) {
 418:             $shorten = true;
 419:         }
 420:         $articlecontent = getContentShorten($articlecontent, $shorten, $shortenindicator, $readmore, $_zp_current_zenpage_news->getLink());
 421:     }
 422: 
 423:     return $articlecontent;
 424: }
 425: 
 426: /**
 427:  * Prints the news article content. Note: TinyMCE used by Zenpage for news articles may already add a surrounding <p></p> to the content.
 428:  *
 429:  * If using the CombiNews feature this prints the thumbnail or sized image for a gallery item.
 430:  * If using the 'CombiNews sized image' mode it shows movies directly and the description below.
 431:  *
 432:  * @param int $shorten $shorten The lengths of the content for the news main page for example (only for video/audio descriptions, not for normal image descriptions)
 433:  * @param string $shortenindicator The placeholder to mark the shortening (e.g."(...)"). If empty the Zenpage option for this is used.
 434:  * @param string $readmore The text for the "read more" link. If empty the term set in Zenpage option is used.
 435:  */
 436: function printNewsContent($shorten = false, $shortenindicator = NULL, $readmore = NULL) {
 437:     global $_zp_current_zenpage_news, $_zp_page;
 438:     $newscontent = getNewsContent($shorten, $shortenindicator, $readmore);
 439:     echo html_encodeTagged($newscontent);
 440: }
 441: 
 442: /**
 443:  * Shorten the content of any type of item and add the shorten indicator and readmore link
 444:  * set on the Zenpage plugin options. Helper function for getNewsContent() but usage of course not limited to that.
 445:  * If there is nothing to shorten the content passed.
 446:  *
 447:  * The read more link is wrapped within <p class="readmorelink"></p>.
 448:  *
 449:  * @param string $text The text content to be shortenend.
 450:  * @param mixed $shorten The lenght the content should be shortened. Set to true for shorten to pagebreak zero or false for no shortening
 451:  * @param string $shortenindicator The placeholder to mark the shortening (e.g."(...)"). If empty the Zenpage option for this is used.
 452:  * @param string $readmore The text for the "read more" link. If empty the term set in Zenpage option is used.
 453:  * @param string $readmoreurl The url the read more link should point to
 454:  */
 455: function getContentShorten($text, $shorten, $shortenindicator = NULL, $readmore = NULL, $readmoreurl = NULL) {
 456:     $readmorelink = '';
 457:     if (is_null($shortenindicator)) {
 458:         $shortenindicator = ZP_SHORTENINDICATOR;
 459:     }
 460:     if (is_null($readmore)) {
 461:         $readmore = get_language_string(ZP_READ_MORE);
 462:     }
 463:     if (!is_null($readmoreurl)) {
 464:         $readmorelink = '<p class="readmorelink"><a href="' . html_encode($readmoreurl) . '" title="' . html_encode($readmore) . '">' . html_encode($readmore) . '</a></p>';
 465:     }
 466: 
 467:     if (!$shorten && !is_NewsArticle()) {
 468:         $shorten = ZP_SHORTEN_LENGTH;
 469:     }
 470:     $contentlenght = mb_strlen($text);
 471:     if (!empty($shorten) && ($contentlenght > (int) $shorten)) {
 472:         if (stristr($text, '<!-- pagebreak -->')) {
 473:             $array = explode('<!-- pagebreak -->', $text);
 474:             $newtext = array_shift($array);
 475:             while (!empty($array) && (mb_strlen($newtext) + mb_strlen($array[0])) < $shorten) { //  find the last break within shorten
 476:                 $newtext .= array_shift($array);
 477:             }
 478:             if ($shortenindicator && empty($array) || ($array[0] == '</p>' || trim($array[0]) == '')) { //  page break was at end of article
 479:                 $text = shortenContent($newtext, $shorten, '') . $readmorelink;
 480:             } else {
 481:                 $text = shortenContent($newtext, $shorten, $shortenindicator, true) . $readmorelink;
 482:             }
 483:         } else {
 484:             if (!is_bool($shorten)) {
 485:                 $newtext = shortenContent($text, $shorten, $shortenindicator);
 486:                 if ($newtext != $text) {
 487:                     $text = $newtext . $readmorelink;
 488:                 }
 489:             }
 490:         }
 491:     }
 492:     return $text;
 493: }
 494: 
 495: /**
 496:  * Gets the extracontent of a news article if in single news articles view or returns FALSE
 497:  *
 498:  * @return string
 499:  */
 500: function getNewsExtraContent() {
 501:     global $_zp_current_zenpage_news;
 502:     if (is_News()) {
 503:         $extracontent = $_zp_current_zenpage_news->getExtraContent();
 504:         return $extracontent;
 505:     } else {
 506:         return FALSE;
 507:     }
 508: }
 509: 
 510: /**
 511:  * Prints the extracontent of a news article if in single news articles view
 512:  *
 513:  * @return string
 514:  */
 515: function printNewsExtraContent() {
 516:     echo getNewsExtraContent();
 517: }
 518: 
 519: /**
 520:  * Returns the text for the read more link for news articles or gallery items if in CombiNews mode
 521:  *
 522:  * @return string
 523:  */
 524: function getNewsReadMore() {
 525:     global $_zp_current_zenpage_news;
 526:     $readmore = get_language_string(ZP_READ_MORE);
 527:     return $readmore;
 528: }
 529: 
 530: /**
 531:  * Gets the custom data field of the curent news article
 532:  *
 533:  * @return string
 534:  */
 535: function getNewsCustomData() {
 536:     global $_zp_current_zenpage_news;
 537:     if (!is_null($_zp_current_zenpage_news)) {
 538:         return $_zp_current_zenpage_news->getCustomData();
 539:     }
 540: }
 541: 
 542: /**
 543:  * Prints the custom data field of the curent news article
 544:  *
 545:  */
 546: function printNewsCustomData() {
 547:     echo getNewsCustomData();
 548: }
 549: 
 550: /**
 551:  * Gets the author of a news article (if in Combinews mode for gallery items the owner)
 552:  *
 553:  * @return string
 554:  */
 555: function getNewsAuthor($fullname = false) {
 556:     global $_zp_current_zenpage_news;
 557:     if (is_News()) {
 558:         return getAuthor($fullname);
 559:     }
 560:     return false;
 561: }
 562: 
 563: /**
 564:  * Prints the author of a news article
 565:  *
 566:  * @return string
 567:  */
 568: function printNewsAuthor($fullname = false) {
 569:     if (getNewsTitle()) {
 570:         echo html_encode(getNewsAuthor($fullname));
 571:     }
 572: }
 573: 
 574: /**
 575:  * Prints the title of the currently selected news category
 576:  *
 577:  * @param string $before insert what you want to be show before it
 578:  */
 579: function printCurrentNewsCategory($before = '') {
 580:     global $_zp_current_category;
 581:     if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
 582:         if ($before) {
 583:             echo '<span class="beforetext">' . html_encode($before) . '</span>';
 584:         }
 585:         echo html_encode($_zp_current_category->getTitle());
 586:     }
 587: }
 588: 
 589: /**
 590:  * Gets the description of the current news category
 591:  *
 592:  * @return string
 593:  */
 594: function getNewsCategoryDesc() {
 595:     global $_zp_current_category;
 596:     if (!is_null($_zp_current_category)) {
 597:         return $_zp_current_category->getDesc();
 598:     }
 599: }
 600: 
 601: /**
 602:  * Prints the description of the news category
 603:  *
 604:  */
 605: function printNewsCategoryDesc() {
 606:     echo html_encodeTagged(getNewsCategoryDesc());
 607: }
 608: 
 609: /**
 610:  * Gets the custom data field of the current news category
 611:  *
 612:  * @return string
 613:  */
 614: function getNewsCategoryCustomData() {
 615:     global $_zp_current_category;
 616:     if (!is_null($_zp_current_category)) {
 617:         return $_zp_current_category->getCustomData();
 618:     }
 619: }
 620: 
 621: /**
 622:  * Prints the custom data field of the news category
 623:  *
 624:  */
 625: function printNewsCategoryCustomData() {
 626:     echo getNewsCategoryCustomData();
 627: }
 628: 
 629: /**
 630:  * Gets the categories of the current news article
 631:  *
 632:  * @return array
 633:  */
 634: function getNewsCategories() {
 635:     global $_zp_current_zenpage_news;
 636:     if (!is_null($_zp_current_zenpage_news)) {
 637:         $categories = $_zp_current_zenpage_news->getCategories();
 638:         return $categories;
 639:     }
 640:     return false;
 641: }
 642: 
 643: /**
 644:  * Prints the categories of current article as a unordered html list
 645:  *
 646:  * @param string $separator A separator to be shown between the category names if you choose to style the list inline
 647:  * @param string $class The CSS class for styling
 648:  * @return string
 649:  */
 650: function printNewsCategories($separator = '', $before = '', $class = '') {
 651:     $categories = getNewsCategories();
 652:     $catcount = count($categories);
 653:     if ($catcount != 0) {
 654:         if ($before) {
 655:             echo '<span class="beforetext">' . html_encode($before) . '</span>';
 656:         }
 657:         echo "<ul class=\"$class\">\n";
 658:         $count = 0;
 659:         if ($separator) {
 660:             $separator = '<span class="betweentext">' . html_encode($separator) . '</span>';
 661:         }
 662:         foreach ($categories as $cat) {
 663:             $count++;
 664:             $catobj = new ZenpageCategory($cat['titlelink']);
 665:             if ($count >= $catcount) {
 666:                 $separator = "";
 667:             }
 668:             echo "<li><a href=\"" . $catobj->getLink() . "\" title=\"" . html_encode($catobj->getTitle()) . "\">" . $catobj->getTitle() . '</a>' . $separator . "</li>\n";
 669:         }
 670:         echo "</ul>\n";
 671:     }
 672: }
 673: 
 674: /**
 675:  * Gets the date of the current news article
 676:  *
 677:  * @return string
 678:  */
 679: function getNewsDate() {
 680:     global $_zp_current_zenpage_news;
 681:     if (!is_null($_zp_current_zenpage_news)) {
 682:         $d = $_zp_current_zenpage_news->getDateTime();
 683:         return zpFormattedDate(DATE_FORMAT, strtotime($d));
 684:     }
 685:     return false;
 686: }
 687: 
 688: /**
 689:  * Prints the date of the current news article
 690:  *
 691:  * @return string
 692:  */
 693: function printNewsDate() {
 694:     echo html_encode(getNewsDate());
 695: }
 696: 
 697: /**
 698:  * Prints the monthy news archives sorted by year
 699:  * NOTE: This does only include news articles.
 700:  *
 701:  * @param string $class optional class
 702:  * @param string $yearclass optional class for "year"
 703:  * @param string $monthclass optional class for "month"
 704:  * @param string $activeclass optional class for the currently active archive
 705:  * @param bool $yearsonly If set to true the archive only shows the years with total count (Default false)
 706:  * @param string $order 'desc' (default) or 'asc' for descending or ascending
 707:  */
 708: function printNewsArchive($class = 'archive', $yearclass = 'year', $monthclass = 'month', $activeclass = "archive-active", $yearsonly = false, $order = 'desc') {
 709:     global $_zp_zenpage;
 710:     if (!empty($class)) {
 711:         $class = "class=\"$class\"";
 712:     }
 713:     if (!empty($yearclass)) {
 714:         $yearclass = "class=\"$yearclass\"";
 715:     }
 716:     if (!empty($monthclass)) {
 717:         $monthclass = "class=\"$monthclass\"";
 718:     }
 719:     if (!empty($activeclass)) {
 720:         $activeclass = "class=\"$activeclass\"";
 721:     }
 722:     $datecount = $_zp_zenpage->getAllArticleDates($yearsonly, $order);
 723:     $lastyear = "";
 724:     $nr = "";
 725:     echo "\n<ul $class>\n";
 726:     while (list($key, $val) = each($datecount)) {
 727:         $nr++;
 728:         if ($key == '0000-00-01') {
 729:             $year = "no date";
 730:             $month = "";
 731:         } else {
 732:             $dt = strftime('%Y-%B', strtotime($key));
 733:             $year = substr($dt, 0, 4);
 734:             $month = substr($dt, 5);
 735:         }
 736:         if ($lastyear != $year) {
 737:             $lastyear = $year;
 738:             if (!$yearsonly) {
 739:                 if ($nr != 1) {
 740:                     echo "</ul>\n</li>\n";
 741:                 }
 742:                 echo "<li $yearclass>$year\n<ul $monthclass>\n";
 743:             }
 744:         }
 745:         if ($yearsonly) {
 746:             $datetosearch = $key;
 747:         } else {
 748:             $datetosearch = strftime('%Y-%B', strtotime($key));
 749:         }
 750:         if (getCurrentNewsArchive('plain') == $datetosearch) {
 751:             $active = $activeclass;
 752:         } else {
 753:             $active = "";
 754:         }
 755:         if ($yearsonly) {
 756:             echo "<li $active><a href=\"" . html_encode(getNewsArchivePath($key, 1)) . "\" title=\"" . $key . " (" . $val . ")\" rel=\"nofollow\">$key ($val)</a></li>\n";
 757:         } else {
 758:             echo "<li $active><a href=\"" . html_encode(getNewsArchivePath(substr($key, 0, 7), 1)) . "\" title=\"" . $month . " (" . $val . ")\" rel=\"nofollow\">$month ($val)</a></li>\n";
 759:         }
 760:     }
 761:     if ($yearsonly) {
 762:         echo "</ul>\n";
 763:     } else {
 764:         echo "</ul>\n</li>\n</ul>\n";
 765:     }
 766: }
 767: 
 768: /**
 769:  * Gets the current select news date (year-month) or formatted
 770:  *
 771:  * @param string $mode "formatted" for a formatted date or "plain" for the pure year-month (for example "2008-09") archive date
 772:  * @param string $format If $mode="formatted" how the date should be printed (see PHP's strftime() function for the requirements)
 773:  * @return string
 774:  */
 775: function getCurrentNewsArchive($mode = 'formatted', $format = '%B %Y') {
 776:     global $_zp_post_date;
 777:     if (in_context(ZP_ZENPAGE_NEWS_DATE)) {
 778:         $archivedate = $_zp_post_date;
 779:         if ($mode == "formatted") {
 780:             $archivedate = strtotime($archivedate);
 781:             $archivedate = strftime($format, $archivedate);
 782:         }
 783:         return $archivedate;
 784:     }
 785:     return false;
 786: }
 787: 
 788: /**
 789:  * Prints the current select news date (year-month) or formatted
 790:  *
 791:  * @param string $before What you want to print before the archive if using in a breadcrumb navigation for example
 792:  * @param string $mode "formatted" for a formatted date or "plain" for the pure year-month (for example "2008-09") archive date
 793:  * @param string $format If $mode="formatted" how the date should be printed (see PHP's strftime() function for the requirements)
 794:  * @return string
 795:  */
 796: function printCurrentNewsArchive($before = '', $mode = 'formatted', $format = '%B %Y') {
 797:     if ($date = getCurrentNewsArchive($mode, $format)) {
 798:         if ($before) {
 799:             echo '<span class="beforetext">' . html_encode($before) . '</span>';
 800:         }
 801:         echo html_encode($date);
 802:     }
 803: }
 804: 
 805: /**
 806:  * Prints all news categories as a unordered html list
 807:  *
 808:  * @param string $newsindex How you want to call the link the main news page without a category, leave empty if you don't want to print it at all.
 809:  * @param bool $counter TRUE or FALSE (default TRUE). If you want to show the number of articles behind the category name within brackets,
 810:  * @param string $css_id The CSS id for the list
 811:  * @param string $css_class_active The css class for the active menu item
 812:  * @param bool $startlist set to true to output the UL tab
 813:  * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list".
 814:  * @param string $css_class CSS class of the sub level list(s)
 815:  * @param string $$css_class_active CSS class of the sub level list(s)
 816:  * @param string $option The mode for the menu:
 817:  *                                              "list" context sensitive toplevel plus sublevel pages,
 818:  *                                              "list-top" only top level pages,
 819:  *                                              "omit-top" only sub level pages
 820:  *                                              "list-sub" lists only the current pages direct offspring
 821:  * @param int $limit truncation of display text
 822:  * @return string
 823:  */
 824: function printAllNewsCategories($newsindex = 'All news', $counter = TRUE, $css_id = '', $css_class_topactive = '', $startlist = true, $css_class = '', $css_class_active = '', $option = 'list', $showsubs = false, $limit = NULL) {
 825:     printNestedMenu($option, 'allcategories', $counter, $css_id, $css_class_topactive, $css_class, $css_class_active, $newsindex, $showsubs, $startlist, $limit);
 826: }
 827: 
 828: /* * ********************************************* */
 829: /* News article URL functions
 830:     /*********************************************** */
 831: 
 832: /**
 833:  * Returns the full path to a news category
 834:  *
 835:  * @param string $cat The category titlelink
 836:  *
 837:  * @return string
 838:  */
 839: function getNewsCategoryURL($cat = NULL) {
 840:     global $_zp_zenpage, $_zp_current_category;
 841:     if (empty($cat)) {
 842:         $obj = $_zp_current_category->getTitlelink();
 843:     } else {
 844:         $obj = new ZenpageCategory($cat);
 845:     }
 846:     return $obj->getLink(1);
 847: }
 848: 
 849: /**
 850:  * Prints the full link to a news category
 851:  *
 852:  * @param string $before If you want to print text before the link
 853:  * @param string $catlink The category link of a category
 854:  *
 855:  * @return string
 856:  */
 857: function printNewsCategoryURL($before = '', $catlink = '') {
 858:     $catobj = new ZenpageCategory($catlink);
 859:     echo "<a href=\"" . html_encode($catobj->getLink()) . "\" title=\"" . html_encode($catobj->getTitle()) . "\">";
 860:     if ($before) {
 861:         echo '<span class="beforetext">' . html_encode($before) . '</span>';
 862:     }
 863:     echo html_encode($catobj->getTitle()) . "</a>";
 864: }
 865: 
 866: /**
 867:  * Prints the full link of the news index page (news page 1 by default)
 868:  *
 869:  * @param string $name The linktext
 870:  * @param string $before The text to appear before the link text
 871:  * @param string $archive Name to print for the news date archive link
 872:  * @param int $page Page number to append
 873:  */
 874: function printNewsIndexURL($name = NULL, $before = '', $archive = NULL, $page = '') {
 875:     global $_zp_post_date;
 876:     if ($_zp_post_date) {
 877:         if (is_null($archive)) {
 878:             $name = '<em>' . gettext('Archive') . '</em>';
 879:         } else {
 880:             $name = getBare(html_encode($archive));
 881:         }
 882:         $link = zp_apply_filter('getLink', rewrite_path(_ARCHIVE_ . '/', "/index.php?p=archive"), 'archive.php', NULL);
 883:     } else {
 884:         if (is_null($name)) {
 885:             $name = gettext('News');
 886:         } else {
 887:             $name = getBare(html_encode($name));
 888:         }
 889:         $link = getNewsIndexURL($page);
 890:     }
 891:     if ($before) {
 892:         echo '<span class="beforetext">' . html_encode($before) . '</span>';
 893:     }
 894:     echo "<a href=\"" . html_encode($link) . "\" title=\"" . getBare($name) . "\">" . $name . "</a>";
 895: }
 896: 
 897: /**
 898:  * Returns path of news date archive
 899:  *
 900:  * @return string
 901:  */
 902: function getNewsArchivePath($date, $page) {
 903:     $rewrite = '/' . _NEWS_ARCHIVE_ . '/' . $date . '/';
 904:     $plain = "/index.php?p=news&date=$date";
 905:     if ($page > 1) {
 906:         $rewrite .=  $page . '/';
 907:         $plain .= "&page=$page";
 908:     }
 909:     return zp_apply_filter('getLink', rewrite_path($rewrite, $plain), 'archive.php', $page);
 910: }
 911: 
 912: /* * ********************************************************* */
 913: /* News index / category / date archive pagination functions
 914:     /********************************************************** */
 915: 
 916: function getNewsPathNav($page) {
 917:     global $_zp_current_category, $_zp_post_date;
 918:     if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
 919:         return $_zp_current_category->getLink($page);
 920:     }
 921:     if (in_context(ZP_ZENPAGE_NEWS_DATE)) {
 922:         return getNewsArchivePath($_zp_post_date, $page);
 923:     }
 924:     $rewrite = '/' . _NEWS_ . '/';
 925:     $plain = 'index.php?p=news';
 926:     if ($page > 1) {
 927:         $rewrite .= $page . '/';
 928:         $plain .= '&page=' . $page;
 929:     }
 930:     return zp_apply_filter('getLink', rewrite_path($rewrite, $plain), 'news.php', $page);
 931: }
 932: 
 933: /**
 934:  * Returns the url to the previous news page
 935:  *
 936:  * @return string
 937:  */
 938: function getPrevNewsPageURL() {
 939:     global $_zp_page;
 940:     if ($_zp_page > 1) {
 941:         return getNewsPathNav($_zp_page - 1);
 942:     } else {
 943:         return false;
 944:     }
 945: }
 946: 
 947: /**
 948:  * Prints the link to the previous news page
 949:  *
 950:  * @param string $prev The linktext
 951:  * @param string $class The CSS class for the disabled link
 952:  *
 953:  * @return string
 954:  */
 955: function printPrevNewsPageLink($prev = '« prev', $class = 'disabledlink') {
 956:     global $_zp_zenpage, $_zp_page;
 957:     if ($link = getPrevNewsPageURL()) {
 958:         echo "<a href='" . html_encode($link) . "' title='" . gettext("Prev page") . " " . ($_zp_page - 1) . "' >" . html_encode($prev) . "</a>\n";
 959:     } else {
 960:         echo "<span class=\"$class\">" . html_encode($prev) . "</span>\n";
 961:     }
 962: }
 963: 
 964: /**
 965:  * Returns the url to the next news page
 966:  *
 967:  * @return string
 968:  */
 969: function getNextNewsPageURL() {
 970:     global $_zp_zenpage, $_zp_page;
 971:     $total_pages = ceil($_zp_zenpage->getTotalArticles() / ZP_ARTICLES_PER_PAGE);
 972:     if ($_zp_page < $total_pages) {
 973:         return getNewsPathNav($_zp_page + 1);
 974:     } else {
 975:         return false;
 976:     }
 977: }
 978: 
 979: /**
 980:  * Prints the link to the next news page
 981:  *
 982:  * @param string $next The linktext
 983:  * @param string $class The CSS class for the disabled link
 984:  *
 985:  * @return string
 986:  */
 987: function printNextNewsPageLink($next = 'next »', $class = 'disabledlink') {
 988:     global $_zp_page;
 989:     if (getNextNewsPageURL()) {
 990:         echo "<a href='" . getNextNewsPageURL() . "' title='" . gettext("Next page") . " " . ($_zp_page + 1) . "'>" . html_encode($next) . "</a>\n";
 991:     } else {
 992:         echo "<span class=\"$class\">" . html_encode($next) . "</span>\n";
 993:     }
 994: }
 995: 
 996: /**
 997:  * Prints the page number list for news page navigation
 998:  *
 999:  * @param string $class The CSS class for the disabled link
1000:  *
1001:  * @return string
1002:  */
1003: function printNewsPageList($class = 'pagelist') {
1004:     printNewsPageListWithNav("", "", false, $class, true);
1005: }
1006: 
1007: /**
1008:  * Prints the full news page navigation with prev/next links and the page number list
1009:  *
1010:  * @param string $next The next page link text
1011:  * @param string $prev The prev page link text
1012:  * @param bool $nextprev If the prev/next links should be printed
1013:  * @param string $class The CSS class for the disabled link
1014:  * @param bool $firstlast Add links to the first and last pages of you gallery
1015:  * @param int $navlen Number of navigation links to show (0 for all pages). Works best if the number is odd.
1016:  *
1017:  * @return string
1018:  */
1019: function printNewsPageListWithNav($next, $prev, $nextprev = true, $class = 'pagelist', $firstlast = true, $navlen = 9) {
1020:     global $_zp_zenpage, $_zp_page;
1021:     $total = ceil($_zp_zenpage->getTotalArticles() / ZP_ARTICLES_PER_PAGE);
1022:     if ($total > 1) {
1023:         if ($navlen == 0)
1024:             $navlen = $total;
1025:         $extralinks = 2;
1026:         if ($firstlast)
1027:             $extralinks = $extralinks + 2;
1028:         $len = floor(($navlen - $extralinks) / 2);
1029:         $j = max(round($extralinks / 2), min($_zp_page - $len - (2 - round($extralinks / 2)), $total - $navlen + $extralinks - 1));
1030:         $ilim = min($total, max($navlen - round($extralinks / 2), $_zp_page + floor($len)));
1031:         $k1 = round(($j - 2) / 2) + 1;
1032:         $k2 = $total - round(($total - $ilim) / 2);
1033:         echo "<ul class=\"$class\">\n";
1034:         if ($nextprev) {
1035:             echo "<li class=\"prev\">";
1036:             printPrevNewsPageLink($prev);
1037:             echo "</li>\n";
1038:         }
1039:         if ($firstlast) {
1040:             echo '<li class = "' . ($_zp_page == 1 ? 'current' : 'first') . '">';
1041:             if ($_zp_page == 1) {
1042:                 echo "1";
1043:             } else {
1044:                 echo '<a href = "' . html_encode(getNewsPathNav(1)) . '" title = "' . gettext("Page") . ' 1">1</a>';
1045:             }
1046:             echo "</li>\n";
1047:             if ($j > 2) {
1048:                 echo "<li>";
1049:                 $linktext = ($j - 1 > 2) ? '...' : $k1;
1050:                 echo '<a href = "' . html_encode(getNewsPathNav($k1)) . '" title = "' . sprintf(ngettext('Page %u', 'Page %u', $k1), $k1) . '">' . $linktext . '</a>';
1051:                 echo "</li>\n";
1052:             }
1053:         }
1054:         for ($i = $j; $i <= $ilim; $i++) {
1055:             echo "<li" . (($i == $_zp_page) ? " class=\"current\"" : "") . ">";
1056:             if ($i == $_zp_page) {
1057:                 echo $i;
1058:             } else {
1059:                 echo '<a href = "' . html_encode(getNewsPathNav($i)) . '" title = "' . sprintf(ngettext('Page %1$u', 'Page %1$u', $i), $i) . '">' . $i . '</a>';
1060:             }
1061:             echo "</li>\n";
1062:         }
1063:         if ($i < $total) {
1064:             echo "<li>";
1065:             $linktext = ($total - $i > 1) ? '...' : $k2;
1066:             echo '<a href = "' . html_encode(getNewsPathNav($k2)) . '" title = "' . sprintf(ngettext('Page %u', 'Page %u', $k2), $k2) . '">' . $linktext . '</a>';
1067:             echo "</li>\n";
1068:         }
1069:         if ($firstlast && $i <= $total) {
1070:             echo "\n  <li class=\"last\">";
1071:             if ($_zp_page == $total) {
1072:                 echo $total;
1073:             } else {
1074:                 echo '<a href = "' . html_encode(getNewsPathNav($total)) . '" title = "' . sprintf(ngettext('Page {%u}', 'Page {%u}', $total), $total) . '">' . $total . '</a>';
1075:             }
1076:             echo "</li>\n";
1077:         }
1078:         if ($nextprev) {
1079:             echo '<li class = "next">';
1080:             printNextNewsPageLink($next);
1081:             echo "</li>\n";
1082:         }
1083:         echo "</ul>\n";
1084:     }
1085: }
1086: 
1087: function getTotalNewsPages() {
1088:     global $_zp_zenpage;
1089:     return ceil($_zp_zenpage->getTotalArticles() / ZP_ARTICLES_PER_PAGE);
1090: }
1091: 
1092: /* * ********************************************************************* */
1093: /* Single news article pagination functions (previous and next article)
1094:     /*********************************************************************** */
1095: 
1096: /**
1097:  * Returns the title and the titlelink of the next or previous article in single news article pagination as an array
1098:  * Returns false if there is none (or option is empty)
1099:  *
1100:  * NOTE: This is not available if using the CombiNews feature
1101:  *
1102:  * @param string $option "prev" or "next"
1103:  *
1104:  * @return mixed
1105:  */
1106: function getNextPrevNews($option = '') {
1107:     global $_zp_zenpage, $_zp_current_zenpage_news;
1108:  if (func_num_args() != 1) {
1109:    Zenpage_internal_deprecations::getNextPrevNews();
1110:  }
1111:     if (!empty($option)) {
1112:         switch ($option) {
1113:             case "prev":
1114:                 $article = $_zp_current_zenpage_news->getPrevArticle();
1115:                 if (!$article)
1116:                     return false;
1117:                 return array("link" => $article->getLink(), "title" => $article->getTitle());
1118:             case "next":
1119:                 $article = $_zp_current_zenpage_news->getNextArticle();
1120:                 if (!$article)
1121:                     return false;
1122:                 return array("link" => $article->getLink(), "title" => $article->getTitle());
1123:         }
1124:     }
1125:     return false;
1126: }
1127: 
1128: /**
1129:  * Returns the title and the titlelink of the next article in single news article pagination as an array
1130:  * Returns false if there is none (or option is empty)
1131:  *
1132:  * NOTE: This is not available if using the CombiNews feature
1133:  *
1134:  * @return mixed
1135:  */
1136: function getNextNewsURL() {
1137:     return getNextPrevNews("next");
1138: }
1139: 
1140: /**
1141:  * Returns the title and the titlelink of the previous article in single news article pagination as an array
1142:  * Returns false if there is none (or option is empty)
1143:  *
1144:  * NOTE: This is not available if using the CombiNews feature
1145:  *
1146:  * @return mixed
1147:  */
1148: function getPrevNewsURL() {
1149:     return getNextPrevNews("prev");
1150: }
1151: 
1152: /**
1153:  * Prints the link of the next article in single news article pagination if available
1154:  *
1155:  * NOTE: This is not available if using the CombiNews feature
1156:  *
1157:  * @param string $next If you want to show something with the title of the article like a symbol
1158:  * @return string
1159:  */
1160: function printNextNewsLink($next = " »") {
1161:     $article_url = getNextPrevNews("next");
1162:     if ($article_url && array_key_exists('link', $article_url) && $article_url['link'] != "") {
1163:         echo "<a href=\"" . html_encode($article_url['link']) . "\" title=\"" . html_encode(getBare($article_url['title'])) . "\">" . $article_url['title'] . "</a> " . html_encode($next);
1164:     }
1165: }
1166: 
1167: /**
1168:  * Prints the link of the previous article in single news article pagination if available
1169:  *
1170:  * NOTE: This is not available if using the CombiNews feature
1171:  *
1172:  * @param string $next If you want to show something with the title of the article like a symbol
1173:  * @return string
1174:  */
1175: function printPrevNewsLink($prev = "« ") {
1176:     $article_url = getNextPrevNews("prev");
1177:     if ($article_url && array_key_exists('link', $article_url) && $article_url['link'] != "") {
1178:         echo html_encode($prev) . " <a href=\"" . html_encode($article_url['link']) . "\" title=\"" . html_encode(getBare($article_url['title'])) . "\">" . $article_url['title'] . "</a>";
1179:     }
1180: }
1181: 
1182: /* * ******************************************************* */
1183: /* Functions - shared by Pages and News articles
1184:     /********************************************************* */
1185: 
1186: /**
1187:  * Gets the statistic for pages, news articles or categories as an unordered list
1188:  *
1189:  * @param int $number The number of news items to get
1190:  * @param string $option "all" pages, articles  and categories
1191:  *                                           "news" for news articles
1192:  *                                           "categories" for news categories
1193:  *                                           "pages" for pages
1194:  * @param string $mode "popular" most viewed for pages, news articles and categories
1195:  *                                       "mostrated" for news articles and pages
1196:  *                                       "toprated" for news articles and pages
1197:  *                                       "random" for pages and news articles
1198:  * @param string $sortdirection "asc" for ascending otherwise descending (default)
1199:  * @return array
1200:  */
1201: function getZenpageStatistic($number = 10, $option = "all", $mode = "popular", $sortdirection = 'desc') {
1202:     global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
1203:     $sortdir = strtolower($sortdirection) != 'asc';
1204:     $statsarticles = array();
1205:     $statscats = array();
1206:     $statspages = array();
1207:     if ($option == "all" || $option == "news") {
1208:         $articles = $_zp_zenpage->getArticles($number, NULL, true, $mode, $sortdir, false);
1209:         $counter = "";
1210:         $statsarticles = array();
1211:         foreach ($articles as $article) {
1212:             $counter++;
1213:             $obj = new ZenpageNews($article['titlelink']);
1214:             $statsarticles[$counter] = array(
1215:                             "id"                     => $obj->getID(),
1216:                             "title"              => $obj->getTitle(),
1217:                             "titlelink"      => $article['titlelink'],
1218:                             "hitcounter"     => $obj->getHitcounter(),
1219:                             "total_votes"    => $obj->getTotal_votes(),
1220:                             "rating"             => $obj->getRating(),
1221:                             "content"            => $obj->getContent(),
1222:                             "date"               => $obj->getDateTime(),
1223:                             "type"               => "News"
1224:             );
1225:         }
1226:         $stats = $statsarticles;
1227:     }
1228:     if (($option == "all" || $option == "categories") && $mode != "mostrated" && $mode != "toprated") {
1229:         $categories = $_zp_zenpage->getAllCategories(true, $mode, $sortdir);
1230:         $counter = "";
1231:         $statscats = array();
1232:         foreach ($categories as $cat) {
1233:             $counter++;
1234:             $statscats[$counter] = array(
1235:                             "id"                     => $cat['id'],
1236:                             "title"              => html_encode(get_language_string($cat['title'])),
1237:                             "titlelink"      => getNewsCategoryURL($cat['titlelink']),
1238:                             "hitcounter"     => $cat['hitcounter'],
1239:                             "total_votes"    => "",
1240:                             "rating"             => "",
1241:                             "content"            => '',
1242:                             "date"               => '',
1243:                             "type"               => "Category"
1244:             );
1245:         }
1246:         $stats = $statscats;
1247:     }
1248:     if ($option == "all" || $option == "pages") {
1249:         $pages = $_zp_zenpage->getPages(NULL, false, $number, $mode, $sortdir);
1250:         $counter = "";
1251:         $statspages = array();
1252:         foreach ($pages as $page) {
1253:             $counter++;
1254:             $pageobj = new ZenpagePage($page['titlelink']);
1255:             $statspages[$counter] = array(
1256:                             "id"                     => $pageobj->getID(),
1257:                             "title"              => $pageobj->getTitle(),
1258:                             "titlelink"      => $page['titlelink'],
1259:                             "hitcounter"     => $pageobj->getHitcounter(),
1260:                             "total_votes"    => $pageobj->get('total_votes'),
1261:                             "rating"             => $pageobj->get('rating'),
1262:                             "content"            => $pageobj->getContent(),
1263:                             "date"               => $pageobj->getDateTime(),
1264:                             "type"               => "Page"
1265:             );
1266:         }
1267:         $stats = $statspages;
1268:     }
1269:     if ($option == "all") {
1270:         $stats = array_merge($statsarticles, $statscats, $statspages);
1271:         if ($mode == 'random') {
1272:             shuffle($stats);
1273:         } else {
1274:             switch ($sortdir) {
1275:                 case 'asc':
1276:                     $desc = false;
1277:                     break;
1278:                 case 'desc':
1279:                     $desc = true;
1280:                     break;
1281:             }
1282:             $stats = sortMultiArray($stats, $mode, $desc);
1283:         }
1284:     }
1285:     return $stats;
1286: }
1287: 
1288: /**
1289:  * Prints the statistics Zenpage items as an unordered list
1290:  *
1291:  * @param int $number The number of news items to get
1292:  * @param string $option "all" pages and articles
1293:  *                                           "news" for news articles
1294:  *                                           "pages" for pages
1295:  * @param string $mode "popular" most viewed for pages, news articles and categories
1296:  *                                       "mostrated" for news articles and pages
1297:  *                                       "toprated" for news articles and pages
1298:  *                                       "random" for pages, news articles and categories
1299:  * @param bool $showstats if the value should be shown
1300:  * @param bool $showtype if the type should be shown
1301:  * @param bool $showdate if the date should be shown (news articles and pages only)
1302:  * @param bool $showcontent if the content should be shown (news articles and pages only)
1303:  * @param bool $contentlength The shortened lenght of the content
1304:  * @param string $sortdir "asc" for ascending or "desc" for descending (default)
1305:  */
1306: function printZenpageStatistic($number = 10, $option = "all", $mode = "popular", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40, $sortdir = 'desc') {
1307:     $stats = getZenpageStatistic($number, $option, $mode);
1308:     $contentlength = sanitize_numeric($contentlength);
1309:     switch ($mode) {
1310:         case 'popular':
1311:             $cssid = "'zenpagemostpopular'";
1312:             break;
1313:         case 'mostrated':
1314:             $cssid = "'zenpagemostrated'";
1315:             break;
1316:         case 'toprated':
1317:             $cssid = "'zenpagetoprated'";
1318:             break;
1319:         case 'random':
1320:             $cssid = "'zenpagerandom'";
1321:             break;
1322:     }
1323:     echo "<ul id=$cssid>";
1324:     foreach ($stats as $item) {
1325:         switch ($mode) {
1326:             case 'popular':
1327:                 $statsvalue = $item['hitcounter'];
1328:                 break;
1329:             case 'mostrated':
1330:                 $statsvalue = $item['total_votes'];
1331:                 break;
1332:             case 'toprated':
1333:                 $statsvalue = $item['rating'];
1334:                 break;
1335:         }
1336:         switch ($item['type']) {
1337:             case 'Page':
1338:                 $titlelink = html_encode(getPageURL($item['titlelink']));
1339:             case 'News':
1340:                 $titlelink = html_encode(getNewsURL($item['titlelink']));
1341:                 break;
1342:             case 'Category':
1343:                 $titlelink = html_encode(getNewsCategoryURL($item['titlelink']));
1344:                 break;
1345:         }
1346:         echo '<li><a href = "' . $titlelink . '" title = "' . html_encode(getBare($item['title'])) . '"><h3>' . $item['title'];
1347:         echo '<small>';
1348:         if ($showtype) {
1349:             echo ' [' . $item['type'] . ']';
1350:         }
1351:         if ($showstats && ($item['type'] != 'Category' && $mode != 'mostrated' && $mode != 'toprated')) {
1352:             echo ' (' . $statsvalue . ')';
1353:         }
1354:         echo '</small>';
1355:         echo '</h3></a>';
1356:         if ($showdate && $item['type'] != 'Category') {
1357:             echo "<p>" . zpFormattedDate(DATE_FORMAT, strtotime($item['date'])) . "</p>";
1358:         }
1359:         if ($showcontent && $item['type'] != 'Category') {
1360:             echo '<p>' . truncate_string($item['content'], $contentlength) . '</p>';
1361:         }
1362:         echo '</li>';
1363:     }
1364:     echo '</ul>';
1365: }
1366: 
1367: /**
1368:  * Prints the most popular pages, news articles and categories as an unordered list
1369:  *
1370:  * @param int $number The number of news items to get
1371:  * @param string $option "all" pages and articles
1372:  *                                           "news" for news articles
1373:  *                                           "pages" for pages
1374:  * @param bool $showstats if the value should be shown
1375:  * @param bool $showtype if the type should be shown
1376:  * @param bool $showdate if the date should be shown (news articles and pages only)
1377:  * @param bool $showcontent if the content should be shown (news articles and pages only)
1378:  * @param bool $contentlength The shortened lenght of the content
1379:  */
1380: function printMostPopularItems($number = 10, $option = "all", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40) {
1381:     printZenpageStatistic($number, $option, "popular", $showstats, $showtype, $showdate, $showcontent, $contentlength);
1382: }
1383: 
1384: /**
1385:  * Prints the most rated pages and news articles as an unordered list
1386:  *
1387:  * @param int $number The number of news items to get
1388:  * @param string $option "all" pages and articles
1389:  *                                           "news" for news articles
1390:  *                                           "pages" for pages
1391:  * @param bool $showstats if the value should be shown
1392:  * @param bool $showtype if the type should be shown
1393:  * @param bool $showdate if the date should be shown (news articles and pages only)
1394:  * @param bool $showcontent if the content should be shown (news articles and pages only)
1395:  * @param bool $contentlength The shortened lenght of the content
1396:  */
1397: function printMostRatedItems($number = 10, $option = "all", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40) {
1398:     printZenpageStatistic($number, $option, "mostrated", $showstats, $showtype, $showdate, $showcontent, $contentlength);
1399: }
1400: 
1401: /**
1402:  * Prints the top rated pages and news articles as an unordered list
1403:  *
1404:  * @param int $number The number of news items to get
1405:  * @param string $option "all" pages and articles
1406:  *                                           "news" for news articles
1407:  *                                           "pages" for pages
1408:  * @param bool $showstats if the value should be shown
1409:  * @param bool $showtype if the type should be shown
1410:  * @param bool $showdate if the date should be shown (news articles and pages only)
1411:  * @param bool $showcontent if the content should be shown (news articles and pages only)
1412:  * @param bool $contentlength The shortened lenght of the content
1413:  */
1414: function printTopRatedItems($number = 10, $option = "all", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40) {
1415:     printZenpageStatistic($number, $option, "toprated", $showstats, $showtype, $showdate, $showcontent, $contentlength);
1416: }
1417: 
1418: /**
1419:  * Prints a context sensitive menu of all pages as a unordered html list
1420:  *
1421:  * @param string $option The mode for the menu:
1422:  *                                              "list" context sensitive toplevel plus sublevel pages,
1423:  *                                              "list-top" only top level pages,
1424:  *                                              "omit-top" only sub level pages
1425:  *                                              "list-sub" lists only the current pages direct offspring
1426:  * @param string $mode 'pages' or 'categories'
1427:  * @param bool $counter Only $mode = 'categories': Count the articles in each category
1428:  * @param string $css_id CSS id of the top level list
1429:  * @param string $css_class_topactive class of the active item in the top level list
1430:  * @param string $css_class CSS class of the sub level list(s)
1431:  * @param string $$css_class_active CSS class of the sub level list(s)
1432:  * @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" (default) if you don't use it, it is not printed then.
1433:  * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list".
1434:  * @param bool $startlist set to true to output the UL tab (false automatically if you use 'omit-top' or 'list-sub')
1435:  * @param int $limit truncation limit display strings
1436:  * @return string
1437:  */
1438: function printNestedMenu($option = 'list', $mode = NULL, $counter = TRUE, $css_id = NULL, $css_class_topactive = NULL, $css_class = NULL, $css_class_active = NULL, $indexname = NULL, $showsubs = 0, $startlist = true, $limit = NULL) {
1439:     global $_zp_zenpage, $_zp_gallery_page, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
1440:     if (is_null($limit)) {
1441:         $limit = MENU_TRUNCATE_STRING;
1442:     }
1443:     if (is_null($css_id)) {
1444:         switch ($mode) {
1445:             case 'pages':
1446:                 $css_id = 'menu_pages';
1447:                 break;
1448:             case 'categories':
1449:             case 'allcategories':
1450:                 $css_id = 'menu_categories';
1451:                 break;
1452:         }
1453:     }
1454:     if (is_null($css_class_topactive)) {
1455:         $css_class_topactive = 'menu_topactive';
1456:     }
1457:     if (is_null($css_class)) {
1458:         $css_class = 'submenu';
1459:     }
1460:     if (is_null($css_class_active)) {
1461:         $css_class_active = 'menu-active';
1462:     }
1463:     if ($showsubs === true)
1464:         $showsubs = 9999999999;
1465:     switch ($mode) {
1466:         case 'pages':
1467:             $items = $_zp_zenpage->getPages();
1468:             $currentitem_id = getPageID();
1469:             if (is_object($_zp_current_zenpage_page)) {
1470:                 $currentitem_parentid = $_zp_current_zenpage_page->getParentID();
1471:             } else {
1472:                 $currentitem_parentid = NULL;
1473:             }
1474:             $currentitem_sortorder = getPageSortorder();
1475:             break;
1476:         case 'categories':
1477:         case 'allcategories':
1478:             $items = $_zp_zenpage->getAllCategories();
1479:             if (is_object($_zp_current_category) && $mode == 'categories') {
1480:                 $currentitem_sortorder = $_zp_current_category->getSortOrder();
1481:                 $currentitem_id = $_zp_current_category->getID();
1482:                 $currentitem_parentid = $_zp_current_category->getParentID();
1483:             } else {
1484:                 $currentitem_sortorder = NULL;
1485:                 $currentitem_id = NULL;
1486:                 $currentitem_parentid = NULL;
1487:             }
1488:             break;
1489:     }
1490: 
1491:     // don't highlight current pages or foldout if in search mode as next_page() sets page context
1492:     if (in_context(ZP_SEARCH) && $mode == 'pages') { // categories are not searched
1493:         $css_class_topactive = "";
1494:         $css_class_active = "";
1495:         rem_context(ZP_ZENPAGE_PAGE);
1496:     }
1497:     if (0 == count($items) + (int) ($mode == 'allcategories'))
1498:         return; // nothing to do
1499:     $startlist = $startlist && !($option == 'omit-top' || $option == 'list-sub');
1500:     if ($startlist)
1501:         echo '<ul id="' . $css_id . '">';
1502:     // if index link and if if with count
1503:     if (!empty($indexname)) {
1504:         if ($limit) {
1505:             $display = shortenContent($indexname, $limit, MENU_TRUNCATE_INDICATOR);
1506:         } else {
1507:             $display = $indexname;
1508:         }
1509:         switch ($mode) {
1510:             case 'pages':
1511:                 if ($_zp_gallery_page == "index.php") {
1512:                     echo '<li class="' . $css_class_topactive . '">' . html_encode($display) . '</li>';
1513:                 } else {
1514:                     echo "<li><a href='" . html_encode(getGalleryIndexURL()) . "' title='" . html_encode($indexname) . "'>" . html_encode($display) . "</a></li>";
1515:                 }
1516:                 break;
1517:             case 'categories':
1518:             case 'allcategories':
1519:                 if (($_zp_gallery_page == "news.php") && !is_NewsCategory() && !is_NewsArchive() && !is_NewsArticle()) {
1520:                     echo '<li class="' . $css_class_topactive . '">' . html_encode($display);
1521:                 } else {
1522:                     echo "<li><a href=\"" . html_encode(getNewsIndexURL()) . "\" title=\"" . html_encode($indexname) . "\">" . html_encode($display) . "</a>";
1523:                 }
1524:                 if ($counter) {
1525:                     if (in_context(ZP_ZENPAGE_NEWS_CATEGORY) && $mode == 'categories') {
1526:                         $totalcount = count($_zp_current_category->getArticles(0));
1527:                     } else {
1528:                         save_context();
1529:                         rem_context(ZP_ZENPAGE_NEWS_DATE);
1530:                         $totalcount = count($_zp_zenpage->getArticles(0));
1531:                         restore_context();
1532:                     }
1533:                     echo ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $totalcount), $totalcount) . ')</small></span>';
1534:                 }
1535:                 echo "</li>\n";
1536:                 break;
1537:         }
1538:     }
1539:     $baseindent = max(1, count(explode("-", $currentitem_sortorder)));
1540:     $indent = 1;
1541:     $open = array($indent => 0);
1542:     $parents = array(NULL);
1543:     $order = explode('-', $currentitem_sortorder);
1544:     $mylevel = count($order);
1545:     $myparentsort = array_shift($order);
1546:     for ($c = 0; $c <= $mylevel; $c++) {
1547:         $parents[$c] = NULL;
1548:     }
1549:     foreach ($items as $item) {
1550:         $password_class = '';
1551:         switch ($mode) {
1552:             case 'pages':
1553:                 $catcount = 1; //   so page items all show.
1554:                 $pageobj = new ZenpagePage($item['titlelink']);
1555:                 $itemtitle = $pageobj->getTitle();
1556:                 $itemsortorder = $pageobj->getSortOrder();
1557:                 $itemid = $pageobj->getID();
1558:                 $itemparentid = $pageobj->getParentID();
1559:                 $itemtitlelink = $pageobj->getTitlelink();
1560:                 $itemurl = $pageobj->getLink();
1561:                 $count = '';
1562:                 if ($pageobj->isProtected()) {
1563:                     $password_class = ' has_password';
1564:                 }
1565:                 break;
1566:             case 'categories':
1567:             case 'allcategories':
1568:                 $catobj = new ZenpageCategory($item['titlelink']);
1569:                 $itemtitle = $catobj->getTitle();
1570:                 $itemsortorder = $catobj->getSortOrder();
1571:                 $itemid = $catobj->getID();
1572:                 $itemparentid = $catobj->getParentID();
1573:                 $itemtitlelink = $catobj->getTitlelink();
1574:                 $itemurl = $catobj->getLink();
1575:                 $catcount = count($catobj->getArticles());
1576:                 if ($counter) {
1577:                     $count = ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $catcount), $catcount) . ')</small></span>';
1578:                 } else {
1579:                     $count = '';
1580:                 }
1581:                 if ($catobj->isProtected()) {
1582:                     $password_class = ' has_password';
1583:                 }
1584:                 break;
1585:         }
1586:         if ($catcount) {
1587:             $level = max(1, count(explode('-', $itemsortorder)));
1588:             $process = (($level <= $showsubs && $option == "list") // user wants all the pages whose level is <= to the parameter
1589:                             || ($option == 'list' || $option == 'list-top') && $level == 1 // show the top level
1590:                             || (($option == 'list' || ($option == 'omit-top' && $level > 1)) && (($itemid == $currentitem_id) // current page
1591:                             || ($itemparentid == $currentitem_id) // offspring of current page
1592:                             || ($level < $mylevel && $level > 1 && (strpos($itemsortorder, $myparentsort) === 0) )// direct ancestor
1593:                             || (($level == $mylevel) && ($currentitem_parentid == $itemparentid)) // sibling
1594:                             )
1595:                             ) || ($option == 'list-sub' && ($itemparentid == $currentitem_id) // offspring of the current page
1596:                             )
1597:                             );
1598: 
1599:             if ($process) {
1600:                 if ($level > $indent) {
1601:                     echo "\n" . str_pad("\t", $indent, "\t") . '<ul class="' . $css_class . '">'."\n";
1602:                     $indent++;
1603:                     $parents[$indent] = NULL;
1604:                     $open[$indent] = 0;
1605:                 } else if ($level < $indent) {
1606:                     $parents[$indent] = NULL;
1607:                     while ($indent > $level) {
1608:                         if ($open[$indent]) {
1609:                             $open[$indent] --;
1610:                             echo "</li>\n";
1611:                         }
1612:                         $indent--;
1613:                         echo str_pad("\t", $indent, "\t") . "</ul>\n";
1614:                     }
1615:                 } else { // level == indent, have not changed
1616:                     if ($open[$indent]) { // level = indent
1617:                         echo str_pad("\t", $indent, "\t") . "</li>\n";
1618:                         $open[$indent] --;
1619:                     } else {
1620:                         echo "\n";
1621:                     }
1622:                 }
1623:                 if ($open[$indent]) { // close an open LI if it exists
1624:                     echo "</li>\n";
1625:                     $open[$indent] --;
1626:                 }
1627:                 echo str_pad("\t", $indent - 1, "\t");
1628:                 $open[$indent] ++;
1629:                 $parents[$indent] = $itemid;
1630:                 if ($level == 1) { // top level
1631:                     $class = $css_class_topactive . $password_class;
1632:                 } else {
1633:                     $class = $css_class_active . $password_class;
1634:                 }
1635:                 if (!is_null($_zp_current_zenpage_page)) {
1636:                     $gettitle = $_zp_current_zenpage_page->getTitle();
1637:                     $getname = $_zp_current_zenpage_page->getTitlelink();
1638:                 } else if (!is_null($_zp_current_category)) {
1639:                     $gettitle = $_zp_current_category->getTitle();
1640:                     $getname = $_zp_current_category->getTitlelink();
1641:                 } else {
1642:                     $gettitle = '';
1643:                     $getname = '';
1644:                 }
1645:                 $current = "";
1646:                 if ($itemtitlelink == $getname && !in_context(ZP_SEARCH)) {
1647:                     switch ($mode) {
1648:                         case 'pages':
1649:                             if ($_zp_gallery_page == 'pages.php') {
1650:                                 $current = $class;
1651:                             }
1652:                             break;
1653:                         case 'categories':
1654:                         case 'allcategories':
1655:                             if ($_zp_gallery_page == 'news.php') {
1656:                                 $current = $class;
1657:                             }
1658:                             break;
1659:                     }
1660:                 }
1661:                 if(empty($current)) {
1662:                     $current =  trim($password_class);
1663:                 }
1664:                 if ($limit) {
1665:                     $itemtitle = shortenContent($itemtitle, $limit, MENU_TRUNCATE_INDICATOR);
1666:                 }
1667:                 echo '<li><a class="' . $current. '" href="' . html_encode($itemurl) . '" title="' . html_encode(getBare($itemtitle)) . '">' . html_encode($itemtitle) . '</a>' . $count;
1668:             }
1669:         }
1670:     }
1671:     // cleanup any hanging list elements
1672:     while ($indent > 1) {
1673:         if ($open[$indent]) {
1674:             echo "</li>\n";
1675:             $open[$indent] --;
1676:         }
1677:         $indent--;
1678:         echo str_pad("\t", $indent, "\t") . "</ul>";
1679:     }
1680:     if ($open[$indent]) {
1681:         echo "</li>\n";
1682:         $open[$indent] --;
1683:     } else {
1684:         echo "\n";
1685:     }
1686:     if ($startlist)
1687:         echo "</ul>\n";
1688: }
1689: 
1690: /**
1691:  * Prints the parent items breadcrumb navigation for pages or categories
1692:  *
1693:  * @param string $before Text to place before the breadcrumb item
1694:  * @param string $after Text to place after the breadcrumb item
1695:  */
1696: function printZenpageItemsBreadcrumb($before = NULL, $after = NULL) {
1697:     global $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_current_category;
1698:     if (is_NewsPage()) {
1699:         $page = '';
1700:         if (is_NewsArticle()) {
1701:             $page = $_zp_current_zenpage_news->getNewsLoopPage();
1702:         }
1703:         printNewsIndexURL(NULL, '', '', $page);
1704:     }
1705:     if (is_Pages() || is_NewsCategory()) {
1706:         $parentitems = array();
1707:         if (is_Pages()) {
1708:             $parentitems = $_zp_current_zenpage_page->getParents();
1709:         }
1710:         if (is_NewsCategory()) {
1711:             $parentitems = $_zp_current_category->getParents();
1712:         }
1713:         foreach ($parentitems as $item) {
1714:             if (is_Pages()) {
1715:                 $pageobj = new ZenpagePage($item);
1716:                 $parentitemurl = html_encode($pageobj->getLink());
1717:                 $parentitemtitle = $pageobj->getTitle();
1718:             }
1719:             if (is_NewsCategory()) {
1720:                 $catobj = new ZenpageCategory($item);
1721:                 $parentitemurl = $catobj->getLink();
1722:                 $parentitemtitle = $catobj->getTitle();
1723:             }
1724:             if ($before) {
1725:                 echo '<span class="beforetext">' . html_encode($before) . '</span>';
1726:             }
1727:             echo"<a href='" . $parentitemurl . "'>" . html_encode($parentitemtitle) . "</a>";
1728:             if ($after) {
1729:                 echo '<span class="aftertext">' . html_encode($after) . '</span>';
1730:             }
1731:         }
1732:     }
1733: }
1734: 
1735: /* * ********************************************* */
1736: /* Pages functions
1737:     /*********************************************** */
1738: $_zp_zenpage_pagelist = NULL;
1739: 
1740: /**
1741:  * Returns a count of the pages
1742:  *
1743:  * If in search context, the count is the number of items found.
1744:  * If in a page context, the count is the number of sub-pages of the current page.
1745:  * Otherwise it is the total number of pages.
1746:  *
1747:  * @param bool $total return the count of all pages
1748:  *
1749:  * @return int
1750:  */
1751: function getNumPages($total = false) {
1752:     global $_zp_zenpage, $_zp_zenpage_pagelist, $_zp_current_search, $_zp_current_zenpage_page;
1753:     $addquery = '';
1754:     if (!$total) {
1755:         if (in_context(ZP_SEARCH)) {
1756:             $_zp_zenpage_pagelist = $_zp_current_search->getPages();
1757:             return count($_zp_zenpage_pagelist);
1758:         } else if (in_context(ZP_ZENPAGE_PAGE)) {
1759:             if (!zp_loggedin(ADMIN_RIGHTS | ZENPAGE_PAGES_RIGHTS)) {
1760:                 $addquery = ' AND `show` = 1';
1761:             }
1762:             return db_count('pages', 'WHERE parentid=' . $_zp_current_zenpage_page->getID() . $addquery);
1763:         }
1764:     }
1765:     if (!zp_loggedin(ADMIN_RIGHTS | ZENPAGE_PAGES_RIGHTS)) {
1766:         $addquery = ' WHERE `show` = 1';
1767:     }
1768:     return db_count('pages', $addquery);
1769: }
1770: 
1771: /**
1772:  * Returns pages from the current page object/search/or parent pages based on context
1773:  * Updates $_zp_zenpage_curent_page and returns true if there is another page to be delivered
1774:  * @return boolean
1775:  */
1776: function next_page() {
1777:     global $_zp_zenpage, $_zp_next_pagelist, $_zp_current_search, $_zp_current_zenpage_page, $_zp_current_page_restore;
1778:     if (func_num_args() != 0) {
1779:         //  These parameters are deprecated
1780:         Zenpage_internal_deprecations::next_page();
1781:     }
1782: 
1783:     if (is_null($_zp_next_pagelist)) {
1784:         if (in_context(ZP_SEARCH)) {
1785:             $_zp_next_pagelist = $_zp_current_search->getPages(NULL, false, NULL, NULL, NULL);
1786:         } else if (in_context(ZP_ZENPAGE_PAGE)) {
1787:             if (!is_null($_zp_current_zenpage_page)) {
1788:                 $_zp_next_pagelist = $_zp_current_zenpage_page->getPages(NULL, false, NULL, NULL, NULL);
1789:             }
1790:         } else {
1791:             $_zp_next_pagelist = $_zp_zenpage->getPages(NULL, true, NULL, NULL, NULL);
1792:         }
1793:         save_context();
1794:         add_context(ZP_ZENPAGE_PAGE);
1795:         $_zp_current_page_restore = $_zp_current_zenpage_page;
1796:     }
1797:     while (!empty($_zp_next_pagelist)) {
1798:         $page = new ZenpagePage(array_shift($_zp_next_pagelist));
1799:         if ((zp_loggedin() && $page->isMyItem(LIST_RIGHTS)) || $page->checkForGuest()) {
1800:             $_zp_current_zenpage_page = $page;
1801:             return true;
1802:         }
1803:     }
1804:     $_zp_next_pagelist = NULL;
1805:     $_zp_current_zenpage_page = $_zp_current_page_restore;
1806:     restore_context();
1807:     return false;
1808: }
1809: 
1810: /**
1811:  * Returns title of a page
1812:  *
1813:  * @return string
1814:  */
1815: function getPageTitle() {
1816:     global $_zp_current_zenpage_page;
1817:     if (!is_null($_zp_current_zenpage_page)) {
1818:         return $_zp_current_zenpage_page->getTitle();
1819:     }
1820: }
1821: 
1822: /**
1823:  * Prints the title of a page
1824:  *
1825:  * @return string
1826:  */
1827: function printPageTitle($before = NULL) {
1828:     echo html_encodeTagged($before) . html_encode(getPageTitle());
1829: }
1830: 
1831: /**
1832:  * Returns the raw title of a page.
1833:  *
1834:  * @return string
1835:  */
1836: function getBarePageTitle() {
1837:     return getBare(getPageTitle());
1838: }
1839: 
1840: /**
1841:  * prints the raw title of a page.
1842:  *
1843:  * @return string
1844:  */
1845: function printBarePageTitle() {
1846:     echo html_encode(getBarePageTitle());
1847: }
1848: 
1849: /**
1850:  * Returns titlelink of a page
1851:  *
1852:  * @return string
1853:  */
1854: function getPageTitleLink() {
1855:     global $_zp_current_zenpage_page;
1856:     if (is_Pages()) {
1857:         return $_zp_current_zenpage_page->getTitlelink();
1858:     }
1859: }
1860: 
1861: /**
1862:  * Prints titlelink of a page
1863:  * !!!!!!!!!!NOT THE URL TO THE PAGE!!!!!!!!!!!!!
1864:  *
1865:  * @return string
1866:  */
1867: function printPageTitleLink() {
1868:     global $_zp_current_zenpage_page;
1869:     echo html_encode(getPageURL(getPageTitleLink()));
1870: }
1871: 
1872: /**
1873:  * Returns the id of a page
1874:  *
1875:  * @return int
1876:  */
1877: function getPageID() {
1878:     global $_zp_current_zenpage_page;
1879:     if (is_Pages()) {
1880:         return $_zp_current_zenpage_page->getID();
1881:     }
1882: }
1883: 
1884: /**
1885:  * Prints the id of a page
1886:  *
1887:  * @return string
1888:  */
1889: function printPageID() {
1890:     echo getPageID();
1891: }
1892: 
1893: /**
1894:  * Returns the id of the parent page of a page
1895:  *
1896:  * @return int
1897:  */
1898: function getPageParentID() {
1899:     global $_zp_current_zenpage_page;
1900:     if (is_Pages()) {
1901:         return $_zp_current_zenpage_page->getParentid();
1902:     }
1903: }
1904: 
1905: /**
1906:  * Returns the creation date of a page
1907:  *
1908:  * @return string
1909:  */
1910: function getPageDate() {
1911:     global $_zp_current_zenpage_page;
1912:     if (!is_null($_zp_current_zenpage_page)) {
1913:         $d = $_zp_current_zenpage_page->getDatetime();
1914:         return zpFormattedDate(DATE_FORMAT, strtotime($d));
1915:     }
1916:     return false;
1917: }
1918: 
1919: /**
1920:  * Prints the creation date of a page
1921:  *
1922:  * @return string
1923:  */
1924: function printPageDate() {
1925:     echo html_encode(getPageDate());
1926: }
1927: 
1928: /**
1929:  * Returns the last change date of a page if available
1930:  *
1931:  * @return string
1932:  */
1933: function getPageLastChangeDate() {
1934:     global $_zp_current_zenpage_page;
1935:     if (!is_null($_zp_current_zenpage_page)) {
1936:         $d = $_zp_current_zenpage_page->getLastchange();
1937:         return zpFormattedDate(DATE_FORMAT, strtotime($d));
1938:     }
1939:     return false;
1940: }
1941: 
1942: /**
1943:  * Prints the last change date of a page
1944:  *
1945:  * @param string $before The text you want to show before the link
1946:  * @return string
1947:  */
1948: function printPageLastChangeDate($before) {
1949:     echo html_encode($before . getPageLastChangeDate());
1950: }
1951: 
1952: /**
1953:  * Returns page content either of the current page or if requested by titlelink directly. If not both return false
1954:  * Set the titlelink of a page to call a specific even un-published page ($published = false) as a gallery description or on another custom page for example
1955:  *
1956:  * @param string $titlelink the titlelink of the page to print the content from
1957:  * @param bool $published If titlelink is set, set this to false if you want to call an un-published page's content. True is default
1958:  *
1959:  * @return mixed
1960:  */
1961: function getPageContent($titlelink = NULL, $published = true) {
1962:     global $_zp_current_zenpage_page;
1963:     if (is_Pages() AND empty($titlelink)) {
1964:         return $_zp_current_zenpage_page->getContent();
1965:     }
1966:     // print content of a page directly on a normal zenphoto theme page or any other page for example
1967:     if (!empty($titlelink)) {
1968:         $page = new ZenpagePage($titlelink);
1969:         if ($page->getShow() OR ( !$page->getShow() AND ! $published)) {
1970:             return $page->getContent();
1971:         }
1972:     }
1973:     return false;
1974: }
1975: 
1976: /**
1977:  * Print page content either of the current page or if requested by titlelink directly. If not both return false
1978:  * Set the titlelink of a page to call a specific even un-published page ($published = false) as a gallery description or on another custom page for example
1979:  *
1980:  * @param string $titlelink the titlelink of the page to print the content from
1981:  * @param bool $published If titlelink is set, set this to false if you want to call an un-published page's content. True is default
1982:  * @return mixed
1983:  */
1984: function printPageContent($titlelink = NULL, $published = true) {
1985:     echo html_encodeTagged(getPageContent($titlelink, $published));
1986: }
1987: 
1988: /**
1989:  * Returns page extra content either of the current page or if requested by titlelink directly. If not both return false
1990:  * Set the titlelink of a page to call a specific even un-published page ($published = false) as a gallery description or on another custom page for example
1991:  *
1992:  * @param string $titlelink the titlelink of the page to print the content from
1993:  * @param bool $published If titlelink is set, set this to false if you want to call an un-published page's extra content. True is default
1994:  * @return mixed
1995:  */
1996: function getPageExtraContent($titlelink = '', $published = true) {
1997:     global $_zp_current_zenpage_page;
1998:     if (is_Pages() AND empty($titlelink)) {
1999:         return $_zp_current_zenpage_page->getExtracontent();
2000:     }
2001:     // print content of a page directly on a normal zenphoto theme page for example
2002:     if (!empty($titlelink)) {
2003:         $page = new ZenpagePage($titlelink);
2004:         if ($page->getShow() OR ( !$page->getShow() AND ! $published)) {
2005:             return $page->getExtracontent();
2006:         }
2007:     }
2008:     return false;
2009: }
2010: 
2011: /**
2012:  * Prints page extra content if on a page either of the current page or if requested by titlelink directly. If not both return false
2013:  * Set the titlelink of a page to call a specific even un-published page ($published = false) as a gallery description or on another custom page for example
2014:  *
2015:  * @param string $titlelink the titlelink of the page to print the content from
2016:  * @param bool $published If titlelink is set, set this to false if you want to call an un-published page's extra content. True is default
2017:  * @return mixed
2018:  */
2019: function printPageExtraContent($titlelink = NULL, $published = true) {
2020:     echo getPageExtraContent($titlelink, $published);
2021: }
2022: 
2023: /**
2024:  * Gets the custom data field of the current page
2025:  *
2026:  * @return string
2027:  */
2028: function getPageCustomData() {
2029:     global $_zp_current_zenpage_page;
2030:     if (!is_null($_zp_current_zenpage_page)) {
2031:         return $_zp_current_zenpage_page->getCustomData();
2032:     }
2033: }
2034: 
2035: /**
2036:  * Prints the custom data field of the current page
2037:  *
2038:  */
2039: function printPageCustomData() {
2040:     echo getPageCustomData();
2041: }
2042: 
2043: /**
2044:  * Returns the author of a page
2045:  *
2046:  * @param bool $fullname True if you want to get the full name if set, false if you want the login/screenname
2047:  *
2048:  * @return string
2049:  */
2050: function getPageAuthor($fullname = false) {
2051:     if (is_Pages()) {
2052:         return getAuthor($fullname);
2053:     }
2054:     return false;
2055: }
2056: 
2057: /**
2058:  * Prints the author of a page
2059:  *
2060:  * @param bool $fullname True if you want to get the full name if set, false if you want the login/screenname
2061:  * @return string
2062:  */
2063: function printPageAuthor($fullname = false) {
2064:     if (getNewsTitle()) {
2065:         echo html_encode(getPageAuthor($fullname));
2066:     }
2067: }
2068: 
2069: /**
2070:  * Returns the sortorder of a page
2071:  *
2072:  * @return string
2073:  */
2074: function getPageSortorder() {
2075:     global $_zp_current_zenpage_page;
2076:     if (is_Pages()) {
2077:         return $_zp_current_zenpage_page->getSortOrder();
2078:     }
2079:     return false;
2080: }
2081: 
2082: /**
2083:  * Returns full path to a specific page
2084:  *
2085:  * @return string
2086:  */
2087: function getPageURL($titlelink = '') {
2088:     global $_zp_zenpage, $_zp_current_zenpage_page;
2089:     if (empty($titlelink)) {
2090:         $obj = $_zp_current_zenpage_page;
2091:     } else {
2092:         $obj = new ZenpagePage($titlelink);
2093:     }
2094:     return $obj->getLink();
2095: }
2096: 
2097: /**
2098:  * Prints the url to a specific zenpage page
2099:  *
2100:  * @param string $linktext Text for the URL
2101:  * @param string $titlelink page to include in URL
2102:  * @param string $prev text to insert before the URL
2103:  * @param string $next text to follow the URL
2104:  * @param string $class optional class
2105:  */
2106: function printPageURL($linktext = NULL, $titlelink = NULL, $prev = '', $next = '', $class = NULL) {
2107:     if (!is_null($class)) {
2108:         $class = 'class="' . $class . '"';
2109:     }
2110:     if (is_null($linktext)) {
2111:         $linktext = getPageTitle();
2112:     }
2113:     echo $prev . "<a href=\"" . html_encode(getPageURL($titlelink)) . "\" $class title=\"" . html_encode($linktext) . "\">" . html_encode($linktext) . "</a>" . $next;
2114: }
2115: 
2116: /**
2117:  * Prints excerpts of the direct subpages (1 level) of a page for a kind of overview. The setup is:
2118:  * <div class='pageexcerpt'>
2119:  * <h4>page title</h3>
2120:  * <p>page content excerpt</p>
2121:  * <p>read more</p>
2122:  * </div>
2123:  *
2124:  * @param int $excerptlength The length of the page content, if nothing specifically set, the plugin option value for 'news article text length' is used
2125:  * @param string $readmore The text for the link to the full page. If empty the read more setting from the options is used.
2126:  * @param string $shortenindicator The optional placeholder that indicates that the content is shortened, if this is not set the plugin option "news article text shorten indicator" is used.
2127:  * @return string
2128:  */
2129: function printSubPagesExcerpts($excerptlength = NULL, $readmore = NULL, $shortenindicator = NULL) {
2130:     global $_zp_current_zenpage_page;
2131:     if (is_null($readmore)) {
2132:         $readmore = get_language_string(ZP_READ_MORE);
2133:     }
2134:     $pages = $_zp_current_zenpage_page->getPages();
2135:     $subcount = 0;
2136:     if (is_null($excerptlength)) {
2137:         $excerptlength = ZP_SHORTEN_LENGTH;
2138:     }
2139:     foreach ($pages as $page) {
2140:         $pageobj = new ZenpagePage($page['titlelink']);
2141:         if ($pageobj->getParentID() == $_zp_current_zenpage_page->getID()) {
2142:             $subcount++;
2143:             $pagetitle = html_encode($pageobj->getTitle());
2144:             $pagecontent = $pageobj->getContent();
2145:             if ($pageobj->checkAccess()) {
2146:                 $pagecontent = getContentShorten($pagecontent, $excerptlength, $shortenindicator, $readmore, $pageobj->getLink());
2147:             } else {
2148:                 $pagecontent = '<p><em>' . gettext('This page is password protected') . '</em></p>';
2149:             }
2150:             echo '<div class="pageexcerpt">';
2151:             echo '<h4><a href="' . html_encode($pageobj->getLink()) . '" title="' . getBare($pagetitle) . '">' . $pagetitle . '</a></h4>';
2152:             echo $pagecontent;
2153:             echo '</div>';
2154:         }
2155:     }
2156: }
2157: 
2158: /**
2159:  * Prints a context sensitive menu of all pages as a unordered html list
2160:  *
2161:  * @param string $option The mode for the menu:
2162:  *                                              "list" context sensitive toplevel plus sublevel pages,
2163:  *                                              "list-top" only top level pages,
2164:  *                                              "omit-top" only sub level pages
2165:  *                                              "list-sub" lists only the current pages direct offspring
2166:  * @param string $css_id CSS id of the top level list
2167:  * @param string $css_class_topactive class of the active item in the top level list
2168:  * @param string $css_class CSS class of the sub level list(s)
2169:  * @param string $$css_class_active CSS class of the sub level list(s)
2170:  * @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" (default) if you don't use it, it is not printed then.
2171:  * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list".
2172:  * @param bool $startlist set to true to output the UL tab
2173:  * @@param int $limit truncation of display text
2174:  * @return string
2175:  */
2176: function printPageMenu($option = 'list', $css_id = NULL, $css_class_topactive = NULL, $css_class = NULL, $css_class_active = NULL, $indexname = NULL, $showsubs = 0, $startlist = true, $limit = NULL) {
2177:     printNestedMenu($option, 'pages', false, $css_id, $css_class_topactive, $css_class, $css_class_active, $indexname, $showsubs, $startlist, $limit);
2178: }
2179: 
2180: /**
2181:  * If the titlelink is valid this will setup for the page
2182:  * Returns true if page is setup and valid, otherwise returns false
2183:  *
2184:  * @param string $titlelink The page to setup
2185:  *
2186:  * @return bool
2187:  */
2188: function checkForPage($titlelink) {
2189:     if (!empty($titlelink)) {
2190:         load_zenpage_pages($titlelink);
2191:         return in_context(ZP_ZENPAGE_PAGE);
2192:     }
2193:     return false;
2194: }
2195: 
2196: /* * ********************************************* */
2197: /* Comments
2198:     /*********************************************** */
2199: 
2200: /**
2201:  * Gets latest comments for news articles and pages
2202:  *
2203:  * @param int $number how many comments you want.
2204:  * @param string $type  "all" for all latest comments for all news articles and all pages
2205:  *                                          "news" for the lastest comments of one specific news article
2206:  *                                          "page" for the lastest comments of one specific page
2207:  * @param int $itemID the ID of the element to get the comments for if $type != "all"
2208:  */
2209: function getLatestZenpageComments($number, $type = "all", $itemID = "") {
2210:     $itemID = sanitize_numeric($itemID);
2211:     $number = sanitize_numeric($number);
2212:     $checkauth = zp_loggedin();
2213: 
2214:     if ($type == 'all' || $type == 'news') {
2215:         $newspasswordcheck = "";
2216:         if (zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) {
2217:             $newsshow = '';
2218:         } else {
2219:             $newsshow = 'news.show=1 AND';
2220:             $newscheck = query_full_array("SELECT * FROM " . prefix('news') . " ORDER BY date");
2221:             foreach ($newscheck as $articlecheck) {
2222:                 $obj = new ZenpageNews($articlecheck['titlelink']);
2223:                 if ($obj->inProtectedCategory()) {
2224:                     if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) {
2225:                         $newsshow = '';
2226:                     } else {
2227:                         $excludenews = " AND id != " . $articlecheck['id'];
2228:                         $newspasswordcheck = $newspasswordcheck . $excludenews;
2229:                     }
2230:                 }
2231:             }
2232:         }
2233:     }
2234:     if ($type == 'all' || $type == 'page') {
2235:         $pagepasswordcheck = "";
2236:         if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS)) {
2237:             $pagesshow = '';
2238:         } else {
2239:             $pagesshow = 'pages.show=1 AND';
2240:             $pagescheck = query_full_array("SELECT * FROM " . prefix('pages') . " ORDER BY date");
2241:             foreach ($pagescheck as $pagecheck) {
2242:                 $obj = new ZenpagePage($pagecheck['titlelink']);
2243:                 if ($obj->isProtected()) {
2244:                     if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) {
2245:                         $pagesshow = '';
2246:                     } else {
2247:                         $excludepages = " AND pages.id != " . $pagecheck['id'];
2248:                         $pagepasswordcheck = $pagepasswordcheck . $excludepages;
2249:                     }
2250:                 }
2251:             }
2252:         }
2253:     }
2254:     switch ($type) {
2255:         case "news":
2256:             $whereNews = " WHERE $newsshow news.id = " . $itemID . " AND c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck;
2257:             break;
2258:         case "page":
2259:             $wherePages = " WHERE $pagesshow pages.id = " . $itemID . " AND c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck;
2260:             break;
2261:         case "all":
2262:             $whereNews = " WHERE $newsshow c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck;
2263:             $wherePages = " WHERE $pagesshow c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck;
2264:             break;
2265:     }
2266:     $comments_news = array();
2267:     $comments_pages = array();
2268:     if ($type == "all" OR $type == "news") {
2269:         $comments_news = query_full_array("SELECT c.id, c.name, c.type, c.website,"
2270:                         . " c.date, c.anon, c.comment, news.title, news.titlelink FROM " . prefix('comments') . " AS c, " . prefix('news') . " AS news "
2271:                         . $whereNews
2272:                         . " ORDER BY c.id DESC LIMIT $number");
2273:     }
2274:     if ($type == "all" OR $type == "page") {
2275:         $comments_pages = query_full_array($sql = "SELECT c.id, c.name, c.type, c.website,"
2276:                         . " c.date, c.anon, c.comment, pages.title, pages.titlelink FROM " . prefix('comments') . " AS c, " . prefix('pages') . " AS pages "
2277:                         . $wherePages
2278:                         . " ORDER BY c.id DESC LIMIT $number");
2279:     }
2280:     $comments = array();
2281:     foreach ($comments_news as $comment) {
2282:         $comments[$comment['id']] = $comment;
2283:     }
2284:     foreach ($comments_pages as $comment) {
2285:         $comments[$comment['id']] = $comment;
2286:     }
2287:     krsort($comments);
2288:     return array_slice($comments, 0, $number);
2289: }
2290: 
2291: /**
2292:  * support to show an image from an album
2293:  * The imagename is optional. If absent the album thumb image will be
2294:  * used and the link will be to the album. If present the link will be
2295:  * to the image.
2296:  *
2297:  * @param string $albumname
2298:  * @param string $imagename
2299:  * @param int $size the size to make the image. If omitted image will be 50% of 'image_size' option.
2300:  * @param bool $linkalbum set true to link specific image to album instead of image
2301:  */
2302: function zenpageAlbumImage($albumname, $imagename = NULL, $size = NULL, $linkalbum = false) {
2303:     global $_zp_gallery;
2304:     echo '<br />';
2305:     $album = newAlbum($albumname);
2306:     if ($album->loaded) {
2307:         if (is_null($size)) {
2308:             $size = floor(getOption('image_size') * 0.5);
2309:         }
2310:         $image = NULL;
2311:         if (is_null($imagename)) {
2312:             $linkalbum = true;
2313:             $image = $album->getAlbumThumbImage();
2314:         } else {
2315:             $image = newImage($album, $imagename);
2316:         }
2317:         if ($image && $image->loaded) {
2318:             makeImageCurrent($image);
2319:             if ($linkalbum) {
2320:                 rem_context(ZP_IMAGE);
2321:                 echo '<a href="' . html_encode($album->getLink()) . '"   title="' . sprintf(gettext('View the %s album'), $albumname) . '">';
2322:                 add_context(ZP_IMAGE);
2323:                 printCustomSizedImage(sprintf(gettext('View the album %s'), $albumname), $size);
2324:                 rem_context(ZP_IMAGE | ZP_ALBUM);
2325:                 echo '</a>';
2326:             } else {
2327:                 echo '<a href="' . html_encode(getImageURL()) . '" title="' . sprintf(gettext('View %s'), $imagename) . '">';
2328:                 printCustomSizedImage(sprintf(gettext('View %s'), $imagename), $size);
2329:                 rem_context(ZP_IMAGE | ZP_ALBUM);
2330:                 echo '</a>';
2331:             }
2332:         } else {
2333:             ?>
2334:             <span style="background:red;color:black;">
2335:                 <?php
2336:                 printf(gettext('<code>zenpageAlbumImage()</code> did not find the image %1$s:%2$s'), $albumname, $imagename);
2337:                 ?>
2338:             </span>
2339:             <?php
2340:         }
2341:     } else {
2342:         ?>
2343:         <span style="background:red;color:black;">
2344:             <?php
2345:             printf(gettext('<code>zenpageAlbumImage()</code> did not find the album %1$s'), $albumname);
2346:             ?>
2347:         </span>
2348:         <?php
2349:     }
2350: }
2351: 
2352: Zenpage::expiry();
2353: ?>
Zenphoto doc API documentation generated by ApiGen