예제 #1
0
 /**
  * Make some operations related to this field before Model Entity will be
  * completely removed.
  *
  * @access   public
  * @param    ModelCore $oModel
  * @param    mixed     $mValue
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function whenRemovingEntity(ModelCore $oModel, $mValue)
 {
     parent::whenRemovingEntity($oModel, $mValue);
     if (empty($mValue)) {
         return FALSE;
     }
     $aValues = [];
     if (!is_array($mValue)) {
         $aValues[] = $mValue;
     }
     foreach ($aValues as $oFileBroker) {
         /* @var $oFileBroker \Plethora\ModelCore\FileBroker */
         $oFile = $oFileBroker->getFile();
         /* @var $oFile \Model\File */
         \Plethora\ImageStyles::removeStyledImgCache($oFile->getPath() . DS . $oFile->getNameWithExt());
     }
 }
예제 #2
0
파일: Page.php 프로젝트: ktrzos/plethora
 /**
  * Fields config for backend.
  *
  * @access   public
  * @return   ModelCore\MConfig
  * @since    1.0.0
  * @version  1.0.3-dev, 2015-04-29
  */
 protected static function generateConfig()
 {
     # create config
     $config = parent::generateConfig();
     # create fields
     $config->addField(Form\Field\Hidden::singleton('id')->setLabel('ID')->setDisabled());
     $config->addField(Form\Field\Select::singleton('published')->setOptions(['Nie', 'Tak'])->setLabel(__('Published'))->setRequired()->addRulesSet(Validator\RulesSetBuilder::factory()->addRule(['in_array', [':value', [1, 0]]])));
     $config->addField(Form\Field\Text::singleton('title')->setLabel(__('Title'))->setRequired());
     $config->addField(Form\Field\Text::singleton('rewrite')->setRequired()->setLabel(__('URL alias')));
     $config->addField(Form\Field\Text::singleton('keywords')->setLabel(__('Keywords')));
     $config->addField(Form\Field\ImageModel::singleton('image')->setBrokerModel('\\Model\\Page\\Image')->setUploadPath('uploads/page')->setRequired()->setLabel(__('Image'))->addRulesSet(Validator\RulesSetBuilder\ImageModel::factory()->allowedExt(':value', ['jpg', 'gif', 'png', 'jpeg'])));
     $config->addField(Form\Field\FileModel::singleton('files')->setBrokerModel('\\Model\\Page\\File')->setUploadPath('uploads/page_files')->setQuantity(0)->setLabel(__('Attachments'))->addRulesSet(Validator\RulesSetBuilder\ImageModel::factory()->allowedExt(':value', ['txt', 'pdf', 'docx', 'doc', 'rtf', 'zip'])));
     $config->addField(Form\Field\Textarea::singleton('description')->setLabel(__('Description')));
     $config->addField(Form\Field\Tinymce::singleton('content')->setRequired()->setLabel(__('Content')));
     # return config
     return $config;
 }