示例#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
 static function wf_widgets()
 {
     // v5.3
     global $post;
     // v6.44
     //$regions = Wf_Widget::$regions;  // v5.3
     $regions = get_regions_list($post);
     // v6.47
     $widget_list = self::list_wf_widgets($regions);
     WF_Debug::stash(array('$widget_list' => $widget_list));
     $region_html = Wf_Widget::$region_html;
     // v4.4
     foreach ($regions as $region) {
         // v3.60
         if (!isset($region_html[$region])) {
             $region_html[$region] = '';
             // v4.4
         }
         $w_list = array();
         // v6.44?  WCTS  errors
         //Cannot use string offset as an array in ... wf_widgets.php on line 175 (= the 'disinherit' line)
         if (count($widget_list[$region]['current']) > 0) {
             $w_list[$region] = $widget_list[$region]['current'];
             if (!is_array($w_list[$region][0])) {
                 // v6.44?
                 error_log("WF bug trap: wf_widgets.php, REQUEST_URI = " . $_SERVER['REQUEST_URI'] . ", REMOTE_ADDR = " . $_SERVER['REMOTE_ADDR']);
             } else {
                 //if($w_list[$region][0]['qstring'] == "0") { // disinherit!
                 if ($w_list[$region][0]['widget_type'] == "cancel") {
                     // disinherit!  // v6.66
                     continue;
                     // skip to next region
                 }
             }
         } elseif (count($widget_list[$region]['inherited']) > 0 && $widget_list[$region]['inherited'][0]['widget_type'] != "cancel") {
             // v6.66
             $w_list[$region] = $widget_list[$region]['inherited'];
         } else {
             continue;
             // skip to next region
         }
         foreach ($w_list[$region] as $widgnum => $widget) {
             // widgnum introduced 12.3.12 to allow id for widget
             $qstring = $widget['qstring'] . "&widgnum=" . $widgnum;
             // ."&widget=".$widget['widget_type'];  // v6.48
             $widget_class = Wf_Widget::$current_specs[$widget['widget_type']]['class_name'];
             // eg: Post_widget
             $widget_obj = new $widget_class($region, $widget['widget_type'], $qstring);
             $region_html[$region] .= $widget_obj->get_html();
             // ($region, $qstring); // v4.4
             WF_Debug::stash(array('$qstring' => $qstring, '$widget_class' => $widget_class, '$region' => $region, '$region_html["' . $region . '"]' => $region_html[$region]));
         }
     }
     Wf_Widget::$region_html = $region_html;
     // v5.3
     //WF_Debug::stash(array('$region_html' => $region_html));
 }