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