Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: PHP  |  size: 1.04 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         /**
  2.          * Генерация ссылки
  3.          */
  4.         function Link($topic_id=0, $product_id=0) {
  5.                 $topic_id=(int)$topic_id;
  6.                
  7.                 if($topic_id != 0 || $product_id != 0) {
  8.                         $topics = $this->data->GetData('products_topics', "AND `show` = 'Y'");
  9.                        
  10.                         if($product_id !== 0) {
  11.                                 if($topic_id == 0) {
  12.                                         $product = $this->data->GetDataById('products', $product_id);
  13.                                         $topic_id = $product['top'];
  14.                                 }
  15.                                 $product_link = '/'.$product_id;
  16.                         } else {
  17.                                 $product_link = '';
  18.                         }
  19.                        
  20.                         foreach($topics as $i) $topicsByTop[$i['top']][$i['id']] = $i;
  21.                         $linkById = function($topic_id, $topicsByTop, $topics, $linkById) {
  22.                                 if($topic_id==0) return;
  23.                                 return $linkById($topics[$topic_id]['top'], $topicsByTop, $topics, $linkById).'/'.$topics[$topic_id]['nav'];
  24.                         };
  25.                         $topic_link = $linkById($topic_id, $topicsByTop, $topics, $linkById);
  26.                        
  27.                         $prepared_link = $topic_link.$product_link;
  28.                 }
  29.                
  30.                 if(empty($this->localCacheLink)) $this->localCacheLink = linkByModule(__CLASS__);
  31.                
  32.                 return $this->localCacheLink.$prepared_link;
  33.         }