Contains functions for getting details about the site directories and URLs.
Exemplo n.º 1
0
 /**
  * Handle incoming requests for RSD
  *
  * @todo Move the internal list of supported feeds into options to allow dynamic editing of capabilities
  */
 public function act_rsd()
 {
     Utils::check_request_method(array('GET', 'HEAD', 'POST'));
     /**
      * List of APIs supported by the RSD
      * Refer to namespace for required elements/attributes.
      */
     $apis_list = array('Atom' => array('preferred' => 'true', 'apiLink' => URL::get('atom_feed', 'index=1'), 'blogID' => '1'));
     $apis_list = Plugins::filter('rsd_api_list', $apis_list);
     $cache_xml = null;
     if (Cache::has('atom:rsd:apis')) {
         $cache_apis = Cache::get('atom:rsd:apis');
         if ($cache_apis === $apis_list && Cache::has('atom:rsd:xml')) {
             $cache_xml = Cache::get('atom:rsd:xml');
             $cache_xml = simplexml_load_string($cache_xml);
         }
     } else {
         Cache::set('atom:rsd:apis', $apis_list);
     }
     if ($cache_xml instanceof SimpleXMLElement) {
         $xml = $cache_xml;
     } else {
         $xml = new SimpleXMLElement('<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"></rsd>');
         $rsd_service = $xml->addChild('service');
         $service_engine_name = $rsd_service->addChild('engineName', 'Habari');
         $service_engine_link = $rsd_service->addChild('engineLink', 'http://www.habariproject.org/');
         $service_home_page_link = $rsd_service->addChild('homePageLink', Site::get_url('habari'));
         $service_apis = $rsd_service->addChild('apis');
         if (!isset($apis_list) || count($apis_list) < 1) {
             return false;
         }
         foreach ($apis_list as $api_name => $atts) {
             if (!isset($atts['preferred'], $atts['apiLink'], $atts['blogID'])) {
                 continue;
             }
             $apis_api = $service_apis->addChild('api');
             $apis_api->addAttribute('name', $api_name);
             $apis_api->addAttribute('preferred', $atts['preferred']);
             $apis_api->addAttribute('apiLink', $atts['apiLink']);
             $apis_api->addAttribute('blogID', $atts['blogID'] == '' ? '1' : $atts['blogID']);
             if (!isset($atts['settings']) || count($atts['settings']) < 1) {
                 continue;
             }
             $api_settings = $apis_api->addChild('settings');
             foreach ($atts['settings'] as $setting_name => $setting_value) {
                 switch ($setting_name) {
                     case 'docs':
                     case 'notes':
                         $settings_setting = $api_settings->addChild($setting_name, $setting_value);
                         break;
                     case 'setting':
                         foreach ($setting_value as $setting_array) {
                             $settings_setting = $api_settings->addChild('setting', $setting_array['value']);
                             $settings_setting->addAttribute('name', $setting_array['name']);
                         }
                         break;
                 }
             }
         }
         Cache::set('atom:rsd:xml', $xml->asXML());
     }
     Plugins::act('rsd', $xml, $this->handler_vars);
     $xml = $xml->asXML();
     ob_clean();
     header('Content-Type: application/rsd+xml');
     print $xml;
 }
Exemplo n.º 2
0
 /**
  * Setup the DefensioAPI on Habari initialization.
  * @todo move text domain loading to only admin.
  */
 public function action_init()
 {
     $this->defensio = new DefensioAPI(Options::get(self::OPTION_API_KEY), Site::get_url('habari'));
     $this->load_text_domain('defensio');
 }