Пример #1
0
function wf_widget_box_contents()
{
    // v6.66
    function empty_or_cancelled($current_or_inherited)
    {
        return empty($current_or_inherited) || $current_or_inherited[0]['widget_type'] == 'cancel';
    }
    global $post;
    // v6.47
    $regions = get_regions_list($post);
    // v6.47
    $wf_widgets = Wf_Widget::list_wf_widgets($regions);
    // v6.47
    $html_start = "\n\n\n\t\t<div id='widget_box'>\n\n\t\t<div id='hidden_fields'>\n\n\t\t<textarea  cols='30' rows='2' name='list_of_deletes' id='list_of_deletes'></textarea>\n\n\t\t<textarea  cols='30' rows='2' name='list_of_updates' id='list_of_updates'></textarea>\n\n\t\t<div id='cfields_to_update'>\n</div>\n\n\t\t</div>\n\n\t\t<div id='admin_region_list'>\n\n\n\t\t<ul class='category-tabs'>\n";
    $html = "</ul>\n\n";
    // start by finishing off 	$html_start and then assemble later
    foreach ($regions as $region_num => $region) {
        // v6.47
        $html_start .= "<li><a href='#region" . $region_num . "'>Region " . $region . "</a></li>\n";
        $html .= "<div id='region" . $region_num . "' class='region region_" . $region . "'>\n";
        // id used by tabs
        $html .= "<h4 class='" . $region . "'>Region " . $region . "</h4>\n";
        $current = $wf_widgets[$region]['current'];
        // v6.66
        $inherited = $wf_widgets[$region]['inherited'];
        // v6.66
        $inherit_vis = empty_or_cancelled($current) ? "" : " style='display: none;' ";
        // v6.66
        //d('$current ('.$region.')',$current);
        //d('$inherited ('.$region.')',$inherited );
        //d('$inherit_vis',$inherit_vis);
        // makes sense to include this in .inherited as it gets displayed under similar conditions
        if (empty_or_cancelled($current) && empty_or_cancelled($inherited)) {
            // v6.66
            $html .= "\n\n\t\t\t\t\t<div class='inherited' " . $inherit_vis . ">\n\n\t\t\t\t\t<p class='strapline'>There are no widgets for this region.</p>\n\t\t\t\t\t</div>\n";
        } else {
            if (!empty_or_cancelled($inherited)) {
                // v6.66
                // Even if there are 'current' widgets, we still need to create this (hidden) list so that js can display it if
                // the last current widget is removed.
                $html .= "\n\n\t\t\t\t\t<div class='inherited' " . $inherit_vis . ">\n\n\t\t\t\t\t<p class='strapline'>Widgets inherited from " . $inherited[0]['aboveness'] . " page(s) above:</p>\n\n\t\t\t\t\t<table cellspacing='0' class='widget_table inherited'>\n\n\t\t\t\t\t<tbody>\n";
                foreach ($inherited as $c => $r_widget) {
                    $params = trim_parse($r_widget['qstring']);
                    // v6.4 Was Wf_Widget::trim_parse
                    $comment = isset($params['comment']) ? $params['comment'] : "&nbsp;";
                    $html .= "\n\n\t\t\t\t\t\t<tr class='" . $r_widget['widget_type'] . "'>\n\n\t\t\t\t\t\t<td class='order'>" . ($c + 1) . "</td>\n\n\t\t\t\t\t\t<td class='widget_type'>" . Wf_Widget::$current_specs[$r_widget['widget_type']]['display_name'] . "</td>\n\n\t\t\t\t\t\t<td class='widget_instance_name'>" . $comment . "</td>\n\n\t\t\t\t\t\t<td class='edit'>&nbsp;</td>\n\n\t\t\t\t\t\t<td class='delete'>&nbsp;</td>\n\n\t\t\t\t\t\t</tr>\n";
                }
                $html .= "</tbody>\n</table>\n";
                //v6.60
                //v6.60
                $html .= "<div class='break_inherit'>\n";
                $html .= "<label for='" . $region . "_break_inherit'>Cancel inheritance?</label>\n";
                $html .= "<input id='" . $region . "_break_inherit' type='checkbox'  value='' name='" . $region . "_break_inherit'>";
                //v6.60
                $html .= "</div>\n";
                $html .= "</div>\n";
                // finish off div#inherited
            }
            // if(!empty_or_cancelled($inherited))
            if (!empty_or_cancelled($current)) {
                // v6.66
                $html .= "\n\n\t\t\t\t\t<div class='current'>\n\n\t\t\t\t\t<p class='strapline'>Widgets on this page: &nbsp;(Drag to reorder)</p>\n\n\t\t\t\t\t<table cellspacing='0' class='widget_table current'>\n\n\t\t\t\t\t<tbody class='widget_sort'>\n";
                foreach ($current as $c => $r_widget) {
                    $params = trim_parse($r_widget['qstring']);
                    // v6.4 Was Wf_Widget::trim_parse
                    $comment = isset($params['comment']) ? $params['comment'] : "&nbsp;";
                    $html .= "\n\n\t\t\t\t\t\t<tr class='" . $r_widget['widget_type'] . "'>\n\n\t\t\t\t\t\t<td class='order'>" . ($c + 1) . "</td>\n\n\t\t\t\t\t\t<td class='widget_type'>" . Wf_Widget::$current_specs[$r_widget['widget_type']]['display_name'] . "</td>\n\n\t\t\t\t\t\t<td class='widget_instance_name'>" . $comment . "</td>\n\n\t\t\t\t\t\t<td class='edit'><i class='icon-large icon-edit' title='Edit this widget'></i></td>\n\n\t\t\t\t\t\t<td class='delete'><i class='icon-large icon-remove-sign' title='Delete this widget'></i></td>\n\n\t\t\t\t\t\t</tr>\n";
                }
                $html .= "</tbody>\n</table>\n</div>\n";
                // finish off div#current
            }
            // if(!empty_or_cancelled($current))
        }
        $html .= "</div>\n\n";
        // .region
    }
    $html .= "<input id='update2' class='button button-primary button-large' type='button' value='Update'>";
    // copy of blue update button
    $html .= "</div>\n";
    $html .= get_widget_dialog();
    // the (initially hidden) skeleton of the dialog box, complete with available items
    $html .= "<br/ class='clearboth'>\n";
    $html .= "</div>\n\n";
    echo $html_start . $html;
}
Пример #2
0
function get_cf_pair_value($post_id, $customfield_name, $pair_name)
{
    $cf_value = get_post_meta($post_id, $customfield_name, true);
    // returns empty or string
    $cf_value_array = trim_parse(qscode($cf_value));
    return isset($cf_value_array[$pair_name]) ? $cf_value_array[$pair_name] : '';
    // v6.4
}
Пример #3
0
 public function __construct($region, $widget_type, $data)
 {
     //$region,$qstring
     //global $post; //v6.76
     $this->region = $region;
     if ($region == 'shortcode') {
         $raw_params = $data;
         // data is atts
     } else {
         $raw_params = trim_parse($data);
         // data is qstring //v6.4 Was $this->trim_parse
     }
     $raw_params['widget'] = $widget_type;
     // v6.48  - coz it was getting lost for hardwired widgets
     //$raw_params['host_post'] = $post->ID; //v6.76
     if (empty($this->default_params)) {
         foreach (Wf_Widget::$current_specs[$widget_type]['params'] as $pkey => $pvalue) {
             $this->default_params[$pkey] = $pvalue['default'];
         }
     }
     $this->params = $this->tidy_params($this->default_params, $raw_params, $region);
     $this->widget_type = $widget_type;
 }