<?php
/** View Template: update articles for a specific category template
 *
 * @package koubel homepage
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */
?>
<h2>Update articles in the category</h2>
<div>Category: <?php echo $this->anchor($this->url(
    array(
        "conteroller" => "category",
        "action" => "edit",
        "item" => $this->category->getId()),
    "blogAdminItemAction"),$this->escape($this->category->getName()))?></div>

<?php if(isset($this->messages)):foreach($this->messages as $message):?>
<div style="color:blue"><?php echo $message?></div>
<?php endforeach;endif?>

<form id="blogCategoryArticlesForm" method="post" action="<?php echo
$this->url(
    array(
        "conteroller" => "category",
        "action" => "edit-articles",
        "item" => $this->category->getId()),
    "blogAdminItemAction")?>">

<table>
 <tr>
  <th>Assigned articles</th><th></th><th>All Articles</th>
 </tr>
 <tr>
 <td style="width:11em">
  <select style="width:100%" id="assigned" name="assigned[]" multiple="multiple" size="10">
   <?php foreach($this->categoryArticles as $article):?>
    <option value="<?php echo $article->getId()?>"><?php echo $this->escape($article->getTitle())?></option>
   <?php endforeach;?>
  </select>
 </td>
 <td>
  <div style="float:left; width:110px">
   <input type="button" name="left"  value="&lt;&lt;" onclick="copySelectedOptions(document.getElementById('allArticles'),document.getElementById('assigned'),true)" /><br /><br />
   <input type="button" name="leftall" value="All &lt;&lt;" onclick="copyAllOptions(document.getElementById('allArticles'),document.getElementById('assigned'),true)" /><br /><br />
   <input type="button" name="remleftsel" value="Remove selected" onclick="removeSelectedOptions(document.getElementById('assigned'))" /><br /><br />
  </div>
 </td>
 <td style="width:11em">
  <select style="width:100%" id="allArticles" name="allArticles[]" multiple="multiple" size="10">
   <?php foreach($this->allArticles as $article):?>
    <option value="<?php echo $article->getId()?>"><?php echo $this->escape($article->getTitle())?></option>
   <?php endforeach;?>
  </select>
 </td>
 </tr>
</table>

<!-- button must be in div -->
<div style="margin-top:0.5em">
 <input type="submit" name="action" onclick="preselect();return true;" />
 <input type="reset" value="Reset" />
</div>

</fieldset>

</form>

<script type="text/javascript">
/**
 * select all options in the assigned multiline select
 */
function preselect()
{
 var obj=document.getElementById('assigned');
 for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
 }
}
</script>
