Esempio n. 1
0
 /**
  * update category into db
  * @param array $data
  * @param type $parent
  * @param type $category
  * @param array $searchedCat
  */
 public function updateCategory($data = array(), $parent = null, $category, $searchedCat = array())
 {
     //preparing data for update
     $translit = translit_url($category->Наименование) . '';
     $data = array();
     $data['id'] = (string) $user->IDWeb ? (string) $user->IDWeb : $id['id'];
     $data['id'] = $category->IDWeb . '' ? $category->IDWeb . '' : $searchedCat;
     $data['url'] = $translit;
     $data['active'] = TRUE;
     $data['code'] = $category->Код . '';
     $data['parent_id'] = 0;
     $data['external_id'] = $category->ID . '';
     //preparing full_path_ids, full_path, and parent ids
     if (isset($category->IDРодитель)) {
         $data['parent_id'] = $category->IDРодитель . '';
         $data['full_path'] = $this->categories_full_puth[$category->IDРодитель . ''];
         $data['full_path_ids'] = array($category->IDРодитель . '');
         $cat_by_ext = array();
         foreach ($this->cat as $cat) {
             $cat_by_ext[$cat[external_id]] = $cat;
         }
         $parent_ext = unserialize($cat_by_ext[$category->IDРодитель . '']['full_path_ids']);
         if (!$this->categories_full_puth_ids[$data['external_id']]) {
             $this->categories_full_puth_ids[$data['external_id']] = array();
         }
         $this->categories_full_puth_ids[$data['external_id']] = array_merge($this->categories_full_puth_ids[$data['external_id']], $parent_ext);
         $this->categories_full_puth_ids[$data['external_id']] = array_merge($this->categories_full_puth_ids[$data['external_id']], $data['full_path_ids']);
         if (strstr($this->categories_full_puth[$data['external_id']], $data['url'])) {
             $this->categories_full_puth[$data['external_id']] .= $data['full_path'];
         } else {
             $this->categories_full_puth[$data['external_id']] .= $data['full_path'] . '/' . $data['url'];
         }
         $this->category_parents[$data['external_id']] = $category->IDРодитель . '';
     } else {
         $this->categories_full_puth[$data['external_id']] = $data['url'];
         $this->categories_full_puth_ids[$data['external_id']] = array(0);
     }
     //$this->categories_full_puth_ids[$data['external_id']] = array(0);
     $data['full_path'] = $this->categories_full_puth[$data['external_id']];
     unset($data['full_path_ids']);
     $this->update[] = $data;
     //preparing data for i18n table update
     $i18n_data['name'] = $category->Наименование . "";
     $i18n_data['id'] = $category->IDWeb . '';
     $this->update_categories_i18n[] = $i18n_data;
 }
Esempio n. 2
0
 function fast_add($action = '')
 {
     //cp_check_perm('category_create');
     ($hook = get_hook('admin_fast_cat_add')) ? eval($hook) : NULL;
     $this->template->add_array(array('tree' => $this->lib_category->build()));
     if ($action == '') {
         $this->template->show('fast_cat_add', FALSE);
     }
     if ($action == 'create') {
         $this->form_validation->set_rules('name', lang("Title", "admin"), 'trim|required|min_length[1]|max_length[160]');
         $this->form_validation->set_rules('parent_id', lang("Parent", "admin"), 'trim|required|integer|max_length[160]');
         if ($this->form_validation->run($this) == FALSE) {
             showMessage(validation_errors(), false, 'r');
         } else {
             // Create category URL
             if ($this->input->post('url') == FALSE) {
                 $this->load->helper('translit');
                 $url = translit_url($this->input->post('name'));
             } else {
                 $url = $this->input->post('url');
             }
             $fetch_pages = '';
             $data = array('name' => $this->input->post('name'), 'url' => $url, 'position' => '0', 'short_desc' => '', 'parent_id' => $this->input->post('parent_id'), 'description' => '', 'keywords' => '', 'title' => '', 'tpl' => '', 'main_tpl' => '', 'page_tpl' => '', 'per_page' => 15, 'order_by' => 'publish_date', 'sort_order' => 'desc', 'comments_default' => '1', 'fetch_pages' => $fetch_pages);
             $parent = $this->lib_category->get_category($data['parent_id']);
             if ($parent != 'NULL') {
                 $full_path = $parent['path_url'] . $data['url'] . '/';
             } else {
                 $full_path = $data['url'] . '/';
             }
             if ($this->category_exists($full_path) == TRUE and $action != 'update' and $data['url'] != 'core') {
                 $data['url'] .= time();
             }
             ($hook = get_hook('admin_fast_cat_insert')) ? eval($hook) : NULL;
             $id = $this->cms_admin->create_category($data);
             $this->cache->delete_all();
             $this->lib_admin->log(lang("Category has been created or created a category", "admin") . " " . '<a href="' . $BASE_URL . '/admin/categories/edit/' . id . '"> ' . $data['name'] . '</a>');
             echo json_encode(array('data' => $id));
             //updateDiv('categories', site_url('/admin/categories/update_block'));
             //updateDiv('fast_category_list', site_url('/admin/categories/update_fast_block/' . $id));
             //closeWindow('fast_add_cat_w');
             //jsCode("$('comments_status').checked = true;");
         }
     }
 }
Esempio n. 3
0
<?$page="langs";
$title="Словарь:Языки";
include "top.php";

function translit_url($text){
	preg_match_all('/./u', $text, $text);
	$text = $text[0];
	$simplePairs = array( 'а' => 'a' , 'л' => 'l' , 'у' => 'u' , 'б' => 'b' , 'м' => 'm' , 'т' => 't' , 'в' => 'v' , 'н' => 'n' , 'ы' => 'y' , 'г' => 'g' , 'о' => 'o' , 'ф' => 'f' , 'д' => 'd' , 'п' => 'p' , 'и' => 'i' , 'р' => 'r' , 'А' => 'A' , 'Л' => 'L' , 'У' => 'U' , 'Б' => 'B' , 'М' => 'M' , 'Т' => 'T' , 'В' => 'V' , 'Н' => 'N' , 'Ы' => 'Y' , 'Г' => 'G' , 'О' => 'O' , 'Ф' => 'F' , 'Д' => 'D' , 'П' => 'P' , 'И' => 'I' , 'Р' => 'R' , ); $complexPairs = array( 'з' => 'z' , 'ц' => 'c' , 'к' => 'k' , 'ж' => 'zh' , 'ч' => 'ch' , 'х' => 'kh' , 'е' => 'e' , 'с' => 's' , 'ё' => 'jo' , 'э' => 'eh' , 'ш' => 'sh' , 'й' => 'jj' , 'щ' => 'shh' , 'ю' => 'ju' , 'я' => 'ja' , 'З' => 'Z' , 'Ц' => 'C' , 'К' => 'K' , 'Ж' => 'ZH' , 'Ч' => 'CH' , 'Х' => 'KH' , 'Е' => 'E' , 'С' => 'S' , 'Ё' => 'JO' , 'Э' => 'EH' , 'Ш' => 'SH' , 'Й' => 'JJ' , 'Щ' => 'SHH' , 'Ю' => 'JU' , 'Я' => 'JA' , 'Ь' => "" , 'Ъ' => "" , 'ъ' => "" , 'ь' => "" , ); $specialSymbols = array( "_" => "-", "'" => "", "`" => "", "^" => "", " " => "-", '.' => '', ',' => '', ':' => '', '"' => '', "'" => '', '<' => '', '>' => '', '«' => '', '»' => '', ' ' => '-', ); $translitLatSymbols = array( 'a','l','u','b','m','t','v','n','y','g','o', 'f','d','p','i','r','z','c','k','e','s', 'A','L','U','B','M','T','V','N','Y','G','O', 'F','D','P','I','R','Z','C','K','E','S', ); $simplePairsFlip = array_flip($simplePairs); $complexPairsFlip = array_flip($complexPairs); $specialSymbolsFlip = array_flip($specialSymbols); $charsToTranslit = array_merge(array_keys($simplePairs),array_keys($complexPairs)); $translitTable = array(); foreach($simplePairs as $key => $val) $translitTable[$key] = $simplePairs[$key]; foreach($complexPairs as $key => $val) $translitTable[$key] = $complexPairs[$key]; foreach($specialSymbols as $key => $val) $translitTable[$key] = $specialSymbols[$key]; $result = ""; $nonTranslitArea = false; foreach($text as $char) { if(in_array($char,array_keys($specialSymbols))) { $result.= $translitTable[$char]; } elseif(in_array($char,$charsToTranslit)) { if($nonTranslitArea) { $result.= ""; $nonTranslitArea = false; } $result.= $translitTable[$char]; } else { if(!$nonTranslitArea && in_array($char,$translitLatSymbols)) { $result.= ""; $nonTranslitArea = true; } $result.= $char; } } return strtolower(preg_replace("/[-]{2,}/", '-', $result));
}

if($_POST['name']){
	$name = translit_url($_POST['name']);
	$ab=$name[0].$name[1];
	$i=2;
	$query=mysqli_query($mysqli,"SELECT * FROM dt_lang_".$user['id']);
	while($lang=mysqli_fetch_assoc($query)){
		if($lang['ab']==$ab){
			$ab.=$name[$i++];
			$query=mysqli_query($mysqli,"SELECT * FROM dt_lang_".$user['id']);
		}
	}
	echo $ab;
	$query=mysqli_query($mysqli,"INSERT INTO dt_lang_".$user['id']." VALUES('','".$_POST['name']."','".$ab."',1)");
}
?>
<script>
	function show(id){
		var xhr=new XMLHttpRequest();
		xhr.open('GET',"<?echo $config['path'];?>/lang_show.php?id="+id);
		xhr.onreadystatechange=function(){
			if(xhr.readyState==4){
Esempio n. 4
0
 /**
  * update category into db
  * @param array $data
  * @param type $parent
  * @param type $category
  * @param array $searchedCat
  */
 public function updateCategory($data = array(), $parent = null, $category, $searchedCat = array())
 {
     //preparing data for update
     $translit = translit_url($category->Наименование) . '';
     $data = array();
     $data['url'] = $translit;
     $data['active'] = TRUE;
     $data['external_id'] = $searchedCat['external_id'];
     if (!$parent) {
         $data['parent_id'] = 0;
         $data['full_path'] = $translit;
         $ids = array();
         $data['full_path_ids'] = serialize($ids);
     } else {
         $data['parent_id'] = $parent['id'];
         $data['full_path'] = $parent['full_path'] . "/" . $translit;
     }
     $this->update[] = $data;
     //preparing data for i18n table update
     $i18n_data['name'] = $category->Наименование . "";
     $i18n_data['id'] = $searchedCat['id'];
     $this->update_categories_i18n[] = $i18n_data;
     //update full path ids if have parent
     //        if ($parent) {
     //            $data['full_path_ids'] = unserialize($parent['full_path_ids']);
     //            if (empty($data['full_path_ids']))
     //                $data['full_path_ids'] = array($searchedCat['id']);
     //            else {
     //                $data['full_path_ids'][] = $searchedCat['id'];
     //            }
     //            $this->ci->db
     //                    ->where('id', $searchedCat['id'])
     //                    ->update($this->categories_table, array('full_path_ids' => serialize($data['full_path_ids'])));
     //        }
 }
Esempio n. 5
0
	};

$result = $db->query("select * from d_fias_addrobj where formalname=\"Москва\" and aolevel=\"1\" group by okato order by formalname ASC");
	while ($row = $db->fetch($result)){ 
		$trans=translit_url($row["formalname"]);
		echo 'Город: '.$row["formalname"].'. ОКАТО: '.$row['okato'].'. Транслит: '.$trans.'<br><hr>';
$name=$row["formalname"];
		$sql  = "delete from city where cityname=\"$name\"";
$db->query($sql);
$data = array('latname'=>"$trans",'cityname'=>"$name",'country'=>"1",'okato'=>$row['okato']);
$sql  = "INSERT INTO city SET ?u";
$db->query($sql, $data);			
	};

$result = $db->query("select * from d_fias_addrobj where formalname=\"Санкт-Петербург\" and aolevel=\"1\" group by okato order by formalname ASC");
	while ($row = $db->fetch($result)){ 
		$trans=translit_url($row["formalname"]);
		echo 'Город: '.$row["formalname"].'. ОКАТО: '.$row['okato'].'. Транслит: '.$trans.'<br><hr>';
$name=$row["formalname"];
		$sql  = "delete from city where cityname=\"$name\"";
$db->query($sql);
$data = array('latname'=>"$trans",'cityname'=>"$name",'country'=>"1",'okato'=>$row['okato']);
$sql  = "INSERT INTO city SET ?u";
$db->query($sql, $data);			
	};

function translit_url($text) { 
preg_match_all('/./u', $text, $text); 
$text = $text[0]; $simplePairs = array( 'а' => 'a' , 'л' => 'l' , 'у' => 'u' , 'б' => 'b' , 'м' => 'm' , 'т' => 't' , 'в' => 'v' , 'н' => 'n' , 'ы' => 'y' , 'г' => 'g' , 'о' => 'o' , 'ф' => 'f' , 'д' => 'd' , 'п' => 'p' , 'и' => 'i' , 'р' => 'r' , 'А' => 'A' , 'Л' => 'L' , 'У' => 'U' , 'Б' => 'B' , 'М' => 'M' , 'Т' => 'T' , 'В' => 'V' , 'Н' => 'N' , 'Ы' => 'Y' , 'Г' => 'G' , 'О' => 'O' , 'Ф' => 'F' , 'Д' => 'D' , 'П' => 'P' , 'И' => 'I' , 'Р' => 'R' , ); $complexPairs = array( 'з' => 'z' , 'ц' => 'c' , 'к' => 'k' , 'ж' => 'zh' , 'ч' => 'ch' , 'х' => 'kh' , 'е' => 'e' , 'с' => 's' , 'ё' => 'jo' , 'э' => 'eh' , 'ш' => 'sh' , 'й' => 'jj' , 'щ' => 'shh' , 'ю' => 'ju' , 'я' => 'ja' , 'З' => 'Z' , 'Ц' => 'C' , 'К' => 'K' , 'Ж' => 'ZH' , 'Ч' => 'CH' , 'Х' => 'KH' , 'Е' => 'E' , 'С' => 'S' , 'Ё' => 'JO' , 'Э' => 'EH' , 'Ш' => 'SH' , 'Й' => 'JJ' , 'Щ' => 'SHH' , 'Ю' => 'JU' , 'Я' => 'JA' , 'Ь' => "" , 'Ъ' => "" , 'ъ' => "" , 'ь' => "" , ); $specialSymbols = array( "_" => "-", "'" => "", "`" => "", "^" => "", " " => "-", '.' => '', ',' => '', ':' => '', '"' => '', "'" => '', '<' => '', '>' => '', '«' => '', '»' => '', ' ' => '-', ); $translitLatSymbols = array( 'a','l','u','b','m','t','v','n','y','g','o', 'f','d','p','i','r','z','c','k','e','s', 'A','L','U','B','M','T','V','N','Y','G','O', 'F','D','P','I','R','Z','C','K','E','S', ); $simplePairsFlip = array_flip($simplePairs); $complexPairsFlip = array_flip($complexPairs); $specialSymbolsFlip = array_flip($specialSymbols); $charsToTranslit = array_merge(array_keys($simplePairs),array_keys($complexPairs)); $translitTable = array(); foreach($simplePairs as $key => $val) $translitTable[$key] = $simplePairs[$key]; foreach($complexPairs as $key => $val) $translitTable[$key] = $complexPairs[$key]; foreach($specialSymbols as $key => $val) $translitTable[$key] = $specialSymbols[$key]; $result = ""; $nonTranslitArea = false; foreach($text as $char) { if(in_array($char,array_keys($specialSymbols))) { $result.= $translitTable[$char]; } elseif(in_array($char,$charsToTranslit)) { if($nonTranslitArea) { $result.= ""; $nonTranslitArea = false; } $result.= $translitTable[$char]; } else { if(!$nonTranslitArea && in_array($char,$translitLatSymbols)) { $result.= ""; $nonTranslitArea = true; } $result.= $char; } } return strtolower(preg_replace("/[-]{2,}/", '-', $result)); } $str = iconv('UTF-8','windows-1251//TRANSLIT','Умляуты немецкого языка: äöüÄÖÜßèéû и Прочие: Čúу́ и т.д. (их очень много)'); $str = iconv('windows-1251','UTF-8',$str); echo translit_url ($str);

?>
Esempio n. 6
0
 public function edit_cat($id = null)
 {
     if ($id == null) {
         return;
     }
     $this->load->library('lib_admin');
     $this->form_validation->set_rules('name', lang("Name", "documentation"), 'trim|min_length[1]|max_length[127]|required|xss_clean');
     $this->form_validation->set_rules('url', lang("URL", "documentation"), 'xss_clean|max_length[127]');
     $this->form_validation->run();
     if (!$this->form_validation->error_string()) {
         if ($this->input->post('url') == FALSE) {
             $url = translit_url($this->input->post('name'));
         } else {
             $url = translit_url($this->input->post('url'));
         }
         $data = array('name' => $this->input->post('name'), 'url' => $url, 'keywords' => $this->input->post('keywords'), 'description' => $this->input->post('description'), 'parent_id' => $this->input->post('category'));
         $parent = $this->lib_category->get_category($data['parent_id']);
         if ($parent != 'NULL') {
             $full_path = $parent['path_url'] . $data['url'] . '/';
         } else {
             $full_path = $data['url'] . '/';
         }
         if ($this->category_exists($full_path) == TRUE and $data['url'] != 'core') {
             $data['url'] .= time();
         }
         $category = $this->documentation_model->updateCategory($data, $id);
         /** Prepare and return answer * */
         $responseArray = array();
         $responseArray['success'] = 'true';
         $responseArray['errors'] = 'false';
         $responseArray['data']['full_url'] = $category['full_url'];
         $this->cache->delete_all();
         echo json_encode($responseArray);
     } else {
         $responseArray['success'] = 'false';
         $responseArray['errors'] = $this->form_validation->error_string();
         echo json_encode($responseArray);
     }
 }
Esempio n. 7
0
 /**
  * Transilt title to url
  */
 function ajax_translit()
 {
     $this->load->helper('translit');
     $str = trim($this->input->post('str'));
     echo translit_url($str);
 }