/**
* Pre process the form
*
- * @access public
*
* @return void
*/
* Set default values for the form. Manage Premiums that in edit/view mode
* the default values are retrieved from the database
*
- * @access public
*
* @return void
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
$defaults = parent::setDefaultValues();
if ($this->_id) {
$params = array('id' => $this->_id);
* Build the form object
*
* @return void
- * @access public
*/
public function buildQuickForm() {
parent::buildQuickForm( );
$this->add('file', 'uploadFile', ts('Image File Name'), 'onChange="select_option();"');
-
$this->add('text', 'price', ts('Market Value'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'price'), TRUE);
$this->addRule('price', ts('Please enter the Market Value for this product.'), 'money');
CRM_Core_PseudoConstant::populate(
$premiumFinancialType,
'CRM_Financial_DAO_EntityFinancialAccount',
- $all = True,
+ $all = TRUE,
$retrieve = 'entity_id',
- $filter = null,
+ $filter = NULL,
'account_relationship = 8'
);
CRM_Core_PseudoConstant::populate(
$costFinancialType,
'CRM_Financial_DAO_EntityFinancialAccount',
- $all = True,
+ $all = TRUE,
$retrieve = 'entity_id',
- $filter = null,
+ $filter = NULL,
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach( $financialType as $key => $financialTypeName ){
- if(!in_array( $key, $productFinancialType))
+ foreach ($financialType as $key => $financialTypeName ){
+ if (!in_array( $key, $productFinancialType)) {
unset( $financialType[$key] );
+ }
}
- if( count( $financialType ) ){
+ if (count( $financialType ) ){
$this->assign( 'financialType', $financialType );
}
$this->add(
'select',
'financial_type_id',
ts( 'Financial Type' ),
- array(''=>ts('- select -')) + $financialType
+ array('' => ts('- select -')) + $financialType
);
$this->add('checkbox', 'is_active', ts('Enabled?'));
/**
* Function for validation
*
- * @param array $params (ref.) an assoc array of name/value pairs
+ * @param array $params
+ * (ref.) an assoc array of name/value pairs.
*
* @param $files
*
* @return mixed true or array of errors
- * @access public
* @static
*/
public static function formRule($params, $files) {
$errors['frequency_interval'] = ts('Please enter the Frequency Interval for this subscription or service.');
}
-
return empty($errors) ? TRUE : $errors;
}
/**
* Process the form submission
*
- * @access public
*
* @return void
*/
// to check wether GD is installed or not
$gdSupport = CRM_Utils_System::getModuleSetting('gd', 'GD Support');
- if($gdSupport) {
- if($imageFile) {
- $error = false;
+ if ($gdSupport) {
+ if ($imageFile) {
+ $error = FALSE;
$params['image'] = $this->_resizeImage($imageFile, "_full", 200, 200);
$params['thumbnail'] = $this->_resizeImage($imageFile, "_thumb", 50, 50);
}
- } else {
- $error = true;
+ }
+ else {
+ $error = TRUE;
$params['image'] = $config->resourceBase . 'i/contribute/default_premium.jpg';
$params['thumbnail'] = $config->resourceBase . 'i/contribute/default_premium_thumb.jpg';
}
- } elseif ($value == 'thumbnail') {
+ }
+ elseif ($value == 'thumbnail') {
$params['image'] = $params['imageUrl'];
$params['thumbnail'] = $params['thumbnailUrl'];
- } elseif ($value == 'default_image') {
+ }
+ elseif ($value == 'default_image') {
$url = parse_url($config->userFrameworkBaseURL);
$params['image'] = $config->resourceBase . 'i/contribute/default_premium.jpg';
$params['thumbnail'] = $config->resourceBase . 'i/contribute/default_premium_thumb.jpg';
- } else {
+ }
+ else {
$params['image'] = "";
$params['thumbnail'] = "";
}
/**
* Resize a premium image to a different size
*
- * @access private
*
* @param string $filename
* @param string $resizedName
$widthOrig = $imageInfo[0];
$heightOrig = $imageInfo[1];
$image = imagecreatetruecolor($width, $height);
- if($imageInfo['mime'] == 'image/gif') {
+ if ($imageInfo['mime'] == 'image/gif') {
$source = imagecreatefromgif($filename);
- } elseif($imageInfo['mime'] == 'image/png') {
+ }
+ elseif($imageInfo['mime'] == 'image/png') {
$source = imagecreatefrompng($filename);
- } else {
+ }
+ else {
$source = imagecreatefromjpeg($filename);
}
// save the resized image
$fp = fopen($newFilename, 'w+');
ob_start();
- ImageJPEG($image);
+ imagejpeg($image);
$image_buffer = ob_get_contents();
ob_end_clean();
- ImageDestroy($image);
+ imagedestroy($image);
fwrite($fp, $image_buffer);
rewind($fp);
fclose($fp);
}
}
-