version fixes
[civicrm-core.git] / xml / templates / listAll.tpl
CommitLineData
6b5ff8c9
ARW
1<?php
2
3/*
4 +--------------------------------------------------------------------+
81621fee 5 | CiviCRM version 4.7 |
6b5ff8c9 6 +--------------------------------------------------------------------+
e7112fa7 7 | Copyright CiviCRM LLC (c) 2004-2015 |
6b5ff8c9
ARW
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
e7112fa7 32 * @copyright CiviCRM LLC (c) 2004-2015
6b5ff8c9
ARW
33 * $Id$
34 *
35 */
36
4d1d7aca 37class CRM_Core_DAO_AllCoreTables {ldelim}
6b5ff8c9 38
fed67e4d
TO
39 static private $tables = null;
40 static private $daoToClass = null;
3c6315b1 41 static private $entityTypes = null;
fed67e4d 42
17b9f7be 43 static public function init($fresh = FALSE) {ldelim}
fed67e4d 44 static $init = FALSE;
95a90cba 45 if ($init && !$fresh) return;
fed67e4d
TO
46
47 $entityTypes = array(
6b5ff8c9 48{foreach from=$tables key=tableName item=table}
fed67e4d
TO
49 '{$table.className}' => array(
50 'name' => '{$table.objectName}',
51 'class' => '{$table.className}',
52 'table' => '{$tableName}',
53 ),
54{/foreach}
55 );
6b5ff8c9 56
fed67e4d 57 CRM_Utils_Hook::entityTypes($entityTypes);
58d8ecd0 58
3c6315b1 59 self::$entityTypes = array();
fed67e4d
TO
60 self::$tables = array();
61 self::$daoToClass = array();
62 foreach ($entityTypes as $entityType) {ldelim}
63 self::registerEntityType($entityType['name'], $entityType['class'], $entityType['table']);
64 {rdelim}
6b5ff8c9 65
fed67e4d
TO
66 $init = TRUE;
67 {rdelim}
68
17b9f7be
TO
69 /**
70 * (Quasi-Private) Do not call externally (except for unit-testing)
71 */
72 static public function registerEntityType($daoName, $className, $tableName) {ldelim}
fed67e4d
TO
73 self::$daoToClass[$daoName] = $className;
74 self::$tables[$tableName] = $className;
3c6315b1
TO
75 self::$entityTypes[$className] = array(
76 'name' => $daoName,
77 'class' => $className,
78 'table' => $tableName,
79 );
80 {rdelim}
81
82 static public function get() {ldelim}
83 self::init();
84 return self::$entityTypes;
fed67e4d
TO
85 {rdelim}
86
87 static public function tables() {ldelim}
88 self::init();
6b5ff8c9
ARW
89 return self::$tables;
90 {rdelim}
91
fed67e4d
TO
92 static public function daoToClass() {ldelim}
93 self::init();
94 return self::$daoToClass;
95 {rdelim}
96
97 static public function getCoreTables() {ldelim}
98 return self::tables();
99 {rdelim}
100
6b5ff8c9 101 static public function isCoreTable($tableName) {ldelim}
fed67e4d 102 return FALSE !== array_search($tableName, self::tables());
6b5ff8c9
ARW
103 {rdelim}
104
a6c6fe56
TO
105 static public function getCanonicalClassName($className) {ldelim}
106 return str_replace('_BAO_', '_DAO_', $className);
107 {rdelim}
108
439a6148 109 static public function getClasses() {ldelim}
fed67e4d 110 return array_values(self::daoToClass());
439a6148
TO
111 {rdelim}
112
113 static public function getClassForTable($tableName) {ldelim}
fed67e4d 114 return CRM_Utils_Array::value($tableName, self::tables());
439a6148
TO
115 {rdelim}
116
6b5ff8c9 117 static public function getFullName($daoName) {ldelim}
fed67e4d 118 return CRM_Utils_Array::value($daoName, self::daoToClass());
6b5ff8c9
ARW
119 {rdelim}
120
edc091f1 121 static public function getBriefName($className) {ldelim}
fed67e4d 122 return CRM_Utils_Array::value($className, array_flip(self::daoToClass()));
edc091f1
ARW
123 {rdelim}
124
a6c6fe56
TO
125 /**
126 * @param string $className DAO or BAO name
127 * @return string|FALSE SQL table name
128 */
129 static public function getTableForClass($className) {ldelim}
130 return array_search(self::getCanonicalClassName($className), self::tables());
131 {rdelim}
132
95a90cba
N
133 static public function reinitializeCache($fresh = FALSE) {ldelim}
134 self::init($fresh);
135 {rdelim}
a6c6fe56 136
6b5ff8c9 137{rdelim}