Example #1
0
    if (!isset($notifyme_email) && isset($_COOKIE['tdomf_notify_widget_email'])) {
        $notifyme_email = $_COOKIE['tdomf_notify_widget_email'];
    }
    $show_email_input = tdomf_widget_notifyme_show_email_input($tdomf_form_id);
    $output .= "<label for='notifyme'><input type='checkbox' name='notifyme' id='notifyme'";
    if (isset($notifyme)) {
        $output .= " checked ";
    }
    $output .= " /> " . __("Do you wish to be notified when your post is approved (or rejected)?", "tdomf") . "</label>";
    if ($show_email_input) {
        $output .= "<br/><label for='notifyme_email'>" . __("Email for notification:", "tdomf") . ' <input type="text" value="' . htmlentities($notifyme_email, ENT_QUOTES) . '" name="notifyme_email" id="notifyme_email" size="40" /></label>';
    }
    $output .= $after_widget;
    return $output;
}
tdomf_register_form_widget('notifyme', 'Notify Me', 'tdomf_widget_notifyme', $modes = array('new'));
// Widget core
//
function tdomf_widget_notifyme_hack($args)
{
    global $current_user;
    get_currentuserinfo();
    extract($args);
    $output = "\t<?php if(tdomf_get_option_form(TDOMF_OPTION_MODERATION,\$tdomf_form_id) && !current_user_can('publish_posts') && !tdomf_current_user_default_author() && !tdomf_current_user_trusted()) { ?>\n\t";
    $output .= $before_widget;
    $output .= "\t\t\t<label for='notifyme'><input type='checkbox' name='notifyme' id='notifyme'";
    $output .= "<?php if(isset(\$notifyme)) { ?> checked <?php } ?>";
    $output .= " /> " . __("Do you wish to be notified when your post is approved (or rejected)?", "tdomf") . "</label>\n";
    $output .= "\t\t<?php if(tdomf_widget_notifyme_show_email_input(%%FORMID%%)) { ?>\n";
    $output .= "\t\t\t<?php if(isset(\$_COOKIE['tdomf_notify_widget_email'])) { \$notifyme_email = \$_COOKIE['tdomf_notify_widget_email']; } ?>\n";
    $output .= "\t\t\t\t<br/>\n\t\t\t\t<label for='notifyme_email'>" . __("Email for notification:", "tdomf") . ' <input type="text" value="';
         if ($options['title'] != "") {
             $output .= $before_title . $options['title'] . $after_title;
         }
         if ($options['required']) {
             $output .= '<label for="tags" class="required" >';
         } else {
             $output .= '<label for="tags" >';
         }
         $output .= __("Tags (separate multiple tags with commas: cats, pet food, dogs):", "tdomf");
         $output .= '</label>';
         $output .= '<br/><input type="text" id="tags" name="tags" size="60" value="' . htmlentities($tags, ENT_QUOTES, get_bloginfo('charset')) . '" />';
         $output .= $after_widget;
     }
     return $output;
 }
 tdomf_register_form_widget('tags', __('Tags', 'tdomf'), 'tdomf_widget_tags', array("new-post"));
 ////////////////////////
 // Add tags to the post
 //
 function tdomf_widget_tags_post($args)
 {
     extract($args);
     $options = tdomf_widget_tags_options($tdomf_form_id);
     $tagslist = '';
     if ($options['default']) {
         $tagslist = strip_tags($options['default']);
     }
     if (isset($tags) && !empty($tags)) {
         if (!empty($tagslist)) {
             $tagslist .= ',';
         }
 /**
  * Start widget
  *
  * @access public
  */
 function start()
 {
     $retVal = false;
     if (!$this->started || !$this->internalName || !$this->displayName) {
         $retVal = true;
         if ($this->multipleInstances) {
             add_action('tdomf_generate_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_create_post_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_control_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_preview_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_validate_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_control_form_start', array($this, '_multipleInstancesHandler'), 10, 2);
             add_action('tdomf_widget_page_bottom', array($this, '_multipleInstancesForm'), 10, 2);
             add_action('tdomf_upload_inline_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             // for multiple instances, init is handled in _multipleInstancesInit function
         } else {
             tdomf_register_form_widget($this->internalName, $this->displayName, array($this, '_form'), $this->modes);
             if ($this->hack) {
                 tdomf_register_form_widget_hack($this->internalName, $this->displayName, array($this, '_formHack'), $this->modes);
             }
             if ($this->control) {
                 tdomf_register_form_widget_control($this->internalName, $this->displayName, array($this, '_control'), $this->controlWidth, $this->controlHeight, $this->modes);
             }
             if ($this->preview) {
                 tdomf_register_form_widget_preview($this->internalName, $this->displayName, array($this, '_preview'), $this->modes);
             }
             if ($this->previewHack) {
                 tdomf_register_form_widget_preview_hack($this->internalName, $this->displayName, array($this, '_previewHack'), $this->modes);
             }
             if ($this->validate) {
                 tdomf_register_form_widget_validate($this->internalName, $this->displayName, array($this, '_validate'), $this->modes);
             }
             if ($this->post) {
                 tdomf_register_form_widget_post($this->internalName, $this->displayName, array($this, '_post'), $this->modes);
             }
             if ($this->adminEmail) {
                 tdomf_register_form_widget_adminemail($this->internalName, $this->displayName, array($this, '_adminEmail'), $this->modes);
             }
             if ($this->adminError) {
                 tdomf_register_form_widget_admin_error($this->internalName, $this->displayName, array($this, '_adminError'), $this->modes);
             }
         }
     }
     return $retVal;
 }
//
function tdomf_widget_getcat($args)
{
    global $tdomf_getcat_var_name;
    extract($args);
    $getcat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $tdomf_form_id);
    if (isset($_GET[$tdomf_getcat_var_name])) {
        $getcat = intval($_GET[$tdomf_getcat_var_name]);
    } else {
        if (isset($args[$tdomf_getcat_var_name])) {
            $getcat = intval($args[$tdomf_getcat_var_name]);
        }
    }
    return "<div><input type='hidden' name='{$tdomf_getcat_var_name}' id='{$tdomf_getcat_var_name}' value='{$getcat}' /></div>";
}
tdomf_register_form_widget("getcat", __("Set Category from GET variables", "tdomf"), 'tdomf_widget_getcat', array("new-post"));
// This is processed once the post is saved.
//
function tdomf_widget_getcat_post($args, $params)
{
    global $tdomf_getcat_overwrite, $tdomf_getcat_var_name;
    extract($args);
    if (isset($args[$tdomf_getcat_var_name])) {
        // Overwrite existing post categories
        //
        if ($tdomf_getcat_overwrite) {
            $post_cats = array($args[$tdomf_getcat_var_name]);
        } else {
            // Append to existing categories
            //
            // Grab existing data
                $output .= "<br/>";
            }
            $output .= '<input type="checkbox" name="comments-user-pings" id="comments-user-pings"';
            if ($defval) {
                $output .= "checked";
            }
            $output .= '>';
            $output .= '<label for="comments-user-pings" >';
            $output .= __("Allow Pings and Trackbacks", "tdomf");
            $output .= '</label>';
        }
        $output .= $after_widget;
    }
    return $output;
}
tdomf_register_form_widget('comments', __('Comments Management', "tdomf"), 'tdomf_widget_comments', $modes = array('new'));
function tdomf_widget_comments_hack($args)
{
    $options = tdomf_widget_comments_get_options($args['tdomf_form_id']);
    $output = "";
    if ($options['user-comments'] || $options['user-pings']) {
        extract($args);
        $output = $before_widget;
        if (!empty($options['title'])) {
            $output .= $before_title;
            $output .= $options['title'];
            $output .= $after_title;
        }
        if ($options['user-comments']) {
            $defval = true;
            if ($options['overwrite']) {
function tdomf_widget_categories_init($form_id, $mode)
{
    if (tdomf_form_exists($form_id) && strpos($mode, 'new-post') !== false) {
        $count = tdomf_get_option_widget('tdomf_categories_widget_count', $form_id);
        $max = tdomf_get_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $form_id);
        if ($max <= 1) {
            $count = 1;
        } else {
            if ($count > $max + 1) {
                $count = $max + 1;
            }
        }
        tdomf_register_form_widget("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_hack("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_control("categories", "Categories 1", 'tdomf_widget_categories_control', 370, 610, array(), 1);
        tdomf_register_form_widget_preview("categories", "Categories 1", 'tdomf_widget_categories_preview', array(), 1);
        tdomf_register_form_widget_preview_hack("categories", "Categories 1", 'tdomf_widget_categories_preview_hack', array(), 1);
        tdomf_register_form_widget_post("categories", "Categories 1", 'tdomf_widget_categories_post', array(), 1);
        tdomf_register_form_widget_adminemail("categories", "Categories 1", 'tdomf_widget_categories_adminemail', array(), 1);
        tdomf_register_form_widget_admin_error("categories", "Categories 1", 'tdomf_widget_categories_admin_error', array(), 1);
        for ($i = 2; $i <= $count; $i++) {
            tdomf_register_form_widget("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_control("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_control', 370, 610, array(), $i);
            tdomf_register_form_widget_preview("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview', array(), $i);
            tdomf_register_form_widget_preview_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview_hack', array(), $i);
            tdomf_register_form_widget_post("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_post', array(), $i);
            tdomf_register_form_widget_adminemail("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_adminemail', array(), $i);
            tdomf_register_form_widget_admin_error("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_admin_error', array(), $i);
        }
    }
}
     } else {
         $output .= __('You will be automatically notified via email of followup comments to your submission. You will be able to unsubscribe after the post is published.', 'tdomf');
     }
     if ($show_email_input || $options['show_email_field']) {
         $output .= "<br/><label for='subscribe_to_comments_email'";
         if ($options['always_subscribe']) {
             $output .= " class='required'>" . __("Email for comment subscription (required):", "tdomf");
         } else {
             $output .= ">" . __("Email for comment subscription:", "tdomf");
         }
         $output .= ' <input type="text" value="' . htmlentities($sc_email, ENT_QUOTES) . '" name="subscribe_to_comments_email" id="subscribe_to_comments_email" size="40" /></label>';
     }
     $output .= $after_widget;
     return $output;
 }
 tdomf_register_form_widget('subscribe_to_comments', __('Subscribe to Comments', "tdomf"), 'tdomf_widget_subscribe_to_comments');
 function tdomf_widget_subscribe_to_comments_hack($args)
 {
     $options = tdomf_widget_subscribe_to_comments_get_options($args['tdomf_form_id']);
     $output = "";
     extract($args);
     $output .= $before_widget;
     if (!empty($options['title'])) {
         $output .= $before_title;
         $output .= $options['title'];
         $output .= $after_title;
     }
     if (!$options['always_subscribe']) {
         $output .= "\t\t<input type='checkbox' name='subscribe_to_comments' id='subscribe_to_comments'";
         $output .= "<?php if(isset(\$subscribe_to_comments)) { ?> checked <?php } ?>";
         $output .= "/><label for=subscribe_to_comments'>" . __('Notify me of followup comments via e-mail', 'tdomf') . "</label>";