Giter Site home page Giter Site logo

extras-evolution / multitv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jako/multitv

8.0 10.0 24.0 2.21 MB

Custom TV for Evolution CMS: Transform a template variables into a sortable multi item list for the Evolution content management framework

PHP 30.71% CSS 5.17% JavaScript 62.65% HTML 1.42% Smarty 0.05%

multitv's Introduction

multiTV custom template variable

Custom Template Variabe containing a sortable multi item list or a datatable for the Evolution CMS content management framework

Features

With this Evolution CMS package a new template variable type is introduced. The template variable could contain a sortable multi item list or a datatable.

Documentation could be found on http://docs.evo.im/en/04_extras/multitv.html

new type "crop"

new type "crop" uses Cropper.js to get parameters for further use with phpthumb.

example of configuration in images.config.inc.php

'image' => array(
    'caption' => 'Image',
    'type' => 'image'
),
'img16x9' =>array (
    'caption' => 'Ratio 16x9',
    'type' => 'crop',
    'cropof' => 'image'
),
'img4x3' =>array (
    'caption' => 'Ratio 4x3',
    'type' => 'crop',
    'cropof' => 'image'
),
'img1x1' =>array (
    'caption' => 'Ratio 1x1',
    'type' => 'crop',
    'cropof' => 'image'
),
'img2x3' =>array (
    'caption' => 'Ratio 2x3',
    'type' => 'crop',
    'cropof' => 'image'
),

where, imgNxN - name that will be used as aspectRatio of Cropper.js initialization, cropof - image field

  1. update tvs\multitv
  2. create/update any config.inc.php to use new type "crop"

As a result, in back-end you can edit images and set four aspect ratio for each image after that you can get this ratio and pass to your image proccessor like phpthumb to crop the image (using snippet, php class, etc.).

Theory:

MultiTV stored image`s ratio in database as

{"fieldValue":[
{"fieldTab":"",
"image":"assets/images/img1.jpg",
"img16x9":"x:12,y:108,width:967,height:543",
"img4x3":"x:4,y:108,width:967,height:725",
"img1x1":"x:5,y:106,width:967,height:967",
"img2x3":"x:65,y:33,width:826,height:1239",
"id":"img1"
}
]}

get this ratio raw json via db helper or MultiTV method for phpThumb crop function correct argument is 'sx=12,sy=108,sw=967,sh=543' we can convert "x:12,y:108,width:967,height:543" to "sx=12,sy=108,sw=967,sh=543" and pass this to phpThumb class

Create Snippet

if you use phpthumb for front-end create snippet 'getImage' like this:

require_once MODX_BASE_PATH .'/assets/snippets/phpthumb/phpthumb.class.php';

$img_source = null;
$img_ration = null;
 
//get raw image`s ratio from db or use multitv method
$modxobject = $modx->getDocumentObject('id', 3, true);

$_images = json_decode($modxobject['goods_images'][1], true);
foreach ($_images['fieldValue'] as $item) {
if (isset($item['image'])) {
  $img_source = $item['image'];
  $img_ratio = $item[$ratio] ?? null;
  break; // get only one image for sample
}
}

//convert multitv image`s data for use in phpthub class
$img_ratio = str_replace(array(':', 'x', 'y', 'width', 'height',','), array('=', 'sx', 'sy', 'sw', 'sh','&'), $img_ratio);
//w & h is image`s output size. you can change this or add your own variables when calling the snippet and replace them here.
$img_params = str_replace('img_ratio',$img_ratio,'q=80&w=450&h=253&img_ratio'); 

parse_str($img_params,$_params);

$path_parts = pathinfo($img_source);
$path = $path_parts['dirname'];

$outputFilename = $path_parts['basename']; // generate public image`s filename here
$defaultCacheFolder = 'assets/cache/';

$path = $defaultCacheFolder . $ratio . '/' . $path;
if (!file_exists($path) && mkdir($path,0755,true) && is_dir($path)) {
    chmod($path, 0755);
}

$phpThumb = new phpthumb();
$phpThumb->config_cache_directory = MODX_BASE_PATH . $defaultCacheFolder;
$phpThumb->config_temp_directory = $defaultCacheFolder;
$phpThumb->config_document_root = MODX_BASE_PATH;
$phpThumb->setSourceFilename(MODX_BASE_PATH . $img_source);

foreach ($_params as $key => $value) {
    $phpThumb->setParameter($key, $value);
}

if ($phpThumb->GenerateThumbnail()) {
	$phpThumb->RenderToFile(MODX_BASE_PATH . $path . $outputFilename);
} 

return  $path . $outputFilename;

Call snippet in front-end

[!getImage? &ratio=`img16x9`!]
[!getImage? &ratio=`img4x3`!]

or

<img src="[!getImage? &ratio=`img16x9`!]">
<img src="[!getImage? &ratio=`img4x3`!]">

multitv's People

Contributors

0test avatar 64j avatar agelxnash avatar atomoc avatar bossloper avatar cipa avatar deesen avatar dmi3yy avatar dreamer0x01 avatar dzhuryn avatar fourroses666 avatar freefali avatar helgispbru avatar jako avatar mnoskov avatar mplavala avatar neoziox avatar nicola1971 avatar pathologic avatar pmfx avatar projectsoft-studionions avatar redduck911 avatar ricardo-lewis avatar russandrussky avatar sashabeep avatar ser1ous avatar serg28 avatar webber12 avatar witq avatar zatomant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multitv's Issues

Custom theme only works when its also loaded in a custom TV

  'head' => array(
        'caption' => 'Title',
        'type' => 'richtext',
        'theme' => 'custom-theme'
    ),
    

This only shows correct when a custom TV has {"theme":"custom-theme"} loaded into the same template.
I guess the needed JS for the custom richtext theme is not loaded in MultiTV.

Multitv dont work (bug)?

My multitv doesn't seem to work anymore. It worked fine and the content will still show up on the website, but the input field are all empty. Also when I try to add content to the empty multitv fields it won't save.

How can I fix this? Updating multitv doesn't seem to work or fix the problem.

MultiTV - how to format the date?

If the date ('date') is used in a multitV Config, the input field (date picker) is available for selection in the document.
The date selected there is called up in the multiTV
& rowTpl = '@ CODE: <div> ((date)) </div>'

Output is in the following form: day-month-year h: m: s

How can this output be formatted?
For example, to display the date only: day.month.year

Help on this point would be great

Рекомендация. Переделать интерфейс, добавить функционал. За основу взять виджет mm_ddMultipleFields

Сравнивал удобство и функционал mm_ddMultipleFields и multiTV. К сожалению по интерфейсу выиграл mm_ddMultipleFields.
Рекомендуемые работы:

  1. Сделать редизайн плагина (За основу можно взять mm_ddMultipleFields)
  2. Добавить общие кнопки:
    а) Очистить Все
    б) Кнопку получить строку с данными в JSON для последующего копирования или использования через Doc Manager
    в) Кнопку пакетного заполнения при наличии полей с изображениями или файлами. Продумать реализацию. Текущий вариант у mm_ddMultipleFields имеет проблемы с тем, что может заполнить только первые изображения в строках.
  1. Добавить для каждой строки помимо кнопок "Добавить" и "Удалить" еще кнопку "копировать", которая создает под копируемой строкой её копию с идентичным контентом.

Я перечислил то немногое, что мне кажется сделает работу с данным плагином удобнее.

screenshot_5
screenshot_6
screenshot_7

+ - buttons improvement

These buttons + and - buttons don’t always respond that good, sometimes have to click it multiple times to add one.

Also not always clear for clients who use it for the first time (my experience). Some clients really don’t look thow :|

Maybe we need to make them al little bigger some pixels and maybe some restyling css.

Heared some complaining when using a pen as mouse. Don’t know exactly what was wrong. Maybe its the drag or no “display block/inline block”.

Maybe we can look into that?

PHP7.2 count() issue

We're using Evo 1.4.6. Our host just upgraded to PHP7.2 and it triggered the error below when the multiTV variable is empty, when there are fields then it only outputs the first one.

Trying to get property 'action' of non-object
« Evo Parse Error »
Error : count(): Parameter must be an array or an object that implements Countable
File /httpd.www/assets/tvs/multitv/includes/multitv.class.php
Line 1089
Source $countOutput = count($tvOutput);
Current Snippet multiTV

Endless loading dbtable display

Hi!

PHP 7.0.33
Evo 1.4.9
multiTV 2.0.15

This function of multiTV is very usefull. I love it. Have a personal DB and manage it with a TV. But it doesn't work anymore. Even with the demo file dbtabledemo.config.json the table is loaded endlessly. Help!

Thanks.

evo 1.4.9 + mtv last = error

Uncaught TypeError: Cannot read property 'language' of undefined
at Object.error (multitv.js:1279)
at i (jquery.min.js:2)
at Object.fireWith [as rejectWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest. (jquery.min.js:4)

PHP Version |   | 5.6.18

problem with datatable config

SVG preview

Is there a way to show a SVG in multiTV image field preview?

When next release?

There have been quite a few commits here since Jan (1.0.13).
When will next release be made so Extras pulls all the latest changes?

PHP 8.0 error

« Evolution CMS Parse Error »

Error : Undefined array key "templates"

Error information  
ErrorType[num] WARNING[2]
File /www/assets/tvs/multitv/includes/multitv.class.php
Line 270
Source $this->templates = $settings[$this->tvTemplates];

PHP 7.1/7.2 Error : A non-numeric value encountered

With MultiTV 2.0.15 and PHP 7.1 and PHP 7.2

`

Error information  
ErrorType[num] WARNING[2]
File /opt/lampp/htdocs/assets/plugins/phx/phx.parser.class.inc.php(356) : eval()'d code
Line 8
Current Snippet multiTV
Current Plugin PHx(OnParseDocument)

Backtrace

DocumentParser->executeParser()index.php on line 139
DocumentParser->prepareResponse()manager/includes/document.parser.class.inc.php on line 2860
DocumentParser->parseDocumentSource(string $var1)manager/includes/document.parser.class.inc.php on line 2969
DocumentParser->invokeEvent('OnParseDocument')manager/includes/document.parser.class.inc.php on line 2704
DocumentParser->evalPlugin(string $var1, array $var2)manager/includes/document.parser.class.inc.php on line 5510
eval()manager/includes/document.parser.class.inc.php on line 1916
PHxParser->OnParseDocument()manager/includes/document.parser.class.inc.php(1916) : eval()'d code on line 9
PHxParser->Parse(string $var1)assets/plugins/phx/phx.parser.class.inc.php on line 50
PHxParser->ParseValues(string $var1)assets/plugins/phx/phx.parser.class.inc.php on line 65
DocumentParser->evalSnippets(string $var1)assets/plugins/phx/phx.parser.class.inc.php on line 132
DocumentParser->_get_snip_result(string $var1)manager/includes/document.parser.class.inc.php on line 2025
DocumentParser->evalSnippet(string $var1, array $var2)manager/includes/document.parser.class.inc.php on line 2113
eval()manager/includes/document.parser.class.inc.php on line 1962
require(string $var1)manager/includes/document.parser.class.inc.php(1962) : eval()'d code on line 1
multiTV->displayMultiValue(array $var1, array $var2)assets/tvs/multitv/multitv.snippet.php on line 95
newChunkie->process()assets/tvs/multitv/includes/multitv.class.php on line 1186
PHxParser->Parse(string $var1)assets/tvs/multitv/includes/newchunkie.class.php on line 519
PHxParser->ParseValues(string $var1)assets/plugins/phx/phx.parser.class.inc.php on line 65
PHxParser->Filter('', string $var2)assets/plugins/phx/phx.parser.class.inc.php on line 187
eval()assets/plugins/phx/phx.parser.class.inc.php on line 356

`

MySQL 5.7 issue

Please replace

"elements": "@SELECT 'Unknown' AS username, 0 as id FROM [+PREFIX+]web_users LIMIT 1 UNION (SELECT username, id FROM [+PREFIX+]web_users ORDER BY username ASC)"

with

"elements": "@SELECT 'Unknown' AS username, 0 as id UNION (SELECT username, id FROM [+PREFIX+]web_users ORDER BY username ASC)"

in assets/tvs/multitv/configs/dbtabledemo.config.json and assets/tvs/multitv/moduleconfigs/event_log.moduleconfig.json

support Font Awesome 5

line 10 in css file
.multitv li.element > div:before {font-family: "Font Awesome 5 Free";top: 40%;left: 8px;content: "\f338";position: absolute;z-index: 100;color: #449d44;}

Sort with accented characters

I have this:
[!multiTV? &tvName=`multicontent` &outerTpl=`content.outer` &rowTpl=`content.row` &display=`all` &orderBy=`title1:text asc` &offset=`0` &published=`1` !]
But, if I have “Éclair” this row is sorted at the end.
I tried to add setlocale(LC_COLLATE, 'fr_FR.UTF8', 'fr_FR.UTF-8', 'fr.UTF8', 'fr.UTF-8'); in multitv.class.php line 1263 (before the usort function) but it's doesn't work.

PHP 8.1.5 - string is deprecated / Undefined array key "tpl_config"

PHP 8.1.5 gives error:

strlen(): Passing null to parameter #1 ($string) of type string is deprecated

« Evolution CMS Parse Error »
Error : Undefined array key "tpl_config"
Error information  
ErrorType[num] WARNING[2]
File /home/.../domains/....com/public_html/assets/tvs/multitv/includes/multitv.class.php
Line 106
Source $this->tvTemplates = 'templates' . $tvDefinitions['tpl_config'];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.