* @return void
*/
public function buildQuickForm() {
- parent::buildQuickForm( );
+ parent::buildQuickForm();
$this->setPageTitle(ts('Premium Product'));
if ($this->_action & CRM_Core_Action::PREVIEW) {
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE);
- $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array('CRM_Contribute_DAO_Product', $this->_id));
+ $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array(
+ 'CRM_Contribute_DAO_Product',
+ $this->_id,
+ ));
$this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku'));
$this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60');
$this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60');
- $this->add('select', 'period_type', ts('Period Type'), array('' => '- select -', 'rolling' => 'Rolling', 'fixed' => 'Fixed'));
+ $this->add('select', 'period_type', ts('Period Type'), array(
+ '' => '- select -',
+ 'rolling' => 'Rolling',
+ 'fixed' => 'Fixed',
+ ));
$this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day'));
$this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval'));
//Financial Type CRM-11106
- $financialType = CRM_Contribute_PseudoConstant::financialType( );
+ $financialType = CRM_Contribute_PseudoConstant::financialType();
$premiumFinancialType = array();
CRM_Core_PseudoConstant::populate(
$premiumFinancialType,
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach( $financialType as $key => $financialTypeName ){
- if(!in_array( $key, $productFinancialType)) {
- unset( $financialType[$key] );
+ foreach ($financialType as $key => $financialTypeName) {
+ if (!in_array($key, $productFinancialType)) {
+ unset($financialType[$key]);
}
}
- if( count( $financialType ) ){
- $this->assign( 'financialType', $financialType );
+ if (count($financialType)) {
+ $this->assign('financialType', $financialType);
}
$this->add(
'select',
'financial_type_id',
- ts( 'Financial Type' ),
+ ts('Financial Type'),
array('' => ts('- select -')) + $financialType
);
*
* @param $files
*
- * @return mixed true or array of errors
- * @static
+ * @return bool|array
+ * mixed true or array of errors
*/
public static function formRule($params, $files) {
if (isset($params['imageOption'])) {
CRM_Core_Session::setStatus(ts('Selected Premium Product type has been deleted.'), ts('Deleted'), 'info');
}
else {
- $params = $this->controller->exportValues($this->_name);
+ $params = $this->controller->exportValues($this->_name);
$imageFile = CRM_Utils_Array::value('uploadFile', $params);
$imageFile = $imageFile['name'];
// to check wether GD is installed or not
$gdSupport = CRM_Utils_System::getModuleSetting('gd', 'GD Support');
- if($gdSupport) {
- if($imageFile) {
+ if ($gdSupport) {
+ if ($imageFile) {
$error = FALSE;
$params['image'] = $this->_resizeImage($imageFile, "_full", 200, 200);
$params['thumbnail'] = $this->_resizeImage($imageFile, "_thumb", 50, 50);
}
- } else {
+ }
+ 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'] = "";
}
// fix the money fields
foreach (array(
- 'cost', 'price', 'min_contribution') as $f) {
+ 'cost',
+ 'price',
+ 'min_contribution',
+ ) as $f) {
$params[$f] = CRM_Utils_Rule::cleanMoney($params[$f]);
}
* @param $width
* @param $height
*
- * @return Path to image
+ * @return string
+ * Path to image
*/
private function _resizeImage($filename, $resizedName, $width, $height) {
// figure out the new filename
$pathParts = pathinfo($filename);
- $newFilename = $pathParts['dirname']."/".$pathParts['filename'].$resizedName.".".$pathParts['extension'];
+ $newFilename = $pathParts['dirname'] . "/" . $pathParts['filename'] . $resizedName . "." . $pathParts['extension'];
// get image about original image
$imageInfo = getimagesize($filename);
$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);
}
// return the URL to link to
$config = CRM_Core_Config::singleton();
- return $config->imageUploadURL.basename($newFilename);
+ return $config->imageUploadURL . basename($newFilename);
}
}