fix version in header
[civicrm-core.git] / CRM / Admin / Page / LabelFormats.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035
TO
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. |
10 | |
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. |
14 | |
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. |
19 | |
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 +--------------------------------------------------------------------+
27*/
28
29/**
30 *
31 * @package CRM
06b69b18 32 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
33 * $Id$
34 *
35 */
36
37/**
38 * Page for displaying list of Label Formats
39 */
40class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic {
41
96f50de2
CW
42 public $useLivePageJS = TRUE;
43
6a488035
TO
44 /**
45 * The action links that we need to display for the browse screen
46 *
47 * @var array
48 * @static
49 */
50 static $_links = NULL;
51
52 /**
53 * Get BAO Name
54 *
55 * @return string Classname of BAO.
56 */
57 function getBAOName() {
58 return 'CRM_Core_BAO_LabelFormat';
59 }
60
61 /**
62 * Get action Links
63 *
64 * @return array (reference) of action links
65 */
66 function &links() {
67 if (!(self::$_links)) {
68 // helper variable for nicer formatting
69 self::$_links = array(
70 CRM_Core_Action::UPDATE => array(
71 'name' => ts('Edit'),
72 'url' => 'civicrm/admin/labelFormats',
eaf5045f 73 'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1',
6a488035
TO
74 'title' => ts('Edit Label Format'),
75 ),
76 CRM_Core_Action::COPY => array(
77 'name' => ts('Copy'),
78 'url' => 'civicrm/admin/labelFormats',
eaf5045f 79 'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1',
6a488035
TO
80 'title' => ts('Copy Label Format'),
81 ),
82 CRM_Core_Action::DELETE => array(
83 'name' => ts('Delete'),
84 'url' => 'civicrm/admin/labelFormats',
eaf5045f 85 'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1',
6a488035
TO
86 'title' => ts('Delete Label Format'),
87 ),
88 );
89 }
90
91 return self::$_links;
92 }
93
94 /**
95 * Get name of edit form
96 *
97 * @return string Classname of edit form.
98 */
99 function editForm() {
100 return 'CRM_Admin_Form_LabelFormats';
101 }
102
103 /**
104 * Get edit form name
105 *
106 * @return string name of this page.
107 */
108 function editName() {
109 return 'Mailing Label Formats';
110 }
111
112 /**
113 * Get user context.
114 *
fd31fa4c
EM
115 * @param null $mode
116 *
6a488035
TO
117 * @return string user context.
118 */
119 function userContext($mode = NULL) {
120 return 'civicrm/admin/labelFormats';
121 }
122
123 /**
124 * Browse all Label Format settings.
125 *
dd244018
EM
126 * @param null $action
127 *
6a488035
TO
128 * @return void
129 * @access public
130 * @static
131 */
132 function browse($action = NULL) {
133 // Get list of configured Label Formats
eaf5045f
KJ
134 $labelFormatList= CRM_Core_BAO_LabelFormat::getList();
135 $nameFormatList= CRM_Core_BAO_LabelFormat::getList(false, 'name_badge');
6a488035
TO
136
137 // Add action links to each of the Label Formats
138 foreach ($labelFormatList as & $format) {
139 $action = array_sum(array_keys($this->links()));
a7488080 140 if (!empty($format['is_reserved'])) {
6a488035
TO
141 $action -= CRM_Core_Action::DELETE;
142 }
252708df
KJ
143
144 $format['groupName'] = ts('Mailing Label');
eaf5045f 145 $format['action'] = CRM_Core_Action::formLink(self::links(), $action,
87dab4a4
AH
146 array('id' => $format['id'], 'group' => 'label_format'),
147 ts('more'),
148 FALSE,
149 'labelFormat.manage.action',
150 'LabelFormat',
151 $format['id']
152 );
6a488035
TO
153 }
154
eaf5045f
KJ
155 // Add action links to each of the Label Formats
156 foreach ($nameFormatList as & $format) {
252708df 157 $format['groupName'] = ts('Name Badge');
eaf5045f
KJ
158 }
159
160 $labelFormatList = array_merge($labelFormatList, $nameFormatList);
161
6a488035
TO
162 // Order Label Formats by weight
163 $returnURL = CRM_Utils_System::url(self::userContext());
164 CRM_Core_BAO_LabelFormat::addOrder($labelFormatList, $returnURL);
165
166 $this->assign('rows', $labelFormatList);
167 }
168}
169