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: /**
   4:  * Album Class
   5:  * @package classes
   6:  */
   7: // force UTF-8 Ø
   8: 
   9: define('IMAGE_SORT_DIRECTION', getOption('image_sortdirection'));
  10: define('IMAGE_SORT_TYPE', getOption('image_sorttype'));
  11: 
  12: Gallery::addAlbumHandler('alb', 'dynamicAlbum');
  13: 
  14: /**
  15:  * Wrapper instantiation function for albums. Do not instantiate directly
  16:  * @param string $folder8 the name of the folder (inernal character set)
  17:  * @param bool $cache true if the album should be fetched from the cache
  18:  * @param bool $quiet true to supress error messages
  19:  * @return Album
  20:  */
  21: function newAlbum($folder8, $cache = true, $quiet = false) {
  22:     global $_zp_albumHandlers;
  23:     $suffix = getSuffix($folder8);
  24:     if (!$suffix || !array_key_exists($suffix, $_zp_albumHandlers) || is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($folder8))) {
  25:         return new Album($folder8, $cache, $quiet);
  26:     } else {
  27:         return new $_zp_albumHandlers[$suffix]($folder8, $cache, $quiet);
  28:     }
  29: }
  30: 
  31: /**
  32:  * Returns true if the object is a zenphoto 'album'
  33:  *
  34:  * @param object $album
  35:  * @return bool
  36:  */
  37: function isAlbumClass($album = NULL) {
  38:     global $_zp_current_album;
  39:     if (is_null($album)) {
  40:         if (!in_context(ZP_ALBUM))
  41:             return false;
  42:         $album = $_zp_current_album;
  43:     }
  44:     return is_object($album) && ($album->table == 'albums');
  45: }
  46: 
  47: class AlbumBase extends MediaObject {
  48: 
  49:     var $name; // Folder name of the album (full path from the albums folder)
  50:     var $linkname; // may have the .alb suffix stripped off
  51:     var $localpath; // Latin1 full server path to the album
  52:     var $exists = true; // Does the folder exist?
  53:     var $images = null; // Full images array storage.
  54:     var $parent = null; // The parent album name
  55:     var $parentalbum = null; // The parent album's album object (lazy)
  56:     var $sidecars = array(); // keeps the list of suffixes associated with this album
  57:     var $manage_rights = MANAGE_ALL_ALBUM_RIGHTS;
  58:     var $manage_some_rights = ALBUM_RIGHTS;
  59:     var $view_rights = ALL_ALBUMS_RIGHTS;
  60:     protected $subalbums = null; // Full album array storage.
  61:     protected $index;
  62:     protected $lastimagesort = NULL; // remember the order for the last album/image sorts
  63:     protected $lastsubalbumsort = NULL;
  64:     protected $albumthumbnail = NULL; // remember the album thumb for the duration of the script
  65:     protected $subrights = NULL; // cache for album subrights
  66: 
  67:     function __construct($folder8, $cache = true) {
  68:         $this->linkname = $this->name = $folder8;
  69:         $this->instantiate('albums', array('folder' => $this->name), 'folder', false, true);
  70:         $this->exists = false;
  71:     }
  72: 
  73:     /**
  74:      * Sets default values for a new album
  75:      *
  76:      * @return bool
  77:      */
  78:     protected function setDefaults() {
  79:         global $_zp_gallery;
  80:         if (TEST_RELEASE) {
  81:             $bt = debug_backtrace();
  82:             $good = false;
  83:             foreach ($bt as $b) {
  84:                 if ($b['function'] == "newAlbum") {
  85:                     $good = true;
  86:                     break;
  87:                 }
  88:             }
  89:             if (!$good) {
  90:                 zp_error(gettext('An album object was instantiated without using the newAlbum() function.'), E_USER_WARNING);
  91:             }
  92:         }
  93: // Set default data for a new Album (title and parent_id)
  94:         $parentalbum = NULL;
  95:         $this->setShow($_zp_gallery->getAlbumPublish());
  96:         $this->set('mtime', time());
  97:         $title = trim($this->name);
  98:         $this->set('title', sanitize($title, 2));
  99:         return true;
 100:     }
 101: 
 102:     /**
 103:      * Returns the folder on the filesystem
 104:      *
 105:      * @return string
 106:      */
 107:     function getFileName() {
 108:         return $this->name;
 109:     }
 110: 
 111:     /**
 112:      * Returns the folder on the filesystem
 113:      *
 114:      * @return string
 115:      */
 116:     function getFolder() {
 117:         return $this->name;
 118:     }
 119: 
 120:     /**
 121:      * Returns The parent Album of this Album. NULL if this is a top-level album.
 122:      *
 123:      * @return object
 124:      */
 125:     function getParent() {
 126:         if (is_null($this->parentalbum)) {
 127:             $slashpos = strrpos($this->name, "/");
 128:             if ($slashpos) {
 129:                 $parent = substr($this->name, 0, $slashpos);
 130:                 $parentalbum = newAlbum($parent, true, true);
 131:                 if ($parentalbum->exists) {
 132:                     return $parentalbum;
 133:                 }
 134:             }
 135:         } else if ($this->parentalbum->exists) {
 136:             return $this->parentalbum;
 137:         }
 138:         return NULL;
 139:     }
 140: 
 141:     function getParentID() {
 142:         return $this->get('parentid');
 143:     }
 144: 
 145:     /**
 146:      * Returns the place data of an album
 147:      *
 148:      * @return string
 149:      */
 150:     function getLocation($locale = NULL) {
 151:         $text = $this->get('location');
 152:         if ($locale !== 'all') {
 153:             $text = get_language_string($text, $locale);
 154:         }
 155:         $text = zpFunctions::unTagURLs($text);
 156:         return $text;
 157:     }
 158: 
 159:     /**
 160:      * Stores the album place
 161:      *
 162:      * @param string $place text for the place field
 163:      */
 164:     function setLocation($place) {
 165:         $this->set('location', zpFunctions::tagURLs($place));
 166:     }
 167: 
 168:     /**
 169:      * Returns either the subalbum sort direction or the image sort direction of the album
 170:      *
 171:      * @param string $what 'image_sortdirection' if you want the image direction,
 172:      *        'album_sortdirection' if you want it for the album
 173:      *
 174:      * @return string
 175:      */
 176:     function getSortDirection($what = 'image') {
 177:         global $_zp_gallery;
 178:         if ($what == 'image') {
 179:             $direction = $this->get('image_sortdirection');
 180:             $type = $this->get('sort_type');
 181:         } else {
 182:             $direction = $this->get('album_sortdirection');
 183:             $type = $this->get('subalbum_sort_type');
 184:         }
 185:         if (empty($type)) {
 186: // using inherited type, so use inherited direction
 187:             $parentalbum = $this->getParent();
 188:             if (is_null($parentalbum)) {
 189:                 if ($what == 'image') {
 190:                     $direction = IMAGE_SORT_DIRECTION;
 191:                 } else {
 192:                     $direction = $_zp_gallery->getSortDirection();
 193:                 }
 194:             } else {
 195:                 $direction = $parentalbum->getSortDirection($what);
 196:             }
 197:         }
 198:         return $direction;
 199:     }
 200: 
 201:     /**
 202:      * Returns the sort type of the album images
 203:      * Will return a parent sort type if the sort type for this album is empty
 204:      *
 205:      * @return string
 206:      */
 207:     function getSortType($what = 'image') {
 208:         global $_zp_gallery;
 209:         if ($what == 'image') {
 210:             $type = $this->get('sort_type');
 211:         } else {
 212:             $type = $this->get('subalbum_sort_type');
 213:         }
 214:         if (empty($type)) {
 215:             $parentalbum = $this->getParent();
 216:             if (is_null($parentalbum)) {
 217:                 if ($what == 'image') {
 218:                     $type = IMAGE_SORT_TYPE;
 219:                 } else {
 220:                     $type = $_zp_gallery->getSortType();
 221:                 }
 222:             } else {
 223:                 $type = $parentalbum->getSortType($what);
 224:             }
 225:         }
 226:         return $type;
 227:     }
 228: 
 229:     /**
 230:      * sets sort directions for the album
 231:      *
 232:      * @param bool $val the direction
 233:      * @param string $what 'image_sortdirection' if you want the image direction,
 234:      *        'album_sortdirection' if you want it for the album
 235:      */
 236:     function setSortDirection($val, $what = 'image') {
 237:         if (is_string($val)) {
 238:             internal_deprecations::setSortDirection();
 239:             $t = $val;
 240:             $val = $what;
 241:             $what = $t;
 242:         }
 243:         if ($what == 'image') {
 244:             $this->set('image_sortdirection', (int) ($val && true));
 245:         } else {
 246:             $this->set('album_sortdirection', (int) ($val && true));
 247:         }
 248:     }
 249: 
 250:     /**
 251:      * Stores the sort type for the album
 252:      *
 253:      * @param string $sorttype the album sort type
 254:      * @param string $what 'Description'image' or 'album'
 255:      */
 256:     function setSortType($sorttype, $what = 'image') {
 257:         if ($what == 'image') {
 258:             $this->set('sort_type', $sorttype);
 259:         } else {
 260:             $this->set('subalbum_sort_type', $sorttype);
 261:         }
 262:     }
 263: 
 264:     /**
 265:      * Returns the sort type for subalbums in this album.
 266:      *
 267:      * Will return a parent sort type if the sort type for this album is empty.
 268:      *
 269:      * @return string
 270:      * @deprecated since version 1.4.5
 271:      */
 272:     function getAlbumSortType() {
 273:         internal_deprecations::getAlbumSortType();
 274:         return $this->getSortType('album');
 275:     }
 276: 
 277:     /**
 278:      * Stores the subalbum sort type for this abum
 279:      *
 280:      * @param string $sorttype the subalbum sort type
 281:      * @deprecated since version 1.4.5
 282:      */
 283:     function setSubalbumSortType($sorttype) {
 284:         internal_deprecations::setAlbumSortType();
 285:         $this->setSortType($sorttype, 'album');
 286:     }
 287: 
 288:     /**
 289:      * Returns the DB key associated with the image sort type
 290:      *
 291:      * @param string $sorttype the sort type
 292:      * @return string
 293:      */
 294:     function getImageSortKey($sorttype = null) {
 295:         if (is_null($sorttype)) {
 296:             $sorttype = $this->getSortType();
 297:         }
 298:         return lookupSortKey($sorttype, 'filename', 'images');
 299:     }
 300: 
 301:     /**
 302:      * Returns the DB key associated with the subalbum sort type
 303:      *
 304:      * @param string $sorttype subalbum sort type
 305:      * @return string
 306:      */
 307:     function getAlbumSortKey($sorttype = null) {
 308:         if (empty($sorttype)) {
 309:             $sorttype = $this->getSortType('album');
 310:         }
 311:         return lookupSortKey($sorttype, 'sort_order', 'albums');
 312:     }
 313: 
 314:     /**
 315:      * Returns all folder names for all the subdirectories.
 316:      *
 317:      * @param string $page  Which page of subalbums to display.
 318:      * @param string $sorttype The sort strategy
 319:      * @param string $sortdirection The direction of the sort
 320:      * @param bool $care set to false if the order does not matter
 321:      * @param bool $mine set true/false to override ownership
 322:      * @return array
 323:      */
 324:     function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
 325:         if ($page == 0) {
 326:             return $this->subalbums;
 327:         } else {
 328:             $albums_per_page = max(1, getOption('albums_per_page'));
 329:             return array_slice($this->subalbums, $albums_per_page * ($page - 1), $albums_per_page);
 330:         }
 331:     }
 332: 
 333:     /**
 334:      * Returns the count of subalbums
 335:      *
 336:      * @return int
 337:      */
 338:     function getNumAlbums() {
 339:         return count($this->getAlbums(0, NULL, NULL, false));
 340:     }
 341: 
 342:     /**
 343:      * Returns a of a slice of the images for this album. They will
 344:      * also be sorted according to the sort type of this album, or by filename if none
 345:      * has been set.
 346:      *
 347:      * @param string $page  Which page of images should be returned. If zero, all images are returned.
 348:      * @param int $firstPageCount count of images that go on the album/image transition page
 349:      * @param string $sorttype optional sort type
 350:      * @param string $sortdirection optional sort direction
 351:      * @param bool $care set to false if the order of the images does not matter
 352:      * @param bool $mine set true/false to override ownership
 353:      *
 354:      * @return array
 355:      */
 356:     function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
 357: // Return the cut of images based on $page. Page 0 means show all.
 358:         if ($page == 0) {
 359:             return $this->images;
 360:         } else {
 361: // Only return $firstPageCount images if we are on the first page and $firstPageCount > 0
 362:             if (($page == 1) && ($firstPageCount > 0)) {
 363:                 $pageStart = 0;
 364:                 $images_per_page = $firstPageCount;
 365:             } else {
 366:                 if ($firstPageCount > 0) {
 367:                     $fetchPage = $page - 2;
 368:                 } else {
 369:                     $fetchPage = $page - 1;
 370:                 }
 371:                 $images_per_page = max(1, getOption('images_per_page'));
 372:                 $pageStart = (int) ($firstPageCount + $images_per_page * $fetchPage);
 373:             }
 374:             return array_slice($this->images, $pageStart, $images_per_page);
 375:         }
 376:     }
 377: 
 378:     /**
 379:      * Returns the number of images in this album (not counting its subalbums)
 380:      *
 381:      * @return int
 382:      */
 383:     function getNumImages() {
 384:         if (is_null($this->images)) {
 385:             return count($this->getImages(0, 0, NULL, NULL, false));
 386:         }
 387:         return count($this->images);
 388:     }
 389: 
 390:     /**
 391:      * Returns an image from the album based on the index passed.
 392:      *
 393:      * @param int $index
 394:      * @return int
 395:      */
 396:     function getImage($index) {
 397:         $images = $this->getImages();
 398:         if ($index >= 0 && $index < count($images)) {
 399:             return newImage($this, $this->images[$index]);
 400:         }
 401:         return false;
 402:     }
 403: 
 404:     /**
 405:      * Gets the album's set thumbnail image from the database if one exists,
 406:      * otherwise, finds the first image in the album or sub-album and returns it
 407:      * as an Image object.
 408:      *
 409:      * @return Image
 410:      */
 411:     function getAlbumThumbImage() {
 412:         global $_zp_albumthumb_selector, $_zp_gallery;
 413: 
 414:         if (!is_null($this->albumthumbnail)) {
 415:             return $this->albumthumbnail;
 416:         }
 417: 
 418:         $albumdir = $this->localpath;
 419:         $thumb = $this->get('thumb');
 420:         if (is_null($thumb)) {
 421:             $this->set('thumb', $thumb = getOption('AlbumThumbSelect'));
 422:         }
 423:         $i = strpos($thumb, '/');
 424:         if ($root = ($i === 0)) {
 425:             $thumb = substr($thumb, 1); // strip off the slash
 426:             $albumdir = ALBUM_FOLDER_SERVERPATH;
 427:         }
 428:         if (!empty($thumb) && !is_numeric($thumb)) {
 429:             if (file_exists($albumdir . internalToFilesystem($thumb))) {
 430:                 if ($i === false) {
 431:                     return newImage($this, $thumb);
 432:                 } else {
 433:                     $pieces = explode('/', $thumb);
 434:                     $i = count($pieces);
 435:                     $thumb = $pieces[$i - 1];
 436:                     unset($pieces[$i - 1]);
 437:                     $albumdir = implode('/', $pieces);
 438:                     if (!$root) {
 439:                         $albumdir = $this->name . "/" . $albumdir;
 440:                     } else {
 441:                         $albumdir = $albumdir . "/";
 442:                     }
 443:                     $this->albumthumbnail = newImage(newAlbum($albumdir), $thumb);
 444:                     return $this->albumthumbnail;
 445:                 }
 446:             } else {
 447:                 $this->set('thumb', $thumb = getOption('AlbumThumbSelect'));
 448:             }
 449:         }
 450:         if ($shuffle = empty($thumb)) {
 451:             $thumbs = $this->getImages(0, 0, NULL, NULL, false);
 452:         } else {
 453:             $thumbs = $this->getImages(0, 0, $_zp_albumthumb_selector[(int) $thumb]['field'], $_zp_albumthumb_selector[(int) $thumb]['direction']);
 454:         }
 455:         if (!is_null($thumbs)) {
 456:             if ($shuffle) {
 457:                 shuffle($thumbs);
 458:             }
 459:             $mine = $this->isMyItem(LIST_RIGHTS);
 460:             $other = NULL;
 461:             while (count($thumbs) > 0) {
 462: // first check for images
 463:                 $thumb = array_shift($thumbs);
 464:                 $thumb = newImage($this, $thumb);
 465:                 if ($mine || $thumb->getShow()) {
 466:                     if (isImagePhoto($thumb)) {
 467: // legitimate image
 468:                         $this->albumthumbnail = $thumb;
 469:                         return $this->albumthumbnail;
 470:                     } else {
 471:                         if (!is_null($thumb->objectsThumb)) {
 472: //  "other" image with a thumb sidecar
 473:                             $this->albumthumbnail = $thumb;
 474:                             return $this->albumthumbnail;
 475:                         } else {
 476:                             if (is_null($other)) {
 477:                                 $other = $thumb;
 478:                             }
 479:                         }
 480:                     }
 481:                 }
 482:             }
 483:             if (!is_null($other)) {
 484: //  "other" image, default thumb
 485:                 $this->albumthumbnail = $other;
 486:                 return $this->albumthumbnail;
 487:             }
 488:         }
 489: 
 490: // Otherwise, look in sub-albums.
 491:         $subalbums = $this->getAlbums();
 492:         if (!is_null($subalbums)) {
 493:             if ($shuffle) {
 494:                 shuffle($subalbums);
 495:             }
 496:             while (count($subalbums) > 0) {
 497:                 $folder = array_pop($subalbums);
 498:                 $subalbum = newAlbum($folder);
 499:                 $pwd = $subalbum->getPassword();
 500:                 if (($subalbum->getShow() && empty($pwd)) || $subalbum->isMyItem(LIST_RIGHTS)) {
 501:                     $thumb = $subalbum->getAlbumThumbImage();
 502:                     if (strtolower(get_class($thumb)) !== 'transientimage' && $thumb->exists) {
 503:                         $this->albumthumbnail = $thumb;
 504:                         return $thumb;
 505:                     }
 506:                 }
 507:             }
 508:         }
 509: 
 510:         $nullimage = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
 511: // check for theme imageDefault.png
 512:         $theme = '';
 513:         $uralbum = getUralbum($this);
 514:         $albumtheme = $uralbum->getAlbumTheme();
 515:         if (!empty($albumtheme)) {
 516:             $theme = $albumtheme;
 517:         } else {
 518:             $theme = $_zp_gallery->getCurrentTheme();
 519:         }
 520:         if (!empty($theme)) {
 521:             $themeimage = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/images/imageDefault.png';
 522:             if (file_exists(internalToFilesystem($themeimage))) {
 523:                 $nullimage = $themeimage;
 524:             }
 525:         }
 526: 
 527:         $this->albumthumbnail = new transientimage($this, $nullimage);
 528:         return $this->albumthumbnail;
 529:     }
 530: 
 531:     /**
 532:      * Gets the thumbnail URL for the album thumbnail image as returned by $this->getAlbumThumbImage();
 533:      * @return string
 534:      */
 535:     function getThumb() {
 536:         $image = $this->getAlbumThumbImage();
 537:         return $image->getThumb('album');
 538:     }
 539: 
 540:     /**
 541:      * Gets the thumbnail URL for the album thumbnail image as returned by $this->getAlbumThumbImage();
 542:      * @return string
 543:      * @deprecated since version 1.4.6
 544:      */
 545:     function getAlbumThumb() {
 546:         internal_deprecations::getAlbumThumb();
 547:         return $this->getThumb();
 548:     }
 549: 
 550:     /**
 551:      * Stores the thumbnail path for an album thumg
 552:      *
 553:      * @param string $filename thumbnail path
 554:      */
 555:     function setThumb($filename) {
 556:         $this->set('thumb', $filename);
 557:     }
 558: 
 559:     /**
 560:      * Stores the thumbnail path for an album thumg
 561:      *
 562:      * @param string $filename thumbnail path
 563:      * @deprecated since version 1.4.6
 564:      */
 565:     function setAlbumThumb($filename) {
 566:         internal_deprecations::setAlbumThumb();
 567:         $this->setThumb($filename);
 568:     }
 569: 
 570:     /**
 571:      * Returns an URL to the album, including the current page number
 572:      *
 573:      * @param string $page if not null, apppend as page #
 574:      * @return string
 575:      * @deprecated since version 1.4.6
 576:      */
 577:     function getAlbumLink($page = NULL) {
 578:         internal_deprecations::getAlbumLink();
 579:         return $this->getLink();
 580:     }
 581: 
 582:     /**
 583:      * Returns an URL to the album, including the current page number
 584:      *
 585:      * @param string $page if not null, apppend as page #
 586:      * @return string
 587:      */
 588:     function getLink($page = NULL) {
 589:         global $_zp_current_album;
 590:         global $_zp_page;
 591:         if (is_null($page) && $_zp_current_album && $_zp_current_album->name == $this->name) {
 592:             $page = $_zp_page;
 593:         }
 594:         $rewrite = pathurlencode($this->linkname) . '/';
 595:         $plain = '/index.php?album=' . pathurlencode($this->name);
 596:         if ($page > 1) {
 597:             $rewrite .=_PAGE_ . '/' . $page . '/';
 598:             $plain .= "&page=$page";
 599:         }
 600:         return zp_apply_filter('getLink', rewrite_path($rewrite, $plain), $this, $page);
 601:     }
 602: 
 603:     /**
 604:      * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable.
 605:      * Returns true if successful
 606:      *
 607:      * @return bool
 608:      */
 609:     function remove() {
 610:         $rslt = false;
 611:         if (PersistentObject::remove()) {
 612:             query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id);
 613:             query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id);
 614:             query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id);
 615:             $rslt = true;
 616:             $filestoremove = safe_glob(substr($this->localpath, 0, -1) . '.*');
 617:             foreach ($filestoremove as $file) {
 618:                 if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
 619:                     @chmod($file, 0777);
 620:                     unlink($file);
 621:                 }
 622:             }
 623:         }
 624:         return $rslt;
 625:     }
 626: 
 627:     /**
 628:      * common album move code
 629:      * @param type $newfolder
 630:      * @return int
 631:      */
 632:     protected function _move($newfolder) {
 633: // First, ensure the new base directory exists.
 634:         $dest = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($newfolder);
 635: // Check to see if the destination already exists
 636:         if (file_exists($dest)) {
 637: // Disallow moving an album over an existing one.
 638:             if (!(CASE_INSENSITIVE && strtolower($dest) == strtolower(rtrim($this->localpath, '/')))) {
 639:                 return 3;
 640:             }
 641:         }
 642:         $oldfolders = explode('/', $this->name);
 643:         $newfolders = explode('/', $newfolder);
 644:         $sub = count($newfolders) > count($oldfolders);
 645:         if ($sub) {
 646:             for ($i = 0; $i < count($oldfolders); $i++) {
 647:                 if ($newfolders[$i] != $oldfolders[$i]) {
 648:                     $sub = false;
 649:                     break;
 650:                 }
 651:             }
 652:             if ($sub) {
 653: // Disallow moving to a subfolder of the current folder.
 654:                 return 4;
 655:             }
 656:         }
 657:   $filemask = substr($this->localpath, 0, -1) . '.*';
 658:         $perms = FOLDER_MOD;
 659:         @chmod($this->localpath, 0777);
 660:         $success = @rename(rtrim($this->localpath, '/'), $dest);
 661:         @chmod($dest, $perms);
 662: 
 663:         if ($success) {
 664:             $this->localpath = $dest . "/";
 665:             $filestomove = safe_glob($filemask);
 666:             foreach ($filestomove as $file) {
 667:                 if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
 668:                     $d = stripslashes($dest) . '.' . getSuffix($file);
 669:                     @chmod($file, 0777);
 670:                     $success = $success && @rename($file, $d);
 671:                     @chmod($d, FILE_MOD);
 672:                 }
 673:             }
 674:             clearstatcache();
 675:             $success = self::move($newfolder);
 676:             if ($success) {
 677:                 $this->updateParent($newfolder);
 678: //rename the cache folder
 679:                 $cacherename = @rename(SERVERCACHE . '/' . $this->name, SERVERCACHE . '/' . $newfolder);
 680:                 return 0;
 681:             }
 682:         }
 683:         return 1;
 684:     }
 685: 
 686:     /**
 687:      * Move this album to the location specified by $newfolder, copying all
 688:      * metadata, subalbums, and subalbums' metadata with it.
 689:      * @param $newfolder string the folder to move to, including the name of the current folder (possibly renamed).
 690:      * @return int 0 on success and error indicator on failure.
 691:      *
 692:      */
 693:     function move($newfolder) {
 694:         return parent::move(array('folder' => $newfolder));
 695:     }
 696: 
 697:     /**
 698:      * Rename this album folder. Alias for move($newfoldername);
 699:      * @param string $newfolder the new folder name of this album (including subalbum paths)
 700:      * @return boolean true on success or false on failure.
 701:      */
 702:     function rename($newfolder) {
 703:         return $this->move($newfolder);
 704:     }
 705: 
 706:     protected function succeed($dest) {
 707:         return false;
 708:     }
 709: 
 710:     /**
 711:      * Copy this album to the location specified by $newfolder, copying all
 712:      * metadata, subalbums, and subalbums' metadata with it.
 713:      * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed).
 714:      * @return int 0 on success and error indicator on failure.
 715:      *
 716:      */
 717:     function copy($newfolder) {
 718: // album name to destination folder
 719:         if (substr($newfolder, -1, 1) != '/')
 720:             $newfolder .= '/';
 721:         $newfolder .= basename($this->localpath);
 722: // First, ensure the new base directory exists.
 723:         $oldfolder = $this->name;
 724:         $dest = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($newfolder);
 725: // Check to see if the destination directory already exists
 726:         if (file_exists($dest)) {
 727: // Disallow moving an album over an existing one.
 728:             return 3;
 729:         }
 730:         if (substr($newfolder, count($oldfolder)) == $oldfolder) {
 731: // Disallow copying to a subfolder of the current folder (infinite loop).
 732:             return 4;
 733:         }
 734:         $success = $this->succeed($dest);
 735:         $filemask = substr($this->localpath, 0, -1) . '.*';
 736:         if ($success) {
 737: //  replicate the album metadata and sub-files
 738:             $uniqueset = array('folder' => $newfolder);
 739:             $parentname = dirname($newfolder);
 740:             if (empty($parentname) || $parentname == '/' || $parentname == '.') {
 741:                 $uniqueset['parentid'] = NULL;
 742:             } else {
 743:                 $parent = newAlbum($parentname);
 744:                 $uniqueset['parentid'] = $parent->getID();
 745:             }
 746:             $newID = parent::copy($uniqueset);
 747:             if ($newID) {
 748: //  replicate the tags
 749:                 storeTags(readTags($this->getID(), 'albums'), $newID, 'albums');
 750: //  copy the sidecar files
 751:                 $filestocopy = safe_glob($filemask);
 752:                 foreach ($filestocopy as $file) {
 753:                     if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
 754:                         $success = $success && @copy($file, dirname($dest) . '/' . basename($file));
 755:                     }
 756:                 }
 757:             }
 758:         }
 759:         if ($success) {
 760:             return 0;
 761:         } else {
 762:             return 1;
 763:         }
 764:     }
 765: 
 766:     /**
 767:      * For every image in the album, look for its file. Delete from the database
 768:      * if the file does not exist. Same for each sub-directory/album.
 769:      *
 770:      * @param bool $deep set to true for a thorough cleansing
 771:      */
 772:     function garbageCollect($deep = false) {
 773: 
 774:     }
 775: 
 776:     /**
 777:      * Load all of the filenames that are found in this Albums directory on disk.
 778:      * Returns an array with all the names.
 779:      *
 780:      * @param  $dirs Whether or not to return directories ONLY with the file array.
 781:      * @return array
 782:      */
 783:     protected function loadFileNames($dirs = false) {
 784: 
 785:     }
 786: 
 787:     /**
 788:      * Returns true if the album is "dynamic"
 789:      *
 790:      * @return bool
 791:      */
 792:     function isDynamic() {
 793:         return false;
 794:     }
 795: 
 796:     /**
 797:      * Returns the search parameters for a dynamic album
 798:      *
 799:      * @return string
 800:      */
 801:     function getSearchParams() {
 802:         return NULL;
 803:     }
 804: 
 805:     /**
 806:      * Sets the search parameters of a dynamic album
 807:      *
 808:      * @param string $params The search string to produce the dynamic album
 809:      */
 810:     function setSearchParams($params) {
 811: 
 812:     }
 813: 
 814:     /**
 815:      * Returns the search engine for a dynamic album
 816:      *
 817:      * @return object
 818:      */
 819:     function getSearchEngine() {
 820:         return NULL;
 821:     }
 822: 
 823:     /**
 824:      * checks access to the album
 825:      * @param bit $action What the requestor wants to do
 826:      *
 827:      * returns true of access is allowed
 828:      */
 829:     function isMyItem($action) {
 830:         global $_zp_loggedin;
 831:         if ($parent = parent::isMyItem($action)) {
 832:             return $parent;
 833:         }
 834:         if (zp_loggedin($action)) {
 835:             $subRights = $this->albumSubRights();
 836:             if (is_null($subRights)) {
 837: // no direct rights, but if this is a private gallery and the album is published he should be allowed to see it
 838:                 if (GALLERY_SECURITY != 'public' && $this->getShow() && $action == LIST_RIGHTS) {
 839:                     return LIST_RIGHTS;
 840:                 }
 841:             } else {
 842:                 $albumrights = LIST_RIGHTS;
 843:                 if ($subRights & (MANAGED_OBJECT_RIGHTS_EDIT)) {
 844:                     $albumrights = $albumrights | ALBUM_RIGHTS;
 845:                 }
 846:                 if ($subRights & MANAGED_OBJECT_RIGHTS_UPLOAD) {
 847:                     $albumrights = $albumrights | UPLOAD_RIGHTS;
 848:                 }
 849:                 if ($action & $albumrights) {
 850:                     return ($_zp_loggedin ^ (ALBUM_RIGHTS | UPLOAD_RIGHTS)) | $albumrights;
 851:                 } else {
 852:                     return false;
 853:                 }
 854:             }
 855:         }
 856:         return false;
 857:     }
 858: 
 859:     /**
 860:      * Checks if guest is loggedin for the album
 861:      * @param unknown_type $hint
 862:      * @param unknown_type $show
 863:      */
 864:     function checkforGuest(&$hint = NULL, &$show = NULL) {
 865:         if (!parent::checkForGuest()) {
 866:             return false;
 867:         }
 868:         return checkAlbumPassword($this, $hint);
 869:     }
 870: 
 871:     /**
 872:      *
 873:      * returns true if there is any protection on the album
 874:      */
 875:     function isProtected() {
 876:         return $this->checkforGuest() != 'zp_public_access';
 877:     }
 878: 
 879:     /**
 880:      * Owner functions
 881:      */
 882:     function getOwner() {
 883:         global $_zp_authority;
 884:         $owner = $this->get('owner');
 885:         if (empty($owner)) {
 886:             $p = $this->getParent();
 887:             if (is_object($p)) {
 888:                 $owner = $p->getOwner();
 889:             } else {
 890:                 $admin = $_zp_authority->getMasterUser();
 891:                 $owner = $admin->getUser();
 892:             }
 893:         }
 894:         return $owner;
 895:     }
 896: 
 897:     function setOwner($owner) {
 898:         $this->set('owner', $owner);
 899:     }
 900: 
 901:     /**
 902:      *
 903:      * Date at which the album last discovered an image
 904:      */
 905:     function getUpdatedDate() {
 906:         return $this->get('updateddate');
 907:     }
 908: 
 909:     function setUpdatedDate($date) {
 910:         return $this->set('updateddate', $date);
 911:     }
 912: 
 913:     /**
 914:      * Returns the theme for the album
 915:      *
 916:      * @return string
 917:      */
 918:     function getAlbumTheme() {
 919:         global $_zp_gallery;
 920:         if (in_context(ZP_SEARCH_LINKED)) {
 921:             return $_zp_gallery->getCurrentTheme();
 922:         } else {
 923:             return $this->get('album_theme');
 924:         }
 925:     }
 926: 
 927:     /**
 928:      * Sets the theme of the album
 929:      *
 930:      * @param string $theme
 931:      */
 932:     function setAlbumTheme($theme) {
 933:         $this->set('album_theme', $theme);
 934:     }
 935: 
 936:     /**
 937:      * returns the album watermark
 938:      * @return string
 939:      */
 940:     function getWatermark() {
 941:         return $this->get('watermark');
 942:     }
 943: 
 944:     /**
 945:      * Sets the album watermark
 946:      * @param string $wm
 947:      */
 948:     function setWatermark($wm) {
 949:         $this->set('watermark', $wm);
 950:     }
 951: 
 952:     /**
 953:      * Returns the album watermark thumb
 954:      *
 955:      * @return bool
 956:      */
 957:     function getWatermarkThumb() {
 958:         return $this->get('watermark_thumb');
 959:     }
 960: 
 961:     /**
 962:      * Sets the custom watermark usage
 963:      *
 964:      * @param $wm
 965:      */
 966:     function setWatermarkThumb($wm) {
 967:         $this->set('watermark_thumb', $wm);
 968:     }
 969: 
 970:     /**
 971:      * returns the mitigated album rights.
 972:      * returns NULL if not a managed album
 973:      */
 974:     function albumSubRights() {
 975:         if (!is_null($this->subrights)) {
 976:             return $this->subrights;
 977:         }
 978:         global $_zp_admin_album_list;
 979:         if (zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
 980:             $this->subrights = MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_UPLOAD | MANAGED_OBJECT_RIGHTS_VIEW;
 981:             return $this->subrights;
 982:         }
 983:         if (zp_loggedin(VIEW_UNPUBLISHED_RIGHTS)) {
 984:             $base = MANAGED_OBJECT_RIGHTS_VIEW;
 985:         } else {
 986:             $base = NULL;
 987:         }
 988:         getManagedAlbumList();
 989:         if (count($_zp_admin_album_list) > 0) {
 990:             $desired_folders = explode('/', $this->name);
 991:             foreach ($_zp_admin_album_list as $adminalbum => $rights) {
 992: // see if it is one of the managed folders or a subfolder there of
 993:                 $admin_folders = explode('/', $adminalbum);
 994:                 $level = 0;
 995:                 $ok = true;
 996:                 foreach ($admin_folders as $folder) {
 997:                     if ($level >= count($desired_folders) || $folder != $desired_folders[$level]) {
 998:                         $ok = false;
 999:                         break;
1000:                     }
1001:                     $level++;
1002:                 }
1003:                 if ($ok) {
1004:                     $this->subrights = $rights | $base;
1005:                     return $this->subrights;
1006:                 }
1007:             }
1008:         }
1009:         $this->subrights = $base;
1010:         return $this->subrights;
1011:     }
1012: 
1013:     /**
1014:      * sortImageArray will sort an array of Images based on the given key. The
1015:      * key must be one of (filename, title, sort_order) at the moment.
1016:      *
1017:      * @param array $images The array of filenames to be sorted.
1018:      * @param  string $sorttype optional sort type
1019:      * @param  string $sortdirection optional sort direction
1020:      * @param bool $mine set to true/false to override ownership clause
1021:      * @return array
1022:      */
1023:     protected function sortImageArray($images, $sorttype, $sortdirection, $mine = NULL) {
1024:         if (is_null($mine)) {
1025:             $mine = $this->isMyItem(LIST_RIGHTS | MANAGE_ALL_ALBUM_RIGHTS);
1026:         }
1027:         if ($mine && !($mine & (MANAGE_ALL_ALBUM_RIGHTS))) {
1028: //  check for managed album view unpublished image rights
1029:             $mine = $this->albumSubRights() & (MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_VIEW);
1030:         }
1031:         $sortkey = $this->getImageSortKey($sorttype);
1032:         if (($sortkey == '`sort_order`') || ($sortkey == 'RAND()')) {
1033: // manual sort is always ascending
1034:             $order = false;
1035:         } else {
1036:             if (!is_null($sortdirection)) {
1037:                 $order = strtoupper($sortdirection) == 'DESC';
1038:             } else {
1039:                 $order = $this->getSortDirection('image');
1040:             }
1041:         }
1042:         $result = query($sql = "SELECT * FROM " . prefix("images") . " WHERE `albumid`= " . $this->getID() . ' ORDER BY ' . $sortkey . ' ' . $sortdirection);
1043:         $results = array();
1044:         while ($row = db_fetch_assoc($result)) {
1045:             $filename = $row['filename'];
1046:             if (($key = array_search($filename, $images)) !== false) {
1047: // the image exists in the filesystem
1048:                 $results[] = $row;
1049:                 unset($images[$key]);
1050:             } else { // the image no longer exists
1051:                 $id = $row['id'];
1052:                 query("DELETE FROM " . prefix('images') . " WHERE `id`=$id"); // delete the record
1053:                 query("DELETE FROM " . prefix('comments') . " WHERE `type` ='images' AND `ownerid`= '$id'"); // remove image comments
1054:             }
1055:         }
1056:         db_free_result($result);
1057:         foreach ($images as $filename) {
1058: // these images are not in the database
1059:             $imageobj = newImage($this, $filename);
1060:             $results[] = $imageobj->getData();
1061:         }
1062: // now put the results into the right order
1063:         $results = sortByKey($results, str_replace('`', '', $sortkey), $order);
1064: // the results are now in the correct order
1065:         $images_ordered = array();
1066:         foreach ($results as $key => $row) {
1067: // check for visible
1068:             switch (checkPublishDates($row)) {
1069:                 case 1:
1070:                     $imageobj = newImage($this, $row['filename']);
1071:                     $imageobj->setShow(0);
1072:                     $imageobj->save();
1073:                 case 2:
1074:                     $row['show'] = 0;
1075:                     break;
1076:             }
1077:             if ($row['show'] || $mine) {
1078: // don't display it
1079:                 $images_ordered[] = $row['filename'];
1080:             }
1081:         }
1082:         return $images_ordered;
1083:     }
1084: 
1085:     /**
1086:      * changes the parent of an album for move/copy
1087:      *
1088:      * @param string $newfolder The folder name of the new parent
1089:      */
1090:     protected function updateParent($newfolder) {
1091:         $this->name = $newfolder;
1092:         $parentname = dirname($newfolder);
1093:         if ($parentname == '/' || $parentname == '.')
1094:             $parentname = '';
1095:         if (empty($parentname)) {
1096:             $this->set('parentid', NULL);
1097:         } else {
1098:             $parent = newAlbum($parentname);
1099:             $this->set('parentid', $parent->getID());
1100:         }
1101:         $this->save();
1102:     }
1103: 
1104:     /**
1105:      * Simply creates objects of all the images and sub-albums in this album to
1106:      * load accurate values into the database.
1107:      */
1108:     function preLoad() {
1109:         $images = $this->getImages(0);
1110:         $subalbums = $this->getAlbums(0);
1111:         foreach ($subalbums as $dir) {
1112:             $album = newAlbum($dir);
1113:             $album->preLoad();
1114:         }
1115:     }
1116: 
1117:     /**
1118:      * Returns the album following the current album
1119:      *
1120:      * @return object
1121:      */
1122:     function getNextAlbum() {
1123:         global $_zp_gallery;
1124:         if (is_null($parent = $this->getParent())) {
1125:             $albums = $_zp_gallery->getAlbums(0);
1126:         } else {
1127:             $albums = $parent->getAlbums(0);
1128:         }
1129:         $inx = array_search($this->name, $albums) + 1;
1130:         if ($inx >= 0 && $inx < count($albums)) {
1131:             return newAlbum($albums[$inx]);
1132:         }
1133:         return null;
1134:     }
1135: 
1136:     /**
1137:      * Returns the album prior to the current album
1138:      *
1139:      * @return object
1140:      */
1141:     function getPrevAlbum() {
1142:         global $_zp_gallery;
1143:         if (is_null($parent = $this->getParent())) {
1144:             $albums = $_zp_gallery->getAlbums(0);
1145:         } else {
1146:             $albums = $parent->getAlbums(0);
1147:         }
1148:         $inx = array_search($this->name, $albums) - 1;
1149:         if ($inx >= 0 && $inx < count($albums)) {
1150:             return newAlbum($albums[$inx]);
1151:         }
1152:         return null;
1153:     }
1154: 
1155:     /**
1156:      * Returns the page number in the gallery or the parent album of this album 
1157:      *
1158:      * @return int
1159:      */
1160:     function getGalleryPage() {
1161:         global $_zp_gallery;
1162:         if ($this->index == null) {
1163:             if (is_null($parent = $this->getParent())) {
1164:                 $albums = $_zp_gallery->getAlbums(0);
1165:             } else {
1166:                 $albums = $parent->getAlbums(0);
1167:             }
1168:             $this->index = array_search($this->name, $albums);
1169:         }
1170:         return floor(($this->index / galleryAlbumsPerPage()) + 1);
1171:     }
1172: 
1173: }
1174: 
1175: class Album extends AlbumBase {
1176: 
1177:     /**
1178:      * Constructor for albums
1179:      *
1180:      * @param object $gallery The parent gallery: deprecated
1181:      * @param string $folder8 folder name (UTF8) of the album
1182:      * @param bool $cache load from cache if present
1183:      * @return Album
1184:      */
1185:     function __construct($folder8, $cache = true, $quiet = false) {
1186: 
1187:         $folder8 = trim($folder8, '/');
1188:         $folderFS = internalToFilesystem($folder8);
1189:         $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS . "/";
1190:         $this->linkname = $this->name = $folder8;
1191:         $this->localpath = $localpath;
1192:         if (!$this->_albumCheck($folder8, $folderFS, $quiet))
1193:             return;
1194: 
1195:         $new = $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
1196: 
1197:         if ($new) {
1198:             $this->save();
1199:             zp_apply_filter('new_album', $this);
1200:         }
1201:         zp_apply_filter('album_instantiate', $this);
1202:     }
1203: 
1204:     /**
1205:      * album validity check
1206:      * @return boolean
1207:      */
1208:     protected function _albumCheck($folder8, $folderFS, $quiet) {
1209:         $msg = false;
1210:         if (empty($folder8)) {
1211:             $msg = gettext('Invalid album instantiation: No album name');
1212:         } else if (filesystemToInternal($folderFS) != $folder8) {
1213: // an attempt to spoof the album name.
1214:             $msg = sprintf(gettext('Invalid album instantiation: %1$s!=%2$s'), html_encode(filesystemToInternal($folderFS)), html_encode($folder8));
1215:         } else if (!file_exists($this->localpath) || !(is_dir($this->localpath)) || $folder8{0} == '.' || preg_match('~/\.*/~', $folder8)) {
1216:             $msg = sprintf(gettext('Invalid album instantiation: %s does not exist.'), html_encode($folder8));
1217:         }
1218:         if ($msg) {
1219:             $this->exists = false;
1220:             if (!$quiet) {
1221:                 trigger_error($msg, E_USER_ERROR);
1222:             }
1223:             return false;
1224:         }
1225:         return true;
1226:     }
1227: 
1228:     /**
1229:      * Sets default values for a new album
1230:      *
1231:      * @return bool
1232:      */
1233:     protected function setDefaults() {
1234:         global $_zp_gallery;
1235:         // Set default data for a new Album (title and parent_id)
1236:         parent::setDefaults();
1237:         $parentalbum = $this->getParent();
1238:         $this->set('mtime', filemtime($this->localpath));
1239:         if (!$_zp_gallery->getAlbumUseImagedate()) {
1240:             $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
1241:         }
1242:         $title = trim($this->name);
1243:         if (!is_null($parentalbum)) {
1244:             $this->set('parentid', $parentalbum->getID());
1245:             $title = substr($title, strrpos($title, '/') + 1);
1246:         }
1247:         $this->set('title', sanitize($title, 2));
1248:         return true;
1249:     }
1250: 
1251:     /**
1252:      * Guts of fetching the subalbums
1253:      * @return array
1254:      */
1255:     protected function _getAlbums() {
1256:         $dirs = $this->loadFileNames(true);
1257:         $subalbums = array();
1258:         foreach ($dirs as $dir) {
1259:             $dir = $this->name . '/' . $dir;
1260:             $subalbums[] = $dir;
1261:         }
1262:         return $subalbums;
1263:     }
1264: 
1265:     /**
1266:      * Returns all folder names for all the subdirectories.
1267:      *
1268:      * @param string $page  Which page of subalbums to display.
1269:      * @param string $sorttype The sort strategy
1270:      * @param string $sortdirection The direction of the sort
1271:      * @param bool $care set to false if the order does not matter
1272:      * @param bool $mine set true/false to override ownership
1273:      * @return array
1274:      */
1275:     function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1276:         global $_zp_gallery;
1277:         if (!$this->exists)
1278:             return array();
1279:         if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) {
1280:             if (is_null($sorttype)) {
1281:                 $sorttype = $this->getSortType('album');
1282:             }
1283:             if (is_null($sortdirection)) {
1284:                 if ($this->getSortDirection('album')) {
1285:                     $sortdirection = 'DESC';
1286:                 } else {
1287:                     $sortdirection = '';
1288:                 }
1289:             }
1290:             $dirs = $this->loadFileNames(true);
1291:             $subalbums = array();
1292:             foreach ($dirs as $dir) {
1293:                 $dir = $this->name . '/' . $dir;
1294:                 $subalbums[] = $dir;
1295:             }
1296:             $key = $this->getAlbumSortKey($sorttype);
1297:             $this->subalbums = $_zp_gallery->sortAlbumArray($this, $subalbums, $key, $sortdirection, $mine);
1298:             $this->lastsubalbumsort = $sorttype . $sortdirection;
1299:         }
1300:         return parent::getAlbums($page);
1301:     }
1302: 
1303:     /**
1304:      * Returns a of a slice of the images for this album. They will
1305:      * also be sorted according to the sort type of this album, or by filename if none
1306:      * has been set.
1307:      *
1308:      * @param int $page  Which page of images should be returned. If zero, all images are returned.
1309:      * @param int $firstPageCount count of images that go on the album/image transition page
1310:      * @param string $sorttype optional sort type
1311:      * @param string $sortdirection optional sort direction
1312:      * @param bool $care set to false if the order of the images does not matter
1313:      * @param bool $mine set true/false to override ownership
1314:      *
1315:      * @return array
1316:      */
1317:     function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1318:         if (!$this->exists)
1319:             return array();
1320:         if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) {
1321:             if (is_null($sorttype)) {
1322:                 $sorttype = $this->getSortType();
1323:             }
1324:             if (is_null($sortdirection)) {
1325:                 if ($this->getSortDirection('image')) {
1326:                     $sortdirection = 'DESC';
1327:                 }
1328:             }
1329:             $images = $this->loadFileNames();
1330:             $this->images = $this->sortImageArray($images, $sorttype, $sortdirection, $mine);
1331:             $this->lastimagesort = $sorttype . $sortdirection;
1332:         }
1333:         return parent::getImages($page, $firstPageCount);
1334:     }
1335: 
1336:     /**
1337:      * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable.
1338:      * Returns true if successful
1339:      *
1340:      * @return bool
1341:      */
1342:     function remove() {
1343:         $rslt = false;
1344:         if (PersistentObject::remove()) {
1345:             foreach ($this->getImages() as $filename) {
1346:                 $image = newImage($this, $filename);
1347:                 $image->remove();
1348:             }
1349:             foreach ($this->getAlbums() as $folder) {
1350:                 $subalbum = newAlbum($folder);
1351:                 $subalbum->remove();
1352:             }
1353:             $curdir = getcwd();
1354:             chdir($this->localpath);
1355:             $filelist = safe_glob('*');
1356:             foreach ($filelist as $file) {
1357:                 if (($file != '.') && ($file != '..')) {
1358:                     @chmod($file, 0777);
1359:                     unlink($this->localpath . $file); // clean out any other files in the folder
1360:                 }
1361:             }
1362:             chdir($curdir);
1363:             clearstatcache();
1364:             query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id);
1365:             query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id);
1366:             query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id);
1367:             $success = true;
1368:             $filestoremove = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*');
1369:             foreach ($filestoremove as $file) {
1370:                 if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
1371:                     @chmod($file, 0777);
1372:                     $success = $success && unlink($file);
1373:                 }
1374:             }
1375:             @chmod($this->localpath, 0777);
1376:             $rslt = @rmdir($this->localpath) && $success;
1377:    $cachepath = SERVERCACHE.'/'.pathurlencode($this->name).'/';
1378:    @chmod($cachepath, 0777);
1379:    @rmdir($cachepath);
1380:         }
1381:         clearstatcache();
1382:         return $rslt;
1383:     }
1384: 
1385:     /**
1386:      * Move this album to the location specified by $newfolder, copying all
1387:      * metadata, subalbums, and subalbums' metadata with it.
1388:      * @param $newfolder string the folder to move to, including the name of the current folder (possibly renamed).
1389:      * @return int 0 on success and error indicator on failure.
1390:      *
1391:      */
1392:     function move($newfolder) {
1393:   $oldfolder = $this->name;
1394:         $rslt = $this->_move($newfolder);
1395:         if (!$rslt) {
1396:             // Then: go through the db and change the album (and subalbum) paths. No ID changes are necessary for a move.
1397:             // Get the subalbums.
1398:             $sql = "SELECT id, folder FROM " . prefix('albums') . " WHERE folder LIKE " . db_quote(db_LIKE_escape($oldfolder) . '/%');
1399:             $result = query($sql);
1400:             if ($result) {
1401:                 while ($subrow = db_fetch_assoc($result)) {
1402:                     $newsubfolder = $subrow['folder'];
1403:                     $newsubfolder = $newfolder . substr($newsubfolder, strlen($oldfolder));
1404:                     $sql = "UPDATE " . prefix('albums') . " SET folder=" . db_quote($newsubfolder) . " WHERE id=" . $subrow['id'];
1405:                     query($sql);
1406:                 }
1407:             }
1408:             db_free_result($result);
1409:             return 0;
1410:         }
1411:         return $rslt;
1412:     }
1413: 
1414:     protected function succeed($dest) {
1415:         return mkdir_recursive($dest, FOLDER_MOD) === TRUE;
1416:     }
1417: 
1418:     /**
1419:      * Copy this album to the location specified by $newfolder, copying all
1420:      * metadata, subalbums, and subalbums' metadata with it.
1421:      * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed).
1422:      * @return int 0 on success and error indicator on failure.
1423:      *
1424:      */
1425:     function copy($newfolder) {
1426:         $rslt = parent::copy($newfolder);
1427:         if (!$rslt) {
1428:             $newfolder .= '/' . basename($this->name);
1429:             $success = true;
1430: //  copy the images
1431:             $images = $this->getImages(0);
1432:             foreach ($images as $imagename) {
1433:                 $image = newImage($this, $imagename);
1434:                 if ($rslt = $image->copy($newfolder)) {
1435:                     $success = false;
1436:                 }
1437:             }
1438: // copy the subalbums.
1439:             $subalbums = $this->getAlbums(0);
1440:             foreach ($subalbums as $subalbumname) {
1441:                 $subalbum = newAlbum($subalbumname);
1442:                 if ($rslt = $subalbum->copy($newfolder)) {
1443:                     $success = false;
1444:                 }
1445:             }
1446:             if ($success) {
1447:                 return 0;
1448:             }
1449:             return 1;
1450:         }
1451:         return $rslt;
1452:     }
1453: 
1454:     /**
1455:      * For every image in the album, look for its file. Delete from the database
1456:      * if the file does not exist. Same for each sub-directory/album.
1457:      *
1458:      * @param bool $deep set to true for a thorough cleansing
1459:      */
1460:     function garbageCollect($deep = false) {
1461:         if (is_null($this->images))
1462:             $this->getImages();
1463:         $result = query("SELECT * FROM " . prefix('images') . " WHERE `albumid` = '" . $this->id . "'");
1464:         $dead = array();
1465:         $live = array();
1466: 
1467:         $files = $this->loadFileNames();
1468: 
1469: // Does the filename from the db row match any in the files on disk?
1470:         while ($row = db_fetch_assoc($result)) {
1471:             if (!in_array($row['filename'], $files)) {
1472: // In the database but not on disk. Kill it.
1473:                 $dead[] = $row['id'];
1474:             } else if (in_array($row['filename'], $live)) {
1475: // Duplicate in the database. Kill it.
1476:                 $dead[] = $row['id'];
1477: // Do something else here? Compare titles/descriptions/metadata/update dates to see which is the latest?
1478:             } else {
1479:                 $live[] = $row['filename'];
1480:             }
1481:         }
1482:         db_free_result($result);
1483: 
1484:         if (count($dead) > 0) {
1485:             $sql = "DELETE FROM " . prefix('images') . " WHERE `id` = '" . array_pop($dead) . "'";
1486:             $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
1487:             foreach ($dead as $id) {
1488:                 $sql .= " OR `id` = '$id'";
1489:                 $sql2 .= " OR `ownerid` = '$id'";
1490:             }
1491:             query($sql);
1492:             query($sql2);
1493:         }
1494: 
1495: // Get all sub-albums and make sure they exist.
1496:         $result = query("SELECT * FROM " . prefix('albums') . " WHERE `folder` LIKE " . db_quote(db_LIKE_escape($this->name) . '%'));
1497:         $dead = array();
1498:         $live = array();
1499: // Does the dirname from the db row exist on disk?
1500:         while ($row = db_fetch_assoc($result)) {
1501:             if (!is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($row['folder'])) || in_array($row['folder'], $live) || substr($row['folder'], -1) == '/' || substr($row['folder'], 0, 1) == '/') {
1502:                 $dead[] = $row['id'];
1503:             } else {
1504:                 $live[] = $row['folder'];
1505:             }
1506:         }
1507:         db_free_result($result);
1508:         if (count($dead) > 0) {
1509:             $sql = "DELETE FROM " . prefix('albums') . " WHERE `id` = '" . array_pop($dead) . "'";
1510:             $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
1511:             foreach ($dead as $albumid) {
1512:                 $sql .= " OR `id` = '$albumid'";
1513:                 $sql2 .= " OR `ownerid` = '$albumid'";
1514:             }
1515:             query($sql);
1516:             query($sql2);
1517:         }
1518: 
1519:         if ($deep) {
1520:             foreach ($this->getAlbums(0) as $dir) {
1521:                 $subalbum = newAlbum($dir);
1522: // Could have been deleted if it didn't exist above...
1523:                 if ($subalbum->exists)
1524:                     $subalbum->garbageCollect($deep);
1525:             }
1526:         }
1527:     }
1528: 
1529:     /**
1530:      * Load all of the filenames that are found in this Albums directory on disk.
1531:      * Returns an array with all the names.
1532:      *
1533:      * @param  $dirs Whether or not to return directories ONLY with the file array.
1534:      * @return array
1535:      */
1536:     protected function loadFileNames($dirs = false) {
1537:         clearstatcache();
1538:         $albumdir = $this->localpath;
1539:         $dir = @opendir($albumdir);
1540:         if (!$dir) {
1541:             if (is_dir($albumdir)) {
1542:                 $msg = sprintf(gettext("Error: The album %s is not readable."), html_encode($this->name));
1543:             } else {
1544:                 $msg = sprintf(gettext("Error: The album named %s cannot be found."), html_encode($this->name));
1545:             }
1546:             trigger_error($msg, E_USER_NOTICE);
1547:             return array();
1548:         }
1549: 
1550:         $files = array();
1551:         $others = array();
1552: 
1553:         while (false !== ($file = readdir($dir))) {
1554:             $file8 = filesystemToInternal($file);
1555:             if (@$file8{0} != '.') {
1556:                 if ($dirs && (is_dir($albumdir . $file) || hasDynamicAlbumSuffix($file))) {
1557:                     $files[] = $file8;
1558:                 } else if (!$dirs && is_file($albumdir . $file)) {
1559:                     if (Gallery::validImageAlt($file)) {
1560:                         $files[] = $file8;
1561:                         $others[] = $file8;
1562:                     } else if (Gallery::validImage($file)) {
1563:                         $files[] = $file8;
1564:                     }
1565:                 }
1566:             }
1567:         }
1568:         closedir($dir);
1569:         if (count($others) > 0) {
1570:             $others_thumbs = array();
1571:             foreach ($others as $other) {
1572:                 $others_root = substr($other, 0, strrpos($other, "."));
1573:                 foreach ($files as $image) {
1574:                     if ($image != $other) {
1575:                         $image_root = substr($image, 0, strrpos($image, "."));
1576:                         if ($image_root == $others_root && Gallery::validImage($image)) {
1577:                             $others_thumbs[] = $image;
1578:                         }
1579:                     }
1580:                 }
1581:             }
1582:             $files = array_diff($files, $others_thumbs);
1583:         }
1584: 
1585:         if ($dirs) {
1586:             return zp_apply_filter('album_filter', $files);
1587:         } else {
1588:             return zp_apply_filter('image_filter', $files);
1589:         }
1590:     }
1591: 
1592: }
1593: 
1594: class dynamicAlbum extends AlbumBase {
1595: 
1596:     var $searchengine; // cache the search engine for dynamic albums
1597: 
1598:     function __construct($folder8, $cache = true, $quiet = false) {
1599:         $folder8 = trim($folder8, '/');
1600:         $folderFS = internalToFilesystem($folder8);
1601:         $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS . "/";
1602:         $this->linkname = $this->name = $folder8;
1603:         $this->localpath = $localpath;
1604:         if (!$this->_albumCheck($folder8, $folderFS, $quiet))
1605:             return;
1606:         $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
1607:         $this->exists = true;
1608:         if (!is_dir(stripSuffix($this->localpath))) {
1609:             $this->linkname = stripSuffix($folder8);
1610:         }
1611:         $new = !$this->get('search_params');
1612:         if ($new || (filemtime($this->localpath) > $this->get('mtime'))) {
1613:             $constraints = '';
1614:             $data = file_get_contents($this->localpath);
1615:             while (!empty($data)) {
1616:                 $data1 = trim(substr($data, 0, $i = strpos($data, "\n")));
1617:                 if ($i === false) {
1618:                     $data1 = $data;
1619:                     $data = '';
1620:                 } else {
1621:                     $data = substr($data, $i + 1);
1622:                 }
1623:                 if (strpos($data1, 'WORDS=') !== false) {
1624:                     $words = "words=" . urlencode(substr($data1, 6));
1625:                 }
1626:                 if (strpos($data1, 'THUMB=') !== false) {
1627:                     $thumb = trim(substr($data1, 6));
1628:                     $this->set('thumb', $thumb);
1629:                 }
1630:                 if (strpos($data1, 'FIELDS=') !== false) {
1631:                     $fields = "&searchfields=" . trim(substr($data1, 7));
1632:                 }
1633:                 if (strpos($data1, 'CONSTRAINTS=') !== false) {
1634:                     $constraint = trim(substr($data1, 12));
1635:                     $constraints = '&' . $constraint;
1636:                 }
1637:             }
1638:             if (!empty($words)) {
1639:                 if (empty($fields)) {
1640:                     $fields = '&searchfields=tags';
1641:                 }
1642:                 $this->set('search_params', $words . $fields . $constraints);
1643:             }
1644:             $this->set('mtime', filemtime($this->localpath));
1645:             if ($new) {
1646:                 $title = $this->get('title');
1647:                 $this->set('title', stripSuffix($title)); // Strip the suffix
1648:                 $this->save();
1649:                 zp_apply_filter('new_album', $this);
1650:             }
1651:         }
1652:         zp_apply_filter('album_instantiate', $this);
1653:     }
1654: 
1655:     /**
1656:      * album validity check
1657:      * @param type $folder8
1658:      * @return boolean
1659:      */
1660:     protected function _albumCheck($folder8, $folderFS, $quiet) {
1661:         $this->localpath = rtrim($this->localpath, '/');
1662: 
1663:         $msg = false;
1664:         if (empty($folder8)) {
1665:             $msg = gettext('Invalid album instantiation: No album name');
1666:         } else if (filesystemToInternal($folderFS) != $folder8) {
1667: // an attempt to spoof the album name.
1668:             $msg = sprintf(gettext('Invalid album instantiation: %1$s!=%2$s'), html_encode(filesystemToInternal($folderFS)), html_encode($folder8));
1669:         } else if (!file_exists($this->localpath) || is_dir($this->localpath)) {
1670:             $msg = sprintf(gettext('Invalid album instantiation: %s does not exist.'), html_encode($folder8));
1671:         }
1672:         if ($msg) {
1673:             $this->exists = false;
1674:             if (!$quiet) {
1675:                 trigger_error($msg, E_USER_ERROR);
1676:             }
1677:             return false;
1678:         }
1679:         return true;
1680:     }
1681: 
1682:     /**
1683:      * Returns all folder names for all the subdirectories.
1684:      *
1685:      * @param string $page  Which page of subalbums to display.
1686:      * @param string $sorttype The sort strategy
1687:      * @param string $sortdirection The direction of the sort
1688:      * @param bool $care set to false if the order does not matter
1689:      * @param bool $mine set true/false to override ownership
1690:      * @return array
1691:      */
1692:     function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1693:         global $_zp_gallery;
1694:         if (!$this->exists)
1695:             return array();
1696:         if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) {
1697:             if (is_null($sorttype)) {
1698:                 $sorttype = $this->getSortType('album');
1699:             }
1700:             if (is_null($sortdirection)) {
1701:                 if ($this->getSortDirection('album')) {
1702:                     $sortdirection = 'DESC';
1703:                 } else {
1704:                     $sortdirection = '';
1705:                 }
1706:             }
1707:             $searchengine = $this->getSearchEngine();
1708:             $subalbums = $searchengine->getAlbums(0, $sorttype, $sortdirection, $care, $mine);
1709:             $key = $this->getAlbumSortKey($sorttype);
1710:             $this->subalbums = $_zp_gallery->sortAlbumArray($this, $subalbums, $key, $sortdirection, $mine);
1711:             $this->lastsubalbumsort = $sorttype . $sortdirection;
1712:         }
1713:         return parent::getAlbums($page);
1714:     }
1715: 
1716:     /**
1717:      * Returns the search parameters for a dynamic album
1718:      *
1719:      * @return string
1720:      */
1721:     function getSearchParams() {
1722:         return $this->get('search_params');
1723:     }
1724: 
1725:     /**
1726:      * Sets the search parameters of a dynamic album
1727:      *
1728:      * @param string $params The search string to produce the dynamic album
1729:      */
1730:     function setSearchParams($params) {
1731:         $this->set('search_params', $params);
1732:     }
1733: 
1734:     /**
1735:      * Returns the search engine for a dynamic album
1736:      *
1737:      * @return object
1738:      */
1739:     function getSearchEngine() {
1740:         if (!is_null($this->searchengine))
1741:             return $this->searchengine;
1742:         $this->searchengine = new SearchEngine(true);
1743:         $params = $this->get('search_params');
1744:         $params .= '&albumname=' . $this->name;
1745:         $this->searchengine->setSearchParams($params);
1746:         return $this->searchengine;
1747:     }
1748: 
1749:     /**
1750:      * Returns a of a slice of the images for this album. They will
1751:      * also be sorted according to the sort type of this album, or by filename if none
1752:      * has been set.
1753:      *
1754:      * @param int $page  Which page of images should be returned. If zero, all images are returned.
1755:      * @param int $firstPageCount count of images that go on the album/image transition page
1756:      * @param string $sorttype optional sort type
1757:      * @param string $sortdirection optional sort direction
1758:      * @param bool $care set to false if the order of the images does not matter
1759:      * @param bool $mine set true/false to override ownership
1760:      *
1761:      * @return array
1762:      */
1763:     function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1764:         if (!$this->exists)
1765:             return array();
1766:         if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) {
1767:             if (is_null($sorttype)) {
1768:                 $sorttype = $this->getSortType();
1769:             }
1770:             if (is_null($sortdirection)) {
1771:                 if ($this->getSortDirection('image')) {
1772:                     $sortdirection = 'DESC';
1773:                 }
1774:             }
1775:             $searchengine = $this->getSearchEngine();
1776:             $this->images = $searchengine->getImages(0, 0, $sorttype, $sortdirection, $care, $mine);
1777:             $this->lastimagesort = $sorttype . $sortdirection;
1778:         }
1779:         return parent::getImages($page, $firstPageCount);
1780:     }
1781: 
1782:     /**
1783:      * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable.
1784:      * Returns true if successful
1785:      *
1786:      * @return bool
1787:      */
1788:     function remove() {
1789:         if ($rslt = parent::remove()) {
1790:             @chmod($this->localpath, 0777);
1791:             $rslt = @unlink($this->localpath);
1792:             clearstatcache();
1793:         }
1794:         return $rslt;
1795:     }
1796: 
1797:     /**
1798:      * Move this album to the location specified by $newfolder, copying all
1799:      * metadata, subalbums, and subalbums' metadata with it.
1800:      * @param $newfolder string the folder to move to, including the name of the current folder (possibly renamed).
1801:      * @return int 0 on success and error indicator on failure.
1802:      *
1803:      */
1804:     function move($newfolder,$oldfolder="") {
1805:         return $this->_move($newfolder);
1806:     }
1807: 
1808:     protected function succeed($dest) {
1809:         return @copy($this->localpath, $dest);
1810:     }
1811: 
1812:     /**
1813:      * Copy this album to the location specified by $newfolder, copying all
1814:      * metadata, subalbums, and subalbums' metadata with it.
1815:      * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed).
1816:      * @return int 0 on success and error indicator on failure.
1817:      *
1818:      */
1819:     function copy($newfolder) {
1820:         return parent::copy($newfolder);
1821:     }
1822: 
1823:     /**
1824:      * Simply creates objects of all the images and sub-albums in this album to
1825:      * load accurate values into the database.
1826:      */
1827:     function preLoad() {
1828:         return; // nothing to do
1829:     }
1830: 
1831:     protected function loadFileNames($dirs = false) {
1832:         return array();
1833:     }
1834: 
1835:     function isDynamic() {
1836:         return 'alb';
1837:     }
1838:     
1839:     /**
1840:      * Sets default values for a new album
1841:      *
1842:      * @return bool
1843:      */
1844:     protected function setDefaults() {
1845:         global $_zp_gallery;
1846:         // Set default data for a new Album (title and parent_id)
1847:         parent::setDefaults();
1848:         $parentalbum = $this->getParent();
1849:         $this->set('mtime', filemtime($this->localpath));
1850:         if (!$_zp_gallery->getAlbumUseImagedate()) {
1851:             $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
1852:         }
1853:         $title = trim($this->name);
1854:         if (!is_null($parentalbum)) {
1855:             $this->set('parentid', $parentalbum->getID());
1856:             $title = substr($title, strrpos($title, '/') + 1);
1857:         }
1858:         $this->set('title', sanitize($title, 2));
1859:         return true;
1860:     }
1861: 
1862: }
1863: 
1864: ?>
1865: 
Zenphoto doc API documentation generated by ApiGen