[GH-ISSUE #183] Document type detection #127

Closed
opened 2026-03-02 15:56:01 +03:00 by kerem · 6 comments
Owner

Originally created by @nk932714 on GitHub (May 30, 2019).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/183

It would be awesome if file manager automatically recognize the document type.
image

Example :- if we are editing php file then document type should automatically pick php template. But it is picking only JavaScript. we have to manually change this to php.

However is there any way to set default language to php from javaScript. because I'm working only on Php files. So every time after i click save i have to choose php template. its annoying.

Originally created by @nk932714 on GitHub (May 30, 2019). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/183 It would be awesome if file manager automatically recognize the document type. ![image](https://user-images.githubusercontent.com/29853208/58627832-cb3ece00-82f5-11e9-994d-bf2b0c5930a5.png) Example :- if we are editing ```php``` file then document type should automatically pick php template. But it is picking only JavaScript. we have to manually change this to php. However is there any way to set default language to php from javaScript. because I'm working only on Php files. So every time after i click save i have to choose php template. its annoying.
kerem 2026-03-02 15:56:01 +03:00
Author
Owner

@prasathmani commented on GitHub (May 30, 2019):

image
e.g. editor.getSession().setMode( {path:"ace/mode/php", inline:true} );
note : dropdown selection will not change

<!-- gh-comment-id:497303744 --> @prasathmani commented on GitHub (May 30, 2019): ![image](https://user-images.githubusercontent.com/11345598/58630796-19f06600-82fe-11e9-9dea-16349a07959d.png) e.g. `editor.getSession().setMode( {path:"ace/mode/php", inline:true} );` note : dropdown selection will not change
Author
Owner

@nk932714 commented on GitHub (May 31, 2019):

Thanks buddy for your quick reply. It helps.
But the problem is that now I'm unable to switch to JavaScript. Anyways i don't need JavaScript.
eg: I'm editing http://xxxx.xxx/tinyfilemanager.php?p=&edit=tinyfilemanager.php here editing edit=tinyfilemanager.php then it should choose mode automatically. i.e php in this case. and if i'm editing http://xxxx.xxx/tinyfilemanager.php?p=&edit=translation.json then it should choose mode to Json.

I believe a simple this code would be ok for this

<?php if (isset($_GET['edit'])) { $filename_= $_GET["edit"]; $ext_ = pathinfo($filename_, PATHINFO_EXTENSION);	}     else { $ext_= "javascript";      } ?>

editor.getSession().setMode( {path:"ace/mode/<?php echo $ext_; ?>", inline:true} ); ```
<!-- gh-comment-id:497570676 --> @nk932714 commented on GitHub (May 31, 2019): Thanks buddy for your quick reply. It helps. But the problem is that now I'm unable to switch to JavaScript. Anyways i don't need JavaScript. eg: I'm editing ```http://xxxx.xxx/tinyfilemanager.php?p=&edit=tinyfilemanager.php``` here editing **edit=tinyfilemanager.php** then it should choose mode automatically. i.e php in this case. and if i'm editing ```http://xxxx.xxx/tinyfilemanager.php?p=&edit=translation.json``` then it should choose mode to Json. I believe a simple this code would be ok for this ``` <?php if (isset($_GET['edit'])) { $filename_= $_GET["edit"]; $ext_ = pathinfo($filename_, PATHINFO_EXTENSION); } else { $ext_= "javascript"; } ?> editor.getSession().setMode( {path:"ace/mode/<?php echo $ext_; ?>", inline:true} ); ```
Author
Owner

@prasathmani commented on GitHub (May 31, 2019):

In next release I will add this feature

<!-- gh-comment-id:497584344 --> @prasathmani commented on GitHub (May 31, 2019): In next release I will add this feature
Author
Owner

@nk932714 commented on GitHub (Jun 3, 2019):

Thanks @prasathmani

<!-- gh-comment-id:498106447 --> @nk932714 commented on GitHub (Jun 3, 2019): Thanks @prasathmani
Author
Owner

@prasathmani commented on GitHub (Jul 23, 2019):

@nk932714 , your suggestion added.

<!-- gh-comment-id:514091122 --> @prasathmani commented on GitHub (Jul 23, 2019): @nk932714 , your suggestion added.
Author
Owner

@nk932714 commented on GitHub (Jul 24, 2019):

Thanks a lot @prasathmani

<!-- gh-comment-id:514468448 --> @nk932714 commented on GitHub (Jul 24, 2019): Thanks a lot @prasathmani
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#127
No description provided.