public static function createWidget($kshow, $entry_id = null, $parent_widget_obj_or_id = null, $ui_conf_id = 1, $custom_data = null, $partner_data = null, $security_type = null)
 {
     $widget = new widget();
     $widget->setKshowId($kshow->getId());
     $widget->setEntryId($entry_id);
     $widget->setPartnerId($kshow->getPartnerId());
     $widget->setSubpId($kshow->getSubpId());
     $source_widget = null;
     if ($parent_widget_obj_or_id != null) {
         if ($parent_widget_obj_or_id instanceof widget) {
             $source_widget = $parent_widget_obj_or_id;
             $widget->setSourceWidgetId($parent_widget_obj_or_id->getId());
         } else {
             // assume its an id
             $source_widget = widgetPeer::retrieveByPK($parent_widget_obj_or_id);
             $widget->setSourceWidgetId($parent_widget_obj_or_id);
         }
     }
     $widget->setUiConfId($ui_conf_id);
     if ($source_widget) {
         $widget->setRootWidgetId($source_widget->getRootWidgetId());
         if ($ui_conf_id == null) {
             // if none was explicitly set - use the parent_widget's ui_conf
             $widget->setUiConfId($source_widget->getUiConfId());
         }
     }
     $widget->setCustomData($custom_data);
     $widget->setPartnerData($partner_data);
     $widget->setSecurityType($security_type);
     $widget->setId(self::calculateId($widget));
     if ($widget->getUiConfId() == null) {
         // set the default to be 1
         $widget->setUiConfId(1);
     }
     if ($widget->getRootWidgetId() == null) {
         // set the root to be self -
         $widget->setRootWidgetId($widget->getId());
     }
     $widget->save();
     return $widget;
 }