3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
35 class CRM_Case_XMLProcessor
{
37 static protected $_xml;
39 function retrieve($caseType) {
40 // trim all spaces from $caseType
41 $caseType = str_replace('_', ' ', $caseType);
42 $caseType = CRM_Utils_String
::munge(ucwords($caseType), '', 0);
44 if (!CRM_Utils_Array
::value($caseType, self
::$_xml)) {
46 self
::$_xml = array();
49 // first check custom templates directory
51 $config = CRM_Core_Config
::singleton();
52 if (isset($config->customTemplateDir
) &&
53 $config->customTemplateDir
55 // check if the file exists in the custom templates directory
56 $fileName = implode(DIRECTORY_SEPARATOR
,
58 $config->customTemplateDir
,
69 !file_exists($fileName)
71 // check if file exists locally
72 $fileName = implode(DIRECTORY_SEPARATOR
,
73 array(dirname(__FILE__
),
80 if (!file_exists($fileName)) {
81 // check if file exists locally
82 $fileName = implode(DIRECTORY_SEPARATOR
,
83 array(dirname(__FILE__
),
85 'configuration.sample',
90 if (!file_exists($fileName)) {
96 $dom = new DomDocument();
97 $dom->load($fileName);
99 self
::$_xml[$caseType] = simplexml_import_dom($dom);
101 return self
::$_xml[$caseType];
104 function &allActivityTypes($indexName = TRUE, $all = FALSE) {
105 static $activityTypes = NULL;
106 if (!$activityTypes) {
107 $activityTypes = CRM_Case_PseudoConstant
::caseActivityType($indexName, $all);
109 return $activityTypes;
112 function &allRelationshipTypes() {
113 static $relationshipTypes = array();
115 if (!$relationshipTypes) {
116 $relationshipInfo = CRM_Core_PseudoConstant
::relationshipType();
118 $relationshipTypes = array();
119 foreach ($relationshipInfo as $id => $info) {
120 $relationshipTypes[$id] = $info['label_b_a'];
124 return $relationshipTypes;