コード例 #1
0
ファイル: holidays.php プロジェクト: dapepe/tymio
 /**
  * @param Localizer $locator
  */
 public function __construct($locale)
 {
     $this->_view = \Xily\Bean::create($locale->replace(file_get_contents(MODULE_DIR . 'holidays' . DIRECTORY_SEPARATOR . 'holidays.xml')));
     $api = APIFactory::get('domain');
     $xmlFilterDomain = $this->_view->getNodeById('selFilterDomain');
     if ($xmlFilterDomain) {
         $xmlFilterDomain->addChild(new \Xily\Bean('option', '--- ' . ucfirst($locale->get('common.all')) . ' ---', array('value' => '')));
         foreach ($api->do_list() as $arrDomain) {
             $xmlFilterDomain->addChild(new \Xily\Bean('option', $arrDomain['Name'], array('value' => $arrDomain['Id'])));
         }
     }
 }
コード例 #2
0
ファイル: ixml.inc.php プロジェクト: dapepe/tymio
 protected function _API($elem)
 {
     $name = strtolower($elem['NAME']);
     $command = strtolower($elem['DO']);
     $callId = $name . '.' . $command;
     if ((string) $name === '' or (string) $command === '') {
         throw new Exception('iXML: <api> tag must specify non-empty "name" and "do" attributes.');
     } elseif (isset(self::$apiCallStack[$callId])) {
         throw new Exception('iXML: Cannot recursively call API function "' . $callId . '".');
     }
     $result = null;
     // Push API call
     self::$apiCallStack[$callId] = true;
     try {
         //$parameters = $this->toApiParameters($this->runParams($elem));
         $parameters = array();
         foreach ($this->runParams($elem) as $paramName => $paramData) {
             $parameters[$paramName] = \Zeyon\iXml::export($paramData);
         }
         $result = APIFactory::get($name)->dispatch($command, $parameters);
         if ($elem['VAR']) {
             $this->setVar($elem['VAR'], \Zeyon\iXml::import($result));
         }
     } catch (Exception $e) {
         unset(self::$apiCallStack[$callId]);
         throw $e;
     }
     unset(self::$apiCallStack[$callId]);
     return json_encode($result);
 }
コード例 #3
0
ファイル: index.php プロジェクト: dapepe/tymio
            PluginPeer::registerEvent($entity, $event);
        }
    }
}
try {
    registerPluginEvents($pluginEvents);
    $userAuthenticated = APIFactory::getAuthenticator()->authUser(true, true, isset($_REQUEST['autologin']) && $_REQUEST['autologin'] == true);
    $user = APIFactory::getAuthenticator()->getUser();
    PluginPeer::setAuthenticatedUser($user);
    if (isset($_REQUEST['do'])) {
        /* PERFORM THE API CALL
        		-------------------------------------------------------------------- */
        $api = null;
        try {
            $apiName = array_key_exists('api', $_REQUEST) ? strtolower($_REQUEST['api']) : API_DEFAULT;
            $api = APIFactory::get($apiName);
            $api->run();
        } catch (Exception $e) {
            if ($e instanceof APIPermissionDeniedException and !empty($_REQUEST['inline'])) {
                HTTP::forwardTo($_SERVER['SCRIPT_NAME'] . '?view=login' . '&return=' . urlencode($_SERVER['REQUEST_URI']) . '&' . Form::getTokenName() . '=' . urlencode(Form::getToken('loginreturn')));
            } else {
                header('Content-Type: application/json; charset=utf-8');
                if ($api instanceof API) {
                    $res = $api->exceptionToResult($e);
                } else {
                    $res = array('error' => $e->getMessage());
                    if (isset($_REQUEST['debug'])) {
                        $res['trace'] = $e->getTrace();
                    }
                }
                echo json_encode($res);