<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\Seo\Module\Admin;

use Core\Control\Button\Button;
use Core\Controller\AdministratorController;
use Core\View\View;
use Core\View\ElementView;

use Core\Control\TabStrip\TabStrip;
use Core\Control\EntityGrid\EntityGrid;
use Core\Control\EntityGrid\EntityColumn;
use Core\Control\EntityGrid\EntityIconColumn;
use Core\Control\EntityGrid\EntityFunctionColumn;
use Apps\Seo\Widget\SeoForm\SeoForm;

/*
 * 
 */
 class AdminController extends AdministratorController
 {
    /**
     * Constructeur
     */
    function _construct($core="")
    {
          $this->Core = $core;
    }

    /**
     * Creation
     */
    function Create()
    {
    }

    /**
     * Initialisation
     */
    function Init()
    {
    }

    /**
     * Affichage du module
     */
    function Show($all=true)
    {
        $view = new View(__DIR__."/View/index.tpl", $this->Core);

        $tabSeo = new TabStrip("tabSeo", "Seo"); 
        $tabSeo->AddTab($this->Core->GetCode("Seo.Seo"), $this->GetTabSeo());
        $tabSeo->AddTab($this->Core->GetCode("Seo.Page"), $this->GetTabPage());
     
        $view->AddElement(new ElementView("tabSeo", $tabSeo->Render()));
        
        return $view->Render();
    }
    
     /***
    * Detail of the Seo app
    */
   function GetTabSeo(){

      $seoForm = new SeoForm($this->Core);
      $seoForm->Load($blog);
      return $seoForm->Render($blog);   
    }
    
    /** 
     * Detail of pages
     */
    function GetTabPage(){
      
      $gdPages = new EntityGrid("gdPages", $this->Core);
      $gdPages->Entity = "Apps\Seo\Entity\SeoPage";
      $gdPages->App = "Seo";
      $gdPages->Action = "GetTabPage";

      $btnAdd = new Button(BUTTON, "btnAddPage");
      $btnAdd->Value = $this->Core->GetCode("Seo.AddPage");

      $gdPages->AddButton($btnAdd);
      $gdPages->AddColumn(new EntityColumn("Url", "Url"));
      $gdPages->AddColumn(new EntityColumn("Title", "Title"));
      
      $gdPages->AddColumn(new EntityIconColumn("Action", 
                                                array(array("EditIcone", "Seo.EditPage", "Seo.EditPage"),
                                                      array("DeleteIcone", "Seo.DeletePage", "Seo.DeletePage"),
                                                )    
                        ));

      return $gdPages->Render();
    }
    
    /*
    * Get the home page
    */
   function Index()
   {
       $view = new View(__DIR__."/View/index.tpl", $this->Core);
       return $view->Render();
   }
          
          /*action*/
 }?>