Example #1
0
 /**
  * Factory method to create the template object.
  * Will choose the correct template type based on the request. Any preregistered
  * variables are also registered and cleared from the preregister cache.
  *
  * @param	string	Name of the template to be evaluated
  * @return	vB_Template	Template object
  */
 public static function create($template_name, $forcenoapi = false)
 {
     static $output_type;
     if (defined('VB_API') and VB_API and !$forcenoapi) {
         // TODO: Use an option to enable/disable the api output
         if (!isset($output_type)) {
             $output_type = 'json';
         }
         if ($output_type == 'xml') {
             $template = new vB_Template_XML($template_name);
         } else {
             $template = new vB_Template_JSON($template_name);
         }
         if (!VB_API_CMS) {
             global $show;
             $copyofshow = $show;
             self::remove_common_show($copyofshow);
             $template->register('show', $copyofshow);
         }
     } else {
         $template = new vB_Template($template_name);
     }
     if (isset(self::$pre_registered[$template_name])) {
         $template->quickRegister(self::$pre_registered[$template_name]);
         // TODO: Reinstate once search uses a single template object
         // unset(self::$pre_registered[$template_name]);
     }
     return $template;
 }
Example #2
0
 /**
  * Factory method to create the template object.
  * Will choose the correct template type based on the request. Any preregistered
  * variables are also registered and cleared from the preregister cache.
  *
  * @param	string	Name of the template to be evaluated
  * @return	vB_Template	Template object
  */
 public static function create($template_name, $forcenoapi = false)
 {
     static $output_type;
     if (defined('VB_API') and VB_API and !$forcenoapi) {
         // TODO: Use an option to enable/disable the api output
         if (!isset($output_type)) {
             //				global $vbulletin;
             //
             //				$vbulletin->input->clean_gpc('r', 'api');
             //				$output_type = in_array($vbulletin->GPC['api'], array('xml', 'json')) ? $vbulletin->GPC['api'] : 'json';
             // Currently we support json only
             $output_type = 'json';
         }
         if ($output_type == 'xml') {
             $template = new vB_Template_XML($template_name);
         } else {
             $template = new vB_Template_JSON($template_name);
         }
         if (!VB_API_CMS) {
             global $show;
             $copyofshow = $show;
             self::remove_common_show($copyofshow);
             $template->register('show', $copyofshow);
         }
     } else {
         $template = new vB_Template($template_name);
     }
     if (isset(self::$pre_registered[$template_name])) {
         $template->quickRegister(self::$pre_registered[$template_name]);
         // TODO: Reinstate once search uses a single template object
         // unset(self::$pre_registered[$template_name]);
     }
     return $template;
 }