Overview

Packages

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

Classes

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

Exceptions

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

Functions

  • __autoload
  • _escape_xref
  • _recaptcha_aes_encrypt
  • _recaptcha_aes_pad
  • _recaptcha_http_post
  • _recaptcha_mailhide_email_parts
  • _recaptcha_mailhide_urlbase64
  • _recaptcha_qsencode
  • accessAllAlbums
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addGeoCoord
  • addItem
  • addPagesToDatabase
  • addPluginScript
  • addPluginType
  • addSubalbumMenus
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • Auth_OpenID_arrangeByType
  • Auth_OpenID_AX_checkAlias
  • Auth_OpenID_AX_toTypeURIs
  • Auth_OpenID_bestMatchingService
  • Auth_OpenID_checkFieldName
  • Auth_OpenID_checkSessionType
  • Auth_OpenID_checkTimestamp
  • Auth_OpenID_detectMathLibrary
  • Auth_OpenID_discover
  • Auth_OpenID_discoverURI
  • Auth_OpenID_discoverWithoutYadis
  • Auth_OpenID_discoverWithYadis
  • Auth_OpenID_discoverXRI
  • Auth_OpenID_extractReturnURL
  • Auth_OpenID_findOPLocalIdentifier
  • Auth_OpenID_getAllAssociationTypes
  • Auth_OpenID_getAllowedReturnURLs
  • Auth_OpenID_getAuthorityPattern
  • Auth_OpenID_getAvailableSessionTypes
  • Auth_OpenID_getDefaultAssociationOrder
  • Auth_OpenID_getDefaultGen
  • Auth_OpenID_getDefaultMod
  • Auth_OpenID_getDefaultNegotiator
  • Auth_OpenID_getEncodedPattern
  • Auth_OpenID_getEncryptedNegotiator
  • Auth_OpenID_getEscapeRE
  • Auth_OpenID_getMathLib
  • Auth_OpenID_getOnlyEncryptedOrder
  • Auth_OpenID_getOpenIDConsumerTypeURIs
  • Auth_OpenID_getOpenIDTypeName
  • Auth_OpenID_getOpenIDTypeURIs
  • Auth_OpenID_getOPOrUserServices
  • Auth_OpenID_getSecretSize
  • Auth_OpenID_getSessionTypes
  • Auth_OpenID_getSupportedAssociationTypes
  • Auth_OpenID_getUnreserved
  • Auth_OpenID_getURIPattern
  • Auth_OpenID_getURLIllegalCharRE
  • Auth_OpenID_HMACSHA1
  • Auth_OpenID_HMACSHA256
  • Auth_OpenID_include_init
  • Auth_OpenID_isError
  • Auth_OpenID_isOpenID1
  • Auth_OpenID_legacy_discover
  • Auth_OpenID_makeOpenIDEndpoints
  • Auth_OpenID_math_extensions
  • Auth_OpenID_mkNonce
  • Auth_OpenID_noMathSupport
  • Auth_OpenID_pct_encoded_replace
  • Auth_OpenID_pct_encoded_replace_unreserved
  • Auth_OpenID_registerNamespaceAlias
  • Auth_OpenID_remove_dot_segments
  • Auth_OpenID_removeNamespaceAlias
  • Auth_OpenID_returnToMatches
  • Auth_OpenID_setNoMathSupport
  • Auth_OpenID_SHA1
  • Auth_OpenID_SHA256
  • Auth_OpenID_splitNonce
  • Auth_OpenID_supportsSReg
  • Auth_OpenID_urinorm
  • Auth_OpenID_verifyReturnTo
  • Auth_Yadis_array_scramble
  • Auth_Yadis_escapeForIRI
  • Auth_Yadis_getCanonicalID
  • Auth_Yadis_getDefaultProxy
  • Auth_Yadis_getEscapeRE
  • Auth_Yadis_getIPrivateChars
  • Auth_Yadis_getNSMap
  • Auth_Yadis_getServiceEndpoints
  • Auth_Yadis_getSupportedExtensions
  • Auth_Yadis_getUCSChars
  • Auth_Yadis_getXMLParser
  • Auth_Yadis_getXRDExpiration
  • Auth_Yadis_getXrefRE
  • Auth_Yadis_getXRIAuthorities
  • Auth_Yadis_identifierScheme
  • Auth_Yadis_iriToURI
  • Auth_Yadis_pct_escape_unicode
  • Auth_Yadis_providerIsAuthoritative
  • Auth_Yadis_rootAuthority
  • Auth_Yadis_setDefaultParser
  • Auth_Yadis_startswith
  • Auth_Yadis_toIRINormal
  • Auth_Yadis_toURINormal
  • Auth_Yadis_XRI
  • Auth_Yadis_XRIAppendArgs
  • authorSelector
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForPassword
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkNewsAccess
  • checkNewsCategoryPassword
  • checkObjectsThumb
  • checkPagePassword
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSelectedAlbum
  • checkSignature
  • cleanAlbum
  • cleanHTML
  • clearSitemapCache
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • countArticles
  • countCombiNews
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • cron_starter
  • currentRelativeURL
  • customOptions
  • dateDiff
  • datepickerJS
  • dateTimeConvert
  • db_affected_rows
  • db_close
  • db_collation
  • db_connect
  • db_count
  • db_create
  • db_create_table
  • db_error
  • db_fetch_assoc
  • db_fetch_row
  • db_free_result
  • db_getSQLmode
  • db_insert_id
  • db_LIKE_escape
  • db_list_fields
  • db_name
  • db_num_rows
  • db_permissions
  • db_quote
  • db_setSQLmode
  • db_show
  • db_software
  • db_table_update
  • db_truncate_table
  • debug404
  • debugLog
  • debugLogBacktrace
  • debugLogVar
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • detect_fetcher
  • detect_math
  • detect_query_corruption
  • detect_random
  • detect_stores
  • detect_xml
  • dircopy
  • displayError
  • doIncludes
  • elFinder_admin_tabs
  • elFinder_tinymce
  • enableExtension
  • escape
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • filter_extractReturnURL
  • filter_MatchesAnyOpenIDConsumerType
  • filter_MatchesAnyOpenIDType
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • genAlbumList
  • generateCaptcha
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateSitemapCacheFile
  • generateSitemapIndexCacheFile
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminThumb
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumId
  • getAlbumInherited
  • getAlbumLinkURL
  • getAlbumLocation
  • getAlbumPage
  • getAlbumPlace
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllArticleDates
  • getAllCategories
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllSubalbums
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getArticles
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsAlbumTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCategory
  • getCategoryID
  • getCategoryLink
  • getCategoryParentID
  • getCategorySortOrder
  • getCategoryTitle
  • getCheckboxState
  • getCodeblock
  • getCombiNews
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDate
  • getCommentDateTime
  • getCommentErrors
  • getCommentsAllowed
  • getCommentStored
  • getCommentTime
  • getConsumer
  • getContentShorten
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentNewsCategory
  • getCurrentNewsCategoryID
  • getCurrentNewsCategoryParentID
  • getCurrentNewsPage
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDefaultHeight
  • getDefaultSizedImage
  • getDefaultWidth
  • getDownloadLink
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFirstImageURL
  • getFullHeight
  • getFullImageURL
  • getFullNewsImage
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageEXIFData
  • getImageGeodata
  • getImageID
  • getImageLinkURL
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageSortOrder
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLanguageArray
  • getLanguageFlag
  • getLastImageURL
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLink
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsAlbumName
  • getNewsAlbumTitle
  • getNewsAlbumURL
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryPath
  • getNewsCategoryURL
  • getNewsContent
  • getNewsContentShorten
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsImageTags
  • getNewsIndexURL
  • getNewsLink
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsTitleLink
  • getNewsTitlePath
  • getNewsType
  • getNewsURL
  • getNewsVideoContent
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getNumSubalbums
  • getOpenIDURL
  • getOption
  • getOptionFromDB
  • getOptionList
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageLinkPath
  • getPageLinkURL
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPages
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentItems
  • getParentMenuItems
  • getParentNewsCategories
  • getParentPages
  • getPasswordProtectImage
  • getPHPFiles
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getRelatedItems
  • getRequestURI
  • getReturnTo
  • getRSSHeaderLink
  • getRSSLink
  • getScheme
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSitemapAlbumList
  • getSitemapAlbums
  • getSitemapGoogleImageVideoExtras
  • getSitemapGoogleLoopIndex
  • getSitemapImages
  • getSitemapIndexLinks
  • getSitemapZenpageNewsArticles
  • getSitemapZenpageNewsCategories
  • getSitemapZenpageNewsIndex
  • getSitemapZenpagePages
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getStore
  • getSubCategories
  • getSubtabs
  • getSuffix
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext_pl
  • gettext_th
  • getTheme
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalArticles
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getTrustRoot
  • getUnprotectedImageURL
  • getUrAlbum
  • getURL
  • getUserIP
  • getUserLocale
  • getVersion
  • getViewerImageSize
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpageHitcounter
  • getZenpageRSSHeaderLink
  • getZenpageRSSLink
  • getZenpageStatistic
  • googleVerifyHead
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextPage
  • hasPrevImage
  • hasPrevPage
  • hitcounter
  • html_decode
  • html_encode
  • html_encodeTagged
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • imageBlurGD
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • inNewsCategory
  • inProtectedNewsCategory
  • installSignature
  • instrument
  • inSubNewsCategoryOf
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_GalleryNewsType
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_NewsType
  • is_Pages
  • is_valid_email_zp
  • is_valid_image
  • is_valid_other_type
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isLandscape
  • isMyAlbum
  • isMyNews
  • isMyPage
  • isolate
  • isProtectedAlbum
  • isProtectedNewsCategory
  • isProtectedPage
  • isSubNewsCategoryOf
  • isValidURL
  • jQueryUpload_head
  • jQueryUpload_headers
  • jQueryUploadHandler
  • jQueryUploadHandler_admin_tabs
  • js_encode
  • json_decode
  • json_encode
  • kses
  • kses_array_lc
  • kses_attr
  • kses_bad_protocol
  • kses_bad_protocol_once
  • kses_bad_protocol_once2
  • kses_check_attr_val
  • kses_decode_entities
  • kses_hair
  • kses_hook
  • kses_html_error
  • kses_js_entities
  • kses_no_null
  • kses_normalize_entities
  • kses_normalize_entities2
  • kses_split
  • kses_split2
  • kses_stripslashes
  • kses_version
  • ksesProcess
  • layoutSelector
  • layoutSelector_album
  • listDBUses
  • listDirectoryFiles
  • listUses
  • load_zenpage_news
  • load_zenpage_pages
  • loadLocalOptions
  • log_message
  • lookupSortKey
  • macro_admin_tabs
  • macroList_show
  • makeAlbumCurrent
  • makeImageCurrent
  • makeSpecialImageName
  • markRelease_button
  • mb_strlen
  • mb_strpos
  • mb_strrpos
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • menu_admin_toolbox_global
  • menu_tabs
  • minDiff
  • mkdir_recursive
  • my_truncate_string
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext_pl
  • ngettext_th
  • normalizeColumns
  • omsAdditions
  • openedForComments
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • passAlbums
  • passImages
  • pathurlencode
  • PclZipUtilCopyBlock
  • PclZipUtilOptionText
  • PclZipUtilPathInclusion
  • PclZipUtilPathReduction
  • PclZipUtilRename
  • PclZipUtilTranslateWinPath
  • PHPMailerAutoload
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminToolbox
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLink
  • printAlbumLocation
  • printAlbumMap
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumPlace
  • printAlbumRating
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAlbumZip
  • printAllDates
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBulkActions
  • printCaptcha
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxHeight
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printDownloadLink
  • printDownloadLinkAlbumZip
  • printdownloadList
  • printDownloadURL
  • printEditable
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesLink
  • printFavoritesURL
  • printField
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageDiv
  • printImageEXIFData
  • printImageID
  • printImageLink
  • printImageMap
  • printImageMetadata
  • printImageRating
  • printImageSortOrder
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjCarouselThumbNav
  • printjPlayerPlaylist
  • printLanguageSelector
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLatestZenpageComments
  • printLink
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsImageTags
  • printNewsIndexURL
  • printNewsLink
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsReadMoreLink
  • printNewsStatistic
  • printNewsTitle
  • printNewsTitleLink
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageLink
  • printNextPageURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageLinkURL
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printParentPagesBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPreloadScript
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageLink
  • printPrevPageURL
  • printPublished
  • printPublishIconLink
  • printRandomImages
  • printRating
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printSearchBreadcrumb
  • printSearchForm
  • printSiteHomeURL
  • printSizedImageLink
  • printSizedImageURL
  • printSlideShow
  • printSlideShowJS
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSizeImage
  • printUserSizeSelector
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePagesSelector
  • printZenpageRSSHeaderLink
  • printZenpageRSSLink
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExpired
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • publishItem
  • purgeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • recaptcha_check_answer
  • recaptcha_get_html
  • recaptcha_get_signup_url
  • recaptcha_mailhide_html
  • recaptcha_mailhide_url
  • reconfigureAction
  • reconfigureCS
  • reconfigurePage
  • recordMissing
  • rem_context
  • removeParentAlbumNames
  • resetCurrentAlbum
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewrite_path_zenpage
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • run
  • safe_fnmatch
  • safe_glob
  • sanitize
  • sanitize_numeric
  • sanitize_path
  • sanitize_script
  • sanitize_string
  • sanitizeRedirect
  • save_context
  • saveLayoutSelection
  • saveZenphotoLayoutSelection
  • search_quote
  • secureServer
  • seo_cleanup_button
  • seoFriendly
  • seoFriendlyJS
  • set_context
  • setAlbumCustomData
  • setAlbumSubtabs
  • setImageCustomData
  • setMainDomain
  • setOption
  • setOptionDefault
  • setPluginDomain
  • setThemeColumns
  • setThemeDomain
  • setThemeOption
  • setThemeOptionDefault
  • setupAllowedMaps
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • showOrNotShowField
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • sitemap_echonl
  • sitemap_getChangefreq
  • sitemap_getDateformat
  • sitemap_getDBLimit
  • sitemap_getISO8601Date
  • skipScheduledPublishing
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • themeIsEditable
  • themeSetup
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • wordpress_import_button
  • wp_prefix
  • wp_query_full_array
  • wpimport_TryAgainError
  • XSRFdefender
  • XSRFToken
  • zenJavascript
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageHitcounter
  • zenpageJSCSS
  • zenpageOpenedForComments
  • zenpagePublish
  • zenphoto_PHPMailer
  • zenphoto_sendmail
  • zenPhotoTheme
  • zp_apply_filter
  • zp_clearCookie
  • zp_colorAllocate
  • zp_cookieEncode
  • zp_copyCanvas
  • zp_createImage
  • zp_drawRectangle
  • zp_error
  • zp_filter_slot
  • zp_filter_unique_id
  • zp_getCookie
  • zp_getFonts
  • zp_graphicsLibInfo
  • zp_handle_password
  • zp_handle_password_single
  • zp_has_filter
  • zp_image_types
  • zp_imageCanRotate
  • zp_imageColorTransparent
  • zp_imageDims
  • zp_imageFill
  • zp_imageFontHeight
  • zp_imageFontWidth
  • zp_imageFromString
  • zp_imageGet
  • zp_imageGray
  • zp_imageHeight
  • zp_imageIPTC
  • zp_imageKill
  • zp_imageLoadFont
  • zp_imageMerge
  • zp_imageOutput
  • zp_imageResizeAlpha
  • zp_imageUnsharpMask
  • zp_imageWidth
  • zp_load_album
  • zp_load_gallery
  • zp_load_image
  • zp_load_page
  • zp_load_request
  • zp_load_search
  • zp_loggedin
  • zp_mail
  • zp_register_filter
  • zp_remove_filter
  • zp_resampleImage
  • zp_rotateImage
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
   1: <?php
   2: /**
   3:  * zenpage admin functions
   4:  *
   5:  * @author Malte Müller (acrylian), Stephen Billard (sbillard)
   6:  * @package plugins
   7:  * @subpackage zenpage
   8:  */
   9: global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
  10: Zenpage::expiry();
  11: 
  12: /**
  13:  * Retrieves posted expiry date and checks it against the current date/time
  14:  * Returns the posted date if it is in the future
  15:  * Returns NULL if the date is past
  16:  *
  17:  * @return string
  18:  */
  19: function getExpiryDatePost() {
  20:     $expiredate = sanitize($_POST['expiredate']);
  21:     if ($expiredate > date(date('Y-m-d H:i:s')))
  22:         return $expiredate;
  23:     return NULL;
  24: }
  25: 
  26: /**
  27:  * processes the taglist save
  28:  *
  29:  * @param object $object the object on which the save happened
  30:  */
  31: function processTags($object) {
  32:     $tagsprefix = 'tags_';
  33:     $tags = array();
  34:     $l = strlen($tagsprefix);
  35:     foreach ($_POST as $key => $value) {
  36:         $key = postIndexDecode($key);
  37:         if (substr($key, 0, $l) == $tagsprefix) {
  38:             if ($value) {
  39:                 $tags[] = substr($key, $l);
  40:             }
  41:         }
  42:     }
  43:     $tags = array_unique($tags);
  44:     $object->setTags(sanitize($tags, 3));
  45: }
  46: 
  47: /* * ************************
  48:   /* page functions
  49:  * ************************* */
  50: 
  51: /**
  52:  * Updates or adds a page and returns the object of that page
  53:  *
  54:  * @param array $reports report display
  55:  * @param bool $newpage true if it is a new page
  56:  *
  57:  * @return object
  58:  */
  59: function updatePage(&$reports, $newpage = false) {
  60:     $title = process_language_string_save("title", 2);
  61:     $author = sanitize($_POST['author']);
  62:     $content = zpFunctions::updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
  63:     $extracontent = zpFunctions::updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
  64:     $custom = process_language_string_save("custom_data", 1);
  65:     $show = getcheckboxState('show');
  66:     $date = sanitize($_POST['date']);
  67:     $lastchange = sanitize($_POST['lastchange']);
  68:     $lastchangeauthor = sanitize($_POST['lastchangeauthor']);
  69:     $expiredate = getExpiryDatePost();
  70:     $commentson = getcheckboxState('commentson');
  71:     $permalink = getcheckboxState('permalink');
  72:     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
  73:         $codeblock = processCodeblockSave(0);
  74:     }
  75:     $locked = getcheckboxState('locked');
  76:     $date = sanitize($_POST['date']);
  77:     if ($newpage) {
  78:         $titlelink = seoFriendly(get_language_string($title));
  79:         if (empty($titlelink)) {
  80:             $titlelink = seoFriendly($date);
  81:         }
  82:         $sql = 'SELECT `id` FROM ' . prefix('pages') . ' WHERE `titlelink`=' . db_quote($titlelink);
  83:         $rslt = query_single_row($sql, false);
  84:         if ($rslt) {
  85:             //already exists
  86:             $time = explode(' ', microtime());
  87:             $titlelink = $titlelink . '_' . ($time[1] + $time[0]);
  88:             $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate page title') . '</p>';
  89:         }
  90:         $oldtitlelink = $titlelink;
  91:     } else {
  92:         $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old']);
  93:     }
  94:     if (getcheckboxState('edittitlelink')) {
  95:         $titlelink = sanitize($_POST['titlelink'], 3);
  96:         if (empty($titlelink)) {
  97:             $titlelink = seoFriendly(get_language_string($title));
  98:             if (empty($titlelink)) {
  99:                 $titlelink = seoFriendly($date);
 100:             }
 101:         }
 102:     } else {
 103:         if (!$permalink) { //   allow the link to change
 104:             $link = seoFriendly(get_language_string($title));
 105:             if (!empty($link)) {
 106:                 $titlelink = $link;
 107:             }
 108:         }
 109:     }
 110:     $id = sanitize($_POST['id']);
 111:     $rslt = true;
 112:     if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
 113:         $rslt = query('UPDATE ' . prefix('pages') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
 114:         if (!$rslt) {
 115:             $titlelink = $oldtitlelink; // force old link so data gets saved
 116:         } else {
 117:             SearchEngine::clearSearchCache();
 118:         }
 119:     }
 120:     // update page
 121:     $page = new ZenpagePage($titlelink, true);
 122: 
 123:     $notice = processCredentials($page);
 124:     $page->setTitle($title);
 125:     $page->setContent($content);
 126:     $page->setExtracontent($extracontent);
 127:     $page->setCustomData(zp_apply_filter('save_page_custom_data', $custom, $page));
 128:     $page->setShow($show);
 129:     $page->setDateTime($date);
 130:     $page->setCommentsAllowed($commentson);
 131:     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
 132:         $page->setCodeblock($codeblock);
 133:     }
 134:     $page->setAuthor($author);
 135:     $page->setLastchange($lastchange);
 136:     $page->setLastchangeauthor($lastchangeauthor);
 137:     $page->setPermalink($permalink);
 138:     $page->setLocked($locked);
 139:     $page->setExpiredate($expiredate);
 140:     if (getcheckboxState('resethitcounter')) {
 141:         $page->set('hitcounter', 0);
 142:     }
 143:     if (getcheckboxState('reset_rating')) {
 144:         $page->set('total_value', 0);
 145:         $page->set('total_votes', 0);
 146:         $page->set('used_ips', 0);
 147:     }
 148:     processTags($page);
 149:     if ($newpage) {
 150:         $msg = zp_apply_filter('new_page', '', $page);
 151:         if (empty($title)) {
 152:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Page <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
 153:         } else if ($notice == '?mismatch=user') {
 154:             $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
 155:         } else if ($notice) {
 156:             $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
 157:         } else {
 158:             $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> added"), $titlelink) . '</p>';
 159:         }
 160:     } else {
 161:         $msg = zp_apply_filter('update_page', '', $page, $oldtitlelink);
 162:         if (!$rslt) {
 163:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A page with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
 164:         } else if (empty($title)) {
 165:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Page <em>%s</em> updated but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
 166:         } else if ($notice == '?mismatch=user') {
 167:             $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
 168:         } else if ($notice) {
 169:             echo "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
 170:         } else {
 171:             $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> updated"), $titlelink) . '</p>';
 172:         }
 173:     }
 174:     $page->save();
 175:     if ($msg) {
 176:         $reports[] = $msg;
 177:     }
 178:     return $page;
 179: }
 180: 
 181: /**
 182:  * Deletes a page (and also if existing its subpages) from the database
 183:  *
 184:  */
 185: function deletePage($titlelink) {
 186:     if (is_object($titlelink)) {
 187:         $obj = $titlelink;
 188:     } else {
 189:         $obj = new ZenpagePage($titlelink);
 190:     }
 191:     $result = $obj->remove();
 192:     if ($result) {
 193:         if (is_object($titlelink)) {
 194:             header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-pages.php?deleted');
 195:             exitZP();
 196:         }
 197:         SearchEngine::clearSearchCache();
 198:         return "<p class='messagebox fade-message'>" . gettext("Page successfully deleted!") . "</p>";
 199:     }
 200:     return "<p class='errorbox fade-message'>" . gettext("Page delete failed!") . "</p>";
 201: }
 202: 
 203: /**
 204:  * Prints the table part of a single page item for the sortable pages list
 205:  *
 206:  * @param object $page The array containing the single page
 207:  * @param bool $flag set to true to flag the element as having a problem with nesting level
 208:  */
 209: function printPagesListTable($page, $flag) {
 210:     if ($flag) {
 211:         $img = '../../images/drag_handle_flag.png';
 212:     } else {
 213:         $img = '../../images/drag_handle.png';
 214:     }
 215:     ?>
 216:     <div class='page-list_row'>
 217:         <div class="page-list_title">
 218:             <?php
 219:             if (checkIfLockedPage($page)) {
 220:                 echo "<a href='admin-edit.php?page&amp;titlelink=" . urlencode($page->getTitlelink()) . "'> ";
 221:                 checkForEmptyTitle($page->getTitle(), "page");
 222:                 echo "</a>" . checkHitcounterDisplay($page->getHitcounter());
 223:             } else {
 224:                 checkForEmptyTitle($page->getTitle(), "page");
 225:                 checkHitcounterDisplay($page->getShow());
 226:             }
 227:             ?>
 228:         </div>
 229:         <div class="page-list_extra">
 230:             <span>
 231:                 <?php echo html_encode($page->getAuthor()); ?>
 232:             </span>
 233:         </div>
 234:         <div class="page-list_extra">
 235:             <?php printPublished($page); ?>
 236:         </div>
 237:         <div class="page-list_extra">
 238:             <?php printExpired($page); ?>
 239:         </div>
 240:         <div class="page-list_iconwrapper">
 241:             <div class="page-list_icon">
 242:                 <?php
 243:                 if ($page->getPassword()) {
 244:                     echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
 245:                 }
 246:                 ?>
 247:             </div>
 248: 
 249:             <?php if (checkIfLockedPage($page)) { ?>
 250:                 <div class="page-list_icon">
 251:                     <?php printPublishIconLink($page, "page"); ?>
 252:                 </div>
 253:                 <div class="page-list_icon">
 254:                     <?php
 255:                     if ($page->getCommentsAllowed()) {
 256:                         ?>
 257:                         <a href="?commentson=0&amp;titlelink=<?php echo html_encode($page->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Disable comments'); ?>">
 258:                             <img src="../../images/comments-on.png" alt="" title="<?php echo gettext("Comments on"); ?>" style="border: 0px;"/>
 259:                         </a>
 260:                         <?php
 261:                     } else {
 262:                         ?>
 263:                         <a href="?commentson=1&amp;titlelink=<?php echo html_encode($page->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Enable comments'); ?>">
 264:                             <img src="../../images/comments-off.png" alt="" title="<?php echo gettext("Comments off"); ?>" style="border: 0px;"/>
 265:                         </a>
 266:                         <?php
 267:                     }
 268:                     ?>
 269:                 </div>
 270:             <?php } else { ?>
 271:                 <div class="page-list_icon">
 272:                     <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
 273:                 </div>
 274:                 <div class="page-list_icon">
 275:                     <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
 276:                 </div>
 277:             <?php } ?>
 278: 
 279:             <div class="page-list_icon">
 280:                 <a href="../../../index.php?p=pages&amp;title=<?php echo js_encode($page->getTitlelink()); ?>" title="<?php echo gettext("View page"); ?>">
 281:                     <img src="images/view.png" alt="" title="<?php echo gettext("view"); ?>" />
 282:                 </a>
 283:             </div>
 284: 
 285:             <?php
 286:             if (checkIfLockedPage($page)) {
 287:                 if (extensionEnabled('hitcounter')) {
 288:                     ?>
 289:                     <div class="page-list_icon">
 290:                         <a href="?hitcounter=1&amp;titlelink=<?php echo html_encode($page->getTitlelink()); ?>&amp;add&amp;XSRFToken=<?php echo getXSRFToken('hitcounter') ?>" title="<?php echo gettext("Reset hitcounter"); ?>">
 291:                             <img src="../../images/reset.png" alt="" title="<?php echo gettext("Reset hitcounter"); ?>" /></a>
 292:                     </div>
 293:                     <?php
 294:                 }
 295:                 ?>
 296:                 <div class="page-list_icon">
 297:                     <a href="javascript:confirmDelete('admin-pages.php?delete=<?php echo $page->getTitlelink(); ?>&amp;add&amp;XSRFToken=<?php echo getXSRFToken('delete') ?>',deletePage)" title="<?php echo gettext("Delete page"); ?>">
 298:                         <img src="../../images/fail.png" alt="" title="<?php echo gettext("delete"); ?>" /></a>
 299:                 </div>
 300:                 <div class="page-list_icon">
 301:                     <input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $page->getTitlelink(); ?>" onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
 302:                 </div>
 303:             <?php } else { ?>
 304:                 <div class="page-list_icon">
 305:                     <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
 306:                 </div>
 307:                 <div class="page-list_icon">
 308:                     <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
 309:                 </div>
 310:                 <div class="page-list_icon">
 311:                     <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
 312:                 </div>
 313:             <?php } ?>
 314:         </div><!--  icon wrapper end -->
 315:     </div>
 316:     <?php
 317: }
 318: 
 319: /* * ************************
 320:   /* news article functions
 321:  * ************************* */
 322: 
 323: /**
 324:  * Updates or adds a news article and returns the object of that article
 325:  *
 326:  * @param array $reports display
 327:  * @param bool $newarticle true if a new article
 328:  *
 329:  * @return object
 330:  */
 331: function updateArticle(&$reports, $newarticle = false) {
 332:     $date = date('Y-m-d_H-i-s');
 333:     $title = process_language_string_save("title", 2);
 334:     $author = sanitize($_POST['author']);
 335:     $content = zpFunctions::updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
 336:     $extracontent = zpFunctions::updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
 337:     $custom = process_language_string_save("custom_data", 1);
 338:     $show = getcheckboxState('show');
 339:     $date = sanitize($_POST['date']);
 340:     $expiredate = getExpiryDatePost();
 341:     $permalink = getcheckboxState('permalink');
 342:     $lastchange = sanitize($_POST['lastchange']);
 343:     $lastchangeauthor = sanitize($_POST['lastchangeauthor']);
 344:     $commentson = getcheckboxState('commentson');
 345:     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
 346:         $codeblock = processCodeblockSave(0);
 347:     }
 348:     $locked = getcheckboxState('locked');
 349:     if ($newarticle) {
 350:         $titlelink = seoFriendly(get_language_string($title));
 351:         if (empty($titlelink)) {
 352:             $titlelink = seoFriendly($date);
 353:         }
 354:         $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
 355:         $rslt = query_single_row($sql, false);
 356:         if ($rslt) {
 357:             //already exists
 358:             $time = explode(' ', microtime());
 359:             $titlelink = $titlelink . '_' . ($time[1] + $time[0]);
 360:             $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate article title') . '</p>';
 361:         }
 362:         $oldtitlelink = $titlelink;
 363:         $id = 0;
 364:     } else {
 365:         $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
 366:         $id = sanitize($_POST['id']);
 367:     }
 368: 
 369:     if (getcheckboxState('edittitlelink')) {
 370:         $titlelink = sanitize($_POST['titlelink'], 3);
 371:         if (empty($titlelink)) {
 372:             $titlelink = seoFriendly(get_language_string($title));
 373:             if (empty($titlelink)) {
 374:                 $titlelink = seoFriendly($date);
 375:             }
 376:         }
 377:     } else {
 378:         if (!$permalink) { //   allow the title link to change.
 379:             $link = seoFriendly(get_language_string($title));
 380:             if (!empty($link)) {
 381:                 $titlelink = $link;
 382:             }
 383:         }
 384:     }
 385: 
 386:     $rslt = true;
 387:     if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
 388:         $rslt = query('UPDATE ' . prefix('news') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
 389:         if (!$rslt) {
 390:             $titlelink = $oldtitlelink; // force old link so data gets saved
 391:         } else {
 392:             SearchEngine::clearSearchCache();
 393:         }
 394:     }
 395:     // update article
 396:     $article = new ZenpageNews($titlelink, true);
 397:     $article->setTitle($title);
 398:     $article->setContent($content);
 399:     $article->setExtracontent($extracontent);
 400:     $article->setCustomData(zp_apply_filter('save_article_custom_data', $custom, $article));
 401:     $article->setShow($show);
 402:     $article->setDateTime($date);
 403:     $article->setCommentsAllowed($commentson);
 404:     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
 405:         $article->setCodeblock($codeblock);
 406:     }
 407:     $article->setAuthor($author);
 408:     $article->setLastchange($lastchange);
 409:     $article->setLastchangeauthor($lastchangeauthor);
 410:     $article->setPermalink($permalink);
 411:     $article->setLocked($locked);
 412:     $article->setExpiredate($expiredate);
 413:     $article->setSticky(sanitize_numeric($_POST['sticky']));
 414:     if (getcheckboxState('resethitcounter')) {
 415:         $article->set('hitcounter', 0);
 416:     }
 417:     if (getcheckboxState('reset_rating')) {
 418:         $article->set('total_value', 0);
 419:         $article->set('total_votes', 0);
 420:         $article->set('used_ips', 0);
 421:     }
 422:     $article->setTruncation(getcheckboxState('truncation'));
 423:     processTags($article);
 424:     $categories = array();
 425:     $result2 = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
 426:     foreach ($result2 as $cat) {
 427:         if (isset($_POST["cat" . $cat['id']])) {
 428:             $categories[] = $cat['titlelink'];
 429:         }
 430:     }
 431:     $article->setCategories($categories);
 432:     if ($newarticle) {
 433:         $msg = zp_apply_filter('new_article', '', $article);
 434:         if (empty($title)) {
 435:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
 436:         } else {
 437:             $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> added"), $titlelink) . '</p>';
 438:         }
 439:     } else {
 440:         $msg = zp_apply_filter('update_article', '', $article, $oldtitlelink);
 441:         if (!$rslt) {
 442:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("An article with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
 443:         } else if (empty($title)) {
 444:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
 445:         } else {
 446:             $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated"), $titlelink) . '</p>';
 447:         }
 448:     }
 449:     $article->save();
 450: 
 451:     if ($msg) {
 452:         $reports[] = $msg;
 453:     }
 454:     return $article;
 455: }
 456: 
 457: /**
 458:  * Deletes an news article from the database
 459:  *
 460:  */
 461: function deleteArticle($titlelink) {
 462:     if (is_object($titlelink)) {
 463:         $obj = $titlelink;
 464:     } else {
 465:         $obj = new ZenpageNews($titlelink);
 466:     }
 467:     $result = $obj->remove();
 468:     if ($result) {
 469:         if (is_object($titlelink)) {
 470:             header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-news-articles.php?deleted');
 471:             exitZP();
 472:         }
 473:         SearchEngine::clearSearchCache();
 474:         return "<p class='messagebox fade-message'>" . gettext("Article successfully deleted!") . "</p>";
 475:     }
 476:     return "<p class='errorbox fade-message'>" . gettext("Article delete failed!") . "</p>";
 477: }
 478: 
 479: /**
 480:  * Print the categories of a news article for the news articles list
 481:  *
 482:  * @param obj $obj object of the news article
 483:  */
 484: function printArticleCategories($obj) {
 485:   $cat = $obj->getCategories();
 486:   $number = 0;
 487:   foreach ($cat as $cats) {
 488:     $number++;
 489:     if ($number != 1) {
 490:       echo ", ";
 491:     }
 492:     echo get_language_string($cats['title']);
 493:   }
 494: }
 495: 
 496: /**
 497:  * Print the categories of a news article for the news articles list
 498:  *
 499:  * @param obj $obj object of the news article
 500:  */
 501: function printPageArticleTags($obj) {
 502:     $tags = $obj->getTags();
 503:     $number = 0;
 504:     foreach ($tags as $tag) {
 505:         $number++;
 506:         if ($number != 1) {
 507:             echo ", ";
 508:         }
 509:         echo get_language_string($tag);
 510:     }
 511: }
 512: 
 513: /**
 514:  * Prints the checkboxes to select and/or show the category of an news article on the edit or add page
 515:  *
 516:  * @param int $id ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added.
 517:  * @param string $option "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned.
 518:  */
 519: function printCategorySelection($id = '', $option = '') {
 520:     global $_zp_zenpage;
 521: 
 522:     $selected = '';
 523:     echo "<ul class='zenpagechecklist'>\n";
 524:     $all_cats = $_zp_zenpage->getAllCategories(false);
 525:     foreach ($all_cats as $cats) {
 526:         $catobj = new ZenpageCategory($cats['titlelink']);
 527:         if ($option != "all") {
 528:             $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $id . " AND cat_id = " . $catobj->getID());
 529:             if ($cat2news['cat_id'] != "") {
 530:                 $selected = "checked ='checked'";
 531:             }
 532:         }
 533:         $catname = $catobj->getTitle();
 534:         $catlink = $catobj->getTitlelink();
 535:         if ($catobj->getPassword()) {
 536:             $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
 537:         } else {
 538:             $protected = '';
 539:         }
 540:         $catid = $catobj->getID();
 541:         echo "<li class=\"hasimage\" ><label for='cat" . $catid . "'><input name='cat" . $catid . "' id='cat" . $catid . "' type='checkbox' value='" . $catid . "' " . $selected . " />" . $catname . " " . $protected . "</label></li>\n";
 542:     }
 543:     echo "</ul>\n";
 544: }
 545: 
 546: /**
 547:  * Prints the dropdown menu for the date archive selector for the news articles list
 548:  *
 549:  */
 550: function printArticleDatesDropdown() {
 551:     global $_zp_zenpage, $subpage;
 552:     $datecount = $_zp_zenpage->getAllArticleDates();
 553:     $lastyear = "";
 554:     $nr = "";
 555:     $option = getNewsAdminOption(array('category' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1));
 556:     if (!isset($_GET['date'])) {
 557:         $selected = 'selected="selected"';
 558:     } else {
 559:         $selected = "";
 560:     }
 561:     ?>
 562:     <form name="AutoListBox1" id="articledatesdropdown" style="float:left; margin-left: 10px;" action="#" >
 563:         <select name="ListBoxURL" size="1" onchange="gotoLink(this.form)">
 564:             <?php
 565:             echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('' => ''), $option)) . "'>" . gettext("View all months") . "</option>";
 566:             while (list($key, $val) = each($datecount)) {
 567:                 $nr++;
 568:                 if ($key == '0000-00-01') {
 569:                     $year = "no date";
 570:                     $month = "";
 571:                 } else {
 572:                     $dt = strftime('%Y-%B', strtotime($key));
 573:                     $year = substr($dt, 0, 4);
 574:                     $month = substr($dt, 5);
 575:                 }
 576:                 if (isset($_GET['category'])) {
 577:                     $catlink = "&amp;category=" . sanitize($_GET['category']);
 578:                 } else {
 579:                     $catlink = "";
 580:                 }
 581:                 $check = $month . "-" . $year;
 582:                 if (isset($_GET['date']) AND $_GET['date'] == substr($key, 0, 7)) {
 583:                     $selected = "selected='selected'";
 584:                 } else {
 585:                     $selected = "";
 586:                 }
 587:                 echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('date' => substr($key, 0, 7)), $option)) . "'>$month $year ($val)</option>\n";
 588:             }
 589:             ?>
 590:         </select>
 591:         <script type="text/javascript" >
 592:             // <!-- <![CDATA[
 593:             function gotoLink(form) {
 594:                 var OptionIndex = form.ListBoxURL.selectedIndex;
 595:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
 596:             }
 597:             // ]]> -->
 598:         </script>
 599:     </form>
 600:     <?php
 601: }
 602: 
 603: /**
 604:  *
 605:  * Compiles an option parameter list
 606:  * @param array $test array of parameter=>type elements. type=0:string type=1:numeric
 607:  * @return array
 608:  */
 609: function getNewsAdminOption($test) {
 610:     $list = array();
 611:     foreach ($test as $item => $type) {
 612:         if (isset($_GET[$item])) {
 613:             if ($type) {
 614:                 $list[$item] = (int) sanitize_numeric($_GET[$item]);
 615:             } else {
 616:                 $list[$item] = sanitize($_GET[$item]);
 617:             }
 618:         }
 619:     }
 620:     return $list;
 621: }
 622: 
 623: /**
 624:  * Creates the admin paths for news articles if you use the dropdowns on the admin news article list together
 625:  *
 626:  * @param array $list an parameter array of item=>value for instance, the result of getNewsAdminOption()
 627:  * @return string
 628:  */
 629: function getNewsAdminOptionPath($list) {
 630:     $optionpath = '';
 631:     $char = '?';
 632:     foreach ($list as $p => $q) {
 633:         if ($q) {
 634:             $optionpath .= $char . $p . '=' . $q;
 635:         } else {
 636:             $optionpath .= $char . $p;
 637:         }
 638:         $char = '&amp;';
 639:     }
 640:     return $optionpath;
 641: }
 642: 
 643: /**
 644:  * Prints the dropdown menu for the published/un-publishd selector for the news articles list
 645:  *
 646:  */
 647: function printUnpublishedDropdown() {
 648:     global $_zp_zenpage;
 649:     ?>
 650:     <form name="AutoListBox3" id="unpublisheddropdown" style="float: left; margin-left: 10px;"  action="#">
 651:         <select name="ListBoxURL" size="1"  onchange="gotoLink(this.form)">
 652:             <?php
 653:             $all = "";
 654:             $published = "";
 655:             $unpublished = "";
 656:             $sticky = '';
 657:             if (isset($_GET['published'])) {
 658:                 switch ($_GET['published']) {
 659:                     case "no":
 660:                         $unpublished = "selected='selected'";
 661:                         break;
 662:                     case "yes":
 663:                         $published = "selected='selected'";
 664:                         break;
 665:                     case 'sticky':
 666:                         $sticky = "selected='selected'";
 667:                         break;
 668:                 }
 669:             } else {
 670:                 $all = "selected='selected'";
 671:             }
 672:             $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'sortorder' => 0, 'articles_page' => 1));
 673:             echo "<option $all value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All articles") . "</option>\n";
 674:             echo "<option $published value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'yes'), $option)) . "'>" . gettext("Published") . "</option>\n";
 675:             echo "<option $unpublished value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'no'), $option)) . "'>" . gettext("Un-published") . "</option>\n";
 676:             echo "<option $sticky value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'sticky'), $option)) . "'>" . gettext("Sticky") . "</option>\n";
 677:             ?>
 678:         </select>
 679:         <script type="text/javascript">
 680:             // <!-- <![CDATA[
 681:             function gotoLink(form) {
 682:                 var OptionIndex = form.ListBoxURL.selectedIndex;
 683:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
 684:             }
 685:             // ]]> -->
 686:         </script>
 687:     </form>
 688:     <?php
 689: }
 690: 
 691: /**
 692:  * Prints the dropdown menu for the sortorder selector for the news articles list
 693:  *
 694:  */
 695: function printSortOrderDropdown() {
 696:     global $_zp_zenpage;
 697:     ?>
 698:     <form name="AutoListBox4" id="sortorderdropdown" style="float: left; margin-left: 10px;"    action="#">
 699:         <select name="ListBoxURL" size="1"  onchange="gotoLink(this.form)">
 700:             <?php
 701:             $orderdate_desc = '';
 702:             $orderdate_asc = '';
 703:             $ordertitle_desc = '';
 704:             $ordertitle_asc = '';
 705:             if (isset($_GET['sortorder'])) {
 706:                 switch ($_GET['sortorder']) {
 707:                     case "date-desc":
 708:                         $orderdate_desc = "selected='selected'";
 709:                         break;
 710:                     case "date-asc":
 711:                         $orderdate_asc = "selected='selected'";
 712:                         break;
 713:                     case "title-desc":
 714:                         $ordertitle_desc = "selected='selected'";
 715:                         break;
 716:                     case "title-asc":
 717:                         $ordertitle_asc = "selected='selected'";
 718:                         break;
 719:                 }
 720:             } else {
 721:                 $orderdate_desc = "selected='selected'";
 722:             }
 723:             $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'articles_page' => 1));
 724:             echo "<option $orderdate_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-desc'), $option)) . "'>" . gettext("Order by date descending") . "</option>\n";
 725:             echo "<option $orderdate_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-asc'), $option)) . "'>" . gettext("Order by date ascending") . "</option>\n";
 726:             echo "<option $ordertitle_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-desc'), $option)) . "'>" . gettext("Order by title descending") . "</option>\n";
 727:             echo "<option $ordertitle_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-asc'), $option)) . "'>" . gettext("Order by title ascending") . "</option>\n";
 728:             ?>
 729:         </select>
 730:         <script type="text/javascript">
 731:             // <!-- <![CDATA[
 732:             function gotoLink(form) {
 733:                 var OptionIndex = form.ListBoxURL.selectedIndex;
 734:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
 735:             }
 736:             // ]]> -->
 737:         </script>
 738:     </form>
 739:     <?php
 740: }
 741: 
 742: /**
 743:  * Prints the dropdown menu for the category selector for the news articles list
 744:  *
 745:  */
 746: function printCategoryDropdown() {
 747:     global $_zp_zenpage;
 748:     $result = $_zp_zenpage->getAllCategories(false);
 749:     if (isset($_GET['date'])) {
 750:         $datelink = "&amp;date=" . sanitize($_GET['date']);
 751:         $datelinkall = "?date=" . sanitize($_GET['date']);
 752:     } else {
 753:         $datelink = "";
 754:         $datelinkall = "";
 755:     }
 756: 
 757:     if (isset($_GET['category'])) {
 758:         $selected = '';
 759:         $category = sanitize($_GET['category']);
 760:     } else {
 761:         $selected = "selected='selected'";
 762:         $category = "";
 763:     }
 764:     ?>
 765:     <form name ="AutoListBox2" id="categorydropdown" style="float:left" action="#" >
 766:         <select name="ListBoxURL" size="1" onchange="gotoLink(this.form)">
 767:             <?php
 768:             $option = getNewsAdminOption(array('date' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1));
 769:             echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All categories") . "</option>\n";
 770: 
 771:             foreach ($result as $cat) {
 772:                 $catobj = new ZenpageCategory($cat['titlelink']);
 773:                 // check if there are articles in this category. If not don't list the category.
 774:                 $count = count($catobj->getArticles(0, 'all'));
 775:                 $count = " (" . $count . ")";
 776:                 if ($category == $cat['titlelink']) {
 777:                     $selected = "selected='selected'";
 778:                 } else {
 779:                     $selected = "";
 780:                 }
 781:                 //This is much easier than hacking the nested list function to work with this
 782:                 $getparents = $catobj->getParents();
 783:                 $levelmark = '';
 784:                 foreach ($getparents as $parent) {
 785:                     $levelmark .= '» ';
 786:                 }
 787:                 $title = $catobj->getTitle();
 788:                 if (empty($title)) {
 789:                     $title = '*' . $catobj->getTitlelink() . '*';
 790:                 }
 791:                 if ($count != " (0)") {
 792:                     echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('category' => $catobj->getTitlelink()), $option)) . "'>" . $levelmark . $title . $count . "</option>\n";
 793:                 }
 794:             }
 795:             ?>
 796:         </select>
 797:         <script type="text/javascript" >
 798:             // <!-- <![CDATA[
 799:             function gotoLink(form) {
 800:                 var OptionIndex = form.ListBoxURL.selectedIndex;
 801:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
 802:             }
 803:             // ]]> -->
 804:         </script>
 805:     </form>
 806:     <?php
 807: }
 808: 
 809: /**
 810:  * Prints the dropdown menu for the articles per page selector for the news articles list
 811:  *
 812:  */
 813: function printArticlesPerPageDropdown() {
 814:     global $_zp_zenpage, $subpage, $articles_page;
 815:     ?>
 816:     <form name="AutoListBox5" id="articlesperpagedropdown" method="POST" style="float: left; margin-left: 10px;"    action="#">
 817:         <select name="ListBoxURL" size="1"  onchange="gotoLink(this.form)">
 818:             <?php
 819:             $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'sortorder' => 0));
 820:             $list = array_unique(array(15, 30, 60, max(1, getOption('articles_per_page'))));
 821:             sort($list);
 822:             foreach ($list as $count) {
 823:                 ?>
 824:                 <option <?php if ($articles_page == $count) echo 'selected="selected"'; ?> value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('articles_page' => $count, 'subpage' => (int) ($subpage * $articles_page / $count)), $option)); ?>"><?php printf(gettext('%u per page'), $count); ?></option>
 825:                 <?php
 826:             }
 827:             ?>
 828:             <option <?php if ($articles_page == 0) echo 'selected="selected"'; ?> value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('articles_page' => 'all'), $option)); ?>"><?php echo gettext("All"); ?></option>
 829: 
 830:         </select>
 831:         <script type="text/javascript">
 832:             // <!-- <![CDATA[
 833:             function gotoLink(form) {
 834:                 var OptionIndex = form.ListBoxURL.selectedIndex;
 835:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
 836:             }
 837:             // ]]> -->
 838:         </script>
 839:         &nbsp;&nbsp;
 840:     </form>
 841:     <?php
 842: }
 843: 
 844: /* * ************************
 845:   /* Category functions
 846:  * ************************* */
 847: 
 848: /**
 849:  * Updates or adds a category
 850:  *
 851:  * @param array $reports the results display
 852:  * @param bool $newcategory true if a new article
 853:  *
 854:  */
 855: function updateCategory(&$reports, $newcategory = false) {
 856:     $date = date('Y-m-d_H-i-s');
 857:     $id = sanitize_numeric($_POST['id']);
 858:     $permalink = getcheckboxState('permalink');
 859:     $title = process_language_string_save("title", 2);
 860:     $desc = process_language_string_save("desc", EDITOR_SANITIZE_LEVEL);
 861:     $custom = process_language_string_save("custom_data", 1);
 862: 
 863:     if ($newcategory) {
 864:         $titlelink = seoFriendly(get_language_string($title));
 865:         if (empty($titlelink))
 866:             $titlelink = seoFriendly($date);
 867:         $sql = 'SELECT `id` FROM ' . prefix('news_categories') . ' WHERE `titlelink`=' . db_quote($titlelink);
 868:         $rslt = query_single_row($sql, false);
 869:         if ($rslt) {
 870:             //already exists
 871:             $time = explode(' ', microtime());
 872:             $titlelink = $titlelink . '_' . ($time[1] + $time[0]);
 873:             $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate category title') . '</p>';
 874:         }
 875:         $oldtitlelink = $titlelink;
 876:     } else {
 877:         $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
 878:         if (getcheckboxState('edittitlelink')) {
 879:             $titlelink = sanitize($_POST['titlelink'], 3);
 880:             if (empty($titlelink)) {
 881:                 $titlelink = seoFriendly(get_language_string($title));
 882:                 if (empty($titlelink)) {
 883:                     $titlelink = seoFriendly($date);
 884:                 }
 885:             }
 886:         } else {
 887:             if (!$permalink) { //   allow the link to change
 888:                 $link = seoFriendly(get_language_string($title));
 889:                 if (!empty($link)) {
 890:                     $titlelink = $link;
 891:                 }
 892:             }
 893:         }
 894:     }
 895:     $titleok = true;
 896:     if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
 897:         $titleok = query('UPDATE ' . prefix('news_categories') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
 898:         if (!$titleok) {
 899:             $titlelink = $oldtitlelink; // force old link so data gets saved
 900:         } else {
 901:             SearchEngine::clearSearchCache();
 902:         }
 903:     }
 904:     //update category
 905:     $show = getcheckboxState('show');
 906:     $cat = new ZenpageCategory($titlelink, true);
 907:     $notice = processCredentials($cat);
 908:     $cat->setPermalink(getcheckboxState('permalink'));
 909:     $cat->set('title', $title);
 910:     $cat->setDesc($desc);
 911:     $cat->setCustomData(zp_apply_filter('save_category_custom_data', $custom, $cat));
 912:     $cat->setShow($show);
 913:     if (getcheckboxState('resethitcounter')) {
 914:         $cat->set('hitcounter', 0);
 915:     }
 916:     if (getcheckboxState('reset_rating')) {
 917:         $cat->set('total_value', 0);
 918:         $cat->set('total_votes', 0);
 919:         $cat->set('used_ips', 0);
 920:     }
 921: 
 922:     if ($newcategory) {
 923:         $msg = zp_apply_filter('new_category', '', $cat);
 924:         if (empty($title)) {
 925:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Category <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), $titlelink) . '</p>';
 926:         } else if ($notice == '?mismatch=user') {
 927:             $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
 928:         } else if ($notice) {
 929:             $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
 930:         } else {
 931:             $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Category <em>%s</em> added"), $titlelink) . '</p>';
 932:         }
 933:     } else {
 934:         $msg = zp_apply_filter('update_category', '', $cat, $oldtitlelink);
 935:         if ($titleok) {
 936:             if (empty($titlelink) OR empty($title)) {
 937:                 $reports[] = "<p class='errorbox fade-message'>" . gettext("You forgot to give your category a <strong>title or titlelink</strong>!") . "</p>";
 938:             } else if ($notice == '?mismatch=user') {
 939:                 $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
 940:             } else if ($notice) {
 941:                 $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
 942:             } else {
 943:                 $reports[] = "<p class='messagebox fade-message'>" . gettext("Category updated!") . "</p>";
 944:             }
 945:         } else {
 946:             $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A category with the title/titlelink <em>%s</em> already exists!"), html_encode($cat->getTitle())) . "</p>";
 947:         }
 948:     }
 949:     $cat->save();
 950:     if ($msg) {
 951:         $reports[] = $msg;
 952:     }
 953:     return $cat;
 954: }
 955: 
 956: /**
 957:  * Deletes a category (and also if existing its subpages) from the database
 958:  *
 959:  */
 960: function deleteCategory($titlelink) {
 961:     $obj = new ZenpageCategory($titlelink);
 962:     $result = $obj->remove();
 963:     if ($result) {
 964:         SearchEngine::clearSearchCache();
 965:         return "<p class='messagebox fade-message'>" . gettext("Category successfully deleted!") . "</p>";
 966:     }
 967:     return "<p class='errorbox fade-message'>" . gettext("Category  delete failed!") . "</p>";
 968: }
 969: 
 970: /**
 971:  * Prints the list entry of a single category for the sortable list
 972:  *
 973:  * @param array $cat Array storing the db info of the category
 974:  * @param string $flag If the category is protected
 975:  * @return string
 976:  */
 977: function printCategoryListSortableTable($cat, $flag) {
 978:     global $_zp_zenpage;
 979:     if ($flag) {
 980:         $img = '../../images/drag_handle_flag.png';
 981:     } else {
 982:         $img = '../../images/drag_handle.png';
 983:     }
 984:     $count = count($cat->getArticles(0, false));
 985:     if ($cat->getTitle()) {
 986:         $cattitle = $cat->getTitle();
 987:     } else {
 988:         $cattitle = "<span style='color:red; font-weight: bold'> <strong>*</strong>" . $cat->getTitlelink() . "*</span>";
 989:     }
 990:     ?>
 991:     <div class='page-list_row'>
 992:         <div class='page-list_title' >
 993:             <?php echo "<a href='admin-edit.php?newscategory&amp;titlelink=" . $cat->getTitlelink() . "' title='" . gettext('Edit this category') . "'>" . $cattitle . "</a>" . checkHitcounterDisplay($cat->getHitcounter()); ?>
 994:         </div>
 995:         <div class="page-list_extra">
 996:             <?php echo $count; ?>
 997:             <?php echo gettext("articles"); ?>
 998:         </div>
 999: 
1000:         <div class="page-list_iconwrapper">
1001:             <div class="page-list_icon"><?php
1002:                 $password = $cat->getPassword();
1003:                 if (!empty($password)) {
1004:                     echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
1005:                 }
1006:                 ?>
1007:             </div>
1008:             <div class="page-list_icon">
1009:                 <?php
1010:                 if ($cat->getShow()) {
1011:                     $title = gettext("Un-publish");
1012:                     ?>
1013:                     <a href="?publish=0&amp;titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
1014:                         <img src="../../images/pass.png" alt="<?php gettext("Scheduled for published"); ?>" title="<?php echo $title; ?>" /></a>
1015:                     <?php
1016:                 } else {
1017:                     $title = gettext("Publish");
1018:                     ?>
1019:                     <a href="?publish=1&amp;titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
1020:                         <img src="../../images/action.png" alt="<?php echo gettext("Un-published"); ?>" title="<?php echo $title; ?>" /></a>
1021:                     <?php
1022:                 }
1023:                 ?>
1024:             </div>
1025:             <div class="page-list_icon">
1026:                 <?php if ($count == 0) { ?>
1027:                     <img src="../../images/icon_inactive.png" alt="<?php gettext('locked'); ?>" />
1028:                     <?php
1029:                 } else {
1030:                     ?>
1031:                     <a href="../../../index.php?p=news&amp;category=<?php echo js_encode($cat->getTitlelink()); ?>" title="<?php echo gettext("View category"); ?>">
1032:                         <img src="images/view.png" alt="view" />
1033:                     </a>
1034:                 <?php } ?>
1035:             </div>
1036:             <?php
1037:             if (extensionEnabled('hitcounter')) {
1038:                 ?>
1039:                 <div class="page-list_icon"><a
1040:                         href="?hitcounter=1&amp;id=<?php echo $cat->getID(); ?>&amp;tab=categories&amp;XSRFToken=<?php echo getXSRFToken('hitcounter') ?>"
1041:                         title="<?php echo gettext("Reset hitcounter"); ?>"> <img
1042:                             src="../../images/reset.png"
1043:                             alt="<?php echo gettext("Reset hitcounter"); ?>" /> </a>
1044:                 </div>
1045:                 <?php
1046:             }
1047:             ?>
1048:             <div class="page-list_icon"><a
1049:                     href="javascript:confirmDelete('admin-categories.php?delete=<?php echo js_encode($cat->getTitlelink()); ?>&amp;tab=categories&amp;XSRFToken=<?php echo getXSRFToken('delete_category') ?>',deleteCategory)"
1050:                     title="<?php echo gettext("Delete Category"); ?>"><img
1051:                         src="../../images/fail.png" alt="<?php echo gettext("Delete"); ?>"
1052:                         title="<?php echo gettext("Delete Category"); ?>" /></a>
1053:             </div>
1054:             <div class="page-list_icon"><input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $cat->getTitlelink(); ?>"
1055:                                                                                  onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
1056:             </div>
1057:         </div>
1058:     </div>
1059:     <?php
1060: }
1061: 
1062: /**
1063:  * Prints the checkboxes to select and/or show the category of an news article on the edit or add page
1064:  *
1065:  * @param int $id ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added.
1066:  * @param string $option "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned.
1067:  */
1068: function printCategoryCheckboxListEntry($cat, $articleid, $option, $class = '') {
1069:     $selected = '';
1070:     if (($option != "all") && !$cat->transient && !empty($articleid)) {
1071:         $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $articleid . " AND cat_id = " . $cat->getID());
1072:         if ($cat2news['cat_id'] != "") {
1073:             $selected = "checked ='checked'";
1074:         } else {
1075:             $selected = "";
1076:         }
1077:     }
1078:     $catname = $cat->getTitle();
1079:     $catlink = $cat->getTitlelink();
1080:     if ($cat->getPassword()) {
1081:         $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
1082:     } else {
1083:         $protected = '';
1084:     }
1085:     $catid = $cat->getID();
1086:     echo '<label for="cat' . $catid . '"><input name="cat' . $catid . '" class="' . $class . '" id="cat' . $catid . '" type="checkbox" value="' . $catid . '"' . $selected . ' />' . $catname . ' ' . $protected . "</label>\n";
1087: }
1088: 
1089: /* * ************************
1090:   /* General functions
1091:  * ************************* */
1092: 
1093: /**
1094:  * Prints the nested list for pages and categories
1095:  *
1096:  * @param string $listtype 'cats-checkboxlist' for a fake nested checkbock list of categories for the news article edit/add page
1097:  *                                              'cats-sortablelist' for a sortable nested list of categories for the admin categories page
1098:  *                                              'pages-sortablelist' for a sortable nested list of pages for the admin pages page
1099:  * @param int $articleid Only for $listtype = 'cats-checkboxlist': For ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added.
1100:  * @param string $option Only for $listtype = 'cats-checkboxlist': "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned.
1101:  * @return string | bool
1102:  */
1103: function printNestedItemsList($listtype = 'cats-sortablelist', $articleid = '', $option = '', $class = 'nestedItem') {
1104:     global $_zp_zenpage;
1105:     switch ($listtype) {
1106:         case 'cats-checkboxlist':
1107:         default:
1108:             $ulclass = "";
1109:             break;
1110:         case 'cats-sortablelist':
1111:         case 'pages-sortablelist':
1112:             $ulclass = " class=\"page-list\"";
1113:             break;
1114:     }
1115:     switch ($listtype) {
1116:         case 'cats-checkboxlist':
1117:         case 'cats-sortablelist':
1118:    //Without this the order is incorrect until the 2nd page reload…
1119:    $_zp_zenpage = new Zenpage();
1120:             $items = $_zp_zenpage->getAllCategories(false);
1121:             break;
1122:         case 'pages-sortablelist':
1123:             $items = $_zp_zenpage->getPages(false);
1124:             break;
1125:         default:
1126:             $items = array();
1127:             break;
1128:     }
1129:     $indent = 1;
1130:     $open = array(1 => 0);
1131:     $rslt = false;
1132:     foreach ($items as $item) {
1133:         switch ($listtype) {
1134:             case 'cats-checkboxlist':
1135:             case 'cats-sortablelist':
1136:                 $itemobj = new ZenpageCategory($item['titlelink']);
1137:                 $ismypage = $itemobj->isMyItem(ZENPAGE_NEWS_RIGHTS);
1138:                 break;
1139:             case 'pages-sortablelist':
1140:                 $itemobj = new ZenpagePage($item['titlelink']);
1141:                 $ismypage = $itemobj->isMyItem(ZENPAGE_PAGES_RIGHTS);
1142:                 break;
1143:         }
1144:         $itemsortorder = $itemobj->getSortOrder();
1145:         $itemid = $itemobj->getID();
1146:         if ($ismypage) {
1147:             $order = explode('-', $itemsortorder);
1148:             $level = max(1, count($order));
1149:             if ($toodeep = $level > 1 && $order[$level - 1] === '') {
1150:                 $rslt = true;
1151:             }
1152:             if ($level > $indent) {
1153:                 echo "\n" . str_pad("\t", $indent, "\t") . "<ul" . $ulclass . ">\n";
1154:                 $indent++;
1155:                 $open[$indent] = 0;
1156:             } else if ($level < $indent) {
1157:                 while ($indent > $level) {
1158:                     $open[$indent] --;
1159:                     $indent--;
1160:                     echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
1161:                 }
1162:             } else { // indent == level
1163:                 if ($open[$indent]) {
1164:                     echo str_pad("\t", $indent, "\t") . "</li>\n";
1165:                     $open[$indent] --;
1166:                 } else {
1167:                     echo "\n";
1168:                 }
1169:             }
1170:             if ($open[$indent]) {
1171:                 echo str_pad("\t", $indent, "\t") . "</li>\n";
1172:                 $open[$indent] --;
1173:             }
1174:             switch ($listtype) {
1175:                 case 'cats-checkboxlist':
1176:                     echo "<li>\n";
1177:                     printCategoryCheckboxListEntry($itemobj, $articleid, $option, $class);
1178:                     break;
1179:                 case 'cats-sortablelist':
1180:                     echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
1181:                     printCategoryListSortableTable($itemobj, $toodeep);
1182:                     break;
1183:                 case 'pages-sortablelist':
1184:                     echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
1185:                     printPagesListTable($itemobj, $toodeep);
1186:                     break;
1187:             }
1188:             $open[$indent] ++;
1189:         }
1190:     }
1191:     while ($indent > 1) {
1192:         echo "</li>\n";
1193:         $open[$indent] --;
1194:         $indent--;
1195:         echo str_pad("\t", $indent, "\t") . "</ul>";
1196:     }
1197:     if ($open[$indent]) {
1198:         echo "</li>\n";
1199:     } else {
1200:         echo "\n";
1201:     }
1202:     return $rslt;
1203: }
1204: 
1205: /**
1206:  * Updates the sortorder of the items list in the database
1207:  *
1208:  * @param string $mode 'pages' or 'categories'
1209:  * @return array
1210:  */
1211: function updateItemSortorder($mode = 'pages') {
1212:     if (!empty($_POST['order'])) { // if someone didn't sort anything there are no values!
1213:         $order = processOrder($_POST['order']);
1214:         $parents = array('NULL');
1215:         foreach ($order as $id => $orderlist) {
1216:             $id = str_replace('id_', '', $id);
1217:             $level = count($orderlist);
1218:             $parents[$level] = $id;
1219:             $myparent = $parents[$level - 1];
1220:             switch ($mode) {
1221:                 case 'pages':
1222:                     $dbtable = prefix('pages');
1223:                     break;
1224:                 case 'categories':
1225:                     $dbtable = prefix('news_categories');
1226:                     break;
1227:             }
1228:             $sql = "UPDATE " . $dbtable . " SET `sort_order` = " . db_quote(implode('-', $orderlist)) . ", `parentid`= " . $myparent . " WHERE `id`=" . $id;
1229:             query($sql);
1230:         }
1231:         return true;
1232:     }
1233:     return false;
1234: }
1235: 
1236: /**
1237:  * Checks if no title has been provide for items on new item creation
1238:  * @param string $titlefield The title field
1239:  * @param string $type 'page', 'news' or 'category'
1240:  * @return string
1241:  */
1242: function checkForEmptyTitle($titlefield, $type, $truncate = true) {
1243:     switch ($type) {
1244:         case "page":
1245:             $text = gettext("Untitled page");
1246:             break;
1247:         case "news":
1248:             $text = gettext("Untitled article");
1249:             break;
1250:         case "category":
1251:             $text = gettext("Untitled category");
1252:             break;
1253:     }
1254:     $title = getBare($titlefield);
1255:     if ($title) {
1256:         if ($truncate) {
1257:             $title = truncate_string($title, 40);
1258:         }
1259:     } else {
1260:         $title = "<span style='color:red; font-weight: bold'>" . $text . "</span>";
1261:     }
1262:     echo $title;
1263: }
1264: 
1265: /**
1266:  * Publishes a page or news article
1267:  *
1268:  * @param object $obj
1269:  * @param int $show the value for publishing
1270:  * @return string
1271:  */
1272: function zenpagePublish($obj, $show) {
1273:     if ($show > 1) {
1274:         $obj->setExpireDate(NULL);
1275:     }
1276:     $obj->setShow((int) ($show && 1));
1277:     $obj->save();
1278: }
1279: 
1280: /**
1281:  * Skips the scheduled publishing by setting the date of a page or article to the current date to publish it immediately
1282:  *
1283:  * @param object $obj
1284:  * @return string
1285:  */
1286: function skipScheduledPublishing($obj) {
1287:     $obj->setDateTime(date('Y-m-d H:i:s'));
1288:     $obj->setShow(1);
1289:     $obj->save();
1290: }
1291: 
1292: /**
1293:  * Checks if there are hitcounts and if they are displayed behind the news article, page or category title
1294:  *
1295:  * @param string $item The array of the current news article, page or category in the list.
1296:  * @return string
1297:  */
1298: function checkHitcounterDisplay($item) {
1299:     if ($item == 0) {
1300:         $hitcount = "";
1301:     } else {
1302:         if ($item == 1) {
1303:             $hits = gettext("hit");
1304:         } else {
1305:             $hits = gettext("hits");
1306:         }
1307:         $hitcount = " (" . $item . " " . $hits . ")";
1308:     }
1309:     return $hitcount;
1310: }
1311: 
1312: /**
1313:  * returns an array of how many pages, articles, categories and news or pages comments we got.
1314:  *
1315:  * @param string $option What the statistic should be shown of: "news", "pages", "categories"
1316:  */
1317: function getNewsPagesStatistic($option) {
1318:     global $_zp_zenpage;
1319:     switch ($option) {
1320:         case "news":
1321:             $items = $_zp_zenpage->getArticles();
1322:             $type = gettext("Articles");
1323:             break;
1324:         case "pages":
1325:             $items = $_zp_zenpage->getPages(false);
1326:             $type = gettext("Pages");
1327:             break;
1328:         case "categories":
1329:             $type = gettext("Categories");
1330:             $items = $_zp_zenpage->getAllCategories(false);
1331:             break;
1332:     }
1333:     $total = count($items);
1334:     $pub = 0;
1335:     foreach ($items as $item) {
1336:         switch ($option) {
1337:             case "news":
1338:                 $itemobj = new ZenpageNews($item['titlelink']);
1339:                 break;
1340:             case "pages":
1341:                 $itemobj = new ZenpagePage($item['titlelink']);
1342:                 break;
1343:             case "categories":
1344:                 $itemobj = new ZenpageCategory($item['titlelink']);
1345:                 break;
1346:         }
1347:         if ($itemobj->getShow() == 1) {
1348:             $pub++;
1349:         }
1350:     }
1351:     $unpub = $total - $pub;
1352:     return array($total, $type, $unpub);
1353: }
1354: 
1355: function printPagesStatistic() {
1356:     list($total, $type, $unpub) = getNewsPagesStatistic("pages");
1357:     if (empty($unpub)) {
1358:         printf(ngettext('<strong>%1$u</strong> page', '<strong>%1$u</strong> pages', $total), $total);
1359:     } else {
1360:         printf(ngettext('<strong>%1$u</strong> page (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> pages (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
1361:     }
1362: }
1363: 
1364: function printNewsStatistic() {
1365:     list($total, $type, $unpub) = getNewsPagesStatistic("news");
1366:     if (empty($unpub)) {
1367:         printf(ngettext('<strong>%1$u</strong> article', '<strong>%1$u</strong> articles', $total), $total);
1368:     } else {
1369:         printf(ngettext('<strong>%1$u</strong> article (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> articles (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
1370:     }
1371: }
1372: 
1373: function printCategoriesStatistic() {
1374:     list($total, $type, $unpub) = getNewsPagesStatistic("categories");
1375:     if (empty($unpub)) {
1376:         printf(ngettext('<strong>%1$u</strong> category', '<strong>%1$u</strong> categories', $total), $total);
1377:     } else {
1378:         printf(ngettext('<strong>%1$u</strong> category (<strong>%2$u</strong> un-published)', '<strong>%1$u</strong> categories (<strong>%2$u</strong> un-published)', $total), $total, $unpub);
1379:     }
1380: }
1381: 
1382: /**
1383:  * Prints the links to JavaScript and CSS files zenpage needs.
1384:  * Actually the same as for zenphoto but with different paths since we are in the plugins folder.
1385:  *
1386:  * @param bool $sortable set to true for tabs with sorts.
1387:  *
1388:  */
1389: function zenpageJSCSS() {
1390:     ?>
1391:     <link rel="stylesheet" href="zenpage.css" type="text/css" />
1392:     <script type="text/javascript">
1393:         // <!-- <![CDATA[
1394:         $(document).ready(function() {
1395:             $("#tip a").click(function() {
1396:                 $("#tips").toggle("slow");
1397:             });
1398:         });
1399:         // ]]> -->
1400:     </script>
1401:     <?php
1402: }
1403: 
1404: function printZenpageIconLegend() {
1405:     ?>
1406:     <ul class="iconlegend">
1407:         <?php
1408:         if (GALLERY_SECURITY == 'public') {
1409:             ?>
1410:             <li><img src="../../images/lock.png" alt="" /><?php echo gettext("Has Password"); ?></li>   <li><img src="../../images/pass.png" alt="" /><img  src="../../images/action.png" alt="" /><img src="images/clock.png" alt="" /><?php echo gettext("Published/Not published/Scheduled for publishing"); ?></li>
1411:             <?php
1412:         }
1413:         ?>
1414:         <li><img src="../../images/comments-on.png" alt="" /><img src="../../images/comments-off.png" alt="" /><?php echo gettext("Comments on/off"); ?></li>
1415:         <li><img src="../../images/view.png" alt="" /><?php echo gettext("View"); ?></li>
1416:         <?php
1417:         if (extensionEnabled('hitcounter')) {
1418:             ?>
1419:             <li><img src="../../images/reset.png" alt="" /><?php echo gettext("Reset hitcounter"); ?></li>
1420:             <?php
1421:         }
1422:         ?>
1423:         <li><img src="../../images/fail.png" alt="" /><?php echo gettext("Delete"); ?></li>
1424:     </ul>
1425:     <?php
1426: }
1427: 
1428: /**
1429:  * Prints a dropdown to select the author of a page or news article (Admin rights users only)
1430:  *
1431:  * @param string $currentadmin The current admin is selected if adding a new article, otherwise the original author
1432:  */
1433: function authorSelector($author = NULL) {
1434:     global $_zp_authority, $_zp_current_admin_obj;
1435:     if (empty($author)) {
1436:         $author = $_zp_current_admin_obj->getUser();
1437:     }
1438:     $authors = array($author => $author);
1439:     if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS | MANAGE_ALL_NEWS_RIGHTS)) {
1440:         $admins = $_zp_authority->getAdministrators();
1441:         foreach ($admins as $admin) {
1442:             if ($admin['rights'] & (ADMIN_RIGHTS | ZENPAGE_PAGES_RIGHTS | ZENPAGE_NEWS_RIGHTS)) {
1443:                 $authors[$admin['user']] = $admin['user'];
1444:             }
1445:         }
1446:     }
1447:     ?>
1448:     <select size='1' name="author" id="author">
1449:         <?php
1450:         generateListFromArray(array($author), $authors, false, false);
1451:         ?>
1452:     </select>
1453:     <?php
1454: }
1455: 
1456: /**
1457:  * Prints data info for objects
1458:  *
1459:  * @param string $object Object of the page or news article to check
1460:  * @return string
1461:  */
1462: function printPublished($object) {
1463:     $dt = $object->getDateTime();
1464:     if ($dt > date('Y-m-d H:i:s')) {
1465:         if ($object->getShow() != 1) {
1466:             echo '<span class="inactivescheduledate">' . $dt . '</strong>';
1467:         } else {
1468:             echo '<span class="scheduledate">' . $dt . '</strong>';
1469:         }
1470:     } else {
1471:         echo '<span>' . $dt . '</span>';
1472:     }
1473: }
1474: 
1475: /**
1476:  * Prints data info for objects
1477:  *
1478:  * @param string $object Object of the page or news article to check
1479:  * @return string
1480:  */
1481: function printExpired($object) {
1482:     $dt = $object->getExpireDate();
1483:     if (!empty($dt)) {
1484:         $expired = $dt < date('Y-m-d H:i:s');
1485:         if ($expired) {
1486:             echo ' <span class="expired">' . $dt . "</span>";
1487:         } else {
1488:             echo ' <span class="expiredate">' . $dt . "</span>";
1489:         }
1490:     }
1491: }
1492: 
1493: /**
1494:  * Prints the publish/un-published/scheduled publishing icon with a link for the pages and news articles list.
1495:  *
1496:  * @param string $object Object of the page or news article to check
1497:  * @return string
1498:  */
1499: function printPublishIconLink($object, $type, $linkback = '') {
1500:     $urladd = '';
1501:     if ($type == "news") {
1502:         if (isset($_GET['subpage'])) {
1503:             $urladd .= "&amp;subpage=" . sanitize($_GET['subpage']);
1504:         }
1505:         if (isset($_GET['date'])) {
1506:             $urladd .= "&amp;date=" . sanitize($_GET['date']);
1507:         }
1508:         if (isset($_GET['category'])) {
1509:             $urladd .= "&amp;category=" . sanitize($_GET['category']);
1510:         }
1511:         if (isset($_GET['sortorder'])) {
1512:             $urladd .= "&amp;sortorder=" . sanitize($_GET['sortorder']);
1513:         }
1514:         if (isset($_GET['articles_page'])) {
1515:             $urladd .= "&amp;articles_page=" . sanitize_numeric($_GET['articles_page']);
1516:         }
1517:     }
1518:     if ($object->getDateTime() > date('Y-m-d H:i:s')) {
1519:         if ($object->getShow()) {
1520:             $title = gettext("Publish immediately (skip scheduling)");
1521:             ?>
1522:             <a href="?skipscheduling=1&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
1523:                 <img src="images/clock.png" alt="<?php gettext("Scheduled for published"); ?>" title="<?php echo $title; ?>" /></a>
1524:             <?php
1525:         } else {
1526:             $title = gettext("Enable scheduled publishing");
1527:             ?>
1528:             <a href="?publish=1&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
1529:                 <img src="../../images/action.png" alt="<?php echo gettext("Un-published"); ?>" title="<?php echo $title; ?>" /></a>
1530:             <?php
1531:         }
1532:     } else {
1533:         if ($object->getShow()) {
1534:             $title = gettext("Un-publish");
1535:             ?>
1536:             <a href="?publish=0&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
1537:                 <img src="../../images/pass.png" alt="<?php echo gettext("Published"); ?>" title="<?php echo $title; ?>" /></a>
1538:             <?php
1539:         } else {
1540:             $dt = $object->getExpireDate();
1541:             if (empty($dt)) {
1542:                 $title = gettext("Publish");
1543:                 ?>
1544:                 <a href="?publish=1&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>">
1545:                     <?php
1546:                 } else {
1547:                     $title = gettext("Publish (override expiration)");
1548:                     ?>
1549:                     <a href="?publish=2&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>">
1550:                         <?php
1551:                     }
1552:                     ?>
1553:                     <img src="../../images/action.png" alt="<?php echo gettext("Un-published"); ?>" title= "<?php echo $title; ?>" /></a>
1554:                 <?php
1555:             }
1556:         }
1557:     }
1558: 
1559:     /**
1560:      * Checks if a checkbox is selected and checks it if.
1561:      *
1562:      * @param string $field the array field of an item array to be checked (for example "permalink" or "comments on")
1563:      */
1564:     function checkIfChecked($field) {
1565:         if ($field) {
1566:             echo 'checked="checked"';
1567:         }
1568:     }
1569: 
1570:     /**
1571:      * Checks if the current logged in admin user is the author that locked the page/article.
1572:      * Only that author or any user with admin rights will be able to edit or unlock.
1573:      *
1574:      * @param object $page The array of the page or article to check
1575:      * @return bool
1576:      */
1577:     function checkIfLockedPage($page) {
1578:         if (zp_loggedin(ADMIN_RIGHTS))
1579:             return true;
1580:         if ($page->getLocked()) {
1581:             return $page->isMyItem(ZENPAGE_PAGES_RIGHTS);
1582:         } else {
1583:             return true;
1584:         }
1585:     }
1586: 
1587:     /**
1588:      * Checks if the current logged in admin user is the author that locked the article.
1589:      * Only that author or any user with admin rights will be able to edit or unlock.
1590:      *
1591:      * @param object $page The array of the page or article to check
1592:      * @return bool
1593:      */
1594:     function checkIfLockedNews($news) {
1595:         if (zp_loggedin(ADMIN_RIGHTS))
1596:             return true;
1597:         if ($news->getLocked()) {
1598:             return $news->isMyItem(ZENPAGE_NEWS_RIGHTS);
1599:         } else {
1600:             return true;
1601:         }
1602:     }
1603: 
1604:     /**
1605:      * Checks if the current admin-edit.php page is called for news articles or for pages.
1606:      *
1607:      * @param string $page What you want to check for, "page" or "newsarticle"
1608:      * @return bool
1609:      */
1610:     function is_AdminEditPage($page) {
1611:         return isset($_GET[$page]);
1612:     }
1613: 
1614:     /**
1615:      * Processes the check box bulk actions
1616:      *
1617:      */
1618:     function processZenpageBulkActions($type) {
1619:         global $_zp_zenpage;
1620:         $action = false;
1621:         if (isset($_POST['ids'])) {
1622:             //echo "action for checked items:". $_POST['checkallaction'];
1623:             $action = sanitize($_POST['checkallaction']);
1624:             $links = sanitize($_POST['ids']);
1625:             $total = count($links);
1626:             $message = NULL;
1627:             $sql = '';
1628:             if ($action != 'noaction') {
1629:                 if ($total > 0) {
1630:                     if ($action == 'addtags' || $action == 'alltags') {
1631:                         $tags = bulkTags();
1632:                     }
1633:                     if ($action == 'addcats') {
1634:                         foreach ($_POST as $key => $value) {
1635:                             $key = postIndexDecode($key);
1636:                             if (substr($key, 0, 3) == 'cat') {
1637:                                 if ($value) {
1638:                                     $cats[] = substr($key, 3);
1639:                                 }
1640:                             }
1641:                         }
1642:                         $cats = sanitize($cats, 3);
1643:                     }
1644:                     $n = 0;
1645:                     foreach ($links as $titlelink) {
1646:                         $class = 'Zenpage' . $type;
1647:                         $obj = new $class($titlelink);
1648: 
1649:                         switch ($action) {
1650:                             case 'deleteall':
1651:                                 $obj->remove();
1652:                                 SearchEngine::clearSearchCache();
1653:                                 break;
1654:                             case 'addtags':
1655:                                 $mytags = array_unique(array_merge($tags, $obj->getTags()));
1656:                                 $obj->setTags($mytags);
1657:                                 break;
1658:                             case 'cleartags':
1659:                                 $obj->setTags(array());
1660:                                 break;
1661:                             case 'alltags':
1662:                                 $allarticles = $obj->getArticles('', 'all', true);
1663:                                 foreach ($allarticles as $article) {
1664:                                     $newsobj = new ZenpageNews($article['titlelink']);
1665:                                     $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
1666:                                     $newsobj->setTags($mytags);
1667:                                     $newsobj->save();
1668:                                 }
1669:                                 break;
1670:                             case 'clearalltags':
1671:                                 $allarticles = $obj->getArticles('', 'all', true);
1672:                                 foreach ($allarticles as $article) {
1673:                                     $newsobj = new ZenpageNews($article['titlelink']);
1674:                                     $newsobj->setTags(array());
1675:                                     $newsobj->save();
1676:                                 }
1677:                                 break;
1678:                             case 'addcats':
1679:                                 $catarray = array();
1680:                                 $allcats = $obj->getCategories();
1681:                                 foreach ($cats as $cat) {
1682:                                     $catitem = $_zp_zenpage->getCategory($cat);
1683:                                     $catarray[] = $catitem['titlelink']; //to use the setCategories method we need an array with just the titlelinks!
1684:                                 }
1685:                                 $allcatsarray = array();
1686:                                 foreach ($allcats as $allcat) {
1687:                                     $allcatsarray[] = $allcat['titlelink']; //same here!
1688:                                 }
1689:                                 $mycats = array_unique(array_merge($catarray, $allcatsarray));
1690:                                 $obj->setCategories($mycats);
1691:                                 break;
1692:                             case 'clearcats':
1693:                                 $obj->setCategories(array());
1694:                                 break;
1695:                             case 'showall':
1696:                                 $obj->set('show', 1);
1697:                                 break;
1698:                             case 'hideall':
1699:                                 $obj->set('show', 0);
1700:                                 break;
1701:                             case 'commentson':
1702:                                 $obj->set('commentson', 1);
1703:                                 break;
1704:                             case 'commentsoff':
1705:                                 $obj->set('commentson', 0);
1706:                                 break;
1707:                             case 'resethitcounter':
1708:                                 $obj->set('hitcounter', 0);
1709:                                 break;
1710:                         }
1711:                         $obj->save();
1712:                     }
1713:                 }
1714:             }
1715:         }
1716:         return $action;
1717:     }
1718: 
1719:     function zenpageBulkActionMessage($action) {
1720:         switch ($action) {
1721:             case 'deleteall':
1722:                 $message = gettext('Selected items deleted');
1723:                 break;
1724:             case 'showall':
1725:                 $message = gettext('Selected items published');
1726:                 break;
1727:             case 'hideall':
1728:                 $message = gettext('Selected items unpublished');
1729:                 break;
1730:             case 'commentson':
1731:                 $message = gettext('Comments enabled for selected items');
1732:                 break;
1733:             case 'commentsoff':
1734:                 $message = gettext('Comments disabled for selected items');
1735:                 break;
1736:             case 'resethitcounter':
1737:                 $message = gettext('Hitcounter for selected items');
1738:                 break;
1739:             case 'addtags':
1740:                 $message = gettext('Tags added to selected items');
1741:                 break;
1742:             case 'cleartags':
1743:                 $message = gettext('Tags cleared from selected items');
1744:                 break;
1745:             case 'alltags':
1746:                 $message = gettext('Tags added to articles of selected items');
1747:                 break;
1748:             case 'clearalltags':
1749:                 $message = gettext('Tags cleared from articles of selected items');
1750:                 break;
1751:             case 'addcats':
1752:                 $message = gettext('Categories added to selected items');
1753:                 break;
1754:             case 'clearcats':
1755:                 $message = gettext('Categories cleared from selected items');
1756:                 break;
1757:             default:
1758:                 return "<p class='notebox fade-message'>" . gettext('Nothing changed') . "</p>";
1759:         }
1760:         if (isset($message)) {
1761:             return "<p class='messagebox fade-message'>" . $message . "</p>";
1762:         }
1763:         return false;
1764:     }
1765:     ?>
1766: 
Zenphoto doc API documentation generated by ApiGen