Category : Programování

2 years, 5 months ago 0
Posted in: Programování
$page_id = !empty($params['page_id']) ? $params['page_id'] : null;
 $assign = !empty($params['assign']) ? $params['assign'] : null;
 
 if (!empty($page_id)) {
  $contentOps = cmsms()->getContentOperations();
  $templateOps = cmsms()->getTemplateOperations();
 if (!empty($contentOps) && !empty($templateOps)) {
   $content = $contentOps->LoadContentFromId($page_id);
      if (!empty($content)) {
    $templateID = $content->templateId();
    if (!empty($templateID)) {
     $template = $templateOps->LoadTemplateByID($templateID);
     if (!empty($template)) {
      if (!empty($assign)) $smarty->assign($assign, $template->name);
      else return $template->name;
     }
    } 
   }
  }
 }
 
 return false;
2 years, 6 months ago 0
Posted in: Programování
function current_url() {
   $pageURL = 'http';
   if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
   $pageURL .= "://";
   if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
   } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
   }
   return $pageURL;
}

function create_url($other_qs_parsed = array()) {
  $url = current_url();
  $url_parsed = parse_url($url);
  $new_qs_parsed = array();
  
  parse_str($url_parsed['query'], $new_qs_parsed);

  $final_query_string_array = array_merge($new_qs_parsed, $other_qs_parsed);
  $final_query_string = http_build_query($final_query_string_array);

  $new_url = $url_parsed['scheme'] 
           . '://'
           . $url_parsed['host'] 
           . $url_parsed['path'] 
           . '?'      
           . $final_query_string;
  return $new_url;
}
3 years, 5 months ago 0

For PhoneGap build it is enough to have self-signed keystore certificate. You can easily deploy just www folder and sign the Android application to Google Play deploy.

Having installed JSDK, in bin folder there is a keytool app. Just run the app with following parameters and the generated keystore key can be used to sign the Android application.

keytool -genkey -v -keystore yourapplication.keystore -alias yourapplication -keyalg RSA -keysize 2048 -validity 10000
3 years, 11 months ago 0
Posted in: Programování

In case you are suffering with the category page breadcrumbs, which look like nonsence, showing totally unrelated categories, solution may be quite simple (eventhough unacceptable). There may be wrong categories in table ps_category, which have parent category id linking to non existing category. In the moment you delete all rows with not-existing parent-ids, the breadcrumbs will be fixed.

This happen in the case you created some categories and deleted them, but the deletion mechanism in Prestashop is buggy.

4 years, 2 months ago 0

WordPress allows you to use custom text editors with the function wp_editor. There is one very annoying issue, which is cause in combination with qTranslate plugin. It means, while you are using qTranslate and in the same time for example in admin you have custom wp_editor ‚s, you are not able to insert any files (uploads neither images) in the wp_editor.

There is fix available. Editing file

[YOUR_SITE_ROOT]/wp-content/plugins/qtranslate/qtranslate_javascript.php

and make the block on line 238 look following:

$q_config['js']['qtrans_wpActiveEditorOverload'] = "
	jQuery('.wp-editor-wrap').unbind('mousedown');
	jQuery('.wp-editor-wrap').mousedown(function(e){
		/*wpActiveEditor = 'qtrans_textarea_'+this.id.slice(3, -5);*/
		 var sliced = this.id.slice(3, -5);
            if (sliced == 'content'){
 	            wpActiveEditor = 'qtrans_textarea_content';
            } else {
                wpActiveEditor = sliced;
            }
});
";
4 years, 3 months ago 0
Posted in: Programování

Create user defined tag with parameters named alias and param_name

if( !isset($params['alias']) ) {
	return;
}
if( !isset($params['param_name']) ) {
	return;
}
$gCms = cmsms();
$hierarchy_manager = $gCms->GetHierarchyManager();
$node = $hierarchy_manager->sureGetNodeByAlias($params['alias']);
$content = $node->getContent();
$property_value = $content->GetPropertyValue($params['param_name']);
if($property_value != "-1"){
	echo $property_value;
}
4 years, 7 months ago 0
Posted in: Programování
CREATE TABLE IF NOT EXISTS `okresy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nazev` text NOT NULL,
  PRIMARY KEY (`id`)
);

INSERT INTO `okresy` (`id`, `nazev`) VALUES
(1, 'Beroun'),
(2, 'Blansko'),
(3, 'Brno-město'),
(4, 'Benešov'),
(5, 'Brno-venkov'),
(6, 'Bruntál'),
(7, 'Břeclav'),
(8, 'České Budějovice'),
(9, 'Cheb'),
(10, 'Český Krumlov'),
(11, 'Česká Lípa'),
(12, 'Chrudim'),
(13, 'Chomutov'),
(14, 'Děčín'),
(15, 'Domažlice'),
(16, 'Frýdek-Místek'),
(17, 'Havlíčkův Brod'),
(18, 'Hradec Králové'),
(19, 'Hodonín'),
(20, 'Jičín'),
(21, 'Jeseník'),
(22, 'Jindřichův Hradec'),
(23, 'Jihlava'),
(24, 'Jablonec nad Nisou'),
(25, 'Kutná Hora'),
(26, 'Karviná'),
(27, 'Kladno'),
(28, 'Kroměříž'),
(29, 'Kolín'),
(30, 'Klatovy'),
(31, 'Karlovy Vary'),
(32, 'Liberec'),
(33, 'Louny'),
(34, 'Litoměřice'),
(35, 'Mladá Boleslav'),
(36, 'Mělník'),
(37, 'Most'),
(38, 'Náchod'),
(39, 'Nymburk'),
(40, 'Nový Jičín'),
(41, 'Olomouc'),
(42, 'Opava'),
(43, 'Ostrava'),
(44, 'Příbram'),
(45, 'Pelhřimov'),
(46, 'Praha-město'),
(47, 'Praha-východ'),
(48, 'Písek'),
(49, 'Plzeň-jih'),
(50, 'Plzeň-město'),
(51, 'Přerov'),
(52, 'Plzeň-sever'),
(53, 'Prachatice'),
(54, 'Pardubice'),
(55, 'Prostějov'),
(56, 'Praha-západ'),
(57, 'Rakovník'),
(58, 'Rychnov nad Kněžnou'),
(59, 'Rokycany'),
(60, 'Semily'),
(61, 'Sokolov'),
(62, 'Strakonice'),
(63, 'Šumperk'),
(64, 'Svitavy'),
(65, 'Tábor'),
(66, 'Tachov'),
(67, 'Teplice'),
(68, 'Třebíč'),
(69, 'Trutnov'),
(70, 'Uherské Hradiště'),
(71, 'Ústí nad Labem'),
(72, 'Ústí nad Orlicí'),
(73, 'Vsetín'),
(74, 'Vyškov'),
(75, 'Zlín'),
(76, 'Znojmo'),
(77, 'Žďár nad Sázavou');
4 years, 9 months ago 0

Temporary solving of the problem where I am not able to change display brightness using Fn keys, nor in the system settings.

sudo setpci -s 00:02.0 F4.B=XX
5 years, 8 months ago 0
Posted in: Programování

Run these commands:

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin
sudo apt-get install sun-java6-jdk
5 years, 8 months ago 0
Posted in: Programování

First, run

sudo a2enmod rewrite

You have to restart Apache now:

sudo /etc/init.d/apache2 restart

Then edit /etc/apache2/sites-available/default:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo AllowOverride FileInfo Order allow,deny allow from all
</Directory>