当前位置: 首页>>代码示例>>PHP>>正文


PHP RSMembershipHelper::createThumb方法代码示例

本文整理汇总了PHP中RSMembershipHelper::createThumb方法的典型用法代码示例。如果您正苦于以下问题:PHP RSMembershipHelper::createThumb方法的具体用法?PHP RSMembershipHelper::createThumb怎么用?PHP RSMembershipHelper::createThumb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RSMembershipHelper的用法示例。


在下文中一共展示了RSMembershipHelper::createThumb方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 function save()
 {
     $row =& JTable::getInstance('RSMembership_Files', 'Table');
     $post = JRequest::get('post');
     if (!empty($post['thumb_delete'])) {
         $post['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $post['thumb_w'] = (int) $post['thumb_w'];
     if ($post['thumb_w'] <= 0) {
         $post['thumb_w'] = 48;
     }
     // These elements are not filtered for HTML code
     $post['description'] = JRequest::getVar('description', '', 'post', 'none', JREQUEST_ALLOWRAW);
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     unset($row->thumb);
     if ($row->store()) {
         $this->_id = $row->path;
         // Process the thumbnail
         $files = JRequest::get('files');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . DS . 'components' . DS . 'com_rsmembership' . DS . 'assets' . DS . 'thumbs' . DS . 'files' . DS . $row->id;
         // Delete it if requested
         if (!empty($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $this->_db->setQuery("UPDATE #__rsmembership_files SET `thumb`='" . JFile::getName($thumb['db_name'] . '.jpg') . "' WHERE `id`='" . $row->id . "'");
                 $this->_db->query();
             }
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:49,代码来源:files.php

示例2: save

 function save()
 {
     $row =& JTable::getInstance('RSMembership_Memberships', 'Table');
     $post = JRequest::get('post');
     if (!empty($post['thumb_delete'])) {
         $post['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $post['thumb_w'] = (int) $post['thumb_w'];
     if ($post['thumb_w'] <= 0) {
         $post['thumb_w'] = 48;
     }
     // Periods must be an integer
     $post['period'] = (int) @$post['period'];
     // Stock must be an integer
     $post['stock'] = (int) $post['stock'];
     // These elements are not filtered for HTML code
     $allowed = array('description', 'custom_code', 'custom_code_transaction', 'thankyou', 'redirect', 'share_redirect', 'admin_email_new_text', 'user_email_new_text', 'user_email_approved_text', 'admin_email_approved_text', 'user_email_renew_text', 'admin_email_renew_text', 'user_email_upgrade_text', 'admin_email_upgrade_text', 'user_email_addextra_text', 'admin_email_addextra_text', 'user_email_expire_text', 'admin_email_expire_text');
     foreach ($allowed as $item) {
         $post[$item] = JRequest::getVar($item, '', 'post', 'none', JREQUEST_ALLOWRAW);
     }
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     if (empty($row->id)) {
         $row->ordering = $row->getNextOrder();
     }
     unset($row->thumb);
     if ($row->store()) {
         $this->_id = $row->id;
         // Process the thumbnail
         $files = JRequest::get('files');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . DS . 'components' . DS . 'com_rsmembership' . DS . 'assets' . DS . 'thumbs' . DS . $row->id;
         // Delete it if requested
         if (!empty($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $this->_db->setQuery("UPDATE #__rsmembership_memberships SET `thumb`='' WHERE `id`='" . $row->id . "'");
             $this->_db->query();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $this->_db->setQuery("UPDATE #__rsmembership_memberships SET `thumb`='" . JFile::getName($thumb['db_name'] . '.jpg') . "' WHERE `id`='" . $row->id . "'");
                 $this->_db->query();
             }
         }
         // Process the extras
         $extras = $post['extras'];
         JArrayHelper::toInteger($extras, array(0));
         $this->_db->setQuery("DELETE FROM #__rsmembership_membership_extras WHERE `membership_id`='" . $row->id . "'");
         $this->_db->query();
         foreach ($extras as $extra) {
             if (empty($extra)) {
                 continue;
             }
             $this->_db->setQuery("INSERT INTO #__rsmembership_membership_extras SET `membership_id`='" . $row->id . "', `extra_id`='" . $extra . "'");
             $this->_db->query();
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:73,代码来源:memberships.php

示例3: save

 public function save($data)
 {
     $row = $this->getTable('File', 'RSMembershipTable');
     $jinput = JFactory::getApplication()->input;
     $jform = $jinput->get('jform', array(), 'array');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     if (!empty($jform['thumb_delete'])) {
         $jform['thumb'] = '';
     }
     // Thumbnail width must not be less than 1px
     $jform['thumb_w'] = (int) $jform['thumb_w'];
     if ($jform['thumb_w'] <= 0) {
         $jform['thumb_w'] = 48;
     }
     if (!$row->bind($jform)) {
         return JError::raiseWarning(500, $row->getError());
     }
     unset($row->thumb);
     if ($row->store()) {
         // Process the thumbnail
         $files = $jinput->files->get('jform', array(), 'array');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . '/components/com_rsmembership/assets/thumbs/files/' . $row->id;
         // Delete the thumbnail if requested
         if (!empty($jform['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $query->clear();
             $query->update($db->qn('#__rsmembership_files'))->set($db->qn('thumb') . ' = ' . $db->q(''))->where($db->qn('id') . ' = ' . $row->id);
             $db->setQuery($query);
             $db->execute();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (!empty($jform['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $row->thumb_w);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $query->clear();
                 $query->update($db->qn('#__rsmembership_files'))->set($db->qn('thumb') . ' = ' . $db->q(JFile::getName($thumb['db_name'] . '.jpg')))->where($db->qn('id') . ' = ' . $row->id);
                 $db->setQuery($query);
                 $db->execute();
             }
         }
         return true;
     } else {
         JError::raiseWarning(500, $row->getError());
         return false;
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:55,代码来源:file.php

示例4: save

 public function save($data)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $post = JFactory::getApplication()->input->get('jform', array(), 'array');
     if (isset($post['period_values'])) {
         $data['period_type'] = $post['period_values'][0];
         $data['period'] = $post['period_values'][1];
     }
     if (isset($post['trial_period_values'])) {
         $data['trial_period_type'] = $post['trial_period_values'][0];
         $data['trial_period'] = $post['trial_period_values'][1];
     }
     if (isset($post['fixed_expiry_values'][3])) {
         $data['fixed_day'] = $post['fixed_expiry_values'][0];
         $data['fixed_month'] = $post['fixed_expiry_values'][1];
         $data['fixed_year'] = $post['fixed_expiry_values'][2];
         $data['fixed_expiry'] = $post['fixed_expiry_values'][3];
     } else {
         $data['fixed_day'] = 0;
         $data['fixed_month'] = 0;
         $data['fixed_year'] = 0;
         $data['fixed_expiry'] = 0;
     }
     if (isset($post['thumb_delete'])) {
         $data['thumb'] = '';
     }
     $data['thumb_w'] = (int) $post['thumb_w'];
     if ($data['thumb_w'] <= 0) {
         $data['thumb_w'] = 48;
     }
     if (parent::save($data)) {
         $data['id'] = $this->getState($this->getName() . '.id');
         // Trigger event
         JFactory::getApplication()->triggerEvent('rsm_onMembershipSave', array(&$data));
         // Process the thumbnail
         $files = JFactory::getApplication()->input->files->get('jform');
         $thumb = $files['thumb'];
         jimport('joomla.filesystem.file');
         $thumb['db_name'] = JPATH_ROOT . '/components/com_rsmembership/assets/thumbs/' . $data['id'];
         // Delete it if requested
         if (isset($post['thumb_delete'])) {
             JFile::delete($thumb['db_name'] . '.jpg');
             $query->clear();
             $query->update($db->qn('#__rsmembership_memberships'))->set($db->qn('thumb') . ' = ' . $db->q(''))->where($db->qn('id') . ' = ' . $data['id']);
             $db->setQuery($query);
             $db->execute();
         }
         // Add the thumbnail if uploaded
         if (!$thumb['error'] && !empty($thumb['tmp_name'])) {
             // Resize the thumb if requested
             if (isset($post['thumb_resize'])) {
                 $success = RSMembershipHelper::createThumb($thumb['tmp_name'], $thumb['db_name'], $data['thumb_w']);
             } else {
                 $success = JFile::upload($thumb['tmp_name'], $thumb['db_name'] . '.jpg');
             }
             // Add to database only if upload successful
             if ($success) {
                 $query->clear();
                 $query->update($db->qn('#__rsmembership_memberships'))->set($db->qn('thumb') . ' = ' . $db->q(JFile::getName($thumb['db_name'] . '.jpg')))->where($db->qn('id') . ' = ' . $data['id']);
                 $db->setQuery($query);
                 $db->execute();
             }
         }
         // Process the extras
         $extras = $data['extras'];
         JArrayHelper::toInteger($extras, array(0));
         $query->clear();
         $query->delete()->from($db->qn('#__rsmembership_membership_extras'))->where($db->qn('membership_id') . ' = ' . $db->q($data['id']));
         $db->setQuery($query);
         $db->execute();
         foreach ($extras as $extra) {
             if (empty($extra)) {
                 continue;
             }
             $query->clear();
             $query->insert($db->qn('#__rsmembership_membership_extras'))->columns(array('membership_id', 'extra_id'))->values($db->q($data['id']) . ', ' . $db->q($extra));
             $db->setQuery($query);
             $db->execute();
         }
         return true;
     } else {
         JError::raiseWarning(500, $this->getError());
         return false;
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:86,代码来源:membership.php


注:本文中的RSMembershipHelper::createThumb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。