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; } public static function getWidgetData($widgetId) { $query = "SELECT * FROM civicrm_wci_widget where id=".$widgetId; $params = array(); $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget'); $data = array(); while ($dao->fetch()) { $data["title"] = $dao->title; $data["logo_image"] = $dao->logo_image; $data["image"] = $dao->image; $data["button_title"] = $dao->button_title; $data["progress_bar_id"] = $dao->button_link_to; $data["description"] = strip_tags(base64_decode($dao->description)); $data["size_variant"] = $dao->size_variant; $data["color_title"] = $dao->color_title; $data["color_title_bg"] = $dao->color_title_bg; $data["color_progress_bar"] = $dao->color_progress_bar; $data["color_widget_bg"] = $dao->color_widget_bg; $data["color_description"] = $dao->color_description; $data["color_border"] = $dao->color_border; $data["color_button"] = $dao->color_button; $data["color_button_bg"] = $dao->color_button_bg; $data["pb_percentage"] = CRM_Wci_BAO_ProgressBar::getProgressbarPercentage($dao->progress_bar_id); } return $data; } }