Welcome Guest, Not a member yet? Register   Sign In
Can a text editor be integrated into the CodeIgniter Libraries?
#1

(This post was last modified: 11-24-2019, 06:59 AM by christaliise.)

I have a simple text editor that I'd like to integrate with CodeIgniter.

Is it just a matter of pasting the program into C:\xampp\htdocs\application\libraries?

And load like this

PHP Code:
$this->load->library('editor'); 

Or is there more? Does there need to be compatibility?
Reply
#2

@christaliise,

That might be one way you could do it. That is the beauty of CI. Depending on what it is your trying to do there might be multiple ways to do it. I can think of a way to do it where you don't even need a library. You just include the necessary libraries in the header view and or footer view and simple add or activate the necessary code in the body of the page where you would need the text editor to appear.
Reply
#3

(This post was last modified: 11-24-2019, 02:00 AM by christaliise.)

(11-23-2019, 07:12 PM)php_rocs Wrote: @christaliise,

That might be one way you could do it.  That is the beauty of CI.  Depending on what it is your trying to do there might be multiple ways to do it.  I can think of a way to do it where you don't even need a library.  You just include the necessary libraries in the header view and or footer view and simple add or activate the necessary code in the body of the page where you would need the text editor to appear.

OK, I dont want it to appear onscreen, I just want it to be triggered in the background. Can you explain how I am to get it to work?

I get the error - Unable to load the requested class: editor
Reply
#4

You will need to specify what "editor" you are using. It's literary thousand of them.
Reply
#5

(This post was last modified: 11-24-2019, 07:35 AM by christaliise.)

(11-24-2019, 02:40 AM)jreklund Wrote: You will need to specify what "editor" you are using. It's literary thousand of them.

OK, I've pasted the program into the Libraries folder, and if I open it within FileExplorer and click on the exe file the program redirects to the open program, so there is nothing wrong with the program.

I've tried

PHP Code:
$this->load->library('editor'); 

and

PHP Code:
$this->load->library('editor\editor.exe'); 

but neither work. Have you got any suggestions on what I should try?

(11-23-2019, 07:12 PM)php_rocs Wrote: @christaliise,

That might be one way you could do it.  That is the beauty of CI.  Depending on what it is your trying to do there might be multiple ways to do it.  I can think of a way to do it where you don't even need a library.  You just include the necessary libraries in the header view and or footer view and simple add or activate the necessary code in the body of the page where you would need the text editor to appear.

I want PHP to execute the program then trigger a macro which would be a hotkey+alpha. Would that be possible?
Reply
#6

Codeigniter can only load PHP based application, not open exe files.
You can however use COM and launch a shell and load it from there.
https://www.php.net/manual/en/function.exec.php#43917

But you can only run everything within the command line. Not doing macros.

So what are you trying to do? (with the editor)
Reply
#7

(This post was last modified: 11-24-2019, 04:50 PM by christaliise.)

(11-24-2019, 12:24 PM)jreklund Wrote: Codeigniter can only load PHP based application, not open exe files.
You can however use COM and launch a shell and load it from there.
https://www.php.net/manual/en/function.exec.php#43917

But you can only run everything within the command line. Not doing macros.

So what are you trying to do? (with the editor)

I'm loading information into the view page via fopen & fwrite but the problem with that is the information "best" goes to the bottom of the page, meaning the recent is at the bottom, whereas I prefer to have recent at the top.

The text editor I have could fix that, by sorting, and it will do many other things but I need it to execute a macro.

I tried using fseek to get the information higher in the page but that overwrites other information which I don't want.

I'm open to any other suggestions if you have any.

Can PHP sort in any way?

Or can PHP copy & delete a line then "find up" and paste, or something similar?
Reply
#8

How are the information saved in the file?

Can't you save the information in a database? And export it instead every time, if you need a file? What are you using it for in the end?

Easiest way are to read the entire file with file_get_contents. Append it to the end of the new line and save it again with file_put_contents.
Reply
#9

(11-25-2019, 11:47 AM)jreklund Wrote: How are the information saved in the file?

Can't you save the information in a database? And export it instead every time, if you need a file? What are you using it for in the end?

Easiest way are to read the entire file with file_get_contents. Append it to the end of the new line and save it again with file_put_contents.

The problem with a database is that I'd need a table for each country, 230+ tables.

I don't think "file_get_contents" and "file_put_contents" will solve my problem.

My problem is that fwrite overwrites any text that comes after new insertions, so I now settle for the 2nd best of appending at the end which means the latest is at the bottom, instead of the preferred, latest at the top. If and when PHP stops the overwriting I'll then adjust the coding so that the latest is at the top.

In any event, I have a new problem with the fwrite. When a script is sent, everything works except paragraphs are not created, for example:-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Risus sed vulputate odio ut. At risus viverra adipiscing at. Quis enim lobortis scelerisque fermentum. Velit dignissim sodales ut eu sem integer. Id donec ultrices tincidunt arcu non sodales. Faucibus turpis in eu mi bibendum. Gravida arcu ac tortor dignissim convallis aenean et tortor. Consequat interdum varius sit amet. Amet luctus venenatis lectus magna fringilla urna porttitor.

Tincidunt ornare massa eget egestas. Pulvinar pellentesque habitant morbi tristique senectus et netus et. Commodo elit at imperdiet dui accumsan sit. Congue nisi vitae suscipit tellus mauris a. Pellentesque habitant morbi tristique senectus. Commodo sed egestas egestas fringilla phasellus faucibus. Id venenatis a condimentum vitae. Urna nunc id cursus metus aliquam eleifend mi. Tortor id aliquet lectus proin nibh nisl condimentum id venenatis. Amet purus gravida quis blandit turpis cursus in hac.

That gets sent to the view file as it appears above but the output in the browser is as follows:-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Risus sed vulputate odio ut. At risus viverra adipiscing at. Quis enim lobortis scelerisque fermentum. Velit dignissim sodales ut eu sem integer. Id donec ultrices tincidunt arcu non sodales. Faucibus turpis in eu mi bibendum. Gravida arcu ac tortor dignissim convallis aenean et tortor. Consequat interdum varius sit amet. Amet luctus venenatis lectus magna fringilla urna porttitor. Tincidunt ornare massa eget egestas. Pulvinar pellentesque habitant morbi tristique senectus et netus et. Commodo elit at imperdiet dui accumsan sit. Congue nisi vitae suscipit tellus mauris a. Pellentesque habitant morbi tristique senectus. Commodo sed egestas egestas fringilla phasellus faucibus. Id venenatis a condimentum vitae. Urna nunc id cursus metus aliquam eleifend mi. Tortor id aliquet lectus proin nibh nisl condimentum id venenatis. Amet purus gravida quis blandit turpis cursus in hac.

I have tried this coding, but it makes no difference:-

PHP Code:
function nl2p($advert)
{
    return 
'<p>'.str_replace(array("\r\n""\r""\n"), '</p><p>'$advert).'</p>';


Any ideas how I can get it to work?
Reply
#10

Hi,
Can you please explain what your software does?
To me it sounds like you have text files that are updated independently to your php program and you want to parse them and display the text in them in a specific order. Is that correct?

If so i would probably be a bit lazy and set up elasticsearch and logstash, where logstash would monitor and parse your files and load them into elastic search. Then you can build your front-end in CI to display and/or search the data from elasticsearch in whatever way you like.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB