';";
$addModule[] = "\t\t\t\t\tbreak;";
$addModule[] = "\t\t\t\tcase 'array':";
$addModule[] = "\t\t\t\tcase 'Array':";
$addModule[] = "\t\t\t\t\treturn \$this->setModules[\$position];";
$addModule[] = "\t\t\t\t\tbreak;";
$addModule[] = "\t\t\t\tdefault:";
$addModule[] = "\t\t\t\t\treturn implode(' ', \$this->setModules[\$position]);";
$addModule[] = "\t\t\t\t\tbreak;";
$addModule[] = "\t\t\t\t";
$addModule[] = "\t\t\t}";
$addModule[] = "\t\t}";
$addModule[] = "\t\treturn false;";
$addModule[] = "\t}";
$this->fileContentDynamic[$view['settings']->code]['###' . $TARGET . '_GET_MODULE_JIMPORT###'] = PHP_EOL . "jimport('joomla.application.module.helper');";
return implode(PHP_EOL, $addModule);
}
$this->fileContentDynamic[$view['settings']->code]['###' . $TARGET . '_GET_MODULE_JIMPORT###'] = '';
return '';
}
public function setCustomGetForm(&$view)
{
return '';
}
public function setDocumentCustomPHP(&$view)
{
if ($view['settings']->add_php_document == 1)
{
$view['settings']->php_document = (array) explode(PHP_EOL, $view['settings']->php_document);
if (ComponentbuilderHelper::checkArray($view['settings']->php_document))
{
$_tmp = PHP_EOL . "\t\t" . implode(PHP_EOL . "\t\t", $view['settings']->php_document);
return $this->setPlaceholders($_tmp, $this->placeholders);
}
}
return '';
}
public function setCustomButtons(&$view, $type = 1, $tab = '')
{
// ensure correct target is set
$TARGET = ComponentbuilderHelper::safeString($this->target, 'U');
if (1 == $type || 2 == $type)
{
if (1 == $type)
{
$viewName = $view['settings']->code;
}
if (2 == $type)
{
$viewName = ComponentbuilderHelper::safeString($view['settings']->name_single);
}
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
$this->fileContentDynamic[$viewName]['###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER###'] = '';
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
$this->fileContentDynamic[$viewName]['###' . $TARGET . '_CUSTOM_BUTTONS_METHOD###'] = '';
}
elseif (3 == $type)
{
// set the names
$viewName = ComponentbuilderHelper::safeString($view['settings']->name_single);
$viewsName = ComponentbuilderHelper::safeString($view['settings']->name_list);
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER_LIST###
$this->fileContentDynamic[$viewsName]['###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST###'] = '';
// set the custom buttons ###CUSTOM_BUTTONS_METHOD_LIST###
$this->fileContentDynamic[$viewsName]['###' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST###'] = '';
}
// if site add buttons to view
if ($this->target === 'site')
{
// set the custom buttons ###SITE_TOP_BUTTON###
$this->fileContentDynamic[$viewName]['###SITE_TOP_BUTTON###'] = '';
// set the custom buttons ###SITE_BOTTOM_BUTTON###
$this->fileContentDynamic[$viewName]['###SITE_BOTTOM_BUTTON###'] = '';
// load into place
switch ($view['settings']->button_position)
{
case 1:
// set buttons to top right of the view
$this->fileContentDynamic[$viewName]['###SITE_TOP_BUTTON###'] = '
toolbar->render(); ?>
';
break;
case 2:
// set buttons to top left of the view
$this->fileContentDynamic[$viewName]['###SITE_TOP_BUTTON###'] = 'toolbar->render(); ?>';
break;
case 3:
// set buttons to buttom right of the view
$this->fileContentDynamic[$viewName]['###SITE_BOTTOM_BUTTON###'] = '
toolbar->render(); ?>
';
break;
case 4:
// set buttons to buttom left of the view
$this->fileContentDynamic[$viewName]['###SITE_BOTTOM_BUTTON###'] = 'toolbar->render(); ?>';
break;
case 5:
// set buttons to buttom left of the view
$this->placeholders['[[[SITE_TOOLBAR]]]'] = 'toolbar->render(); ?>';
break;
}
}
// check if custom button should be added
if (isset($view['settings']->add_custom_button) && $view['settings']->add_custom_button == 1)
{
$buttons = array();
$this->onlyFunctionButton = array();
$functionNames = array();
if (isset($view['settings']->custom_buttons) && ComponentbuilderHelper::checkArray($view['settings']->custom_buttons))
{
foreach ($view['settings']->custom_buttons as $custom_button)
{
if (3 !== $type && ($custom_button['target'] != 2 || $this->target === 'site'))
{
// Load to lang
$keyLang = $this->langPrefix . '_' . ComponentbuilderHelper::safeString($custom_button['name'], 'U');
$keyCode = ComponentbuilderHelper::safeString($custom_button['name']);
$this->langContent[$this->lang][$keyLang] = trim($custom_button['name']);
// add cpanel button TODO does not work well on site with permissions
if ($custom_button['target'] == 2)
{
$buttons[] = "\t" . $tab . "\tif (\$this->user->authorise('" . $viewName . "." . $keyCode . "'))";
}
else
{
$buttons[] = "\t" . $tab . "\tif (\$this->canDo->get('" . $viewName . "." . $keyCode . "'))";
}
$buttons[] = "\t" . $tab . "\t{";
$buttons[] = "\t" . $tab . "\t\t//" . $this->setLine(__LINE__) . " add " . $custom_button['name'] . " button.";
$buttons[] = "\t" . $tab . "\t\tJToolBarHelper::custom('" . $viewName . "." . $custom_button['method'] . "', '" . $custom_button['icomoon'] . "', '', '" . $keyLang . "', false);";
$buttons[] = "\t" . $tab . "\t}";
}
// load the list button
elseif (3 == $type && $custom_button['target'] != 1)
{
// Load to lang
$keyLang = $this->langPrefix . '_' . ComponentbuilderHelper::safeString($custom_button['name'], 'U');
$keyCode = ComponentbuilderHelper::safeString($custom_button['name']);
$this->langContent[$this->lang][$keyLang] = trim($custom_button['name']);
// add cpanel button TODO does not work well on site with permissions
if (isset($custom_button['type']) && $custom_button['type'] == 2)
{
if (!isset($this->onlyFunctionButton[$viewsName]))
{
$this->onlyFunctionButton[$viewsName] = array();
}
$this->onlyFunctionButton[$viewsName][] = "\t" . $tab . "if (\$this->user->authorise('" . $viewName . "." . $keyCode . "', 'com_" . $this->fileContentStatic['###component###'] . "'))";
$this->onlyFunctionButton[$viewsName][] = "\t" . $tab . "{";
$this->onlyFunctionButton[$viewsName][] = "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " add " . $custom_button['name'] . " button.";
$this->onlyFunctionButton[$viewsName][] = "\t" . $tab . "\tJToolBarHelper::custom('" . $viewsName . "." . $custom_button['method'] . "', '" . $custom_button['icomoon'] . "', '', '" . $keyLang . "', false);";
$this->onlyFunctionButton[$viewsName][] = "\t" . $tab . "}";
}
else
{
$buttons[] = "\t" . $tab . "\tif (\$this->user->authorise('" . $viewName . "." . $keyCode . "', 'com_" . $this->fileContentStatic['###component###'] . "'))";
$buttons[] = "\t" . $tab . "\t{";
$buttons[] = "\t" . $tab . "\t\t//" . $this->setLine(__LINE__) . " add " . $custom_button['name'] . " button.";
$buttons[] = "\t" . $tab . "\t\tJToolBarHelper::custom('" . $viewsName . "." . $custom_button['method'] . "', '" . $custom_button['icomoon'] . "', '', '" . $keyLang . "', false);";
$buttons[] = "\t" . $tab . "\t}";
}
}
}
}
// load the model and controller
if (3 == $type)
{
// insure the controller and model strings are added
if (isset($view['settings']->php_controller_list) && ComponentbuilderHelper::checkString($view['settings']->php_controller_list) && $view['settings']->php_controller_list != '//')
{
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
$this->fileContentDynamic[$viewsName]['###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST###'] = PHP_EOL . PHP_EOL . $this->setPlaceholders($view['settings']->php_controller_list, $this->placeholders);
}
// load the model
if (isset($view['settings']->php_model_list) && ComponentbuilderHelper::checkString($view['settings']->php_model_list) && $view['settings']->php_model_list != '//')
{
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
$this->fileContentDynamic[$viewsName]['###' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST###'] = PHP_EOL . PHP_EOL . $this->setPlaceholders($view['settings']->php_model_list, $this->placeholders);
}
}
else
{
// insure the controller and model strings are added
if (ComponentbuilderHelper::checkString($view['settings']->php_controller) && $view['settings']->php_controller != '//')
{
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
$this->fileContentDynamic[$viewName]['###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER###'] = PHP_EOL . PHP_EOL . $this->setPlaceholders($view['settings']->php_controller, $this->placeholders);
if ('site' === $this->target)
{
// add the controller for this view
// build the file
$target = array($this->target => $viewName);
$this->buildDynamique($target, 'custom_form');
###GET_FORM_CUSTOM###
}
}
// load the model
if (ComponentbuilderHelper::checkString($view['settings']->php_model) && $view['settings']->php_model != '//')
{
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
$this->fileContentDynamic[$viewName]['###' . $TARGET . '_CUSTOM_BUTTONS_METHOD###'] = PHP_EOL . PHP_EOL . $this->setPlaceholders($view['settings']->php_model, $this->placeholders);
}
}
// return buttons if they were build
if (ComponentbuilderHelper::checkArray($buttons))
{
return PHP_EOL . implode(PHP_EOL, $buttons);
}
}
return '';
}
public function setFunctionOnlyButtons($viewName_list)
{
// return buttons if they were build
if (isset($this->onlyFunctionButton[$viewName_list]) && ComponentbuilderHelper::checkArray($this->onlyFunctionButton[$viewName_list]))
{
return PHP_EOL . implode(PHP_EOL, $this->onlyFunctionButton[$viewName_list]);
}
return '';
}
public function setCustomCSS(&$view)
{
if ($view['settings']->add_css == 1)
{
if (ComponentbuilderHelper::checkString($view['settings']->css))
{
return $this->setPlaceholders($view['settings']->css, $this->placeholders);
}
}
return '';
}
public function setDocumentCustomCSS(&$view)
{
if ($view['settings']->add_css_document == 1)
{
$view['settings']->css_document = (array) explode(PHP_EOL, $view['settings']->css_document);
if (ComponentbuilderHelper::checkArray($view['settings']->css_document))
{
$script = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the Custom CSS script to view" . PHP_EOL . "\t\t" . '$this->document->addStyleDeclaration("';
$cssDocument = PHP_EOL . "\t\t\t" . str_replace('"', '\"', implode(PHP_EOL . "\t\t\t", $view['settings']->css_document));
return $script . $this->setPlaceholders($cssDocument, $this->placeholders) . PHP_EOL . "\t\t" . '");';
}
}
return '';
}
public function setJavaScriptFile(&$view, $TARGET)
{
if ($view['settings']->add_javascript_file == 1 && ComponentbuilderHelper::checkString($view['settings']->javascript_file))
{
// get dates
$created = $this->getCreatedDate($view);
$modified = $this->getLastModifiedDate($view);
// add file to view
$target = array($this->target => $view['settings']->code);
$config = array('###CREATIONDATE###' => $created, '###BUILDDATE###' => $modified, '###VERSION###' => $view['settings']->version);
$this->buildDynamique($target, 'javascript_file', false, $config);
// set path
if ('site' === $this->target)
{
$path = '/components/com_' . $this->fileContentStatic['###component###'] . '/assets/js/' . $view['settings']->code . '.js';
}
else
{
$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);
// 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);
}
return '';
}
public function setDocumentCustomJS(&$view)
{
if ($view['settings']->add_js_document == 1)
{
$view['settings']->js_document = (array) explode(PHP_EOL, $view['settings']->js_document);
if (ComponentbuilderHelper::checkArray($view['settings']->js_document))
{
$script = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the Custom JS script to view" . PHP_EOL . "\t\t" . '$this->document->addScriptDeclaration("';
$jsDocument = PHP_EOL . "\t\t\t" . str_replace('"', '\"', implode(PHP_EOL . "\t\t\t", $view['settings']->js_document));
return $script . $this->setPlaceholders($jsDocument, $this->placeholders) . PHP_EOL . "\t\t" . '");';
}
}
return '';
}
public function setFootableScriptsLoader(&$view)
{
if (isset($this->footableScripts[$this->target][$view['settings']->code]) && $this->footableScripts[$this->target][$view['settings']->code])
{
return $this->setFootableScripts(false);
}
return '';
}
public function setDocumentMetadata(&$view)
{
if ($view['settings']->main_get->gettype == 1 && isset($view['metadata']) && $view['metadata'] == 1)
{
return $this->setMetadataItem();
}
elseif (isset($view['metadata']) && $view['metadata'] == 1)
{
// lets check if we have a custom get method that has the same name as the view
// if we do then it posibly can be that the metadata is loaded via that method
// and we can load the full metadata structure with its vars
if (isset($view['settings']->custom_get) && ComponentbuilderHelper::checkArray($view['settings']->custom_get))
{
$found = false;
$searchFor = 'get' . $view['settings']->Code;
foreach ($view['settings']->custom_get as $custom_get)
{
if ($searchFor == $custom_get->getcustom)
{
$found = true;
break;
}
}
// now lets see
if ($found)
{
return $this->setMetadataItem($view['settings']->code);
}
else
{
return $this->setMetadataList();
}
}
else
{
return $this->setMetadataList();
}
}
return '';
}
public function setMetadataItem($item = 'item')
{
$meta = array();
$meta[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " load the meta description";
$meta[] = "\t\tif (isset(\$this->" . $item . "->metadesc) && \$this->" . $item . "->metadesc)";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setDescription(\$this->" . $item . "->metadesc);";
$meta[] = "\t\t}";
$meta[] = "\t\telseif (\$this->params->get('menu-meta_description'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " load the key words if set";
$meta[] = "\t\tif (isset(\$this->" . $item . "->metakey) && \$this->" . $item . "->metakey)";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('keywords', \$this->" . $item . "->metakey);";
$meta[] = "\t\t}";
$meta[] = "\t\telseif (\$this->params->get('menu-meta_keywords'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " check the robot params";
$meta[] = "\t\tif (isset(\$this->" . $item . "->robots) && \$this->" . $item . "->robots)";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('robots', \$this->" . $item . "->robots);";
$meta[] = "\t\t}";
$meta[] = "\t\telseif (\$this->params->get('robots'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('robots', \$this->params->get('robots'));";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " check if autor is to be set";
$meta[] = "\t\tif (isset(\$this->" . $item . "->created_by) && \$this->params->get('MetaAuthor') == '1')";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetaData('author', \$this->" . $item . "->created_by);";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " check if metadata is available";
$meta[] = "\t\tif (isset(\$this->" . $item . "->metadata) && \$this->" . $item . "->metadata)";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$mdata = json_decode(\$this->" . $item . "->metadata,true);";
$meta[] = "\t\t\tforeach (\$mdata as \$k => \$v)";
$meta[] = "\t\t\t{";
$meta[] = "\t\t\t\tif (\$v)";
$meta[] = "\t\t\t\t{";
$meta[] = "\t\t\t\t\t\$this->document->setMetadata(\$k, \$v);";
$meta[] = "\t\t\t\t}";
$meta[] = "\t\t\t}";
$meta[] = "\t\t}";
return implode(PHP_EOL, $meta);
}
public function setMetadataList()
{
$meta = array();
$meta[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " load the meta description";
$meta[] = "\t\tif (\$this->params->get('menu-meta_description'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setDescription(\$this->params->get('menu-meta_description'));";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " load the key words if set";
$meta[] = "\t\tif (\$this->params->get('menu-meta_keywords'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));";
$meta[] = "\t\t}";
$meta[] = "\t\t//" . $this->setLine(__LINE__) . " check the robot params";
$meta[] = "\t\tif (\$this->params->get('robots'))";
$meta[] = "\t\t{";
$meta[] = "\t\t\t\$this->document->setMetadata('robots', \$this->params->get('robots'));";
$meta[] = "\t\t}";
return implode(PHP_EOL, $meta);
}
public function setGoogleChartLoader(&$view)
{
if (isset($this->googleChart[$this->target][$view['settings']->code]) && $this->googleChart[$this->target][$view['settings']->code])
{
$chart = array();
$chart[] = PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " add the google chart builder class.";
$chart[] = "\t\trequire_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php';";
$chart[] = "\t\t//" . $this->setLine(__LINE__) . " load the google chart js.";
$chart[] = "\t\t\$this->document->addScript(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/js/google.jsapi.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
$chart[] = "\t\t\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
$chart[] = "\t\t\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
return implode(PHP_EOL, $chart);
}
return '';
}
public function setLibrariesLoader($view)
{
// reset bucket
$setter = '';
// allways load these in
$setter .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " always make sure jquery is loaded.";
$setter .= PHP_EOL . "\t\tJHtml::_('jquery.framework');";
$setter .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Load the header checker class.";
if ($this->target === 'site')
{
$setter .= PHP_EOL . "\t\trequire_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );";
}
else
{
$setter .= PHP_EOL . "\t\trequire_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );";
}
$setter .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Initialize the header checker.";
$setter .= PHP_EOL . "\t\t\$HeaderCheck = new " . $this->fileContentStatic['###component###'] . "HeaderCheck;";
// check if this view should get libraries
if (isset($this->libManager[$this->target][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->libManager[$this->target][$view['settings']->code]))
{
foreach ($this->libManager[$this->target][$view['settings']->code] as $id => $true)
{
if (isset($this->libraries[$id]) && ComponentbuilderHelper::checkObject($this->libraries[$id]) && isset($this->libraries[$id]->document) && ComponentbuilderHelper::checkString($this->libraries[$id]->document))
{
$setter .= PHP_EOL . PHP_EOL . $this->setPlaceholders(
str_replace('$document->', '$this->document->', $this->libraries[$id]->document), $this->placeholders);
}
elseif (isset($this->libraries[$id]) && ComponentbuilderHelper::checkObject($this->libraries[$id]) && isset($this->libraries[$id]->how))
{
$setter .= $this->setLibraryDocument($id);
}
}
}
return $setter;
}
protected function setLibraryDocument($id)
{
if (2 == $this->libraries[$id]->how && isset($this->libraries[$id]->conditions) && ComponentbuilderHelper::checkArray($this->libraries[$id]->conditions))
{
// build document with the conditions values
$this->setLibraryDocConditions($id, $this->setLibraryScripts($id, false));
}
elseif (1 == $this->libraries[$id]->how)
{
// build document to allways add all files and urls
$this->setLibraryScripts($id);
}
// check if the document was build
if (isset($this->libraries[$id]->document) && ComponentbuilderHelper::checkString($this->libraries[$id]->document))
{
return PHP_EOL . PHP_EOL . $this->libraries[$id]->document;
}
return '';
}
protected function setLibraryDocConditions($id, $scripts)
{
$document = '';
// Start script builder for library files
if (!isset($this->libwarning[$id]))
{
$this->app->enqueueMessage(JText::sprintf('The conditional script builder for %s is not ready, sorry!', $this->libraries[$id]->name), 'warning');
// set the warning only once
$this->libwarning[$id] = true;
}
// if there was any code added to document then set globaly
if (ComponentbuilderHelper::checkString($document))
{
$this->libraries[$id]->document = $document;
}
}
protected function setLibraryScripts($id, $buildDoc = true)
{
$scripts = array();
// load the urls if found
if (isset($this->libraries[$id]->urls) && ComponentbuilderHelper::checkArray($this->libraries[$id]->urls))
{
// set all the files
foreach ($this->libraries[$id]->urls as $url)
{
// if local path is set, then use it first
if (isset($url['path']))
{
// update the root path
$path = $this->getScriptRootPath($url['path']);
// load document script
$scripts[md5($url['path'])] = $this->setIncludeLibScript($path);
// load url also if not building document
if (!$buildDoc)
{
// load document script
$scripts[md5($url['url'])] = $this->setIncludeLibScript($url['url'], false);
}
}
else
{
// load document script
$scripts[md5($url['url'])] = $this->setIncludeLibScript($url['url'], false);
}
}
}
// load the local files if found
if (isset($this->libraries[$id]->files) && ComponentbuilderHelper::checkArray($this->libraries[$id]->files))
{
// set all the files
foreach ($this->libraries[$id]->files as $file)
{
$path = '/' . trim($file['path'], '/');
// check if path has new file name (has extetion)
$pathInfo = pathinfo($path);
// update the root path
$_path = $this->getScriptRootPath($path);
if (isset($pathInfo['extension']) && $pathInfo['extension'])
{
// load document script
$scripts[md5($path)] = $this->setIncludeLibScript($_path, false, $pathInfo);
}
else
{
// load document script
$scripts[md5($path . '/' . trim($file['file'], '/'))] = $this->setIncludeLibScript($_path . '/' . trim($file['file'], '/'));
}
}
}
// load the local folders if found
if (isset($this->libraries[$id]->folders) && ComponentbuilderHelper::checkArray($this->libraries[$id]->folders))
{
// get all the file paths
foreach ($this->libraries[$id]->folders as $folder)
{
if (isset($folder['path']) && isset($folder['folder']))
{
$path = '/' . trim($folder['path'], '/');
if (isset($folder['rename']) && 1 == $folder['rename'])
{
if ($_paths = ComponentbuilderHelper::getAllFilePaths($this->componentPath . $path))
{
$files[$path] = $_paths;
}
}
else
{
$path = $path . '/' . trim($folder['folder'], '/');
if ($_paths = ComponentbuilderHelper::getAllFilePaths($this->componentPath . $path))
{
$files[$path] = $_paths;
}
}
}
}
// now load the script
foreach ($files as $root => $paths)
{
// update the root path
$_root = $this->getScriptRootPath($root);
// load per path
foreach ($paths as $path)
{
$scripts[md5($root . '/' . trim($path, '/'))] = $this->setIncludeLibScript($_root . '/' . trim($path, '/'));
}
}
}
// if there was any code added to document then set globaly
if ($buildDoc && ComponentbuilderHelper::checkArray($scripts))
{
$this->libraries[$id]->document = "\t\t//" . $this->setLine(__LINE__) . " always load these files." . PHP_EOL . "\t\t" . implode(PHP_EOL . "\t\t", $scripts);
// success
return true;
}
elseif (ComponentbuilderHelper::checkArray($scripts))
{
return $scripts;
}
return false;
}
protected function setIncludeLibScript($path, $local = true, $pathInfo = false)
{
// insure we have the path info
if (!$pathInfo)
{
$pathInfo = pathinfo($path);
}
// set the local string
$JURI = '';
if ($local)
{
$JURI = 'JURI::root(true) . ';
}
// use the path info to build the script
if (isset($pathInfo['extension']) && $pathInfo['extension'])
{
switch ($pathInfo['extension'])
{
case 'js':
return '$this->document->addScript(' . $JURI . '"' . $path . '", (' . $this->fileContentStatic['###Component###'] . 'Helper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/javascript");';
break;
case 'css':
case 'less':
return '$this->document->addStyleSheet(' . $JURI . '"' . $path . '", (' . $this->fileContentStatic['###Component###'] . 'Helper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/css");';
break;
case 'php':
if (strpos($path, 'http') === false)
{
return 'require_once("' . $path . '");';
}
break;
}
}
return '';
}
protected function getScriptRootPath($root)
{
if (strpos($root, '/media/') !== false && strpos($root, '/admin/') === false && strpos($root, '/site/') === false)
{
return str_replace('/media/', '/media/com_' . $this->fileContentStatic['###component###'] . '/', $root);
}
elseif (strpos($root, '/media/') === false && strpos($root, '/admin/') !== false && strpos($root, '/site/') === false)
{
return str_replace('/admin/', '/administrator/components/com_' . $this->fileContentStatic['###component###'] . '/', $root);
}
elseif (strpos($root, '/media/') === false && strpos($root, '/admin/') === false && strpos($root, '/site/') !== false)
{
return str_replace('/site/', '/components/com_' . $this->fileContentStatic['###component###'] . '/', $root);
}
return $root;
}
public function setUikitLoader(&$view)
{
// reset setter
$setter = '';
// load the defaults needed
if ($this->uikit > 0)
{
$setter .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Load uikit options.";
$setter .= PHP_EOL . "\t\t\$uikit = \$this->params->get('uikit_load');";
$setter .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set script size.";
$setter .= PHP_EOL . "\t\t\$size = \$this->params->get('uikit_min');";
$tabV = "";
// if both versions should be loaded then add some more logic
if (2 == $this->uikit)
{
$setter .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Load uikit version.";
$setter .= PHP_EOL . "\t\t\$uikitVersion = \$this->params->get('uikit_version', 2);";
$setter .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Use Uikit Version 2";
$setter .= PHP_EOL . "\t\tif (2 == \$uikitVersion)";
$setter .= PHP_EOL . "\t\t{";
$tabV = "\t";
}
}
// load the defaults needed
if (2 == $this->uikit || 1 == $this->uikit)
{
$setter .= PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " Set css style.";
$setter .= PHP_EOL . $tabV . "\t\t\$style = \$this->params->get('uikit_style');";
$setter .= PHP_EOL . PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " The uikit css.";
$setter .= PHP_EOL . $tabV . "\t\tif ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/css/uikit'.\$style.\$size.'.css', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
$setter .= PHP_EOL . $tabV . "\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " The uikit js.";
$setter .= PHP_EOL . $tabV . "\t\tif ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/js/uikit'.\$size.'.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
$setter .= PHP_EOL . $tabV . "\t\t}";
}
// load the components need
if ((2 == $this->uikit || 1 == $this->uikit) && isset($this->uikitComp[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->uikitComp[$view['settings']->code]))
{
$setter .= PHP_EOL . PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " Load the script to find all uikit components needed.";
$setter .= PHP_EOL . $tabV . "\t\tif (\$uikit != 2)";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " Set the default uikit components in this view.";
$setter .= PHP_EOL . $tabV . "\t\t\t\$uikitComp = array();";
foreach ($this->uikitComp[$view['settings']->code] as $class)
{
$setter .= PHP_EOL . $tabV . "\t\t\t\$uikitComp[] = '" . $class . "';";
}
// check content for more needed components
if (isset($this->siteFieldData['uikit'][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->siteFieldData['uikit'][$view['settings']->code]))
{
$setter .= PHP_EOL . PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " Get field uikit components needed in this view.";
$setter .= PHP_EOL . $tabV . "\t\t\t\$uikitFieldComp = \$this->get('UikitComp');";
$setter .= PHP_EOL . $tabV . "\t\t\tif (isset(\$uikitFieldComp) && " . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$uikitFieldComp))";
$setter .= PHP_EOL . $tabV . "\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\tif (isset(\$uikitComp) && " . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL . $tabV . "\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\$uikitComp = array_merge(\$uikitComp, \$uikitFieldComp);";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\$uikitComp = array_unique(\$uikitComp);";
$setter .= PHP_EOL . $tabV . "\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t\telse";
$setter .= PHP_EOL . $tabV . "\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\$uikitComp = \$uikitFieldComp;";
$setter .= PHP_EOL . $tabV . "\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t}";
}
$setter .= PHP_EOL . $tabV . "\t\t}";
$setter .= PHP_EOL . PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " Load the needed uikit components in this view.";
$setter .= PHP_EOL . $tabV . "\t\tif (\$uikit != 2 && isset(\$uikitComp) && " . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " load just in case.";
$setter .= PHP_EOL . $tabV . "\t\t\tjimport('joomla.filesystem.file');";
$setter .= PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " loading...";
$setter .= PHP_EOL . $tabV . "\t\t\tforeach (\$uikitComp as \$class)";
$setter .= PHP_EOL . $tabV . "\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\tforeach (" . $this->fileContentStatic['###Component###'] . "Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL . $tabV . "\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t//" . $this->setLine(__LINE__) . " check if the CSS file exists.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t//" . $this->setLine(__LINE__) . " load the css.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t//" . $this->setLine(__LINE__) . " check if the JavaScript file exists.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t//" . $this->setLine(__LINE__) . " load the js.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/js/components/'.\$name.\$size.'.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t}";
}
elseif ((2 == $this->uikit || 1 == $this->uikit) && isset($this->siteFieldData['uikit'][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->siteFieldData['uikit'][$view['settings']->code]))
{
$setter .= PHP_EOL . PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " Load the needed uikit components in this view.";
$setter .= PHP_EOL . $tabV . "\t\t\$uikitComp = \$this->get('UikitComp');";
$setter .= PHP_EOL . $tabV . "\t\tif (\$uikit != 2 && isset(\$uikitComp) && " . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " load just in case.";
$setter .= PHP_EOL . $tabV . "\t\t\tjimport('joomla.filesystem.file');";
$setter .= PHP_EOL . $tabV . "\t\t\t//" . $this->setLine(__LINE__) . " loading...";
$setter .= PHP_EOL . $tabV . "\t\t\tforeach (\$uikitComp as \$class)";
$setter .= PHP_EOL . $tabV . "\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\tforeach (" . $this->fileContentStatic['###Component###'] . "Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL . $tabV . "\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t//" . $this->setLine(__LINE__) . " check if the CSS file exists.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t//" . $this->setLine(__LINE__) . " load the css.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t//" . $this->setLine(__LINE__) . " check if the JavaScript file exists.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t//" . $this->setLine(__LINE__) . " load the js.";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v2/js/components/'.\$name.\$size.'.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);";
$setter .= PHP_EOL . $tabV . "\t\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t}";
}
// now set the version 3
if (2 == $this->uikit || 3 == $this->uikit)
{
if (2 == $this->uikit)
{
$setter .= PHP_EOL . "\t\t}";
$setter .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Use Uikit Version 3";
$setter .= PHP_EOL . "\t\telseif (3 == \$uikitVersion)";
$setter .= PHP_EOL . "\t\t{";
}
// add version 3 fiels to page
$setter .= PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " The uikit css.";
$setter .= PHP_EOL . $tabV . "\t\tif ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v3/css/uikit'.\$size.'.css', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
$setter .= PHP_EOL . $tabV . "\t\t}";
$setter .= PHP_EOL . $tabV . "\t\t//" . $this->setLine(__LINE__) . " The uikit js.";
$setter .= PHP_EOL . $tabV . "\t\tif ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . "\t\t{";
$setter .= PHP_EOL . $tabV . "\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_" . $this->fileContentStatic['###component###'] . "/uikit-v3/js/uikit'.\$size.'.js', (" . $this->fileContentStatic['###Component###'] . "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
$setter .= PHP_EOL . $tabV . "\t\t}";
if (2 == $this->uikit)
{
$setter .= PHP_EOL . "\t\t}";
}
}
return $setter;
}
public function setCustomViewExtraDisplayMethods(&$view)
{
if ($view['settings']->add_php_jview == 1)
{
return PHP_EOL . PHP_EOL . $this->setPlaceholders($view['settings']->php_jview, $this->placeholders);
}
return '';
}
public function setCustomViewBody(&$view)
{
if (ComponentbuilderHelper::checkString($view['settings']->default))
{
if ($view['settings']->main_get->gettype == 2 && $view['settings']->main_get->pagination == 1)
{
// build body
$body = array();
// add limit box
if (strpos($view['settings']->default, '[[[LIMITBOX]]]') !== false)
{
$this->placeholders['[[[LIMITBOX]]]'] = 'pagination->getLimitBox(); ?>';
}
$body[] = $this->setPlaceholders($view['settings']->default, $this->placeholders);
$body[] = PHP_EOL . 'items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>';
$body[] = '';
$body[] = '';
return implode(PHP_EOL, $body);
}
else
{
return PHP_EOL . $this->setPlaceholders($view['settings']->default, $this->placeholders);
}
}
return '';
}
public function setCustomViewSubmitButtonScript(&$view)
{
if (ComponentbuilderHelper::checkString($view['settings']->default))
{
// add the script only if there is none set
if (strpos($view['settings']->default, 'Joomla.submitbutton = function(task)') === false)
{
$script = array();
$script[] = PHP_EOL . "";
return implode(PHP_EOL, $script);
}
}
return '';
}
public function setCustomViewCodeBody(&$view)
{
if ($view['settings']->add_php_view == 1)
{
$view['settings']->php_view = (array) explode(PHP_EOL, $view['settings']->php_view);
if (ComponentbuilderHelper::checkArray($view['settings']->php_view))
{
$_tmp = PHP_EOL . PHP_EOL . implode(PHP_EOL, $view['settings']->php_view);
return $this->setPlaceholders($_tmp, $this->placeholders);
}
}
return '';
}
public function setCustomViewTemplateBody(&$view)
{
if (isset($this->templateData[$this->target][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->templateData[$this->target][$view['settings']->code]))
{
$created = $this->getCreatedDate($view);
$modified = $this->getLastModifiedDate($view);
foreach ($this->templateData[$this->target][$view['settings']->code] as $template => $data)
{
// build the file
$target = array($this->target => $view['settings']->code);
$config = array('###CREATIONDATE###' => $created, '###BUILDDATE###' => $modified, '###VERSION###' => $view['settings']->version);
$this->buildDynamique($target, 'template', $template, $config);
// set the file data
$TARGET = ComponentbuilderHelper::safeString($this->target, 'U');
// ###SITE_TEMPLATE_BODY### <<>>
$this->fileContentDynamic[$view['settings']->code . '_' . $template]['###' . $TARGET . '_TEMPLATE_BODY###'] = PHP_EOL . $this->setPlaceholders($data['html'], $this->placeholders);
// ###SITE_TEMPLATE_CODE_BODY### <<>>
$this->fileContentDynamic[$view['settings']->code . '_' . $template]['###' . $TARGET . '_TEMPLATE_CODE_BODY###'] = $this->setCustomViewTemplateCode($data['php_view']);
}
}
}
public function setCustomViewTemplateCode(&$php)
{
if (ComponentbuilderHelper::checkString($php))
{
$php_view = (array) explode(PHP_EOL, $php);
if (ComponentbuilderHelper::checkArray($php_view))
{
$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
return $this->setPlaceholders($php_view, $this->placeholders);
}
}
return '';
}
public function setCustomViewLayouts()
{
if (isset($this->layoutData[$this->target]) && ComponentbuilderHelper::checkArray($this->layoutData[$this->target]))
{
foreach ($this->layoutData[$this->target] as $layout => $data)
{
// build the file
$target = array($this->target => $layout);
$this->buildDynamique($target, 'layout');
// set the file data
$TARGET = ComponentbuilderHelper::safeString($this->target, 'U');
// ###SITE_LAYOUT_CODE### <<>>
$php_view = (array) explode(PHP_EOL, $data['php_view']);
if (ComponentbuilderHelper::checkArray($php_view))
{
$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
$this->fileContentDynamic[$layout]['###' . $TARGET . '_LAYOUT_CODE###'] = $this->setPlaceholders($php_view, $this->placeholders);
}
else
{
$this->fileContentDynamic[$layout]['###' . $TARGET . '_LAYOUT_CODE###'] = '';
}
// ###SITE_LAYOUT_BODY### <<>>
$this->fileContentDynamic[$layout]['###' . $TARGET . '_LAYOUT_BODY###'] = PHP_EOL . $this->setPlaceholders($data['html'], $this->placeholders);
}
}
}
public function getReplacementNames()
{
foreach ($this->newFiles as $type => $files)
{
foreach ($files as $view => $file)
{
if (isset($file['path']) && ComponentbuilderHelper::checkArray($file))
{
if (JFile::exists($file['path']))
{
$string = ComponentbuilderHelper::getFileContents($file['path']);
$buket['static'][] = $this->getInbetweenStrings($string);
}
}
elseif (ComponentbuilderHelper::checkArray($file))
{
foreach ($file as $nr => $doc)
{
if (ComponentbuilderHelper::checkArray($doc))
{
if (JFile::exists($doc['path']))
{
$string = ComponentbuilderHelper::getFileContents($doc['path']);
$buket[$view][] = $this->getInbetweenStrings($string);
}
}
}
}
}
}
foreach ($buket as $type => $array)
{
foreach ($array as $replacments)
{
$replacments = array_unique($replacments);
foreach ($replacments as $replacment)
{
if ($type !== 'static')
{
//var_dump($replacment); echo PHP_EOL;
$echos[$replacment] = "###" . $replacment . "### ";
}
elseif ($type === 'static')
{
//var_dump($replacment); echo PHP_EOL;
$echos[$replacment] = "###" . $replacment . "### ";
}
}
}
}
foreach ($echos as $echo)
{
echo $echo . ' ';
}
}
public function setMethodGetItem(&$view)
{
$script = '';
// go from json to array
if (isset($this->jsonItemBuilder[$view]) && ComponentbuilderHelper::checkArray($this->jsonItemBuilder[$view]))
{
foreach ($this->jsonItemBuilder[$view] as $jsonItem)
{
$script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $jsonItem . "))";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Convert the " . $jsonItem . " field to an array.";
$script .= PHP_EOL . "\t\t\t\t\$" . $jsonItem . " = new Registry;";
$script .= PHP_EOL . "\t\t\t\t\$" . $jsonItem . "->loadString(\$item->" . $jsonItem . ");";
$script .= PHP_EOL . "\t\t\t\t\$item->" . $jsonItem . " = \$" . $jsonItem . "->toArray();";
$script .= PHP_EOL . "\t\t\t}";
}
}
// go from json to string
if (isset($this->jsonStringBuilder[$view]) && ComponentbuilderHelper::checkArray($this->jsonStringBuilder[$view]))
{
$makeArray = '';
foreach ($this->jsonStringBuilder[$view] as $jsonString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $jsonString . "))";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " JSON Decode " . $jsonString . ".";
if (isset($this->jsonItemBuilderArray[$view]) && ComponentbuilderHelper::checkArray($this->jsonItemBuilderArray[$view]) && in_array($jsonString, $this->jsonItemBuilderArray[$view]))
{
$makeArray = ',true';
}
elseif (strpos($jsonString, 'group') !== false)
{
$makeArray = ',true';
}
$script .= PHP_EOL . "\t\t\t\t\$item->" . $jsonString . " = json_decode(\$item->" . $jsonString . $makeArray . ");";
$script .= PHP_EOL . "\t\t\t}";
}
}
// go from base64 to string
if (isset($this->base64Builder[$view]) && ComponentbuilderHelper::checkArray($this->base64Builder[$view]))
{
foreach ($this->base64Builder[$view] as $baseString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $baseString . "))"; // TODO && base64_encode(base64_decode(\$item->".$baseString.", true)) === \$item->".$baseString.")";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " base64 Decode " . $baseString . ".";
$script .= PHP_EOL . "\t\t\t\t\$item->" . $baseString . " = base64_decode(\$item->" . $baseString . ");";
$script .= PHP_EOL . "\t\t\t}";
}
}
// get the component name
$Component = $this->fileContentStatic['###Component###'];
// decryption
foreach ($this->cryptionTypes as $cryptionType)
{
if (isset($this->{$cryptionType . 'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType . 'EncryptionBuilder'}[$view]))
{
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the " . $cryptionType . " encryption.";
$script .= PHP_EOL . "\t\t\t\$" . $cryptionType . "key = " . $Component . "Helper::getCryptKey('" . $cryptionType . "');";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the encryption object.";
$script .= PHP_EOL . "\t\t\t\$" . $cryptionType . " = new FOFEncryptAes(\$" . $cryptionType . "key);";
foreach ($this->{$cryptionType . 'EncryptionBuilder'}[$view] as $baseString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $baseString . ") && \$" . $cryptionType . "key && !is_numeric(\$item->" . $baseString . ") && \$item->" . $baseString . " === base64_encode(base64_decode(\$item->" . $baseString . ", true)))";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " " . $cryptionType . " decrypt data " . $baseString . ".";
$script .= PHP_EOL . "\t\t\t\t\$item->" . $baseString . " = rtrim(\$" . $cryptionType . "->decryptString(\$item->" . $baseString . "), " . '"\0"' . ");";
$script .= PHP_EOL . "\t\t\t}";
}
}
}
// add custom php to getitem method
$script .= $this->getCustomScriptBuilder('php_getitem', $view, PHP_EOL . PHP_EOL);
return $script;
}
public function setCheckboxSave(&$view)
{
$script = '';
if (isset($this->checkboxBuilder[$view]) && ComponentbuilderHelper::checkArray($this->checkboxBuilder[$view]))
{
foreach ($this->checkboxBuilder[$view] as $checkbox)
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the empty " . $checkbox . " item to data";
$script .= PHP_EOL . "\t\tif (!isset(\$data['" . $checkbox . "']))";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t\$data['" . $checkbox . "'] = '';";
$script .= PHP_EOL . "\t\t}";
}
}
return $script;
}
public function setMethodItemSave(&$view)
{
$script = '';
// check if there was script added before modeling of data
$script .= $this->getCustomScriptBuilder('php_before_save', $view, PHP_EOL . PHP_EOL);
// turn array into JSON string
if (isset($this->jsonItemBuilder[$view]) && ComponentbuilderHelper::checkArray($this->jsonItemBuilder[$view]))
{
foreach ($this->jsonItemBuilder[$view] as $jsonItem)
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the " . $jsonItem . " items to data.";
$script .= PHP_EOL . "\t\tif (isset(\$data['" . $jsonItem . "']) && is_array(\$data['" . $jsonItem . "']))";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t\$" . $jsonItem . " = new JRegistry;";
$script .= PHP_EOL . "\t\t\t\$" . $jsonItem . "->loadArray(\$data['" . $jsonItem . "']);";
$script .= PHP_EOL . "\t\t\t\$data['" . $jsonItem . "'] = (string) \$" . $jsonItem . ";";
$script .= PHP_EOL . "\t\t}";
$script .= PHP_EOL . "\t\telseif (!isset(\$data['" . $jsonItem . "']))";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Set the empty " . $jsonItem . " to data";
$script .= PHP_EOL . "\t\t\t\$data['" . $jsonItem . "'] = '';";
$script .= PHP_EOL . "\t\t}";
}
}
// turn string into json string
if (isset($this->jsonStringBuilder[$view]) && ComponentbuilderHelper::checkArray($this->jsonStringBuilder[$view]))
{
foreach ($this->jsonStringBuilder[$view] as $jsonString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the " . $jsonString . " string to JSON string.";
$script .= PHP_EOL . "\t\tif (isset(\$data['" . $jsonString . "']))";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t\$data['" . $jsonString . "'] = (string) json_encode(\$data['" . $jsonString . "']);";
$script .= PHP_EOL . "\t\t}";
}
}
// turn string into base 64 string
if (isset($this->base64Builder[$view]) && ComponentbuilderHelper::checkArray($this->base64Builder[$view]))
{
foreach ($this->base64Builder[$view] as $baseString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Set the " . $baseString . " string to base64 string.";
$script .= PHP_EOL . "\t\tif (isset(\$data['" . $baseString . "']))";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t\$data['" . $baseString . "'] = base64_encode(\$data['" . $baseString . "']);";
$script .= PHP_EOL . "\t\t}";
}
}
// turn string into encrypted string
$Component = $this->fileContentStatic['###Component###'];
foreach ($this->cryptionTypes as $cryptionType)
{
if (isset($this->{$cryptionType . 'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType . 'EncryptionBuilder'}[$view]))
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the " . $cryptionType . " encryption key.";
$script .= PHP_EOL . "\t\t\$" . $cryptionType . "key = " . $Component . "Helper::getCryptKey('" . $cryptionType . "');";
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object";
$script .= PHP_EOL . "\t\t\$" . $cryptionType . " = new FOFEncryptAes(\$" . $cryptionType . "key);";
foreach ($this->{$cryptionType . 'EncryptionBuilder'}[$view] as $baseString)
{
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Encrypt data " . $baseString . ".";
$script .= PHP_EOL . "\t\tif (isset(\$data['" . $baseString . "']) && \$" . $cryptionType . "key)";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t\$data['" . $baseString . "'] = \$" . $cryptionType . "->encryptString(\$data['" . $baseString . "']);";
$script .= PHP_EOL . "\t\t}";
}
}
}
// add custom PHP to the save method
$script .= $this->getCustomScriptBuilder('php_save', $view, PHP_EOL . PHP_EOL);
return $script;
}
public function setJtableConstructor(&$view)
{
// reset
$oserver = "";
// set component name
$component = $this->fileContentStatic['###component###'];
// add the tags observer
if (isset($this->tagsBuilder[$view]) && ComponentbuilderHelper::checkString($this->tagsBuilder[$view]))
{
$oserver .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Adding Tag Options";
$oserver .= PHP_EOL . "\t\tJTableObserverTags::createObserver(\$this, array('typeAlias' => 'com_" . $component . "." . $view . "'));";
}
// add the history/version observer
if (isset($this->historyBuilder[$view]) && ComponentbuilderHelper::checkString($this->historyBuilder[$view]))
{
$oserver .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Adding History Options";
$oserver .= PHP_EOL . "\t\tJTableObserverContenthistory::createObserver(\$this, array('typeAlias' => 'com_" . $component . "." . $view . "'));";
}
return $oserver;
}
public function setJtableAliasCategory(&$view)
{
// only add Observers if both title, alias and category is availabe in view
if (array_key_exists($view, $this->catCodeBuilder))
{
$code = $this->catCodeBuilder[$view]['code'];
return ", '" . $code . "' => \$this->" . $code;
}
return '';
}
public function setComponentToContentTypes($action)
{
$script = '';
if (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views))
{
// set component name
$component = $this->fileContentStatic['###component###'];
// reset
$dbStuff = array();
// start loading the content type data
foreach ($this->componentData->admin_views as $viewData)
{
// set main keys
$view = ComponentbuilderHelper::safeString($viewData['settings']->name_single);
// set list view keys
$views = ComponentbuilderHelper::safeString($viewData['settings']->name_list);
// get this views content type data
$dbStuff[$view] = $this->getContentType($view, $component);
// get the correct views name
$checkViews = (isset($this->catCodeBuilder[$view]['views']) && ComponentbuilderHelper::checkString($this->catCodeBuilder[$view]['views'])) ? $this->catCodeBuilder[$view]['views'] : $views;
if (ComponentbuilderHelper::checkArray($dbStuff[$view]) && array_key_exists($view, $this->catCodeBuilder) && ($checkViews == $views))
{
$dbStuff[$view . ' category'] = $this->getCategoryContentType($view, $views, $component);
}
elseif (!isset($dbStuff[$view]) || !ComponentbuilderHelper::checkArray($dbStuff[$view]))
{
// remove if not array
unset($dbStuff[$view]);
}
}
// build the db insert query
if (ComponentbuilderHelper::checkArray($dbStuff))
{
$taabb = '';
if ($action === 'update')
{
$taabb = "\t";
}
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get The Database object";
$script .= PHP_EOL . "\t\t\t\$db = JFactory::getDbo();";
foreach ($dbStuff as $name => $tables)
{
if (ComponentbuilderHelper::checkArray($tables))
{
$code = ComponentbuilderHelper::safeString($name);
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Create the " . $name . " content type object.";
$script .= PHP_EOL . "\t\t\t\$" . $code . " = new stdClass();";
foreach ($tables as $table => $data)
{
$script .= PHP_EOL . "\t\t\t\$" . $code . "->" . $table . " = '" . $data . "';";
}
if ($action === 'update')
{
// we first load script to check if data exist
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Check if " . $name . " type is already in content_type DB.";
$script .= PHP_EOL . "\t\t\t\$" . $code . "_id = null;";
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\$query->select(\$db->quoteName(array('type_id')));";
$script .= PHP_EOL . "\t\t\t\$query->from(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . "\t\t\t\$query->where(\$db->quoteName('type_alias') . ' LIKE '. \$db->quote($" . $code . "->type_alias));";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t\$db->execute();";
}
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Set the object into the content types table.";
if ($action === 'update')
{
$script .= PHP_EOL . "\t\t\tif (\$db->getNumRows())";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t\$" . $code . "->type_id = \$db->loadResult();";
$script .= PHP_EOL . "\t\t\t\t\$" . $code . "_Updated = \$db->updateObject('#__content_types', \$" . $code . ", 'type_id');";
$script .= PHP_EOL . "\t\t\t}";
$script .= PHP_EOL . "\t\t\telse";
$script .= PHP_EOL . "\t\t\t{";
}
$script .= PHP_EOL . "\t\t\t" . $taabb . "\$" . $code . "_Inserted = \$db->insertObject('#__content_types', \$" . $code . ");";
if ($action === 'update')
{
$script .= PHP_EOL . "\t\t\t}";
}
}
}
$script .= PHP_EOL . PHP_EOL;
}
}
return $script;
}
public function setPostInstallScript()
{
// reset script
$script = $this->setComponentToContentTypes('install');
// set the component name
$component = $this->fileContentStatic['###component###'];
// add the assets table update for permissions rules
if (isset($this->assetsRules) && ComponentbuilderHelper::checkArray($this->assetsRules))
{
if (ComponentbuilderHelper::checkString($script))
{
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Install the global extenstion assets permission.";
}
else
{
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Install the global extenstion assets permission.";
$script .= PHP_EOL . "\t\t\t\$db = JFactory::getDbo();";
}
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Field to update.";
$script .= PHP_EOL . "\t\t\t\$fields = array(";
$script .= PHP_EOL . "\t\t\t\t\$db->quoteName('rules') . ' = ' . \$db->quote('{" . implode(',', $this->assetsRules) . "}'),";
$script .= PHP_EOL . "\t\t\t);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Condition.";
$script .= PHP_EOL . "\t\t\t\$conditions = array(";
$script .= PHP_EOL . "\t\t\t\t\$db->quoteName('name') . ' = ' . \$db->quote('com_" . $component . "')";
$script .= PHP_EOL . "\t\t\t);";
$script .= PHP_EOL . "\t\t\t\$query->update(\$db->quoteName('#__assets'))->set(\$fields)->where(\$conditions);";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t\$allDone = \$db->execute();" . PHP_EOL;
}
// add the global params for the component global settings
if (isset($this->extensionsParams) && ComponentbuilderHelper::checkArray($this->extensionsParams))
{
if (ComponentbuilderHelper::checkString($script))
{
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Install the global extenstion params.";
}
else
{
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Install the global extenstion params.";
$script .= PHP_EOL . "\t\t\t\$db = JFactory::getDbo();";
}
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Field to update.";
$script .= PHP_EOL . "\t\t\t\$fields = array(";
$script .= PHP_EOL . "\t\t\t\t\$db->quoteName('params') . ' = ' . \$db->quote('{" . implode(',', $this->extensionsParams) . "}'),";
$script .= PHP_EOL . "\t\t\t);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Condition.";
$script .= PHP_EOL . "\t\t\t\$conditions = array(";
$script .= PHP_EOL . "\t\t\t\t\$db->quoteName('element') . ' = ' . \$db->quote('com_" . $component . "')";
$script .= PHP_EOL . "\t\t\t);";
$script .= PHP_EOL . "\t\t\t\$query->update(\$db->quoteName('#__extensions'))->set(\$fields)->where(\$conditions);";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t\$allDone = \$db->execute();" . PHP_EOL;
}
// add the custom script
$script .= $this->getCustomScriptBuilder('php_postflight', 'install', PHP_EOL . PHP_EOL, null, true);
// add the component install notice
if (ComponentbuilderHelper::checkString($script))
{
$script .= PHP_EOL . "\t\t\t" . 'echo \'';
$script .= PHP_EOL . "\t\t\t\t" . '';
$script .= PHP_EOL . "\t\t\t\t" . '\';';
return $script;
}
return PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " noting to install.";
}
public function setPostUpdateScript()
{
// reset script
$script = $this->setComponentToContentTypes('update');
// add the custom script
$script .= $this->getCustomScriptBuilder('php_postflight', 'update', PHP_EOL . PHP_EOL, null, true);
if (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views))
{
$script .= PHP_EOL . "\t\t\t" . 'echo \'';
$script .= PHP_EOL . "\t\t\t\t" . '';
$script .= PHP_EOL . "\t\t\t\t" . '';
$script .= PHP_EOL . "\t\t\t\t
Upgrade to Version " . $this->fileContentStatic['###ACTUALVERSION###'] . " Was Successful! Let us know if anything is not working as expected.
';";
}
if (ComponentbuilderHelper::checkString($script))
{
return $script;
}
return PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " noting to update.";
}
public function setUninstallScript()
{
// reset script
$script = '';
if (isset($this->uninstallScriptBuilder) && ComponentbuilderHelper::checkArray($this->uninstallScriptBuilder))
{
$component = $this->fileContentStatic['###component###'];
// start loading the data to delet
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get Application object";
$script .= PHP_EOL . "\t\t\$app = JFactory::getApplication();";
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get The Database object";
$script .= PHP_EOL . "\t\t\$db = JFactory::getDbo();";
foreach ($this->uninstallScriptBuilder as $viewName => $typeAlias)
{
// set a var value
$view = ComponentbuilderHelper::safeString($viewName);
// First check if data is till in table
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Select id from content type table";
$script .= PHP_EOL . "\t\t\$query->select(\$db->quoteName('type_id'));";
$script .= PHP_EOL . "\t\t\$query->from(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Where " . $viewName . " alias is found";
$script .= PHP_EOL . "\t\t\$query->where( \$db->quoteName('type_alias') . ' = '. \$db->quote('" . $typeAlias . "') );";
$script .= PHP_EOL . "\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Execute query to see if alias is found";
$script .= PHP_EOL . "\t\t\$db->execute();";
$script .= PHP_EOL . "\t\t\$" . $view . "_found = \$db->getNumRows();";
$script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Now check if there were any rows";
$script .= PHP_EOL . "\t\tif (\$" . $view . "_found)";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Since there are load the needed " . $view . " type ids";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_ids = \$db->loadColumn();";
// Now remove the actual type entry
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Remove " . $viewName . " from the content type table";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" . $typeAlias . "') );";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\$query->delete(\$db->quoteName('#__content_types'));";
$script .= PHP_EOL . "\t\t\t\$query->where(\$" . $view . "_condition);";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Execute the query to remove " . $viewName . " items";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_done = \$db->execute();";
$script .= PHP_EOL . "\t\t\tif (\$" . $view . "_done);";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " If succesfully remove " . $viewName . " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . "\t\t\t\t\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias . ") type alias was removed from the #__content_type table'));";
$script .= PHP_EOL . "\t\t\t}";
// Now remove the related items from contentitem tag map table
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Remove " . $viewName . " items from the contentitem tag map table";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" . $typeAlias . "') );";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\$query->delete(\$db->quoteName('#__contentitem_tag_map'));";
$script .= PHP_EOL . "\t\t\t\$query->where(\$" . $view . "_condition);";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Execute the query to remove " . $viewName . " items";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_done = \$db->execute();";
$script .= PHP_EOL . "\t\t\tif (\$" . $view . "_done);";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " If succesfully remove " . $viewName . " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . "\t\t\t\t\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias . ") type alias was removed from the #__contentitem_tag_map table'));";
$script .= PHP_EOL . "\t\t\t}";
// Now remove the related items from ucm content table
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Remove " . $viewName . " items from the ucm content table";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_condition = array( \$db->quoteName('core_type_alias') . ' = ' . \$db->quote('" . $typeAlias . "') );";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\$query->delete(\$db->quoteName('#__ucm_content'));";
$script .= PHP_EOL . "\t\t\t\$query->where(\$" . $view . "_condition);";
$script .= PHP_EOL . "\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Execute the query to remove " . $viewName . " items";
$script .= PHP_EOL . "\t\t\t\$" . $view . "_done = \$db->execute();";
$script .= PHP_EOL . "\t\t\tif (\$" . $view . "_done);";
$script .= PHP_EOL . "\t\t\t{";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " If succesfully remove " . $viewName . " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . "\t\t\t\t\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias . ") type alias was removed from the #__ucm_content table'));";
$script .= PHP_EOL . "\t\t\t}";
// setup the foreach loop of ids
$script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Make sure that all the " . $viewName . " items are cleared from DB";
$script .= PHP_EOL . "\t\t\tforeach (\$" . $view . "_ids as \$" . $view . "_id)";
$script .= PHP_EOL . "\t\t\t{";
// Now remove the related items from ucm base table
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Remove " . $viewName . " items from the ucm base table";
$script .= PHP_EOL . "\t\t\t\t\$" . $view . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" . $view . "_id);";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\t\$query->delete(\$db->quoteName('#__ucm_base'));";
$script .= PHP_EOL . "\t\t\t\t\$query->where(\$" . $view . "_condition);";
$script .= PHP_EOL . "\t\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Execute the query to remove " . $viewName . " items";
$script .= PHP_EOL . "\t\t\t\t\$db->execute();";
// Now remove the related items from ucm history table
$script .= PHP_EOL . PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Remove " . $viewName . " items from the ucm history table";
$script .= PHP_EOL . "\t\t\t\t\$" . $view . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" . $view . "_id);";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\t\t\$query->delete(\$db->quoteName('#__ucm_history'));";
$script .= PHP_EOL . "\t\t\t\t\$query->where(\$" . $view . "_condition);";
$script .= PHP_EOL . "\t\t\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " Execute the query to remove " . $viewName . " items";
$script .= PHP_EOL . "\t\t\t\t\$db->execute();";
$script .= PHP_EOL . "\t\t\t}";
$script .= PHP_EOL . "\t\t}";
}
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " If All related items was removed queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . "\t\t\$app->enqueueMessage(JText:" . ":_('All related items was removed from the #__ucm_base table'));";
$script .= PHP_EOL . "\t\t\$app->enqueueMessage(JText:" . ":_('All related items was removed from the #__ucm_history table'));";
// finaly remove the assets from the assets table
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Remove " . $component . " assets from the assets table";
$script .= PHP_EOL . "\t\t\$" . $component . "_condition = array( \$db->quoteName('name') . ' LIKE ' . \$db->quote('com_" . $component . "%') );";
$script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Create a new query object.";
$script .= PHP_EOL . "\t\t\$query = \$db->getQuery(true);";
$script .= PHP_EOL . "\t\t\$query->delete(\$db->quoteName('#__assets'));";
$script .= PHP_EOL . "\t\t\$query->where(\$" . $component . "_condition);";
$script .= PHP_EOL . "\t\t\$db->setQuery(\$query);";
$script .= PHP_EOL . "\t\t\$" . $view . "_done = \$db->execute();";
$script .= PHP_EOL . "\t\tif (\$" . $view . "_done);";
$script .= PHP_EOL . "\t\t{";
$script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " If succesfully remove " . $component . " add queued success message.";
// TODO lang is not translated
$script .= PHP_EOL . "\t\t\t\$app->enqueueMessage(JText:" . ":_('All related items was removed from the #__assets table'));";
$script .= PHP_EOL . "\t\t}";
// done
$script .= PHP_EOL;
}
// add the custom uninstall script
$script .= $this->getCustomScriptBuilder('php_method', 'uninstall', "", null, true, null, PHP_EOL);
return $script;
}
public function setMoveFolderScript()
{
if ($this->setMoveFolders)
{
// reset script
$script = array();
$script[] = "\t\t//" . $this->setLine(__LINE__) . " We check if we have dynamic folders to copy";
$script[] = "\t\t\$this->setDynamicF0ld3rs(\$app, \$parent);";
// done
return PHP_EOL . implode(PHP_EOL, $script);
}
return '';
}
public function setMoveFolderMethod()
{
if ($this->setMoveFolders)
{
// reset script
$script = array();
$script[] = "\t/**";
$script[] = "\t * Method to set/copy dynamic folders into place (use with caution)";
$script[] = "\t *";
$script[] = "\t * @return void";
$script[] = "\t */";
$script[] = "\tprotected function setDynamicF0ld3rs(\$app, \$parent)";
$script[] = "\t{";
$script[] = "\t\t//" . $this->setLine(__LINE__) . " get the instalation path";
$script[] = "\t\t\$installer = \$parent->getParent();";
$script[] = "\t\t\$installPath = \$installer->getPath('source');";
$script[] = "\t\t//" . $this->setLine(__LINE__) . " get all the folders";
$script[] = "\t\t\$folders = JFolder::folders(\$installPath);";
$script[] = "\t\t//" . $this->setLine(__LINE__) . " check if we have folders we may want to copy";
$script[] = "\t\t\$doNotCopy = array('media','admin','site'); // Joomla already deals with these";
$script[] = "\t\tif (count(\$folders) > 1)";
$script[] = "\t\t{";
$script[] = "\t\t\tforeach (\$folders as \$folder)";
$script[] = "\t\t\t{";
$script[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " Only copy if not a standard folders";
$script[] = "\t\t\t\tif (!in_array(\$folder, \$doNotCopy))";
$script[] = "\t\t\t\t{";
$script[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " set the source path";
$script[] = "\t\t\t\t\t\$src = \$installPath.'/'.\$folder;";
$script[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " set the destination path";
$script[] = "\t\t\t\t\t\$dest = JPATH_ROOT.'/'.\$folder;";
$script[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " now try to copy the folder";
$script[] = "\t\t\t\t\tif (!JFolder::copy(\$src, \$dest, '', true))";
$script[] = "\t\t\t\t\t{";
$script[] = "\t\t\t\t\t\t\$app->enqueueMessage('Could not copy '.\$folder.' folder into place, please make sure destination is writable!', 'error');";
$script[] = "\t\t\t\t\t}";
$script[] = "\t\t\t\t}";
$script[] = "\t\t\t}";
$script[] = "\t\t}";
$script[] = "\t}";
// done
return PHP_EOL . PHP_EOL . implode(PHP_EOL, $script);
}
return '';
}
public function getContentType($view, $component)
{
// add if history is to be kept or if tags is added
if ((isset($this->historyBuilder[$view]) && ComponentbuilderHelper::checkString($this->historyBuilder[$view])) || (isset($this->tagsBuilder[$view]) && ComponentbuilderHelper::checkString($this->tagsBuilder[$view])))
{
// reset array
$array = array();
// set needed defaults
$alias = (array_key_exists($view, $this->aliasBuilder)) ? $this->aliasBuilder[$view] : 'null';
$title = (array_key_exists($view, $this->titleBuilder)) ? $this->titleBuilder[$view] : 'null';
$category = (array_key_exists($view, $this->catCodeBuilder)) ? $this->catCodeBuilder[$view]['code'] : 'null';
$categoryHistory = (array_key_exists($view, $this->catCodeBuilder)) ?
'{"sourceColumn": "' . $category . '","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},' : '';
$Component = ComponentbuilderHelper::safeString($component, 'F');
$View = ComponentbuilderHelper::safeString($view, 'F');
$maintext = (isset($this->maintextBuilder[$view]) && ComponentbuilderHelper::checkString($this->maintextBuilder[$view])) ? $this->maintextBuilder[$view] : 'null';
$hiddenFields = (isset($this->hiddenFieldsBuilder[$view]) && ComponentbuilderHelper::checkString($this->hiddenFieldsBuilder[$view])) ? $this->hiddenFieldsBuilder[$view] : '';
$dynamicfields = (isset($this->dynamicfieldsBuilder[$view]) && ComponentbuilderHelper::checkString($this->dynamicfieldsBuilder[$view])) ? $this->dynamicfieldsBuilder[$view] : '';
$intFields = (isset($this->intFieldsBuilder[$view]) && ComponentbuilderHelper::checkString($this->intFieldsBuilder[$view])) ? $this->intFieldsBuilder[$view] : '';
$customfieldlinks = (isset($this->customFieldLinksBuilder[$view]) && ComponentbuilderHelper::checkString($this->customFieldLinksBuilder[$view])) ? $this->customFieldLinksBuilder[$view] : '';
// build uninstall script for content types
$this->uninstallScriptBuilder[$View] = 'com_' . $component . '.' . $view;
// check if this view has metadata
if (isset($this->metadataBuilder[$view]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view]))
{
$core_metadata = 'metadata';
$core_metakey = 'metakey';
$core_metadesc = 'metadesc';
}
else
{
$core_metadata = 'null';
$core_metakey = 'null';
$core_metadesc = 'null';
}
// check if view has access
if (isset($this->accessBuilder[$view]) && ComponentbuilderHelper::checkString($this->accessBuilder[$view]))
{
$core_access = 'access';
$accessHistory = ',{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"}';
}
else
{
$core_access = 'null';
$accessHistory = '';
}
// set the title
$array['type_title'] = $Component . ' ' . $View;
// set the alias
$array['type_alias'] = 'com_' . $component . '.' . $view;
// set the table
$array['table'] = '{"special": {"dbtable": "#__' . $component . '_' . $view . '","key": "id","type": "' . $View . '","prefix": "' . $component . 'Table","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
// set field map
$array['field_mappings'] = '{"common": {"core_content_item_id": "id","core_title": "' . $title . '","core_state": "published","core_alias": "' . $alias . '","core_created_time": "created","core_modified_time": "modified","core_body": "' . $maintext . '","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "' . $core_access . '","core_params": "params","core_featured": "null","core_metadata": "' . $core_metadata . '","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "' . $core_metakey . '","core_metadesc": "' . $core_metadesc . '","core_catid": "' . $category . '","core_xreference": "null","asset_id": "asset_id"},"special": {' . $dynamicfields . '}}';
// set the router class method
$array['router'] = $Component . 'HelperRoute::get' . $View . 'Route';
// set content history
$array['content_history_options'] = '{"formFile": "administrator/components/com_' . $component . '/models/forms/' . $view . '.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"' . $hiddenFields . '],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"' . $intFields . '],"displayLookup": [' . $categoryHistory . '{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' . $accessHistory . ',{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' . $customfieldlinks . ']}';
return $array;
}
return false;
}
public function getCategoryContentType($view, $views, $component)
{
$category = $this->catCodeBuilder[$view]['code'];
$Component = ComponentbuilderHelper::safeString($component, 'F');
$View = ComponentbuilderHelper::safeString($view, 'F');
// build uninstall script for content types
$this->uninstallScriptBuilder[$View . ' ' . $category] = 'com_' . $component . '.' . $views . '.category';
// set the title
$array['type_title'] = $Component . ' ' . $View . ' ' . ComponentbuilderHelper::safeString($category, 'F');
// set the alias
$array['type_alias'] = 'com_' . $component . '.' . $views . '.category';
// set the table
$array['table'] = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
// set field map
$array['field_mappings'] = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
// set the router class method
$array['router'] = $Component . 'HelperRoute::getCategoryRoute';
// set content history
$array['content_history_options'] = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
return $array;
}
public function setRouterHelp($viewName_single, $viewName_list, $front = false)
{
// add if tags is added, also for all front item views
if (((isset($this->tagsBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->tagsBuilder[$viewName_single])) || $front) && (!in_array($viewName_single, $this->setRouterHelpDone)))
{
// insure we load a view only once
$this->setRouterHelpDone[] = $viewName_single;
// build view route helper
$View = ComponentbuilderHelper::safeString($viewName_single, 'F');
$routeHelper = array();
$routeHelper[] = PHP_EOL . PHP_EOL . "\t/**";
$routeHelper[] = "\t* @param int The route of the " . $View;
$routeHelper[] = "\t*/";
if ('category' === $viewName_single || 'categories' === $viewName_single)
{
$routeHelper[] = "\tpublic static function get" . $View . "Route(\$id = 0)";
}
else
{
$routeHelper[] = "\tpublic static function get" . $View . "Route(\$id = 0, \$catid = 0)";
}
$routeHelper[] = "\t{";
$routeHelper[] = "\t\tif (\$id > 0)";
$routeHelper[] = "\t\t{";
$routeHelper[] = "\t\t\t//" . $this->setLine(__LINE__) . " Initialize the needel array.";
$routeHelper[] = "\t\t\t\$needles = array(";
$routeHelper[] = "\t\t\t\t'" . $viewName_single . "' => array((int) \$id)";
$routeHelper[] = "\t\t\t);";
$routeHelper[] = "\t\t\t//" . $this->setLine(__LINE__) . " Create the link";
$routeHelper[] = "\t\t\t\$link = 'index.php?option=com_" . $this->fileContentStatic['###component###'] . "&view=" . $viewName_single . "&id='. \$id;";
$routeHelper[] = "\t\t}";
$routeHelper[] = "\t\telse";
$routeHelper[] = "\t\t{";
$routeHelper[] = "\t\t\t//" . $this->setLine(__LINE__) . " Initialize the needel array.";
$routeHelper[] = "\t\t\t\$needles = array();";
$routeHelper[] = "\t\t\t//" . $this->setLine(__LINE__) . "Create the link but don't add the id.";
$routeHelper[] = "\t\t\t\$link = 'index.php?option=com_" . $this->fileContentStatic['###component###'] . "&view=" . $viewName_single . "';";
$routeHelper[] = "\t\t}";
if ('category' != $viewName_single && 'categories' != $viewName_single)
{
$routeHelper[] = "\t\tif (\$catid > 1)";
$routeHelper[] = "\t\t{";
$routeHelper[] = "\t\t\t\$categories = JCategories::getInstance('" . $this->fileContentStatic['###component###'] . "." . $viewName_list . "');";
$routeHelper[] = "\t\t\t\$category = \$categories->get(\$catid);";
$routeHelper[] = "\t\t\tif (\$category)";
$routeHelper[] = "\t\t\t{";
$routeHelper[] = "\t\t\t\t\$needles['category'] = array_reverse(\$category->getPath());";
$routeHelper[] = "\t\t\t\t\$needles['categories'] = \$needles['category'];";
$routeHelper[] = "\t\t\t\t\$link .= '&catid='.\$catid;";
$routeHelper[] = "\t\t\t}";
$routeHelper[] = "\t\t}";
}
if (isset($this->hasMenuGlobal[$viewName_single]))
{
$routeHelper[] = PHP_EOL . "\t\tif (\$item = self::_findItem(\$needles, '" . $viewName_single . "'))";
}
else
{
$routeHelper[] = PHP_EOL . "\t\tif (\$item = self::_findItem(\$needles))";
}
$routeHelper[] = "\t\t{";
$routeHelper[] = "\t\t\t\$link .= '&Itemid='.\$item;";
$routeHelper[] = "\t\t}";
$routeHelper[] = PHP_EOL . "\t\treturn \$link;";
$routeHelper[] = "\t}";
return implode(PHP_EOL, $routeHelper);
}
return '';
}
public function routerParseSwitch(&$view, $viewArray = null, $aliasView = true, $idView = true)
{
// reset buckets
$routerSwitch = array();
$isCategory = '';
$viewTable = false;
if ($viewArray && ComponentbuilderHelper::checkArray($viewArray) && isset($viewArray['settings']) && isset($viewArray['settings']->main_get))
{
// check if we have custom script for this router parse switch case
if (isset($viewArray['settings']->main_get->add_php_router_parse) && $viewArray['settings']->main_get->add_php_router_parse == 1 && isset($viewArray['settings']->main_get->php_router_parse) && ComponentbuilderHelper::checkString($viewArray['settings']->main_get->php_router_parse))
{
// load the custom script for the switch based on dynamic get
$routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':";
$routerSwitch[] = $this->setPlaceholders($this->setDynamicValues(base64_decode($viewArray['settings']->main_get->php_router_parse)), $this->placeholders);
$routerSwitch[] = "\t\t\t\tbreak;";
return implode(PHP_EOL, $routerSwitch);
}
// is this a catogory
elseif (isset($viewArray['settings']->main_get->db_table_main) && $viewArray['settings']->main_get->db_table_main === 'categories')
{
$isCategory = ', true'; // TODO we will keep an eye on this....
}
// get the main table name
elseif (isset($viewArray['settings']->main_get->main_get) && ComponentbuilderHelper::checkArray($viewArray['settings']->main_get->main_get))
{
foreach ($viewArray['settings']->main_get->main_get as $get)
{
if ($get['as'] === 'a')
{
if (isset($get['selection']) && ComponentbuilderHelper::checkArray($get['selection']) && isset($get['selection']['select_gets']) && ComponentbuilderHelper::checkArray($get['selection']['select_gets']))
{
if (isset($get['selection']['table']))
{
$viewTable = str_replace('#__' . $this->fileContentStatic['###component###'] . '_', '', $get['selection']['table']);
}
}
break;
}
}
}
}
// add if tags is added, also for all front item views
if ($aliasView)
{
$routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':";
$routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';";
$routerSwitch[] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))";
$routerSwitch[] = "\t\t\t\t{";
$routerSwitch[] = "\t\t\t\t\t\$vars['id'] = (int) \$segments[\$count-1];";
$routerSwitch[] = "\t\t\t\t}";
$routerSwitch[] = "\t\t\t\telseif (\$segments[\$count-1])";
$routerSwitch[] = "\t\t\t\t{";
// we need to get from the table of this views main get the alias so we need the table name
if ($viewTable)
{
$routerSwitch[] = "\t\t\t\t\t\$id = \$this->getVar('" . $viewTable . "', \$segments[\$count-1], 'alias', 'id'" . $isCategory . ");";
}
else
{
$routerSwitch[] = "\t\t\t\t\t\$id = \$this->getVar('" . $view . "', \$segments[\$count-1], 'alias', 'id'" . $isCategory . ");";
}
$routerSwitch[] = "\t\t\t\t\tif(\$id)";
$routerSwitch[] = "\t\t\t\t\t{";
$routerSwitch[] = "\t\t\t\t\t\t\$vars['id'] = \$id;";
$routerSwitch[] = "\t\t\t\t\t}";
$routerSwitch[] = "\t\t\t\t}";
$routerSwitch[] = "\t\t\t\tbreak;";
}
elseif ($idView)
{
$routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':";
$routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';";
$routerSwitch[] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))";
$routerSwitch[] = "\t\t\t\t{";
$routerSwitch[] = "\t\t\t\t\t\$vars['id'] = (int) \$segments[\$count-1];";
$routerSwitch[] = "\t\t\t\t}";
$routerSwitch[] = "\t\t\t\tbreak;";
}
else
{
$routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':";
$routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';";
$routerSwitch[] = "\t\t\t\tbreak;";
}
return implode(PHP_EOL, $routerSwitch);
}
public function routerBuildViews(&$view)
{
if (isset($this->fileContentStatic['###ROUTER_BUILD_VIEWS###']) && ComponentbuilderHelper::checkString($this->fileContentStatic['###ROUTER_BUILD_VIEWS###']))
{
return " || \$view === '" . $view . "'";
}
else
{
return "\$view === '" . $view . "'";
}
}
public function setBatchMove($viewName_single)
{
// set needed defaults
$title = false;
$alias = false;
$category = false;
$batchmove = array();
$VIEW = ComponentbuilderHelper::safeString($viewName_single, 'U');
// component helper name
$Helper = $this->fileContentStatic['###Component###'] . 'Helper';
// setup correct core target
$coreLoad = false;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
$coreLoad = true;
}
// only load category if set in this view
if (array_key_exists($viewName_single, $this->catCodeBuilder))
{
$category = $this->catCodeBuilder[$viewName_single]['code'];
}
// only load alias if set in this view
if (array_key_exists($viewName_single, $this->aliasBuilder))
{
$alias = $this->aliasBuilder[$viewName_single];
}
// only load title if set in this view
if (array_key_exists($viewName_single, $this->titleBuilder))
{
$title = $this->titleBuilder[$viewName_single];
}
// prepare custom script
$customScript = $this->getCustomScriptBuilder('php_batchmove', $viewName_single, PHP_EOL . PHP_EOL, null, true);
$batchmove[] = PHP_EOL . "\t/**";
$batchmove[] = "\t * Batch move items to a new category";
$batchmove[] = "\t *";
$batchmove[] = "\t * @param integer \$value The new category ID.";
$batchmove[] = "\t * @param array \$pks An array of row IDs.";
$batchmove[] = "\t * @param array \$contexts An array of item contexts.";
$batchmove[] = "\t *";
$batchmove[] = "\t * @return boolean True if successful, false otherwise and internal error is set.";
$batchmove[] = "\t *";
$batchmove[] = "\t * @since\t12.2";
$batchmove[] = "\t */";
$batchmove[] = "\tprotected function batchMove(\$values, \$pks, \$contexts)";
$batchmove[] = "\t{";
$batchmove[] = "\t\tif (empty(\$this->batchSet))";
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\t//" . $this->setLine(__LINE__) . " Set some needed variables.";
$batchmove[] = "\t\t\t\$this->user = JFactory::getUser();";
$batchmove[] = "\t\t\t\$this->table = \$this->getTable();";
$batchmove[] = "\t\t\t\$this->tableClassName = get_class(\$this->table);";
$batchmove[] = "\t\t\t\$this->canDo = " . $Helper . "::getActions('" . $viewName_single . "');";
$batchmove[] = "\t\t}";
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit']]))
{
$batchmove[] = PHP_EOL . "\t\tif (!\$this->canDo->get('" . $core['core.edit'] . "') && !\$this->canDo->get('" . $core['core.batch'] . "'))";
}
else
{
$batchmove[] = PHP_EOL . "\t\tif (!\$this->canDo->get('core.edit') && !\$this->canDo->get('core.batch'))";
}
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\t\$this->setError(JText:" . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));";
$batchmove[] = "\t\t\treturn false;";
$batchmove[] = "\t\t}" . $customScript;
$batchmove[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " make sure published only updates if user has the permission.";
if ($coreLoad && isset($core['core.edit.state']) && isset($this->permissionBuilder['global'][$core['core.edit.state']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit.state']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit.state']]))
{
$batchmove[] = "\t\tif (isset(\$values['published']) && !\$this->canDo->get('" . $core['core.edit.state'] . "'))";
}
else
{
$batchmove[] = "\t\tif (isset(\$values['published']) && !\$this->canDo->get('core.edit.state'))";
}
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\tunset(\$values['published']);";
$batchmove[] = "\t\t}";
$batchmove[] = "\t\t//" . $this->setLine(__LINE__) . " remove move_copy from array";
$batchmove[] = "\t\tunset(\$values['move_copy']);";
if ($category)
{
$batchmove[] = PHP_EOL . "\t\tif (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))";
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\treturn false;";
$batchmove[] = "\t\t}";
$batchmove[] = "\t\telseif (isset(\$values['category']) && (int) \$values['category'] > 0)";
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\t//" . $this->setLine(__LINE__) . " move the category value to correct field name";
$batchmove[] = "\t\t\t\$values['" . $category . "'] = \$values['category'];";
$batchmove[] = "\t\t\tunset(\$values['category']);";
$batchmove[] = "\t\t}";
$batchmove[] = "\t\telseif (isset(\$values['category']))";
$batchmove[] = "\t\t{";
$batchmove[] = "\t\t\tunset(\$values['category']);";
$batchmove[] = "\t\t}" . PHP_EOL;
}
$batchmove[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Parent exists so we proceed";
$batchmove[] = "\t\tforeach (\$pks as \$pk)";
$batchmove[] = "\t\t{";
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder[$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.edit']]))
{
$batchmove[] = "\t\t\tif (!\$this->user->authorise('" . $core['core.edit'] . "', \$contexts[\$pk]))";
}
else
{
$batchmove[] = "\t\t\tif (!\$this->user->authorise('core.edit', \$contexts[\$pk]))";
}
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\t\$this->setError(JText:" . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));";
$batchmove[] = "\t\t\t\treturn false;";
$batchmove[] = "\t\t\t}";
$batchmove[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Check that the row actually exists";
$batchmove[] = "\t\t\tif (!\$this->table->load(\$pk))";
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\tif (\$error = \$this->table->getError())";
$batchmove[] = "\t\t\t\t{";
$batchmove[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " Fatal error";
$batchmove[] = "\t\t\t\t\t\$this->setError(\$error);";
$batchmove[] = "\t\t\t\t\treturn false;";
$batchmove[] = "\t\t\t\t}";
$batchmove[] = "\t\t\t\telse";
$batchmove[] = "\t\t\t\t{";
$batchmove[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " Not fatal error";
$batchmove[] = "\t\t\t\t\t\$this->setError(JText:" . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));";
$batchmove[] = "\t\t\t\t\tcontinue;";
$batchmove[] = "\t\t\t\t}";
$batchmove[] = "\t\t\t}";
$batchmove[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " insert all set values.";
$batchmove[] = "\t\t\tif (" . $Helper . "::checkArray(\$values))";
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\tforeach (\$values as \$key => \$value)";
$batchmove[] = "\t\t\t\t{";
$batchmove[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " Do special action for access.";
$batchmove[] = "\t\t\t\t\tif ('access' === \$key && strlen(\$value) > 0)";
$batchmove[] = "\t\t\t\t\t{";
$batchmove[] = "\t\t\t\t\t\t\$this->table->\$key = \$value;";
$batchmove[] = "\t\t\t\t\t}";
$batchmove[] = "\t\t\t\t\telseif (strlen(\$value) > 0 && isset(\$this->table->\$key))";
$batchmove[] = "\t\t\t\t\t{";
$batchmove[] = "\t\t\t\t\t\t\$this->table->\$key = \$value;";
$batchmove[] = "\t\t\t\t\t}";
$batchmove[] = "\t\t\t\t}";
$batchmove[] = "\t\t\t}" . PHP_EOL;
$batchmove[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Check the row.";
$batchmove[] = "\t\t\tif (!\$this->table->check())";
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\t\$this->setError(\$this->table->getError());";
$batchmove[] = PHP_EOL . "\t\t\t\treturn false;";
$batchmove[] = "\t\t\t}";
$batchmove[] = PHP_EOL . "\t\t\tif (!empty(\$this->type))";
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\t\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);";
$batchmove[] = "\t\t\t}";
$batchmove[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Store the row.";
$batchmove[] = "\t\t\tif (!\$this->table->store())";
$batchmove[] = "\t\t\t{";
$batchmove[] = "\t\t\t\t\$this->setError(\$this->table->getError());";
$batchmove[] = PHP_EOL . "\t\t\t\treturn false;";
$batchmove[] = "\t\t\t}";
$batchmove[] = "\t\t}";
$batchmove[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Clean the cache";
$batchmove[] = "\t\t\$this->cleanCache();";
$batchmove[] = PHP_EOL . "\t\treturn true;";
$batchmove[] = "\t}";
return PHP_EOL . implode(PHP_EOL, $batchmove);
}
public function setBatchCopy($viewName_single)
{
// set needed defaults
$title = false;
$alias = false;
$category = false;
$batchcopy = array();
$VIEW = ComponentbuilderHelper::safeString($viewName_single, 'U');
// component helper name
$Helper = $this->fileContentStatic['###Component###'] . 'Helper';
// setup correct core target
$coreLoad = false;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
$coreLoad = true;
}
// only load category if set in this view
if (array_key_exists($viewName_single, $this->catCodeBuilder))
{
$category = $this->catCodeBuilder[$viewName_single]['code'];
}
// only load alias if set in this view
if (array_key_exists($viewName_single, $this->aliasBuilder))
{
$alias = $this->aliasBuilder[$viewName_single];
}
// only load title if set in this view
if (array_key_exists($viewName_single, $this->titleBuilder))
{
$title = $this->titleBuilder[$viewName_single];
}
// prepare custom script
$customScript = $this->getCustomScriptBuilder('php_batchcopy', $viewName_single, PHP_EOL . PHP_EOL, null, true);
$batchcopy[] = PHP_EOL . "\t/**";
$batchcopy[] = "\t * Batch copy items to a new category or current.";
$batchcopy[] = "\t *";
$batchcopy[] = "\t * @param integer \$values The new values.";
$batchcopy[] = "\t * @param array \$pks An array of row IDs.";
$batchcopy[] = "\t * @param array \$contexts An array of item contexts.";
$batchcopy[] = "\t *";
$batchcopy[] = "\t * @return mixed An array of new IDs on success, boolean false on failure.";
$batchcopy[] = "\t *";
$batchcopy[] = "\t * @since\t12.2";
$batchcopy[] = "\t */";
$batchcopy[] = "\tprotected function batchCopy(\$values, \$pks, \$contexts)";
$batchcopy[] = "\t{";
$batchcopy[] = "\t\tif (empty(\$this->batchSet))";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\t//" . $this->setLine(__LINE__) . " Set some needed variables.";
$batchcopy[] = "\t\t\t\$this->user = JFactory::getUser();";
$batchcopy[] = "\t\t\t\$this->table = \$this->getTable();";
$batchcopy[] = "\t\t\t\$this->tableClassName = get_class(\$this->table);";
$batchcopy[] = "\t\t\t\$this->canDo = " . $Helper . "::getActions('" . $viewName_single . "');";
$batchcopy[] = "\t\t}";
if ($coreLoad && isset($core['core.create']) && isset($this->permissionBuilder['global'][$core['core.create']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.create']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.create']]))
{
$batchcopy[] = PHP_EOL . "\t\tif (!\$this->canDo->get('" . $core['core.create'] . "') && !\$this->canDo->get('" . $core['core.batch'] . "'))";
}
else
{
$batchcopy[] = PHP_EOL . "\t\tif (!\$this->canDo->get('core.create') || !\$this->canDo->get('core.batch'))";
}
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\treturn false;";
$batchcopy[] = "\t\t}" . $customScript;
$batchcopy[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " get list of uniqe fields";
$batchcopy[] = "\t\t\$uniqeFields = \$this->getUniqeFields();";
$batchcopy[] = "\t\t//" . $this->setLine(__LINE__) . " remove move_copy from array";
$batchcopy[] = "\t\tunset(\$values['move_copy']);";
$batchcopy[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " make sure published is set";
$batchcopy[] = "\t\tif (!isset(\$values['published']))";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\t\$values['published'] = 0;";
$batchcopy[] = "\t\t}";
if ($coreLoad && isset($core['core.edit.state']) && isset($this->permissionBuilder['global'][$core['core.edit.state']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit.state']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit.state']]))
{
$batchcopy[] = "\t\telseif (isset(\$values['published']) && !\$this->canDo->get('" . $core['core.edit.state'] . "'))";
}
else
{
$batchcopy[] = "\t\telseif (isset(\$values['published']) && !\$this->canDo->get('core.edit.state'))";
}
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\t\t\$values['published'] = 0;";
$batchcopy[] = "\t\t}";
if ($category)
{
$batchcopy[] = PHP_EOL . "\t\tif (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\treturn false;";
$batchcopy[] = "\t\t}";
$batchcopy[] = "\t\telseif (isset(\$values['category']) && (int) \$values['category'] > 0)";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\t//" . $this->setLine(__LINE__) . " move the category value to correct field name";
$batchcopy[] = "\t\t\t\$values['" . $category . "'] = \$values['category'];";
$batchcopy[] = "\t\t\tunset(\$values['category']);";
$batchcopy[] = "\t\t}";
$batchcopy[] = "\t\telseif (isset(\$values['category']))";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\tunset(\$values['category']);";
$batchcopy[] = "\t\t}";
}
$batchcopy[] = PHP_EOL . "\t\t\$newIds = array();";
$batchcopy[] = "\t\t//" . $this->setLine(__LINE__) . " Parent exists so let's proceed";
$batchcopy[] = "\t\twhile (!empty(\$pks))";
$batchcopy[] = "\t\t{";
$batchcopy[] = "\t\t\t//" . $this->setLine(__LINE__) . " Pop the first ID off the stack";
$batchcopy[] = "\t\t\t\$pk = array_shift(\$pks);";
$batchcopy[] = PHP_EOL . "\t\t\t\$this->table->reset();";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " only allow copy if user may edit this item.";
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder[$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.edit']]))
{
$batchcopy[] = "\t\t\tif (!\$this->user->authorise('" . $core['core.edit'] . "', \$contexts[\$pk]))";
}
else
{
$batchcopy[] = "\t\t\tif (!\$this->user->authorise('core.edit', \$contexts[\$pk]))";
}
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " Not fatal error";
$batchcopy[] = "\t\t\t\t\$this->setError(JText:" . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));";
$batchcopy[] = "\t\t\t\tcontinue;";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Check that the row actually exists";
$batchcopy[] = "\t\t\tif (!\$this->table->load(\$pk))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tif (\$error = \$this->table->getError())";
$batchcopy[] = "\t\t\t\t{";
$batchcopy[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " Fatal error";
$batchcopy[] = "\t\t\t\t\t\$this->setError(\$error);";
$batchcopy[] = "\t\t\t\t\treturn false;";
$batchcopy[] = "\t\t\t\t}";
$batchcopy[] = "\t\t\t\telse";
$batchcopy[] = "\t\t\t\t{";
$batchcopy[] = "\t\t\t\t\t//" . $this->setLine(__LINE__) . " Not fatal error";
$batchcopy[] = "\t\t\t\t\t\$this->setError(JText:" . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));";
$batchcopy[] = "\t\t\t\t\tcontinue;";
$batchcopy[] = "\t\t\t\t}";
$batchcopy[] = "\t\t\t}";
if ($category && $alias === 'alias' && $title === 'title')
{
$batchcopy[] = PHP_EOL . "\t\t\tif (isset(\$values['" . $category . "']))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tstatic::generateTitle((int) \$values['" . $category . "'], \$this->table);";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = "\t\t\telse";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tstatic::generateTitle((int) \$this->table->" . $category . ", \$this->table);";
$batchcopy[] = "\t\t\t}";
}
elseif ($category && $alias && $title)
{
$batchcopy[] = PHP_EOL . "\t\t\tif (isset(\$values['" . $category . "']))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tlist(\$this->table->" . $title . ", \$this->table->" . $alias . ") = \$this->generateNewTitle(\$values['" . $category . "'], \$this->table->" . $alias . ", \$this->table->" . $title . ");";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = "\t\t\telse";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tlist(\$this->table->" . $title . ", \$this->table->" . $alias . ") = \$this->generateNewTitle(\$this->table->" . $category . ", \$this->table->" . $alias . ", \$this->table->" . $title . ");";
$batchcopy[] = "\t\t\t}";
}
elseif (!$category && $alias && $title)
{
$batchcopy[] = "\t\t\tlist(\$this->table->" . $title . ", \$this->table->" . $alias . ") = \$this->_generateNewTitle(\$this->table->" . $alias . ", \$this->table->" . $title . ");";
}
elseif (!$category && !$alias && $title && $title != 'user' && $title != 'jobnumber') // TODO [jobnumber] just for one project (not ideal)
{
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Only for strings";
$batchcopy[] = "\t\t\tif (" . $Helper . "::checkString(\$this->table->" . $title . ") && !is_numeric(\$this->table->" . $title . "))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t\$this->table->" . $title . " = \$this->generateUniqe('" . $title . "',\$this->table->" . $title . ");";
$batchcopy[] = "\t\t\t}";
}
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " insert all set values";
$batchcopy[] = "\t\t\tif (" . $Helper . "::checkArray(\$values))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tforeach (\$values as \$key => \$value)";
$batchcopy[] = "\t\t\t\t{";
$batchcopy[] = "\t\t\t\t\tif (strlen(\$value) > 0 && isset(\$this->table->\$key))";
$batchcopy[] = "\t\t\t\t\t{";
$batchcopy[] = "\t\t\t\t\t\t\$this->table->\$key = \$value;";
$batchcopy[] = "\t\t\t\t\t}";
$batchcopy[] = "\t\t\t\t}";
$batchcopy[] = "\t\t\t}" . PHP_EOL;
$batchcopy[] = "\t\t\t//" . $this->setLine(__LINE__) . " update all uniqe fields";
$batchcopy[] = "\t\t\tif (" . $Helper . "::checkArray(\$uniqeFields))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\tforeach (\$uniqeFields as \$uniqeField)";
$batchcopy[] = "\t\t\t\t{";
$batchcopy[] = "\t\t\t\t\t\$this->table->\$uniqeField = \$this->generateUniqe(\$uniqeField,\$this->table->\$uniqeField);";
$batchcopy[] = "\t\t\t\t}";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Reset the ID because we are making a copy";
$batchcopy[] = "\t\t\t\$this->table->id = 0;";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " TODO: Deal with ordering?";
$batchcopy[] = "\t\t\t//" . $this->setLine(__LINE__) . " \$this->table->ordering\t= 1;";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Check the row.";
$batchcopy[] = "\t\t\tif (!\$this->table->check())";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t\$this->setError(\$this->table->getError());";
$batchcopy[] = PHP_EOL . "\t\t\t\treturn false;";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = PHP_EOL . "\t\t\tif (!empty(\$this->type))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Store the row.";
$batchcopy[] = "\t\t\tif (!\$this->table->store())";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t\$this->setError(\$this->table->getError());";
$batchcopy[] = PHP_EOL . "\t\t\t\treturn false;";
$batchcopy[] = "\t\t\t}";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the new item ID";
$batchcopy[] = "\t\t\t\$newId = \$this->table->get('id');";
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Add the new ID to the array";
$batchcopy[] = "\t\t\t\$newIds[\$pk] = \$newId;";
$batchcopy[] = "\t\t}";
$batchcopy[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Clean the cache";
$batchcopy[] = "\t\t\$this->cleanCache();";
$batchcopy[] = PHP_EOL . "\t\treturn \$newIds;";
$batchcopy[] = "\t}";
return PHP_EOL . implode(PHP_EOL, $batchcopy);
}
public function setAliasTitleFix($viewName_single)
{
$fixUniqe = array();
// only load this if these two items are set
if (array_key_exists($viewName_single, $this->aliasBuilder) && array_key_exists($viewName_single, $this->titleBuilder))
{
// set needed defaults
$setCategory = false;
$alias = $this->aliasBuilder[$viewName_single];
$title = $this->titleBuilder[$viewName_single];
$VIEW = ComponentbuilderHelper::safeString($viewName_single, 'U');
if (array_key_exists($viewName_single, $this->catCodeBuilder))
{
$category = $this->catCodeBuilder[$viewName_single]['code'];
$setCategory = true;
}
// start building the fix
$fixUniqe[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the " . $title . " for save as copy";
$fixUniqe[] = "\t\tif (\$input->get('task') === 'save2copy')";
$fixUniqe[] = "\t\t{";
$fixUniqe[] = "\t\t\t\$origTable = clone \$this->getTable();";
$fixUniqe[] = "\t\t\t\$origTable->load(\$input->getInt('id'));";
$fixUniqe[] = PHP_EOL . "\t\t\tif (\$data['" . $title . "'] == \$origTable->" . $title . ")";
$fixUniqe[] = "\t\t\t{";
if ($setCategory)
{
$fixUniqe[] = "\t\t\t\tlist(\$" . $title . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], \$data['" . $title . "']);";
}
else
{
$fixUniqe[] = "\t\t\t\tlist(\$" . $title . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], \$data['" . $title . "']);";
}
$fixUniqe[] = "\t\t\t\t\$data['" . $title . "'] = \$" . $title . ";";
$fixUniqe[] = "\t\t\t\t\$data['" . $alias . "'] = \$" . $alias . ";";
$fixUniqe[] = "\t\t\t}";
$fixUniqe[] = "\t\t\telse";
$fixUniqe[] = "\t\t\t{";
$fixUniqe[] = "\t\t\t\tif (\$data['" . $alias . "'] == \$origTable->" . $alias . ")";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$data['" . $alias . "'] = '';";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = "\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\$data['published'] = 0;";
$fixUniqe[] = "\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Automatic handling of " . $alias . " for empty fields";
$fixUniqe[] = "\t\tif (in_array(\$input->get('task'), array('apply', 'save', 'save2new')) && (int) \$input->get('id') == 0)";
$fixUniqe[] = "\t\t{";
$fixUniqe[] = "\t\t\tif (\$data['" . $alias . "'] == null)";
$fixUniqe[] = "\t\t\t{";
$fixUniqe[] = "\t\t\t\tif (JFactory::getConfig()->get('unicodeslugs') == 1)";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$data['" . $alias . "'] = JFilterOutput::stringURLUnicodeSlug(\$data['" . $title . "']);";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = "\t\t\t\telse";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$data['" . $alias . "'] = JFilterOutput::stringURLSafe(\$data['" . $title . "']);";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\t\$table = JTable::getInstance('" . $viewName_single . "', '" . $this->fileContentStatic['###component###'] . "Table');";
if ($setCategory)
{
$fixUniqe[] = PHP_EOL . "\t\t\t\tif (\$table->load(array('" . $alias . "' => \$data['" . $alias . "'], '" . $category . "' => \$data['" . $category . "'])) && (\$table->id != \$data['id'] || \$data['id'] == 0))";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$msg = JText:" . ":_('COM_" . $this->fileContentStatic['###COMPONENT###'] . "_" . $VIEW . "_SAVE_WARNING');";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\tlist(\$" . $title . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], \$data['" . $title . "']);";
}
else
{
$fixUniqe[] = PHP_EOL . "\t\t\t\tif (\$table->load(array('" . $alias . "' => \$data['" . $alias . "'])) && (\$table->id != \$data['id'] || \$data['id'] == 0))";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$msg = JText:" . ":_('COM_" . $this->fileContentStatic['###COMPONENT###'] . "_" . $VIEW . "_SAVE_WARNING');";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\tlist(\$" . $title . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], \$data['" . $title . "']);";
}
$fixUniqe[] = "\t\t\t\t\$data['" . $alias . "'] = \$" . $alias . ";";
$fixUniqe[] = PHP_EOL . "\t\t\t\tif (isset(\$msg))";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\tJFactory::getApplication()->enqueueMessage(\$msg, 'warning');";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = "\t\t\t}";
$fixUniqe[] = "\t\t}";
}
// handel other uniqe fields
$fixUniqe[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the uniqe field for save as copy";
$fixUniqe[] = "\t\tif (\$input->get('task') === 'save2copy')";
$fixUniqe[] = "\t\t{";
$fixUniqe[] = "\t\t\t//" . $this->setLine(__LINE__) . " Automatic handling of other uniqe fields";
$fixUniqe[] = "\t\t\t\$uniqeFields = \$this->getUniqeFields();";
$fixUniqe[] = "\t\t\tif (" . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$uniqeFields))";
$fixUniqe[] = "\t\t\t{";
$fixUniqe[] = "\t\t\t\tforeach (\$uniqeFields as \$uniqeField)";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$data[\$uniqeField] = \$this->generateUniqe(\$uniqeField,\$data[\$uniqeField]);";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = "\t\t\t}";
$fixUniqe[] = "\t\t}";
return PHP_EOL . implode(PHP_EOL, $fixUniqe);
}
public function setGenerateNewTitle($viewName_single)
{
// if category is added to this view then do nothing
if (array_key_exists($viewName_single, $this->aliasBuilder) && array_key_exists($viewName_single, $this->titleBuilder))
{
$newFunction = array();
$newFunction[] = PHP_EOL . PHP_EOL . "\t/**";
$newFunction[] = "\t* Method to change the title & alias.";
$newFunction[] = "\t*";
$newFunction[] = "\t* @param string \$alias The alias.";
$newFunction[] = "\t* @param string \$title The title.";
$newFunction[] = "\t*";
$newFunction[] = "\t* @return array Contains the modified title and alias.";
$newFunction[] = "\t*";
$newFunction[] = "\t*/";
$newFunction[] = "\tprotected function _generateNewTitle(\$alias, \$title)";
$newFunction[] = "\t{";
$newFunction[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the title & alias";
$newFunction[] = "\t\t\$table = \$this->getTable();";
$newFunction[] = PHP_EOL . "\t\twhile (\$table->load(array('alias' => \$alias)))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$title = JString::increment(\$title);";
$newFunction[] = "\t\t\t\$alias = JString::increment(\$alias, 'dash');";
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL . "\t\treturn array(\$title, \$alias);";
$newFunction[] = "\t}";
return implode(PHP_EOL, $newFunction);
}
elseif (array_key_exists($viewName_single, $this->titleBuilder))
{
$newFunction = array();
$newFunction[] = PHP_EOL . PHP_EOL . "\t/**";
$newFunction[] = "\t* Method to change the title & alias.";
$newFunction[] = "\t*";
$newFunction[] = "\t* @param string \$title The title.";
$newFunction[] = "\t*";
$newFunction[] = "\t* @return array Contains the modified title and alias.";
$newFunction[] = "\t*";
$newFunction[] = "\t*/";
$newFunction[] = "\tprotected function _generateNewTitle(\$title)";
$newFunction[] = "\t{";
$newFunction[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the title";
$newFunction[] = "\t\t\$table = \$this->getTable();";
$newFunction[] = PHP_EOL . "\t\twhile (\$table->load(array('title' => \$title)))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$title = JString::increment(\$title);";
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL . "\t\treturn \$title;";
$newFunction[] = "\t}";
return implode(PHP_EOL, $newFunction);
}
return '';
}
public function setInstall()
{
if (isset($this->queryBuilder) && ComponentbuilderHelper::checkArray($this->queryBuilder))
{
// set the main db prefix
$component = $this->fileContentStatic['###component###'];
// start building the db
$db = '';
foreach ($this->queryBuilder as $view => $fields)
{
// build the uninstall array
$this->uninstallBuilder[] = "DROP TABLE IF EXISTS `#__" . $component . "_" . $view . "`;";
// setup the table DB string
$db_ = '';
$db_ .= "CREATE TABLE IF NOT EXISTS `#__" . $component . "_" . $view . "` (";
// check if the table name has changed
if (isset($this->updateSQL['table_name']) && isset($this->updateSQL['table_name'][$view]))
{
$old_table_name = $this->updateSQL['table_name'][$view]['old'];
$this->updateSQLBuilder["RENAMETABLE`#__" . $component . "_" . $old_table_name . "`"] = "RENAME TABLE `#__" . $component . "_" . $old_table_name . "` to `#__" . $component . "_" . $view . "`;";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['id']))
{
$db_ .= PHP_EOL . "\t`id` INT(11) NOT NULL AUTO_INCREMENT,";
}
$db_ .= PHP_EOL . "\t`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',";
ksort($fields);
$last_name = 'asset_id';
foreach ($fields as $field => $data)
{
// set default
$default = $data['default'];
if ($default === 'Other')
{
$default = $data['other'];
}
if ($default === 'EMPTY')
{
$default = $data['null_switch'];
}
elseif ($default === 'DATETIME' || $default === 'CURRENT_TIMESTAMP')
{
$default = $default . ' ' . $data['null_switch'];
}
elseif ($default == 0 || $default)
{
if (is_numeric($default))
{
$default = $data['null_switch'] . " DEFAULT " . $default;
}
else
{
$default = $data['null_switch'] . " DEFAULT '" . $default . "'";
}
}
elseif ($data['null_switch'] === 'NULL')
{
$default = "DEFAULT NULL";
}
else
{
$default = $data['null_switch'] . " DEFAULT ''";
}
// set the lenght
$lenght = '';
if (isset($data['lenght']) && $data['lenght'] === 'Other' && isset($data['lenght_other']) && $data['lenght_other'] > 0)
{
$lenght = '(' . $data['lenght_other'] . ')';
}
elseif (isset($data['lenght']) && $data['lenght'] > 0)
{
$lenght = '(' . $data['lenght'] . ')';
}
// set the field to db
$db_ .= PHP_EOL . "\t`" . $field . "` " . $data['type'] . $lenght . " " . $default . ",";
// check if this a new field that should be added via SQL update
if (isset($this->addSQL['field']) && isset($this->addSQL['field'][$view]) && ComponentbuilderHelper::checkArray($this->addSQL['field'][$view]) && in_array($data['ID'], $this->addSQL['field'][$view]))
{
$this->updateSQLBuilder["ALTERTABLE`#__" . $component . "_" . $view . "`ADD`" . $field . "`"] = "ALTER TABLE `#__" . $component . "_" . $view . "` ADD `" . $field . "` " . $data['type'] . $lenght . " " . $default . " AFTER `" . $last_name . "`;";
}
// check if the field has changed name and/or data type and lenght
elseif ((isset($this->updateSQL['field.datatype']) && isset($this->updateSQL['field.datatype'][$view . '.' . $field])) ||
(isset($this->updateSQL['field.lenght']) && isset($this->updateSQL['field.lenght'][$view . '.' . $field])) ||
(isset($this->updateSQL['field.name']) && isset($this->updateSQL['field.name'][$view . '.' . $field])))
{
// if the name changed
if (isset($this->updateSQL['field.name']) && isset($this->updateSQL['field.name'][$view . '.' . $field]))
{
$oldName = $this->updateSQL['field.name'][$view . '.' . $field]['old'];
}
else
{
$oldName = $field;
}
// now set the update SQL
$this->updateSQLBuilder["ALTERTABLE`#__" . $component . "_" . $view . "`CHANGE`" . $oldName . "``" . $field . "`"] = "ALTER TABLE `#__" . $component . "_" . $view . "` CHANGE `" . $oldName . "` `" . $field . "` " . $data['type'] . $lenght . " " . $default . ";";
}
// be sure to track the last name used :)
$last_name = $field;
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['params']))
{
$db_ .= PHP_EOL . "\t`params` text NOT NULL DEFAULT '',";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['published']))
{
$db_ .= PHP_EOL . "\t`published` TINYINT(3) NOT NULL DEFAULT 1,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['created_by']))
{
$db_ .= PHP_EOL . "\t`created_by` INT(10) unsigned NOT NULL DEFAULT 0,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['modified_by']))
{
$db_ .= PHP_EOL . "\t`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['created']))
{
$db_ .= PHP_EOL . "\t`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['modified']))
{
$db_ .= PHP_EOL . "\t`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['checked_out']))
{
$db_ .= PHP_EOL . "\t`checked_out` int(11) unsigned NOT NULL DEFAULT 0,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['checked_out_time']))
{
$db_ .= PHP_EOL . "\t`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['version']))
{
$db_ .= PHP_EOL . "\t`version` INT(10) unsigned NOT NULL DEFAULT 1,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['hits']))
{
$db_ .= PHP_EOL . "\t`hits` INT(10) unsigned NOT NULL DEFAULT 0,";
}
// check if view has access
if (isset($this->accessBuilder[$view]) && ComponentbuilderHelper::checkString($this->accessBuilder[$view]))
{
$db_ .= PHP_EOL . "\t`access` INT(10) unsigned NOT NULL DEFAULT 0,";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['ordering']))
{
$db_ .= PHP_EOL . "\t`ordering` INT(11) NOT NULL DEFAULT 0,";
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$view]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view]))
{
$db_ .= PHP_EOL . "\t`metakey` TEXT NOT NULL DEFAULT '',";
$db_ .= PHP_EOL . "\t`metadesc` TEXT NOT NULL DEFAULT '',";
$db_ .= PHP_EOL . "\t`metadata` TEXT NOT NULL DEFAULT '',";
}
$db_ .= PHP_EOL . "\tPRIMARY KEY (`id`)";
if (isset($this->dbUniqueKeys[$view]) && ComponentbuilderHelper::checkArray($this->dbUniqueKeys[$view]))
{
foreach ($this->dbUniqueKeys[$view] as $nr => $key)
{
$db_ .= "," . PHP_EOL . "\tUNIQUE KEY `idx_" . $key . "` (`" . $key . "`)";
}
}
// check if view has access
if (isset($this->accessBuilder[$view]) && ComponentbuilderHelper::checkString($this->accessBuilder[$view]))
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_access` (`access`)";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['checked_out']))
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_checkout` (`checked_out`)";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['created_by']))
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_createdby` (`created_by`)";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['modified_by']))
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_modifiedby` (`modified_by`)";
}
// check if default field was over written
if (!isset($this->fieldsNames[$view]['published']))
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_state` (`published`)";
}
if (isset($this->dbKeys[$view]) && ComponentbuilderHelper::checkArray($this->dbKeys[$view]))
{
foreach ($this->dbKeys[$view] as $nr => $key)
{
$db_ .= "," . PHP_EOL . "\tKEY `idx_" . $key . "` (`" . $key . "`)";
}
}
$db_ .= PHP_EOL . ") ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";
// check if this is a new table that should be added via update SQL
if (isset($this->addSQL['adminview']) && ComponentbuilderHelper::checkArray($this->addSQL['adminview']) && in_array($view, $this->addSQL['adminview']))
{
// build the update array
$this->updateSQLBuilder["CREATETABLEIFNOTEXISTS`#__" . $component . "_" . $view . "`"] = $db_;
}
// add to main DB string
$db .= $db_ . PHP_EOL . PHP_EOL;
}
// add custom sql dump to the file
if (isset($this->customScriptBuilder['sql']) && ComponentbuilderHelper::checkArray($this->customScriptBuilder['sql']))
{
foreach ($this->customScriptBuilder['sql'] as $for => $customSql)
{
$placeholders = array('[[[component]]]' => $component, '[[[view]]]' => $for);
$db .= $this->setPlaceholders($customSql, $placeholders) . PHP_EOL . PHP_EOL;
}
}
return $db;
}
return '';
}
public function setUninstall()
{
if (isset($this->queryBuilder) && ComponentbuilderHelper::checkArray($this->queryBuilder))
{
$bd = '';
foreach ($this->uninstallBuilder as $line)
{
$bd .= $line . PHP_EOL;
}
return $bd;
}
return '';
}
public function setLangAdmin()
{
// add final list of needed lang strings
$componentName = JFilterOutput::cleanText($this->componentData->name);
$this->langContent['adminsys'][$this->langPrefix] = $componentName;
$this->langContent['adminsys'][$this->langPrefix . '_CONFIGURATION'] = $componentName . ' Configuration';
$this->langContent['admin'][$this->langPrefix] = $componentName;
$this->langContent['admin'][$this->langPrefix . '_BACK'] = 'Back';
$this->langContent['admin'][$this->langPrefix . '_DASH'] = 'Dashboard';
$this->langContent['admin'][$this->langPrefix . '_VERSION'] = 'Version';
$this->langContent['admin'][$this->langPrefix . '_DATE'] = 'Date';
$this->langContent['admin'][$this->langPrefix . '_AUTHOR'] = 'Author';
$this->langContent['admin'][$this->langPrefix . '_WEBSITE'] = 'Website';
$this->langContent['admin'][$this->langPrefix . '_LICENSE'] = 'License';
$this->langContent['admin'][$this->langPrefix . '_CONTRIBUTORS'] = 'Contributors';
$this->langContent['admin'][$this->langPrefix . '_CONTRIBUTOR'] = 'Contributor';
$this->langContent['admin'][$this->langPrefix . '_DASHBOARD'] = $componentName . ' Dashboard';
$this->langContent['admin'][$this->langPrefix . '_SAVE_SUCCESS'] = "Great! Item successfully saved.";
$this->langContent['admin'][$this->langPrefix . '_SAVE_WARNING'] = "The value already existed so please select another.";
$this->langContent['admin'][$this->langPrefix . '_HELP_MANAGER'] = "Help";
$this->langContent['admin'][$this->langPrefix . '_NEW'] = "New";
$this->langContent['admin'][$this->langPrefix . '_CLOSE_NEW'] = "Close & New";
$this->langContent['admin'][$this->langPrefix . '_CREATE_NEW_S'] = "Create New %s";
$this->langContent['admin'][$this->langPrefix . '_EDIT_S'] = "Edit %s";
$this->langContent['admin'][$this->langPrefix . '_KEEP_ORIGINAL_STATE'] = "- Keep Original State -";
$this->langContent['admin'][$this->langPrefix . '_KEEP_ORIGINAL_ACCESS'] = "- Keep Original Access -";
$this->langContent['admin'][$this->langPrefix . '_KEEP_ORIGINAL_CATEGORY'] = "- Keep Original Category -";
$this->langContent['admin'][$this->langPrefix . '_PUBLISHED'] = 'Published';
$this->langContent['admin'][$this->langPrefix . '_INACTIVE'] = 'Inactive';
$this->langContent['admin'][$this->langPrefix . '_ARCHIVED'] = 'Archived';
$this->langContent['admin'][$this->langPrefix . '_TRASHED'] = 'Trashed';
$this->langContent['admin'][$this->langPrefix . '_NO_ACCESS_GRANTED'] = "No Access Granted!";
$this->langContent['admin'][$this->langPrefix . '_NOT_FOUND_OR_ACCESS_DENIED'] = "Not found or access denied!";
if ($this->componentData->add_license && $this->componentData->license_type == 3)
{
$this->langContent['admin']['NIE_REG_NIE'] = "
License not set for " . $componentName . ".
Notify your administrator! The license can be obtained from " . $this->componentData->companyname . ".
";
}
// add the langug files needed to import and export data
if ($this->addEximport)
{
$this->langContent['admin'][$this->langPrefix . '_EXPORT_FAILED'] = "Export Failed";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FAILED'] = "Import Failed";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_TITLE'] = "Data Importer";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_NO_IMPORT_TYPE_FOUND'] = "Import type not found.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'] = "Package to import not found.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_ERROR'] = "Import error.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_SUCCESS'] = "Great! Import successful.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_WARNIMPORTFILE'] = "Warning, import file error.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_NO_FILE_SELECTED'] = "No import file selected.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_PLEASE_SELECT_A_FILE'] = "Please select a file to import.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_PLEASE_SELECT_ALL_COLUMNS'] = "Please link all columns.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_PLEASE_SELECT_A_DIRECTORY'] = "Please enter the file directory.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_WARNIMPORTUPLOADERROR'] = "Warning, import upload error.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'] = "Please enter the file directory.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'] = "Path does not have a valid file.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'] = "Does not have a valid file type.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_ENTER_A_URL'] = "Please enter a url.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_MSG_INVALID_URL'] = "Invalid url.";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_CONTINUE'] = "Continue";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FROM_UPLOAD'] = "Upload";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_SELECT_FILE'] = "Select File";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_UPLOAD_BOTTON'] = "Upload File";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FROM_DIRECTORY'] = "Directory";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_SELECT_FILE_DIRECTORY'] = "Set the path to file";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_GET_BOTTON'] = "Get File";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FROM_URL'] = "URL";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_SELECT_FILE_URL'] = "Enter file URL";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_UPDATE_DATA'] = "Import Data";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FORMATS_ACCEPTED'] = "formats accepted";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_LINK_FILE_TO_TABLE_COLUMNS'] = "Link File to Table Columns";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_TABLE_COLUMNS'] = "Table Columns";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_FILE_COLUMNS'] = "File Columns";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_PLEASE_SELECT_COLUMN'] = "-- Please Select Column --";
$this->langContent['admin'][$this->langPrefix . '_IMPORT_IGNORE_COLUMN'] = "-- Ignore This Column --";
}
// check if the both array is set
if (isset($this->langContent['both']) && ComponentbuilderHelper::checkArray($this->langContent['both']))
{
foreach ($this->langContent['both'] as $keylang => $langval)
{
$this->langContent['admin'][$keylang] = $langval;
}
}
// check if the both admin array is set
if (isset($this->langContent['bothadmin']) && ComponentbuilderHelper::checkArray($this->langContent['bothadmin']))
{
foreach ($this->langContent['bothadmin'] as $keylang => $langval)
{
$this->langContent['admin'][$keylang] = $langval;
}
}
if (isset($this->langContent['admin']) && ComponentbuilderHelper::checkArray($this->langContent['admin']))
{
ksort($this->langContent['admin']);
// load to global languages
$this->languages['en-GB']['admin'] = $this->langContent['admin'];
// remove tmp array
unset($this->langContent['admin']);
return true;
}
return false;
}
public function setLangSite()
{
// add final list of needed lang strings
$this->langContent['site'][$this->langPrefix] = ComponentbuilderHelper::safeString($this->componentData->name, 'W');
// some more defaults
$this->langContent['site']['JTOOLBAR_APPLY'] = "Save";
$this->langContent['site']['JTOOLBAR_SAVE_AS_COPY'] = "Save as Copy";
$this->langContent['site']['JTOOLBAR_SAVE'] = "Save & Close";
$this->langContent['site']['JTOOLBAR_SAVE_AND_NEW'] = "Save & New";
$this->langContent['site']['JTOOLBAR_CANCEL'] = "Cancel";
$this->langContent['site']['JTOOLBAR_CLOSE'] = "Close";
$this->langContent['site']['JTOOLBAR_HELP'] = "Help";
$this->langContent['site']['JGLOBAL_FIELD_ID_LABEL'] = "ID";
$this->langContent['site']['JGLOBAL_FIELD_ID_DESC'] = "Record number in the database.";
$this->langContent['site']['JGLOBAL_FIELD_MODIFIED_LABEL'] = "Modified Date";
$this->langContent['site']['COM_CONTENT_FIELD_MODIFIED_DESC'] = "The last date this item was modified.";
$this->langContent['site']['JGLOBAL_FIELD_MODIFIED_BY_LABEL'] = "Modified By";
$this->langContent['site']['JGLOBAL_FIELD_MODIFIED_BY_DESC'] = "The user who did the last modification.";
$this->langContent['site'][$this->langPrefix . '_NEW'] = "New";
$this->langContent['site'][$this->langPrefix . '_CREATE_NEW_S'] = "Create New %s";
$this->langContent['site'][$this->langPrefix . '_EDIT_S'] = "Edit %s";
$this->langContent['site'][$this->langPrefix . '_NO_ACCESS_GRANTED'] = "No Access Granted!";
$this->langContent['site'][$this->langPrefix . '_NOT_FOUND_OR_ACCESS_DENIED'] = "Not found or access denied!";
// check if the both array is set
if (isset($this->langContent['both']) && ComponentbuilderHelper::checkArray($this->langContent['both']))
{
foreach ($this->langContent['both'] as $keylang => $langval)
{
$this->langContent['site'][$keylang] = $langval;
}
}
// check if the both site array is set
if (isset($this->langContent['bothsite']) && ComponentbuilderHelper::checkArray($this->langContent['bothsite']))
{
foreach ($this->langContent['bothsite'] as $keylang => $langval)
{
$this->langContent['site'][$keylang] = $langval;
}
}
if (isset($this->langContent['site']) && ComponentbuilderHelper::checkArray($this->langContent['site']))
{
ksort($this->langContent['site']);
// load to global languages
$this->languages['en-GB']['site'] = $this->langContent['site'];
// remove tmp array
unset($this->langContent['site']);
return true;
}
return false;
}
public function setLangSiteSys()
{
// add final list of needed lang strings
$this->langContent['sitesys'][$this->langPrefix] = ComponentbuilderHelper::safeString($this->componentData->name, 'W');
$this->langContent['sitesys'][$this->langPrefix . '_NO_ACCESS_GRANTED'] = "No Access Granted!";
$this->langContent['sitesys'][$this->langPrefix . '_NOT_FOUND_OR_ACCESS_DENIED'] = "Not found or access denied!";
// check if the both site array is set
if (isset($this->langContent['bothsite']) && ComponentbuilderHelper::checkArray($this->langContent['bothsite']))
{
foreach ($this->langContent['bothsite'] as $keylang => $langval)
{
$this->langContent['sitesys'][$keylang] = $langval;
}
}
if (isset($this->langContent['sitesys']) && ComponentbuilderHelper::checkArray($this->langContent['sitesys']))
{
ksort($this->langContent['sitesys']);
// load to global languages
$this->languages['en-GB']['sitesys'] = $this->langContent['sitesys'];
// remove tmp array
unset($this->langContent['sitesys']);
return true;
}
return false;
}
public function setLangAdminSys()
{
// check if the both admin array is set
if (isset($this->langContent['bothadmin']) && ComponentbuilderHelper::checkArray($this->langContent['bothadmin']))
{
foreach ($this->langContent['bothadmin'] as $keylang => $langval)
{
$this->langContent['adminsys'][$keylang] = $langval;
}
}
if (isset($this->langContent['adminsys']) && ComponentbuilderHelper::checkArray($this->langContent['adminsys']))
{
ksort($this->langContent['adminsys']);
// load to global languages
$this->languages['en-GB']['adminsys'] = $this->langContent['adminsys'];
// remove tmp array
unset($this->langContent['adminsys']);
return true;
}
return false;
}
public function setCustomAdminViewListLink($view, $viewName_list)
{
if (isset($this->componentData->custom_admin_views) && ComponentbuilderHelper::checkArray($this->componentData->custom_admin_views))
{
foreach ($this->componentData->custom_admin_views as $custom_admin_view)
{
if (isset($custom_admin_view['adminviews']) && ComponentbuilderHelper::checkArray($custom_admin_view['adminviews']))
{
foreach ($custom_admin_view['adminviews'] as $adminview)
{
if (isset($view['adminview']) && $view['adminview'] == $adminview)
{
// set the needed keys
$setId = false;
if (ComponentbuilderHelper::checkArray($custom_admin_view['settings']->main_get->filter))
{
foreach ($custom_admin_view['settings']->main_get->filter as $filter)
{
if ($filter['filter_type'] == 1 || '$id' == $filter['state_key'])
{
$setId = true;
}
}
}
// set the needed array values
$set = array(
'icon' => $custom_admin_view['icomoon'],
'link' => $custom_admin_view['settings']->code,
'NAME' => $custom_admin_view['settings']->CODE,
'name' => $custom_admin_view['settings']->name);
// only load to list if it has id filter
if ($setId)
{
// now load it to the global object for items list
$this->customAdminViewListLink[$viewName_list][] = $set;
// add to set id for list view if needed
$this->customAdminViewListId[$custom_admin_view['settings']->code] = true;
}
else
{
// now load it to the global object for tool bar
$this->customAdminDynamicButtons[$viewName_list][] = $set;
}
// log that it has been added already
$this->customAdminAdded[$custom_admin_view['settings']->code] = $adminview;
}
}
}
}
}
}
public function setListBody($viewName_single, $viewName_list)
{
if (isset($this->listBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listBuilder[$viewName_list]))
{
// component helper name
$Helper = $this->fileContentStatic['###Component###'] . 'Helper';
// setup correct core target
$coreLoad = false;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
$coreLoad = true;
}
// make sure the custom links are only added once
$firstTimeBeingAdded = true;
// add the default
$body = "items as \$i => \$item): ?>";
$body .= PHP_EOL . "\tuser->authorise('core.manage', 'com_checkin') || \$item->checked_out == \$this->user->id || \$item->checked_out == 0;";
$body .= PHP_EOL . "\t\t\$userChkOut = JFactory::getUser(\$item->checked_out);";
$body .= PHP_EOL . "\t\t\$canDo = " . $Helper . "::getActions('" . $viewName_single . "',\$item,'" . $viewName_list . "');";
$body .= PHP_EOL . "\t?>";
$body .= PHP_EOL . "\t" . '
';
// only load if not over written
if (!isset($this->fieldsNames[$viewName_single]['ordering']))
{
$body .= PHP_EOL . "\t\t" . '
";
$add = false;
}
else
{
// start building the links
$link = '&id=id; ?>';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customAdminViewListLink[$viewName_list]) && $firstTimeBeingAdded)
{
// make sure the custom links are only added once
$firstTimeBeingAdded = false;
// start building the links
$customAdminView = PHP_EOL . "\t\t\t" . '
';
}
// now build the template
foreach ($bucket as $tabCodeName => $posions)
{
// check main if both left and right is set
$lrCounter = $posions['lr'];
// get lang string
$tabLangName = $posions['lang'];
// build main center
$main = '';
$mainbottom = '';
foreach ($posions as $posion => $string)
{
if ($lrCounter == 2)
{
switch ($posion)
{
case 1: // left
case 2: // right
$main .= PHP_EOL . "\t\t\t" . '
';
break;
}
}
// set acctive tab
if ($tabCounter == 0)
{
$body .= PHP_EOL . PHP_EOL . "\t '" . $tabCodeName . "')); ?>";
}
// if this is a linked view set permissions
$closeIT = false;
if (isset($linkedViewIdentifier) && ComponentbuilderHelper::checkArray($linkedViewIdentifier) && in_array($tabCodeName, $linkedViewIdentifier))
{
// get view name
$linkedViewId = array_search($tabCodeName, $linkedViewIdentifier);
$linkedViewData = $this->getAdminViewData($linkedViewId);
$linkedCodeName = ComponentbuilderHelper::safeString($linkedViewData->name_single);
// setup correct core target
$coreLoadLinked = false;
if (isset($this->permissionCore[$linkedCodeName]))
{
$coreLinked = $this->permissionCore[$linkedCodeName];
$coreLoadLinked = true;
}
// check if the item has permissions.
if ($coreLoadLinked && isset($coreLinked['core.access']) && isset($this->permissionBuilder['global'][$coreLinked['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$coreLinked['core.access']]) && in_array($linkedCodeName, $this->permissionBuilder['global'][$coreLinked['core.access']]))
{
$body .= PHP_EOL . PHP_EOL . "\tcanDo->get('" . $coreLinked['core.access'] . "')) : ?>";
$closeIT = true;
}
else
{
$body .= PHP_EOL;
}
// insure clear
unset($coreLoadLinked, $coreLinked, $linkedViewData);
}
else
{
$body .= PHP_EOL;
}
// start tab
$body .= PHP_EOL . "\t";
// add the main
$body .= PHP_EOL . "\t\t" . '
';
$body .= $main;
$body .= PHP_EOL . "\t\t
";
if (strlen($mainbottom) > 0)
{
// add the main bottom
$body .= PHP_EOL . "\t\t" . '
';
$body .= $mainbottom;
$body .= PHP_EOL . "\t\t
";
}
$body .= PHP_EOL . "\t";
if ($closeIT)
{
$body .= PHP_EOL . "\t";
}
// set counter
$tabCounter++;
}
// set default publishing tab lang
$tabLangName = $langView . '_PUBLISHING';
// add to lang array
if (!isset($this->langContent[$this->lang][$tabLangName]))
{
$this->langContent[$this->lang][$tabLangName] = 'Publishing';
}
// the default publishing items
$items = array('left' => array(), 'right' => array());
// Setup the default (custom) fields
// only load (1 => 'left', 2 => 'right')
$fieldsAddedRight = false;
if (isset($this->newPublishingFields[$viewName_single]))
{
foreach ($this->newPublishingFields[$viewName_single] as $df_alignment => $df_items)
{
foreach ($df_items as $df_order => $df_name)
{
if ($df_alignment == 2 || $df_alignment == 1)
{
$items[$alignmentNames[$df_alignment]][$df_order] = $df_name;
}
else
{
$this->app->enqueueMessage(JText::sprintf('Your %s field could not be added, since the %s alignment position is not available in the %s (publishing) tab. Please only target Left or right in the publishing tab.', $df_name, $alignmentNames[$df_alignment], $viewName_single), 'warning');
}
}
}
// set switch to trigger notice if custom fields added to right
if (ComponentbuilderHelper::checkArray($items['right']))
{
$fieldsAddedRight = true;
}
}
// load all defaults
$loadDefaultFields = array(
'left' => array('created', 'created_by', 'modified', 'modified_by'),
'right' => array('published', 'ordering', 'access', 'version', 'hits', 'id')
);
foreach ($loadDefaultFields as $d_alignment => $defaultFields)
{
foreach ($defaultFields as $defaultField)
{
if (!isset($this->movedPublishingFields[$viewName_single][$defaultField]))
{
if ($defaultField != 'access')
{
$items[$d_alignment][] = $defaultField;
}
elseif ($defaultField === 'access' && isset($this->accessBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName_single]))
{
$items[$d_alignment][] = $defaultField;
}
}
}
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName_single]))
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing';
$tabCodeNameRight = 'metadata';
// the default publishing tiems
if (ComponentbuilderHelper::checkArray($items['left']) || ComponentbuilderHelper::checkArray($items['right']))
{
$items_one = '';
// load the items into one side
if (ComponentbuilderHelper::checkArray($items['left']))
{
$items_one .= "'" . implode("'," . PHP_EOL . "\t'", $items['left']) . "'";
}
if (ComponentbuilderHelper::checkArray($items['right']))
{
// there is already fields just add these
if (strlen($items_one) > 3)
{
$items_one .= "," . PHP_EOL . "\t'" . implode("'," . PHP_EOL . "\t'", $items['right']) . "'";
}
// no fields has been added yet
else
{
$items_one .= "'" . implode("'," . PHP_EOL . "\t'", $items['right']) . "'";
}
}
// only triger the info notice if there were custom fields targeted to the right alignment position.
if ($fieldsAddedRight)
{
$this->app->enqueueMessage(JText::sprintf('Your field/s added to the right alignment position in the %s (publishing) tab was added to the left. Since we have metadata fields on the right. Fields can only be loaded to the right of the publishing tab if there is no metadata fields.', $viewName_single), 'Notice');
}
// set the publishing layout
$this->setLayout($viewName_single, $tabCodeNameLeft, $items_one, 'layoutpublished');
$items_one = true;
}
else
{
$items_one = false;
}
// set the metadata layout
$this->setLayout($viewName_single, $tabCodeNameRight, false, 'layoutmetadata');
$items_two = true;
}
else
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing';
$tabCodeNameRight = 'publlshing';
// the default publishing tiems
if (ComponentbuilderHelper::checkArray($items['left']) || ComponentbuilderHelper::checkArray($items['right']))
{
// load left items that remain
if (ComponentbuilderHelper::checkArray($items['left']))
{
// load all items
$items_one = "'" . implode("'," . PHP_EOL . "\t'", $items['left']) . "'";
// set the publishing layout
$this->setLayout($viewName_single, $tabCodeNameLeft, $items_one, 'layoutpublished');
$items_one = true;
}
// load right items that remain
if (ComponentbuilderHelper::checkArray($items['right']))
{
// load all items
$items_two = "'" . implode("'," . PHP_EOL . "\t'", $items['right']) . "'";
// set the publishing layout
$this->setLayout($viewName_single, $tabCodeNameRight, $items_two, 'layoutpublished');
$items_two = true;
}
}
else
{
$items_one = false;
$items_two = false;
}
}
if ($items_one && $items_two)
{
$classs = "span6";
}
elseif ($items_one || $items_two)
{
$classs = "span12";
}
// only load this if needed
if ($items_one || $items_two)
{
// check if the item has permissions.
$publishingPer = array();
$allToBeChekced = array('core.delete', 'core.edit.created_by', 'core.edit.state', 'core.edit.created');
foreach ($allToBeChekced as $core_permission)
{
if ($coreLoad && isset($core[$core_permission]) && isset($this->permissionBuilder['global'][$core[$core_permission]]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core[$core_permission]]) && in_array($viewName_single, $this->permissionBuilder['global'][$core[$core_permission]]))
{
// set permissions.
$publishingPer[] = "\$this->canDo->get('" . $core[$core_permission] . "')";
}
else
{
// set permissions.
$publishingPer[] = "\$this->canDo->get('" . $core_permission . "')";
}
}
$body .= PHP_EOL . PHP_EOL . "\t";
// set the default publishing tab
$body .= PHP_EOL . "\t";
$body .= PHP_EOL . "\t\t" . '
";
$body .= PHP_EOL . "\t";
$body .= PHP_EOL . "\t";
}
// make sure we dont load it to a view with the name component
if ($viewName_single != 'component')
{
// set permissions tab lang
$tabLangName = $langView . '_PERMISSION';
// set permissions tab code name
$tabCodeName = 'permissions';
// add to lang array
if (!isset($this->langContent[$this->lang][$tabLangName]))
{
$this->langContent[$this->lang][$tabLangName] = 'Permissions';
}
// set the permissions tab
$body .= PHP_EOL . PHP_EOL . "\tcanDo->get('core.admin')) : ?>";
$body .= PHP_EOL . "\t";
$body .= PHP_EOL . "\t\t" . '
";
// check if left has been set
if (strlen($leftside) > 0)
{
$left = '
' . $leftside . PHP_EOL . "
";
}
else
{
$left = '';
}
// check if right has been set
if (strlen($rightside) > 0)
{
$right = '
' . $rightside . PHP_EOL . "
";
}
else
{
$right = '';
}
// set active tab and return
return $header . $left . $body . $right . $footer;
}
return '';
}
public function setFadeInEfect(&$view)
{
// check if we should load the fade in affect
if ($view['settings']->add_fadein == 1)
{
// set view name
$fadein[] = "";
$fadein[] = "
";
$add = false;
}
else
{
$link = '&id=id; ?>&ref=' . $refview . '&refid=';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customAdminViewListLink[$viewName_list]) && $firstTimeBeingAdded)
{
// make sure the custom links are only added once
$firstTimeBeingAdded = false;
// start building the links
$customAdminView = PHP_EOL . "\t\t\t" . '
';
$body .= PHP_EOL . '';
// return the build
return $body;
}
return '';
}
public function setListHeadLinked($viewName_single, $viewName_list, $addNewButon, $refview)
{
if (isset($this->listBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listBuilder[$viewName_list]))
{
// component helper name
$Helper = $this->fileContentStatic['###Component###'] . 'Helper';
$head = '';
// only add new button if set
if ($addNewButon > 0)
{
// setup correct core target
$coreLoad = false;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
$coreLoad = true;
}
// check if the item has permissions.
if ($coreLoad && isset($core['core.create']) && isset($this->permissionBuilder['global'][$core['core.create']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.create']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.create']]))
{
// set permissions.
$accessCheck = "\$can->get('" . $core['core.create'] . "')";
}
else
{
// set permissions.
$accessCheck = "\$can->get('core.create')";
}
// add a button for new
$head = '';
// make group button if needed
$tabB = "";
if ($addNewButon == 2)
{
$head .= PHP_EOL . "\t" . '
';
$tabB = "\t";
}
// add the new buttons
if ($addNewButon == 1 || $addNewButon == 2)
{
$head .= PHP_EOL . $tabB . "\t" . ' langPrefix . "_NEW'" . '); ?>';
}
// add the close and new button
if ($addNewButon == 2 || $addNewButon == 3)
{
$head .= PHP_EOL . $tabB . "\t" . ' langPrefix . "_CLOSE_NEW'" . '); ?>';
}
// close group button if needed
if ($addNewButon == 2)
{
$head .= PHP_EOL . "\t" . '
';
}
else
{
$head .= '
';
}
$head .= PHP_EOL . '' . PHP_EOL;
}
$head .= '';
// set the style for V2
$metro_blue = (2 == $this->footableVersion) ? ' metro-blue' : '';
// set the toggle for V3
$toggle = (3 == $this->footableVersion) ? ' data-show-toggle="true" data-toggle-column="first"' : '';
// set paging
$paging = (2 == $this->footableVersion) ? ' data-page-size="20" data-filter="#filter_' . $viewName_list . '"' : ' data-sorting="true" data-paging="true" data-paging-size="20" data-filtering="true"';
// add html fix for V3
$htmlFix = (3 == $this->footableVersion) ? ' data-type="html" data-sort-use="text"' : '';
$head .= PHP_EOL . '
';
$head .= PHP_EOL . "";
// main lang prefix
$langView = $this->langPrefix . '_' . ComponentbuilderHelper::safeString($viewName_single, 'U');
// set status lang
$statusLangName = $langView . '_STATUS';
// set id lang
$idLangName = $langView . '_ID';
// make sure only first link is used as togeler
$firstLink = true;
// add to lang array
if (!isset($this->langContent[$this->lang][$statusLangName]))
{
$this->langContent[$this->lang][$statusLangName] = 'Status';
}
// add to lang array
if (!isset($this->langContent[$this->lang][$idLangName]))
{
$this->langContent[$this->lang][$idLangName] = 'Id';
}
$head .= PHP_EOL . "\t
';
// set the tab to insure correct spacing
$tab = "\t\t\t";
// change the name of the main tab
$mainAccordianName = 'Control Panel';
$loadTabs = true;
}
else
{
$display[] = '