--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ *
+ */
+
+class CRM_WCI_BAO_ProgressBar extends CRM_WCI_DAO_ProgressBar {
+
+ /**
+ * class constructor
+ */
+ function __construct() {
+ parent::__construct();
+ }
+
+ /**
+ * Function to create a ProgressBar
+ * takes an associative array and creates a ProgressBar object
+ *
+ * This function is invoked from within the web form layer and also from the api layer
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return object CRM_WCI_BAO_ProgressBar object
+ * @access public
+ * @static
+ */
+ static function create(array $params) {
+
+ // check required params
+ if (!self::dataExists($params)) {
+ CRM_Core_Error::fatal('Not enough data to create a progress bar.');
+ }
+
+ $progress_bar = new CRM_WCI_BAO_ProgressBar();
+ $progress_bar->copyValues($params);
+
+ $progress_bar->save();
+
+ return $progress_bar;
+ }
+
+ /**
+ * Get a list of Widgets matching the params, where params keys are column
+ * names of civicrm_wci_widget.
+ *
+ * @param array $params
+ * @return array of CRM_WCI_BAO_ProgressBar objects
+ */
+ static function retrieve(array $params) {
+ $result = array();
+
+ $progress_bar = new CRM_WCI_BAO_ProgressBar();
+ $progress_bar->copyValues($params);
+ $progress_bar->find();
+
+ while ($progress_bar->fetch()) {
+ $result[(int) $progress_bar->id] = clone $progress_bar;
+ }
+
+ $progress_bar->free();
+
+ return $result;
+ }
+
+ /**
+ * Wrapper method for retrieve
+ *
+ * @param mixed $id Int or int-like string representing widget ID
+ * @return CRM_WCI_BAO_ProgressBar
+ */
+ static function retrieveByID($id) {
+ if (!is_int($id) && !ctype_digit($id)) {
+ CRM_Core_Error::fatal(__CLASS__ . '::' . __FUNCTION__ . ' expects an integer.');
+ }
+ $id = (int) $id;
+
+ $progress_bars = self::retrieve(array('id' => $id));
+
+ if (!array_key_exists($id, $progress_bars)) {
+ CRM_Core_Error::fatal("No Progress bar with ID $id exists.");
+ }
+
+ return $progress_bars[$id];
+ }
+
+ /**
+ * Check if there is absolute minimum of data to add the object
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return boolean
+ * @access public
+ */
+ public static function dataExists($params) {
+ if (CRM_Utils_Array::value('name', $params)) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ *
+ */
+
+class CRM_WCI_BAO_ProgressBarFormula extends CRM_WCI_DAO_ProgressBarFormula {
+
+ /**
+ * class constructor
+ */
+ function __construct() {
+ parent::__construct();
+ }
+
+ /**
+ * Function to create a ProgressBar
+ * takes an associative array and creates a ProgressBar object
+ *
+ * This function is invoked from within the web form layer and also from the api layer
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return object CRM_WCI_BAO_ProgressBarFormula object
+ * @access public
+ * @static
+ */
+ static function create(array $params) {
+
+ // check required params
+ if (!self::dataExists($params)) {
+ CRM_Core_Error::fatal('Not enough data to create a progress bar formula entry.');
+ }
+
+ $progress_bar_formula = new CRM_WCI_BAO_ProgressBarFormula();
+ $progress_bar_formula->copyValues($params);
+
+ $progress_bar_formula->save();
+
+ return $progress_bar_formula;
+ }
+
+ /**
+ * Get a list of Widgets matching the params, where params keys are column
+ * names of civicrm_wci_widget.
+ *
+ * @param array $params
+ * @return array of CRM_WCI_BAO_ProgressBarFormula objects
+ */
+ static function retrieve(array $params) {
+ $result = array();
+
+ $progress_bar_formula = new CRM_WCI_BAO_ProgressBarFormula();
+ $progress_bar_formula->copyValues($params);
+ $progress_bar_formula->find();
+
+ while ($progress_bar_formula->fetch()) {
+ $result[(int) $progress_bar_formula->id] = clone $progress_bar_formula;
+ }
+
+ $progress_bar_formula->free();
+
+ return $result;
+ }
+
+ /**
+ * Wrapper method for retrieve
+ *
+ * @param mixed $id Int or int-like string representing widget ID
+ * @return CRM_WCI_BAO_ProgressBarFormula
+ */
+ static function retrieveByID($id) {
+ if (!is_int($id) && !ctype_digit($id)) {
+ CRM_Core_Error::fatal(__CLASS__ . '::' . __FUNCTION__ . ' expects an integer.');
+ }
+ $id = (int) $id;
+
+ $progress_bar_formulas = self::retrieve(array('id' => $id));
+
+ if (!array_key_exists($id, $progress_bar_formulas)) {
+ CRM_Core_Error::fatal("No formula entry with ID $id exists.");
+ }
+
+ return $progress_bar_formulas[$id];
+ }
+
+ /**
+ * Check if there is absolute minimum of data to add the object
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return boolean
+ * @access public
+ */
+ public static function dataExists($params) {
+ if (CRM_Utils_Array::value('contribution_page_id', $params) && CRM_Utils_Array::value('progress_bar_id', $params)) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ *
+ */
+
+class CRM_WCI_BAO_Widget extends CRM_WCI_DAO_Widget {
+
+ /**
+ * class constructor
+ */
+ function __construct() {
+ parent::__construct();
+ }
+
+ /**
+ * Function to create a Widget
+ * takes an associative array and creates a Widget object
+ *
+ * This function is invoked from within the web form layer and also from the api layer
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return object CRM_WCI_BAO_Widget object
+ * @access public
+ * @static
+ */
+ static function create(array $params) {
+
+ // check required params
+ if (!self::dataExists($params)) {
+ CRM_Core_Error::fatal('Not enough data to create a widget.');
+ }
+
+ $widget = new CRM_WCI_BAO_Widget();
+ $widget->copyValues($params);
+
+ $widget->save();
+
+ return $widget;
+ }
+
+ /**
+ * Get a list of Widgets matching the params, where params keys are column
+ * names of civicrm_wci_widget.
+ *
+ * @param array $params
+ * @return array of CRM_WCI_BAO_Widget objects
+ */
+ static function retrieve(array $params) {
+ $result = array();
+
+ $widget = new CRM_WCI_BAO_Widget();
+ $widget->copyValues($params);
+ $widget->find();
+
+ while ($widget->fetch()) {
+ $result[(int) $widget->id] = clone $widget;
+ }
+
+ $widget->free();
+
+ return $result;
+ }
+
+ /**
+ * Wrapper method for retrieve
+ *
+ * @param mixed $id Int or int-like string representing widget ID
+ * @return CRM_WCI_BAO_Widget
+ */
+ static function retrieveByID($id) {
+ if (!is_int($id) && !ctype_digit($id)) {
+ CRM_Core_Error::fatal(__CLASS__ . '::' . __FUNCTION__ . ' expects an integer.');
+ }
+ $id = (int) $id;
+
+ $widgets = self::retrieve(array('id' => $id));
+
+ if (!array_key_exists($id, $widgets)) {
+ CRM_Core_Error::fatal("No widget with ID $id exists.");
+ }
+
+ return $widgets[$id];
+ }
+
+ /**
+ * Check if there is absolute minimum of data to add the object
+ *
+ * @param array $params (reference ) an assoc array of name/value pairs
+ *
+ * @return boolean
+ * @access public
+ */
+ public static function dataExists($params) {
+ if (CRM_Utils_Array::value('title', $params)) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+}
--- /dev/null
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.4 |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2013 |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM. |
+| |
+| CiviCRM is free software; you can copy, modify, and distribute it |
+| under the terms of the GNU Affero General Public License |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+| |
+| CiviCRM is distributed in the hope that it will be useful, but |
+| WITHOUT ANY WARRANTY; without even the implied warranty of |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+| See the GNU Affero General Public License for more details. |
+| |
+| You should have received a copy of the GNU Affero General Public |
+| License and the CiviCRM Licensing Exception along |
+| with this program; if not, contact CiviCRM LLC |
+| at info[AT]civicrm[DOT]org. If you have questions about the |
+| GNU Affero General Public License or the licensing of CiviCRM, |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_WCI_DAO_ProgressBar extends CRM_Core_DAO
+{
+ /**
+ * static instance to hold the table name
+ *
+ * @var string
+ * @static
+ */
+ static $_tableName = 'civicrm_wci_progress_bar';
+ /**
+ * static instance to hold the field values
+ *
+ * @var array
+ * @static
+ */
+ static $_fields = null;
+ /**
+ * static instance to hold the keys used in $_fields for each field.
+ *
+ * @var array
+ * @static
+ */
+ static $_fieldKeys = null;
+ /**
+ * static instance to hold the FK relationships
+ *
+ * @var string
+ * @static
+ */
+ static $_links = null;
+ /**
+ * static instance to hold the values that can
+ * be imported
+ *
+ * @var array
+ * @static
+ */
+ static $_import = null;
+ /**
+ * static instance to hold the values that can
+ * be exported
+ *
+ * @var array
+ * @static
+ */
+ static $_export = null;
+ /**
+ * static value to see if we should log any modifications to
+ * this table in the civicrm_log table
+ *
+ * @var boolean
+ * @static
+ */
+ static $_log = true;
+ /**
+ * Progress bar Id
+ *
+ * @var int unsigned
+ */
+ public $id;
+ /**
+ * Name of progress bar
+ *
+ * @var string
+ */
+ public $name;
+ /**
+ * Arbitrary starting amount
+ *
+ * @var float
+ */
+ public $starting_amount;
+ function __construct()
+ {
+ $this->__table = 'civicrm_wci_progress_bar';
+ parent::__construct();
+ }
+ /**
+ * return foreign keys and entity references
+ *
+ * @static
+ * @access public
+ * @return array of CRM_Core_EntityReference
+ */
+ static function getReferenceColumns()
+ {
+ return self::$_links;
+ }
+ /**
+ * returns all the column names of this table
+ *
+ * @access public
+ * @return array
+ */
+ static function &fields()
+ {
+ if (!(self::$_fields)) {
+ self::$_fields = array(
+ 'progress_bar_id' => array(
+ 'name' => 'id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('WCI Progress Bar Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ 'name' => array(
+ 'name' => 'name',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Progress Bar Name', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 64,
+ ) ,
+ 'starting_amount' => array(
+ 'name' => 'starting_amount',
+ 'type' => CRM_Utils_Type::T_FLOAT,
+ 'required' => false,
+ ) ,
+ );
+ }
+ return self::$_fields;
+ }
+ /**
+ * Returns an array containing, for each field, the arary key used for that
+ * field in self::$_fields.
+ *
+ * @access public
+ * @return array
+ */
+ static function &fieldKeys()
+ {
+ if (!(self::$_fieldKeys)) {
+ self::$_fieldKeys = array(
+ 'id' => 'progress_bar_id',
+ 'name' => 'name',
+ 'starting_amount' => 'starting_amount',
+ );
+ }
+ return self::$_fieldKeys;
+ }
+ /**
+ * returns the names of this table
+ *
+ * @access public
+ * @static
+ * @return string
+ */
+ static function getTableName()
+ {
+ return self::$_tableName;
+ }
+ /**
+ * returns if this table needs to be logged
+ *
+ * @access public
+ * @return boolean
+ */
+ function getLog()
+ {
+ return self::$_log;
+ }
+ /**
+ * returns the list of fields that can be imported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &import($prefix = false)
+ {
+ if (!(self::$_import)) {
+ self::$_import = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('import', $field)) {
+ if ($prefix) {
+ self::$_import['wci_progress_bar'] = & $fields[$name];
+ } else {
+ self::$_import[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_import;
+ }
+ /**
+ * returns the list of fields that can be exported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &export($prefix = false)
+ {
+ if (!(self::$_export)) {
+ self::$_export = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('export', $field)) {
+ if ($prefix) {
+ self::$_export['wci_progress_bar'] = & $fields[$name];
+ } else {
+ self::$_export[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_export;
+ }
+}
--- /dev/null
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.4 |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2013 |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM. |
+| |
+| CiviCRM is free software; you can copy, modify, and distribute it |
+| under the terms of the GNU Affero General Public License |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+| |
+| CiviCRM is distributed in the hope that it will be useful, but |
+| WITHOUT ANY WARRANTY; without even the implied warranty of |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+| See the GNU Affero General Public License for more details. |
+| |
+| You should have received a copy of the GNU Affero General Public |
+| License and the CiviCRM Licensing Exception along |
+| with this program; if not, contact CiviCRM LLC |
+| at info[AT]civicrm[DOT]org. If you have questions about the |
+| GNU Affero General Public License or the licensing of CiviCRM, |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_WCI_DAO_ProgressBarFormula extends CRM_Core_DAO
+{
+ /**
+ * static instance to hold the table name
+ *
+ * @var string
+ * @static
+ */
+ static $_tableName = 'civicrm_wci_progress_bar_formula';
+ /**
+ * static instance to hold the field values
+ *
+ * @var array
+ * @static
+ */
+ static $_fields = null;
+ /**
+ * static instance to hold the keys used in $_fields for each field.
+ *
+ * @var array
+ * @static
+ */
+ static $_fieldKeys = null;
+ /**
+ * static instance to hold the FK relationships
+ *
+ * @var string
+ * @static
+ */
+ static $_links = null;
+ /**
+ * static instance to hold the values that can
+ * be imported
+ *
+ * @var array
+ * @static
+ */
+ static $_import = null;
+ /**
+ * static instance to hold the values that can
+ * be exported
+ *
+ * @var array
+ * @static
+ */
+ static $_export = null;
+ /**
+ * static value to see if we should log any modifications to
+ * this table in the civicrm_log table
+ *
+ * @var boolean
+ * @static
+ */
+ static $_log = true;
+ /**
+ * Formula entry id
+ *
+ * @var int unsigned
+ */
+ public $id;
+ /**
+ * Contribution page reference id
+ *
+ * @var int unsigned
+ */
+ public $contribution_page_id;
+ /**
+ * Progress bar reference id
+ *
+ * @var int unsigned
+ */
+ public $progress_bar_id;
+ /**
+ * Percentage amount
+ *
+ * @var float
+ */
+ public $percentage;
+ function __construct()
+ {
+ $this->__table = 'civicrm_wci_progress_bar_formula';
+ parent::__construct();
+ }
+ /**
+ * return foreign keys and entity references
+ *
+ * @static
+ * @access public
+ * @return array of CRM_Core_EntityReference
+ */
+ static function getReferenceColumns()
+ {
+ if (!self::$_links) {
+ self::$_links = array(
+ new CRM_Core_EntityReference(self::getTableName() , 'progress_bar_id', 'civicrm_wci_progress_bar', 'id') ,
+ new CRM_Core_EntityReference(self::getTableName() , 'contribution_page_id', 'civicrm_contribution_page', 'id') ,
+ );
+ }
+ return self::$_links;
+ }
+ /**
+ * returns all the column names of this table
+ *
+ * @access public
+ * @return array
+ */
+ static function &fields()
+ {
+ if (!(self::$_fields)) {
+ self::$_fields = array(
+ 'progress_bar_formula_id' => array(
+ 'name' => 'id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('WCI Progress Bar Formula Entry Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ 'contribution_page_id' => array(
+ 'name' => 'contribution_page_id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('Contribution Page Reference Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ 'progress_bar_id' => array(
+ 'name' => 'progress_bar_id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('Progress Bar Reference Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ 'percentage' => array(
+ 'name' => 'percentage',
+ 'type' => CRM_Utils_Type::T_FLOAT,
+ 'title' => ts('Percentage Amount', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ );
+ }
+ return self::$_fields;
+ }
+ /**
+ * Returns an array containing, for each field, the arary key used for that
+ * field in self::$_fields.
+ *
+ * @access public
+ * @return array
+ */
+ static function &fieldKeys()
+ {
+ if (!(self::$_fieldKeys)) {
+ self::$_fieldKeys = array(
+ 'id' => 'progress_bar_formula_id',
+ 'contribution_page_id' => 'contribution_page_id',
+ 'progress_bar_id' => 'progress_bar_id',
+ 'percentage' => 'percentage',
+ );
+ }
+ return self::$_fieldKeys;
+ }
+ /**
+ * returns the names of this table
+ *
+ * @access public
+ * @static
+ * @return string
+ */
+ static function getTableName()
+ {
+ return self::$_tableName;
+ }
+ /**
+ * returns if this table needs to be logged
+ *
+ * @access public
+ * @return boolean
+ */
+ function getLog()
+ {
+ return self::$_log;
+ }
+ /**
+ * returns the list of fields that can be imported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &import($prefix = false)
+ {
+ if (!(self::$_import)) {
+ self::$_import = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('import', $field)) {
+ if ($prefix) {
+ self::$_import['wci_progress_bar_formula'] = & $fields[$name];
+ } else {
+ self::$_import[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_import;
+ }
+ /**
+ * returns the list of fields that can be exported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &export($prefix = false)
+ {
+ if (!(self::$_export)) {
+ self::$_export = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('export', $field)) {
+ if ($prefix) {
+ self::$_export['wci_progress_bar_formula'] = & $fields[$name];
+ } else {
+ self::$_export[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_export;
+ }
+}
--- /dev/null
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.4 |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2013 |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM. |
+| |
+| CiviCRM is free software; you can copy, modify, and distribute it |
+| under the terms of the GNU Affero General Public License |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+| |
+| CiviCRM is distributed in the hope that it will be useful, but |
+| WITHOUT ANY WARRANTY; without even the implied warranty of |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+| See the GNU Affero General Public License for more details. |
+| |
+| You should have received a copy of the GNU Affero General Public |
+| License and the CiviCRM Licensing Exception along |
+| with this program; if not, contact CiviCRM LLC |
+| at info[AT]civicrm[DOT]org. If you have questions about the |
+| GNU Affero General Public License or the licensing of CiviCRM, |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_WCI_DAO_Widget extends CRM_Core_DAO
+{
+ /**
+ * static instance to hold the table name
+ *
+ * @var string
+ * @static
+ */
+ static $_tableName = 'civicrm_wci_widget';
+ /**
+ * static instance to hold the field values
+ *
+ * @var array
+ * @static
+ */
+ static $_fields = null;
+ /**
+ * static instance to hold the keys used in $_fields for each field.
+ *
+ * @var array
+ * @static
+ */
+ static $_fieldKeys = null;
+ /**
+ * static instance to hold the FK relationships
+ *
+ * @var string
+ * @static
+ */
+ static $_links = null;
+ /**
+ * static instance to hold the values that can
+ * be imported
+ *
+ * @var array
+ * @static
+ */
+ static $_import = null;
+ /**
+ * static instance to hold the values that can
+ * be exported
+ *
+ * @var array
+ * @static
+ */
+ static $_export = null;
+ /**
+ * static value to see if we should log any modifications to
+ * this table in the civicrm_log table
+ *
+ * @var boolean
+ * @static
+ */
+ static $_log = true;
+ /**
+ * Widget Id
+ *
+ * @var int unsigned
+ */
+ public $id;
+ /**
+ * Widget title
+ *
+ * @var string
+ */
+ public $title;
+ /**
+ * Widget title logo
+ *
+ * @var string
+ */
+ public $logo_image;
+ /**
+ * Widget image
+ *
+ * @var string
+ */
+ public $image;
+ /**
+ * Widget contribute/donate button title
+ *
+ * @var string
+ */
+ public $button_title;
+ /**
+ * Contribution/donate page reference id
+ *
+ * @var int unsigned
+ */
+ public $button_link_to;
+ /**
+ * WCI Progress bar reference id
+ *
+ * @var int unsigned
+ */
+ public $progress_bar_id;
+ /**
+ * Widget description
+ *
+ * @var string
+ */
+ public $description;
+ /**
+ * Newsletter signup group reference id
+ *
+ * @var int unsigned
+ */
+ public $email_signup_group_id;
+ /**
+ * Widget size (Thin/Normal/Wide)
+ *
+ * @var string
+ */
+ public $size_variant;
+ /**
+ * Widget title color
+ *
+ * @var string
+ */
+ public $color_title;
+ /**
+ * Widget title background color
+ *
+ * @var string
+ */
+ public $color_title_bg;
+ /**
+ * Widget progress bar color
+ *
+ * @var string
+ */
+ public $color_progress_bar;
+ /**
+ * Widget background color
+ *
+ * @var string
+ */
+ public $color_widget_bg;
+ /**
+ * Widget description color
+ *
+ * @var string
+ */
+ public $color_description;
+ /**
+ * Widget border color
+ *
+ * @var string
+ */
+ public $color_border;
+ /**
+ * Widget button color
+ *
+ * @var string
+ */
+ public $color_button;
+ /**
+ * Widget button background color
+ *
+ * @var string
+ */
+ public $color_button_bg;
+ /**
+ * Additional custom style rules
+ *
+ * @var int unsigned
+ */
+ public $style_rules;
+ /**
+ * Flag to override default widget template
+ *
+ * @var boolean
+ */
+ public $override;
+ /**
+ * Custom template
+ *
+ * @var string
+ */
+ public $custom_template;
+ function __construct()
+ {
+ $this->__table = 'civicrm_wci_widget';
+ parent::__construct();
+ }
+ /**
+ * return foreign keys and entity references
+ *
+ * @static
+ * @access public
+ * @return array of CRM_Core_EntityReference
+ */
+ static function getReferenceColumns()
+ {
+ if (!self::$_links) {
+ self::$_links = array(
+ new CRM_Core_EntityReference(self::getTableName() , 'button_link_to', 'civicrm_contribution_page', 'id') ,
+ new CRM_Core_EntityReference(self::getTableName() , 'progress_bar_id', 'civicrm_wci_progress_bar', 'id') ,
+ new CRM_Core_EntityReference(self::getTableName() , 'email_signup_group_id', 'civicrm_group', 'id') ,
+ );
+ }
+ return self::$_links;
+ }
+ /**
+ * returns all the column names of this table
+ *
+ * @access public
+ * @return array
+ */
+ static function &fields()
+ {
+ if (!(self::$_fields)) {
+ self::$_fields = array(
+ 'widget_id' => array(
+ 'name' => 'id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('WCI Widget Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ ) ,
+ 'title' => array(
+ 'name' => 'title',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget title', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 64,
+ ) ,
+ 'logo_image' => array(
+ 'name' => 'logo_image',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Image url of widget logo image', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ 'maxlength' => 255,
+ ) ,
+ 'image' => array(
+ 'name' => 'image',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Url of widget image', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ 'maxlength' => 255,
+ ) ,
+ 'button_title' => array(
+ 'name' => 'button_title',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Contribute/Donate button title', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ 'maxlength' => 64,
+ ) ,
+ 'button_link_to' => array(
+ 'name' => 'button_link_to',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('Contribution/Donation page reference', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'progress_bar_id' => array(
+ 'name' => 'id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('WCI Progress Bar Reference Id', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'description' => array(
+ 'name' => 'description',
+ 'type' => CRM_Utils_Type::T_TEXT,
+ 'title' => ts('Widget description', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'email_signup_group_id' => array(
+ 'name' => 'email_signup_group_id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('Group reference for email newsletter signup', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'size_variant' => array(
+ 'name' => 'id',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget size variant', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_title' => array(
+ 'name' => 'color_title',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget title color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_title_bg' => array(
+ 'name' => 'color_title_bg',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget title background color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_progress_bar' => array(
+ 'name' => 'color_progress_bar',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Progress bar color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_widget_bg' => array(
+ 'name' => 'color_widget_bg',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget background color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_description' => array(
+ 'name' => 'color_description',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget description color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_border' => array(
+ 'name' => 'color_border',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget border color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_button' => array(
+ 'name' => 'color_button',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget button text color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'color_button_bg' => array(
+ 'name' => 'color_button_bg',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Widget button background color', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => true,
+ 'maxlength' => 10,
+ ) ,
+ 'style_rules' => array(
+ 'name' => 'style_rules',
+ 'type' => CRM_Utils_Type::T_TEXT,
+ 'title' => ts('Additional style rules', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'override' => array(
+ 'name' => 'override',
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
+ 'title' => ts('Override default template', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ 'custom_template' => array(
+ 'name' => 'custom_template',
+ 'type' => CRM_Utils_Type::T_TEXT,
+ 'title' => ts('Widget custom template', array('domain' => 'org.civicrm.wci')) ,
+ 'required' => false,
+ ) ,
+ );
+ }
+ return self::$_fields;
+ }
+ /**
+ * Returns an array containing, for each field, the arary key used for that
+ * field in self::$_fields.
+ *
+ * @access public
+ * @return array
+ */
+ static function &fieldKeys()
+ {
+ if (!(self::$_fieldKeys)) {
+ self::$_fieldKeys = array(
+ 'id' => 'widget_id',
+ 'title' => 'title',
+ 'logo_image' => 'logo_image',
+ 'image' => 'image',
+ 'button_title' => 'button_title',
+ 'button_link_to' => 'button_link_to',
+ 'progress_bar_id' => 'progress_bar_id',
+ 'description' => 'description',
+ 'email_signup_group_id' => 'email_signup_group_id',
+ 'size_variant' => 'size_variant',
+ 'color_title' => 'color_title',
+ 'color_title_bg' => 'color_title_bg',
+ 'color_progress_bar' => 'color_progress_bar',
+ 'color_widget_bg' => 'color_widget_bg',
+ 'color_description' => 'color_description',
+ 'color_border' => 'color_border',
+ 'color_button' => 'color_button',
+ 'color_button_bg' => 'color_button_bg',
+ 'style_rules' => 'style_rules',
+ 'override' => 'override',
+ 'custom_template' => 'custom_template',
+ );
+ }
+ return self::$_fieldKeys;
+ }
+ /**
+ * returns the names of this table
+ *
+ * @access public
+ * @static
+ * @return string
+ */
+ static function getTableName()
+ {
+ return self::$_tableName;
+ }
+ /**
+ * returns if this table needs to be logged
+ *
+ * @access public
+ * @return boolean
+ */
+ function getLog()
+ {
+ return self::$_log;
+ }
+ /**
+ * returns the list of fields that can be imported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &import($prefix = false)
+ {
+ if (!(self::$_import)) {
+ self::$_import = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('import', $field)) {
+ if ($prefix) {
+ self::$_import['wci_widget'] = & $fields[$name];
+ } else {
+ self::$_import[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_import;
+ }
+ /**
+ * returns the list of fields that can be exported
+ *
+ * @access public
+ * return array
+ * @static
+ */
+ static function &export($prefix = false)
+ {
+ if (!(self::$_export)) {
+ self::$_export = array();
+ $fields = self::fields();
+ foreach($fields as $name => $field) {
+ if (CRM_Utils_Array::value('export', $field)) {
+ if ($prefix) {
+ self::$_export['wci_widget'] = & $fields[$name];
+ } else {
+ self::$_export[$name] = & $fields[$name];
+ }
+ }
+ }
+ }
+ return self::$_export;
+ }
+}
* @see http://wiki.civicrm.org/confluence/display/CRMDOC43/QuickForm+Reference
*/
class CRM_Wci_Form_CreateWidget extends CRM_Core_Form {
- function buildQuickForm() {
+
+ function preProcess() {
+ parent::preProcess();
- // add form elements
- $this->add(
- 'select', // field type
- 'favorite_color', // field name
- 'Favorite Color', // field label
- $this->getColorOptions(), // list of options
- true // is required
+ $this->_colorFields = array('color_title' => array(ts('Title Text Color'),
+ 'text',
+ FALSE,
+ '#2786C2',
+ ),
+ 'color_bar' => array(ts('Progress Bar Color'),
+ 'text',
+ FALSE,
+ '#FFFFFF',
+ ),
+ 'color_main_text' => array(ts('Additional Text Color'),
+ 'text',
+ FALSE,
+ '#FFFFFF',
+ ),
+ 'color_main' => array(ts('Background Color'),
+ 'text',
+ FALSE,
+ '#96C0E7',
+ ),
+ 'color_main_bg' => array(ts('Background Color Top Area'),
+ 'text',
+ FALSE,
+ '#B7E2FF',
+ ),
+ 'color_bg' => array(ts('Border Color'),
+ 'text',
+ FALSE,
+ '#96C0E7',
+ ),
+ 'color_about_link' => array(ts('Button Link Color'),
+ 'text',
+ FALSE,
+ '#556C82',
+ ),
+ 'color_button' => array(ts('Button Background Color'),
+ 'text',
+ FALSE,
+ '#FFFFFF',
+ ),
+ 'color_homepage_link' => array(ts('Homepage Link Color'),
+ 'text',
+ FALSE,
+ '#FFFFFF',
+ ),
);
+ }
+
+ function buildQuickForm() {
+
+ // add form elements
+ $this->add('text', 'title', ts('Title'),true);
+ $this->add('text', 'logo_image', ts('Logo image'));
+ $this->add('text', 'image', ts('Image'));
+ $this->add('select', 'button_link_to', ts('Contribution button'), $this->getContributionPageOptions());
+ $this->add('text', 'button_title', ts('Contribution button title'));
+ $this->add('select', 'progress_bar', ts('Progress bar'), array('' => '- select -'));
+ $this->add('textarea', 'description', ts('Description'));
+ $this->add('select', 'email_signup_group_id', ts('Newsletter signup'), $this->getGroupOptions());
+ $this->add('select', 'size_variant', ts('Size variant'), $this->getSizeOptions());
+ foreach ($this->_colorFields as $name => $val) {
+ $this->add($val[1],
+ $name,
+ $val[0],
+ $name,
+ $val[2]
+ );
+ }
+ $this->add('textarea', 'style_rules', ts('Additional Style Rules'));
+ $this->add('checkbox', 'override', ts('Override default template'));
+ $this->add('textarea', 'custom_template', ts('Custom template'));
$this->addButtons(array(
array(
'type' => 'submit',
- 'name' => ts('Submit'),
+ 'name' => ts('Save'),
'isDefault' => TRUE,
),
));
function postProcess() {
$values = $this->exportValues();
- $options = $this->getColorOptions();
- CRM_Core_Session::setStatus(ts('You picked color "%1"', array(
- 1 => $options[$values['favorite_color']]
- )));
+
parent::postProcess();
}
- function getColorOptions() {
+ function getContributionPageOptions() {
+ $options = array(
+ '' => ts('- select -'),
+ );
+
+ $result = civicrm_api3('contribution_page', 'get');
+ foreach ($result['values'] as $contribution_page) {
+ $options[$contribution_page['id']] = $contribution_page['title'];
+ }
+
+ return $options;
+ }
+
+ function getGroupOptions() {
$options = array(
'' => ts('- select -'),
- '#f00' => ts('Red'),
- '#0f0' => ts('Green'),
- '#00f' => ts('Blue'),
- '#f0f' => ts('Purple'),
);
- foreach (array('1','2','3','4','5','6','7','8','9','a','b','c','d','e') as $f) {
- $options["#{$f}{$f}{$f}"] = ts('Grey (%1)', array(1 => $f));
+
+ $result = civicrm_api3('group', 'get');
+ foreach ($result['values'] as $group) {
+ $options[$group['id']] = $group['title'];
}
+
+ return $options;
+ }
+
+ function getSizeOptions() {
+ $options = array(
+ '' => ts('- select -'),
+ 'thin' => ts('Thin'),
+ 'normal' => ts('Normal'),
+ 'wide' => ts('Wide'),
+ );
+
return $options;
}
-- WCI progress bar.
CREATE TABLE IF NOT EXISTS civicrm_wci_progress_bar (
- id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Custom Progress bar Id',
+ id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Custom Progress bar Id.',
name varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Name of progress bar.',
starting_amount float unsigned NULL COMMENT 'Arbitrary starting amount for progress bar.',
PRIMARY KEY (`id`),
-- WCI progress bar formula
CREATE TABLE IF NOT EXISTS civicrm_wci_progress_bar_formula (
- id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Formula entry Id',
+ id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Formula entry Id.',
contribution_page_id int(10) unsigned NOT NULL COMMENT 'Reference contribution page id.',
progress_bar_id int(10) unsigned DEFAULT NULL COMMENT 'Custom Progress bar reference id.',
percentage float unsigned NULL COMMENT 'Percentage amount.',
-- WCI widget
CREATE TABLE IF NOT EXISTS civicrm_wci_widget (
- id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Widget Id',
+ id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Widget Id.',
title varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget title.',
logo_image varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Image url of widget logo image.',
image varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Url of widget image.',
email_signup_group_id int(10) unsigned DEFAULT NULL COMMENT 'Group reference for email newsletter signup.',
size_variant varchar(25) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget size variant.',
color_title varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget title color.',
- color_title_background varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget title background color.',
+ color_title_bg varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget title background color.',
color_progress_bar varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Progress bar color.',
- color_widget_bg varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget title color.',
+ color_widget_bg varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget background color.',
color_description varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget description color.',
color_border varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget border color.',
color_button varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Widget button text color.',