$this->assign('operators', CRM_Core_DAO::acceptedSQLOperators());
// List example directories
- global $civicrm_root;
$examples = array();
- foreach (scandir(CRM_Utils_file::addTrailingSlash($civicrm_root, '/') . 'api/v3/examples') as $item) {
+ foreach (scandir(\Civi::paths()->getPath('[civicrm.root]/api/v3/examples')) as $item) {
if ($item && strpos($item, '.') === FALSE) {
$examples[] = $item;
}
* AJAX callback to fetch examples.
*/
public static function getExampleFile() {
- global $civicrm_root;
- $basePath = CRM_Utils_file::addTrailingSlash($civicrm_root, '/');
if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) {
$examples = array();
- foreach (scandir($basePath . 'api/v3/examples/' . $_GET['entity']) as $item) {
+ foreach (scandir(\Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['entity']}")) as $item) {
$item = str_replace('.php', '', $item);
if ($item && strpos($item, '.') === FALSE) {
$examples[] = array('key' => $item, 'value' => $item);
CRM_Utils_JSON::output($examples);
}
if (!empty($_GET['file']) && strpos($_GET['file'], '.') === FALSE) {
- $fileName = $basePath . 'api/v3/examples/' . $_GET['file'] . '.php';
+ $fileName = \Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['file']}.php");
if (file_exists($fileName)) {
echo file_get_contents($fileName);
}