Development =========== What should I use to edit php code ---------------------------------- There are two main options: text editor or `integrated development environment`_ (IDE). Text Editor ^^^^^^^^^^^ If you are new to software development or do not have much experience with IDEs, using a text editor will get you up and running the quickest. At a minimum, you will want one that does syntax highlighting to make the code easier to read. If you think you might submit patches to the bug tracker, you will want to make sure that your text editor does not change line endings. If you are using Windows, `Notepad++`_ is a good choice. If you are on a Mac, TextWrangler_ is a popular choice. You could also give TextMate_ a try. Integrated Development Environment ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ An IDE does just what it's name implies: it includes a set of tools that you would normally use separately. Most IDEs will include source code control which will allow you to directly commit and update your code from your cvs repository. It may have an FTP client built into it to make the transfer of files to a remote server easier. It will have syntax checking to catch errors before you try to execute the code on a server. The two most popular free IDEs for PHP developers are Eclipse_ and NetBeans_. Eclipse has two different plugins for working with PHP code: PDT_ and PHPEclipse_. .. _integrated development environment: http://en.wikipedia.org/wiki/Integrated_development_environment .. _Notepad++: http://notepad-plus-plus.org/ .. _TextWrangler: http://www.barebones.com/products/textwrangler/index.html .. _TextMate: http://macromates.com/ .. _Eclipse: http://www.eclipse.org/ .. _NetBeans: http://netbeans.org/ .. _PDT: http://www.eclipse.org/pdt/ .. _PHPEclipse: http://www.phpeclipse.com/ I don't like the wording of something in Elgg. How do I change it? ------------------------------------------------------------------ The best way to do this is with a plugin. Create the plugin skeleton ^^^^^^^^^^^^^^^^^^^^^^^^^^ :doc:`/guides/plugins/plugin-skeleton` Locate the string that you want to change ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ All the strings that a user sees should be in the ``/languages`` directory or in a plugin's languages directory (``/mod//languages``). This is done so that it is easy to change what language Elgg uses. For more information on this see the developer documentation on :doc:`/guides/i18n` . To find the string use ``grep`` or a text editor that provides searching through files to locate the string. (A good text editor for Windows is `Notepad++`_ ) Let's say we want to change the string "Add friend" to "Make a new friend". The ``grep`` command to find this string would be ``grep -r "Add friend" *``. Using `Notepad++`_ , you would use the "Find in files" command. You would search for the string, set the filter to ``*.php``, set the directory to the base directory of Elgg, and make sure it searches all subdirectories. You might want to set it to be case sensitive also. You should locate the string "Add friend" in ``/languages/en.php``. You should see something like this in the file: .. code:: php 'friend:add' => "Add friend", This means every time Elgg sees ``friend:add`` it replaces it with "Add friend". We want to change the definition of ``friend:add``. Override the string ^^^^^^^^^^^^^^^^^^^ To override this definition, we will add a languages file to the plugin that we built in the first step. 1. Create a new directory: ``/mod//languages`` 2. Create a file in that directory called ``en.php`` 3. Add these lines to that file .. code:: php 'Make a new friend', ); Make sure that you do not have any spaces or newlines before the ``` that are triggered on every page load: 1. boot, system 2. plugins_boot, system 3. init, system 4. pagesetup, system 5. shutdown, system The *boot*, *system* event is triggered before the plugins get loaded. There does not appear to be any difference between the timing of the next two events: *plugins_boot*, *system* and *init*, *system* so plugins tend to use *init*, *system*. This event is triggered just after the plugins are loaded near the end of the boot script (``/engine/start.php``). The *pagesetup*, *system* event is thrown the first time ``elgg_view()`` is called. Some pages like the default ``index.php`` do not call ``elgg_view()`` so it is not triggered for them. The *shutdown*, *system* event is triggered after the page has been sent to the requester and is handled through the PHP function ``register_shutdown_function()``. There are :doc:`other events ` that are triggered by the Elgg core but they happen occasionally (such as when a user logs in). What variables are reserved by Elgg? ------------------------------------ - ``$CONFIG`` - ``$vars`` - ``$autofeed`` - ``$_GET['action']`` / ``$_POST['action']`` - ``$viewtype`` Copy a plugin ------------- There are many questions asked about how to copy a plugin. Let's say you want to copy the ``blog`` plugin in order to run one plugin called ``blog`` and another called ``poetry``. This is not difficult but it does require a lot of work. You would need to - change the directory name - change the names of every function (having two functions causes PHP to crash) - change the name of every view (so as not to override the views on the original plugin) - change any data model subtypes - change the language file - change anything else that was specific to the original plugin .. note:: If you are trying to clone the ``groups`` plugin, you will have the additional difficulty that the group plugin does not set a subtype.