Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Leaderboard

Popular Content

Showing content with the highest reputation on 09/29/2011 in all areas

  1. Поделюсь) <?php define('DS', DIRECTORY_SEPARATOR); define('APP_PATH', realpath(dirname(__FILE__)).DS); require_once APP_PATH.'config.php'; try { $db = new PDO("mysql:host=".DB_HOSTNAME.";dbname=".DB_DATABASE, DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); } catch (Exception $e) { echo $e->getMessage(); } $db -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $exceptions = array(); foreach ($db->query('SELECT query from url_alias') as $row) { $path = $row['query']; preg_match("/^(.*)_id=(\d+$)/iU",$path,$matches); if ($matches[1] == 'category') $exceptions['category'][] = $matches[2]; elseif($matches[1] == 'vendor') $exceptions['vendor'][] = $matches[2]; else $exceptions[$matches[1]][] = $matches[2]; } //Результаты $insert = array(); //Обход производителей foreach ($db->query('SELECT manufacturer_id as id,name from manufacturer') as $row) { if (!in_array($row['id'],$exceptions['vendor'])) $insert[] = array( 'query'=>'manufacturer_id='.$row['id'], 'keyword'=>slug($row['name']) ); } //Обход категорий foreach ($db->query('SELECT category_id as id,name from category_description') as $row) { if (!in_array($row['id'],$exceptions['category'])) $insert[] = array( 'query'=>'category_id='.$row['id'], 'keyword'=>$row['id'].'-'.slug($row['name']) ); } //Обход продуктов foreach ($db->query('SELECT product_id as id,model from product') as $row) { $insert[] = array( 'query'=>'product_id='.$row['id'], 'keyword'=>(strlen($row['model'])>0)?$row['id'].'-'.slug($row['model']):$row['id'] ); } //Обход новостей foreach ($db->query('SELECT news_id as id,title from news_description') as $row) { if (!in_array($row['id'],$exceptions['news'])) $insert[] = array( 'query'=>'news_id='.$row['id'], 'keyword'=>$row['id'].'-'.slug($row['title']) ); } //Обход инфо-страниц foreach ($db->query('SELECT information_id as id,title from information_description') as $row) { if (!in_array($row['id'],$exceptions['information'])) $insert[] = array( 'query'=>'info_id='.$row['id'], 'keyword'=>$row['id'].'-'.slug($row['title']) ); } $fields = array('query'=>PDO::PARAM_STR, 'keyword'=>PDO::PARAM_STR); foreach ($insert as $r) { echo "INSERT INTO `url_alias` (`query`,`keyword`) VALUES('{$r['query']}','{$r['keyword']}');<br />"; } //Slugify function slug($title) { $gost = array( "Є"=>"EH","І"=>"I","і"=>"i","№"=>"#","є"=>"eh", "А"=>"A","Б"=>"B","В"=>"V","Г"=>"G","Д"=>"D", "Е"=>"E","Ё"=>"JO","Ж"=>"ZH", "З"=>"Z","И"=>"I","Й"=>"JJ","К"=>"K","Л"=>"L", "М"=>"M","Н"=>"N","О"=>"O","П"=>"P","Р"=>"R", "С"=>"S","Т"=>"T","У"=>"U","Ф"=>"F","Х"=>"KH", "Ц"=>"C","Ч"=>"CH","Ш"=>"SH","Щ"=>"SHH","Ъ"=>"'", "Ы"=>"Y","Ь"=>"","Э"=>"EH","Ю"=>"YU","Я"=>"YA", "а"=>"a","б"=>"b","в"=>"v","г"=>"g","д"=>"d", "е"=>"e","ё"=>"jo","ж"=>"zh", "з"=>"z","и"=>"i","й"=>"jj","к"=>"k","л"=>"l", "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r", "с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"kh", "ц"=>"c","ч"=>"ch","ш"=>"sh","щ"=>"shh","ъ"=>"", "ы"=>"y","ь"=>"","э"=>"eh","ю"=>"yu","я"=>"ya","«"=>"","»"=>"","—"=>"-"," "=>"-", ")"=>"-","("=>"-","*"=>"-","&"=>"-","/"=>"-" ); $return = trim(strtr($title, $gost), '-'); $return = strtolower($return); $return = str_replace("--","-",$return); $return = preg_replace("![^\w\d\s-]*!iU","",$return); return $return; }
    1 point
  2. Что то у меня не получается, вот кусок самого блока поиска: <div class="block-search"> <div class="indent-search"> <fieldset class="form-search"> <?php if ($keyword) { ?> <input type="text" value="<?php echo $keyword; ?>" id="filter_keyword" class="input-text" /> <?php } else { ?> <input type="text" value="<?php echo $text_keyword; ?>" id="filter_keyword" onclick="this.value = '';" onkeydown="this.style.color = '000000'" style="color: #999;" class="input-text" /> <?php } ?> <button class="button" type="submit" onclick="moduleSearch();"> </button> </fieldset> </div> <p class="search-text"><?php echo $entry_search; ?></p> </div> А вот джава внизу: <script type="text/javascript"><!-- $('block-search').keydown(function(e) { if (e.keyCode == 13) { moduleSearch(); } }); function moduleSearch() { url = 'index.php?route=product/search'; var filter_keyword = $('#filter_keyword').attr('value') if (filter_keyword) { url += '&keyword=' + encodeURIComponent(filter_keyword); } var filter_category_id = $('#filter_category_id').attr('value'); if (filter_category_id) { url += '&category_id=' + filter_category_id; } location = url; } //--></script> <script type="text/javascript"><!-- $('.switcher').bind('click', function() { $(this).find('.option').slideToggle('fast'); }); так и не пойму почему не работает!
    1 point
  3. если есть этот модуль под 1.5 - готов обсудить сумму!
    1 point
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.