gino-news  2.1.0
Modulo News per gino CMS
class.Category.php
Go to the documentation of this file.
1 <?php
12 namespace Gino\App\News;
13 
14 use \Gino\ImageField;
15 use \Gino\SlugField;
16 
25 class Category extends \Gino\Model {
26 
27  protected static $_extension_img = array('jpg', 'jpeg', 'png');
28  public static $table = 'news_category';
29 
37  function __construct($id, $instance) {
38 
39  $this->_controller = $instance;
40  $this->_tbl_data = self::$table;
41 
42  $this->_fields_label = array(
43  'name'=>_("Nome"),
44  'slug'=>array(_("Slug"), _('utilizzato per creare un permalink alla risorsa')),
45  'description'=>_('Descrizione'),
46  'image'=>array(_('Immagine'), _('Attenzione, l\'immagine inserita non viene ridimensionata'))
47  );
48 
49  parent::__construct($id);
50 
51  $this->_model_label = _('Categoria');
52  }
53 
58  function __toString() {
59  return (string) $this->name;
60  }
61 
69  public function structure($id) {
70 
71  $structure = parent::structure($id);
72 
73  $structure['slug'] = new SlugField(array(
74  'name' => 'slug',
75  'model' => $this,
76  'required' => TRUE,
77  'autofill' => array('name')
78  ));
79 
80  $base_path = $this->_controller->getBaseAbsPath() . OS . 'img';
81  $structure['image'] = new ImageField(array(
82  'name' => 'image',
83  'model' => $this,
84  'extensions' => self::$_extension_img,
85  'path' => $base_path,
86  'resize' => FALSE
87  ));
88 
89  return $structure;
90  }
91 
98  public function imagePath($controller) {
99  return $controller->getBasePath().'/img/'.$this->image;
100  }
101 
102 }
structure($id)
Sovrascrive la struttura di default.
imagePath($controller)
Path relativo dell'immagine associata.
__toString()
Rappresentazione a stringa dell'oggetto.
__construct($id, $instance)
Costruttore.
Classe di tipo Gino.Model che rappresenta una categoria di news.
Namespace dell'applicazione News