Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ all elements ]

Source for file Administration.php

Documentation is available at Administration.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * LTranslation class file.
  6.  *
  7.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9.  * @author $Author: schmunk $
  10.  * @version $Revision: 297 $  $Date: 2006-07-03 19:33:02 +0200 (Mo, 03 Jul 2006) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LTranslate
  13.  */
  14.  
  15. /**
  16.  * Displays main media manager administration interface
  17.  *
  18.  * @package Admin.Pages
  19.  * @subpackage LTranslate
  20.  */
  21.  
  22. Prado :: setPathOfAlias("LTranslate"dirname(__FILE__));
  23. Prado :: using("LTranslate.db.propel.*");
  24. Prado :: using("LTranslate.db.propel.l_translate.*");
  25.  
  26. class Administration extends TPage
  27. {
  28.     public $Core;
  29.  
  30.     /**
  31.      * @ignore
  32.      */
  33.     function onInit($param)
  34.     {
  35.         parent :: onInit($param);
  36.  
  37.         $conn $this->Application->getModule("database")->getConnection("l_translate");
  38.  
  39.         $catalogs CataloguePeer::doSelect(new Criteria$conn);
  40.         #var_dump($catalogs);
  41.  
  42.         $this->CatalogueId->DataSource $catalogs;
  43.         $this->CatalogueId->DataTextField "Name";
  44.         $this->CatalogueId->DataValueField "CatId";
  45.         $this->CatalogueId->dataBind();
  46.     }
  47.  
  48.     /**
  49.      * @ignore
  50.      */
  51.     function onPreRender($param)
  52.     {
  53.         parent :: onPreRender($param);
  54.  
  55.         $this->fillGrid();
  56.     }
  57.  
  58.     function queryCatalogueId()
  59.     {
  60.         $catalogue_where "messages.".$this->Application->Globalization->Culture;
  61.  
  62.         $c new Criteria();
  63.         $c->add(CataloguePeer::NAME$catalogue_where);
  64.  
  65.         $result CataloguePeer::doSelect($c);
  66.  
  67.         if ($result[0])
  68.         {
  69.             return $result[0]->getCatId();
  70.         }
  71.     }
  72.  
  73.     function cleanupDatabase()
  74.     {
  75.         $c new Criteria();
  76.         $c->addAnd(TransUnitPeer::TARGETnull);
  77.         $result TransUnitPeer::doDelete($c);
  78.     }
  79.  
  80.     function deleteRecord($sender$param)
  81.     {
  82.         $c new Criteria();
  83.         $c->addAnd(TransUnitPeer::MSG_ID$sender->CustomData);
  84.         $result TransUnitPeer::doDelete($c);
  85.     }
  86.  
  87.     function queryRecords()
  88.     {
  89.         $conn $this->Application->getModule("database")->getConnection("l_translate");
  90.  
  91.         $c new Criteria();
  92.         $c->addAscendingOrderByColumn(TransUnitPeer::SOURCE);
  93.  
  94.         // query only items with same cat_id as user's culture, if user is not root
  95.         if (!$this->User->isInRole('root'))
  96.         {
  97.             $cat_id $this->queryCatalogueId();
  98.             $c->add(TransUnitPeer::CAT_ID$cat_id);
  99.             $result TransUnitPeer::doSelect($c);
  100.  
  101.             return $result;
  102.         }
  103.  
  104.         // select only current culture, even if root, if chosen catalogue is "all"
  105.         if ($this->CatalogueId->SelectedValue == "all")
  106.         {
  107.             $result TransUnitPeer::doSelect($c$conn);
  108.  
  109.         else if ($this->CatalogueId->SelectedValue != "all"{
  110.             $cat_id $this->CatalogueId->SelectedValue;
  111.  
  112.             $c->add(TransUnitPeer::CAT_ID$cat_id);
  113.             $result TransUnitPeer::doSelect($c$conn);
  114.         }
  115.  
  116.         return $result;
  117.     }
  118.  
  119.     function fillGrid()
  120.     {
  121.         $translation_data $this->queryRecords();
  122.         $filter_type $this->FilterType->SelectedValue;
  123.  
  124.         if ($filter_type != "all"$translation_data $this->filter($translation_data);
  125.  
  126.         $this->TranslationGrid->setDataSource($translation_data);
  127.         $this->TranslationGrid->dataBind();
  128.     }
  129.  
  130.     function filter($data)
  131.     {
  132.         $shown_objects array();
  133.  
  134.         foreach($data as $dbObject)
  135.         {
  136.             if (!$dbObject->getTarget()) $shown_objects[$dbObject;
  137.         }
  138.         return $shown_objects;
  139.     }
  140.  
  141.     /**
  142.      * edits selected item
  143.      */
  144.     public function editItem($sender$param)
  145.     {
  146.         $conn$this->Application->getModule("database")->getConnection("l_translate""propel");
  147.         $id $this->TranslationGrid->DataKeys[$param->Item->ItemIndex];
  148.         $result TransUnitPeer :: retrieveByPK($id$conn);
  149.  
  150.         $this->TranslationGrid->EditItemIndex $param->Item->ItemIndex;
  151.  
  152.         $this->fillGrid();
  153.     }
  154.  
  155.         /**
  156.     * Description
  157.     * @todo
  158.     */
  159.     function saveItem($sender$param)
  160.     {
  161.         $conn$this->Application->getModule("database")->getConnection("l_translate""propel");
  162.  
  163.         $item $param->Item;
  164.         $id $this->TranslationGrid->DataKeys[$item->ItemIndex];
  165.  
  166.         $result TransUnitPeer :: retrieveByPK($id$conn);
  167.  
  168.         $result->setTarget($item->Cells[3]->Target->Text);
  169.  
  170.         $result->save();
  171.  
  172.         $this->TranslationGrid->EditItemIndex= -1;
  173.         $this->fillGrid();
  174.     }
  175.  
  176.     /**
  177.     * Description
  178.     * @todo
  179.     */
  180.     public function changePage($sender$param)
  181.     {
  182.         $this->TranslationGrid->CurrentPageIndex$param->NewPageIndex;
  183.         $this->fillGrid();
  184.     }
  185.  
  186.     /**
  187.     * Description
  188.     * @todo
  189.     */
  190.     public function cancelItem($sender$param)
  191.     {
  192.         $this->TranslationGrid->EditItemIndex= -1;
  193.         $this->fillGrid();
  194.     }
  195.  
  196. }
  197. ?>

Documentation generated on Sun, 25 Feb 2007 16:09:20 +0100 by phpDocumentor 1.3.1