Merge remote-tracking branch 'origin/4.4' into 4.4-4.5-2014-09-14-13-58-42
[civicrm-core.git] / xml / templates / listAll.tpl
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
33 * $Id$
34 *
35 */
36
37 class CRM_Core_DAO_AllCoreTables {ldelim}
38
39 static private $tables = null;
40 static private $daoToClass = null;
41
42 static private function init($fresh = FALSE) {ldelim}
43 static $init = FALSE;
44 if ($init && !$fresh) return;
45
46 $entityTypes = array(
47 {foreach from=$tables key=tableName item=table}
48 '{$table.className}' => array(
49 'name' => '{$table.objectName}',
50 'class' => '{$table.className}',
51 'table' => '{$tableName}',
52 ),
53 {/foreach}
54 );
55
56 CRM_Utils_Hook::entityTypes($entityTypes);
57
58 self::$tables = array();
59 self::$daoToClass = array();
60 foreach ($entityTypes as $entityType) {ldelim}
61 self::registerEntityType($entityType['name'], $entityType['class'], $entityType['table']);
62 {rdelim}
63
64 $init = TRUE;
65 {rdelim}
66
67 static private function registerEntityType($daoName, $className, $tableName) {ldelim}
68 self::$daoToClass[$daoName] = $className;
69 self::$tables[$tableName] = $className;
70 {rdelim}
71
72 static public function tables() {ldelim}
73 self::init();
74 return self::$tables;
75 {rdelim}
76
77 static public function daoToClass() {ldelim}
78 self::init();
79 return self::$daoToClass;
80 {rdelim}
81
82 static public function getCoreTables() {ldelim}
83 return self::tables();
84 {rdelim}
85
86 static public function isCoreTable($tableName) {ldelim}
87 return FALSE !== array_search($tableName, self::tables());
88 {rdelim}
89
90 static public function getCanonicalClassName($className) {ldelim}
91 return str_replace('_BAO_', '_DAO_', $className);
92 {rdelim}
93
94 static public function getClasses() {ldelim}
95 return array_values(self::daoToClass());
96 {rdelim}
97
98 static public function getClassForTable($tableName) {ldelim}
99 return CRM_Utils_Array::value($tableName, self::tables());
100 {rdelim}
101
102 static public function getFullName($daoName) {ldelim}
103 return CRM_Utils_Array::value($daoName, self::daoToClass());
104 {rdelim}
105
106 static public function getBriefName($className) {ldelim}
107 return CRM_Utils_Array::value($className, array_flip(self::daoToClass()));
108 {rdelim}
109
110 /**
111 * @param string $className DAO or BAO name
112 * @return string|FALSE SQL table name
113 */
114 static public function getTableForClass($className) {ldelim}
115 return array_search(self::getCanonicalClassName($className), self::tables());
116 {rdelim}
117
118 static public function reinitializeCache($fresh = FALSE) {ldelim}
119 self::init($fresh);
120 {rdelim}
121
122 {rdelim}