Skip to content

Commit

Permalink
Fix includes (#941)
Browse files Browse the repository at this point in the history
* Add __DIR__ to includes

Regex: ((?<!will )(include|require)(_once)?\s+)'
Replace: $1__DIR__ . '/

* Include always once if desired

Regex: (include|require)(?=\s+__DIR__)
Replace: $1_once

* Fix include in doc

* Minor alignment fix in doc

* Update init.php

Co-authored-by: Imants Horsts <[email protected]>
  • Loading branch information
mvorisek and DarkSide666 authored Feb 11, 2020
1 parent fc56998 commit ad62e44
Show file tree
Hide file tree
Showing 94 changed files with 156 additions and 156 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Create "index.php" file with:

``` php
<?php
require 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

$app = new \atk4\ui\App(); // That's your UI application
$app->initLayout('Centered');
Expand Down
2 changes: 1 addition & 1 deletion demos/accordion-nested.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

/*
$app->add(['Button', 'View Form input split in Accordion section', 'small right floated basic blue', 'iconRight' => 'right arrow'])
Expand Down
2 changes: 1 addition & 1 deletion demos/accordion.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

$app->add(['Button', 'Nested accordions', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['accordion-nested']);
Expand Down
4 changes: 2 additions & 2 deletions demos/actions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'js Event Executor', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['jsactions']);
Expand Down
4 changes: 2 additions & 2 deletions demos/autocomplete.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

// create header
$app->add(['Header', 'Database-driven form with an enjoyable layout']);
Expand Down
4 changes: 2 additions & 2 deletions demos/breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Demonstrates how to use BreadCrumb.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$crumb = $app->add('BreadCrumb');
$crumb->addCrumb('UI Demo', ['index']);
Expand Down
2 changes: 1 addition & 1 deletion demos/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Demonstrates how to use buttons.
*/
require 'init.php';
require_once __DIR__ . '/init.php';
use atk4\ui\Button;
use atk4\ui\Icon;
use atk4\ui\Label;
Expand Down
4 changes: 2 additions & 2 deletions demos/card-action.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Card Deck', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['card-deck']);
Expand Down
4 changes: 2 additions & 2 deletions demos/card-deck.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Card Model', 'small left floated basic blue', 'icon' => 'left arrow'])
->link(['card-action']);
Expand Down
4 changes: 2 additions & 2 deletions demos/card.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Card Model', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['card-action']);
Expand Down
4 changes: 2 additions & 2 deletions demos/cardtable.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

include 'init.php';
include 'database.php';
include_once __DIR__ . '/init.php';
include_once __DIR__ . '/database.php';

$app->add(['Header', 'Card displays read-only data of a single record']);

Expand Down
2 changes: 1 addition & 1 deletion demos/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Testing fields.
*/
require 'init.php';
require_once __DIR__ . '/init.php';

use atk4\ui\FormField\CheckBox;
use atk4\ui\View;
Expand Down
2 changes: 1 addition & 1 deletion demos/columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Testing Columns.
*/
require 'init.php';
require_once __DIR__ . '/init.php';

// some custom style needed for our "highlight" to work. You don't need this on
// your page and it's bad style to include CSS like this!
Expand Down
2 changes: 1 addition & 1 deletion demos/console.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

if (!class_exists('TestConsole')) {
class TestConsole extends \atk4\data\Model
Expand Down
4 changes: 2 additions & 2 deletions demos/crud.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';
$m = new Country($db);
$m->addAction('test', ['ui'=>['button'=>['icon'=>'pencil']]]);
$m->addAction('test1');
Expand Down
4 changes: 2 additions & 2 deletions demos/crud2.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$g = $app->add(['CRUD']);
$g->setModel(new Stat($db));
Expand Down
4 changes: 2 additions & 2 deletions demos/crud3.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

class TestModel extends \atk4\data\Model
{
Expand Down
2 changes: 1 addition & 1 deletion demos/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// A very basic file that sets up Agile Data to be used in some demonstrations
try {
if (file_exists('db.php')) {
include 'db.php';
include_once __DIR__ . '/db.php';
} else {
$db = new \atk4\data\Persistence\SQL('mysql:dbname=atk4;host=localhost', 'root', 'root');
}
Expand Down
4 changes: 2 additions & 2 deletions demos/dropdown-plus.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$form = $app->add('Form');

Expand Down
2 changes: 1 addition & 1 deletion demos/exception_test.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

// JUST TO TEST Exceptions and Error throws

Expand Down
2 changes: 1 addition & 1 deletion demos/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Testing fields.
*/
require 'init.php';
require_once __DIR__ . '/init.php';

$app->add(['Header', 'Types', 'size' => 2]);

Expand Down
4 changes: 2 additions & 2 deletions demos/field2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Demonstrates how to use fields with form.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Header', 'Disabled and read only form fields (normal / readonly / disabled)']);

Expand Down
4 changes: 2 additions & 2 deletions demos/form-custom-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Demonstrates how to use fields with form.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Header', 'Custom Form Layout']);

Expand Down
2 changes: 1 addition & 1 deletion demos/form-section-accordion.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

$app->add(['Button', 'Form Sections', 'small left floated basic blue', 'icon' => 'left arrow'])
->link(['form-section']);
Expand Down
4 changes: 2 additions & 2 deletions demos/form-section.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Accordion in Form', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['form-section-accordion']);
Expand Down
2 changes: 1 addition & 1 deletion demos/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This approach will also prevent your application from registering shutdown handler or catching error,
* so we will need to do a bit of work about that too.
*/
require 'init.php';
require_once __DIR__ . '/init.php';

$tabs = $app->add('Tabs');

Expand Down
4 changes: 2 additions & 2 deletions demos/form2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Testing form.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

// create header
$app->add(['Header', 'Database-driven form with an enjoyable layout']);
Expand Down
4 changes: 2 additions & 2 deletions demos/form3.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Testing form.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

use atk4\ui\jsReload;

Expand Down
4 changes: 2 additions & 2 deletions demos/form4.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Testing form.
*/
require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Header', 'Form automatically decided how many columns to use']);

Expand Down
2 changes: 1 addition & 1 deletion demos/form5.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

$app->add(new \atk4\ui\View([
'Forms below focus on Data integration and automated layouts',
Expand Down
2 changes: 1 addition & 1 deletion demos/form6.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

$app->add(new \atk4\ui\View([
'Forms below demonstrate how to work with multi-value selectors',
Expand Down
2 changes: 1 addition & 1 deletion demos/grid-layout.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

// create layout
$g = $app->add(new \atk4\ui\GridLayout(['columns'=>4, 'rows'=>2]));
Expand Down
4 changes: 2 additions & 2 deletions demos/grid.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$g = $app->add(['Grid']);
$m = new Country($db);
Expand Down
4 changes: 2 additions & 2 deletions demos/grid_action.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$country = new Country($db);

Expand Down
2 changes: 1 addition & 1 deletion demos/header.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require 'init.php';
require_once __DIR__ . '/init.php';

$img = 'https://raw.githubusercontent.com/atk4/ui/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png';

Expand Down
2 changes: 1 addition & 1 deletion demos/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include 'init.php';
include_once __DIR__ . '/init.php';

if (!$app->stickyget('begin')) {
$app->add('Header')->set('Welcome to Agile Toolkit Demo!!');
Expand Down
8 changes: 4 additions & 4 deletions demos/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

date_default_timezone_set('UTC');

require '../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';

/* START - PHPUNIT & COVERAGE SETUP */
if (file_exists('coverage.php')) {
include_once 'coverage.php';
if (file_exists(__DIR__ . '/coverage.php')) {
include_once __DIR__ . '/coverage.php';
}

class Demo extends \atk4\ui\Columns
Expand Down Expand Up @@ -151,4 +151,4 @@ public function highLightCode()
$img = 'https://raw.githubusercontent.com/atk4/ui/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png';
}

require_once 'somedatadef.php';
require_once __DIR__ . '/somedatadef.php';
2 changes: 1 addition & 1 deletion demos/js.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Demonstrates how to use interractive buttons.
*/
include 'init.php';
include_once __DIR__ . '/init.php';

use atk4\ui\Button;
use atk4\ui\Buttons;
Expand Down
4 changes: 2 additions & 2 deletions demos/jsactions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Actions from jsEvent', 'small right floated basic blue', 'iconRight' => 'right arrow'])
->link(['jsactions2']);
Expand Down
4 changes: 2 additions & 2 deletions demos/jsactions2.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$country = new Country($db);
$ct = $country->tryLoadAny();
Expand Down
4 changes: 2 additions & 2 deletions demos/jsactionsgrid.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require 'init.php';
require 'database.php';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/database.php';

$app->add(['Button', 'Actions from jsEvent', 'small left floated basic blue', 'icon' => 'left arrow'])
->link(['jsactions2']);
Expand Down
Loading

0 comments on commit ad62e44

Please sign in to comment.