developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #833: patch_833_1.diff

File patch_833_1.diff, 9.6 KB (added by mike, 12 years ago)

Correcting a mistake in a template

  • lib/jelix-www/design/master_admin.css

     
    8181    color: #DD7070;
    8282}
    8383
     84#content h2 {
     85    color: #002830;
     86    border-bottom: 1px solid #002830;
     87}
     88
    8489#menu {
    8590    width:180px;
    8691    float:left;
  • lib/jelix-scripts/templates/controller.daocrud.tpl

     
    1414
    1515    protected $form = '%%module%%~%%table%%';
    1616
     17        /**
     18     * add a filter at the top of the listview
     19     * uncomment to enable, if you want you can use a different form
     20     */
     21        //protected $filterForm = '%%module%%~%%table%%';
     22
    1723    /**
    1824     * the jDb profile to use with the dao
    1925     */
     
    3642     */
    3743    //protected $propertiesForRecordsOrder = array();
    3844
     45        /**
     46     * list of properties to enable the filtering on
     47     * if empty list (default), it use the same properties as $propertiesForList
     48     * this property is only usefull when you use the default "list" template
     49     * @var array
     50     */
     51    //protected $propertiesForFilter = array();
     52
    3953    //protected $listTemplate = 'jelix~crud_list';
    4054    //protected $editTemplate = 'jelix~crud_edit';
    4155    //protected $viewTemplate = 'jelix~crud_view';
  • lib/jelix/core-modules/jelix/locales/en_EN/crud.UTF-8.properties

     
    22title.update = Edit of a record
    33title.create = Create a new record
    44title.view = Record details
     5title.filter = Search
     6title.results = Results (%s)
    57
    68link.return.to.list = Return to the list
    79link.view.record = View
     
    911link.edit.record = Edit
    1012link.delete.record = Delete
    1113
    12 confirm.deletion = Are you sure to want to delete this record ?
    13  No newline at end of file
     14confirm.deletion = Are you sure to want to delete this record ?
  • lib/jelix/core-modules/jelix/locales/en_US/crud.UTF-8.properties

     
    22title.update = Edit of a record
    33title.create = Create a new record
    44title.view = Record details
     5title.filter = Search
     6title.results = Results (%s)
    57
    68link.return.to.list = Return to the list
    79link.view.record = View
     
    911link.edit.record = Edit
    1012link.delete.record = Delete
    1113
    12 confirm.deletion = Are you sure to want to delete this record ?
    13  No newline at end of file
     14confirm.deletion = Are you sure to want to delete this record ?
  • lib/jelix/core-modules/jelix/locales/fr_FR/crud.UTF-8.properties

     
    22title.update = Édition d'un enregistrement
    33title.create = Création d'un enregistrement
    44title.view = Détails d'un enregistrement
     5title.filter = Recherche
     6title.results = Résultats (%s)
    57
    68link.return.to.list = Retourner à la liste
    79link.view.record = Voir
     
    911link.edit.record = Editer
    1012link.delete.record = Effacer
    1113
    12 confirm.deletion = Êtes-vous sûr de vouloir effacer cet enregistrement ?
    13  No newline at end of file
     14confirm.deletion = Êtes-vous sûr de vouloir effacer cet enregistrement ?
  • lib/jelix/core-modules/jelix/templates/crud_list.tpl

     
    11<h1>{@jelix~crud.title.list@}</h1>
     2{if isset($filterForm)}
     3<h2>{@jelix~crud.title.filter@}</h2>
     4{form $filterForm, $filterAction}
     5<table class="jforms-table">
     6{formcontrols $filterFields}
     7    <tr>
     8        <th scope="row">{ctrl_label}</th>
     9        <td>{ctrl_control}</td>
     10    </tr>
     11{/formcontrols}
     12</table>
     13<div>{formreset}{formsubmit}</div>
     14{/form}
     15<h2>{jlocale 'jelix~crud.title.results', $recordCount}</h2>
     16{/if}
    217
    318<table class="records-list">
    419<thead>
  • lib/jelix/controllers/jControllerDaoCrud.class.php

     
    55* @author       Laurent Jouanneau
    66* @contributor  Bastien Jaillot
    77* @contributor  Thibault PIRONT < nuKs >
     8* @contributor  Mickael Fradin
    89* @copyright    2007-2008 Laurent Jouanneau
    910* @copyright    2007 Thibault PIRONT
    1011* @copyright    2007,2008 Bastien Jaillot
     12* @copyright    2009 Mickael Fradin
    1113* @link         http://www.jelix.org
    1214* @licence      http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1315*
     
    3335     * It should be filled by child controller.
    3436     * @var string
    3537     */
    36     protected $form ='';
     38    protected $form = '';
    3739
    3840    /**
     41     * selector of the form to use to filter the results on the "list" template if the filter is enabled
     42     * It should be filled by child controller.
     43     * @var string
     44     */
     45    protected $filterForm = '';
     46
     47    /**
    3948     * list of properties to show in the list page
    4049     * if empty list (default), it shows all properties.
    4150     * this property is only usefull when you use the default "list" template
     
    4453    protected $propertiesForList = array();
    4554
    4655    /**
     56     * list of properties to enable the filtering on
     57     * if empty list (default), it use the same properties as $propertiesForList
     58     * this property is only usefull when you use the default "list" template
     59     * @var array
     60     */
     61    protected $propertiesForFilter = array();
     62
     63    /**
    4764     * list of properties which serve to order the record list
    4865     * if empty list (default), the list is in a natural order
    4966     * keys are properties name, and values are "asc" or "desc"
     
    95112     */
    96113    protected $pseudoFormId = 'jelix_crud_roxor';
    97114
     115    /**
     116     * id for the "pseudo" form used to filter results. You can change it if the default one corresponds to
     117     * a possible id in your dao.
     118     * @var string
     119     */
     120    protected $pseudoFilterFormId = 'jelix_crud_filter';
    98121
     122
    99123    protected $uploadsDirectory ='';
    100124
    101125    /**
     
    177201
    178202        $dao = jDao::get($this->dao, $this->dbProfile);
    179203
     204        if(count($this->propertiesForList)) {
     205            $prop = $this->propertiesForList;
     206        }else{
     207            $prop = array_keys($dao->getProperties());
     208        }
     209        // filter properties. If array is empty we take the same properties as the display
     210        if (empty($this->propertiesForFilter)) {
     211            $this->propertiesForFilter = $prop;
     212        }
     213
    180214        $cond = jDao::createConditions();
     215        $this->_filterSetConditions($cond, $prop);
    181216        $this->_indexSetConditions($cond);
    182217
    183218        $results = $dao->findBy($cond,$offset,$this->listPageSize);
     
    190225        $tpl->assign('list',$results);
    191226        $tpl->assign('primarykey', $pk[0]);
    192227
    193         if(count($this->propertiesForList)) {
    194             $prop = $this->propertiesForList;
    195         }else{
    196             $prop = array_keys($dao->getProperties());
    197         }
     228        // filter
     229        $filterForm = $this->_filterCreateForm();
     230        $tpl->assign('filterForm', $filterForm);
     231        $tpl->assign('filterAction', $this->_getAction('index'));
     232        $tpl->assign('filterFields', $this->propertiesForFilter);
    198233
    199234        $tpl->assign('properties', $prop);
    200235        $tpl->assign('controls',$form->getControls());
     
    236271    }
    237272
    238273    /**
     274     * this method set conditions according to the form filter submit
     275     * @param jDaoConditions $cond the conditions
     276     * @param Array $prop the default properties
     277     */
     278    protected function _filterSetConditions($cond) {
     279        if ($this->filterForm) {
     280            if ($this->param('_submit'))
     281                $form = jForms::fill($this->form, $this->pseudoFilterFormId);
     282            else
     283                $form = jForms::get($this->form, $this->pseudoFilterFormId);
     284            if ($form) {
     285                foreach($this->propertiesForFilter as $propertie) {
     286                    $value = $form->getData($propertie);
     287                    if (!empty($value))
     288                        $cond->addCondition($propertie, 'LIKE', $value.'%');
     289                }
     290            }
     291        }
     292    }
     293
     294    /**
     295     * Get or Create the filter form if we use filter
     296     * @return jFormsBase the form if filter is enable
     297     */
     298    protected function _filterCreateForm() {
     299        if ($this->filterForm) {
     300            $form = jForms::get($this->filterForm, $this->pseudoFilterFormId);
     301            if (!$form)
     302                $form = jForms::create($this->filterForm, $this->pseudoFilterFormId);
     303            //Remove required flags in the form
     304            foreach($form->getControls() as $control) {
     305                $control->required = false;
     306            }
     307            return $form;
     308        }
     309    }
     310
     311    /**
    239312     * prepare a form to create a record.
    240313     */
    241314    function precreate() {