MiTo Team - We do not look for easy ways. We implement them.

RSS: Directory Changes Watcher

http://mito-team.com/rss.xml

Publisher: MiTo Team

MiTo Team - We do not look for easy ways. We implement them.

PHP 8.3 is out!
Wed, 20 Dec 2023 02:32:10 -0500

PHP 8.3 is out!

PHP 8.3 is out! Yay!

This is first time for last years when PHP version upgrade did not brake anything in our projects. All issues were just about some dependencies did not update php version requirements. Now everything is solved so we have PHP 8.3 on our production servers and everything works good. Much faster, much less code problems to solve comparing to 8.0 -> 8.1 or 8.1 -> 8.2 upgrades.

mitoteam/jpgraph package is upgraded as well to support PHPP 8.3. Yet marked as "rc" but there are no any issues reported. Going to release stable version in a few days.

mishutka

Switching to Debian 12 "bookworm"
Thu, 03 Aug 2023 03:49:18 -0400

Switching to Debian 12 "bookworm"

Debian 12 bookworm was released on June 10th, 2023. And next day we tried to use it (in development environment). And it went unexpectedly easy, there were no problems at all. So we started to plan migration for all servers in three steps: development servers, testing (staging) servers, production servers. And today we finished migration of all production servers to Debian 12 bookworm.

From our 20 years of experience of using Debian Linux transition from bullseye to bookworm was smoothest and easiest ever.

Thanks to everyone participated in creating such a great product. One more donation from our team. And long live the Debian!

P.S.: There was just one question with MySQL (the have no package for bookworm yet). But is works without any problems being installed from bullseye package.

mishutka

Switching to Drupal 10
Thu, 16 Feb 2023 00:32:06 -0500

Switching to Drupal 10

Drupal 10 is out for more than two months already! And this is extremely exciting.

Usually it takes from a year to switch to new core version: a lot of modules to upgrade, significant code changes. But Drupal 10 has almost the same core code as previous generation Drupal 9.5. There is a lot of deprecated code removed, there are some new features, but most of 9.5-compatible code runs without any problems with 10.0-core.

Most annoying issue is that not all contrib modules declared their support for Drupal 10. Usually the only change required is to add "^10" core version to .info file. So while waiting for maintainers to do this we using this temporary approach to overcome this.

Next major technological milestone will be switching infrastructure to new PHP 8.2. Benchmarks promise 3-8% to overall performance. Will see.

P.S.: This site is already on Drupal 10.

mishutka

PHP 8.2 support added for our composer compatible version of JpGraph library
Fri, 26 Aug 2022 07:00:09 -0400

PHP 8.2 support added for our composer compatible version of JpGraph library

As usual long story short: https://packagist.org/packages/mitoteam/jpgraph.

We added patches to avoid PHP 8.2 warnings and some deprecation notices. Our internal tests are passing. Plus we have several confirmations from other users about no problems with PHP 8.2. So version 10.2.1 marked as release candidate and seems to be ready for production usage.

We'll mark it stable as soon as PHP 8.2 released (expected on November 24, 2022).

Original JpGraph library: https://jpgraph.net

mishutka

Our composer package of JpGraph library used in PhpSpreadsheet
Mon, 08 Aug 2022 08:20:50 -0400

Our composer package of JpGraph library used in PhpSpreadsheet

Long Story Short: PR accepted by PHPOffice/PhpSpreadsheet maintainers. So it will be included in next release.

We use both JpGraph and PhpSpreadsheet intensively in our projects. But they were not intersected at all since we do not add charts to our spreadsheets.

PHPOffice/PhpSpreadsheet used old abandoned jpgraph/jpgraph package to render charts in spreadsheets so there were no possibility to run it under PHP 8.1 without additional dances, drumming and code-patching.

One of users asked us if our version of JpGraph compatible with PhpSpreadsheet. Answer was yes... but. Oh, there is always but. Investigation led us deep into PhpSpreadsheet's source code, solution was found and confirmed working. So we created pull-request and now it is accepted. The goal was not to break existing compatibility with old jpgraph/jpgraph. So now both abandoned jpgraph/jpgraph and actual mitoteam/jpgraph versions are supported by PhpSpreadsheet.

Have a nice coding!

mishutka

mt-howmany: characters, lines, printed pages count for source code of project
Thu, 16 Jun 2022 10:05:26 -0400

mt-howmany: characters, lines, printed pages count for source code of project

One day our team has discussion about how to estimate amount of source code for one of our projects. First idea was just calculate total files size, but... A whole bunch of questions arised immediately: there are a lot of vendor code in project, there are binary files, there are images, generated code, multi-byte character encodings and so on.

Our goal was to understand just how many pure code was written by our team. And we want to know characters, lines and printed-pages estimate counts for projects. So this pet-project was born as an answer to this questions.

mt-howmany is composer based command-line utility. It is installed like any composer package as a dependency:

composer require mitoteam/mt-howmany

Please take a look at GitHub project page for more details about installation and program usage.

Both UNIX-based and Windows OS are supported. All paths are relative to working directory, directory separators are changed from UNIX-ones (/) to Windows-ones (\) automatically when needed.

Unicode strings are handled by symfony/string package for proper characters count calculation. Tool supports exclusions by file extension or by file type. You can define custom characters per page and lines per page values in config.

Config files are in YAML. There is an ability to split config file to several files (importing one to another). We use this to have common part of config in common repository and individual per-project configs.

Program output example for binardo project:

mt-howmany by MiTo Team
=======================
Working directory: /www/binardo.mt.test
Config file loaded: /www/binardo.mt.test/web/modules/custom/mtlapbase/mt-howmany.common.yml
Config file loaded: /www/binardo.mt.test/mt-howmany.yml
Results by file extension
=========================
 ----------- -------- ------------ ------------- -------
  Type        Size     Characters   Files Count   Lines
 ----------- -------- ------------ ------------- -------
  php         777Kb    782756       174           32225
  twig        50.0Kb   51145        26            1471
  scss        29.8Kb   30464        47            1886
  js          17.1Kb   17276        11            637
  yml         15.5Kb   15767        18            621
  sh          9.59Kb   9816         11            348
  po          3.69Kb   2965         1             164
  json        3.27Kb   3344         4             127
  module      3.10Kb   3176         2             131
  theme       3.06Kb   3133         2             123
  gitignore   2.23Kb   2280         2             82
  md          2.08Kb   1323         6             38
  txt         139      139          1             8
  htaccess    38       38           2             4
 ----------- -------- ------------ ------------- -------
Totals
======
Types count: 14
Paths count: 67
Files count: 307
Size: 916Kb
Characters: 923622
Lines: 37865
Pages by Characters: 257
Pages by Lines: 1052
mishutka

Composer compatible version of JpGraph library with PHP 8.1 support
Fri, 25 Feb 2022 11:24:58 -0500

Composer compatible version of JpGraph library with PHP 8.1 support

Long story short: https://packagist.org/packages/mitoteam/jpgraph.

We use JpGraph library in several projects. It is looks like abandoned project: almost no updates from maintainers, website and documentation is not updated either. We tried to look for alternative... and there are none! All other charts libraries are either paid ones or have much less functionality. So we stayed with JpGraph.

First problem was composer support. There is 2022 already and all our php dependencies are managed with composer. So we created small wrapper for original JpGraph library with single class for comfortable use of JpGraph library in modern projects. This wrapper is available at https://packagist.org/packages/mitoteam/jpgraph.

Now we upgrading our infrastructure from php 8.0 to 8.1. Everything went fine with Drupal itself and its contrib modules. There were some minor changes in our code (deprecations mostly). But it was a huge amount of warnings in logs about deprecations in JpGraph code. So we had to decide either to stay at php 8.0 or try to patch JpGraph library to be compatible with php 8.1. And we did it! We managed to get rid of all the deprecation warnings from JpGraph.

So we can declare php 8.1 support for our JpGraph wrapper at https://packagist.org/packages/mitoteam/jpgraph now.

mishutka

Moving site under Drupal 9
Sun, 13 Feb 2022 10:47:47 -0500

Moving site under Drupal 9

"The shoemaker’s child always goes barefoot"... Our site was created under Drupal 6 CMS in 2008. It was almost frozen since 2012. It took several years to finally find a spare time to migrate out site to modern Drupal 9 CMS.

For now we just moved all important content from old site and did some basic setup. There is a lot of work ahead. But at least is is possible now to  add information about company, projects, team, skills and so on. So stay tuned, we'll do a lot of updates in near future.

There are also couple ideas about technical articles for site.

Hoooray!

mishutka

"Collapse" button plugin for CKEditor for Drupal
Mon, 20 Feb 2012 03:12:05 -0500

"Collapse" button plugin for CKEditor for Drupal

Several days ago I needed to add an ability to add "spoilers" to comments and nodes at VELOBY.NET web site (Minsk's cycling community). Spoiler is a part of text, that is hidden from viewing by default. It expands by click showing previously hidden content to users.

I've googled nice Collapse Text module for Drupal. Installed it, enabled in input format settings. Everything is fine with it.

We use CKEditor as wysiwyg-editor on VELOBY.NET. And I wanted to add a button to its toolbar, to be able to insert [collapsed]...[/collapsed] meta tags before and after text, selected in editor. Googling almost an hour gave me nothing. So I decided to write own plugin for CKEditor with this functionality.

This small article is about creating this plugin.

There is a really good tutorial Creating a Simple CKEditor Plugin. So I'm not reproducing whole plugin creation process here step-by-step. There will be only comments about final plugin code. Full source code is attached at the end of article.

First of all we think of name for new plugin and create a folder with this name. I chose mtcollapsed as plugin name.

Our plugin will add a button to editor's toolbar, so let take care about icon for it before starting coding. It should be 16x16 pixels, and I prefer PNG format. This is what I drew: . Gave it name button.png and put into our mtcollapsed directory.

Then I created an empty plugin.js file to put plugin code in. Our plugin consists of 3 parts: command, toolbar button, and dialog.

Command is really simple:

editor.addCommand('cmdMTCollapsedDialog', new CKEDITOR.dialogCommand('mtcollapsedDialog'));

It adds command cmdMTCollapsedDialog that shows mtcollapsedDialog dialog.

Adding a toolbar is simple and easy to understand too:

editor.ui.addButton('MTcollapsed', { label: 'Insert spoiler', command: 'cmdMTCollapsedDialog', icon: this.path + 'button.png' });

This adds a button with MTcollapsed name with Insert spoiler label (tooltip), with our button.png as button's icon. Clicking this button executes our cmdMTCollapsedDialog command.

And here is most complicated part - dialog:

CKEDITOR.dialog.add( 'mtcollapsedDialog', function ( editor )
    {
      return
      {
        title : 'Spoiler settings',
        minWidth : 300,
        minHeight : 200,
        contents :
        [{
          id : 'tab1',
          label : 'Settings',
          elements :
          [{
            type : 'text',
            id : 'title',
            label : 'Spoiler title',
            onShow : function() { this.setValue('Hidden text'); },
            validate : CKEDITOR.dialog.validate.notEmpty( "Spoiler title should be provided" )
          }]
        }],
        onOk : function()
               {
                 var dialog = this;
                 var title = dialog.getValueOf( 'tab1', 'title' );
 
                 var openTag = '[collapsed title=' + title + ']';
                 var closeTag = '[/collapsed]';
                 var inplaceTag = ' ' + openTag + ' text ' + closeTag + ' ';
 
                 var S = editor.getSelection();
 
                 if( S == null)
                 {
                   editor.insertHtml(inplaceTag);
                   return;
                 }
 
                 var R = S.getRanges();
                 R = R[0];
     
                 if( R == null)
                 {
                   editor.insertHtml(inplaceTag);
                   return;
                 }
 
                 var startPos = Math.min(R.startOffset, R.endOffset);
                 var endPos = Math.max(R.startOffset, R.endOffset);
                 
                 if( startPos == endPos )
                 { editor.insertHtml(inplaceTag); return; }
 
                 var container = new CKEDITOR.dom.element('p');
                 var fragment = R.extractContents();
                 
                 container.appendText(openTag);                  
                 fragment.appendTo(container);  
                 container.appendText(closeTag);
 
                 editor.insertElement(container);
               }
      };
    });

Lines 5-7: dialog parameters setup. Dialogs params described here.

Lines 8-20: Dialog's GUI elements. We just need one textbox (type = 'text') for user to be able to provide a title for hidden text. Line 17 sets default value for this textbox. Line 18 obliges user to provide a title.

Default dialog has two buttons: OK and Cancel. Cancel button just closes dialog without any other actions. Clicking OK button raises onOk event where most work is done (lines 21-61):

Line 24: accessing value provided by user in textbox.

Lines 26-28: preparing meta tags code to insert into editor. If there is a text selected open and close tags inserted before and after this text. If there are no text selected inline open-close metatag inserted ([collapsed title='title text'][/collapsed]).

Lines 30-36: Check if there is a selection in editor. Insert inline open-close metatag at cursor position if there is no selection.

Lines 38-45: Selection consists of ranges. We need first range of selection (actually there is alway just one range in selection). Insert inline open-close metatag at cursor position if there is no first range.

Lines 47-51: Sometimes there is a selection with a range, but this range starts and ends at the same position. This means that nothing still selected. Same thing: insert inline open-close metatag at cursor position.

If there is a selection wit a range we should create a container for its contents (because there could be severals elements selected, for example two paragraphs or paragrah and image).

Lines 53-54: Create container element and prepare range contents.

Lines 56-58: Adding open tag, range contents and close tag to our container.

Line 60: Insert container to editor at cursor position (replacing current selection).

Thats all! Full plugin.js source is in archive attached at the end of this article.

Now we should add our plugin to Drupal's CKEditor. There are two ways of adding plugind to CKEditor in Drupal:

  • An easy one: just putting your plugin into "plugins" folder in CKEditor's module directory. This is really easy. But you'll have to keep this in mind everytime you updating the CKEditor module.
  • As part of own module: you should create owm Drupal module, or add some code to a new one.

I have own module on VELOBY.NET site already, so second way is right for me. But you can try to experiment with first one. it should work as well. To add CKEditor plugin with own module your module should implement hook_ckeditor_plugin hook function. This hook should return an array with plugin definitions. There is only one plugin in our case.

This is what I've added to my velobynet.module file:

/**
* CKEditor plugins hook
*/
function velobynet_ckeditor_plugin() {
  return array(
        'mtcollapsed' => array(
            'name' => 'mtcollapsed',
            'desc' => 'MTCollapsed - ' . t('Inserts [collapsed][/collapsed] tags'),
            'path' => drupal_get_path('module', 'velobynet') . '/ckeditor-plugins/mtcollapsed/',
            'buttons' => array(
                'MTcollapsed' => array('label' => 'Insert spoiler',
                                       'icon' => 'button.png' ),
            )
        )
    );
}

Line 7: Plugin name.

Line 8: Plugin description to show at CKEditor's settings page.

Line 9: Full path (with trailing slash) to plugin folder.

Lines 10-13: Plugin buttons definitions (optional). We define just one button with 'Insert spoiler' label and button.png icon.

After adding this we can enable plugin in some CKEditor's profile settings, and try how it works.

Thank you for reading this and excuse me for my English, it is far from perfect yet .

Please contact us if you have any questions.

Module was tested with Drupal v.6.24, CKEditor (itself) v.3.6.2 and CKEditor (Drupal module) v6.x-1.8.

Downloads

mishutka

Introducing new project: MT Browser Switcher
Fri, 10 Jul 2009 07:05:28 -0400

Introducing new project: MT Browser Switcher

We are glad to introduce you our new project: MT Browser Switcher!

This small utility allows you to assign URLs to several different browsers so different websites can be opened with different browsers. This can be useful if you use some browser for everyday surfing but prefer another browser for particular websites. For example you use Opera for everyday surfing, but you prefer to work with your GMail account using Google Chrome since Google services work much more faster and more stable with Google's native browser.

More details are available at project page. Please provide us with your feedback.

mishutka