PubkitBlog main snippet code
The main pubKitBlog snippet code sets up the parameters and includes the main program files: pubKitBlog.inc.php, pubKit.functions.php and optionsbuilder.class.php. All of these are located in the assets/snippets/pubKit folder.
The Docmanager class file is also required - I keep this in the /libs folder, so the include reads:require_once($modx->config["base_path"] . 'assets/libs/docmanager/document.class.inc.php');
Note that this is Docmanager version 0.5.3 by ur001 (on MODx site as repo-883.zip under Previous Releases, not the version updated for MODx Revolution). Also that you should update the opening php tag to read <?php in case your server does not allow the <? shortcut tag in the original file.
<?php
#::::::::::::::::::::::::::::::::::::::::
#
# Snippet Name: PubKitBlog
# Short Desc: Publish blog items from front end
# Created By: Keith Penton (kp52)
#
# Version: 1.4.1
# 18 Sep 2009
#::::::::::::::::::::::::::::::::::::::::
# Description:
# Create and modify blog posts or news articles, with tagging
# Like NewsPublisher, but allowing for modification, custom
# fields in template variables etc. and easier to adapt
#::::::::::::::::::::::::::::::::::::::::
#
# Latest updates: 18 Sep 09 (code changes in include file))
# - placeholder to reproduce introtext in main content
# - bug fix for permalinks (use new doc's ID, not form's)
# - bug fix for tag retrieval (use raw "||" separator on tags re-edit))
#
# Parameters:
# &snipFolder - name of folder containing include files
# &folder - id of folder where posts are stored
# &postid - document id to load after posting news item. Defaults to the page created
# &prefix - string prefix for HTML anchors formed from this plus doc ID; default 'N'
# &canpost - comma delimited web groups that can post comments. leave blank for public posting
# &template - name of template to use for news post
# &formtpl - form template (chunk name or @FILE:name of file in pubKit/chunks/chunk.name.html)
# &rtcontent - name of a richtext content form field
# &rtsummary - name of a richtext summary form field
# &tags - name of (checkbox/radiobutton) TV containing tags. Default = 'pkTags'
# &delimiter - delimiter for tags list; default ||
# &tagFormat - name of CSS class to apply to span surrounding tags. No default
# &showinmenu - sets whether or not item shows in menus. Defaults to false (0)
# &permalinks - create aliases from title? Default = 1;
# &permaLength - max length of alias (but doc ID will be added to it). Default = 35;
# &cacheItem - make resource cacheable or not (e.g. for Ditto/PHx clash). Default = 1
# &clearcache - clear the site cache after publishing an article. Default = 1
# &debug - if 1, dump $_POST variables at top of form display. Default = 0
# ---------------------------------------------------------
# See changelog in docs folder for update history
# ------------------------------------------------------------#
$snipFolder = isset($snipFolder) ? $snipFolder : 'pubKit';
$snipPath = $modx->config['base_path'] . 'assets/snippets/' . $snipFolder.'/';
require_once($modx->config['base_path'] . 'assets/libs/docmanager/document.class.inc.php');
require_once($snipPath . 'optionsbuilder.class.php');
require_once($snipPath . 'pubKit.functions.php');
// get user groups that can post articles
$postgrp = isset($canpost) ? explode(",",$canpost) : array();
$allowAnyPost = count($postgrp)==0 ? true : false;
// cacheing options; reduce to one or zero
$clearcache = (isset($clearcache) && $clearcache == 0) ? 0 : 1;
$cacheable = (isset($cacheItem) && $cacheItem == 0) ? 0 : 1;
// showinmenu (negated for hidemenu, may be modified by form)
$showinmenu = (isset($showinmenu) && $showinmenu == 1) ? 1 : 0;
// get folder id where we should store articles
// else store in current document
$folder = isset($folder) ? intval($folder) : $modx->documentIdentifier;
// prefix for anchors
$prefix = isset($prefix) ? $prefix : 'N';
// name of TV containign tags (checkbox or radio buttons)
$tagTv = isset($tags) ? $tags : 'pkTags';
// class to apply to SPAN surrounding tag set
$tagFormat = isset($tagFormat) ? $tagFormat : '';
// delimiter for tags list. Default is || (as when no widget used)
$delimiter = isset($delimiter) ? $delimiter : '||';
// set rich text fields (add "tv" prefix if required)
if (isset($rtcontent)) {
if (substr($rtcontent,0,2) != 'tv' ) {
$rtcontent = 'tv' . $rtcontent;
}
} else {
$rtcontent = 'content';
}
if (isset($rtsummary)) {
if (substr($rtsummary,0,2) != 'tv' ) {
$rtsummary = 'tv' . $rtsummary;
}
} else {
$rtsummary = 'introtext';
}
// define tags that can be used in rich content
$allowedTags = '<p><br><a><i><em><b><strong><pre><table><th><td><tr><img>';
$allowedTags .= '<span><div><h1><h2><h3><h4><h5><font><ul><ol><li><dl><dt><dd>';
// get template
$template = isset($template) ? $template : $modx->config['default_template'];
// create aliases from title? default = 1; limit length
$permalinks = (isset($permalinks)) ? $permalinks : 1;
$permaLength = (isset($permaLength)) ? $permaLength : 35;
$debug = isset($debug) ? $debug : 0;
// main include file (needs to follow parameter settings)
require_once($snipPath . 'pubKitBlog.inc.php');
return $pubKit;
?>
#::::::::::::::::::::::::::::::::::::::::
#
# Snippet Name: PubKitBlog
# Short Desc: Publish blog items from front end
# Created By: Keith Penton (kp52)
#
# Version: 1.4.1
# 18 Sep 2009
#::::::::::::::::::::::::::::::::::::::::
# Description:
# Create and modify blog posts or news articles, with tagging
# Like NewsPublisher, but allowing for modification, custom
# fields in template variables etc. and easier to adapt
#::::::::::::::::::::::::::::::::::::::::
#
# Latest updates: 18 Sep 09 (code changes in include file))
# - placeholder to reproduce introtext in main content
# - bug fix for permalinks (use new doc's ID, not form's)
# - bug fix for tag retrieval (use raw "||" separator on tags re-edit))
#
# Parameters:
# &snipFolder - name of folder containing include files
# &folder - id of folder where posts are stored
# &postid - document id to load after posting news item. Defaults to the page created
# &prefix - string prefix for HTML anchors formed from this plus doc ID; default 'N'
# &canpost - comma delimited web groups that can post comments. leave blank for public posting
# &template - name of template to use for news post
# &formtpl - form template (chunk name or @FILE:name of file in pubKit/chunks/chunk.name.html)
# &rtcontent - name of a richtext content form field
# &rtsummary - name of a richtext summary form field
# &tags - name of (checkbox/radiobutton) TV containing tags. Default = 'pkTags'
# &delimiter - delimiter for tags list; default ||
# &tagFormat - name of CSS class to apply to span surrounding tags. No default
# &showinmenu - sets whether or not item shows in menus. Defaults to false (0)
# &permalinks - create aliases from title? Default = 1;
# &permaLength - max length of alias (but doc ID will be added to it). Default = 35;
# &cacheItem - make resource cacheable or not (e.g. for Ditto/PHx clash). Default = 1
# &clearcache - clear the site cache after publishing an article. Default = 1
# &debug - if 1, dump $_POST variables at top of form display. Default = 0
# ---------------------------------------------------------
# See changelog in docs folder for update history
# ------------------------------------------------------------#
$snipFolder = isset($snipFolder) ? $snipFolder : 'pubKit';
$snipPath = $modx->config['base_path'] . 'assets/snippets/' . $snipFolder.'/';
require_once($modx->config['base_path'] . 'assets/libs/docmanager/document.class.inc.php');
require_once($snipPath . 'optionsbuilder.class.php');
require_once($snipPath . 'pubKit.functions.php');
// get user groups that can post articles
$postgrp = isset($canpost) ? explode(",",$canpost) : array();
$allowAnyPost = count($postgrp)==0 ? true : false;
// cacheing options; reduce to one or zero
$clearcache = (isset($clearcache) && $clearcache == 0) ? 0 : 1;
$cacheable = (isset($cacheItem) && $cacheItem == 0) ? 0 : 1;
// showinmenu (negated for hidemenu, may be modified by form)
$showinmenu = (isset($showinmenu) && $showinmenu == 1) ? 1 : 0;
// get folder id where we should store articles
// else store in current document
$folder = isset($folder) ? intval($folder) : $modx->documentIdentifier;
// prefix for anchors
$prefix = isset($prefix) ? $prefix : 'N';
// name of TV containign tags (checkbox or radio buttons)
$tagTv = isset($tags) ? $tags : 'pkTags';
// class to apply to SPAN surrounding tag set
$tagFormat = isset($tagFormat) ? $tagFormat : '';
// delimiter for tags list. Default is || (as when no widget used)
$delimiter = isset($delimiter) ? $delimiter : '||';
// set rich text fields (add "tv" prefix if required)
if (isset($rtcontent)) {
if (substr($rtcontent,0,2) != 'tv' ) {
$rtcontent = 'tv' . $rtcontent;
}
} else {
$rtcontent = 'content';
}
if (isset($rtsummary)) {
if (substr($rtsummary,0,2) != 'tv' ) {
$rtsummary = 'tv' . $rtsummary;
}
} else {
$rtsummary = 'introtext';
}
// define tags that can be used in rich content
$allowedTags = '<p><br><a><i><em><b><strong><pre><table><th><td><tr><img>';
$allowedTags .= '<span><div><h1><h2><h3><h4><h5><font><ul><ol><li><dl><dt><dd>';
// get template
$template = isset($template) ? $template : $modx->config['default_template'];
// create aliases from title? default = 1; limit length
$permalinks = (isset($permalinks)) ? $permalinks : 1;
$permaLength = (isset($permaLength)) ? $permaLength : 35;
$debug = isset($debug) ? $debug : 0;
// main include file (needs to follow parameter settings)
require_once($snipPath . 'pubKitBlog.inc.php');
return $pubKit;
?>