<?php 
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# Display page to add module (rss or other widget)
#
# !! be careful, this file must be saved under uft8 format, and display an e accentuated here : é
# ***************************************

$not_access=1;
$granted="I";

require_once('includes_mobile.php'); 
require_once('../includes/template.inc.php');
require_once('../includes/miscfunctions.inc.php');

$prevTabId='';
$html = '';
$html_widgets = '';
$html_tabs = '';
$selectedTab = '';
if (isset($_REQUEST['tab']) && !empty($_REQUEST['tab'])) {
	$selectedTab = $_REQUEST['tab'];
}

$DB->getResults($mobPortalAddModule_getAvailableWidgetsList,$DB->escape($_SESSION['user_id']));
$html_widgets .= '<p>'.lg("select_widget").'</p>';
while($row = $DB->fetch(0)) {
    $widget_id = $row['item_id'];
    $widget_name = $row['title'];
    if ($widget_id!=86){
        $html_widgets .= '<input type="radio" name="widgets" value="'.$widget_id.'" id="'.$widget_id.'"  /> 
                          <label for="'.$widget_id.'">'.$widget_name.'</label><br />';
    }
}
$html_widgets .= '<br />';
$DB->freeResults();

$options = defineHeader();
          
echo page_begining();

echo '<div id="header">';
    echo generate_header($options);
echo '</div>';

echo '<div id="wrapper">';
echo '<div id="page">';

$htmlTabs = buildTabs($selectedTab,$tabs);
echo $htmlTabs;

$currTab = '';
for ($i=0;$i<count($tabs);$i++) {
    if ($tabs[$i]["id"] == $selectedTab)    
        $currTab = $tabs[$i]["name"];
}

echo '<div id="addwidget_form">';
echo '<span><strong>'.lg("Information").'</strong>: '.lg("addWidgetInCurrentTab",$currTab).'</span><br /><br />';
echo '<div class="configuration_title">'.lg("addAFeed").'</div><br />';
echo '<form method="post" action="scr_addmodule_rss.php">
        <input type="hidden" name="selectedtab" value="'.$selectedTab.'" />
        <span>'.lg("feedUrl").': <input type="text" name="url" size="13"></span>
        <input type="submit" class="minibtn" value="'.lg('ok').'">'.(isset($_GET['msg'])?$_GET['msg']:'').'
	 </form>';
echo '<br /><div class="configuration_title">'.lg("addAWidget").'</div><br />';
echo '<form method="post" action="scr_addmodule_widget.php">';
echo '<input type="hidden" name="selectedtab" value="'.$selectedTab.'"> ';
echo  $html_widgets;
echo '<div id="page_footer">
        <input class="submit" type="submit" value="'.lg("add").'"> 
        <a href="portal.php?tab='.$selectedTab.'"><input class="submit" type="button" value="'.lg("cancel").'"></a>
      </div>
      </form>';
echo '  </div>
      </div>';  
echo '</div>';
  
echo generate_footer();
?>