Exemple #1
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $infoblock_id = $result->get_infoblock_id();
     if ($infoblock_id && preg_match('/^(\\d+)/', $result->get_remainder(), $matches)) {
         $object_id = $matches[0];
         $infoblock_settings = nc_core::get_object()->sub_class->get_by_id($infoblock_id);
         list($object_id, $real_object_keyword) = (array) ObjectExistsByID($infoblock_settings['Class_ID'], $infoblock_settings['sysTbl'], $object_id, $result->get_resource_parameter('date'), true);
         if ($object_id) {
             $result->set_resource_parameter('object_id', $object_id);
             $result->set_resource_parameter('object_keyword', $real_object_keyword);
             $result->truncate_remainder(strlen($object_id));
             return true;
         }
     }
     return false;
 }
Exemple #2
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (preg_match('/^(html|xml|rss)\\b/', $result->get_remainder(), $matches)) {
         $format = $matches[1];
         if ($format == 'rss' || $format == 'xml') {
             $infoblock_id = $result->get_infoblock_id();
             if (!$infoblock_id) {
                 return false;
             }
             $infoblock_settings = nc_core('sub_class')->get_by_id($infoblock_id);
             $format_mismatch = $format == 'rss' && !$infoblock_settings['AllowRSS'] || $format == 'xml' && !$infoblock_settings['AllowXML'];
             if ($format_mismatch) {
                 return false;
             }
         }
         $result->set_resource_parameter('format', $format);
         $result->truncate_remainder(strlen($format));
         return true;
     } else {
         return false;
     }
 }