Overview

Classes

  • _zp_captcha
  • _zp_HTML_cache
  • admin_approval
  • Album
  • AlbumBase
  • AlbumZip
  • AMFReader
  • AMFStream
  • AnyFile
  • AnyFile_Options
  • auto_backup
  • AVCSequenceParameterSetReader
  • bxslider
  • cacheManager
  • cachemanager_internal_deprecations
  • cacheManagerFeed
  • CI_jsmin
  • CI_load
  • cloneZenphoto
  • codeIgniter_kludge
  • colorbox
  • Combi
  • Comment
  • comment_form
  • contactformOptions
  • cookieConsent
  • crop_image
  • cycle
  • defaultCodeblocks
  • deprecated_functions
  • DownloadList
  • dynamic_locale
  • dynamicAlbum
  • elFinder
  • elFinder_options
  • elFinderConnector
  • elFinderEditor
  • elFinderEditorOnlineConvert
  • elFinderEditorZipArchive
  • elFinderEditorZohoOffice
  • elFinderLibGdBmp
  • elFinderPlugin
  • elFinderPluginAutoResize
  • elFinderPluginAutoRotate
  • elFinderPluginNormalizer
  • elFinderPluginSanitizer
  • elFinderPluginWatermark
  • elFinderSession
  • elFinderVolumeBox
  • elFinderVolumeDriver
  • elFinderVolumeDropbox
  • elFinderVolumeDropbox2
  • elFinderVolumeFlysystemGoogleDriveCache
  • elFinderVolumeFlysystemGoogleDriveNetmount
  • elFinderVolumeFTP
  • elFinderVolumeGoogleDrive
  • elFinderVolumeGroup
  • elFinderVolumeLocalFileSystem
  • elFinderVolumeMySQL
  • elFinderVolumeOneDrive
  • elFinderVolumeTrash
  • elFinderVolumeTrashMySQL
  • email_new_user
  • exampleMacros
  • external_auth
  • favorites
  • favoritesOptions
  • 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
  • hitcounter
  • htmlmetatags
  • Image
  • internal_deprecations
  • ipBlocker
  • jPlayer
  • jplayer_options
  • jquery_rating
  • JSMin
  • lazyload
  • lib_GD_Options
  • lib_Imagick_Options
  • lib_NoGraphics
  • matomoStats
  • 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
  • openStreetMap
  • openStreetMapOptions
  • pagedThumbsNav
  • pagedthumbsOptions
  • PersistentObject
  • PHPMailer\PHPMailer\PHPMailer
  • PHPMailer\PHPMailer\POP3
  • PHPMailer\PHPMailer\SMTP
  • print_album_menu
  • pseudoPlayer
  • publishContent
  • quota_manager
  • reCaptcha
  • RecursiveCallbackFilterIterator
  • redirector
  • redirectorOptions
  • register_user
  • rewriteRules
  • rewriteTokens
  • RSS
  • rss_options
  • scriptlessSocialsharing
  • scriptlessSocialsharingOptions
  • search_statistics
  • SearchEngine
  • security_logger
  • securityHeaders
  • securityheadersOptions
  • seo_locale
  • Services_JSON
  • Services_JSON_Error
  • setup
  • setupMutex
  • setupRSS
  • show_not_loggedin
  • sitemap
  • sitemapOptions
  • static_html_cache
  • staticHTMLCacheOptions
  • tagsuggest
  • TextObject
  • TextObject_Options
  • ThemeObject
  • themeSwitcher
  • tinymce4Options
  • tinyURL
  • Transientimage
  • UploadHandler
  • user_expiry
  • user_groups
  • user_logout_options
  • userAddressFields
  • userDataExport
  • utf8
  • Video
  • VideoObject_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
  • zpFunctions
  • zpMutex
  • zpSimpleSpam
  • zpTrivialSpam

Interfaces

  • elFinderSessionInterface

Exceptions

  • elFinderAbortException
  • elFinderTriggerException
  • getid3_exception
  • JSMin_UnterminatedCommentException
  • JSMin_UnterminatedRegExpException
  • JSMin_UnterminatedStringException
  • OAuthExcept
  • PHPMailer\PHPMailer\Exception

Functions

  • access
  • accessAlbums
  • accessAllAlbums
  • accessImage
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addDateToTitlelink
  • addGeoCoord
  • addItem
  • addMissingDefaultRewriteTokens
  • addPagesToDatabase
  • addReconfigureNote
  • addSubalbumMenus
  • addWatermark
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • authorSelector
  • bind_textdomain_codeset
  • bindtextdomain
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumForImages
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkObjectsThumb
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSchedulePublishingNotes
  • checkSelectedAlbum
  • checkSignature
  • checkTitlelinkDuplicate
  • cleanAlbum
  • cleanHTML
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • compressRow
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • createTitlelink
  • cron_starter
  • curlRequest
  • 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_getClientInfo
  • db_getServerInfo
  • db_getSQLmode
  • db_getVersion
  • db_insert_id
  • db_isMariaDB
  • 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
  • debuglogReconfigureNote
  • debugLogVar
  • decompressField
  • decompressRow
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • dircopy
  • disableExtension
  • elFinder_admin_tabs
  • elFinder_tinymce
  • elFinderAutoloader
  • enableExtension
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extendExecution
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • fillbuffer
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • gallerystats_filesize_r
  • genAlbumList
  • generateAttributesFromArray
  • generateImageCacheFile
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminstratorsOptionsArray
  • getAdminThumb
  • getAdminThumbHTML
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumInherited
  • getAlbumLocation
  • getAlbumPage
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getAnonymIP
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCheckboxState
  • getCodeblock
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDateTime
  • getCommentErrors
  • getCommentStored
  • getContactFormMacros
  • getContentShorten
  • getCookieInfoData
  • getCookieInfoHTML
  • getCookieInfoMacro
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomGalleryIndexPage
  • getCustomGalleryIndexURL
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDataUsageNotice
  • getDefaultHeight
  • getDefaultRewriteTokens
  • getDefaultSizedImage
  • getDefaultWidth
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFullHeight
  • getFullImageFilesize
  • getFullImageURL
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageGeodata
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageType
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLangAttributeLocale
  • getLanguageArray
  • getLanguageDisplayName
  • getLanguageFlag
  • getLanguageSubdomains
  • getLanguageText
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryURL
  • getNewsContent
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsIndexURL
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsURL
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getOption
  • getOptionFromDB
  • getOptionList
  • getOwnerAuthor
  • getOwnerAuthorURL
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentMenuItems
  • getPasswordProtectImage
  • getPHPFiles
  • getPictureOfTheDay
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getReconfigureNote
  • getRelatedItems
  • getRequestURI
  • getrow
  • getRSSLink
  • getRules
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getSortByOptions
  • getSortByStatusOptions
  • getStandardGalleryIndexURL
  • getSubtabs
  • getSuffix
  • getSystemLocales
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext
  • gettext_pl
  • gettext_th
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalHitcounter
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getUnprotectedImageURL
  • getUrAlbum
  • getUserIP
  • getUserLocale
  • getUserURL
  • getVersion
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpagePagesOptionsArray
  • getZenpageStatistic
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextNewsPage
  • hasNextPage
  • hasPrevImage
  • hasPrevNewsPage
  • hasPrevPage
  • hasPrimaryScripts
  • hl_attrval
  • hl_bal
  • hl_cmtcd
  • hl_ent
  • hl_prot
  • hl_regex
  • hl_spec
  • hl_tag
  • hl_tag2
  • hl_tidy
  • hl_version
  • html_decode
  • html_encode
  • html_encodeTagged
  • html_pathurlencode
  • htmLawed
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • ignoreSetupRunRequest
  • imageBlurGD
  • imagecreatefrombmp
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • installSignature
  • instrument
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_Pages
  • is_valid_email_zp
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isCurrentitemParent
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isIncompatibleExtension
  • isLandscape
  • isolate
  • isSetupProtected
  • isValidEmail
  • 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
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext
  • ngettext_pl
  • ngettext_th
  • omsAdditions
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • pathurlencode
  • pluginDebug
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminThumb
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLocation
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAllDates
  • printAllNestedList
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printAuthorDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBarGraph
  • printBulkActions
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printContactFormMacro
  • printCookieInfo
  • printCopyrightNotice
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDataUsageNotice
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printdownloadList
  • printDownloadURL
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesURL
  • printFullAlbumsList
  • printFullImageDownloadURL
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageMetadata
  • printImageslist
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjPlayerPlaylist
  • printLangAttribute
  • printLanguageSelector
  • printLastChangeInfo
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsArticlesList
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsIndexURL
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsStatistic
  • printNewsTitle
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageURL
  • printOpenStreetMap
  • printOwnerAuthor
  • printOwnerAuthorURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageURL
  • printPrivacyPageLink
  • printPublished
  • printPublishIconLink
  • printPublishIconLinkGallery
  • printRandomImages
  • printRating
  • printReconfigureError
  • printReconfigureNote
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printScheduledPublishingNotes
  • printSearchBreadcrumb
  • printSearchForm
  • printSelectorWithCustomField
  • printSiteHomeURL
  • printSizedImageURL
  • printSlideShow
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubLevelAlbums
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTinyPageNav
  • printTinyZenpageCategorySelector
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSelector
  • printUserURL
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItems
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePageSelector
  • printZenpagePagesSelector
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExtensionVariable
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • protectSetupFiles
  • publishItem
  • purgeOption
  • purgeThemeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • reconfigureAction
  • reconfigureCSS
  • recordMissing
  • redirectionHandler
  • redirectURL
  • rem_context
  • removeDir
  • removeParentAlbumNames
  • removeTrailingSlash
  • renameOption
  • replaceOption
  • replaceThemeOption
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewriteHandler
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • 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
  • setAlbumSubtabs
  • setexifvars
  • setMainDomain
  • setOption
  • setOptionDefault
  • setSiteState
  • setThemeColumns
  • setThemeOption
  • setThemeOptionDefault
  • setTinyZenpageLocale
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • shortentitle
  • showOrNotShowField
  • showZenphotoOptions
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • skipScheduledPublishing
  • sortArray
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • tagURLs
  • textdomain
  • themeIsEditable
  • themeSetup
  • tidyHTML
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unprotectSetupFiles
  • unpublishedZenpageItemCheck
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unTagURLs
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateImageProcessorLink
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • writeHeader
  • XSRFdefender
  • XSRFToken
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageJSCSS
  • 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_imageResizeTransparent
  • 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_destroy
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Class
  • Tree
  • Package
  • Deprecated
   1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791: 1792: 1793: 1794: 1795: 1796: 1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821: 1822: 1823: 
<?php
/**
 * zenpage admin functions
 *
 * @author Malte Müller (acrylian), Stephen Billard (sbillard)
 * @package plugins
 * @subpackage zenpage
 */
global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
Zenpage::expiry();


/**
 * Retrieves posted expiry date and checks it against the current date/time
 * Returns the posted date if it is in the future
 * Returns NULL if the date is past
 *
 * @return string
 */
function getExpiryDatePost() {
    $expiredate = sanitize($_POST['expiredate']);
    if ($expiredate > date(date('Y-m-d H:i:s')))
        return $expiredate;
    return NULL;
}

/**
 * processes the taglist save
 *
 * @param object $object the object on which the save happened
 */
function processTags($object) {
    $tagsprefix = 'tags_';
    $tags = array();
    $l = strlen($tagsprefix);
    foreach ($_POST as $key => $value) {
        $key = postIndexDecode($key);
        if (substr($key, 0, $l) == $tagsprefix) {
            if ($value) {
                $tags[] = substr($key, $l);
            }
        }
    }
    $tags = array_unique($tags);
    $object->setTags(sanitize($tags, 3));
}

/* * ************************
  /* page functions
 * ************************* */

/**
 * Updates or adds a page and returns the object of that page
 *
 * @param array $reports report display
 * @param bool $newpage true if it is a new page
 *
 * @return object
 */
function updatePage(&$reports, $newpage = false) {
    global $_zp_zenpage, $_zp_current_admin_obj;
    $title = process_language_string_save("title", 2);
    $author = sanitize($_POST['author']);
    $content = updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
    $extracontent = updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
    $custom = process_language_string_save("custom_data", 1);
    $show = getcheckboxState('show');
    $date = sanitize($_POST['date']);
    $expiredate = getExpiryDatePost();
    $commentson = getcheckboxState('commentson');
    $permalink = getcheckboxState('permalink');
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $codeblock = processCodeblockSave(0);
    }
    $locked = getcheckboxState('locked');
    if ($newpage) {
        $titlelink = createTitlelink($title, $date);
        if(getOption('zenpage_titlelinkdate_pages')) {
            $titlelink = addDateToTitlelink($titlelink);
        }
        $duplicate = checkTitlelinkDuplicate($titlelink, 'page');
        if ($duplicate) {
            //already exists
            $titlelink = addDateToTitlelink($titlelink);
            $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate page title') . '</p>';
        }
        $oldtitlelink = $titlelink;
    } else {
        $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old']);
    }
    if (getcheckboxState('edittitlelink')) {
        $titlelink = sanitize($_POST['titlelink'], 3);
        if (empty($titlelink)) {
            $titlelink = createTitlelink($title, $date);
        }
    } else {
        if (!$permalink) { //   allow the link to change
            $link = seoFriendly(get_language_string($title));
            if (!empty($link)) {
                $titlelink = $link;
            }
        }
    }
    $id = sanitize($_POST['id']);
    $rslt = true;
    if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
        $rslt = query('UPDATE ' . prefix('pages') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$rslt) {
            $titlelink = $oldtitlelink; // force old link so data gets saved
        } else {
            SearchEngine::clearSearchCache();
        }
    }
    // update page
    $page = new ZenpagePage($titlelink, true);

    $notice = processCredentials($page);
    $page->setTitle($title);
    $page->setContent($content);
    $page->setExtracontent($extracontent);
    $page->setCustomData(zp_apply_filter('save_page_custom_data', $custom, $page));
    $page->setShow($show);
    $page->setDateTime($date);
    $page->setLastChange($date);
    $page->setCommentsAllowed($commentson);
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $page->setCodeblock($codeblock);
    }
    $page->setAuthor($author);
    $page->setPermalink($permalink);
    $page->setLocked($locked);
    $page->setExpiredate($expiredate);
    if (getcheckboxState('resethitcounter')) {
        $page->set('hitcounter', 0);
    }
    if (getcheckboxState('reset_rating')) {
        $page->set('total_value', 0);
        $page->set('total_votes', 0);
        $page->set('used_ips', 0);
    }
    processTags($page);
    if ($newpage) {
        $page->setDefaultSortorder();
        $msg = zp_apply_filter('new_page', '', $page);
        if (empty($title)) {
            $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>';
        } else if ($notice == '?mismatch=user') {
            $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
        } else if ($notice) {
            $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> added"), $titlelink) . '</p>';
        }
    } else {
        $page->setLastchangeUser($_zp_current_admin_obj->getUser());
        $msg = zp_apply_filter('update_page', '', $page, $oldtitlelink);
        if (!$rslt) {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A page with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
        } else if (empty($title)) {
            $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>';
        } else if ($notice == '?mismatch=user') {
            $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Page user') . '</p>';
        } else if ($notice) {
            echo "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Page <em>%s</em> updated"), $titlelink) . '</p>';
        }
    }
    $checkupdates = true;
    if ($newpage) { 
        $checkupdates = false;
    }
    $page->save($checkupdates);
    if ($msg) {
        $reports[] = $msg;
    }
    return $page;
}

/**
 * Deletes a page (and also if existing its subpages) from the database
 *
 */
function deletePage($titlelink) {
    if (is_object($titlelink)) {
        $obj = $titlelink;
    } else {
        $obj = new ZenpagePage($titlelink);
    }
    $result = $obj->remove();
    if ($result) {
        if (is_object($titlelink)) {
            redirectURL(FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-pages.php?deleted');
        }
        SearchEngine::clearSearchCache();
        return "<p class='messagebox fade-message'>" . gettext("Page successfully deleted!") . "</p>";
    }
    return "<p class='errorbox fade-message'>" . gettext("Page delete failed!") . "</p>";
}

/**
 * Prints the table part of a single page item for the sortable pages list
 *
 * @param object $page The array containing the single page
 * @param bool $flag set to true to flag the element as having a problem with nesting level
 */
function printPagesListTable($page, $flag) {
    if ($flag) {
        $img = '../../images/drag_handle_flag.png';
    } else {
        $img = '../../images/drag_handle.png';
    }
    ?>
    <div class='page-list_row'>
        <div class="page-list_title">
            <?php
            if (checkIfLockedPage($page)) {
                echo "<a href='admin-edit.php?page&amp;titlelink=" . urlencode($page->getTitlelink()) . "'> ";
                checkForEmptyTitle($page->getTitle(), "page");
                echo "</a>" . checkHitcounterDisplay($page->getHitcounter());
            } else {
                checkForEmptyTitle($page->getTitle(), "page");
                checkHitcounterDisplay($page->isPublished());
            }
            ?>
        </div>
        <div class="page-list_extra">
            <span>
                <?php echo html_encode($page->getAuthor()); ?>
            </span>
        </div>
        <div class="page-list_extra">
            <?php printPublished($page); ?>
        </div>
        <div class="page-list_extra">
            <?php printExpired($page); ?>
        </div>
        <div class="page-list_iconwrapper">
            <div class="page-list_icon">
                <?php
                if ($page->getPassword()) {
                    echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
                }
                ?>
            </div>

            <?php if (checkIfLockedPage($page)) { ?>
                <div class="page-list_icon">
                    <?php printPublishIconLink($page, "page"); ?>
                </div>
                <?php if(extensionEnabled('comment_form')) { ?>
                    <div class="page-list_icon">
                        <?php
                            if ($page->getCommentsAllowed()) {
                                ?>
                                <a href="?commentson=0&amp;titlelink=<?php echo html_encode($page->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Disable comments'); ?>">
                                    <img src="../../images/comments-on.png" alt="" title="<?php echo gettext("Comments on"); ?>" style="border: 0px;"/>
                                </a>
                                <?php
                            } else {
                                ?>
                                <a href="?commentson=1&amp;titlelink=<?php echo html_encode($page->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo gettext('Enable comments'); ?>">
                                    <img src="../../images/comments-off.png" alt="" title="<?php echo gettext("Comments off"); ?>" style="border: 0px;"/>
                                </a>
                                <?php
                            }
                        ?>
                    </div>
                <?php } ?>
            <?php } else { ?>
                <div class="page-list_icon">
                    <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
                </div>
                <div class="page-list_icon">
                    <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
                </div>
            <?php } ?>

            <div class="page-list_icon">
                <a href="../../../index.php?p=pages&amp;title=<?php echo js_encode($page->getTitlelink()); ?>" title="<?php echo gettext("View page"); ?>">
                    <img src="images/view.png" alt="" title="<?php echo gettext("view"); ?>" />
                </a>
            </div>

            <?php
            if (checkIfLockedPage($page)) {
                if (extensionEnabled('hitcounter')) {
                    ?>
                    <div class="page-list_icon">
                        <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"); ?>">
                            <img src="../../images/reset.png" alt="" title="<?php echo gettext("Reset hitcounter"); ?>" /></a>
                    </div>
                    <?php
                }
                ?>
                <div class="page-list_icon">
                    <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"); ?>">
                        <img src="../../images/fail.png" alt="" title="<?php echo gettext("delete"); ?>" /></a>
                </div>
                <div class="page-list_icon">
                    <input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $page->getTitlelink(); ?>" onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
                </div>
            <?php } else { ?>
                <div class="page-list_icon">
                    <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
                </div>
                <div class="page-list_icon">
                    <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
                </div>
                <div class="page-list_icon">
                    <img src="../../images/icon_inactive.png" alt="" title="<?php gettext('locked'); ?>" />
                </div>
            <?php } ?>
        </div><!--  icon wrapper end -->
    </div>
    <?php
}

/* * ************************
  /* news article functions
 * ************************* */

/**
 * Updates or adds a news article and returns the object of that article
 *
 * @param array $reports display
 * @param bool $newarticle true if a new article
 *
 * @return object
 */
function updateArticle(&$reports, $newarticle = false) {
    global $_zp_current_admin_obj;
    $date = date('Y-m-d_H-i-s');
    $title = process_language_string_save("title", 2);
    $author = sanitize($_POST['author']);
    $content = updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
    $extracontent = updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
    $custom = process_language_string_save("custom_data", 1);
    $show = getcheckboxState('show');
    $date = sanitize($_POST['date']);
    $expiredate = getExpiryDatePost();
    $permalink = getcheckboxState('permalink');
    $commentson = getcheckboxState('commentson');
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $codeblock = processCodeblockSave(0);
    }
    $locked = getcheckboxState('locked');
    if ($newarticle) {
        $titlelink = createTitlelink($title, $date);
        if(getOption('zenpage_titlelinkdate_articles')) {
            $titlelink = addDateToTitlelink($titlelink);
        }
        $duplicate = checkTitlelinkDuplicate($titlelink, 'article');
        if ($duplicate) {
            //already exists
            $titlelink = addDateToTitlelink($titlelink);
            $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate article title') . '</p>';
        }
        $oldtitlelink = $titlelink;
        $id = 0;
    } else {
        $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
        $id = sanitize($_POST['id']);
    }

    if (getcheckboxState('edittitlelink')) {
        $titlelink = sanitize($_POST['titlelink'], 3);
        if (empty($titlelink)) {
            $titlelink = createTitlelink($title, $date);
        }
    } else {
        if (!$permalink) { //   allow the title link to change.
            $link = seoFriendly(get_language_string($title));
            if (!empty($link)) {
                $titlelink = $link;
            }
        }
    }

    $rslt = true;
    if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
        $rslt = query('UPDATE ' . prefix('news') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$rslt) {
            $titlelink = $oldtitlelink; // force old link so data gets saved
        } else {
            SearchEngine::clearSearchCache();
        }
    }
    // update article
    $article = new ZenpageNews($titlelink, true);
    $article->setTitle($title);
    $article->setContent($content);
    $article->setExtracontent($extracontent);
    $article->setCustomData(zp_apply_filter('save_article_custom_data', $custom, $article));
    $article->setShow($show);
    $article->setDateTime($date);
    $article->setLastChange($date);
    $article->setCommentsAllowed($commentson);
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $article->setCodeblock($codeblock);
    }
    $article->setAuthor($author);
    $article->setPermalink($permalink);
    $article->setLocked($locked);
    $article->setExpiredate($expiredate);
    $article->setSticky(sanitize_numeric($_POST['sticky']));
    if (getcheckboxState('resethitcounter')) {
        $article->set('hitcounter', 0);
    }
    if (getcheckboxState('reset_rating')) {
        $article->set('total_value', 0);
        $article->set('total_votes', 0);
        $article->set('used_ips', 0);
    }
    $article->setTruncation(getcheckboxState('truncation'));
    processTags($article);
    $categories = array();
    $result2 = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
    foreach ($result2 as $cat) {
        if (isset($_POST["cat" . $cat['id']])) {
            $categories[] = $cat['titlelink'];
        }
    }
    $article->setCategories($categories);
    if (!$newarticle) {
        $article->setLastchangeUser($_zp_current_admin_obj->getUser());
    }
    if ($newarticle) {
        $msg = zp_apply_filter('new_article', '', $article);
        if (empty($title)) {
            $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>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> added"), $titlelink) . '</p>';
        }
    } else {
        $msg = zp_apply_filter('update_article', '', $article, $oldtitlelink);
        if (!$rslt) {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("An article with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
        } else if (empty($title)) {
            $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>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated"), $titlelink) . '</p>';
        }
    }
    $checkupdates = true;
    if($newarticle) {
        $checkupdates = false;
    }
    $article->save($checkupdates);
    if ($msg) {
        $reports[] = $msg;
    }
    return $article;
}

/**
 * Deletes an news article from the database
 *
 */
function deleteArticle($titlelink) {
    if (is_object($titlelink)) {
        $obj = $titlelink;
    } else {
        $obj = new ZenpageNews($titlelink);
    }
    $result = $obj->remove();
    if ($result) {
        if (is_object($titlelink)) {
            redirectURL(FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-news-articles.php?deleted');
        }
        SearchEngine::clearSearchCache();
        return "<p class='messagebox fade-message'>" . gettext("Article successfully deleted!") . "</p>";
    }
    return "<p class='errorbox fade-message'>" . gettext("Article delete failed!") . "</p>";
}

/**
 * Print the categories of a news article for the news articles list
 *
 * @param obj $obj object of the news article
 */
function printArticleCategories($obj) {
  $cat = $obj->getCategories();
  $number = 0;
  foreach ($cat as $cats) {
    $number++;
    if ($number != 1) {
      echo ", ";
    }
    echo get_language_string($cats['title']);
  }
}

/**
 * Print the categories of a news article for the news articles list
 *
 * @param obj $obj object of the news article
 */
function printPageArticleTags($obj) {
    $tags = $obj->getTags();
    $number = 0;
    foreach ($tags as $tag) {
        $number++;
        if ($number != 1) {
            echo ", ";
        }
        echo get_language_string($tag);
    }
}

/**
 * Prints the checkboxes to select and/or show the category of an news article on the edit or add page
 *
 * @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.
 * @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.
 */
function printCategorySelection($id = '', $option = '') {
    global $_zp_zenpage;

    $selected = '';
    echo "<ul class='zenpagechecklist'>\n";
    $all_cats = $_zp_zenpage->getAllCategories(false);
    foreach ($all_cats as $cats) {
        $catobj = new ZenpageCategory($cats['titlelink']);
        if ($option != "all") {
            $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $id . " AND cat_id = " . $catobj->getID());
            if (isset($cat2news['cat_id']) && !empty($cat2news['cat_id'])) {
                $selected = "checked ='checked'";
            }
        }
        $catname = $catobj->getTitle();
        $catlink = $catobj->getTitlelink();
        if ($catobj->getPassword()) {
            $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
        } else {
            $protected = '';
        }
        $catid = $catobj->getID();
        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";
    }
    echo "</ul>\n";
}

/**
 * Prints the dropdown menu for the date archive selector for the news articles list
 *
 */
function printArticleDatesDropdown() {
    global $_zp_zenpage, $subpage;
    $datecount = $_zp_zenpage->getAllArticleDates();
    $lastyear = "";
    $nr = "";
    $option = getNewsAdminOption(array('category' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
    if (!isset($_GET['date'])) {
        $selected = 'selected="selected"';
    } else {
        $selected = "";
    }
    ?>
    <form name="articledatesdropdown" id="articledatesdropdown" style="float:left; margin-left: 10px;" action="#" >
        <select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
            <?php
            echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('' => ''), $option)) . "'>" . gettext("View all months") . "</option>";
            foreach($datecount as $key => $val) {
                $nr++;
                if ($key == '0000-00-01') {
                    $year = "no date";
                    $month = "";
                } else {
                    $dt = strftime('%Y-%B', strtotime($key));
                    $year = substr($dt, 0, 4);
                    $month = substr($dt, 5);
                }
                if (isset($_GET['category'])) {
                    $catlink = "&amp;category=" . sanitize($_GET['category']);
                } else {
                    $catlink = "";
                }
                $check = $month . "-" . $year;
                if (isset($_GET['date']) AND $_GET['date'] == substr($key, 0, 7)) {
                    $selected = "selected='selected'";
                } else {
                    $selected = "";
                }
                echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('date' => substr($key, 0, 7)), $option)) . "'>$month $year ($val)</option>\n";
            }
            ?>
        </select>
    </form>
    <?php
}

/**
 *
 * Compiles an option parameter list
 * @param array $test array of parameter=>type elements. type=0:string type=1:numeric
 * @return array
 */
function getNewsAdminOption($test) {
    $list = array();
    foreach ($test as $item => $type) {
        if (isset($_GET[$item])) {
            if ($type) {
                $list[$item] = (int) sanitize_numeric($_GET[$item]);
            } else {
                $list[$item] = sanitize($_GET[$item]);
            }
        }
    }
    return $list;
}

/**
 * Creates the admin paths for news articles if you use the dropdowns on the admin news article list together
 *
 * @param array $list an parameter array of item=>value for instance, the result of getNewsAdminOption()
 * @return string
 */
function getNewsAdminOptionPath($list) {
    $optionpath = '';
    $char = '?';
    foreach ($list as $p => $q) {
        if ($q) {
            $optionpath .= $char . $p . '=' . $q;
        } else {
            $optionpath .= $char . $p;
        }
        $char = '&amp;';
    }
    return $optionpath;
}

/**
 * Prints the dropdown menu for the published/un-publishd selector for the news articles list
 *
 */
function printUnpublishedDropdown() {
    global $_zp_zenpage;
    ?>
    <form name="unpublisheddropdown" id="unpublisheddropdown" style="float: left; margin-left: 10px;"   action="#">
        <select name="ListBoxURL" size="1"  onchange="zp_gotoLink(this.form)">
            <?php
            $all = "";
            $published = "";
            $unpublished = "";
            $sticky = '';
            if (isset($_GET['published'])) {
                switch ($_GET['published']) {
                    case "no":
                        $unpublished = "selected='selected'";
                        break;
                    case "yes":
                        $published = "selected='selected'";
                        break;
                    case 'sticky':
                        $sticky = "selected='selected'";
                        break;
                }
            } else {
                $all = "selected='selected'";
            }
            $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
            echo "<option $all value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All articles") . "</option>\n";
            echo "<option $published value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'yes'), $option)) . "'>" . gettext("Published") . "</option>\n";
            echo "<option $unpublished value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'no'), $option)) . "'>" . gettext("Un-published") . "</option>\n";
            echo "<option $sticky value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('published' => 'sticky'), $option)) . "'>" . gettext("Sticky") . "</option>\n";
            ?>
        </select>
    </form>
    <?php
}

/**
 * Prints the dropdown menu for the sortorder selector for the news articles list
 *
 */
function printSortOrderDropdown() {
    global $_zp_zenpage;
    ?>
    <form name="sortorderdropdown" id="sortorderdropdown" style="float: left; margin-left: 10px;"   action="#">
        <select name="ListBoxURL" size="1"  onchange="zp_gotoLink(this.form)">
            <?php
            $orderdate_desc = '';
            $orderdate_asc = '';
            $ordertitle_desc = '';
            $ordertitle_asc = '';
            $orderlastchange_desc = '';
            $orderlastchange_asc = '';
            if (isset($_GET['sortorder'])) {
                switch ($_GET['sortorder']) {
                    case "date-desc":
                        $orderdate_desc = "selected='selected'";
                        break;
                    case "date-asc":
                        $orderdate_asc = "selected='selected'";
                        break;
                    case "title-desc":
                        $ordertitle_desc = "selected='selected'";
                        break;
                    case "title-asc":
                        $ordertitle_asc = "selected='selected'";
                        break;
                    case "lastchange-desc":
                        $orderlastchange_desc = "selected='selected'";
                        break;
                    case "lastchange-asc":
                        $orderlastchange_asc = "selected='selected'";
                        break;
                }
            } else {
                $orderdate_desc = "selected='selected'";
            }
            $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'articles_page' => 1, 'author' => 0));
            echo "<option $orderdate_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-desc'), $option)) . "'>" . gettext("Order by date descending") . "</option>\n";
            echo "<option $orderdate_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'date-asc'), $option)) . "'>" . gettext("Order by date ascending") . "</option>\n";
            echo "<option $ordertitle_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-desc'), $option)) . "'>" . gettext("Order by title descending") . "</option>\n";
            echo "<option $ordertitle_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'title-asc'), $option)) . "'>" . gettext("Order by title ascending") . "</option>\n";
            echo "<option $orderlastchange_desc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'lastchange-desc'), $option)) . "'>" . gettext("Order by last change date descending") . "</option>\n";
            echo "<option $orderlastchange_asc value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('sortorder' => 'lastchange-asc'), $option)) . "'>" . gettext("Order by last change date ascending") . "</option>\n";
            ?>
        </select>
    </form>
    <?php
}

/**
 * Prints the dropdown menu for the category selector for the news articles list
 *
 */
function printCategoryDropdown() {
    global $_zp_zenpage;
    $result = $_zp_zenpage->getAllCategories(false);
    if (isset($_GET['date'])) {
        $datelink = "&amp;date=" . sanitize($_GET['date']);
        $datelinkall = "?date=" . sanitize($_GET['date']);
    } else {
        $datelink = "";
        $datelinkall = "";
    }

    if (isset($_GET['category'])) {
        $selected = '';
        $category = sanitize($_GET['category']);
    } else {
        $selected = "selected='selected'";
        $category = "";
    }
    ?>
    <form name ="categorydropdown" id="categorydropdown" style="float:left" action="#" >
        <select name="ListBoxURL" size="1" onchange="zp_gotoLink(this.form)">
            <?php
            $option = getNewsAdminOption(array('date' => 0, 'published' => 0, 'sortorder' => 0, 'articles_page' => 1, 'author' => 0));
            echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath($option) . "'>" . gettext("All categories") . "</option>\n";

            foreach ($result as $cat) {
                $catobj = new ZenpageCategory($cat['titlelink']);
                // check if there are articles in this category. If not don't list the category.
                $count = count($catobj->getArticles(0, 'all'));
                $count = " (" . $count . ")";
                if ($category == $cat['titlelink']) {
                    $selected = "selected='selected'";
                } else {
                    $selected = "";
                }
                //This is much easier than hacking the nested list function to work with this
                $getparents = $catobj->getParents();
                $levelmark = '';
                foreach ($getparents as $parent) {
                    $levelmark .= '» ';
                }
                $title = $catobj->getTitle();
                if (empty($title)) {
                    $title = '*' . $catobj->getTitlelink() . '*';
                }
                if ($count != " (0)") {
                    echo "<option $selected value='admin-news-articles.php" . getNewsAdminOptionPath(array_merge(array('category' => $catobj->getTitlelink()), $option)) . "'>" . $levelmark . $title . $count . "</option>\n";
                }
            }
            ?>
        </select>
    </form>
    <?php
}

/**
 * Prints the dropdown menu for the articles per page selector for the news articles list
 *
 */
function printArticlesPerPageDropdown($subpage, $articles_page) {
    global $_zp_zenpage;
    ?>
    <form name="articlesperpagedropdown" id="articlesperpagedropdown" method="POST" style="float: left; margin-left: 10px;" action="#">
        <select name="ListBoxURL" size="1"  onchange="zp_gotoLink(this.form)">
            <?php
            $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'sortorder' => 0, 'author' => 0));
            $list = array_unique(array(15, 30, 60, max(1, getOption('articles_per_page'))));
            sort($list);
            foreach ($list as $count) {
                ?>
                <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>
                <?php
            }
            ?>
            <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>

        </select>
        &nbsp;&nbsp;
    </form>
    <?php
}

/**
 * Prints the dropdown menu all authors that currently are authors of news articles
 */
function printAuthorDropdown() {
    $authors = Zenpage::getAllAuthors();
    $selected = "selected='selected'";
    if (isset($_GET['author'])) {
        $current_author = sanitize($_GET['author']);
    } else {
        $current_author = "";
    }
    ?>
    <form name="newssauthorsdropdown" id="newssauthorsdropdown" method="POST" style="float: left; margin-left: 10px;"   action="#">
        <select name="ListBoxURL" size="1"  onchange="zp_gotoLink(this.form)">
            <?php
            $option = getNewsAdminOption(array('category' => 0, 'date' => 0, 'published' => 0, 'articles_page' => 1, 'sortorder' => 0));            
            foreach ($authors as $author) {
                ?>
                <option <?php if ($current_author == $author) echo $selected; ?>value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('author' => $author), $option)); ?>"><?php echo $author; ?></option>
                <?php
            }
            ?>
            <option <?php if ($current_author == 'all') echo $selected; ?>value="admin-news-articles.php<?php echo getNewsAdminOptionPath(array_merge(array('author' => 'all'), $option)); ?>"><?php echo gettext("All authors"); ?></option>
        </select>
        &nbsp;&nbsp;
    </form>
    <?php
}

/* * ************************
  /* Category functions
 * ************************* */

/**
 * Updates or adds a category
 *
 * @param array $reports the results display
 * @param bool $newcategory true if a new article
 *
 */
function updateCategory(&$reports, $newcategory = false) {
    global $_zp_zenpage, $_zp_current_admin_obj;
    $date = date('Y-m-d_H-i-s');
    $id = sanitize_numeric($_POST['id']);
    $permalink = getcheckboxState('permalink');
    $title = process_language_string_save("title", 2);
    $desc = process_language_string_save("desc", EDITOR_SANITIZE_LEVEL);
    $custom = process_language_string_save("custom_data", 1);
    if ($newcategory) {
        $titlelink = createTitlelink($title, $date);
        if(getOption('zenpage_titlelinkdate_categories')) {
            $titlelink = addDateToTitlelink($titlelink);
        }
        $duplicate = checkTitlelinkDuplicate($titlelink, 'category');
        if ($duplicate) {
            //already exists
            $titlelink = addDateToTitlelink($titlelink);
            $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate category title') . '</p>';
        }
        $oldtitlelink = $titlelink;
    } else {
        $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
        if (getcheckboxState('edittitlelink')) {
            $titlelink = sanitize($_POST['titlelink'], 3);
            if (empty($titlelink)) {
                $titlelink = createTitlelink($title, $date);
            }
        } else {
            if (!$permalink) { //   allow the link to change
                $link = seoFriendly(get_language_string($title));
                if (!empty($link)) {
                    $titlelink = $link;
                }
            }
        }
    }
    $titleok = true;
    if ($titlelink != $oldtitlelink) { // title link change must be reflected in DB before any other updates
        $titleok = query('UPDATE ' . prefix('news_categories') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$titleok) {
            $titlelink = $oldtitlelink; // force old link so data gets saved
        } else {
            SearchEngine::clearSearchCache();
        }
    }
    //update category
    $show = getcheckboxState('show');
    $cat = new ZenpageCategory($titlelink, true);
    $notice = processCredentials($cat);
    $cat->setPermalink(getcheckboxState('permalink'));
    $cat->set('title', $title);
    $cat->setDesc($desc);
    $cat->setLastChange();
    $cat->setCustomData(zp_apply_filter('save_category_custom_data', $custom, $cat));
    $cat->setShow($show);
    if (getcheckboxState('resethitcounter')) {
        $cat->set('hitcounter', 0);
    }
    if (getcheckboxState('reset_rating')) {
        $cat->set('total_value', 0);
        $cat->set('total_votes', 0);
        $cat->set('used_ips', 0);
    }
    if ($newcategory) {
        $cat->setDefaultSortorder();
        $msg = zp_apply_filter('new_category', '', $cat);
        if (empty($title)) {
            $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>';
        } else if ($notice == '?mismatch=user') {
            $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
        } else if ($notice) {
            $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Category <em>%s</em> added"), $titlelink) . '</p>';
        }
    } else {
        $cat->setLastchangeUser($_zp_current_admin_obj->getUser());
        $msg = zp_apply_filter('update_category', '', $cat, $oldtitlelink);
        if ($titleok) {
            if (empty($titlelink) OR empty($title)) {
                $reports[] = "<p class='errorbox fade-message'>" . gettext("You forgot to give your category a <strong>title or titlelink</strong>!") . "</p>";
            } else if ($notice == '?mismatch=user') {
                $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
            } else if ($notice) {
                $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
            } else {
                $reports[] = "<p class='messagebox fade-message'>" . gettext("Category updated!") . "</p>";
            }
        } else {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A category with the title/titlelink <em>%s</em> already exists!"), html_encode($cat->getTitle())) . "</p>";
        }
    }
    $checkupdates = true;
    if ($newcategory) { 
        $checkupdates = false;
    }
    $cat->save($checkupdates);
    if ($msg) {
        $reports[] = $msg;
    }
    return $cat;
}

/**
 * Deletes a category (and also if existing its subpages) from the database
 *
 */
function deleteCategory($titlelink) {
    $obj = new ZenpageCategory($titlelink);
    $result = $obj->remove();
    if ($result) {
        SearchEngine::clearSearchCache();
        return "<p class='messagebox fade-message'>" . gettext("Category successfully deleted!") . "</p>";
    }
    return "<p class='errorbox fade-message'>" . gettext("Category  delete failed!") . "</p>";
}

/**
 * Prints the list entry of a single category for the sortable list
 *
 * @param array $cat Array storing the db info of the category
 * @param string $flag If the category is protected
 * @return string
 */
function printCategoryListSortableTable($cat, $flag) {
    global $_zp_zenpage;
    if ($flag) {
        $img = '../../images/drag_handle_flag.png';
    } else {
        $img = '../../images/drag_handle.png';
    }
    $count = count($cat->getArticles(0, false));
    if ($cat->getTitle()) {
        $cattitle = $cat->getTitle();
    } else {
        $cattitle = "<span style='color:red; font-weight: bold'> <strong>*</strong>" . $cat->getTitlelink() . "*</span>";
    }
    ?>
    <div class='page-list_row'>
        <div class='page-list_title' >
            <?php echo "<a href='admin-edit.php?newscategory&amp;titlelink=" . $cat->getTitlelink() . "' title='" . gettext('Edit this category') . "'>" . $cattitle . "</a>" . checkHitcounterDisplay($cat->getHitcounter()); ?>
        </div>
        <div class="page-list_extra">
            <?php echo $count; ?>
            <?php echo gettext("articles"); ?>
        </div>

        <div class="page-list_iconwrapper">
            <div class="page-list_icon"><?php
                $password = $cat->getPassword();
                if (!empty($password)) {
                    echo '<img src="../../images/lock.png" style="border: 0px;" alt="' . gettext('Password protected') . '" title="' . gettext('Password protected') . '" />';
                }
                ?>
            </div>
            <div class="page-list_icon">
                <?php
                if ($cat->isPublished()) {
                    $title = gettext("Un-publish");
                    ?>
                    <a href="?publish=0&amp;titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
                        <img src="../../images/pass.png" alt="<?php gettext("Scheduled for published"); ?>" title="<?php echo $title; ?>" /></a>
                    <?php
                } else {
                    $title = gettext("Publish");
                    ?>
                    <a href="?publish=1&amp;titlelink=<?php echo html_encode($cat->getTitlelink()); ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>" title="<?php echo $title; ?>">
                        <img src="../../images/action.png" alt="<?php echo gettext("Un-published"); ?>" title="<?php echo $title; ?>" /></a>
                    <?php
                }
                ?>
            </div>
            <div class="page-list_icon">
                <?php if ($count == 0) { ?>
                    <img src="../../images/icon_inactive.png" alt="<?php gettext('locked'); ?>" />
                    <?php
                } else {
                    ?>
                    <a href="../../../index.php?p=news&amp;category=<?php echo js_encode($cat->getTitlelink()); ?>" title="<?php echo gettext("View category"); ?>">
                        <img src="images/view.png" alt="view" />
                    </a>
                <?php } ?>
            </div>
            <?php
            if (extensionEnabled('hitcounter')) {
                ?>
                <div class="page-list_icon"><a
                        href="?hitcounter=1&amp;id=<?php echo $cat->getID(); ?>&amp;tab=categories&amp;XSRFToken=<?php echo getXSRFToken('hitcounter') ?>"
                        title="<?php echo gettext("Reset hitcounter"); ?>"> <img
                            src="../../images/reset.png"
                            alt="<?php echo gettext("Reset hitcounter"); ?>" /> </a>
                </div>
                <?php
            }
            ?>
            <div class="page-list_icon"><a
                    href="javascript:confirmDelete('admin-categories.php?delete=<?php echo js_encode($cat->getTitlelink()); ?>&amp;tab=categories&amp;XSRFToken=<?php echo getXSRFToken('delete_category') ?>',deleteCategory)"
                    title="<?php echo gettext("Delete Category"); ?>"><img
                        src="../../images/fail.png" alt="<?php echo gettext("Delete"); ?>"
                        title="<?php echo gettext("Delete Category"); ?>" /></a>
            </div>
            <div class="page-list_icon"><input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $cat->getTitlelink(); ?>"
                                                                                 onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" />
            </div>
        </div>
    </div>
    <?php
}

/**
 * Prints the checkboxes to select and/or show the category of an news article on the edit or add page
 *
 * @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.
 * @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.
 */
function printCategoryCheckboxListEntry($cat, $articleid, $option, $class = '') {
    $selected = '';
    if (($option != "all") && !$cat->transient && !empty($articleid)) {
        $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $articleid . " AND cat_id = " . $cat->getID());
        $selected = "";
        if (isset($cat2news['cat_id']) && !empty($cat2news['cat_id'])) {
            $selected = "checked ='checked'";
        }
    }
    $catname = $cat->getTitle();
    $catlink = $cat->getTitlelink();
    if ($cat->getPassword()) {
        $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
    } else {
        $protected = '';
    }
    $catid = $cat->getID();
    echo '<label for="cat' . $catid . '"><input name="cat' . $catid . '" class="' . $class . '" id="cat' . $catid . '" type="checkbox" value="' . $catid . '"' . $selected . ' />' . $catname . ' ' . $protected . "</label>\n";
}

/* * ************************
  /* General functions
 * ************************* */

/**
 * Prints the nested list for pages and categories
 *
 * @param string $listtype 'cats-checkboxlist' for a fake nested checkbock list of categories for the news article edit/add page
 *                                              'cats-sortablelist' for a sortable nested list of categories for the admin categories page
 *                                              'pages-sortablelist' for a sortable nested list of pages for the admin pages page
 * @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.
 * @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.
 * @return string | bool
 */
function printNestedItemsList($listtype = 'cats-sortablelist', $articleid = '', $option = '', $class = 'nestedItem') {
    global $_zp_zenpage;
    switch ($listtype) {
        case 'cats-checkboxlist':
        default:
            $ulclass = "";
            break;
        case 'cats-sortablelist':
        case 'pages-sortablelist':
            $ulclass = " class=\"page-list\"";
            break;
    }
    switch ($listtype) {
        case 'cats-checkboxlist':
        case 'cats-sortablelist':
            //Without this the order is incorrect until the 2nd page reload…
            $_zp_zenpage = new Zenpage();
            $items = $_zp_zenpage->getAllCategories(false);
            break;
        case 'pages-sortablelist':
            $items = $_zp_zenpage->getPages(false);
            break;
        default:
            $items = array();
            break;
    }
    //echo "<pre>"; print_r($items); echo "</pre>";
    $indent = 1;
    $open = array(1 => 0);
    $rslt = false;
    foreach ($items as $item) {
        switch ($listtype) {
            case 'cats-checkboxlist':
            case 'cats-sortablelist':
                $itemobj = new ZenpageCategory($item['titlelink']);
                $ismypage = $itemobj->isMyItem(ZENPAGE_NEWS_RIGHTS);
                break;
            case 'pages-sortablelist':
                $itemobj = new ZenpagePage($item['titlelink']);
                $ismypage = $itemobj->isMyItem(ZENPAGE_PAGES_RIGHTS);
                break;
        }
        $itemsortorder = $itemobj->getSortOrder();
        $itemid = $itemobj->getID();
        if ($ismypage) {
            $order = explode('-', $itemsortorder);
            $level = max(1, count($order));
            if ($toodeep = $level > 1 && $order[$level - 1] === '') {
                $rslt = true;
            }
            if ($level > $indent) {
                echo "\n" . str_pad("\t", $indent, "\t") . "<ul" . $ulclass . ">\n";
                $indent++;
                $open[$indent] = 0;
            } else if ($level < $indent) {
                while ($indent > $level) {
                    $open[$indent] --;
                    $indent--;
                    echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
                }
            } else { // indent == level
                if ($open[$indent]) {
                    echo str_pad("\t", $indent, "\t") . "</li>\n";
                    $open[$indent] --;
                } else {
                    echo "\n";
                }
            }
            if ($open[$indent]) {
                echo str_pad("\t", $indent, "\t") . "</li>\n";
                $open[$indent] --;
            }
            switch ($listtype) {
                case 'cats-checkboxlist':
                    echo "<li>\n";
                    printCategoryCheckboxListEntry($itemobj, $articleid, $option, $class);
                    break;
                case 'cats-sortablelist':
                    echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
                    printCategoryListSortableTable($itemobj, $toodeep);
                    break;
                case 'pages-sortablelist':
                    echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
                    printPagesListTable($itemobj, $toodeep);
                    break;
            }
            $open[$indent] ++;
        }
    }
    while ($indent > 1) {
        echo "</li>\n";
        $open[$indent] --;
        $indent--;
        echo str_pad("\t", $indent, "\t") . "</ul>";
    }
    if ($open[$indent]) {
        echo "</li>\n";
    } else {
        echo "\n";
    }
    return $rslt;
}

/**
 * Updates the sortorder of the items list in the database
 *
 * @param string $mode 'pages' or 'categories'
 * @return array
 */
function updateItemSortorder($mode = 'pages') {
    if (!empty($_POST['order'])) { // if someone didn't sort anything there are no values!
        $order = processOrder($_POST['order']);
        $parents = array('NULL');
        foreach ($order as $id => $orderlist) {
            $id = str_replace('id_', '', $id);
            $level = count($orderlist);
            $parents[$level] = $id;
            $myparent = $parents[$level - 1];
            switch ($mode) {
                case 'pages':
                    $dbtable = prefix('pages');
                    break;
                case 'categories':
                    $dbtable = prefix('news_categories');
                    break;
            }
            $sql = "UPDATE " . $dbtable . " SET `sort_order` = " . db_quote(implode('-', $orderlist)) . ", `parentid`= " . $myparent . " WHERE `id`=" . $id;
            query($sql);
        }
        return true;
    }
    return false;
}

/**
 * Checks if no title has been provide for items on new item creation
 * @param string $titlefield The title field
 * @param string $type 'page', 'news' or 'category'
 * @return string
 */
function checkForEmptyTitle($titlefield, $type, $truncate = true) {
    switch ($type) {
        case "page":
            $text = gettext("Untitled page");
            break;
        case "news":
            $text = gettext("Untitled article");
            break;
        case "category":
            $text = gettext("Untitled category");
            break;
    }
    $title = getBare($titlefield);
    if ($title) {
        if ($truncate) {
            $title = truncate_string($title, 40);
        }
    } else {
        $title = "<span style='color:red; font-weight: bold'>" . $text . "</span>";
    }
    echo $title;
}

/**
 * Publishes a page or news article
 *
 * @param object $obj
 * @param int $show the value for publishing
 * @return string
 */
function zenpagePublish($obj, $show) {
    global $_zp_current_admin_obj;
    $obj->setShow((int) ($show && 1));
    $obj->setLastchangeUser($_zp_current_admin_obj->getUser());
    $obj->save();
}

/**
 * Skips the scheduled future publishing by setting the date of a page or article to the current date to publish it immediately
 * or the expiration handling by setting the expiredate to null.
 *
 * @since ZenphotoCMS 1.5.7
 * @param object $obj
 * @param string $type "futuredate" or "expiredate"
 * @return string
 */
function skipScheduledPublishing($obj, $type = 'futuredate') {
    global $_zp_current_admin_obj;
    switch ($type) {
        case 'futuredate':
            $obj->setDateTime(date('Y-m-d H:i:s'));
            $obj->setShow(1);
            break;
        case 'expiredate':
            $obj->setExpiredate(null);
            $obj->setShow(1);
            break;
    }
    $obj->setLastchangeUser($_zp_current_admin_obj->getUser());
    $obj->save();
}

/**
 * Checks if there are hitcounts and if they are displayed behind the news article, page or category title
 *
 * @param string $item The array of the current news article, page or category in the list.
 * @return string
 */
function checkHitcounterDisplay($item) {
    if ($item == 0) {
        $hitcount = "";
    } else {
        if ($item == 1) {
            $hits = gettext("hit");
        } else {
            $hits = gettext("hits");
        }
        $hitcount = " (" . $item . " " . $hits . ")";
    }
    return $hitcount;
}

/**
 * returns an array of how many pages, articles, categories and news or pages comments we got.
 *
 * @param string $option What the statistic should be shown of: "news", "pages", "categories"
 */
function getNewsPagesStatistic($option) {
    global $_zp_zenpage;
    switch ($option) {
        case "news":
            $items = $_zp_zenpage->getArticles();
            $type = gettext("Articles");
            break;
        case "pages":
            $items = $_zp_zenpage->getPages(false);
            $type = gettext("Pages");
            break;
        case "categories":
            $type = gettext("Categories");
            $items = $_zp_zenpage->getAllCategories(false);
            break;
    }
    $total = count($items);
    $pub = 0;
    foreach ($items as $item) {
        switch ($option) {
            case "news":
                $itemobj = new ZenpageNews($item['titlelink']);
                break;
            case "pages":
                $itemobj = new ZenpagePage($item['titlelink']);
                break;
            case "categories":
                $itemobj = new ZenpageCategory($item['titlelink']);
                break;
        }
        if ($itemobj->isPublished()) {
            $pub++;
        }
    }
    $unpub = $total - $pub;
    return array($total, $type, $unpub);
}

function printPagesStatistic() {
    list($total, $type, $unpub) = getNewsPagesStatistic("pages");
    if (empty($unpub)) {
        printf(ngettext('<strong>%1$u</strong> page', '<strong>%1$u</strong> pages', $total), $total);
    } else {
        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);
    }
}

function printNewsStatistic() {
    list($total, $type, $unpub) = getNewsPagesStatistic("news");
    if (empty($unpub)) {
        printf(ngettext('<strong>%1$u</strong> article', '<strong>%1$u</strong> articles', $total), $total);
    } else {
        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);
    }
}

function printCategoriesStatistic() {
    list($total, $type, $unpub) = getNewsPagesStatistic("categories");
    if (empty($unpub)) {
        printf(ngettext('<strong>%1$u</strong> category', '<strong>%1$u</strong> categories', $total), $total);
    } else {
        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);
    }
}

/**
 * Prints the links to JavaScript and CSS files zenpage needs.
 * Actually the same as for zenphoto but with different paths since we are in the plugins folder.
 *
 * @param bool $sortable set to true for tabs with sorts.
 *
 */
function zenpageJSCSS() {
    ?>
    <link rel="stylesheet" href="zenpage.css" type="text/css" />
    <script type="text/javascript">
        // <!-- <![CDATA[
        $(document).ready(function() {
            $("#tip a").click(function() {
                $("#tips").toggle("slow");
            });
        });
        // ]]> -->
    </script>
    <?php
}

function printZenpageIconLegend() {
    ?>
    <ul class="iconlegend">
        <?php
        if (GALLERY_SECURITY == 'public') {
            ?>
            <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="" /><?php echo gettext("Published/Not published"); ?></li>
            <li><img src="../../images/clock_futuredate.png" alt="" /><img src="../../images/clock_expiredate.png" alt="" /><img src="../../images/clock_expired.png" alt="" /><?php echo gettext("Scheduled publishing/Scheduled expiration/Expired"); ?></li>
            <?php
        }
        ?>
        <li><img src="../../images/comments-on.png" alt="" /><img src="../../images/comments-off.png" alt="" /><?php echo gettext("Comments on/off"); ?></li>
        <li><img src="../../images/view.png" alt="" /><?php echo gettext("View"); ?></li>
        <?php
        if (extensionEnabled('hitcounter')) {
            ?>
            <li><img src="../../images/reset.png" alt="" /><?php echo gettext("Reset hitcounter"); ?></li>
            <?php
        }
        ?>
        <li><img src="../../images/fail.png" alt="" /><?php echo gettext("Delete"); ?></li>
    </ul>
    <?php
}

/**
 * Prints a dropdown to select the author of a page or news article (Admin rights users only)
 *
 * @param string $currentadmin The current admin is selected if adding a new article, otherwise the original author
 */
function authorSelector($author = NULL) {
    global $_zp_authority, $_zp_current_admin_obj;
    if (empty($author)) {
        $author = $_zp_current_admin_obj->getUser();
    }
    $authors = array($author => $author);
    if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS | MANAGE_ALL_NEWS_RIGHTS)) {
        $admins = $_zp_authority->getAdministrators();
        foreach ($admins as $admin) {
            if ($admin['rights'] & (ADMIN_RIGHTS | ZENPAGE_PAGES_RIGHTS | ZENPAGE_NEWS_RIGHTS)) {
                $authors[$admin['user']] = $admin['user'];
            }
        }
    }
    ?>
    <select size='1' name="author" id="author">
        <?php
        generateListFromArray(array($author), $authors, false, false);
        ?>
    </select>
    <?php
}



/**
 * Prints the publish/un-published/scheduled publishing icon with a link for the pages and news articles list.
 *
 * @param string $object Object of the page or news article to check
 * @return string
 */
function printPublishIconLink($object, $type, $linkback = '') {
    $urladd = '';
    if ($type == "news") {
        if (isset($_GET['subpage'])) {
            $urladd .= "&amp;subpage=" . sanitize($_GET['subpage']);
        }
        if (isset($_GET['date'])) {
            $urladd .= "&amp;date=" . sanitize($_GET['date']);
        }
        if (isset($_GET['category'])) {
            $urladd .= "&amp;category=" . sanitize($_GET['category']);
        }
        if (isset($_GET['sortorder'])) {
            $urladd .= "&amp;sortorder=" . sanitize($_GET['sortorder']);
        }
        if (isset($_GET['articles_page'])) {
            $urladd .= "&amp;articles_page=" . sanitize_numeric($_GET['articles_page']);
        }
    }
    if ($object->hasPublishSchedule()) {
        $title = gettext("Publish immediately (skip scheduling)");
        $alt = gettext("Scheduled for published");
        $action = '?skipscheduling=1';
        $icon = '../../images/clock_futuredate.png';
    } else if ($object->hasExpiration()) {
        $title = gettext("Skip scheduled expiration");
        $alt = gettext("Scheduled for expiration");
        $action = '?skipexpiration=1';
        $icon = '../../images/clock_expiredate.png';
    } else if ($object->isPublished()) {
        $title = gettext("Un-publish");
        $alt = gettext("Published");
        $action = '?publish=0';
        $icon = '../../images/pass.png';
    } else if (!$object->isPublished()) {
        if ($object->hasExpired()) {
            $title = gettext("Publish immediately (skip expiration)");
            $alt = gettext("Un-published because expired");
            $action = '?skipexpiration=1';
            $icon = '../../images/clock_expired.png';
        } else {
            $title = gettext("Publish");
            $alt = gettext("Un-published");
            $action = '?publish=1';
            $icon = '../../images/action.png';
        }
    }
    ?>
    <a href="<?php echo $action; ?>&amp;titlelink=<?php echo html_encode($object->getTitlelink()) . $urladd; ?>&amp;XSRFToken=<?php echo getXSRFToken('update') ?>">
        <img src="<?php echo $icon; ?>" alt="<?php echo $alt; ?>" title= "<?php echo $title; ?>" />
    </a>
    <?php
}


    /**
     * Checks if a checkbox is selected and checks it if.
     *
     * @param string $field the array field of an item array to be checked (for example "permalink" or "comments on")
     */
    function checkIfChecked($field) {
        if ($field) {
            echo 'checked="checked"';
        }
    }

    /**
     * Checks if the current logged in admin user is the author that locked the page/article.
     * Only that author or any user with admin rights will be able to edit or unlock.
     *
     * @param object $page The array of the page or article to check
     * @return bool
     */
    function checkIfLockedPage($page) {
        global $_zp_current_admin_obj;
        if (zp_loggedin(ADMIN_RIGHTS))
            return true;
        if ($page->getLocked()) {
            return $_zp_current_admin_obj->getUser() == $page->getAuthor() && $page->isMyItem(ZENPAGE_PAGES_RIGHTS);
        } else {
            return true;
        }
    }

    /**
     * Checks if the current logged in admin user is the author that locked the article.
     * Only that author or any user with admin rights will be able to edit or unlock.
     *
     * @param object $page The array of the page or article to check
     * @return bool
     */
    function checkIfLockedNews($news) {
        global $_zp_current_admin_obj;
        if (zp_loggedin(ADMIN_RIGHTS))
            return true;
            
        if ($news->getLocked()) {
            return $_zp_current_admin_obj->getUser() == $news->getAuthor() && $news->isMyItem(ZENPAGE_NEWS_RIGHTS);
        } else {
            return true;
        }
    }

    /**
     * Checks if the current admin-edit.php page is called for news articles or for pages.
     *
     * @param string $page What you want to check for, "page" or "newsarticle"
     * @return bool
     */
    function is_AdminEditPage($page) {
        return isset($_GET[$page]);
    }

    /**
     * Processes the check box bulk actions
     *
     */
    function processZenpageBulkActions($type) {
        global $_zp_zenpage, $_zp_current_admin_obj;
        $action = false;
        if (isset($_POST['ids'])) {
            //echo "action for checked items:". $_POST['checkallaction'];
            $action = sanitize($_POST['checkallaction']);
            $links = sanitize($_POST['ids']);
            $total = count($links);
            $message = NULL;
            $sql = '';
            if ($action != 'noaction') {
                if ($total > 0) {
                    if ($action == 'addtags' || $action == 'alltags') {
                        $tags = bulkTags();
                    }
                    if ($action == 'addcats') {
                        foreach ($_POST as $key => $value) {
                            $key = postIndexDecode($key);
                            if (substr($key, 0, 3) == 'cat') {
                                if ($value) {
                                    $cats[] = substr($key, 3);
                                }
                            }
                        }
                        $cats = sanitize($cats, 3);
                    }
                    $n = 0;
                    foreach ($links as $titlelink) {
                        $class = 'Zenpage' . $type;
                        $obj = new $class($titlelink);

                        switch ($action) {
                            case 'deleteall':
                                $obj->remove();
                                SearchEngine::clearSearchCache();
                                break;
                            case 'addtags':
                                $mytags = array_unique(array_merge($tags, $obj->getTags()));
                                $obj->setTags($mytags);
                                break;
                            case 'cleartags':
                                $obj->setTags(array());
                                break;
                            case 'alltags':
                                $allarticles = $obj->getArticles('', 'all', true);
                                foreach ($allarticles as $article) {
                                    $newsobj = new ZenpageNews($article['titlelink']);
                                    $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
                                    $newsobj->setTags($mytags);
                                    $newsobj->setLastchangeUser($_zp_current_admin_obj->getUser());
                                    $newsobj->save(true);
                                }
                                break;
                            case 'clearalltags':
                                $allarticles = $obj->getArticles('', 'all', true);
                                foreach ($allarticles as $article) {
                                    $newsobj = new ZenpageNews($article['titlelink']);
                                    $newsobj->setTags(array());
                                    $newsobj->setLastchangeUser($_zp_current_admin_obj->getUser());
                                    $newsobj->save(true);
                                }
                                break;
                            case 'addcats':
                                $catarray = array();
                                $allcats = $obj->getCategories();
                                foreach ($cats as $cat) {
                                    $catitem = $_zp_zenpage->getCategory($cat);
                                    $catarray[] = $catitem['titlelink']; //to use the setCategories method we need an array with just the titlelinks!
                                }
                                $allcatsarray = array();
                                foreach ($allcats as $allcat) {
                                    $allcatsarray[] = $allcat['titlelink']; //same here!
                                }
                                $mycats = array_unique(array_merge($catarray, $allcatsarray));
                                $obj->setCategories($mycats);
                                break;
                            case 'clearcats':
                                $obj->setCategories(array());
                                break;
                            case 'showall':
                                $obj->set('show', 1);
                                break;
                            case 'hideall':
                                $obj->set('show', 0);
                                break;
                            case 'commentson':
                                $obj->set('commentson', 1);
                                break;
                            case 'commentsoff':
                                $obj->set('commentson', 0);
                                break;
                            case 'resethitcounter':
                                $obj->set('hitcounter', 0);
                                break;
                        }
                        $obj->setLastchangeUser($_zp_current_admin_obj->getUser());
                        $obj->save(true);
                    }
                }
            }
        }
        return $action;
    }

    function zenpageBulkActionMessage($action) {
        switch ($action) {
            case 'deleteall':
                $message = gettext('Selected items deleted');
                break;
            case 'showall':
                $message = gettext('Selected items published');
                break;
            case 'hideall':
                $message = gettext('Selected items unpublished');
                break;
            case 'commentson':
                $message = gettext('Comments enabled for selected items');
                break;
            case 'commentsoff':
                $message = gettext('Comments disabled for selected items');
                break;
            case 'resethitcounter':
                $message = gettext('Hitcounter for selected items');
                break;
            case 'addtags':
                $message = gettext('Tags added to selected items');
                break;
            case 'cleartags':
                $message = gettext('Tags cleared from selected items');
                break;
            case 'alltags':
                $message = gettext('Tags added to articles of selected items');
                break;
            case 'clearalltags':
                $message = gettext('Tags cleared from articles of selected items');
                break;
            case 'addcats':
                $message = gettext('Categories added to selected items');
                break;
            case 'clearcats':
                $message = gettext('Categories cleared from selected items');
                break;
            default:
                return "<p class='notebox fade-message'>" . gettext('Nothing changed') . "</p>";
        }
        if (isset($message)) {
            return "<p class='messagebox fade-message'>" . $message . "</p>";
        }
        return false;
    }
    
    /**
     * Creates the titlelink from the title passed.
     * 
     * @since ZenphotoCMS 1.5.2
     * 
     * @param string|array $title The title respectively language array of titles
     * @param string $date The date the article is saved
     * @return type
     */
    function createTitlelink($title, $date) {
        $titlelink = seoFriendly(get_language_string($title));
        if (empty($titlelink)) {
            $titlelink = seoFriendly($date);
        }
        return $titlelink;
    }

    /**
     * Checks if a title link of this itemtype already exists
     * 
     * @since ZenphotoCMS 1.5.2
     * 
     * @param string $titlelink The titlelink to check
     * @param string $itemtype
     * @return bool
     */
    function checkTitlelinkDuplicate($titlelink, $itemtype) {
        switch ($itemtype) {
            case 'article':
                $table = prefix('news');
                break;
            case 'category':
                $table = prefix('news_categories');
                break;
            case 'page':
                $table = prefix('pages');
                break;
        }
        $sql = 'SELECT `id` FROM ' . $table . ' WHERE `titlelink`=' . db_quote($titlelink);
        $rslt = query_single_row($sql, false);
        return $rslt;
    }

    /**
     * Append or prepends a date string to a titlelink as defined.
     * Note: This does not check the item type option and will add to any string passed!
     * 
     * @since ZenphotoCMS 1.5.2
     * 
     * @param string $titlelink The titleink (e.g. as created by createTitleink())
     * @return string
     */
    function addDateToTitlelink($titlelink) {
        $addwhere = getOption('zenpage_titlelinkdate_location');
        $dateformat = getOption('zenpage_titlelinkdate_dateformat');
        switch($dateformat) {
            case 'Y-m-d':
            case 'Ymd':
            case 'Y-m-d_H-i-s':
            case 'YmdHis':
                $date = date($dateformat);
                break;
            default:
            case 'timestamp':
                $date = time();
                break;
    }
    switch ($addwhere) {
        case 'before':
            $titlelink = $date . '-' . $titlelink;
            break;
        default:
        case 'after':
            $titlelink = $titlelink . '-' . $date;
            break;
    }
    return $titlelink;
}
ZenphotoCMS 1.5.x API documentation generated by ApiGen