コード例 #1
0
ファイル: index.php プロジェクト: intelliants/subrion
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage(iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('body'))), false);
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['owner'], $entry['tags']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $iaPicture = $this->_iaCore->factory('picture');
         $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
         if ($image = $iaPicture->processImage($_FILES['image'], iaUtil::getAccountDir(), iaUtil::generateToken(), $info)) {
             empty($entry['image']) || $iaPicture->delete($entry['image']);
             // already has an assigned image
             $entry['image'] = $image;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: index.php プロジェクト: bohmszi/kdbe_cms
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage('body_is_empty');
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if (!empty($data['owner'])) {
         if ($memberId = $this->_iaCore->iaDb->one_bind('id', '`username` = :name OR `fullname` = :name', array('name' => iaSanitize::sql($_POST['owner'])), iaUsers::getTable())) {
             $entry['member_id'] = $memberId;
         } else {
             $this->addMessage('incorrect_owner_specified');
         }
     } else {
         $entry['member_id'] = iaUsers::getIdentity()->id;
     }
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['owner']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $iaPicture = $this->_iaCore->factory('picture');
         $path = iaUtil::getAccountDir();
         $file = $_FILES['image'];
         $token = iaUtil::generateToken();
         $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
         if ($image = $iaPicture->processImage($file, $path, $token, $info)) {
             if ($entry['image']) {
                 $iaPicture = $this->_iaCore->factory('picture');
                 $iaPicture->delete($entry['image']);
             }
             $entry['image'] = $image;
         }
     }
     unset($entry['tags']);
     return true;
 }
コード例 #3
0
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage('body_is_empty');
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $this->_iaCore->loadClass(iaCore::CORE, 'picture');
         $iaImage = $this->_iaCore->factoryPlugin($this->getPluginName(), iaCore::ADMIN, 'image');
         $imageData = json_decode($entry['image-data'], true);
         $path = iaUtil::getAccountDir();
         $file = $_FILES['image'];
         $token = iaUtil::generateToken();
         $info = array('image_width' => $this->_iaCore->get('portfolio_image_width'), 'image_height' => $this->_iaCore->get('portfolio_image_height'), 'crop_width' => $imageData['width'], 'crop_height' => $imageData['height'], 'thumb_width' => $this->_iaCore->get('portfolio_thumbnail_width'), 'thumb_height' => $this->_iaCore->get('portfolio_thumbnail_height'), 'positionX' => $imageData['x'], 'positionY' => $imageData['y'], 'position' => 'LT', 'resize' => 'after_crop', 'resize_mode' => iaImage::CROP);
         if ($image = $iaImage->processFolioImage($file, $path, $token, $info)) {
             if ($entry['image']) {
                 $iaImage = $this->_iaCore->factory('picture');
                 $iaImage->delete($entry['image']);
             }
             $entry['image'] = $image;
         }
     }
     if (empty($entry['image'])) {
         $this->addMessage('invalid_image_file');
     }
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['image-src']);
     unset($entry['image-data']);
     return true;
 }