コード例 #1
0
ファイル: category.php プロジェクト: optimosolution/marhk
 function store($data, $return)
 {
     //If this file doesn't exists don't save it
     if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
         $this->setError('File not exists');
         return false;
     }
     $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
     //If there is no title and no alias, use filename as title and alias
     if (!isset($data['title']) || isset($data['title']) && $data['title'] == '') {
         $data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     if (!isset($data['alias']) || isset($data['alias']) && $data['alias'] == '') {
         $data['alias'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     //clean alias name (no bad characters)
     //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
     if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '' || (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '')) {
         phocagalleryimport('phocagallery.geo.geo');
         $coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
         if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '') {
             $data['longitude'] = $coords['longitude'];
         }
         if (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '') {
             $data['latitude'] = $coords['latitude'];
         }
         if ((!isset($data['zoom']) || isset($data['zoom']) && $data['zoom'] == '') && $data['longitude'] != '' && $data['latitude'] != '') {
             $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
         }
     }
     $row =& $this->getTable('phocagallery', 'Table');
     // Bind the form fields to the Phoca gallery table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Create the timestamp for the date
     $row->date = gmdate('Y-m-d H:i:s');
     // if new item, order last in appropriate group
     if (!$row->id) {
         $where = 'catid = ' . (int) $row->catid;
         $row->ordering = $row->getNextOrder($where);
     }
     // Make sure the Phoca gallery table is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Store the Phoca gallery table to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     //Create thumbnail small, medium, large
     $returnFrontMessage = PhocaGalleryFileThumbnail::getOrCreateThumbnail($row->filename, $return, 1, 1, 1, 1);
     if ($returnFrontMessage == 'Success') {
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
 function recreate($cid = array(), &$message)
 {
     if (count($cid)) {
         JArrayHelper::toInteger($cid);
         $cids = implode(',', $cid);
         $query = 'SELECT a.filename, a.extid' . ' FROM #__phocagallery AS a' . ' WHERE a.id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         $files = $this->_db->loadObjectList();
         if (isset($files) && count($files)) {
             foreach ($files as $key => $value) {
                 if (isset($value->extid) && (int) $value->extid > 0) {
                     // Picasa cannot be recreated
                     $message = JText::_('COM_PHOCAGALLERY_ERROR_EXT_IMG_NOT_RECREATE');
                     return false;
                 } else {
                     if (isset($value->filename) && $value->filename != '') {
                         $original = PhocaGalleryFile::existsFileOriginal($value->filename);
                         if (!$original) {
                             // Original does not exist - cannot generate new thumbnail
                             $message = JText::_('COM_PHOCAGALLERY_FILEORIGINAL_NOT_EXISTS');
                             return false;
                         }
                         // Delete old thumbnails
                         $deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1);
                     } else {
                         $message = JText::_('COM_PHOCAGALLERY_FILENAME_NOT_EXISTS');
                         return false;
                     }
                 }
                 if (!$deleteThubms) {
                     $message = JText::_('COM_PHOCAGALLERY_ERROR_DELETE_THUMBNAIL');
                     return false;
                 }
             }
         } else {
             $message = JText::_('COM_PHOCAGALLERY_ERROR_LOADING_DATA_DB');
             return false;
         }
     } else {
         $message = JText::_('COM_PHOCAGALLERY_ERROR_ITEM_NOT_SELECTED');
         return false;
     }
     return true;
 }