I'm not sure source tools is the right way to define what I mean so I'll give you an example.
In my code I may have something like that
<div>
<span>Hello</span>
</div>
Since I want my app to be translated I use the _ function.
So I would like to be able to select "Hello" and to click somewhere on the context menu to a launch a tools of mine that would change "Hello" to <?=_("Hello");?>
What you are looking for are regular expressions.
Eclipse has some awesome search and replace functionality.
Do a project wide file search on *.html files with the regexp >([^<]+)< and then replace with ><?=_("$1");?>
Afterwards you can mark which replacements should actually take place.
It might not get you all the way, but it sure is going to help with the bulk of it.
Related
How I can find and show all files in Phpstorm where this method
$this->other_model->any_method()
is called?
cmd+shift+f for Mac and ctrl+shift+f for Windows will find any piece of text throughout the project or directory. Or you could use alt+f7 to find usages.
PHPStorm Keyboard Mapping.
Viewing Structure of a Source File.
You can search for symbol with combination Ctrl+Shift+Alt+N. This combination allows you to search not only PHP classes/methods but also PHP variables, CSS classes etc.
If you want to find method usages in files:
click on your method and press Alt+F7
If you want to search any composition of your desire search, you can use from searching everywhere. I prefer to use this because PhpStorm makes it possible to look for any item of the source code, databases, actions, elements of the user interface, etc. in a single action.
to use that, only press search button in the right upper corner of phpStorm or 2 times press shift key on your keyboard. Now you can find your search everywhere. This is great functionality of phpStorm.
To read more information about using this search method, go to the following link:
Searching Everywhere
To See all the methods for search in phpStorm, Go to the following link:Searching Through the Source Code
I am in the process of creating a website that will eventually be moved to a different domain. Every link on the site currently starts with http://www.mydomain.com/folder. This means that when I move domain I will have to change each and every link. Is there a replacing method of this? Sorry that this is a very basic question, I wasn't quite sure what I was looking for. Thanks for any help.
Firstly; best way is to make it configurable. There should be a global variable:
HTTP_SERVER = 'http://www.mydomain.com/';
and when you want you build a link, you should use:
Link To Folder
But let's get back to your question;
You can use an IDE to search and replace in all of the files in a specific folder. I use Visual Studio which you can choose to search in entire project and replace. But if you want other quick solutions, the best one comes to my mind is Notepad++, you can open a bunch of files and search & replace among them. Another one is Sublime Text which is a great lightweight text-editor / IDE that i use.
I would use an IDE to do a global search and replace across all files in the project.
try declaring a $base_url="www.domain.com/folder" in your connection file which will be included in all pages. so that you can just change the base url there only. and when you want the link call it as $base_url.'/page_name.php';
I have text and tables in a word-document and need to extract this into a website. It is very time-consuming to manually copy the table and write all the html.
So I started to use some search & replace operations. Like replace \n with </td></tr>. At the end I have like 5 different search & replace operations. Is there a way to chain these? I tried the macro functionality of PHPStorm but this doesn't work (does not support clicks on dialogs)
Anyone out there could help we with this or if not possible, recommend another tool that works on Mac OS X?
Thanks in advance
I'd recommend #sln's suggestion, or you can chain regexes together in JavaScript. :-)
Also, might I recommend using my custom-built regex tester that will let you search/replace in sequence, but really it's nothing more than a fancy UI on top of preg_replace. :-)
Is there a addon where let say I want to see the origin/stack/trace of a variable I can do so?
I primarily want to see where variables are coming from, what classes and files they go through.
If there is another editor that does this well Ill take suggestions as well!
Thanks.
I don't think TextMate is able to do that, with or without a plugin.
-- START EDIT --
When I was still using it and I wanted to see (and possibly jump to) where a method or property came from I just used Search in Project.
-- END EDIT --
Vim in conjunction with ctags and cscope can help you jump from instance to prototype and vice-versa — wether it's in the current file or not — with <C-]> (or <C-$> on my french Mac keyboard); with TagList or TagBar you can see the structure of your code… but none of this can give you the clean overview you are looking for. But there is probably a plugin for that.
But if that kind of features is important for you it is typically a good reason to use an IDE instead of a text editor. In Eclipse, for example, you have a Type Hierarchy view that does most of what you want and possibly other tools to do the rest. I haven't tried every single IDE under the sun but I think a similar or more powerful feature exists in all of them.
Maybe in Emacs…
I am going to start working on a website that has already been built by someone else.
The main script was bought and then adjusted by the lead programmer. The lead has left and I am the only programmer.
Never met the lead and there are no papers, documentation or comments in the code to help me out, also there are many functions with single letter names. There are also parts of the code that are all compressed in one line (like where there should be 200 lines there is one).
There are a few hundred files.
My questions are:
Does anyone have any advice on how to understand this system?
Has anyone had any similar experiences?
Does anyone have a quick way of decompressing the lines?
Please help me out here. This is my first big break and I really want this to work out well.
Thanks
EDIT:
On regards to the question:
- Does anyone have a quick way of decompressing the lines?
I just used notepad++ (extended replace) and netbeans (the format option) to change a file from 1696 lines to 5584!!
This is going to be a loooonnngggg project
For reformatting the source, try this online pretty-printer: http://www.prettyprinter.de/
For understanding the HTML and CSS, use Firebug.
For understanding the PHP code, step through it in a debugger. (I can't personally recommend a PHP debugger, but I've heard good things about Komodo.)
Start by checking the whole thing into source control, if you haven't already, and then as you work out what the various functions and variables do, rename them to something sensible and check in your changes.
If you can cobble together some rough regression tests (eg. with Selenium) before you start then you can be reasonably sure you aren't breaking anything as you go.
Ouch! I feel your pain!
A few things to get started:
If you're not using source control, don't do anything else until you get that set up. As you hack away at the files, you need to be able to revert to previous, presumably-working versions. Which source-control system you use isn't as important as using one. Subversion is easy and widely used.
Get an editor with a good PHP syntax highlighter and code folder. Which one is largely down to platform and personal taste; I like JEdit and Notepad++. These will help you navigate the code within a page. JEdit's folder is the best around. Notepad++ has a cool feature that when you highlight a word it highlights the other occurrences in the same file, so you can easily see e.g. where a tag begins, or where a variable is used.
Unwind those long lines by search-and-replace ';' with ';\n' -- at least you'll get every statement on a line of its own. The pretty-printer mentioned above will do the same plus indent. But I find that going in and indenting the code manually is a nice way to start to get familiar with it.
Analyze the website's major use cases and trace each one. If you're a front-end guy, this might be easier if you start from the front-end and work your way back to the DB; if you're a back-end guy, start with the DB and see what talks to it, and then how that's used to render pages -- either way works. Use FireBug in Firefox to inspect e.g. forms to see what names the fields take and what page they post to. Look at the PHP page to see what happens next. Use some echo() statements to print out the values of variables at various places. Finally, crack open the DB and get familiar with its schema.
Lather, rinse, repeat.
Good luck!
Could you get a copy of the original script version which was bought? It might be that that is documented. You could then use a comparison tool like Beyond Compare in order to extract any modifications that have been made.
If the functions names are only one letter it could be that the code is encoded with some kind of tool (I think Zend had a tool like that - Zend Encoder?) so that people cannot copy it. You should try to find an unencoded version, if there is one because that would save a lot of time.