Example #1
0
 public function info()
 {
     global $machines_api;
     $php = '';
     if (!empty($machines_api->query->controller)) {
         return $machines_api->controller_info($machines_api->query->controller);
     } else {
         $dir = machines_api_dir();
         if (file_exists("{$dir}/machines-api.php")) {
             $php = file_get_contents("{$dir}/machines-api.php");
         } else {
             // Check one directory up, in case machines-api.php was moved
             $dir = dirname($dir);
             if (file_exists("{$dir}/machines-api.php")) {
                 $php = file_get_contents("{$dir}/machines-api.php");
             }
         }
         if (preg_match('/^\\s*Version:\\s*(.+)$/m', $php, $matches)) {
             $version = $matches[1];
         } else {
             $version = '(Unknown)';
         }
         $active_controllers = explode(',', get_option('machines_api_controllers', 'core'));
         $controllers = array_intersect($machines_api->get_controllers(), $active_controllers);
         return array('machines_api_version' => $version, 'controllers' => array_values($controllers));
     }
 }
Example #2
0
 function controller_path($controller)
 {
     $machines_api_dir = machines_api_dir();
     $machines_api_path = "{$machines_api_dir}/controllers/{$controller}.php";
     $theme_dir = get_stylesheet_directory();
     $theme_path = "{$theme_dir}/{$controller}.php";
     if (file_exists($theme_path)) {
         $path = $theme_path;
     } else {
         if (file_exists($machines_api_path)) {
             $path = $machines_api_path;
         } else {
             $path = null;
         }
     }
     $controller_class = $this->controller_class($controller);
     return apply_filters("{$controller_class}_path", $path);
 }
Example #3
0
<?php

/*
Plugin Name: Machines
Plugin URI: http://sector67.org
Description: A hackerspace tool to manage machines, where a machine can be a tool, a door, or anything that requires permission to access
Version: 0.1
Author: Bob Baddeley
Author URI: http://wyzgyz.org
License: GPL2
*/
$dir = machines_api_dir();
@(include_once "{$dir}/singletons/api.php");
@(include_once "{$dir}/singletons/query.php");
@(include_once "{$dir}/singletons/introspector.php");
@(include_once "{$dir}/singletons/response.php");
@(include_once "{$dir}/models/post.php");
@(include_once "{$dir}/models/comment.php");
@(include_once "{$dir}/models/category.php");
@(include_once "{$dir}/models/tag.php");
@(include_once "{$dir}/models/author.php");
@(include_once "{$dir}/models/attachment.php");
@(include_once "{$dir}/widget.php");
machines_api_init();
function machines_api_init()
{
    global $machines_api;
    if (phpversion() < 5) {
        add_action('admin_notices', 'machines_api_php_version_warning');
        return;
    }