Stable release of v3.2.0-beta3
Move the old helper compiler files to powers. Move the old helper extrusion files to powers.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,900 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
|
||||
|
||||
/**
|
||||
* Structure class
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
class Structure extends Get
|
||||
{
|
||||
|
||||
/**
|
||||
* The folder counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Counter')->folder;
|
||||
*/
|
||||
public $folderCount = 0;
|
||||
|
||||
/**
|
||||
* The file counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Counter')->file;
|
||||
*/
|
||||
public $fileCount = 0;
|
||||
|
||||
/**
|
||||
* The page counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $pageCount = 0;
|
||||
|
||||
/**
|
||||
* The line counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Counter')->line;
|
||||
*/
|
||||
public $lineCount = 0;
|
||||
|
||||
/**
|
||||
* The field counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $fieldCount = 0;
|
||||
|
||||
/**
|
||||
* The seconds counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $seconds = 0;
|
||||
|
||||
/**
|
||||
* The actual seconds counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $actualSeconds = 0;
|
||||
|
||||
/**
|
||||
* The folder seconds counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $folderSeconds = 0;
|
||||
|
||||
/**
|
||||
* The file seconds counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $fileSeconds = 0;
|
||||
|
||||
/**
|
||||
* The line seconds counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $lineSeconds = 0;
|
||||
|
||||
/**
|
||||
* The seconds debugging counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $secondsDebugging = 0;
|
||||
|
||||
/**
|
||||
* The seconds planning counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $secondsPlanning = 0;
|
||||
|
||||
/**
|
||||
* The seconds mapping counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $secondsMapping = 0;
|
||||
|
||||
/**
|
||||
* The seconds office counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $secondsOffice = 0;
|
||||
|
||||
/**
|
||||
* The total hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $totalHours = 0;
|
||||
|
||||
/**
|
||||
* The debugging hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $debuggingHours = 0;
|
||||
|
||||
/**
|
||||
* The planning hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $planningHours = 0;
|
||||
|
||||
/**
|
||||
* The mapping hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $mappingHours = 0;
|
||||
|
||||
/**
|
||||
* The office hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $officeHours = 0;
|
||||
|
||||
/**
|
||||
* The actual Total Hours counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $actualTotalHours = 0;
|
||||
|
||||
/**
|
||||
* The actual hours spent counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $actualHoursSpent = 0;
|
||||
|
||||
/**
|
||||
* The actual days spent counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $actualDaysSpent = 0;
|
||||
|
||||
/**
|
||||
* The total days counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $totalDays = 0;
|
||||
|
||||
/**
|
||||
* The actual Total Days counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $actualTotalDays = 0;
|
||||
|
||||
/**
|
||||
* The project week time counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $projectWeekTime = 0;
|
||||
|
||||
/**
|
||||
* The project month time counter
|
||||
*
|
||||
* @var int
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $projectMonthTime = 0;
|
||||
|
||||
/**
|
||||
* The template path
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path;
|
||||
*/
|
||||
public $templatePath;
|
||||
|
||||
/**
|
||||
* The custom template path
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path_custom;
|
||||
*/
|
||||
public $templatePathCustom;
|
||||
|
||||
/**
|
||||
* The Joomla Version Data
|
||||
*
|
||||
* @var object
|
||||
* @deprecated 3.3 Use CFactory::_('Component.Settings')
|
||||
*/
|
||||
public $joomlaVersionData;
|
||||
|
||||
/**
|
||||
* Static File Content
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.One')->allActive()
|
||||
*/
|
||||
public $fileContentStatic = [];
|
||||
|
||||
/**
|
||||
* Extention Custom Fields
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Compiler.Builder.Extension.Custom.Fields')->get($key)
|
||||
*/
|
||||
public $extentionCustomfields = [];
|
||||
|
||||
/**
|
||||
* Extention Tracking Files Moved
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $extentionTrackingFilesMoved = [];
|
||||
|
||||
/**
|
||||
* The standard folders
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $stdFolders = array('site', 'admin', 'media');
|
||||
|
||||
/**
|
||||
* The standard root files
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public $stdRootFiles
|
||||
= array('access.xml', 'config.xml', 'controller.php', 'index.html', 'README.txt');
|
||||
|
||||
/**
|
||||
* Dynamic File Content
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.Multi')->allActive()
|
||||
*/
|
||||
public $fileContentDynamic = [];
|
||||
|
||||
/**
|
||||
* The Component Sales name
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_sales_name;
|
||||
*/
|
||||
public $componentSalesName;
|
||||
|
||||
/**
|
||||
* The Component Backup name
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_backup_name;
|
||||
*/
|
||||
public $componentBackupName;
|
||||
|
||||
/**
|
||||
* The Component Folder name
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_folder_name;
|
||||
*/
|
||||
public $componentFolderName;
|
||||
|
||||
/**
|
||||
* The Component path
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_path;
|
||||
*/
|
||||
public $componentPath;
|
||||
|
||||
/**
|
||||
* The Dynamic paths
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Registry')->get('dynamic_paths');
|
||||
*/
|
||||
public $dynamicPaths = [];
|
||||
|
||||
/**
|
||||
* The not new static items
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Registry')->get('files.not.new', []);
|
||||
*/
|
||||
public $notNew = [];
|
||||
|
||||
/**
|
||||
* Update the file content
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Registry')->get('update.file.content');
|
||||
*/
|
||||
public $updateFileContent = [];
|
||||
|
||||
/**
|
||||
* The new files
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Files');
|
||||
*/
|
||||
public $newFiles = [];
|
||||
|
||||
/**
|
||||
* The Checkin Switch
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $addCheckin = false;
|
||||
|
||||
/**
|
||||
* The Move Folders Switch
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $setMoveFolders = false;
|
||||
|
||||
/**
|
||||
* The array of last modified dates
|
||||
*
|
||||
* @var array
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
protected $lastModifiedDate = [];
|
||||
|
||||
/**
|
||||
* The default view switch
|
||||
*
|
||||
* @var bool/string
|
||||
* @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard');
|
||||
*/
|
||||
public $dynamicDashboard = false;
|
||||
|
||||
/**
|
||||
* The default view type
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard.type');
|
||||
*/
|
||||
public $dynamicDashboardType;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// first we run the parent constructor
|
||||
if (parent::__construct())
|
||||
{
|
||||
// set incase no extra admin folder are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FOLDERS', '');
|
||||
// set incase no extra site folder are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FOLDERS', '');
|
||||
// set incase no extra media folder are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FOLDERS', '');
|
||||
// set incase no extra admin files are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FILES', '');
|
||||
// set incase no extra site files are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FILES', '');
|
||||
// set incase no extra media files are loaded
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FILES', '');
|
||||
// make sure there is no old build
|
||||
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path);
|
||||
// load the libraries files/folders and url's
|
||||
CFactory::_('Library.Structure')->build();
|
||||
// load the powers files/folders
|
||||
CFactory::_('Power.Structure')->build();
|
||||
// load the module files/folders and url's
|
||||
CFactory::_('Joomlamodule.Structure')->build();
|
||||
// load the plugin files/folders and url's
|
||||
CFactory::_('Joomlaplugin.Structure')->build();
|
||||
// set the dashboard
|
||||
CFactory::_('Component.Dashboard')->set();
|
||||
// set the component base structure
|
||||
if (!CFactory::_('Component.Structure')->build())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// set all single instance folders and files
|
||||
if (!CFactory::_('Component.Structure.Single')->build())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// set all the dynamic folders and files
|
||||
if (!CFactory::_('Component.Structure.Multiple')->build())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Powers files, folders
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Power.Structure')->build();
|
||||
*/
|
||||
private function buildPowers()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Modules files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Joomlamodule.Structure')->build();
|
||||
*/
|
||||
private function buildModules()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Plugins files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Joomlaplugin.Structure')->build();
|
||||
*/
|
||||
private function buildPlugins()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Path if not exist
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Folder')->create($path);
|
||||
*/
|
||||
private function createFolder($path)
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Libraries files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Library.Structure')->build();
|
||||
*/
|
||||
private function setLibraries()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the dynamic dashboard if set
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Component.Dashboard')->set();
|
||||
*/
|
||||
private function setDynamicDashboard()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to file
|
||||
*
|
||||
* @return bool true on success
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public function writeFile($path, $data)
|
||||
{
|
||||
return FileHelper::write($path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Initial Folders
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Component.Structure')->build();
|
||||
*/
|
||||
private function setFolders()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Static File & Folder
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated 3.3 Use CFactory::_('Component.Structure.Single')->build();
|
||||
*/
|
||||
private function setStatic()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Dynamic File & Folder
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated 3.3 Use CFactory::_('Component.Structure.Multiple')->build();
|
||||
*/
|
||||
private function setDynamique()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* move the fields and Rules
|
||||
*
|
||||
* @param array $field The field data
|
||||
* @param string $path The path to move to
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function moveFieldsRules($field, $path)
|
||||
{
|
||||
// check if we have a subform or repeatable field
|
||||
if ($field['type_name'] === 'subform'
|
||||
|| $field['type_name'] === 'repeatable')
|
||||
{
|
||||
// since we could have a custom field or rule inside
|
||||
$this->moveMultiFieldsRules($field, $path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if this is a custom field that should be moved
|
||||
if (CFactory::_('Compiler.Builder.Extension.Custom.Fields')->exists($field['type_name']))
|
||||
{
|
||||
$check = md5($path . 'type' . $field['type_name']);
|
||||
// lets check if we already moved this
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3 &&
|
||||
!isset($this->extentionTrackingFilesMoved[$check]))
|
||||
{
|
||||
// check files exist
|
||||
if (File::exists(
|
||||
CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/'
|
||||
. $field['type_name'] . '.php'
|
||||
))
|
||||
{
|
||||
// copy the custom field
|
||||
File::copy(
|
||||
CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/'
|
||||
. $field['type_name'] . '.php',
|
||||
$path . '/fields/' . $field['type_name'] . '.php'
|
||||
);
|
||||
}
|
||||
// stop from doing this again.
|
||||
$this->extentionTrackingFilesMoved[$check] = true;
|
||||
}
|
||||
}
|
||||
// check if this has validation that should be moved
|
||||
if (CFactory::_('Registry')->get('validation.linked.' . $field['field']) !== null)
|
||||
{
|
||||
$check = md5(
|
||||
$path . 'rule'
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
);
|
||||
// lets check if we already moved this
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3 &&
|
||||
!isset($this->extentionTrackingFilesMoved[$check]))
|
||||
{
|
||||
// check files exist
|
||||
if (File::exists(
|
||||
CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/'
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php'
|
||||
))
|
||||
{
|
||||
// copy the custom field
|
||||
File::copy(
|
||||
CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/'
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php', $path . '/rules/'
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php'
|
||||
);
|
||||
}
|
||||
// stop from doing this again.
|
||||
$this->extentionTrackingFilesMoved[$check] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* move the fields and Rules of multi fields
|
||||
*
|
||||
* @param array $multi_field The field data
|
||||
* @param string $path The path to move to
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
protected function moveMultiFieldsRules($multi_field, $path)
|
||||
{
|
||||
// get the fields ids
|
||||
$ids = array_map(
|
||||
'trim',
|
||||
explode(
|
||||
',',
|
||||
(string) GetHelper::between(
|
||||
$multi_field['settings']->xml, 'fields="', '"'
|
||||
)
|
||||
)
|
||||
);
|
||||
if (ArrayHelper::check($ids))
|
||||
{
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
// setup the field
|
||||
$field = [];
|
||||
$field['field'] = $id;
|
||||
CFactory::_('Field')->set($field);
|
||||
// move field and rules if needed
|
||||
$this->moveFieldsRules($field, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the created date of the (view)
|
||||
*
|
||||
* @param array $view The view values
|
||||
*
|
||||
* @return string Last Modified Date
|
||||
* @deprecated 3.3 Use CFactory::_('Model.Createdate')->get($view);
|
||||
*/
|
||||
public function getCreatedDate($view)
|
||||
{
|
||||
return CFactory::_('Model.Createdate')->get($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the last modified date of a MVC (view)
|
||||
*
|
||||
* @param array $view The view values
|
||||
*
|
||||
* @return string Last Modified Date
|
||||
* @deprecated 3.3 Use CFactory::_('Model.Modifieddate')->get($view);
|
||||
*/
|
||||
public function getLastModifiedDate($view)
|
||||
{
|
||||
return CFactory::_('Model.Modifieddate')->get($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Static File & Folder
|
||||
*
|
||||
* @param array $target The main target and name
|
||||
* @param string $type The type in the target
|
||||
* @param string $fileName The custom file name
|
||||
* @param array $cofig to add more data to the files info
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config);
|
||||
*/
|
||||
public function buildDynamique($target, $type, $fileName = null, $config = null)
|
||||
{
|
||||
return CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the Joomla Version Data
|
||||
*
|
||||
* @return object The version data
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
private function setJoomlaVersionData()
|
||||
{
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dynamic folders
|
||||
*/
|
||||
protected function setDynamicFolders()
|
||||
{
|
||||
// check if we should add the dynamic folder moving script to the installer script
|
||||
if (!CFactory::_('Registry')->get('set_move_folders_install_script'))
|
||||
{
|
||||
// add the setDynamicF0ld3rs() method to the install scipt.php file
|
||||
CFactory::_('Registry')->set('set_move_folders_install_script', true);
|
||||
// set message that this was done (will still add a tutorial link later)
|
||||
$this->app->enqueueMessage(
|
||||
Text::_(
|
||||
'<hr /><h3>Dynamic folder(s) were detected.</h3>'
|
||||
), 'Notice'
|
||||
);
|
||||
$_function = 'setDynamicF0ld3rs';
|
||||
$_script = 'script.php';
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) != 3)
|
||||
{
|
||||
$_function = 'moveFolders';
|
||||
$_script = 'ComponentnameInstallerScript.php';
|
||||
}
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'A method (%s) was added to the install <b>%s</b> of this package to insure that the folder(s) are copied into the correct place when this component is installed!',
|
||||
$_function, $_script
|
||||
), 'Notice'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the index.html file in a folder path
|
||||
*
|
||||
* @param string $path The path to place the index.html file in
|
||||
*
|
||||
* @return void
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.File')->write($path, $root);
|
||||
*
|
||||
*/
|
||||
private function indexHTML($path, $root = 'component')
|
||||
{
|
||||
CFactory::_('Utilities.File')->write($path, $root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update paths with real value
|
||||
*
|
||||
* @param string $path The full path
|
||||
*
|
||||
* @return string The updated path
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Dynamicpath')->update($path);
|
||||
*/
|
||||
protected function updateDynamicPath($path)
|
||||
{
|
||||
return CFactory::_('Utilities.Dynamicpath')->update($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folders with files
|
||||
*
|
||||
* @param string $dir The path to folder to remove
|
||||
* @param boolean $ignore The files and folders to ignore
|
||||
*
|
||||
* @return boolean True if all is removed
|
||||
* @deprecated 3.3 Use CFactory::_('Utilities.Folder')->remove($dir, $ignore);
|
||||
*/
|
||||
protected function removeFolder($dir, $ignore = false)
|
||||
{
|
||||
return CFactory::_('Utilities.Folder')->remove($dir, $ignore);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -1123,15 +1123,6 @@ abstract class ComponentbuilderHelper
|
||||
jimport('joomla.application');
|
||||
}
|
||||
|
||||
/**
|
||||
* The dynamic builder of views, tables and fields
|
||||
**/
|
||||
public static function dynamicBuilder(&$data, $type)
|
||||
{
|
||||
self::autoLoader('extrusion');
|
||||
$extruder = new Extrusion($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert repeatable field to subform
|
||||
*
|
||||
|
@ -1,421 +0,0 @@
|
||||
<?php
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 1.0.0
|
||||
@created 26th December, 2016
|
||||
@package Component Builder
|
||||
@subpackage mapping.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@my wife Roline van der Merwe <http://www.vdm.io/>
|
||||
@copyright Copyright (C) 2015. All Rights Reserved
|
||||
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Builds Complex Joomla Components
|
||||
|
||||
/-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Mapping class
|
||||
*/
|
||||
class Mapping
|
||||
{
|
||||
/**
|
||||
* Some default fields
|
||||
*/
|
||||
protected $buildcompsql;
|
||||
public $id;
|
||||
public $name_code;
|
||||
public $addadmin_views;
|
||||
public $addSql = array();
|
||||
public $source = array();
|
||||
public $sql = array();
|
||||
|
||||
/**
|
||||
* The map of the needed fields and views
|
||||
*/
|
||||
public $map;
|
||||
|
||||
/**
|
||||
* The app to load messages mostly
|
||||
*/
|
||||
public $app;
|
||||
|
||||
/**
|
||||
* The needed set of keys needed to set
|
||||
*/
|
||||
protected $setting = array('id' => 'default', 'buildcompsql' => 'base64', 'name_code' => 'safeString');
|
||||
|
||||
/**
|
||||
* The needed set of keys needed to set
|
||||
*/
|
||||
protected $notRequiered = array('id', 'asset_id', 'published',
|
||||
'created_by', 'modified_by', 'created', 'modified', 'checked_out','checked_out_time',
|
||||
'version', 'hits', 'access', 'ordering',
|
||||
'metakey', 'metadesc', 'metadata', 'params');
|
||||
|
||||
/**
|
||||
* The datatypes and it linked field types (basic)
|
||||
* (TODO) We may need to set this dynamicly
|
||||
*/
|
||||
protected $dataTypes = array( 'VARCHAR' => 'Text', 'CHAR' => 'Text',
|
||||
'MEDIUMTEXT' => 'Textarea', 'LONGTEXT' => 'Textarea',
|
||||
'TEXT' => 'Textarea', 'DATETIME' => 'Calendar',
|
||||
'DATE' => 'Text', 'TIME' => 'Text', 'TINYINT' => 'Text',
|
||||
'BIGINT' => 'Text', 'INT' => 'Text', 'FLOAT' => 'Text',
|
||||
'DECIMAL' => 'Text', 'DOUBLE' => 'Text');
|
||||
|
||||
/**
|
||||
* The datasize identifiers
|
||||
*/
|
||||
protected $dataSize = array(
|
||||
'CHAR', 'VARCHAR', 'INT', 'TINYINT',
|
||||
'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE');
|
||||
|
||||
/**
|
||||
* The default identifiers
|
||||
*/
|
||||
protected $defaults = array(0, 1, "CURRENT_TIMESTAMP", "DATETIME"); // Other
|
||||
|
||||
/**
|
||||
* The sizes identifiers
|
||||
*/
|
||||
protected $sizes = array("1", "7", "10", "11", "50", "64", "100", "255", "1024", "2048"); // Other
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($data = false)
|
||||
{
|
||||
// set the app to insure messages can be set
|
||||
$this->app = Factory::getApplication();
|
||||
// check that we have data
|
||||
if (ArrayHelper::check($data))
|
||||
{
|
||||
// make sure we have an id
|
||||
if (isset($data['id']) && $data['id'] > 0)
|
||||
{
|
||||
if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql']))
|
||||
{
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
if (isset($this->setting[$key]))
|
||||
{
|
||||
switch($this->setting[$key])
|
||||
{
|
||||
case 'base64':
|
||||
// set needed value
|
||||
$this->$key = base64_decode((string) $value);
|
||||
break;
|
||||
case 'json':
|
||||
// set needed value
|
||||
$this->$key = json_decode((string) $value, true);
|
||||
break;
|
||||
case 'safeString':
|
||||
// set needed value
|
||||
$this->$key = StringHelper::check($value);
|
||||
break;
|
||||
default :
|
||||
$this->$key = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// get linked admin views
|
||||
$addadmin_views = GetHelper::var('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views');
|
||||
if (JsonHelper::check($addadmin_views))
|
||||
{
|
||||
$this->addadmin_views = json_decode((string)$addadmin_views, true);
|
||||
}
|
||||
// set the map of the views needed
|
||||
if ($this->setMap())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('No "CREATE TABLE.." were found, please check your sql.'),
|
||||
'Error'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return false; // not set so just return without any error
|
||||
}
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('Please try again, this error usualy happens if it is a new component, beacues we need a component ID to do this build with your sql dump.'),
|
||||
'Error'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('Could not find the data needed to continue.'),
|
||||
'Error'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping function
|
||||
* To Map the views and fields that are needed
|
||||
*/
|
||||
protected function setMap()
|
||||
{
|
||||
// start parsing the sql dump data
|
||||
$queries = JDatabaseDriver::splitSql($this->buildcompsql);
|
||||
if (ArrayHelper::check($queries))
|
||||
{
|
||||
foreach ($queries as $query)
|
||||
{
|
||||
// only use create table queries
|
||||
if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false ||
|
||||
strpos($query, 'CREATE TABLE') !== false)
|
||||
{
|
||||
if ($tableName = $this->getTableName($query))
|
||||
{
|
||||
// now get the fields/columns of this view/table
|
||||
if ($fields = $this->getFields($query))
|
||||
{
|
||||
// make sure it is all lower case from here on
|
||||
$tableName = strtolower($tableName);
|
||||
$this->map[$tableName] = $fields;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// get the insert data if set
|
||||
if (strpos($query, 'INSERT INTO `') !== false)
|
||||
{
|
||||
if ($tableName = $this->getTableName($query))
|
||||
{
|
||||
$this->addSql[$tableName] = 1;
|
||||
$this->source[$tableName] = 2;
|
||||
$this->sql[$tableName] = $query;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if the mapping was done
|
||||
if (ArrayHelper::check($this->map))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table name
|
||||
*/
|
||||
protected function getTableName(&$query)
|
||||
{
|
||||
if (strpos($query, '`#__') !== false)
|
||||
{
|
||||
// get table name
|
||||
$tableName = GetHelper::between($query, '`#__', "`");
|
||||
}
|
||||
elseif (strpos($query, "'#__") !== false)
|
||||
{
|
||||
// get table name
|
||||
$tableName = GetHelper::between($query, "'#__", "'");
|
||||
}
|
||||
// if it still was not found
|
||||
if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName))
|
||||
{
|
||||
// skip this query
|
||||
return false;
|
||||
}
|
||||
// clean the table name (so only view name remain)
|
||||
if (strpos($tableName, $this->name_code) !== false)
|
||||
{
|
||||
$tableName = trim(str_replace($this->name_code, '', $tableName), '_');
|
||||
}
|
||||
// if found
|
||||
if (ComponentbuilderHelper::checkString($tableName))
|
||||
{
|
||||
return $tableName;
|
||||
}
|
||||
// skip this query
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field details
|
||||
*/
|
||||
protected function getFields(&$query)
|
||||
{
|
||||
$rows = array_map('trim', explode(PHP_EOL, $query));
|
||||
$fields = array();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// make sure we have a lower case string
|
||||
$row = strtoupper($row);
|
||||
$field = array();
|
||||
$name = '';
|
||||
if (0 === strpos($row, '`'))
|
||||
{
|
||||
// get field name
|
||||
$name = GetHelper::between($row, '`', '`');
|
||||
}
|
||||
if (0 === strpos($row, "'"))
|
||||
{
|
||||
// get field name
|
||||
$name = GetHelper::between($row, "'", "'");
|
||||
}
|
||||
// check if the name was found
|
||||
if (ComponentbuilderHelper::checkString($name))
|
||||
{
|
||||
// insure we have the name in lower case from here on
|
||||
$name = strtolower($name);
|
||||
// only continue if field is requered
|
||||
if (in_array($name, $this->notRequiered))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// check if the field type is found
|
||||
if ($fieldType = $this->getType($row, $field, $name))
|
||||
{
|
||||
$field['row'] = $row;
|
||||
$field['name'] = $name;
|
||||
$field['label'] = StringHelper::check($name, 'W');
|
||||
$field['fieldType'] = $fieldType;
|
||||
$field['size'] = $this->getSize($row, $field);
|
||||
$field['sizeOther'] = '';
|
||||
if (!in_array($field['size'], $this->sizes))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkString($field['size']))
|
||||
{
|
||||
$field['sizeOther'] = $field['size'];
|
||||
$field['size'] = 'Other';
|
||||
}
|
||||
}
|
||||
$field['default'] = $this->getDefault($row);
|
||||
$field['defaultOther'] = '';
|
||||
if (!in_array($field['default'], $this->defaults))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkString($field['default']))
|
||||
{
|
||||
$field['defaultOther'] = $field['default'];
|
||||
$field['default'] = 'Other';
|
||||
}
|
||||
}
|
||||
$field['null'] = $this->getNullValue($row, $field);
|
||||
// check if field is a key
|
||||
$field['key'] = $this->getKeyStatus($rows, $name);
|
||||
// load to fields
|
||||
$fields[] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ArrayHelper::check($fields))
|
||||
{
|
||||
return $fields;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field types
|
||||
*/
|
||||
protected function getType($row, &$field, &$name)
|
||||
{
|
||||
// first remove field name
|
||||
$row = str_replace($name, '', $row);
|
||||
// get the data type first
|
||||
foreach ($this->dataTypes as $type => $fieldType)
|
||||
{
|
||||
if (strpos($row, $type) !== false)
|
||||
{
|
||||
$field['dataType'] = $type;
|
||||
return $fieldType;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field size
|
||||
*/
|
||||
protected function getSize(&$row, $field)
|
||||
{
|
||||
if (in_array($field['dataType'], $this->dataSize))
|
||||
{
|
||||
return GetHelper::between($row, $field['dataType'].'(', ')');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field default
|
||||
*/
|
||||
protected function getDefault(&$row)
|
||||
{
|
||||
// get default value
|
||||
if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct...
|
||||
{
|
||||
return GetHelper::between($row, 'DEFAULT "', '"');
|
||||
}
|
||||
// get default value
|
||||
if (strpos($row, "DEFAULT '") !== false)
|
||||
{
|
||||
return GetHelper::between($row, "DEFAULT '", "'");
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field Null Value
|
||||
*/
|
||||
protected function getNullValue(&$row, &$field)
|
||||
{
|
||||
// get the result of null
|
||||
if (strpos($row, 'NOT NULL') !== false)
|
||||
{
|
||||
return 'NOT NULL';
|
||||
}
|
||||
if (strpos($row, 'DEFAULT NULL') !== false)
|
||||
{
|
||||
$field['default'] = 'NULL';
|
||||
return '';
|
||||
}
|
||||
return 'NULL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field key status
|
||||
*/
|
||||
protected function getKeyStatus(&$rows, &$name)
|
||||
{
|
||||
// get the data type first
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if (strpos($row, 'UNIQUE KEY ') !== false && stripos($row, $name) !== false)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ((strpos($row, 'PRIMARY KEY ') !== false && stripos($row, $name) !== false) || (strpos($row, 'KEY ') !== false && stripos($row, $name) !== false))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,295 +0,0 @@
|
||||
<?php
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 1.0.0
|
||||
@created 26th December, 2016
|
||||
@package Component Builder
|
||||
@subpackage builder.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@my wife Roline van der Merwe <http://www.vdm.io/>
|
||||
@copyright Copyright (C) 2015. All Rights Reserved
|
||||
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Builds Complex Joomla Components
|
||||
|
||||
/-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
|
||||
/**
|
||||
* Builder class
|
||||
*/
|
||||
class Builder extends Mapping
|
||||
{
|
||||
/**
|
||||
* Some default fields
|
||||
*/
|
||||
public $user;
|
||||
public $today;
|
||||
public $db;
|
||||
public $views = array();
|
||||
public $admin_fields = array();
|
||||
protected $fields = array();
|
||||
protected $title = array();
|
||||
protected $description = array();
|
||||
protected $alias = array();
|
||||
protected $list = array();
|
||||
|
||||
/**
|
||||
* Field that should not be used in name, alias, disc, and list view
|
||||
* (TODO) We may need to set this dynamicly
|
||||
*/
|
||||
protected $avoidList = array('not_required');
|
||||
|
||||
/***
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(&$data)
|
||||
{
|
||||
// first we run the perent constructor
|
||||
if (parent::__construct($data))
|
||||
{
|
||||
// always reset the building values if found
|
||||
$data['buildcomp'] = 0;
|
||||
$data['buildcompsql'] = '';
|
||||
// set some globals
|
||||
$this->db = Factory::getDbo();
|
||||
$this->user = Factory::getUser();
|
||||
$this->today = Factory::getDate()->toSql();
|
||||
|
||||
// no start the building of the views and fields
|
||||
if ($this->setBuild())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The building function
|
||||
* To build the views and fields that are needed
|
||||
*/
|
||||
protected function setBuild()
|
||||
{
|
||||
foreach ($this->map as $view => $fields)
|
||||
{
|
||||
// set this field with all its needed data
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$this->setField($view, $field);
|
||||
}
|
||||
// set this view with all its needed data
|
||||
$this->setView($view);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The building function for views
|
||||
*/
|
||||
protected function setView(&$name)
|
||||
{
|
||||
// set the view object
|
||||
$object = new stdClass();
|
||||
$object->system_name = StringHelper::check($name, 'W') . ' (dynamic build)';
|
||||
$object->name_single = $name;
|
||||
$object->name_list = $name. 's';
|
||||
$object->short_description = $name. ' view (dynamic build)';
|
||||
$object->type = 1;
|
||||
$object->description = $name. ' view (dynamic build)';
|
||||
$object->add_fadein = 1;
|
||||
$object->add_sql = (isset($this->addSql[$name])) ? $this->addSql[$name]: 0;
|
||||
$object->source = (isset($this->source[$name])) ? $this->source[$name]: 0;
|
||||
$object->sql = (isset($this->sql[$name])) ? base64_encode($this->sql[$name]): '';
|
||||
$object->addpermissions = '{"action":["view.edit","view.edit.own","view.edit.state","view.create","view.delete","view.access"],"implementation":["3","3","3","3","3","3"]}';
|
||||
$object->created = $this->today;
|
||||
$object->created_by = $this->user->id;
|
||||
$object->published = 1;
|
||||
// add to data base
|
||||
if ($this->db->insertObject('#__componentbuilder_admin_view', $object))
|
||||
{
|
||||
// make sure the access of asset is set
|
||||
$id = $this->db->insertid();
|
||||
ComponentbuilderHelper::setAsset($id, 'admin_view');
|
||||
// load the views
|
||||
$this->views[] = $id;
|
||||
// load the admin view fields
|
||||
return $this->addFields($name, $id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the fields to the view
|
||||
*/
|
||||
protected function addFields(&$view, &$view_id)
|
||||
{
|
||||
if (isset($this->fields[$view]))
|
||||
{
|
||||
// set some defaults
|
||||
$addField = array ();
|
||||
$fixLink = (isset($this->title[$view])) ? 0 : 1;
|
||||
// build the field data... hmmm
|
||||
foreach ($this->fields[$view] as $nr => $id)
|
||||
{
|
||||
$alignment = 1;
|
||||
if ($nr % 2 == 0)
|
||||
{
|
||||
$alignment = 2;
|
||||
}
|
||||
// some defaults
|
||||
$isTitle = (isset($this->title[$view]) && $this->title[$view] == $id) ? 1 : 0;
|
||||
$isAlias = (isset($this->alias[$view]) && $this->alias[$view] == $id) ? 1 : 0;
|
||||
$isList = ($key = array_search($id, $this->list[$view])) ? 1 : 0;
|
||||
$isLink = ($isTitle) ? 1 : (($isList && $fixLink) ? 1 : 0);
|
||||
if ($isLink)
|
||||
{
|
||||
$fixLink = 0;
|
||||
}
|
||||
// load the field values
|
||||
$addField['addfields'.$nr]['field'] = $id;
|
||||
$addField['addfields'.$nr]['list'] = $isList;
|
||||
$addField['addfields'.$nr]['order_list'] = ($key) ? $key : 0;
|
||||
$addField['addfields'.$nr]['title'] = $isTitle;
|
||||
$addField['addfields'.$nr]['alias'] = $isAlias;
|
||||
$addField['addfields'.$nr]['sort'] = $isList;
|
||||
$addField['addfields'.$nr]['search'] = $isList;
|
||||
$addField['addfields'.$nr]['filter'] = $isList;
|
||||
$addField['addfields'.$nr]['link'] = $isLink;
|
||||
$addField['addfields'.$nr]['tab'] = 1;
|
||||
$addField['addfields'.$nr]['alignment'] = ($isTitle || $isAlias) ? 4 : $alignment;
|
||||
$addField['addfields'.$nr]['order_edit'] = $nr;
|
||||
$addField['addfields'.$nr]['permission'] = 0;
|
||||
}
|
||||
|
||||
// set the field object
|
||||
$object = new stdClass();
|
||||
$object->admin_view = $view_id;
|
||||
$object->addfields = json_encode($addField, JSON_FORCE_OBJECT);
|
||||
$object->created = $this->today;
|
||||
$object->created_by = $this->user->id;
|
||||
$object->published = 1;
|
||||
// add to data base
|
||||
return $this->db->insertObject('#__componentbuilder_admin_fields', $object);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The building function for fields
|
||||
*/
|
||||
protected function setField(&$view, &$field)
|
||||
{
|
||||
if ($fieldType = CFactory::_('Field.Type.Name')->get($field['fieldType']))
|
||||
{
|
||||
// set the field object
|
||||
$object = new stdClass();
|
||||
$object->name = $field['label'] . ' (dynamic build)';
|
||||
$object->fieldtype = $fieldType;
|
||||
$object->datatype = $field['dataType'];
|
||||
$object->indexes = $field['key'];
|
||||
$object->null_switch = $field['null'];
|
||||
$object->datalenght = $field['size'];
|
||||
$object->datalenght_other = $field['sizeOther'];
|
||||
$object->datadefault = $field['default'];
|
||||
$object->datadefault_other = $field['defaultOther'];
|
||||
$object->created = $this->today;
|
||||
$object->created_by = $this->user->id;
|
||||
$object->published = 1;
|
||||
$object->store = 0;
|
||||
$object->xml = $this->setFieldXML($field, $fieldType);
|
||||
// add to data base
|
||||
if ($this->db->insertObject('#__componentbuilder_field', $object))
|
||||
{
|
||||
// make sure the access of asset is set
|
||||
$id = $this->db->insertid();
|
||||
ComponentbuilderHelper::setAsset($id, 'field');
|
||||
// check if any field for this field was already set, if not set array
|
||||
if (!isset($this->fields[$view]))
|
||||
{
|
||||
$this->fields[$view] = array();
|
||||
}
|
||||
// load the field
|
||||
$this->fields[$view][] = $id;
|
||||
|
||||
if (!isset($this->list[$view]))
|
||||
{
|
||||
$this->list[$view] = array();
|
||||
}
|
||||
// insure that some fields are avoided
|
||||
if (!in_array($field['name'], $this->avoidList))
|
||||
{
|
||||
// set the name/title field if found
|
||||
if (!isset($this->title[$view]) && (stripos($field['name'], 'name') !== false || stripos($field['name'], 'title') !== false))
|
||||
{
|
||||
$this->title[$view] = $id;
|
||||
$this->list[$view][] = $id;
|
||||
}
|
||||
// set the alias field if found
|
||||
elseif (!isset($this->alias[$id]) && stripos($field['name'], 'alias') !== false)
|
||||
{
|
||||
$this->alias[$view] = $id;
|
||||
}
|
||||
// set the alias field if found
|
||||
elseif (!isset($this->description[$id]) && stripos($field['name'], 'desc') !== false)
|
||||
{
|
||||
$this->description[$view] = $id;
|
||||
$this->list[$view][] = $id;
|
||||
}
|
||||
elseif ('Text' == $field['fieldType'] && count($this->list[$view]) < 5)
|
||||
{
|
||||
$this->list[$view][] = $id;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the field type id from system
|
||||
*/
|
||||
protected function getFieldType($fieldName)
|
||||
{
|
||||
// load the field settings
|
||||
return GetHelper::var('fieldtype', $fieldName, 'name', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* The building function for field xml
|
||||
*/
|
||||
protected function setFieldXML(&$field, $fieldId)
|
||||
{
|
||||
// load the field settings
|
||||
$settings = array();
|
||||
$settings['name'] = $field['name'];
|
||||
$settings['description'] = 'The '.strtolower($field['label']) . ' is set here.';
|
||||
$settings['message'] = "Error! Please add some ".strtolower($field['label'])." here.";
|
||||
$settings['label'] = $field['label'];
|
||||
$settings['default'] = ($field['default'] == 'Other') ? $field['defaultOther'] : $field['default'];
|
||||
$settings['hint'] = $field['label'] .' Here!';
|
||||
// okay set the xml field values
|
||||
if ($fieldOptions = ComponentbuilderHelper::getFieldTypeProperties($fieldId, 'id', $settings))
|
||||
{
|
||||
return json_encode($fieldOptions['values']);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 1.0.0
|
||||
@created 26th December, 2016
|
||||
@package Component Builder
|
||||
@subpackage extrusion.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@my wife Roline van der Merwe <http://www.vdm.io/>
|
||||
@copyright Copyright (C) 2015. All Rights Reserved
|
||||
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Builds Complex Joomla Components
|
||||
|
||||
/-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Extrusion class
|
||||
*/
|
||||
class Extrusion extends Builder
|
||||
{
|
||||
/***
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(&$data)
|
||||
{
|
||||
// first we run the perent constructor
|
||||
if (parent::__construct($data))
|
||||
{
|
||||
// link the view data to the component
|
||||
if ($this->setAdminViews($data['id']))
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('All the fields and views from your sql dump has been created and linked to this component.'),
|
||||
'Success'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* link the build views to the component
|
||||
*/
|
||||
protected function setAdminViews(&$component_id)
|
||||
{
|
||||
// check if views were set
|
||||
if (ArrayHelper::check($this->views))
|
||||
{
|
||||
$count = 0;
|
||||
if (ArrayHelper::check($this->addadmin_views))
|
||||
{
|
||||
$count = (int) count((array)$this->addadmin_views) + 3;
|
||||
}
|
||||
// set the admin view data linking
|
||||
foreach ($this->views as $nr => $id)
|
||||
{
|
||||
$pointer = $count + $nr;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['adminview'] = $id;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['icomoon'] = 'joomla';
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['mainmenu'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['dashboard_add'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['dashboard_list'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['submenu'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['checkin'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['history'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['metadata'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['access'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['port'] = 1;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['edit_create_site_view'] = 0;
|
||||
$this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1;
|
||||
}
|
||||
}
|
||||
if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views))
|
||||
{
|
||||
// set the field object
|
||||
$object = new stdClass();
|
||||
$object->joomla_component = $component_id;
|
||||
$object->addadmin_views = json_encode($this->addadmin_views, JSON_FORCE_OBJECT);
|
||||
$object->created = $this->today;
|
||||
$object->created_by = $this->user->id;
|
||||
$object->published = 1;
|
||||
// check if it is already set
|
||||
if ($item_id = GetHelper::var('component_admin_views', $component_id, 'joomla_component', 'id'))
|
||||
{
|
||||
// set ID
|
||||
$object->id = (int) $item_id;
|
||||
return $this->db->updateObject('#__componentbuilder_component_admin_views', $object, 'id');
|
||||
}
|
||||
// add to data base
|
||||
return $this->db->insertObject('#__componentbuilder_component_admin_views', $object);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -1,204 +0,0 @@
|
||||
<?php
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.6.x
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage indenter.php
|
||||
@author Llewellyn van der Merwe <http://joomlacomponentbuilder.com>
|
||||
@github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
@copyright Copyright (C) 2015. All Rights Reserved
|
||||
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Builds Complex Joomla Components
|
||||
|
||||
/-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
/**
|
||||
* @link https://github.com/gajus/dindent for the canonical source repository
|
||||
* @license https://github.com/gajus/dindent/blob/master/LICENSE BSD 3-Clause
|
||||
*/
|
||||
class Indenter {
|
||||
private
|
||||
$log = array(),
|
||||
$options = array(
|
||||
'indentation_character' => ' '
|
||||
),
|
||||
$inline_elements = array('b', 'big', 'i', 'small', 'tt', 'abbr', 'acronym', 'cite', 'code', 'dfn', 'em', 'kbd', 'strong', 'samp', 'var', 'a', 'bdo', 'br', 'img', 'span', 'sub', 'sup'),
|
||||
$temporary_replacements_script = array(),
|
||||
$temporary_replacements_inline = array();
|
||||
|
||||
const ELEMENT_TYPE_BLOCK = 0;
|
||||
const ELEMENT_TYPE_INLINE = 1;
|
||||
|
||||
const MATCH_INDENT_NO = 0;
|
||||
const MATCH_INDENT_DECREASE = 1;
|
||||
const MATCH_INDENT_INCREASE = 2;
|
||||
const MATCH_DISCARD = 3;
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct (array $options = array()) {
|
||||
foreach ($options as $name => $value) {
|
||||
if (!array_key_exists($name, $this->options)) {
|
||||
throw new Exception\InvalidArgumentException('Unrecognized option.');
|
||||
}
|
||||
|
||||
$this->options[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $element_name Element name, e.g. "b".
|
||||
* @param ELEMENT_TYPE_BLOCK|ELEMENT_TYPE_INLINE $type
|
||||
* @return null
|
||||
*/
|
||||
public function setElementType ($element_name, $type) {
|
||||
if ($type === static::ELEMENT_TYPE_BLOCK) {
|
||||
$this->inline_elements = array_diff($this->inline_elements, array($element_name));
|
||||
} else if ($type === static::ELEMENT_TYPE_INLINE) {
|
||||
$this->inline_elements[] = $element_name;
|
||||
} else {
|
||||
throw new Exception\InvalidArgumentException('Unrecognized element type.');
|
||||
}
|
||||
|
||||
$this->inline_elements = array_unique($this->inline_elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input HTML input.
|
||||
* @return string Indented HTML.
|
||||
*/
|
||||
public function indent ($input) {
|
||||
$this->log = array();
|
||||
|
||||
// Dindent does not indent <script> body. Instead, it temporary removes it from the code, indents the input, and restores the script body.
|
||||
if (preg_match_all('/<script\b[^>]*>([\s\S]*?)<\/script>/mi', $input, $matches)) {
|
||||
$this->temporary_replacements_script = $matches[0];
|
||||
foreach ($matches[0] as $i => $match) {
|
||||
$input = str_replace($match, '<script>' . ($i + 1) . '</script>', $input);
|
||||
}
|
||||
}
|
||||
|
||||
// Removing double whitespaces to make the source code easier to read.
|
||||
// With exception of <pre>/ CSS white-space changing the default behaviour, double whitespace is meaningless in HTML output.
|
||||
// This reason alone is sufficient not to use Dindent in production.
|
||||
$input = str_replace("\t", '', $input);
|
||||
$input = preg_replace('/\s{2,}/', ' ', $input);
|
||||
|
||||
// Remove inline elements and replace them with text entities.
|
||||
if (preg_match_all('/<(' . implode('|', $this->inline_elements) . ')[^>]*>(?:[^<]*)<\/\1>/', $input, $matches)) {
|
||||
$this->temporary_replacements_inline = $matches[0];
|
||||
foreach ($matches[0] as $i => $match) {
|
||||
$input = str_replace($match, 'ᐃ' . ($i + 1) . 'ᐃ', $input);
|
||||
}
|
||||
}
|
||||
|
||||
$subject = $input;
|
||||
|
||||
$output = '';
|
||||
|
||||
$next_line_indentation_level = 0;
|
||||
|
||||
do {
|
||||
$indentation_level = $next_line_indentation_level;
|
||||
|
||||
$patterns = array(
|
||||
// block tag
|
||||
'/^(<([a-z]+)(?:[^>]*)>(?:[^<]*)<\/(?:\2)>)/' => static::MATCH_INDENT_NO,
|
||||
// DOCTYPE
|
||||
'/^<!([^>]*)>/' => static::MATCH_INDENT_NO,
|
||||
// tag with implied closing
|
||||
'/^<(input|link|meta|base|br|img|hr)([^>]*)>/' => static::MATCH_INDENT_NO,
|
||||
// opening tag
|
||||
'/^<[^\/]([^>]*)>/' => static::MATCH_INDENT_INCREASE,
|
||||
// closing tag
|
||||
'/^<\/([^>]*)>/' => static::MATCH_INDENT_DECREASE,
|
||||
// self-closing tag
|
||||
'/^<(.+)\/>/' => static::MATCH_INDENT_DECREASE,
|
||||
// whitespace
|
||||
'/^(\s+)/' => static::MATCH_DISCARD,
|
||||
// text node
|
||||
'/([^<]+)/' => static::MATCH_INDENT_NO
|
||||
);
|
||||
$rules = array('NO', 'DECREASE', 'INCREASE', 'DISCARD');
|
||||
|
||||
foreach ($patterns as $pattern => $rule) {
|
||||
if ($match = preg_match($pattern, $subject, $matches)) {
|
||||
$this->log[] = array(
|
||||
'rule' => $rules[$rule],
|
||||
'pattern' => $pattern,
|
||||
'subject' => $subject,
|
||||
'match' => $matches[0]
|
||||
);
|
||||
|
||||
$subject = mb_substr($subject, mb_strlen($matches[0]));
|
||||
|
||||
if ($rule === static::MATCH_DISCARD) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($rule === static::MATCH_INDENT_NO) {
|
||||
|
||||
} else if ($rule === static::MATCH_INDENT_DECREASE) {
|
||||
$next_line_indentation_level--;
|
||||
$indentation_level--;
|
||||
} else {
|
||||
$next_line_indentation_level++;
|
||||
}
|
||||
|
||||
if ($indentation_level < 0) {
|
||||
$indentation_level = 0;
|
||||
}
|
||||
|
||||
$output .= str_repeat($this->options['indentation_character'], $indentation_level) . $matches[0] . "\n";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ($match);
|
||||
|
||||
$interpreted_input = '';
|
||||
foreach ($this->log as $e) {
|
||||
$interpreted_input .= $e['match'];
|
||||
}
|
||||
|
||||
if ($interpreted_input !== $input) {
|
||||
throw new Exception\RuntimeException('Did not reproduce the exact input.');
|
||||
}
|
||||
|
||||
$output = preg_replace('/(<(\w+)[^>]*>)\s*(<\/\2>)/', '\\1\\3', $output);
|
||||
|
||||
foreach ($this->temporary_replacements_script as $i => $original) {
|
||||
$output = str_replace('<script>' . ($i + 1) . '</script>', $original, $output);
|
||||
}
|
||||
|
||||
foreach ($this->temporary_replacements_inline as $i => $original) {
|
||||
$output = str_replace('ᐃ' . ($i + 1) . 'ᐃ', $original, $output);
|
||||
}
|
||||
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging utility. Get log for the last indent operation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLog () {
|
||||
return $this->log;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user