Category : Programování

2 months, 1 week ago 0
Posted in: Programování
bin/console doctrine:mapping:import "AppBundle" yml --filter=JmenoTabulky
bin/console doctrine:mapping:convert annotation ./src/AppBundle/Entity --from-database --filter="JmenoTabulky"
bin/console doctrine:generate:entities AppBundle:JmenoTabulky --no-backup
2 months, 3 weeks ago 0
Posted in: Programování
function clean_uploads_from_nonattachments(){
	$uploads_dir = wp_upload_dir(); 
	$search = $uploads_dir['basedir'];
	$replace = $uploads_dir['baseurl'];

	$uploads_dir = ( $uploads_dir['basedir']); 
	$root = $uploads_dir;

	$iter = new RecursiveIteratorIterator(
		new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
		RecursiveIteratorIterator::SELF_FIRST,
		RecursiveIteratorIterator::CATCH_GET_CHILD 
	);
	foreach ($iter as $fileinfo) {
		if ($fileinfo->isFile()) {	
			$image = $fileinfo->getPathname();
			$image_url = str_replace($search, $replace, $image);
			$attachment_id = attachment_url_to_postid($image_url);
				//Not found - then delete file 
				if (!$attachment_id){
					unlink($image);	
				}
				else {
					echo $attachment_id.': '.$image; 			   
				}	
		}
	}			
}
1 year, 7 months ago 0
Posted in: Programování
add_filter( 'wpseo_metabox_prio', 'jw_filter_yoast_seo_metabox' );
function jw_filter_yoast_seo_metabox() {
	return 'low';
}
1 year, 7 months ago 0
Posted in: Programování
php -d memory_limit=2048M /usr/local/bin/composer require ....
1 year, 7 months ago 0
Posted in: Programování
# based on http://www.commandlinefu.com/commands/view/2916/backup-all-mysql-databases-to-individual-files
# but modified for the MAMP path and to include default root/root as username and password

for I in $(/Applications/MAMP/Library/bin/mysql -u root -proot -e 'show databases' -s --skip-column-names); do /Applications/MAMP/Library/bin/mysqldump -u root -proot $I | gzip > "$I.sql.gz"; done

Source: https://gist.github.com/salcode/9142815

4 years 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;
4 years, 1 month 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;
}
5 years, 1 month 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
5 years, 7 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.

5 years, 9 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;
            }
});
";