3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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-2015
36 * Page for displaying list of Label Formats.
38 class CRM_Admin_Page_LabelFormats
extends CRM_Core_Page_Basic
{
40 public $useLivePageJS = TRUE;
43 * The action links that we need to display for the browse screen.
47 static $_links = NULL;
55 public function getBAOName() {
56 return 'CRM_Core_BAO_LabelFormat';
63 * (reference) of action links
65 public function &links() {
66 if (!(self
::$_links)) {
67 // helper variable for nicer formatting
68 self
::$_links = array(
69 CRM_Core_Action
::UPDATE
=> array(
71 'url' => 'civicrm/admin/labelFormats',
72 'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1',
73 'title' => ts('Edit Label Format'),
75 CRM_Core_Action
::COPY
=> array(
77 'url' => 'civicrm/admin/labelFormats',
78 'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1',
79 'title' => ts('Copy Label Format'),
81 CRM_Core_Action
::DELETE
=> array(
82 'name' => ts('Delete'),
83 'url' => 'civicrm/admin/labelFormats',
84 'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1',
85 'title' => ts('Delete Label Format'),
94 * Get name of edit form.
97 * Classname of edit form.
99 public function editForm() {
100 return 'CRM_Admin_Form_LabelFormats';
104 * Get edit form name.
109 public function editName() {
110 return 'Mailing Label Formats';
121 public function userContext($mode = NULL) {
122 return 'civicrm/admin/labelFormats';
126 * Browse all Label Format settings.
128 * @param null $action
130 public function browse($action = NULL) {
131 // Get list of configured Label Formats
132 $labelFormatList = CRM_Core_BAO_LabelFormat
::getList();
133 $nameFormatList = CRM_Core_BAO_LabelFormat
::getList(FALSE, 'name_badge');
135 // Add action links to each of the Label Formats
136 foreach ($labelFormatList as & $format) {
137 $action = array_sum(array_keys($this->links()));
138 if (!empty($format['is_reserved'])) {
139 $action -= CRM_Core_Action
::DELETE
;
142 $format['groupName'] = ts('Mailing Label');
143 $format['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
144 array('id' => $format['id'], 'group' => 'label_format'),
147 'labelFormat.manage.action',
153 // Add action links to each of the Label Formats
154 foreach ($nameFormatList as & $format) {
155 $format['groupName'] = ts('Name Badge');
158 $labelFormatList = array_merge($labelFormatList, $nameFormatList);
160 // Order Label Formats by weight
161 $returnURL = CRM_Utils_System
::url(self
::userContext());
162 CRM_Core_BAO_LabelFormat
::addOrder($labelFormatList, $returnURL);
164 $this->assign('rows', $labelFormatList);