Plugin Directory

Changeset 334363


Ignore:
Timestamp:
01/18/2011 11:02:55 PM (15 years ago)
Author:
beatpanda
Message:

Committed version 1.0. Temporary until we can fix Git/SVN integration.

Location:
wordpress-wiki
Files:
47 added
5 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • wordpress-wiki/trunk/lib/WPW_WikiParser.php

    r272690 r334363  
    33
    44class WPW_WikiParser extends WikiParser {
    5     //parent::WikiParser();
    6     function wiki_link($topic) {
    7         $wiki = get_page_by_title($topic);
     5    // 2011-01-02 arjen adjusted to deal with namespaces
     6    function wiki_link($topic,$namespace='') {
     7        global $wpdb;
     8        $wiki = $wpdb->get_var('SELECT `p`.`id` FROM `' . $wpdb->posts . '` `p` WHERE `p`.`post_type` = "wiki" AND `p`.`post_name` = "' . strtolower(preg_replace('/[ -]+/', '-', $topic)) .'"');
     9   
     10        if (!$wiki)
     11            return 'new?redlink=1&title='.($namespace ? $namespace.':' : '').$topic;
     12        else
     13            return ($namespace ? strtolower(preg_replace('/[ -]+/', '-', $namespace)).'/' : '') . strtolower(preg_replace('/[ -]+/', '-', $topic));
     14    }
     15   
     16    // 2011-01-02 arjen adjusted to deal with namespaces
     17    function handle_internallink($matches) {
     18        global $wpdb;
     19        $nolink = false;
     20
     21        $href = $matches[4];
     22        $title = $matches[6] ? $matches[6] : $href.$matches[7];
     23        $namespace = $matches[3];
     24
     25        if ($namespace=='Image') {
     26            $options = explode('|',$title);
     27            $title = array_pop($options);
     28
     29            return $this->handle_image($href,$title,$options);
     30        }
    831       
    9         if (!$wiki)
    10             return 'new?redlink=1&title='.$topic;
    11         else
    12             return strtolower(str_replace(' ','-',$topic));
    13     }
    14    
    15     function handle_internallink($matches) {
    16         //var_dump($matches);
    17         $nolink = false;
     32        $href = trim(preg_replace('/[^a-zA-Z0-9-\s]/', '', $href));
     33        $title = preg_replace('/\(.*?\)/','',$title);
     34        $title = preg_replace('/^.*?\:/','',$title);
     35        $wiki = $wpdb->get_var('SELECT `p`.`id` FROM `' . $wpdb->posts . '` `p` WHERE `p`.`post_type` = "wiki" AND `p`.`post_name` = "' . strtolower(preg_replace('/[ -]+/', '-', $href)) .'"');
     36
     37        if(!$wiki)
     38            $redlink = 'style="color:red"';
     39        else
     40            $redlink = false;
     41        if ($this->reference_wiki) {
     42            $href = $this->reference_wiki.$this->wiki_link($href,$namespace);
     43        } else {
     44            $nolink = true;
     45        }
    1846       
    19         $href = $matches[4];
    20         $title = $matches[6] ? $matches[6] : $href.$matches[7];
    21         $namespace = $matches[3];
    22 
    23         if ($namespace=='Image') {
    24             $options = explode('|',$title);
    25             $title = array_pop($options);
    26            
    27             return $this->handle_image($href,$title,$options);
    28         }       
    29        
    30         $title = preg_replace('/\(.*?\)/','',$title);
    31         $title = preg_replace('/^.*?\:/','',$title);
    32         $wiki = get_page_by_title($href);
    33        
    34         if(!$wiki)
    35             $redlink = 'style="color:red"';
    36         else
    37             $redlink = false;
    38        
    39         if ($this->reference_wiki) {
    40             $href = $this->reference_wiki.($namespace?$namespace.':':'').$this->wiki_link($href);
    41         } else {
    42             $nolink = true;
    43         }
    44 
    4547        if ($nolink) return $title;
    4648       
  • wordpress-wiki/trunk/lib/class_WikiParser.php

    r272690 r334363  
    268268   
    269269    function emphasize_off() {
     270        if (!$this->emphasis) return $output;
    270271        $output = "";
    271272        foreach ($this->emphasis as $amount=>$state) {
    272273            if ($state) $output .= $this->emphasize($amount);
    273274        }
    274        
    275275        return $output;
    276276    }
  • wordpress-wiki/trunk/readme.txt

    r287190 r334363  
    11=== Wordpress Wiki ===
    2 Contributors: Dan Milward, Allen Han, Matthew Gerring
     2Contributors: Dan Milward, Matthew Gerring, Brent Shepard, Arjen Lentz, and the WP-Wiki community
    33Donate link: http://www.instinct.co.nz/
    44Tags: wiki
    55Requires at least: 2.8
    6 Tested up to: 3.0.1
    7 Stable Tag: 0.8
     6Tested up to: 3.1
     7Stable Tag: 1.0
    88
    99== Description ==
  • wordpress-wiki/trunk/wordpress-wiki.php

    r142581 r334363  
    44Plugin URI: http://wordpress.org/extend/plugins/wordpress-wiki/
    55Description: Add Wiki functionality to your wordpress site.
    6 Version: 0.8
    7 Author: Instinct Entertainment
     6Version: 1.0
     7Author: Dan Milward/Matthew Gerring
    88Author URI: http://www.instinct.co.nz
    9 /* Major version for "major" releases */
    10 
    11 
    12 /**
    13 * Guess the wp-content and plugin urls/paths
    14 */
    15 if ( !defined('WP_CONTENT_URL') )
    16     define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
    17 if ( !defined('WP_CONTENT_DIR') )
    18     define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
    19 
    20 if (!defined('PLUGIN_URL'))
    21     define('PLUGIN_URL', WP_CONTENT_URL . '/plugins/');
    22 if (!defined('PLUGIN_PATH'))
    23     define('PLUGIN_PATH', WP_CONTENT_DIR . '/plugins/');
    24 if(get_option('numberOfRevisions') == NULL){
    25     add_option('numberOfRevisions', 5, '', 'yes' );
    26 }
    27 if(get_option('wiki_email_admins') == NULL){
    28     add_option('wiki_email_admins', 0, '', 'yes');
    29 }
    30 if(get_option('wiki_show_toc_onfrontpage') == NULL){
    31     add_option('wiki_show_toc_onfrontpage', 0, '', 'yes');
    32 }
    33 if(get_option('wiki_cron_last_email_date') == NULL){
    34     add_option('wiki_cron_last_email_date', date('Y-m-d G:i:s') , '', 'yes');
    35 }
    36 define('WPWIKI_FILE_PATH', dirname(__FILE__));
    37 define('WPWIKI_DIR_NAME', basename(WPWIKI_FILE_PATH));
    38 
    39 ///controller function for admin settings
    40 if(isset($_POST['submit'])){
    41         if(isset($_POST['numberOfRevisions'])){
    42         update_option('numberOfRevisions', (int)$_POST['numberOfRevisions'], '', 'yes');
    43     }
    44     //exit(print_r($_POST));
    45         if($_POST['emailnotification'] == 'on'){
    46             update_option('wiki_email_admins', 1, '' , 'yes');
    47         }elseif(!isset($_POST['emailnotification'])){
    48             update_option('wiki_email_admins', 0, '' , 'yes');
    49         }
    50         if($_POST['showonfrontpage'] == 'on'){
    51             update_option('wiki_show_toc_onfrontpage', 1, '' , 'yes');
    52         }elseif(!isset($_POST['showonfrontpage'])){
    53             update_option('wiki_show_toc_onfrontpage', 0, '' , 'yes');
    54         }
    55         if($_POST['cronnotify'] == 'on'){
    56             update_option('wiki_cron_email', 1, '' , 'yes');
    57         }elseif(!isset($_POST['cronnotify'])){
    58             update_option('wiki_cron_email', 0, '' , 'yes');
    59         }
    60 
    61 
    62     //echo print_r($_POST, true).get_option('wiki_email_admins');
    63 }
    64 
    65 
    66     //exit(get_option('wiki_email_admins'));
    67 
    68 /**
    69 *  The following roles and capabilities code has been removed because it does not work. If you can help with this, please do.
    709*/
    7110
    72 global $wp_roles;
    73 
    74 if ( ! isset($wp_roles) )
    75     $wp_roles = new WP_Roles();
    76 
    77 if ( ! get_role('wiki_editor')){
    78     $role_capabilities = array('read'=>true
    79     ,'edit_posts'=>true
    80     ,'edit_others_posts'=>true
    81     ,'edit_published_posts'=>true
    82 //  ,'delete_posts'=>true
    83 //  ,'delete_published_posts'=>true
    84 //  ,'publish_posts'=>true
    85 //  ,'publish_pages'=>true
    86 //  ,'delete_pages'=>true
    87 //  ,'edit_pages'=>true
    88 //  ,'edit_others_pages'=>true
    89 //  ,'edit_published_pages'=>true
    90 //  ,'delete_published_pages'=>true
    91     ,'edit_wiki'=>true);
    92     $wp_roles->add_role('wiki_editor', 'Wiki Editor',$role_capabilities);
    93 }
    94 
    95 
    96 $role = get_role('wiki_editor');
    97 $role->add_cap('edit_wiki');
    98 $role->add_cap('edit_pages');
    99 $role->add_cap('edit_post');
    100 $role->add_cap('edit_others_posts');
    101 $role->add_cap('edit_published_posts');
    102 function wiki_post_revisions($content='') {
    103     global $post, $current_user, $role;
    104     if ( !$post = get_post( $post->ID ) )
    105         return $content;
    106     $initial_post_id = $post->ID;
    107     if($post->post_type == 'revision' && ($post->post_parent > 0)) {
    108         if(!$post = get_post( $post->post_parent ))
    109             return $content;
     11class WP_Wiki {
     12    function __construct() {
     13        $this->WP_Wiki();
    11014    }
    11115   
    112     $defaults = array( 'parent' => false, 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );
    113     extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    114     $type = 'revision';
    115     switch ( $type ) {
    116     case 'autosave' :
    117         if ( !$autosave = wp_get_post_autosave( $post->ID ) )
    118             return $content;
    119         $revisions = array( $autosave );
    120         break;
    121     case 'revision' : // just revisions - remove autosave later
    122     case 'all' :
    123     default :
    124         if ( !$revisions = wp_get_post_revisions( $post->ID ) )
    125             return $content;
    126         break;
    127     }
    128 
    129         //echo("<pre>".print_r($revisions,true)."</pre>");
    130     $titlef = _c( '%1$s by %2$s|post revision 1:datetime, 2:name' );
    131 
    132     if ( $parent )
    133         array_unshift( $revisions, $post );
    134 
    135     $rows = '';
    136     $class = false;
    137     $can_edit_post = current_user_can( 'edit_post', $post->ID );
    138     //Track the first iteration as this is the current version auther who is different from the original
    139     $k=0;
    140     $i = 0;
    141     foreach ( $revisions as $revision ) {
    142         if($i == get_option('numberOfRevisions')) break;
    143         $is_selected = '';
    144         if ( !current_user_can( 'read_post', $revision->ID ) )
    145             continue;
    146         if ( 'revision' === $type && wp_is_post_autosave( $revision ) )
    147             continue;
    148         if($initial_post_id == $revision->ID ) {
    149             $is_selected = "class='selected-revision'";
    150         }
    151         $date = wiki_post_revision_title( $revision );
    152         $name = get_author_name( $revision->post_author );
    153         $title = sprintf( $titlef, $date, $name );
    154    
     16    function WP_Wiki() {
     17        global $wp_version;
    15518       
    156         $rows .= "\t<li $is_selected >$title</li>\n";
    157         $i++;
    158         }
    159         if($k==0)
    160             // Current author
    161             $post_author=$name;
    162         $k++;
     19        //include component controllers
     20        include('model/wiki_post_type.php');
     21        include('controllers/wiki_pages.php');
     22        include('controllers/wiki_notifications.php');
     23        include('controllers/wiki_feed.php');
     24        include('controllers/wiki_admin.php');
     25        include('controllers/wiki_dashboard_widget.php');
     26        include('controllers/wiki_user_contrib_widget.php');
     27        include('wiki_helpers.php');
    16328       
    164    
    165     $wpwiki_members_data = get_post_meta($post->ID,'_wiki_page');
    166     if (current_user_can('edit_wiki') && (is_array($wpwiki_members_data) && ($wpwiki_members_data[0] == 1)) && current_user_can('edit_pages')) {
    167             $link = get_permalink($post->ID);
    168             $output .= "<h4>". 'Post Revisions'."</h4>";
    169             $output .= "<ul class='post-revisions'>\n";
    170         $output .= "\t<li $is_selected ><a href='".$link."'>Current revision</a> by ".$post_author." - <a href='".get_edit_post_link( $post->ID )."'>Edit this page</a></li>\n";
    171             $output .= $rows;
    172             $output .= "</ul>";
    173         }
    174     if((is_user_logged_in() == false)&&(is_array($wpwiki_members_data) && ($wpwiki_members_data[0] == 1))){
    175         $siteurl = get_option('siteurl');
    176         $currentpage = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    177         $output .= "This page is wiki editable click <a href='".$siteurl."/wp-login.php?redirect_to=http://".$currentpage."'> here</a> to edit this page.";
    178      
    179      }
    180     return $content.$output;
    181 }
    182 
    183 function wiki_post_revision_title( $revision, $link = true ) {
    184     if ( !$revision = get_post( $revision ) )
    185         return $revision;
    186 
    187     if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
    188         return false;
    189 
    190     $datef = _c( 'j F, Y @ G:i|revision date format');
    191     $autosavef = __( '%s [Autosave]' );
    192     $currentf   = __( '%s [Current Revision]' );
    193 
    194     $date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
    195     if ( $link ) {
    196         $link = get_permalink($revision->post_parent)."?revision=".$revision->ID;
    197         $date = "<a href='$link'>$date</a>";
    198     }
    199 
    200     if ( !wp_is_post_revision( $revision ) )
    201         $date = sprintf( $currentf, $date );
    202     elseif ( wp_is_post_autosave( $revision ) )
    203         $date = sprintf( $autosavef, $date );
    204 
    205     return $date;
    206 }
    207 
    208 
    209 function wiki_substitute_in_revision_id($query) {
    210     /**
    211     *   This function substitutes the revision ID for the post ID
    212     *  we need to set $query->is_single and $query->is_page to false, otherwise it cannot select the revisions
    213     */
    214     if(((int)$_GET['revision'] > 0) && ($query->is_single == true)) {
    215         $query->query_vars['page_id'] = $_GET['revision'];
    216         $query->query_vars['pagename'] = null;
    217         $query->query_vars['post_type'] = 'revision';
    218         $query->is_single = false;
    219     } else if(((int)$_GET['revision'] > 0) && ($query->is_page == true)) {
    220         $query->query_vars['page_id'] = $_GET['revision'];
    221         $query->query_vars['pagename'] = null;
    222         $query->query_vars['post_type'] = 'revision';
    223         $query->is_single = false;
    224         $query->is_page = false;
    225 //      echo("<pre>".print_r($query,true)."</pre>");
     29        //include Wiki Parser class here so it doesn't get re-declared- fixes issue #4 on GitHub. Thanks Nexiom!
     30        include('lib/WPW_WikiParser.php');
     31       
     32        /**
     33        * Guess the wp-content and plugin urls/paths
     34        */
     35        if ( !defined('WP_CONTENT_URL') )
     36            define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
     37        if ( !defined('WP_CONTENT_DIR') )
     38            define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
     39       
     40        if (!defined('PLUGIN_URL'))
     41            define('PLUGIN_URL', WP_CONTENT_URL . '/plugins');
     42        if (!defined('PLUGIN_PATH'))
     43            define('PLUGIN_PATH', WP_CONTENT_DIR . '/plugins');
     44       
     45        define('WPWIKI_FILE_PATH', dirname(__FILE__));
     46        define('WPWIKI_DIR_NAME', basename(WPWIKI_FILE_PATH));
     47       
     48        //Enables Wiki Pages
     49        $WikiPostType = new WikiPostType();
     50       
     51        //Create classes for our components. This will be changed to allow filtering in a future release.
     52        $WikiPageController = new WikiPageController();
     53        $WikiNotifications = new WikiNotifications();
     54        $WikiFeed = new WikiFeed();
     55        $WikiAdmin = new WikiAdmin();
     56        $WikiDashboardWidget = new WikiDashboardWidget();
     57       
     58        //Version-specific actions and filters
     59       
     60        if ($wp_version >= 3.0):
     61            //Register the post type
     62            add_action('init', array($WikiPostType,'register') );
     63           
     64            //Set permissions
     65            add_action('init', array($WikiPostType,'set_permissions') );
     66           
     67            //Make Table of Contents on by default for Wiki post type
     68            add_action('publish_wiki',array($WikiPageController,'set_toc'));
     69           
     70            //Make Table of Contents on by default for pages marked as Wikis
     71            add_action('publish_page',array($WikiPageController,'set_toc'));
     72        else:
     73            //Make Table of Contents on by default for pages marked as Wikis
     74            add_action('publish_page',array($WikiPageController,'set_toc'));
     75            //Manage permissions for versions prior to 3.0
     76            add_filter('user_has_cap', array($WikiPostType, 'page_cap'), 100, 3);
     77        endif;
     78       
     79        //Front-end editor
     80        add_action('wp', array($WikiPageController, 'set_query'));
     81        add_action('template_redirect', array($WikiPageController, 'invoke_editor'));
     82        add_action('init', array($WikiPageController, 'create_new_and_redirect'));
     83        add_action('wp', array($WikiPageController, 'fake_page'));
     84        add_action('_wp_put_post_revision', array($WikiPageController,'anon_meta_save_as_revision'), 10);
     85       
     86        //Ajax functions
     87        add_action('wp_ajax_ajax_save',array($WikiPageController,'ajax_save'));
     88        add_action('wp_ajax_nopriv_ajax_save',array($WikiPageController,'ajax_save'));
     89       
     90        //if JavaScript isn't available...
     91        if( !defined('DOING_AJAX') && isset($_POST['wpw_editor_content']) )
     92            add_action('init',array($WikiPageController,'no_js_save'));
     93       
     94        //Notifications
     95        add_action('save_post', array($WikiNotifications,'page_edit_notification'));
     96        add_action('cron_email_hook', array($WikiNotifications,'cron_email'));
     97        add_filter('cron_schedules', array($WikiNotifications,'more_reccurences'));
     98       
     99        //Feed
     100        add_action('init', array($WikiFeed, 'add_feed'), 11);
     101       
     102        //Admin pages
     103        add_action('admin_menu', array($WikiAdmin,'register_options_page'));
     104        add_action('save_post',array($WikiAdmin,'replace_current_with_pending'));
     105        add_action('admin_menu', array($WikiAdmin,'add_custom_box'));
     106       
     107        //Widgets
     108        add_action('widgets_init', create_function('', 'return register_widget("WikiUserContribWidget");'));
     109        add_action('wp_dashboard_setup', array($WikiDashboardWidget, 'dashboard_widget_hook') );
    226110    }
    227111}
     112$WP_Wiki = new WP_Wiki();
    228113
    229 function wiki_view_sql_query($query) {
    230     /**
    231     *   This function makes wordpress treat a revision as a single post
    232     */
    233     global $wp_query;
    234     if((int)$_GET['revision'] > 0 ) {
    235         $wp_query->is_single= true;
    236 //      echo("<pre>".print_r($wp_query,true)."</pre>");
    237     }
    238     return $query;
    239 }
    240 
    241 
    242 
    243 /**
    244 *  wiki page metabox section starts
    245 */
    246 function wordpressWiki_metabox() {
    247         /**
    248         *  this function creates the HTML for the wiki page metabox module
    249         */
    250     global $wpdb, $post_meta_cache;
    251    
    252     if(is_numeric($_GET['post'])) {
    253         $post_ID = (int)$_GET['post'];
    254         $wpwiki_members_data = get_post_meta($post_ID,'_wiki_page');
    255         if(is_array($wpwiki_members_data) && ($wpwiki_members_data[0] == 1)) {
    256             $checked_status = "checked='checked'";
    257 
    258             $wiki_toc_data = get_post_meta($post_ID,'_wiki_page_toc');
    259             if(is_array($wiki_toc_data) && ($wiki_toc_data[0] == 1)) {
    260                 $wiki_toc_status = "checked='checked'";
    261             } else {
    262                 $wiki_toc_status = "";
    263             }
    264         } else {
    265             $checked_status = "";
    266             $wiki_toc_status = "disabled";
    267         }
    268     } else {
    269         $checked_status = "";
    270         $wiki_toc_status = "disabled";
    271     }
    272 
    273         echo "<label class='selectit' for='wiki_page'>
    274                 <input id='wiki_page_check' type='hidden' value='1' name='wiki_page_check' />
    275                 <input id='wiki_page' type='checkbox' $checked_status value='1' name='wiki_page' onchange = 'check_toc();' />";
    276                
    277                 _e("This page/post is a wiki friendly page and may be edited by authors and contributors.");
    278 
    279                 echo "
    280                 </label><br />
    281                 <lable class = 'selectit' for = 'wiki_toc'>
    282                 <input id='wiki_toc' type='checkbox' $wiki_toc_status value='1' name='wiki_toc' />";
    283 
    284                 _e("Enable Table of Contents");
    285                
    286                 echo "</label>";
    287 
    288 }
    289 /**
    290 *  wiki page metabox section starts
    291 */
    292 function wiki_metabox_module() {
    293         /**
    294         *  this function creates the HTML for the wiki page metabox module
    295         */
    296 
    297     add_meta_box( 'wordpressWiki', __( 'Wordpress Wiki', 'wordpressWiki' ),
    298                 'wordpressWiki_metabox', 'page', 'advanced' );
    299                     add_meta_box( 'wordpressWiki', __( 'Wordpress Wiki', 'wordpressWiki' ),
    300                 'wordpressWiki_metabox', 'post', 'advanced' );
    301     }
    302 
    303 function wiki_metabox_module_submit($post_ID) {
    304         /**
    305         *  this function saves the HTML for the wiki page metabox module
    306         */
    307   global $wpdb;
    308   if(is_numeric($post_ID) && ($_POST['wiki_page_check'] == 1)) {
    309     if(isset($_POST['wiki_page']) && ($_POST['wiki_page'] == 1)) {
    310       $wpwiki_members_value = 1;
    311         } else {
    312       $wpwiki_members_value = 0;
    313         }
    314    
    315     if(isset($_POST['wiki_toc']) && ($_POST['wiki_toc'] == 1)) {
    316         $wiki_toc_value = 1;
    317     } else {
    318         $wiki_toc_value = 0;
    319     }
    320 
    321     $wpwiki_check_members_data = $wpdb->get_var("SELECT `meta_id` FROM `".$wpdb->postmeta."` WHERE `post_id` IN('".$post_ID."') AND `meta_key` IN ('wiki_page') LIMIT 1");
    322     //changed by jeffry 23-02-09  fixes the meta content bug
    323     update_post_meta($post_ID, '_wiki_page',  (int)(bool)$wpwiki_members_value);
    324    
    325     $wpwiki_check_toc_data = $wpdb->get_var("SELECT `meta_id` FROM `".$wpdb->postmeta."` WHERE `post_id` IN('".$post_ID."') AND `meta_key` IN ('wiki_page_toc') LIMIT 1");
    326      //changed by jeffry 23-02-09 fixes the meta content bug
    327       update_post_meta($post_ID, '_wiki_page_toc',  (int)(bool)$wiki_toc_value);
    328 
    329         // need to change the custom fields value too, else it tries to reset what we just did.
    330         if(is_array($_POST['meta'])) {
    331             foreach($_POST['meta'] as $meta_key=>$meta_data) {
    332                 if($meta_data['key'] == 'wiki_page') {
    333                   $_POST['meta'][$meta_key]['value'] = $wpwiki_members_value;
    334                 }
    335                 if($meta_data['key'] == 'wiki_page_toc') {
    336                   $_POST['meta'][$meta_key]['value'] = $wiki_toc_value;
    337                 }
    338             }
    339         }
    340     }
    341 }
    342 
    343 
    344 /**
    345 *  wiki page metabox module ends
    346 */
    347 
    348 function wiki_exclude_pages_filter($excludes) {
    349     global $wpdb;
    350     // get the list of excluded pages and merge them with the current list
    351     $excludes = array_merge((array)$excludes, (array)$wpdb->get_col("SELECT DISTINCT `post_id` FROM `".$wpdb->postmeta."` WHERE `meta_key` IN ( 'wiki_page' ) AND `meta_value` IN ( '1' )"));
    352     return $excludes;
    353 }
    354 
    355 function table_of_contents($content) {
    356     /**
    357     *   This creates the Table of Contents
    358     */
    359     global $wpdb,$post;
    360     $wpwiki_members_data = get_post_meta($post->ID,'_wiki_page');
    361     if ($wpwiki_members_data[0] != '1') {
    362         return $content;
    363     }
    364 
    365     // Check whether table of contents is set or not
    366     $wiki_toc_data = get_post_meta($post->ID,'_wiki_page_toc');
    367     // second condition checks: are we on the front page and
    368     // is front page displaying set. - tony@irational.org
    369     if ($wiki_toc_data[0] != '1'
    370         || (is_front_page() && !get_option('wiki_show_toc_onfrontpage'))) {
    371 
    372         return $content;
    373     }
    374 
    375     preg_match_all("|<h2>(.*)</h2>|", $content, $h2s, PREG_PATTERN_ORDER);
    376     $content = preg_replace("|<h2>(.*)</h2>|", "<a name='$1'></a><h2>$1</h2>", $content);
    377     $content = preg_replace("|<h3>(.*)</h3>|", "<a name='$1'></a><h3>$1</h3>", $content);
    378     $h2s = $h2s[1];
    379     $content = str_replace("\n", "::newline::", $content);
    380     preg_match_all("|</h2>(.*)<h2>|U", $content, $h3s_contents, PREG_PATTERN_ORDER);
    381    
    382     /**
    383     *   The following lines are really ugly for finding <h3> after the last </h2> please tidy it up if u know a better solution, and please let us know about it.
    384     */
    385     $last_h2_pos = explode('</h2>', $content);
    386     $last_h2_pos = array_pop($last_h2_pos);
    387     $last_h2_pos[1] = $last_h2_pos;
    388     $h3s_contents[1][] = $last_h2_pos;
    389     if (!is_array($h3s_contents[1])) {
    390         $h3s_contents[1] = array();
    391     }
    392     array_push($h3s_contents[1], $last_h2_pos);
    393     foreach ($h3s_contents[1] as $key => $h3s_content) {
    394         preg_match_all("|<h3>(.*)</h3>|U", $h3s_content, $h3s[$key], PREG_PATTERN_ORDER);
    395     }
    396     $table = "<ol class='content_list'>";
    397     foreach($h2s as $key => $h2) {
    398         $table .= "<li><a href='#$h2'>".($key+1)." ".$h2."</a></li>";
    399         if (!empty($h3s[$key][1])) {
    400             foreach($h3s[$key][1] as $key1 => $h3) {
    401                 $table .= "<li class='lvl2'><a href='#$h3'>".($key+1).".".($key1+1)." ".$h3."</a></li>";
    402             }
    403         }
    404     }
    405     $table .= "</ol>";
    406     $content = str_replace("::newline::", "\n", $content);
    407     return "<div class='contents'><h3>Contents</h3><p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>$table</div>".$content;
    408 }
    409 
    410 function wp_wiki_head() {
    411     /**
    412     *   Include CSS
    413     */
    414 
    415     echo "<link href='". PLUGIN_URL ."/".WPWIKI_DIR_NAME."/style.css' rel='stylesheet' type='text/css' />";
    416 }
    417 
    418 /**
    419  * Enqueue Scripts
    420  */
    421 function wiki_enqueue_scripts() {
    422    wp_enqueue_script("jquery");
    423    wp_enqueue_script('wordpress-wiki', PLUGIN_URL ."/".WPWIKI_DIR_NAME."/wordpress-wiki.js");
    424 }
    425 
    426 //Feed Functions
    427 
    428 /**
    429  * Add new feed to WordPress
    430  * @global <type> $wp_rewrite
    431  */
    432 function wiki_add_feed(  ) {
    433     if (function_exists('load_plugin_textdomain')) {
    434         $plugin_dir = basename(dirname(__FILE__));
    435         load_plugin_textdomain('wordpress_wiki', '', $plugin_dir);
    436     }
    437 
    438     global $wp_rewrite;
    439     add_feed('wiki', 'wiki_create_feed');
    440     add_action('generate_rewrite_rules', 'wiki_rewrite_rules');
    441     $wp_rewrite->flush_rules();
    442 }
    443 
    444 /**
    445  * Modify feed rewrite rules
    446  * @param <type> $wp_rewrite
    447  */
    448 function wiki_rewrite_rules( $wp_rewrite ) {
    449   $new_rules = array(
    450     'feed/(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1)
    451   );
    452   $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    453 }
    454 
    455 /**
    456  * This function creates the actual feed
    457  */
    458 function wiki_create_feed() {
    459     global $wpdb;
    460 
    461     $posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where ID in (
    462                     select post_id from $wpdb->postmeta where
    463                     meta_key = 'wiki_page' and meta_value = 1)
    464                     and post_type in ('post','page') order by post_modified desc"));
    465 
    466     header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
    467     echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
     114//That's all she wrote!
    468115?>
    469 <rss version="2.0"
    470     xmlns:content="http://purl.org/rss/1.0/modules/content/"
    471     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    472     xmlns:dc="http://purl.org/dc/elements/1.1/"
    473 >
    474 
    475 <channel>
    476     <title><?php print(__('Recently modifiyed wiki pages for : ')); bloginfo_rss('name'); ?></title>
    477     <link><?php bloginfo_rss('url') ?></link>
    478     <description><?php bloginfo_rss("description") ?></description>
    479     <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
    480     <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
    481     <language><?php echo get_option('rss_language'); ?></language>
    482 <?php
    483         if (count($posts) > 0) {
    484             foreach ($posts as $post) {
    485                 $content = '
    486                             <p>'.__('wiki URL: ').'<a href="'. get_permalink($post->ID).'">'.$post->post_title.'</a></p>
    487                     <p>'.__('Modifiyed By: ').'<a href="'. get_author_posts_url($post->post_author).'">'. get_author_name($post->post_author).'</a></p>
    488                 ';
    489 ?>
    490     <item>
    491         <title><![CDATA[<?php print(htmlspecialchars($post->post_title)); ?>]]></title>
    492         <link><![CDATA[<?php print(get_permalink($post->ID)); ?>]]></link>
    493         <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post->post_date_gmt, false); ?></pubDate>
    494         <guid isPermaLink="false"><?php print($post->ID); ?></guid>
    495         <description><![CDATA[<?php print($content); ?>]]></description>
    496         <content:encoded><![CDATA[<?php print($content); ?>]]></content:encoded>
    497     </item>
    498 <?php $items_count++; if (($items_count == get_option('posts_per_rss')) && !is_date()) { break; } } } ?>
    499 </channel>
    500 </rss>
    501 <?php
    502         die();
    503 }
    504 function wiki_get_post_revision($id){
    505     global $wpdb;
    506     $sql = "SELECT `$wpdb->users`.`user_login` FROM $wpdb->users LEFT JOIN $wpdb->posts ON $wpdb->posts.`post_author` = $wpdb->users.`ID` WHERE $wpdb->posts.`post_parent`= $id AND $wpdb->posts.`post_type`='revision' AND `post_name`  LIKE '%revision%' ORDER BY $wpdb->posts.`post_date` DESC";
    507     //echo $sql;
    508     $revision = $wpdb->get_var($sql);
    509     return $revision;
    510 //  exit('<pre>'.print_r($revision,true).'</pre>');
    511    
    512 }
    513 
    514 /**
    515  * function to output the contents of our Dashboard Widget
    516  */
    517 function wiki_dashboard_widget_function() {
    518     global $wpdb;
    519 
    520     // Display whatever it is you want to show
    521     $posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where ID in (
    522                     select post_id from $wpdb->postmeta where
    523                     meta_key = 'wiki_page' and meta_value = 1)
    524                     and post_type in ('post','page') order by post_modified desc limit 5"));
    525 ?>
    526     <div class="rss-widget">
    527     <ul>
    528 <?php
    529     if (count($posts) > 0) {
    530         foreach ($posts as $post) {
    531          $name =    wiki_get_post_revision($post->ID);
    532 
    533 ?>
    534         <li><a href = "<?php echo get_permalink($post->ID)?>"><?php echo $post->post_title ?></a> (<?php echo $name; ?>)</li>
    535 <?php
    536         }
    537     } else {
    538 ?>
    539         <li><?php _e("No contributions yet.") ?></li>
    540 <?php
    541     }
    542 ?>
    543     </ul>
    544     </div>
    545 <?php
    546 }
    547 
    548 /**
    549  * function to hook
    550  */
    551 function wiki_dashboard_widget() {
    552     wp_add_dashboard_widget('wiki_dashboard_widget', 'Recent contributions to Wiki', 'wiki_dashboard_widget_function');
    553 }
    554 
    555 /**
    556  * Fetch the posts edited by the current user
    557  * @global <type> $userdata
    558  * @global <type> $wpdb
    559  * @param <type> $nos
    560  */
    561 function wiki_get_user_posts($nos) {
    562     global $userdata;
    563     global $wpdb;
    564 
    565     get_currentuserinfo();
    566     $nos = ($nos <= 0) ? 10: $nos;
    567     $count = 0;
    568 
    569     $posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d and post_status = 'publish' and post_type in ('post','page')",  $userdata->ID));
    570 ?>
    571     <ul>
    572 <?php
    573     foreach ($posts as $post) {
    574         if (get_post_meta($post->ID, "_wiki_page", "true") == "1") {
    575             printf("<li><a href = '%s'>%s</a></li>", get_permalink($post->ID) ,$post->post_title);
    576             $count++;
    577             if ($count == $nos) {
    578                 break;
    579             }
    580         }
    581     }
    582 
    583     if ($count == 0) {
    584 ?>
    585         <li> <?php _e("You have made no contributions"); ?> </li>
    586 <?php
    587     }
    588 ?>
    589     </ul>
    590 <?php
    591 }
    592 
    593 /**
    594  * Widget Initialization
    595  * @return <type>
    596  */
    597 function wiki_widget_myc_init() {
    598 
    599     if(!function_exists('register_sidebar_widget')) { return; }
    600 
    601     /**
    602      * Widget Calls this function
    603      * @param <type> $args
    604      */
    605     function wiki_widget_myc($args) {
    606         global $userdata;
    607         get_currentuserinfo();
    608 
    609         if ($userdata->ID == 0 || trim($userdata->ID == "")) {
    610             return;
    611         } else {
    612             extract($args);
    613             $widget_options = get_option('widget_myc');
    614             $widget_title = $widget_options['title'];
    615             $widget_nos = $widget_options['nos'];
    616 
    617             echo $before_widget . $before_title . $widget_title . $after_title;
    618             wiki_get_user_posts($widget_nos);
    619             echo $after_widget;
    620         }
    621     }
    622 
    623     /**
    624      * Widget Control function
    625      */
    626     function wiki_widget_myc_control() {
    627         $options = $newoptions = get_option('widget_myc');
    628         if ( $_POST["myc-submit"] ) {
    629                 $newoptions['title'] = strip_tags(stripslashes($_POST["myc-title"]));
    630                 $newoptions['nos'] = strip_tags(stripslashes($_POST["myc-nos"]));
    631         }
    632         if ( $options != $newoptions ) {
    633                 $options = $newoptions;
    634                 update_option('widget_myc', $options);
    635         }
    636         $title = attribute_escape($options['title']);
    637         $nos = absint(attribute_escape($options['nos']));
    638         $nos = ($nos <= 0) ? 10: $nos;
    639     ?>
    640         <p>
    641         <label for="myc-title"><?php _e('Title:'); ?><br />
    642             <input style="width: 250px;" id="myc-title" name="myc-title" type="text" value="<?php echo $title; ?>" />
    643         </label>
    644         </p>
    645         <p>
    646         <label for="myc-nos"><?php _e('Number of posts to show:'); ?>
    647             <input name="myc-nos" id="myc-nos" type="text" size = "3" maxlength="3" value="<?php echo $nos; ?>" />
    648         </label>
    649         </p>
    650         <input type="hidden" id="myc-submit" name="myc-submit" value="1" />
    651     <?php
    652     }
    653 
    654     $widget_ops = array('classname' => 'widget_my_contributions', 'description' => __( "My Contributions widget for WordPress Wiki Plugin") );
    655     wp_register_sidebar_widget('my_contributions', __('My Contributions'), 'wiki_widget_myc', $widget_ops);
    656     wp_register_widget_control('my_contributions', __('My Contributions'),'wiki_widget_myc_control', 300, 100);
    657 }
    658 
    659 /**
    660  * Build links from shortcodes
    661  * @param <type> $content
    662  * @return <type> modifiyed content
    663  */
    664 function wiki_build_links($content) {
    665     global $post;
    666 
    667     if (get_post_meta($post->ID, "_wiki_page", "true") == "1") {
    668         // If it is a wiki post or page, then parse the content and build links
    669         $pattern = '/(\[\[([^\]]*)\]\])/i';
    670         return preg_replace_callback($pattern, "wiki_callback_func", $content);
    671     } else {
    672         //If it is not a wiki post or page then return the content.
    673         return $content;
    674     }
    675 }
    676 
    677 /**
    678  * Call back function for regex
    679  * @param <type> $m
    680  * @return <type> link
    681  */
    682 function wiki_callback_func($m) {
    683     global $post;
    684 
    685     $splited = explode("|", $m[2]);
    686     if (count($splited) == 2) {
    687         $link_text = trim($splited[1]);
    688         $link_slug = trim($splited[0]);
    689     } else {
    690         $link_slug = $link_text = $m[2];
    691     }
    692 
    693     $link = get_permalink_by_title($link_slug);
    694     if (!$link) {
    695         // If there is no post with that title
    696 
    697         if ($post->post_type == "page") {
    698             $link = get_bloginfo("wpurl") . "/wp-admin/page-new.php" ;
    699         } else {
    700             $link = get_bloginfo("wpurl") . "/wp-admin/post-new.php" ;
    701         }
    702     }
    703     return "<a href = '" . $link . "' >" . $link_text . "</a>";
    704 }
    705 
    706 /**
    707  * Get Permalink by post title
    708  * @global <type> $wpdb
    709  * @param <type> $page_title
    710  * @return <type> permalink
    711  */
    712 function get_permalink_by_title($page_title) {
    713       global $wpdb;
    714       $post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type in ('post','page')", $page_title ));
    715       if ( $post )
    716           return get_permalink($post);
    717 
    718       return NULL;
    719 }
    720 /**
    721  * wiki_page_edit_notification
    722  * @global <type> $wpdb
    723  * @param <type> $pageID
    724  * @return NULL
    725  */
    726 function wiki_page_edit_notification($pageID) {
    727     global $wpdb;
    728      
    729     if(get_option('wiki_email_admins') == 1){
    730  
    731         $emails = getAllAdmins();
    732         $sql = "SELECT post_title, guid FROM ".$wpdb->prefix."posts WHERE ID=".$pageID;
    733         $subject = "Wiki Change";
    734         $results = $wpdb->get_results($sql);
    735    
    736         $pageTitle = $results[0]->post_title;
    737         $pagelink = $results[0]->guid;
    738         $message = "A Wiki Page has been modified on '".get_option('home')."' \n\r The page title is ".$pageTitle.". \n\r To visit this page <a href='".$pagelink."'> click here</a>.";
    739         //exit(print_r($emails, true));
    740         foreach($emails as $email){
    741             wp_mail($email, $subject, $message);
    742         }
    743     }
    744 }
    745 /**
    746  * getAllAdmins
    747  * @global <type> $wpdb
    748  * @param <type> NULL
    749  * @return email addresses for all administrators
    750  */
    751 function getAllAdmins(){
    752     global $wpdb;
    753     $sql = "SELECT ID from $wpdb->users";
    754     $IDS = $wpdb->get_col($sql);
    755 
    756     foreach($IDS as $id){
    757         $user_info = get_userdata($id);
    758         if($user_info->user_level == 10){
    759             $emails[] = $user_info->user_email;
    760        
    761         }
    762     }
    763     return $emails;
    764 }
    765 
    766 /**
    767  * Template tag which can be added in the 404 page
    768  */
    769 function wiki_404() {
    770     $not_found = str_replace("/", "", $_SERVER['REQUEST_URI']);
    771     echo "<p>" . __("Sorry, the page with title ") . $not_found . __(" is not created yet. Click") . '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post-new.php">' . __("here") . '</a>' . __(" to create a new page with that title.") . "</p";
    772 }
    773 
    774 
    775 /**
    776  * If page edit capabilities are checked for a wiki page, grant them if current user has edit_wiki cap.
    777  * @global <type> $wp_query
    778  * @param <array> $wp_blogcaps : current user's blog-wide capabilities
    779  * @param <array> $reqd_caps : primitive capabilities being tested / requested
    780  * @param <array> $args = array:
    781  *               $args[0] = original capability requirement passed to current_user_can (possibly a meta cap)
    782  *               $args[1] = user being tested
    783  *               $args[2] = object id (could be a postID, linkID, catID or something else)
    784  * @return <array> capabilities as array key
    785  */
    786 function wiki_page_cap($wp_blogcaps, $reqd_caps, $args) {
    787     static $busy;
    788     if ( ! empty($busy) )   // don't process recursively
    789         return $wp_blogcaps;
    790    
    791     $busy = true;
    792    
    793     // Note: add edit_private_pages if you want the edit_wiki cap to satisfy that check also.
    794     if ( ! array_diff( $reqd_caps, array( 'edit_pages', 'edit_others_pages', 'edit_published_pages' ) ) ) {
    795 
    796         // determine page ID
    797         if ( ! empty($args[2]) )
    798             $page_id = $args[2];
    799         elseif ( ! empty($_GET['post']) )
    800             $page_id = $_GET['post'];
    801         elseif ( ! empty($_POST['ID']) )
    802             $page_id = $_POST['ID'];
    803         elseif ( ! empty($_POST['post_ID']) )
    804             $page_id = $_POST['post_ID'];
    805         elseif ( ! is_admin() ) {
    806             global $wp_query;
    807             if ( ! empty($wp_query->post->ID) ) {
    808                 $page_id = $wp_query->post->ID;
    809             }
    810         }
    811        
    812         if ( ! empty($page_id) ) {
    813             global $current_user, $scoper;
    814 
    815             if ( ! empty($scoper) && function_exists('is_administrator_rs') && ! is_administrator_rs() && $scoper->cap_defs->is_member('edit_wiki') ) {
    816                 // call Role Scoper has_cap filter directly because recursive calling of has_cap filter confuses WP
    817                 $user_caps = $scoper->cap_interceptor->flt_user_has_cap( $current_user->allcaps, array('edit_wiki'), array('edit_wiki', $current_user->ID, $page_id ) );
    818             } else
    819                 $user_caps = $current_user->allcaps;
    820 
    821             if ( ! empty( $user_caps['edit_wiki'] ) ) {
    822                 // Static-buffer the metadata to avoid performance toll from multiple cap checks.
    823                 static $wpsc_members_data;
    824 
    825                 if ( ! isset($wpsc_members_data) )
    826                     $wpsc_members_data = array();
    827                
    828                 if ( ! isset($wpsc_members_data[$page_id]) )
    829                     $wpsc_members_data[$page_id] = get_post_meta($page_id,'_wiki_page');
    830 
    831                 // If the page in question is a wiki page, give current user credit for all page edit caps.
    832                 if ( is_array($wpsc_members_data[$page_id]) && ($wpsc_members_data[$page_id][0] == 1) ) {
    833                     $wp_blogcaps = array_merge( $wp_blogcaps, array_fill_keys($reqd_caps, true) );
    834                 }
    835             }
    836         }
    837     }
    838 
    839     $busy = false;
    840     return $wp_blogcaps;
    841 }
    842 
    843 add_filter('user_has_cap', 'wiki_page_cap', 100, 3);    // this filter must be applied after Role Scoper's because we're changing the cap requirement
    844 add_action('edit_form_advanced','wiki_metabox_module');
    845 add_action('edit_page_form', 'wiki_metabox_module');
    846 
    847 add_action('edit_post', 'wiki_metabox_module_submit');
    848 add_action('publish_post', 'wiki_metabox_module_submit');
    849 add_action('save_post', 'wiki_metabox_module_submit');
    850 add_action('edit_page_form', 'wiki_metabox_module_submit');
    851 
    852 add_action('pre_get_posts', 'wiki_substitute_in_revision_id');
    853 add_filter('posts_request', 'wiki_view_sql_query');
    854 add_filter('the_content', 'table_of_contents', 9);
    855 add_filter('the_content', 'wiki_post_revisions', 11);
    856 
    857 //add css
    858 add_action('wp_head', 'wp_wiki_head');
    859 add_action('init', 'wiki_enqueue_scripts', 9);
    860 
    861 // Feeds
    862 add_action('init', 'wiki_add_feed', 11);
    863 
    864 // Hoook into the 'wp_dashboard_setup' action to register our other functions
    865 add_action('wp_dashboard_setup', 'wiki_dashboard_widget' );
    866 
    867 add_action('plugins_loaded', 'wiki_widget_myc_init');
    868 add_filter("the_content", "wiki_build_links", 999);
    869 add_action('admin_menu', 'wiki_admin_menu');
    870 //hook to check whether a page has been edited
    871 add_action('publish_page', 'wiki_page_edit_notification');
    872 function more_reccurences() {
    873     return array(
    874         'weekly' => array('interval' => 604800, 'display' => 'Once Weekly'),
    875         'fortnightly' => array('interval' => 1209600, 'display' => 'Once Fortnightly'),
    876     );
    877 }
    878 add_filter('cron_schedules', 'more_reccurences');
    879 
    880 if (!wp_next_scheduled('cron_email_hook')) {
    881     wp_schedule_event( time(), 'weekly', 'cron_email_hook' );
    882 }
    883 
    884 add_action( 'cron_email_hook', 'cron_email' );
    885 
    886 function cron_email() {
    887 
    888     if (get_option('wiki_cron_email') == 1) {
    889         $last_email = get_option('wiki_cron_last_email_date');
    890        
    891         $emails = getAllAdmins();
    892         $sql = "SELECT post_title, guid FROM ".$wpdb->prefix."posts WHERE post_modifiyed > ".$last_email;
    893        
    894         $subject = "Wiki Change";
    895         $results = $wpdb->get_results($sql);
    896    
    897         $message = " The following Wiki Pages has been modified on '".get_option('home')."' \n\r ";
    898         if ($results) {
    899             foreach ($results as $result) {
    900                 $pageTitle = $result->post_title;
    901                 $pagelink = $result->guid;
    902                 $message .= "Page title is ".$pageTitle.". \n\r To visit this page <a href='".$pagelink."'> click here</a>.\n\r\n\r";
    903                 //exit(print_r($emails, true));
    904                 foreach($emails as $email){
    905                     wp_mail($email, $subject, $message);
    906                 }
    907             }
    908         }
    909         update_option('wiki_cron_last_email_date', date('Y-m-d G:i:s'));
    910     }
    911 }
    912 
    913 function wiki_admin_menu(){
    914     add_submenu_page('options-general.php', 'Wiki settings','Wiki settings', 10 , __FILE__, 'wiki_plugin_options');
    915 }
    916 
    917 function wiki_plugin_options(){
    918     if(get_option('wiki_email_admins') == 0){
    919         $checked = '';
    920     }else if(get_option('wiki_email_admins') == 1){
    921         $checked = 'checked=checked';
    922     }
    923     if(get_option('wiki_show_toc_onfrontpage') == 0){
    924         $checked_toc = '';
    925     }else if(get_option('wiki_show_toc_onfrontpage') == 1){
    926         $checked_toc = 'checked=checked';
    927     }
    928     if(get_option('wiki_cron_email') == 0){
    929         $cron_checked = '';
    930     }else if(get_option('wiki_cron_email') == 1){
    931         $cron_checked = 'checked=checked';
    932     }
    933 
    934     ?>
    935     <div class="wrap">
    936     <h2>Wiki Settings</h2>
    937     <br />
    938     <?php
    939         if(isset($_POST['submit'])){
    940         ?>
    941             <p>Update Complete.</p>
    942         <?php
    943         }
    944     ?>
    945     <form action='' method='post'>
    946     <label for='numberOfRevisions'>Number of Revisions per page: </label>
    947     <p><input type='text' name='numberOfRevisions' size='10' value="<?php echo get_option('numberOfRevisions');?>" /></p>
    948     <p><input type='checkbox' name='emailnotification' <?php echo $checked; ?> /> Notify Administrators via Email when wiki pages have been editted.</p>
    949     <p><input type='checkbox' name='showonfrontpage' <?php echo $checked_toc; ?> /> Show Table of Content on the front page posts.</p>
    950     <p><input type='checkbox' name='cronnotify' <?php echo $cron_checked; ?> /> Notify Administrators via Email when wiki pages have been editted. (only once in a week)</p>
    951 
    952     <input class='button-primary' type='submit' name='submit' value='Submit' />
    953     </form>
    954    
    955    
    956     </div>
    957     <?php
    958 
    959 }
    960 
    961 ?>
Note: See TracChangeset for help on using the changeset viewer.