Esempio n. 1
0
File: id.php Progetto: Blu2z/implsk
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (preg_match('/^(\\d+)/', $result->get_remainder(), $matches)) {
         $infoblock_id = $matches[0];
         $result->set_resource_parameter('infoblock_id', $infoblock_id);
         $result->truncate_remainder(strlen($infoblock_id));
         return true;
     }
     return false;
 }
Esempio n. 2
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (nc_preg_match('/^(add|search|subscribe)/', $result->get_remainder(), $matches)) {
         $action = $matches[1];
         $result->set_resource_parameter('action', $action);
         $result->truncate_remainder(strlen($action));
         return true;
     }
     return false;
 }
Esempio n. 3
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (!nc_preg_match($this->get_keyword_regexp(), $result->get_remainder(), $matches)) {
         return false;
         // --- RETURN ---
     }
     $possible_keywords = $this->get_possible_keywords($matches[1]);
     $infoblocks_in_folder = array();
     $infoblock_id = $result->get_resource_parameter('infoblock_id');
     // sic, not get_infoblock_id()
     $folder_id = $result->get_resource_parameter('folder_id');
     $infoblock_manager = nc_core::get_object()->sub_class;
     if ($infoblock_id) {
         $infoblocks_in_folder = array($infoblock_manager->get_by_id($infoblock_id));
     } else {
         if ($folder_id) {
             $infoblocks_in_folder = $infoblock_manager->get_by_subdivision_id($folder_id);
         }
     }
     foreach ($possible_keywords as $object_keyword) {
         foreach ($infoblocks_in_folder as $infoblock_settings) {
             list($object_id, $real_object_keyword) = (array) ObjectExists($infoblock_settings['Class_ID'], $infoblock_settings['sysTbl'], $infoblock_settings['Sub_Class_ID'], $object_keyword, $result->get_resource_parameter('date'), true);
             if ($object_id) {
                 $result->set_resource_parameter('infoblock_id', $infoblock_settings['Sub_Class_ID']);
                 $result->set_resource_parameter('object_keyword', $real_object_keyword);
                 $result->set_resource_parameter('object_id', $object_id);
                 $result->truncate_remainder(strlen($object_keyword));
                 return true;
                 // --- RETURN ---
             }
         }
     }
     return false;
     // --- RETURN ---
 }
Esempio n. 4
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (nc_preg_match('/^(\\d+)/', $result->get_remainder(), $matches)) {
         $match = $matches[1];
         $result->set_variable('nc_page', $match);
         $result->truncate_remainder(strlen($match));
         return true;
     } else {
         return false;
     }
 }
Esempio n. 5
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (nc_preg_match($this->regexp, $result->get_remainder(), $matches)) {
         $match = $matches[1];
         $result->set_variable($this->variable_name, $match);
         $result->truncate_remainder(strlen($match));
         return true;
     } else {
         return false;
     }
 }
Esempio n. 6
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $remainder = $result->get_remainder();
     for ($i = 0; $i < $this->length; $i++) {
         if ($remainder[$i] != $this->string[$i]) {
             return false;
         }
     }
     $result->truncate_remainder($this->length);
     return true;
 }
Esempio n. 7
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $infoblock_id = $result->get_resource_parameter('infoblock_id');
     $folder_id = $result->get_resource_parameter('folder_id');
     if ($infoblock_id && !$this->infoblock_has_event_field($infoblock_id)) {
         return false;
     } else {
         if ($folder_id && !$this->folder_has_component_with_event_field($folder_id)) {
             return false;
         } else {
             if (!$infoblock_id && !$folder_id) {
                 return false;
             }
         }
     }
     foreach ($this->regexps as $regexp) {
         if (preg_match($regexp, $result->get_remainder(), $matches)) {
             $date = $matches['Y'] . ($matches['m'] ? "-{$matches['m']}" . ($matches['d'] ? "-{$matches['d']}" : "") : "");
             $result->set_resource_parameter('date', $date);
             $result->truncate_remainder(strlen($date));
             return true;
         }
     }
     return false;
 }
Esempio n. 8
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;
     }
 }
Esempio n. 9
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $remainder = $result->get_remainder();
     // ensure remainder starts and ends with a slash:
     $starts_with_slash = $remainder[0] == '/';
     if (!$starts_with_slash) {
         $remainder = '/' . $remainder;
     }
     if (substr($remainder, -1) != '/') {
         $remainder .= '/';
     }
     // try to get the folder that corresponds to the unresolved path remainder:
     $folder_settings = $this->get_folder_settings($request->get_site_id(), $remainder);
     if ($folder_settings) {
         $result->set_resource_parameter('folder_id', $folder_settings['Subdivision_ID']);
         // do not remove trailing slash, but remove the slash added above
         $chars_to_remove = strlen($folder_settings['Hidden_URL']) - ($starts_with_slash ? 1 : 2);
         $result->truncate_remainder($chars_to_remove);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 10
0
File: id.php Progetto: Blu2z/implsk
 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;
 }
Esempio n. 11
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     $folder_id = $result->get_resource_parameter('folder_id');
     $date = $result->get_resource_parameter('date');
     if ($folder_id && nc_preg_match($this->get_keyword_regexp(), $result->get_remainder(), $matches)) {
         // Сначала попробовать максимально возможное совпадение;
         // затем, если есть возможность частичного совпадения —
         // более короткие варианты (для того, чтобы, к примеру,
         // была возможность использовать символ подчёркивания в
         // ключевых словах или "-" в качестве разделителя частей
         // адреса)
         $keyword_parts = nc_preg_split($this->get_keyword_delimiter(), $matches[1], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
         $possible_keywords = array();
         while (sizeof($keyword_parts)) {
             $possible_keywords[] = join('', $keyword_parts);
             array_pop($keyword_parts);
         }
         $infoblocks_in_folder = nc_core::get_object()->sub_class->get_by_subdivision_id($folder_id);
         foreach ($possible_keywords as $keyword) {
             foreach ($infoblocks_in_folder as $infoblock) {
                 if ($infoblock['EnglishName'] == $keyword) {
                     // KEYWORD MATCH!
                     if ($date) {
                         $has_event_field = nc_core::get_object()->get_component($infoblock['Class_ID'])->get_date_field();
                         if (!$has_event_field) {
                             continue;
                         }
                     }
                     $result->set_resource_parameter('infoblock_id', $infoblock['Sub_Class_ID']);
                     $result->truncate_remainder(strlen($keyword));
                     return true;
                 }
             }
         }
     }
     return false;
 }