Example #1
0
function marantz_plugin_page()
{
    global $_, $conf, $myUser;
    if (isset($_['section']) && $_['section'] == 'marantz') {
        if ($myUser != false) {
            ?>
	<div class="span9 userBloc">
		<h1>Marantz</h1>
		<p></p>
		<ul class="nav nav-tabs">
			<li <?php 
            echo !isset($_['block']) || $_['block'] == 'cmd' ? 'class="active"' : '';
            ?>
 > <a href="setting.php?section=marantz&amp;block=cmd"><i class="fa fa-angle-right"></i> Commandes Vocales</a></li>
			<li <?php 
            echo isset($_['block']) && $_['block'] == 'new' ? 'class="active"' : '';
            ?>
 > <a href="setting.php?section=marantz&amp;block=new"><i class="fa fa-angle-right"></i> Nouvelles Commandes</a></li>
			<li <?php 
            echo isset($_['block']) && $_['block'] == 'edit' ? 'class="active"' : 'class="disabled"';
            ?>
 > <a href="setting.php?section=marantz&amp;block=edit"><i class="fa fa-angle-right"></i> Modification</a></li>
		</ul>
	
	
	<?php 
            if (isset($_['section']) && $_['section'] == 'marantz' && (@$_['block'] == 'cmd' || @$_['block'] == '')) {
                if ($myUser != false) {
                    $maranzManager = new MarantzCmd();
                    $marantzCmds = $maranzManager->populate();
                    ?>
		
					<table class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>Name</th>
							<th>Commande vocale</th>
							<th>Paramètres</th>
							<th>Confidence</th>
							<th>Actions</th>
						</tr>
						
					</thead>
					<?php 
                    if (is_array($marantzCmds)) {
                        foreach ($marantzCmds as $row) {
                            ?>
									<tr>
										<!--td><?php 
                            //echo $row->getType();
                            ?>
</td -->
										<td><?php 
                            echo $row->getName();
                            ?>
</td>
										<td><?php 
                            echo $conf->get('VOCAL_ENTITY_NAME') . $row->getCmd();
                            ?>
</td>
										<td><?php 
                            echo urldecode($row->getParametre());
                            ?>
</td>
										<td><?php 
                            echo $row->getConfidence();
                            ?>
</td>
										<td><a class="btn" href="action.php?action=marantz_enable&id=<?php 
                            echo $row->getId();
                            ?>
" >
										<?php 
                            if ($row->getVocal()) {
                                echo '<i class="fa fa-microphone fa-lg" style="color:#84C400"  title="D&eacute;sactive l\\’&eacute;coute de cette commande"></i>';
                            } else {
                                echo '<i class="fa fa-microphone-slash fa-lg" style="color:#C1004F" title="Active l\\’&eacute;coute de cette commande"></i>';
                            }
                            ?>
										</a>
										<a class="btn" href="setting.php?section=marantz&amp;block=edit&id=<?php 
                            echo $row->getId();
                            ?>
"><i class="fa fa-pencil-square-o fa-lg"></i></a>
										<a class="btn" href="action.php?action=marantz_delete&id=<?php 
                            echo $row->getId();
                            ?>
"><i class="fa fa-trash-o fa-lg"  style="color:#C1004F"></i></a></td>
									</tr>
									
									<?php 
                        }
                    }
                    ?>
					
					
					</table>
					
					<?php 
                }
            }
            ?>
		<?php 
            if (isset($_['section']) && $_['section'] == 'marantz' && @$_['block'] == 'new') {
                if ($myUser != false) {
                    ?>
		
					<table class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>Name</th>
							<th>Commande vocale</th>
							<th>Paramètres</th>
							<th>Confidence</th>
							<th>Actions</th>
						</tr>
					<?php 
                    $marantzPlugins = new MarantzPlugin($conf);
                    $commands = $marantzPlugins->predefined_commands($actionUrl, $conf->get('VOCAL_ENTITY_NAME'));
                    foreach ($commands as $command) {
                        ?>
							<tr>
							<td><?php 
                        echo $command['name'];
                        ?>
</td>
							<td><?php 
                        echo $command['command'];
                        ?>
</td>
							<td><?php 
                        echo urldecode($command['parametre']);
                        ?>
</td>
							<td><?php 
                        echo $command['confidence'];
                        ?>
</td>
							<td><a class="btn" href="action.php?action=marantz_add&uid=<?php 
                        echo $command['uid'];
                        ?>
" title="Active ou désactive l’écoute de cette commande">
										<i class="fa fa-plus fa-lg"></i>
										</a></td>
						</tr>
					
					
					<?php 
                    }
                    ?>
						
					</thead></table>
					
					<?php 
                }
            }
            if (isset($_['section']) && $_['section'] == 'marantz' && @$_['block'] == 'edit') {
                if ($myUser != false && isset($_['id'])) {
                    if (isset($_['id'])) {
                        $marantz = new MarantzCmd();
                        $marantz = $marantz->load(array('id' => $_['id']));
                    } else {
                        $marantz = new MarantzCmd();
                    }
                    ?>
					<div class="span9 userBloc">
						<form class="form-inline" action="action.php?action=marantz_edit" method="POST">
						<legend>Modification de la Commande Vocale</legend>
							<input type="hidden"  name="id" value="<?php 
                    echo $marantz->getId();
                    ?>
" >
							<label>Nom : </label><?php 
                    echo $marantz->getName();
                    ?>
	
							<br/><br/><label>Commande  : </label><br/>
							<?php 
                    echo $conf->get('VOCAL_ENTITY_NAME');
                    ?>
<input type="text" class="input-large" name="cmd" value="<?php 
                    echo $marantz->getCmd();
                    ?>
" >					
							<br/><br/><label>Parametre : </label><br/>
							<input type="text" class="input-large" name="parametre" value="<?php 
                    echo $marantz->getParametre();
                    ?>
" >					
							<br/><br/><label>Confidence :</label><br/>
							 <select name="confidence" id="confidence">
                                <?php 
                    for ($confidence = 1; $confidence <= 9; $confidence++) {
                        ?>
                                
                                    <option value=0.<?php 
                        echo $confidence;
                        ?>
 <?php 
                        echo '0.' . $confidence == $marantz->getConfidence() ? "selected" : "";
                        ?>
>0.<?php 
                        echo $confidence;
                        ?>
</option>
                                <?php 
                    }
                    ?>
                            </select>    					
							<br/><br/><button type="submit" class="btn">Sauvegarder</button>
						</form>
					</div>
					<?php 
                }
            }
            ?>
		</div><?php 
        }
    }
}