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