Fixed missing placeholder strings for views in compiler

This commit is contained in:
2018-01-19 12:27:47 +02:00
parent a310efaf61
commit e6466474b1
12 changed files with 814 additions and 1524 deletions

View File

@ -65,7 +65,7 @@ class Compiler extends Infusion
{
// to check the compiler speed
$this->time_start = microtime(true);
// first we run the perent constructor
// first we run the perent constructors
if (parent::__construct($config))
{
// set temp directory

View File

@ -375,33 +375,19 @@ class Fields extends Structure
/**
* set the Field set of a view
*
* @param array $view The view data
* @param string $component The component name
* @param array $view The view data
* @param string $component The component name
* @param string $viewName The single view name
* @param string $listViewName The list view name
*
* @return string The fields set in xml
*
*/
public function setFieldSet($view, $component)
public function setFieldSet($view, $component, $viewName, $listViewName)
{
// setup the fieldset of this view
if (isset($view['settings']->fields) && ComponentbuilderHelper::checkArray($view['settings']->fields))
{
// setup the list view and single view name
$listViewName = ComponentbuilderHelper::safeString($view['settings']->name_list);
$viewName = ComponentbuilderHelper::safeString($view['settings']->name_single);
// set some place holder for this view
$this->placeholders['###view###'] = $viewName;
$this->placeholders['###VIEW###'] = strtoupper($viewName);
$this->placeholders['###View###'] = ucfirst($viewName);
$this->placeholders['[[[view]]]'] = $this->placeholders['###view###'];
$this->placeholders['[[[VIEW]]]'] = $this->placeholders['###VIEW###'];
$this->placeholders['[[[View]]]'] = $this->placeholders['###View###'];
$this->placeholders['###views###'] = $listViewName;
$this->placeholders['###VIEWS###'] = strtoupper($listViewName);
$this->placeholders['###Views###'] = ucfirst($listViewName);
$this->placeholders['[[[views]]]'] = $this->placeholders['###views###'];
$this->placeholders['[[[VIEWS]]]'] = $this->placeholders['###VIEWS###'];
$this->placeholders['[[[Views]]]'] = $this->placeholders['###Views###'];
// add metadata to the view
if (isset($view['metadata']) && $view['metadata'])
{
@ -753,8 +739,6 @@ class Fields extends Structure
// count the static field created
$this->fieldCount++;
}
// just to be safe, lets clear the view placeholders
$this->clearFromPlaceHolders('view');
// return the set
return $this->xmlPrettyPrint($XML, 'fieldset');
}

View File

@ -3339,8 +3339,7 @@ class Interpretation extends Fields
$path = '/administrator/components/com_' . $this->fileContentStatic['###component###'] . '/assets/js/' . $view['settings']->code . '.js';
}
// add script to file
$this->fileContentDynamic[$view['settings']->code]['###' . $TARGET . '_JAVASCRIPT_FILE###']
= $this->setPlaceholders($view['settings']->javascript_file, $this->placeholders);
$this->fileContentDynamic[$view['settings']->code]['###' . $TARGET . '_JAVASCRIPT_FILE###'] = $this->setPlaceholders($view['settings']->javascript_file, $this->placeholders);
// add script to view
return PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Add View JavaScript File" . PHP_EOL . "\t\t" . $this->setIncludeLibScript($path);
}
@ -8104,36 +8103,10 @@ class Interpretation extends Fields
$query .= PHP_EOL . "\t\treturn false;";
$query .= PHP_EOL . "\t}";
// set some placeholders just incase
if (!isset($this->placeholders['###view###']) && !isset($this->placeholders['[[[view]]]']))
{
$this->placeholders['###view###'] = $viewName_single;
$this->placeholders['[[[view]]]'] = $viewName_single;
$_viewSet = true;
}
if (!isset($this->placeholders['###views###']) && !isset($this->placeholders['[[[views]]]']))
{
$this->placeholders['###views###'] = $viewName_list;
$this->placeholders['[[[views]]]'] = $viewName_list;
$_viewsSet = true;
}
// add getExImPortHeaders
$query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true,
$query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true,
// set a default script for those with no custom script
PHP_EOL . PHP_EOL . $this->setPlaceholders(ComponentbuilderHelper::getImportScripts('headers'), $this->placeholders));
// remove place holders if not needed (to not be suprized)
if (isset($_viewSet))
{
unset($this->placeholders['###view###']);
unset($this->placeholders['[[[view]]]']);
}
if (isset($_viewsSet))
{
unset($this->placeholders['###views###']);
unset($this->placeholders['[[[views]]]']);
}
}
return $query;
}

View File

@ -236,14 +236,25 @@ class Infusion extends Interpretation
// start dynamic build
foreach ($this->componentData->admin_views as $view)
{
// just to be safe, lets clear the view placeholders
$this->clearFromPlaceHolders('view');
// set the target
$this->target = 'admin';
$this->lang = 'admin';
// set main keys
$viewName_single = ComponentbuilderHelper::safeString($view['settings']->name_single);
$viewName_list = ComponentbuilderHelper::safeString($view['settings']->name_list);
// set single view
if (isset($view['settings']->name_single))
{
$viewName_single = ComponentbuilderHelper::safeString($view['settings']->name_single);
}
// set list view
if (isset($view['settings']->name_list))
{
$viewName_list = ComponentbuilderHelper::safeString($view['settings']->name_list);
}
// set the view placeholders
$this->setViewPlaceholders($view['settings']);
// set site edit view array
if (isset($view['edit_create_site_view']) && $view['edit_create_site_view'])
{
@ -258,36 +269,14 @@ class Infusion extends Interpretation
// set view array
$viewarray[] = "\t\t\t\t'" . $viewName_single . "' => '" . $viewName_list . "'";
// set the view names
if ($view['settings']->name_single != 'null')
if (isset($view['settings']->name_single) && $view['settings']->name_single != 'null')
{
// ###VIEW### <<<DYNAMIC>>>
$viewName_u = ComponentbuilderHelper::safeString($view['settings']->name_single, 'U');
$this->fileContentDynamic[$viewName_single]['###VIEW###'] = $viewName_u;
$this->fileContentDynamic[$viewName_list]['###VIEW###'] = $viewName_u;
// ###View### <<<DYNAMIC>>>
$viewName_f = ComponentbuilderHelper::safeString($view['settings']->name_single, 'F');
$this->fileContentDynamic[$viewName_single]['###View###'] = $viewName_f;
$this->fileContentDynamic[$viewName_list]['###View###'] = $viewName_f;
// ###view### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###view###'] = $viewName_single;
$this->fileContentDynamic[$viewName_list]['###view###'] = $viewName_single;
// set some place holder for the views
$this->placeholders['###view###'] = $viewName_single;
$this->placeholders['###View###'] = $viewName_f;
$this->placeholders['###VIEW###'] = $viewName_u;
$this->placeholders['[[[view]]]'] = $viewName_single;
$this->placeholders['[[[View]]]'] = $viewName_f;
$this->placeholders['[[[VIEW]]]'] = $viewName_u;
// set license per view if needed
$this->setLockLicensePer($viewName_single, $this->target);
$this->setLockLicensePer($viewName_list, $this->target);
// ###FIELDSETS### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###FIELDSETS###'] = $this->setFieldSet($view, $this->fileContentStatic['###component###']);
$this->fileContentDynamic[$viewName_single]['###FIELDSETS###'] = $this->setFieldSet($view, $this->fileContentStatic['###component###'], $viewName_single, $viewName_list);
// ###ACCESSCONTROL### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###ACCESSCONTROL###'] = $this->setFieldSetAccessControl($viewName_single);
@ -391,35 +380,15 @@ class Infusion extends Interpretation
}
}
// set the views names
if ($view['settings']->name_list != 'null')
if (isset($view['settings']->name_list) && $view['settings']->name_list != 'null')
{
$this->lang = 'admin';
// ###VIEWS### <<<DYNAMIC>>>
$viewsName_u = ComponentbuilderHelper::safeString($view['settings']->name_list, 'U');
$this->fileContentDynamic[$viewName_list]['###VIEWS###'] = $viewsName_u;
$this->fileContentDynamic[$viewName_single]['###VIEWS###'] = $viewsName_u;
// ###Views### <<<DYNAMIC>>>
$viewsName_f = ComponentbuilderHelper::safeString($view['settings']->name_list, 'F');
$this->fileContentDynamic[$viewName_list]['###Views###'] = $viewsName_f;
$this->fileContentDynamic[$viewName_single]['###Views###'] = $viewsName_f;
// ###views### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_list]['###views###'] = $viewName_list;
$this->fileContentDynamic[$viewName_single]['###views###'] = $viewName_list;
// ###ICOMOON### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_list]['###ICOMOON###'] = $view['icomoon'];
// set some place holder for the views
$this->placeholders['###views###'] = $viewName_list;
$this->placeholders['###Views###'] = $viewsName_f;
$this->placeholders['###VIEWS###'] = $viewsName_u;
$this->placeholders['[[[views]]]'] = $viewName_list;
$this->placeholders['[[[Views]]]'] = $viewsName_f;
$this->placeholders['[[[VIEWS]]]'] = $viewsName_u;
// set the export/import option
if (isset($view['port']) && $view['port'])
if (isset($view['port']) && $view['port'] || 1 == $view['settings']->add_custom_import)
{
$this->eximportView[$viewName_list] = true;
if (1 == $view['settings']->add_custom_import)
@ -1083,6 +1052,82 @@ class Infusion extends Interpretation
return false;
}
/**
* Set the view place holders to global scope
*
* @param object $view The view settings
*
* @ return void
*/
protected function setViewPlaceholders(&$view)
{
// just to be safe, lets clear previous view placeholders
$this->clearFromPlaceHolders('view');
// ###VIEW### <<<DYNAMIC>>>
if (isset($view->name_single))
{
// set main keys
$viewName_single = ComponentbuilderHelper::safeString($view->name_single);
$viewName_u = ComponentbuilderHelper::safeString($view->name_single, 'U');
$viewName_f = ComponentbuilderHelper::safeString($view->name_single, 'F');
// set some place holder for the views
$this->placeholders['###view###'] = $viewName_single;
$this->placeholders['###View###'] = $viewName_f;
$this->placeholders['###VIEW###'] = $viewName_u;
$this->placeholders['[[[view]]]'] = $viewName_single;
$this->placeholders['[[[View]]]'] = $viewName_f;
$this->placeholders['[[[VIEW]]]'] = $viewName_u;
}
// ###VIEWS### <<<DYNAMIC>>>
if (isset($view->name_list))
{
$viewName_list = ComponentbuilderHelper::safeString($view->name_list);
$viewsName_u = ComponentbuilderHelper::safeString($view->name_list, 'U');
$viewsName_f = ComponentbuilderHelper::safeString($view->name_list, 'F');
// set some place holder for the views
$this->placeholders['###views###'] = $viewName_list;
$this->placeholders['###Views###'] = $viewsName_f;
$this->placeholders['###VIEWS###'] = $viewsName_u;
$this->placeholders['[[[views]]]'] = $viewName_list;
$this->placeholders['[[[Views]]]'] = $viewsName_f;
$this->placeholders['[[[VIEWS]]]'] = $viewsName_u;
}
// ###view### <<<DYNAMIC>>>
if (isset($viewName_single))
{
$this->fileContentDynamic[$viewName_single]['###view###'] = $viewName_single;
$this->fileContentDynamic[$viewName_single]['###VIEW###'] = $viewName_u;
$this->fileContentDynamic[$viewName_single]['###View###'] = $viewName_f;
if (isset($viewName_list))
{
$this->fileContentDynamic[$viewName_list]['###view###'] = $viewName_single;
$this->fileContentDynamic[$viewName_list]['###VIEW###'] = $viewName_u;
$this->fileContentDynamic[$viewName_list]['###View###'] = $viewName_f;
}
}
// ###views### <<<DYNAMIC>>>
if (isset($viewName_list))
{
$this->fileContentDynamic[$viewName_list]['###views###'] = $viewName_list;
$this->fileContentDynamic[$viewName_list]['###VIEWS###'] = $viewsName_u;
$this->fileContentDynamic[$viewName_list]['###Views###'] = $viewsName_f;
if (isset($viewName_single))
{
$this->fileContentDynamic[$viewName_single]['###views###'] = $viewName_list;
$this->fileContentDynamic[$viewName_single]['###VIEWS###'] = $viewsName_u;
$this->fileContentDynamic[$viewName_single]['###Views###'] = $viewsName_f;
}
}
}
/**
* Build the lang values and insert to fiel
*

File diff suppressed because it is too large Load Diff