3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright (C) 2011 Marty Wright |
7 | Licensed to CiviCRM under the Academic Free License version 3.0. |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2013
38 * Page for displaying list of Label Formats
40 class CRM_Admin_Page_LabelFormats
extends CRM_Core_Page_Basic
{
42 public $useLivePageJS = TRUE;
45 * The action links that we need to display for the browse screen
50 static $_links = NULL;
55 * @return string Classname of BAO.
57 function getBAOName() {
58 return 'CRM_Core_BAO_LabelFormat';
64 * @return array (reference) of action links
67 if (!(self
::$_links)) {
68 // helper variable for nicer formatting
69 self
::$_links = array(
70 CRM_Core_Action
::UPDATE
=> array(
72 'url' => 'civicrm/admin/labelFormats',
73 'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1',
74 'title' => ts('Edit Label Format'),
76 CRM_Core_Action
::COPY
=> array(
78 'url' => 'civicrm/admin/labelFormats',
79 'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1',
80 'title' => ts('Copy Label Format'),
82 CRM_Core_Action
::DELETE
=> array(
83 'name' => ts('Delete'),
84 'url' => 'civicrm/admin/labelFormats',
85 'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1',
86 'title' => ts('Delete Label Format'),
95 * Get name of edit form
97 * @return string Classname of edit form.
100 return 'CRM_Admin_Form_LabelFormats';
106 * @return string name of this page.
108 function editName() {
109 return 'Mailing Label Formats';
115 * @return string user context.
117 function userContext($mode = NULL) {
118 return 'civicrm/admin/labelFormats';
122 * Browse all Label Format settings.
128 function browse($action = NULL) {
129 // Get list of configured Label Formats
130 $labelFormatList= CRM_Core_BAO_LabelFormat
::getList();
131 $nameFormatList= CRM_Core_BAO_LabelFormat
::getList(false, 'name_badge');
133 // Add action links to each of the Label Formats
134 foreach ($labelFormatList as & $format) {
135 $action = array_sum(array_keys($this->links()));
136 if (!empty($format['is_reserved'])) {
137 $action -= CRM_Core_Action
::DELETE
;
140 $format['groupName'] = ts('Mailing Label');
141 $format['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
142 array('id' => $format['id'], 'group' => 'label_format'),
145 'labelFormat.manage.action',
151 // Add action links to each of the Label Formats
152 foreach ($nameFormatList as & $format) {
153 $format['groupName'] = ts('Name Badge');
156 $labelFormatList = array_merge($labelFormatList, $nameFormatList);
158 // Order Label Formats by weight
159 $returnURL = CRM_Utils_System
::url(self
::userContext());
160 CRM_Core_BAO_LabelFormat
::addOrder($labelFormatList, $returnURL);
162 $this->assign('rows', $labelFormatList);