Vim PHP Tab jumping to next blank line after statement - php

I'm having an odd problem with editing PHP files with macvim. When I press tab, instead of giving me a tab or series of spaces, it instead jumps down to a blank line after any series of statements. It will do this through the entire file until it reaches the end. For example, in the following snippet, if I have my cursor in front of "$products" and pressed tab, no tab or space would be inserted, and the cursor would land on the empty line below it:
public function index()
{
// get a distinct list of product names
$products = $this->license_model->get_all_product_names();
// get all records and fields from the view
$records = $this->license_model->get_all_records();
// assign objects to the array to pass to the view
$data = array(
'products' => $products,
'records' => $records
);
// load the view
$this->load->view('home.php', $data);
}
If I was to try and tab the comment above the $data array, the cursor would move to the line just above the next comment "load the view".
Using the vim command >> will indent the line as expected, however. The problem only seems to be with *.php files. Tabbing in say a *.java file works as normal.
Any ideas how I can fix this?
Thanks

Sounds like something has mapped <Tab> or <C-i> in insert mode to something. See what maps are defined for <Tab> by issuing:
:verbose map <Tab>
This should output any mappings that are currently set up and which file set these mappings (so you may remove them).

Related

FileMaker - editing container field using php api and Insert from URL script

I am using php api for adding/editing/viewing a FileMaker database. I am using Filemaker pro 14 and FMS 14 in windows environment.
I am having an issue with adding/editing container fields. Tried the solution given in the following link: https://community.filemaker.com/thread/66165
It was success. The FM script is:
Goto Layout[ The layout that shows your container field ]
New Record/Request
Set Variable[$url ; Value:Get(ScriptParameter)]
Insert from URL [Select, No Dialog ; database_name::ContainerField ; $url]
Exit Script
I don't want to add new record. I have several container fields in the layout so it's not a solution to add a record for each one, and I need to be able to modify older records' container fields.
I tried modifying the script as follows:
Go to Layout ["products" (products)]
Go to Record/Request/Page [Last]
Open Record/Request
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
note: (Last) parameter is just experimental.
The php script is as follows:
$runscript = $fm->newPerformScriptCommand('products', 'addContainerData', 'http://link_to_uploded_file');
$result = $runscript->execute();
$result returns success, but the file wasn't inserted in the container field.
Somebody pointed to me that to use "Insert from URL" I have to specify a record ID. So I did the follows:
modified the php script to:
$editCommand = $fm->newEditCommand('products', $recordID, $editedData);
$editCommand->setPreCommandScript('addContainerData', 'http://url_to_my_uploaded_file');
$result = $editCommand->execute();
and the FM script (addContainerData) to
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
Also the result was success BUT without inserting the file to the container field.
What am I missing? What to do to be able to add container data to new/old records?
A possible workaround is to use PHP functions to encode the file to base 64 and set that value to a text field in FileMaker. Once there, you can have auto enter or a script to take the base 64 value and decode it to a container field. This works well especially for files with smaller file sizes.

How to grab data from the script protected site with Excel VBA?

I can't import data table from the site which contain stock data. I did in MS Excel 2007; Data > Get External Data > From Web > Import as usual but there have no return from sites. When I tried to grab data table from the site its shown a small window massage (screenshot), I think the process redirecting to another link; but ultimate result is zero. I think the page is script protected.
Redirecting massage: "Opening: 'http://www.dsebd.org/latest_share_price_all.php"
Please advice me how could I download ( import) data from such site in my Excel Workbook.
The site original link: http://www.dsebd.org/latest_share_price_scroll_l.php [I want to download data from here]
Thanks in Advance for any support.
It's not problem with Excel.
Website is using iframe-->and denying access to request...
Look for site code by pressing F12. Did it ever worked for you before
The following code will place each trading code, LTP, change and % change on a separate line in the active worksheet.
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://www.dsebd.org/latest_share_price_scroll_l.php"
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
If you use F12 to look at the source code, you'll notice that each stock and it's associated data is bracketed by a tagname (in this case "a"). Use this to collect the data for each stock and place the data for all stocks in "Results". Step through "Results" and place each stock on a separate line. Use the replace function to remove a line break so the data appears on 1 line.
Set Results = IE.document.getElementsByTagname("table")(0).getElementsByTagname("a")
x = Results.Length
For y = 0 To x - 1
gg = Results(y).innertext
gg = Replace(gg, Chr(10), "", 1, -1, vbTextCompare)
ActiveCell = gg
ActiveCell.Offset(1,0).Select
Next
Press A1 cell, then data-> http://www.dsebd.org/latest_share_price_scroll_l.php-> click first arrow-> import->ok .....eureka
on cell E1 you will see ur desired thing

Typo3 +TV not rendering content elements

I have installed typo3, templavoila and mapped a template.
Everything works fine, except my content elements. They just don't appear. They did before I installed templavoila and mapped a template.
Also, when using
10 = RECORDS
10 {
tables = tt_content
source = 9
}
it does not give me any output.
even nothing with:
10 = RECORDS
10 {
tables = tt_content
source = 9
conf.tt_content = TEXT
conf.tt_content.value = TEST
}
Does anyone have a clue as to what I might be doing wrong?
You must include the css styled content static template in your TS template.
In your ts page object you need to assign it to the templavoila object.
# Default PAGE object:
page = PAGE
page.typeNum = 0
page.10 = USER
page.10.userFunc = tx_templavoila_pi1->main_page
Probably the page, where tt_content is situated is not visible to regular visitor ?
In this case, following snippet will help.
10 = RECORDS
10.tables = tt_content
10.source = 9
10.dontCheckPid = 1
Finally we got it to work. Don't know what I did wrong, but I guess I learned not to do it again.
I'll put the "solution" here since someone might find it helpful and lose more than a day over this like I did.
Solution:
copy an existing content element in list mode, pasted it on a page via page mode
This was to test if that would do anything. Guess what, everything worked again. Not only the newly copied element but also ALL other test elements created via different ways on different pages and storage folders.
Thank you all for helping and thinking along.

PHP - open, read and delete data from a file

I have a file called functions.php.
It contains a lot of data in over 3000 lines.
Somewhere in the middle of this file there is code:
/*****************************************
My Custom Code
*****************************************/
if ( function_exists('my_code') )
my_code(array(
'name' => 'First instance',
'description' => 'Hello, hello.',
));
if ( function_exists('my_code') )
my_code(array(
'name' => 'Second instance',
'description' => 'Haha :)',
));
I'm listing all my_code arrays and I'm getting:
First Instance
Second Instance
Now, what I want to achieve, is, when user clicks X next to "First instance" PHP opens functions.php file in the background, finds the exact function and deletes it without touching anything else.
So after deleting "First Instance" functions.php file should look like this:
/*****************************************
My Custom Code
*****************************************/
if ( function_exists('my_code') )
my_code(array(
'name' => 'Second instance',
'description' => 'Haha :)',
));
Any idea how to achieve this? I know how to open files, write, delete, but I'm not sure how to wipe out not only a single line but a few lines around? :)
If your code is always in the format you described you could read each 5 lines from your file and if it's the instance you want to keep, output them to a string. Then write the string back to the original file.
But again yes, code modifying code IS PAIN. Storing your instances in a data structure such as databases or a formatted file is much better.
I think the best way would be to open the file and loop through the lines. You'll need to match each line of your function, or you would need match the first line and track the number of open and close brackets { } to know when you've reached the end of it.
If a line doesn't match you write that out to a new file. If it does match you ignore it. Then finally you make an system call to do a syntax check on the new file (in case something went wrong with your line matching):
system( "php -l newfile.php", &$retval );
Then check the return value $retval to make sure it was ok (it will be exactly equal to 0). If it is okay then you overwrite functions.php with your new file.
if( $retval === 0 ) {
// the syntax is good
rename( "newfile.php", "functions.php");
}
You would need to set the appropriate paths for this to work.
Now all of that said, this is not a very good idea and I would advise you not to implement it. A better method would be to break your functions out into separate files. Then use an INI config file or a database to keep track of what you should load. Either of those have the ability to be edited. Even a text data file would be better than mucking with the actual code.
Once you know what you're supposed to load then at the beginning require or include the appropriate file.
Here's a simple example of doing it with a database:
$res = mysql_query("SELECT file_name FROM load_functions");
if( mysql_error() ) {
// do something because the query failed
}
else {
while( list($file_name) = mysql_fetch_row($res) ) {
if( file_exists($file_name) ) {
require_once( $file_name );
}
else {
// warn because a file requested didn't exist
}
}
}
Hope that helps

phpmyadmin - default to structure instead of browse

Can I set the default in phpMyAdmin to open in structure instead of browse?
thanks
If perchance you are using the "quick access icon" next to the table name in the navigation frame, this may be configured.
From the configuration file documentation:
$cfg['LeftDefaultTabTable'] string
Defines the tab displayed by default when clicking the small icon
next to each table name in the
navigation panel. Possible values:
"tbl_structure.php", "tbl_sql.php",
"tbl_select.php", "tbl_change.php" or
"sql.php".
For MAMP 3.x the DefaultTabTable configuration parameter applies. It needs to be set in MAMP/bin/phpMyAdmin/config.inc.php, e.g.:
$cfg['DefaultTabTable'] = 'sql.php';
As I said in my comment, you can click on the little table icon to the left of the table name (assuming, as Mike B said, we are talking about the table list on the left) and it will open up the table structure page.
AFAIK, switching the behavior on those links is not possible through a configuration directive. You would have to dig through the code and change it in there. Shouldn't be too complicated, though.
Add:
$cfg['DefaultTabTable'] = 'tbl_structure.php';
To either config.inc.php or config.default.php.
You can also change LeftDefaultTabTable which changes the icon. The options are:
'tbl_structure.php' = fields list
'tbl_sql.php' = SQL form
'tbl_select.php' = search page
'tbl_change.php' = insert row page
'sql.php' = browse page
In phpMyAdmin 4.8.2...
Click the double gears icon at the top of the left navigation pane.
Then click the "Tables" tab within the popup modal. (last tab)
There you can set the "Target for quick access icon" setting, which is referring to the little index card icon to the left of the table links in the left pane.
I didn't see any settings to change the default link behavior, but you can also add an additional "Target for second quick access icon" and define it's default view behavior differently if desired. It adds an additional "Quick access" icon to the left of the table links with your chosen behavior.
I use an old version of XAMPP (1.6.7) which contains an old version of phpMyAdmin (2.11.7), but the following worked for me.
In the /phpmyadmin/libraries/config.default.php file there is a section of code that handles how the table is viewed.
Change the last two lines of code to suit your purposes, for mine I wanted to open tables in "Browse" view, not "Structure" view (which was my default).
/**
* Possible values:
* 'tbl_structure.php' = fields list
* 'tbl_sql.php' = SQL form
* 'tbl_select.php' = select page
* 'tbl_change.php' = insert row page
* 'sql.php' = browse page
*
* #global string $cfg['DefaultTabTable']
*/
// Show table Structure - Default
$cfg['DefaultTabTable'] = 'tbl_structure.php';
// Uncomment below to show table data
// $cfg['DefaultTabTable'] = 'sql.php';
Save this config file and refresh PhpMyAdmin in your browser.
Hope that helps!
In version 3.5.1: go to the PhpMyAdmin home page -> Settings -> Navigation Frame -> Tables tab. Here you will find an option "Target for quick access icon", and set it
"sql.php" if you want it to go to the Browse tab
"tbl_structure.php" if you want it to go to the Structure tab
"tbl_sql.php" if you want it to go to the SQL tab
"tbl_select.php" if you want it to go to the Search tab
"tbl_change.php" if you want it to go to the Insert tab.
Then Save.
This way when you will click on the table name, it will go to the structure; and when clicking on the little icon before the table name, it will go to the tab you just set.
navigation.php
Around Line #646 in phpMyAdmin version 3.3.8
Insert
$href = $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
. $GLOBALS['common_url_query']
.'&table=' . urlencode($table['Name'])
.'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'];
AFTER
$href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
.$GLOBALS['common_url_query'] . '&table='
.urlencode($table['Name']) . '&pos=0';
to make the text field name link in the navigation to behave the same as the little icon to the left of it.
In my version, the configuration setting for it is supposed to be
$cfg['DefaultTabTable'] = 'tbl_structure.php';
It is listed in sample config file. However, /libraries/navigation/Nodes/Node_Table.class.php on line 34 ignores this setting and uses 'sql.php' directly. I changed that line to
'text' => $GLOBALS['cfg']['DefaultTabTable'].'?server=' . $GLOBALS['server']
On that line and it works fine for me.
Go to phpMyAdmin/config.inc.php
find line starting
$cfg['DefaultTabTable']
and set it to value
$cfg['DefaultTabTable'] = 'browse';
Restart Apache, empty session data (second icon under phpMyAdmin logo, alternatively log-out and log-in, not sure if this step is needed, some configs are cached in user's session)
This solved the issue in MAMP 5.7 (i.e. if you click on table name in left navigation tree, the Browse tab is open). PhpMyAdmin is located in MAMP/bin folder
I was following the instructions from etheros and wasn't able to find that configuration option, but it can just be added (to the confic.inc.php file). In my config file, I added it to the "Left frame setup" section, around line 160.
Depending on the phpMyAdmin version either of these should work:
$cfg['LeftDefaultTabTable'] = 'tbl_structure.php';
$cfg['NavigationTreeDefaultTabTable'] = 'tbl_structure.php';
Also you may actually be saving these setting in the phpmyadmin database, table=pma__userconfig. Go ot the phpmyadmin home and click Settings -> Navigation Frame ->Tables -> Target for quick access icon

Categories