';";
$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 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,'$this->document');
}
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');";
$chart[] = "\t\t\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js');";
$chart[] = "\t\t\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js');";
return implode(PHP_EOL,$chart);
}
return '';
}
public function setUikitLoader(&$view)
{
// reset buktes
$setter = '';
$loader['css'] = array();
$loader['js'] = array();
// 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;";
// load the defaults needed
if ($this->uikit)
{
$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');";
$setter .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Set css style.";
$setter .= PHP_EOL."\t\t\$style = \$this->params->get('uikit_style');";
$setter .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." The uikit css.";
$setter .= PHP_EOL."\t\tif ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL."\t\t{";
$setter .= PHP_EOL."\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/css/uikit'.\$style.\$size.'.css');";
$setter .= PHP_EOL."\t\t}";
$setter .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." The uikit js.";
$setter .= PHP_EOL."\t\tif ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL."\t\t{";
$setter .= PHP_EOL."\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/js/uikit'.\$size.'.js');";
$setter .= PHP_EOL."\t\t}";
}
// load the components need
if ($this->uikit && isset($this->uikitComp[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->uikitComp[$view['settings']->code]))
{
$setter .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Load the script to find all uikit components needed.";
$setter .= PHP_EOL."\t\tif (\$uikit != 2)";
$setter .= PHP_EOL."\t\t{";
$setter .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Set the default uikit components in this view.";
$setter .= PHP_EOL."\t\t\t\$uikitComp = array();";
foreach ($this->uikitComp[$view['settings']->code] as $class)
{
$setter .= PHP_EOL."\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."\t\t\t//".$this->setLine(__LINE__)." Get field uikit components needed in this view.";
$setter .= PHP_EOL."\t\t\t\$uikitFieldComp = \$this->get('UikitComp');";
$setter .= PHP_EOL."\t\t\tif (isset(\$uikitFieldComp) && ".$this->fileContentStatic['###Component###']."Helper::checkArray(\$uikitFieldComp))";
$setter .= PHP_EOL."\t\t\t{";
$setter .= PHP_EOL."\t\t\t\tif (isset(\$uikitComp) && ".$this->fileContentStatic['###Component###']."Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL."\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\$uikitComp = array_merge(\$uikitComp, \$uikitFieldComp);";
$setter .= PHP_EOL."\t\t\t\t\t\$uikitComp = array_unique(\$uikitComp);";
$setter .= PHP_EOL."\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t\telse";
$setter .= PHP_EOL."\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\$uikitComp = \$uikitFieldComp;";
$setter .= PHP_EOL."\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t}";
}
$setter .= PHP_EOL."\t\t}";
$setter .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Load the needed uikit components in this view.";
$setter .= PHP_EOL."\t\tif (\$uikit != 2 && isset(\$uikitComp) && ".$this->fileContentStatic['###Component###']."Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL."\t\t{";
$setter .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." load just in case.";
$setter .= PHP_EOL."\t\t\tjimport('joomla.filesystem.file');";
$setter .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." loading...";
$setter .= PHP_EOL."\t\t\tforeach (\$uikitComp as \$class)";
$setter .= PHP_EOL."\t\t\t{";
$setter .= PHP_EOL."\t\t\t\tforeach (".$this->fileContentStatic['###Component###']."Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL."\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t//".$this->setLine(__LINE__)." check if the CSS file exists.";
$setter .= PHP_EOL."\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_".$this->fileContentStatic['###component###']."/uikit/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL."\t\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\t//".$this->setLine(__LINE__)." load the css.";
$setter .= PHP_EOL."\t\t\t\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/css/components/'.\$name.\$style.\$size.'.css');";
$setter .= PHP_EOL."\t\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t\t\t//".$this->setLine(__LINE__)." check if the JavaScript file exists.";
$setter .= PHP_EOL."\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_".$this->fileContentStatic['###component###']."/uikit/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL."\t\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\t//".$this->setLine(__LINE__)." load the js.";
$setter .= PHP_EOL."\t\t\t\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/js/components/'.\$name.\$size.'.js', 'text/javascript', true);";
$setter .= PHP_EOL."\t\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t}";
$setter .= PHP_EOL."\t\t}";
}
elseif ($this->uikit && isset($this->siteFieldData['uikit'][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->siteFieldData['uikit'][$view['settings']->code]))
{
$setter .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Load the needed uikit components in this view.";
$setter .= PHP_EOL."\t\t\$uikitComp = \$this->get('UikitComp');";
$setter .= PHP_EOL."\t\tif (\$uikit != 2 && isset(\$uikitComp) && ".$this->fileContentStatic['###Component###']."Helper::checkArray(\$uikitComp))";
$setter .= PHP_EOL."\t\t{";
$setter .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." load just in case.";
$setter .= PHP_EOL."\t\t\tjimport('joomla.filesystem.file');";
$setter .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." loading...";
$setter .= PHP_EOL."\t\t\tforeach (\$uikitComp as \$class)";
$setter .= PHP_EOL."\t\t\t{";
$setter .= PHP_EOL."\t\t\t\tforeach (".$this->fileContentStatic['###Component###']."Helper::\$uk_components[\$class] as \$name)";
$setter .= PHP_EOL."\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t//".$this->setLine(__LINE__)." check if the CSS file exists.";
$setter .= PHP_EOL."\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_".$this->fileContentStatic['###component###']."/uikit/css/components/'.\$name.\$style.\$size.'.css'))";
$setter .= PHP_EOL."\t\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\t//".$this->setLine(__LINE__)." load the css.";
$setter .= PHP_EOL."\t\t\t\t\t\t\$this->document->addStyleSheet(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/css/components/'.\$name.\$style.\$size.'.css');";
$setter .= PHP_EOL."\t\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t\t\t//".$this->setLine(__LINE__)." check if the JavaScript file exists.";
$setter .= PHP_EOL."\t\t\t\t\tif (JFile::exists(JPATH_ROOT.'/media/com_".$this->fileContentStatic['###component###']."/uikit/js/components/'.\$name.\$size.'.js'))";
$setter .= PHP_EOL."\t\t\t\t\t{";
$setter .= PHP_EOL."\t\t\t\t\t\t//".$this->setLine(__LINE__)." load the js.";
$setter .= PHP_EOL."\t\t\t\t\t\t\$this->document->addScript(JURI::root(true) .'/media/com_".$this->fileContentStatic['###component###']."/uikit/js/components/'.\$name.\$size.'.js', 'text/javascript', true);";
$setter .= PHP_EOL."\t\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t\t}";
$setter .= PHP_EOL."\t\t\t}";
$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) && '.$this->fileContentStatic['###component###'].'Helper::checkArray($this->items) && count($this->items) > 4): ?>';
$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 = file_get_contents($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 = file_get_contents($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 writeFile($path, $data)
{
return ComponentbuilderHelper::writeFile($path, $data);
}
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}";
}
}
// decryption
if ((isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) || (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view])))
{
$Component = $this->fileContentStatic['###Component###'];
if (isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view]))
{
$script .= PHP_EOL.PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Get the basic encryption.";
$script .= PHP_EOL."\t\t\t\$basickey = ".$Component."Helper::getCryptKey('basic');";
$script .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Get the encryption object.";
$script .= PHP_EOL."\t\t\t\$basic = new FOFEncryptAes(\$basickey, 128);";
foreach ($this->basicEncryptionBuilder[$view] as $baseString)
{
$script .= PHP_EOL.PHP_EOL."\t\t\tif (!empty(\$item->".$baseString.") && \$basickey && !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__)." basic decrypt data ".$baseString.".";
$script .= PHP_EOL."\t\t\t\t\$item->".$baseString." = rtrim(\$basic->decryptString(\$item->".$baseString."), ".'"\0"'.");";
$script .= PHP_EOL."\t\t\t}";
}
}
if (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view]))
{
$script .= PHP_EOL.PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Get the advanced encryption key.";
$script .= PHP_EOL."\t\t\t\$advancedkey = ".$Component."Helper::getCryptKey('advanced');";
$script .= PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Get the encryption object.";
$script .= PHP_EOL."\t\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);";
foreach ($this->advancedEncryptionBuilder[$view] as $baseString)
{
$script .= PHP_EOL.PHP_EOL."\t\t\tif (!empty(\$item->".$baseString.") && \$advancedkey && !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__)." advanced decrypt data ".$baseString.".";
$script .= PHP_EOL."\t\t\t\t\$item->".$baseString." = rtrim(\$advanced->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
if((isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) || (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view])))
{
$Component = $this->fileContentStatic['###Component###'];
if(isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view]))
{
$script .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Get the basic encryption key.";
$script .= PHP_EOL."\t\t\$basickey = ".$Component."Helper::getCryptKey('basic');";
$script .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Get the encryption object";
$script .= PHP_EOL."\t\t\$basic = new FOFEncryptAes(\$basickey, 128);";
foreach ($this->basicEncryptionBuilder[$view] as $baseString)
{
$script .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Encrypt data ".$baseString.".";
$script .= PHP_EOL."\t\tif (isset(\$data['".$baseString."']) && \$basickey)";
$script .= PHP_EOL."\t\t{";
$script .= PHP_EOL."\t\t\t\$data['".$baseString."'] = \$basic->encryptString(\$data['".$baseString."']);";
$script .= PHP_EOL."\t\t}";
}
}
if(isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view]))
{
$script .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Get the advanced encryption key.";
$script .= PHP_EOL."\t\t\$advancedkey = ".$Component."Helper::getCryptKey('advanced');";
$script .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Get the encryption object";
$script .= PHP_EOL."\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);";
foreach ($this->advancedEncryptionBuilder[$view] as $baseString)
{
$script .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Encrypt data ".$baseString.".";
$script .= PHP_EOL."\t\tif (isset(\$data['".$baseString."']) && \$advancedkey)";
$script .= PHP_EOL."\t\t{";
$script .= PHP_EOL."\t\t\t\$data['".$baseString."'] = \$advanced->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['###VERSION###']." 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 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)
{
$isCategory = '';
$viewTable = false;
if ($viewArray && ComponentbuilderHelper::checkArray($viewArray))
{
if (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....
}
// elseif (isset($viewArray['settings']->main_get->gettype) && $viewArray['settings']->main_get->gettype == 2)
// {
// $idView = false; // TODO we will keep an eye on this....
// $aliasView = false;
// }
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']);
}
}
}
}
}
}
// add if tags is added, also for all front item views
if ($aliasView)
{
// build view route switch
$routerSwitch = array();
$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;";
return implode(PHP_EOL,$routerSwitch);
}
elseif ($idView)
{
// build view route switch
$routerSwitch = array();
$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;";
return implode(PHP_EOL,$routerSwitch);
}
else
{
// build view route switch
$routerSwitch = array();
$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);
}
return '';
}
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->contentType = new JUcmType;";
$batchmove[] = "\t\t\t\$this->type = \$this->contentType->getTypeByTable(\$this->tableClassName);";
$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[] = PHP_EOL."\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[] = PHP_EOL."\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->contentType = new JUcmType;";
$batchcopy[] = "\t\t\t\$this->type = \$this->contentType->getTypeByTable(\$this->tableClassName);";
$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[] = PHP_EOL."\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[] = PHP_EOL."\t\t\tif (!\$this->user->authorise('".$core['core.edit']."', \$contexts[\$pk]))";
}
else
{
$batchcopy[] = PHP_EOL."\t\t\tif (!\$this->user->authorise('core.edit', \$contexts[\$pk]))";
}
$batchcopy[] = PHP_EOL."\t\t\t{";
$batchcopy[] = PHP_EOL."\t\t\t\t//".$this->setLine(__LINE__)." Not fatal error";
$batchcopy[] = PHP_EOL."\t\t\t\t\$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));";
$batchcopy[] = PHP_EOL."\t\t\t\tcontinue;";
$batchcopy[] = PHP_EOL."\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[] = PHP_EOL."\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[] = PHP_EOL."\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->table->".$title." = \$this->generateUniqe('".$title."',\$this->table->".$title.");";
}
$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 (0)
{
// hmmm tough one
}
// 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[$this->lang][$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.'_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';
if ($this->componentData->add_license && $this->componentData->license_type == 3)
{
$this->langContent['admin']['NIE_REG_NIE'] = "
Lincense not set for ".$componentName.".
Notify your administrator! The lincense 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 --";
$this->langContent['admin'][$this->langPrefix.'_NO_ACCESS_GRANTED'] = "No Access Granted!";
}
// 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!";
// 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!";
// 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 (ComponentbuilderHelper::checkArray($custom_admin_view['adminviews']))
{
foreach ($custom_admin_view['adminviews'] as $adminview)
{
if ($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".'
';
}
// check if the item has permissions.
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']]))
{
// set permissions.
$accessCheck = "\$canDo->get('".$core['core.edit']."')";
}
else
{
// set permissions.
$accessCheck = "\$canDo->get('core.edit')";
}
// triger the checked out script to be added
$checkoutTriger = true;
}
if ($add)
{
// set as linked
$body .= PHP_EOL."\t\t".'
";
$body .= PHP_EOL."";
// return the build
return $body;
}
return '';
}
public function setListHead($viewName_single,$viewName_list)
{
if (isset($this->listBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listBuilder[$viewName_list]))
{
// main lang prefix
$langView = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($viewName_single,'U');
// set status lang
$statusLangName = $langView.'_STATUS';
// set id lang
$idLangName = $langView.'_ID';
// 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';
}
// set default
$head = '
";
return $head;
}
return '';
}
public function setListColnr($viewName_list)
{
if (isset($this->listColnrBuilder[$viewName_list]))
{
return $this->listColnrBuilder[$viewName_list];
}
return '';
}
public function setEditBody(&$view)
{
// set view name
$viewName_single = ComponentbuilderHelper::safeString($view['settings']->name_single);
// alignment
$alignmentNames = array(1 => 'left', 2 => 'right', 3 => 'fullwidth', 4 => 'above', 5 => 'under', 6 => 'leftside', 7 => 'rightside');
// main lang prefix
$langView = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($viewName_single,'U');
if (isset($this->layoutBuilder[$viewName_single]) && ComponentbuilderHelper::checkArray($this->layoutBuilder[$viewName_single]))
{
// set the linked view tabs
$linkedTab = array();
$keys = array();
// setup correct core target
$coreLoad = false;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
$coreLoad = true;
}
if (isset($this->linkedAdminViews[$viewName_single]) && ComponentbuilderHelper::checkArray($this->linkedAdminViews[$viewName_single]))
{
foreach ($this->linkedAdminViews[$viewName_single] as $linkedView)
{
$tabName = $view['settings']->tabs[(int) $linkedView['tab']];
$this->tabCounter[$viewName_single][$linkedView['tab']] = $tabName;
$linkedTab[$linkedView['adminview']] = $linkedView['tab'];
if (ComponentbuilderHelper::checkString($linkedView['key']) && ComponentbuilderHelper::checkString($linkedView['parentkey']))
{
$keys[$linkedView['adminview']] = array( 'key' => $linkedView['key'], 'parentKey' => $linkedView['parentkey']);
}
else
{
$keys[$linkedView['adminview']] = array( 'key' => null, 'parentKey' => null);
}
if (isset($linkedView['addnew']))
{
$keys[$linkedView['adminview']]['addNewButton'] = (int) $linkedView['addnew'];
}
else
{
$keys[$linkedView['adminview']]['addNewButton'] = 0;
}
}
}
// start tab set
$bucket = array();
$leftside = '';
$rightside = '';
$footer = '';
$header = '';
$mainwidth = 12;
$sidewidth = 0;
ksort($this->tabCounter[$viewName_single]);
foreach ($this->tabCounter[$viewName_single] as $tabNr => $tabName)
{
$tabWidth = 12;
$lrCounter = 0;
// set tab lang
$tabLangName = $langView.'_'.ComponentbuilderHelper::safeString($tabName,'U');
// set tab code name
$tabCodeName = ComponentbuilderHelper::safeString($tabName);
// add to lang array
if (!isset($this->langContent[$this->lang][$tabLangName]))
{
$this->langContent[$this->lang][$tabLangName] = $tabName;
}
// check if linked view belongs to this tab
$buildLayout = true;
$linkedViewId = '';
if (ComponentbuilderHelper::checkArray($linkedTab))
{
if (($linkedViewId = array_search($tabNr, $linkedTab)) !== false)
{
// don't build
$buildLayout = false;
}
}
if ($buildLayout)
{
// sort to make sure it loads left first
$alignments = $this->layoutBuilder[$viewName_single][$tabName];
ksort($alignments);
foreach ($alignments as $alignment => $names)
{
// set layout code name
$layoutCodeName = $tabCodeName.'_'.$alignmentNames[$alignment];
// reset each time
$items = '';
$itemCounter = 0;
ksort($names);
foreach ($names as $nr => $name)
{
if ($itemCounter == 0)
{
$items .= "'".$name."'";
}
else
{
$items .= ",".PHP_EOL."\t'".$name."'";
}
$itemCounter++;
}
switch($alignment)
{
case 1: // left
case 2: // right
// count
$lrCounter++;
// set as items layout
$this->setLayout($viewName_single,$layoutCodeName,$items,'layoutitems');
// set the lang to tab
$bucket[$tabCodeName]['lang'] = $tabLangName;
// load the body
if (!isset($bucket[$tabCodeName][(int) $alignment]))
{
$bucket[$tabCodeName][(int) $alignment] = '';
}
$bucket[$tabCodeName][(int) $alignment] .= "";
break;
case 3: // fullwidth
// set as items layout
$this->setLayout($viewName_single,$layoutCodeName,$items,'layoutfull');
// set the lang to tab
$bucket[$tabCodeName]['lang'] = $tabLangName;
// load the body
if (!isset($bucket[$tabCodeName][(int) $alignment]))
{
$bucket[$tabCodeName][(int) $alignment] = '';
}
$bucket[$tabCodeName][(int) $alignment] .= "";
break;
case 4: // above
// set as title layout
$this->setLayout($viewName_single, $layoutCodeName, $items, 'layouttitle');
// load to header
$header .= PHP_EOL."\t";
break;
case 5: // under
// set as title layout
$this->setLayout($viewName_single, $layoutCodeName, $items, 'layouttitle');
// load to footer
$footer .= PHP_EOL.PHP_EOL."".PHP_EOL."";
break;
case 6: // left side
$tabWidth = $tabWidth - 2;
// set as items layout
$this->setLayout($viewName_single, $layoutCodeName, $items, 'layoutitems');
// load the body
$leftside .= PHP_EOL."\t";
break;
case 7: // right side
$tabWidth = $tabWidth - 2;
// set as items layout
$this->setLayout($viewName_single, $layoutCodeName, $items, 'layoutitems');
// load the body
$rightside .= PHP_EOL."\t";
break;
}
}
}
else
{
// set layout code name
$layoutCodeName = $tabCodeName.'_fullwidth';
// set identifiers
$linkedViewIdentifier[$linkedViewId] = $tabCodeName;
//set function name
$codeName = ComponentbuilderHelper::safeString($this->uniquekey(3).$tabCodeName);
// set as items layout
$this->setLayout($viewName_single,$layoutCodeName,$codeName,'layoutlinkedview');
// set the lang to tab
$bucket[$tabCodeName]['lang'] = $tabLangName;
// set all the linked view stuff
$this->secondRunAdmin['setLinkedView'][] = array(
'viewId' => $linkedViewId,
'viewName_single' => $viewName_single,
'codeName' => $codeName,
'layoutCodeName' => $layoutCodeName,
'key' => $keys[$linkedViewId]['key'],
'parentKey' => $keys[$linkedViewId]['parentKey'],
'addNewButon' => $keys[$linkedViewId]['addNewButton']);
// load the body
if (!isset($bucket[$tabCodeName][3]))
{
$bucket[$tabCodeName][3] = '';
}
$bucket[$tabCodeName][3] .= "";
}
// width calculator :)
if ($tabWidth == 8)
{
$mainwidth = 8;
$sidewidth = 2;
}
elseif ($tabWidth == 10 && $mainwidth != 8)
{
$mainwidth = 9;
$sidewidth = 3;
}
$bucket[$tabCodeName]['lr'] = $lrCounter;
}
// tab counter
$tabCounter = 0;
// check if width is still 12
$span = '';
if ($mainwidth != 12)
{
$span = 'span'.$mainwidth;
}
// start building body
$body = PHP_EOL.'
';
if (ComponentbuilderHelper::checkString($span))
{
$body .= PHP_EOL."\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".'
';
}
// check if the item has permissions.
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']]))
{
// set permissions.
$accessCheck = "\$canDo->get('".$core['core.edit']."')";
}
else
{
// set permissions.
$accessCheck = "\$canDo->get('core.edit')";
}
// triger the checked out script to be added
$checkoutTriger = true;
}
if ($add)
{
// set as linked
$body .= PHP_EOL."\t\t".'
';
$body .= PHP_EOL.'';
// return the build
return $body;
}
return '';
}
public function setListHeadLinked($viewName_single,$viewName_list,$addNewButon)
{
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)
{
// 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 = '';
$head .= PHP_EOL."\t".' langPrefix."_NEW'".'); ?>
';
$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 controller for data hiding options
$controller = 1;
// build the dynamic fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="phone"':' data-breakpoints="xs sm"';
if ($controller > 3)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"';
}
if ($controller > 6)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="all"':' data-breakpoints="all"';
}
if ($item['link'] && $firstLink)
{
$setin = (2 == $this->footableVersion) ? ' data-toggle="true"':'';
$firstLink = false;
}
$head .= PHP_EOL."\t\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[] = '
';
$langKey = $this->langPrefix.'_DASHBOARD_'.$menu['settings']->CODE;
// add to lang
$this->langContent[$this->lang][$langKey] = $langName;
// set icon
$this->lastCustomDashboardIcon[$nr] = ", '".$type.$menu['settings']->code."'";
}
}
}
// see if we should have custom menus
if (isset($this->componentData->custommenus) && ComponentbuilderHelper::checkArray($this->componentData->custommenus))
{
foreach ($this->componentData->custommenus as $nr => $menu)
{
$nr = $nr + 100;
$nameList = ComponentbuilderHelper::safeString($menu['name_code']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name_code'], 'U');
if ($menu['dashboard_list'] == 1 && $view['adminview'] == $menu['before'])
{
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
// TODO must look at adding custom links to icons aswell
return '';
}
else
{
$type = ComponentbuilderHelper::imageInfo('images/'.$menu['icon']);
if ($type)
{
$type = $type.".";
// icon builder loader
$this->iconBuilder[$type.$nameList] = 'images/'.$menu['icon'];
}
else
{
$type = 'png.';
}
// build lang
$langName = $menu['name'].'
';
$langKey = $this->langPrefix.'_DASHBOARD_'.$nameUpper;
// add to lang
$this->langContent[$this->lang][$langKey] = $langName;
// set icon
if ($counter == 0)
{
$counter++;
$icon .= "'".$type.$nameList."'";
}
else
{
$counter++;
$icon .= ", '".$type.$nameList."'";
}
}
}
elseif($menu['dashboard_list'] == 1 && empty($menu['before']))
{
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
// TODO must look at adding custom links to icons aswell
return '';
}
else
{
$type = ComponentbuilderHelper::imageInfo('images/'.$menu['icon']);
if ($type)
{
$type = $type.".";
// icon builder loader
$this->iconBuilder[$type.$nameList] = 'images/'.$menu['icon'];
}
else
{
$type = 'png.';
}
// build lang
$langName = $menu['name'].'
';
$langKey = $this->langPrefix.'_DASHBOARD_'.$nameUpper;
// add to lang
$this->langContent[$this->lang][$langKey] = $langName;
// set icon
$this->lastCustomDashboardIcon[$nr] = ", '".$type.$nameList."'";
}
}
}
}
return $icon;
}
public function setSubMenus()
{
if (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views))
{
$menus = '';
// main lang prefix
$lang = $this->langPrefix.'_SUBMENU';
// set the code name
$codeName = ComponentbuilderHelper::safeString($this->componentData->name_code);
// set dashboard
$menus .= "JHtmlSidebar::addEntry(JText::_('".$lang."_DASHBOARD'), 'index.php?option=com_".$codeName."&view=".$codeName."', \$submenu === '".$codeName."');";
$this->langContent[$this->lang][$lang.'_DASHBOARD'] = 'Dashboard';
$catArray = array();
foreach ($this->componentData->admin_views as $view)
{
// set custom menu
$menus .= $this->addCustomSubMenu($view,$codeName,$lang);
if (isset($view['submenu']) && $view['submenu'] == 1)
{
// setup access defaults
$tab = "";
$nameSingle = ComponentbuilderHelper::safeString($view['settings']->name_single);
$coreLoad = false;
if (isset($this->permissionCore[$nameSingle]))
{
$core = $this->permissionCore[$nameSingle];
$coreLoad = true;
}
// check if the item has permissions.
if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder['global'][$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.access']]) && in_array($nameSingle,$this->permissionBuilder['global'][$core['core.access']]))
{
$menus .= PHP_EOL."\t\tif (\$user->authorise('".$core['core.access']."', 'com_".$codeName."') && \$user->authorise('".$nameSingle.".submenu', 'com_".$codeName."'))";
$menus .= PHP_EOL."\t\t{";
// add tab to lines to follow
$tab = "\t";
}
$nameList = ComponentbuilderHelper::safeString($view['settings']->name_list);
$nameUpper = ComponentbuilderHelper::safeString($view['settings']->name_list, 'U');
$menus .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$lang."_".$nameUpper."'), 'index.php?option=com_".$codeName."&view=".$nameList."', \$submenu === '".$nameList."');";
$this->langContent[$this->lang][$lang."_".$nameUpper] = $view['settings']->name_list;
// check if category has another name
if (isset($this->catOtherName[$nameList]) && ComponentbuilderHelper::checkArray($this->catOtherName[$nameList]))
{
$otherViews = $this->catOtherName[$nameList]['views'];
}
else
{
$otherViews = $nameList;
}
if (isset($this->categoryBuilder[$nameList]) && ComponentbuilderHelper::checkArray($this->categoryBuilder[$nameList]) && !in_array($otherViews,$catArray))
{
$menus .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$this->categoryBuilder[$nameList]['name']."'), 'index.php?option=com_categories&view=categories&extension=com_".$codeName.".".$otherViews."', \$submenu === 'categories.".$otherViews."');";
// make sure we add a category only once
$catArray[] = $otherViews;
}
// check if the item has permissions.
if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder['global'][$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.access']]) && in_array($nameSingle,$this->permissionBuilder['global'][$core['core.access']]))
{
$menus .= PHP_EOL."\t\t}";
}
}
}
if (isset($this->lastCustomSubMenu) && ComponentbuilderHelper::checkArray($this->lastCustomSubMenu))
{
foreach ($this->lastCustomSubMenu as $menu)
{
$menus .= $menu;
}
unset($this->lastCustomSubMenu);
}
return $menus;
}
return false;
}
public function addCustomSubMenu(&$view,&$codeName,&$lang)
{
// see if we should have custom menus
$custom = '';
if (isset($this->componentData->custom_admin_views) && ComponentbuilderHelper::checkArray($this->componentData->custom_admin_views))
{
foreach ($this->componentData->custom_admin_views as $nr => $menu)
{
if (!isset($this->customAdminAdded[$menu['settings']->code]))
{
if ($custom = $this->setCustomAdminSubMenu($view,$codeName,$lang,$nr,$menu,'customView'))
{
break;
}
}
}
}
if (isset($this->componentData->custommenus) && ComponentbuilderHelper::checkArray($this->componentData->custommenus))
{
foreach ($this->componentData->custommenus as $nr => $menu)
{
if ($custom2 = $this->setCustomAdminSubMenu($view,$codeName,$lang,$nr,$menu,'customMenu'))
{
$custom = $custom.$custom2;
break;
}
}
}
return $custom;
}
public function setCustomAdminSubMenu(&$view,&$codeName,&$lang,&$nr,&$menu,$type)
{
if ($type === 'customMenu')
{
$name = $menu['name'];
$nameSingle = ComponentbuilderHelper::safeString($menu['name']);
$nameList = ComponentbuilderHelper::safeString($menu['name']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name'], 'U');
}
elseif ($type === 'customView')
{
$name = $menu['settings']->name;
$nameSingle = $menu['settings']->code;
$nameList = $menu['settings']->code;
$nameUpper = $menu['settings']->CODE;
}
if ($menu['submenu'] == 1 && $view['adminview'] == $menu['before'])
{
// setup access defaults
$tab = "";
$coreLoad = false;
if (isset($this->permissionCore[$nameSingle]))
{
$core = $this->permissionCore[$nameSingle];
$coreLoad = true;
}
$custom = '';
// check if the item has permissions.
if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder['global'][$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.access']]) && in_array($nameSingle,$this->permissionBuilder['global'][$core['core.access']]))
{
$custom .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Access control (".$core['core.access']." && ".$nameSingle.".submenu).";
$custom .= PHP_EOL."\t\tif (\$user->authorise('".$core['core.access']."', 'com_".$codeName."') && \$user->authorise('".$nameSingle.".submenu', 'com_".$codeName."'))";
$custom .= PHP_EOL."\t\t{";
// add tab to lines to follow
$tab = "\t";
}
else
{
$custom .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Access control (".$nameSingle.".submenu).";
$custom .= PHP_EOL."\t\tif (\$user->authorise('".$nameSingle.".submenu', 'com_".$codeName."'))";
$custom .= PHP_EOL."\t\t{";
// add tab to lines to follow
$tab = "\t";
}
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
$this->langContent[$this->lang][$lang.'_'.$nameUpper] = $name;
// add custom menu
$custom .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$lang."_".$nameUpper."'), '".$menu['link']."', \$submenu === '".$nameList."');";
}
else
{
$this->langContent[$this->lang][$lang.'_'.$nameUpper] = $name;
// add custom menu
$custom .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$lang."_".$nameUpper."'), 'index.php?option=com_".$codeName."&view=".$nameList."', \$submenu === '".$nameList."');";
}
// check if the item has permissions.
$custom .= PHP_EOL."\t\t}";
return $custom;
}
elseif($menu['submenu'] == 1 && empty($menu['before']))
{
// setup access defaults
$tab = "";
$nameSingle = ComponentbuilderHelper::safeString($name);
$coreLoad = false;
if (isset($this->permissionCore[$nameSingle]))
{
$core = $this->permissionCore[$nameSingle];
$coreLoad = true;
}
$this->lastCustomSubMenu[$nr] = '';
// check if the item has permissions.
if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder['global'][$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.access']]) && in_array($nameSingle,$this->permissionBuilder['global'][$core['core.access']]))
{
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\tif (\$user->authorise('".$core['core.access']."', 'com_".$codeName."') && \$user->authorise('".$nameSingle.".submenu', 'com_".$codeName."'))";
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\t{";
// add tab to lines to follow
$tab = "\t";
}
else
{
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\tif (\$user->authorise('".$nameSingle.".submenu', 'com_".$codeName."'))";
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\t{";
// add tab to lines to follow
$tab = "\t";
}
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
$this->langContent[$this->lang][$lang.'_'.$nameUpper] = $name;
// add custom menu
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$lang."_".$nameUpper."'), '".$menu['link']."', \$submenu === '".$nameList."');";
}
else
{
$this->langContent[$this->lang][$lang.'_'.$nameUpper] = $name;
// add custom menu
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\t".$tab."JHtmlSidebar::addEntry(JText::_('".$lang."_".$nameUpper."'), 'index.php?option=com_".$codeName."&view=".$nameList."', \$submenu === '".$nameList."');";
}
// check if the item has permissions.
$this->lastCustomSubMenu[$nr] .= PHP_EOL."\t\t}";
}
return false;
}
public function setMainMenus()
{
if (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views))
{
$menus = '';
// main lang prefix
$lang = $this->langPrefix.'_MENU';
// set the code name
$codeName = ComponentbuilderHelper::safeString($this->componentData->name_code);
// set main menu name to lang
$this->langContent['adminsys'][$lang] = '» '.$this->componentData->name;
foreach ($this->componentData->admin_views as $view)
{
// set custom menu
$menus .= $this->addCustomMainMenu($view,$codeName,$lang);
if (isset($view['mainmenu']) && $view['mainmenu'] == 1)
{
$nameList = ComponentbuilderHelper::safeString($view['settings']->name_list);
$nameUpper = ComponentbuilderHelper::safeString($view['settings']->name_list, 'U');
$menus .= PHP_EOL."\t\t\t".'';
$this->langContent['adminsys'][$lang.'_'.$nameUpper] = $view['settings']->name_list;
}
}
if (isset($this->lastCustomMainMenu) && ComponentbuilderHelper::checkArray($this->lastCustomMainMenu))
{
foreach ($this->lastCustomMainMenu as $menu)
{
$menus .= $menu;
}
unset($this->lastCustomMainMenu);
}
return $menus;
}
return false;
}
public function addCustomMainMenu(&$view,&$codeName,&$lang)
{
$customMenu = '';
// see if we should have custom admin views
if (isset($this->componentData->custom_admin_views) && ComponentbuilderHelper::checkArray($this->componentData->custom_admin_views))
{
foreach ($this->componentData->custom_admin_views as $nr => $menu)
{
if (!isset($this->customAdminAdded[$menu['settings']->code]))
{
if ($menu['mainmenu'] == 1 && $view['adminview'] == $menu['before'])
{
$this->langContent['adminsys'][$lang.'_'.$menu['settings']->CODE] = $menu['settings']->name;
// add custom menu
$customMenu .= PHP_EOL."\t\t\t".'';
}
elseif($menu['mainmenu'] == 1 && empty($menu['before']))
{
$this->langContent['adminsys'][$lang.'_'.$menu['settings']->CODE] = $menu['settings']->name;
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL."\t\t\t".'';
}
}
}
}
// see if we should have custom menus
if (isset($this->componentData->custommenus) && ComponentbuilderHelper::checkArray($this->componentData->custommenus))
{
foreach ($this->componentData->custommenus as $nr => $menu)
{
$nr = $nr + 100;
if ($menu['mainmenu'] == 1 && $view['adminview'] == $menu['before'])
{
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
$nameList = ComponentbuilderHelper::safeString($menu['name']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name'], 'U');
$this->langContent['adminsys'][$lang.'_'.$nameUpper] = $menu['name'];
// add custom menu
$customMenu .= PHP_EOL."\t\t\t".'';
}
else
{
$nameList = ComponentbuilderHelper::safeString($menu['name_code']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name_code'], 'U');
$this->langContent['adminsys'][$lang.'_'.$nameUpper] = $menu['name'];
// add custom menu
$customMenu .= PHP_EOL."\t\t\t".'';
}
}
elseif($menu['mainmenu'] == 1 && empty($menu['before']))
{
if (isset($menu['link']) && ComponentbuilderHelper::checkString($menu['link']))
{
$nameList = ComponentbuilderHelper::safeString($menu['name']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name'], 'U');
$this->langContent['adminsys'][$lang.'_'.$nameUpper] = $menu['name'];
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL."\t\t\t".'';
}
else
{
$nameList = ComponentbuilderHelper::safeString($menu['name_code']);
$nameUpper = ComponentbuilderHelper::safeString($menu['name_code'], 'U');
$this->langContent['adminsys'][$lang.'_'.$nameUpper] = $menu['name'];
// add custom menu
$this->lastCustomMainMenu[$nr] = PHP_EOL."\t\t\t".'';
}
}
}
}
return $customMenu;
}
public function setConfigFieldsets($timer = 0)
{
// main lang prefix
$lang = $this->langPrefix.'_CONFIG';
if (1 == $timer) // this is before the admin views are build
{
// start loading Global params
$autorName = ComponentbuilderHelper::htmlEscape($this->componentData->author);
$autorEmail = ComponentbuilderHelper::htmlEscape($this->componentData->email);
$this->extensionsParams[] = '"autorName":"'.$autorName.'","autorEmail":"'.$autorEmail.'"';
// set the custom fields
if (isset($this->componentData->config) && ComponentbuilderHelper::checkArray($this->componentData->config))
{
$component = ComponentbuilderHelper::safeString($this->componentData->name_code);
$viewName = 'config';
$listViewName = 'configs';
$placeholders = array(
'###component###' => $component,
'###view###' => $viewName,
'###views###' => $listViewName);
$spacerCounter = 'a';
$view = '';
$viewType = 0;
// set the custom table key
$dbkey = 'g';
foreach ($this->componentData->config as $field)
{
$xmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $spacerCounter, $placeholders, $dbkey, false);
if (ComponentbuilderHelper::checkString($xmlField))
{
$this->configFieldSetsCustomField[$field['tabname']][] = $xmlField;
// set global params to db on install
$fieldName = ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($xmlField,'name="','"'));
$fieldDefault = ComponentbuilderHelper::getBetween($xmlField,'default="','"');
if (isset($field['custom_value']) && ComponentbuilderHelper::checkString($field['custom_value']))
{
// add array if found
if ((strpos($field['custom_value'], '["') !== false) && (strpos($field['custom_value'], '"]') !== false))
{
// load the Global checkin defautls
$this->extensionsParams[] = '"'.$fieldName.'":'.$field['custom_value'];
}
else
{
// load the Global checkin defautls
$this->extensionsParams[] = '"'.$fieldName.'":"'.$field['custom_value'].'"';
}
}
elseif (ComponentbuilderHelper::checkString($fieldDefault))
{
// load the Global checkin defautls
$this->extensionsParams[] = '"'.$fieldName.'":"'.$fieldDefault.'"';
}
}
}
}
// first run we must set the globals
$this->setGlobalConfigFieldsets($lang,$autorName,$autorEmail);
$this->setSiteControlConfigFieldsets($lang);
}
elseif (2 == $timer) // this is after the admin views are build
{
// these field sets can only be added after admin view is build
$this->setGroupControlConfigFieldsets($lang);
// these can be added anytime really (but looks best after groups
$this->setUikitConfigFieldsets($lang);
$this->setGooglechartConfigFieldsets($lang);
$this->setEmailHelperConfigFieldsets($lang);
$this->setEncryptionConfigFieldsets($lang);
// these are the coustom settings
$this->setCustomControlConfigFieldsets($lang);
}
// we cad add more event (timers as we need)
}
public function setSiteControlConfigFieldsets($lang)
{
$front_end = array();
// do quick build of front-end views
if (isset($this->componentData->site_views) && ComponentbuilderHelper::checkArray($this->componentData->site_views))
{
// load the names only to link the page params
foreach ($this->componentData->site_views as $siteView)
{
// now load the view name to the front-end array
$front_end[] = $siteView['settings']->name;
}
}
// add frontend view stuff including menus
if (isset($this->configFieldSetsCustomField) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField))
{
foreach ($this->configFieldSetsCustomField as $tab => &$tabFields)
{
$tabCode = ComponentbuilderHelper::safeString($tab).'_custom_config';
$tabUpper = ComponentbuilderHelper::safeString($tab,'U');
$tabLower = ComponentbuilderHelper::safeString($tab);
// load the request id setters for menu views
$viewRequest = 'name="'.$tabLower.'_request_id';
foreach($tabFields as $et => $id_field)
{
if(strpos($id_field,$viewRequest) !== false)
{
$this->setRequestValues($tabLower, $id_field, $viewRequest, 'id', 'hasIdRequest');
unset($tabFields[$et]);
}
elseif (strpos($id_field,'_request_id') !== false)
{
// not loaded to a tab "view" name
$_viewRequest = ComponentbuilderHelper::getBetween($id_field,'name="','_request_id');
$searchIdKe = 'name="'.$_viewRequest.'_request_id';
$this->setRequestValues($_viewRequest, $id_field, $searchIdKe, 'id', 'hasIdRequest');
unset($tabFields[$et]);
}
}
// load the request catid setters for menu views
$viewRequestC = 'name="'.$tabLower.'_request_catid';
foreach($tabFields as $ci => $catid_field)
{
if(strpos($catid_field,$viewRequestC) !== false)
{
$this->setRequestValues($tabLower, $catid_field, $viewRequestC, 'catid', 'hasCatIdRequest');
unset($tabFields[$ci]);
}
elseif (strpos($catid_field,'_request_catid') !== false)
{
// not loaded to a tab "view" name
$_viewRequestC = ComponentbuilderHelper::getBetween($catid_field,'name="','_request_catid');
$searchCatidKe = 'name="'.$_viewRequestC.'_request_catid';
$this->setRequestValues($_viewRequestC, $catid_field, $searchCatidKe, 'catid', 'hasCatIdRequest');
unset($tabFields[$ci]);
}
}
// load the global menu setters for single fields
$menuSetter = $tabLower.'_menu';
$pageSettings = array();
foreach($tabFields as $ct => $field)
{
if(strpos($field,$menuSetter) !== false)
{
// set the values needed to insure route is done correclty
$this->hasMenuGlobal[$tabLower] = $menuSetter;
}
elseif (strpos($field,'_menu"') !== false)
{
// not loaded to a tab "view" name
$_tabLower = ComponentbuilderHelper::getBetween($field,'name="','_menu"');
// set the values needed to insure route is done correclty
$this->hasMenuGlobal[$_tabLower] = $_tabLower.'_menu';
}
else
{
$pageSettings[$ct] = $field;
}
}
// insure we load the needed params
if (in_array($tab,$front_end))
{
$this->frontEndParams[$tab] = $pageSettings;
}
}
}
}
protected function setRequestValues($view, $field, $search, $target, $store)
{
$key = ComponentbuilderHelper::getBetween($field, $search, '"');
if (!ComponentbuilderHelper::checkString($key))
{
// is not having special var
$key = $target;
// update field
$field = str_replace($search . '"', 'name="'. $key . '"', $field);
}
else
{
// update field
$field = str_replace($search . $key . '"', 'name="'. $key . '"', $field);
}
if (!isset($this->{$store}[$view]))
{
$this->{$store}[$view] = array();
}
// set the values needed for view requests to be made
$this->{$store}[$view][$key] = $field;
}
public function setCustomControlConfigFieldsets($lang)
{
// add custom new global fields set
if (isset($this->configFieldSetsCustomField) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField))
{
foreach ($this->configFieldSetsCustomField as $tab => $tabFields)
{
$tabCode = ComponentbuilderHelper::safeString($tab).'_custom_config';
$tabUpper = ComponentbuilderHelper::safeString($tab,'U');
$tabLower = ComponentbuilderHelper::safeString($tab);
// setup lang
$this->langContent[$this->lang][$lang.'_'.$tabUpper] = $tab;
// start field set
$this->configFieldSets[] = "\t";
// remove after loading
unset($this->configFieldSetsCustomField[$tab]);
}
}
}
public function setGroupControlConfigFieldsets($lang)
{
// start loading Group control params if needed
if (isset($this->setGroupControl) && ComponentbuilderHelper::checkArray($this->setGroupControl))
{
// start building field set for config
$this->configFieldSets[] = "\t";
}
}
/**
* @param $lang
* @param $autorName
* @param $autorEmail
*/
public function setGlobalConfigFieldsets($lang, $autorName, $autorEmail)
{
// set component name
$component = ComponentbuilderHelper::safeString($this->componentData->name_code);
// start building field set for config
$this->configFieldSets[] = '";
}
public function setUikitConfigFieldsets($lang)
{
if ($this->uikit)
{
// main lang prefix
$lang = $lang.'';
// start building field set for uikit functions
$this->configFieldSets[] = "\t";
}
}
public function setEmailHelperConfigFieldsets($lang)
{
if (isset($this->componentData->add_email_helper) && $this->componentData->add_email_helper)
{
// main lang prefix
$lang = $lang.'';
// set main lang string
$this->langContent[$this->lang][$lang.'_MAIL_CONFIGURATION'] = "Mail Configuration";
$this->langContent[$this->lang][$lang.'_DKIM'] = "DKIM";
// start building field set for email helper functions
$this->configFieldSets[] = PHP_EOL."\t";
// start dkim field set
$this->configFieldSets[] = "\t";
}
}
public function setGooglechartConfigFieldsets($lang)
{
if ($this->googlechart)
{
$this->configFieldSets[] = PHP_EOL."\t";
// set params defaults
$this->extensionsParams[] = '"admin_chartbackground":"#F7F7FA","admin_mainwidth":"1000","admin_chartareatop":"20","admin_chartarealeft":"20","admin_chartareawidth":"170","admin_legendtextstylefontcolor":"10","admin_legendtextstylefontsize":"20","admin_vaxistextstylefontcolor":"#63B1F2","admin_haxistextstylefontcolor":"#63B1F2","admin_haxistitletextstylefontcolor":"#63B1F2","site_chartbackground":"#F7F7FA","site_mainwidth":"1000","site_chartareatop":"20","site_chartarealeft":"20","site_chartareawidth":"170","site_legendtextstylefontcolor":"10","site_legendtextstylefontsize":"20","site_vaxistextstylefontcolor":"#63B1F2","site_haxistextstylefontcolor":"#63B1F2","site_haxistitletextstylefontcolor":"#63B1F2"';
// set field lang
$this->langContent[$this->lang][$lang.'_CHART_SETTINGS_LABEL'] = "Chart Settings";
$this->langContent[$this->lang][$lang.'_CHART_SETTINGS_DESC'] = "The Google Chart Display Settings Are Made Here.";
$this->langContent[$this->lang][$lang.'_ADMIN_CHART_NOTE_LABEL'] = "Admin Settings";
$this->langContent[$this->lang][$lang.'_ADMIN_CHART_NOTE_DESC'] = "The following settings are used on the back-end of the site called (admin).";
$this->langContent[$this->lang][$lang.'_SITE_CHART_NOTE_LABEL'] = "Site Settings";
$this->langContent[$this->lang][$lang.'_SITE_CHART_NOTE_DESC'] = "The following settings are used on the front-end of the site called (site).";
$this->langContent[$this->lang][$lang.'_CHARTAREALEFT_DESC'] = "Set in pixels the spacing from the left of the chart area to the beginning of the chart it self. Please don't add the px sign";
$this->langContent[$this->lang][$lang.'_CHARTAREALEFT_HINT'] = "170";
$this->langContent[$this->lang][$lang.'_CHARTAREALEFT_LABEL'] = "Left Spacing";
$this->langContent[$this->lang][$lang.'_CHARTAREATOP_DESC'] = "Set in pixels the spacing from the top of the chart area to the beginning of the chart it self. Please don't add the px sign";
$this->langContent[$this->lang][$lang.'_CHARTAREATOP_HINT'] = "20";
$this->langContent[$this->lang][$lang.'_CHARTAREATOP_LABEL'] = "Top Spacing";
$this->langContent[$this->lang][$lang.'_CHARTAREAWIDTH_DESC'] = "Set in % the width of the chart it self inside the chart area. Please don't add the % sign";
$this->langContent[$this->lang][$lang.'_CHARTAREAWIDTH_HINT'] = "60";
$this->langContent[$this->lang][$lang.'_CHARTAREAWIDTH_LABEL'] = "Chart Width";
$this->langContent[$this->lang][$lang.'_CHARTBACKGROUND_DESC'] = "Select the chart background color here.";
$this->langContent[$this->lang][$lang.'_CHARTBACKGROUND_LABEL'] = "Chart Background";
$this->langContent[$this->lang][$lang.'_HAXISTEXTSTYLEFONTCOLOR_DESC'] = "Select the horizontal axis font color.";
$this->langContent[$this->lang][$lang.'_HAXISTEXTSTYLEFONTCOLOR_LABEL'] = "hAxis Font Color";
$this->langContent[$this->lang][$lang.'_HAXISTITLETEXTSTYLEFONTCOLOR_DESC'] = "Select the horizontal axis title's font color.";
$this->langContent[$this->lang][$lang.'_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL'] = "hAxis Title Font Color";
$this->langContent[$this->lang][$lang.'_LEGENDTEXTSTYLEFONTCOLOR_DESC'] = "Select the legend font color.";
$this->langContent[$this->lang][$lang.'_LEGENDTEXTSTYLEFONTCOLOR_LABEL'] = "Legend Font Color";
$this->langContent[$this->lang][$lang.'_LEGENDTEXTSTYLEFONTSIZE_DESC'] = "Set in pixels the font size of the legend";
$this->langContent[$this->lang][$lang.'_LEGENDTEXTSTYLEFONTSIZE_HINT'] = "10";
$this->langContent[$this->lang][$lang.'_LEGENDTEXTSTYLEFONTSIZE_LABEL'] = "Legend Font Size";
$this->langContent[$this->lang][$lang.'_MAINWIDTH_DESC'] = "Set the width of the entire chart area";
$this->langContent[$this->lang][$lang.'_MAINWIDTH_HINT'] = "1000";
$this->langContent[$this->lang][$lang.'_MAINWIDTH_LABEL'] = "Chart Area Width";
$this->langContent[$this->lang][$lang.'_VAXISTEXTSTYLEFONTCOLOR_DESC'] = "Select the vertical axis font color.";
$this->langContent[$this->lang][$lang.'_VAXISTEXTSTYLEFONTCOLOR_LABEL'] = "vAxis Font Color";
}
}
/**
* @param $lang
*/
public function setEncryptionConfigFieldsets($lang)
{
// Add encryption if needed
if ((isset($this->basicEncryption) && $this->basicEncryption) || (isset($this->advancedEncryption) && $this->advancedEncryption))
{
// start building field set for uikit functions
$this->configFieldSets[] = "\t";
}
}
public function setAccessSectionsCategory($viewName_single, $viewName_list)
{
$component = '';
// check if view has category
if (array_key_exists($viewName_single, $this->catCodeBuilder))
{
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
if ($otherViews == $viewName_list)
{
$component .= PHP_EOL."\t".'';
$component .= PHP_EOL."\t\t".'';
$component .= PHP_EOL."\t\t".'';
$component .= PHP_EOL."\t\t".'';
$component .= PHP_EOL."\t\t".'';
$component .= PHP_EOL."\t\t".'';
$component .= PHP_EOL."\t";
}
}
return $component;
}
public function setAccessSections()
{
// set the default component access values
$this->componentHead = array();
$this->componentGlobal = array();
$this->permissionViews = array();
$this->componentHead[] = '';
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
if ($this->addEximport)
{
$exportTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Export Data','U');
$exportDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Export Data','U').'_DESC';
$this->langContent['bothadmin'][$exportTitle] = 'Export Data';
$this->langContent['bothadmin'][$exportDesc] = ' Allows users in this group to export data.';
$this->componentHead[] = "\t\t".'';
$importTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Import Data','U');
$importDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Import Data','U').'_DESC';
$this->langContent['bothadmin'][$importTitle] = 'Import Data';
$this->langContent['bothadmin'][$importDesc] = ' Allows users in this group to import data.';
$this->componentHead[] = "\t\t".'';
}
// version permission
$batchTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Use Batch','U');
$batchDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Use Batch','U').'_DESC';
$this->langContent['bothadmin'][$batchTitle] = 'Use Batch';
$this->langContent['bothadmin'][$batchDesc] = ' Allows users in this group to use batch copy/update method.';
$this->componentHead[] = "\t\t".'';
// version permission
$importTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Versions','U');
$importDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Versions','U').'_DESC';
$this->langContent['bothadmin'][$importTitle] = 'Edit Version';
$this->langContent['bothadmin'][$importDesc] = ' Allows users in this group to edit versions.';
$this->componentHead[] = "\t\t".'';
// set the defaults
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
$this->componentHead[] = "\t\t".'';
// new custom created by permissions
$created_byTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Created By','U');
$created_byDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Created By','U').'_DESC';
$this->langContent['bothadmin'][$created_byTitle] = 'Edit Created By';
$this->langContent['bothadmin'][$created_byDesc] = ' Allows users in this group to edit created by.';
$this->componentHead[] = "\t\t".'';
// new custom created date permissions
$createdTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Created Date','U');
$createdDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString('Edit Created Date','U').'_DESC';
$this->langContent['bothadmin'][$createdTitle] = 'Edit Created Date';
$this->langContent['bothadmin'][$createdDesc] = ' Allows users in this group to edit created date.';
$this->componentHead[] = "\t\t".'';
// set the menu controller lookup
$menuControllers = array('access','submenu','dashboard_list','dashboard_add');
// set the custom admin views permissions
if (isset($this->componentData->custom_admin_views) && ComponentbuilderHelper::checkArray($this->componentData->custom_admin_views))
{
foreach ($this->componentData->custom_admin_views as $custom_admin_view)
{
// new custom permissions to access this view
$customAdminName = $custom_admin_view['settings']->name;
$customAdminCode = $custom_admin_view['settings']->code;
$customAdminTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($customAdminName.' Access','U');
$customAdminDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($customAdminName.' Access','U').'_DESC';
$sortKey = ComponentbuilderHelper::safeString($customAdminName.' Access');
$this->langContent['bothadmin'][$customAdminTitle] = $customAdminName.' Access';
$this->langContent['bothadmin'][$customAdminDesc] = ' Allows the users in this group to access '.ComponentbuilderHelper::safeString($customAdminName,'w').'.';
$this->componentGlobal[$sortKey] = "\t\t".'';
// add the custom permissions to use the buttons of this view
$this->addCustomButtonPermissions($custom_admin_view['settings'], $customAdminName, $customAdminCode);
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
// add menu controll view that has menus options
if (isset($custom_admin_view[$menuController]) && $custom_admin_view[$menuController])
{
$targetView_ = 'views.';
if ($menuController === 'dashboard_add')
{
$targetView_ = 'view.';
}
// menucontroller
$menucontrollerView['action'] = $targetView_.$menuController;
$menucontrollerView['implementation'] = '2';
if (isset($custom_admin_view['settings']->permissions) && ComponentbuilderHelper::checkArray($custom_admin_view['settings']->permissions))
{
array_push($custom_admin_view['settings']->permissions,$menucontrollerView);
}
else
{
$custom_admin_view['settings']->permissions = array();
$custom_admin_view['settings']->permissions[] = $menucontrollerView;
}
unset($menucontrollerView);
}
}
$this->buildPermissions($custom_admin_view, $customAdminCode, $customAdminCode, $menuControllers, 'customAdmin');
}
}
// set the site views permissions
if (isset($this->componentData->site_views) && ComponentbuilderHelper::checkArray($this->componentData->site_views))
{
foreach ($this->componentData->site_views as $site_view)
{
// new custom permissions to access this view
$siteName = $site_view['settings']->name;
$siteCode = $site_view['settings']->code;
$siteTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($siteName.' Access Site','U');
$siteDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($siteName.' Access Site','U').'_DESC';
$sortKey = ComponentbuilderHelper::safeString($siteName.' Access Site');
if (isset($site_view['access']) && $site_view['access'] == 1)
{
$this->langContent['bothadmin'][$siteTitle] = $siteName.' (Site) Access';
$this->langContent['bothadmin'][$siteDesc] = ' Allows the users in this group to access site '.ComponentbuilderHelper::safeString($siteName,'w').'.';
$this->componentGlobal[$sortKey] = "\t\t".'';
// check if this site view requires access rule to default to public
if (isset($site_view['public']) && $site_view['public'] == 1)
{
// we use one as public group (TODO we see if we run into any issues)
$this->assetsRules[] = '"site.'.$siteCode.'.access":{"1":1}';
}
}
// add the custom permissions to use the buttons of this view
$this->addCustomButtonPermissions($site_view['settings'], $siteName, $siteCode);
}
}
if (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views))
{
foreach ($this->componentData->admin_views as $view)
{
// set view name
$nameView = ComponentbuilderHelper::safeString($view['settings']->name_single);
$nameViews = ComponentbuilderHelper::safeString($view['settings']->name_list);
// add the custom permissions to use the buttons of this view
$this->addCustomButtonPermissions($view['settings'], $view['settings']->name_single, $nameView);
if ($nameView != 'component')
{
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
// add menu controll view that has menus options
if (isset($view[$menuController]) && $view[$menuController])
{
$targetView_ = 'views.';
if ($menuController === 'dashboard_add')
{
$targetView_ = 'view.';
}
// menucontroller
$menucontrollerView['action'] = $targetView_.$menuController;
$menucontrollerView['implementation'] = '2';
if (isset($view['settings']->permissions) && ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$menucontrollerView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $menucontrollerView;
}
unset($menucontrollerView);
}
}
// check if there are fields
if (ComponentbuilderHelper::checkArray($view['settings']->fields))
{
// check the fields for their permission settings
foreach($view['settings']->fields as $field)
{
// see if field require permissions to be set
if (isset($field['permission']) && $field['permission'])
{
if (ComponentbuilderHelper::checkArray($field['settings']->properties))
{
foreach ($field['settings']->properties as $property)
{
if ($property['name'] === 'type')
{
$propertyType = $property;
}
}
$fieldType = $this->getFieldType($field['settings']->type_name,$field['settings']->xml,$propertyType);
$fieldName = $this->getFieldName($fieldType,$field['settings']->xml,$field['alias']);
$fieldView = array();
// set the permission for this field
$fieldView['action'] = 'view.edit.'.$fieldName;
$fieldView['implementation'] = '3';
if (ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$fieldView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $fieldView;
}
// insure that no default field get loaded
if (!in_array($fieldName, $this->defaultFields))
{
// load to global field permission set
$this->permissionFields[$nameView][$fieldName] = $fieldType;
}
}
}
}
}
$this->buildPermissions($view, $nameView, $nameViews, $menuControllers);
}
}
// set the views permissions now
if (ComponentbuilderHelper::checkArray($this->permissionViews))
{
foreach ($this->permissionViews as $viewName => $actions)
{
$componentViews[] = "\t".'';
foreach ($actions as $action)
{
$componentViews[] = "\t\t".$action;
}
$componentViews[] = "\t";
}
}
/// now build the section
$component = implode(PHP_EOL,$this->componentHead);
// sort the array to insure easy search
ksort($this->componentGlobal,SORT_STRING);
// add global to the compnent section
$component .= PHP_EOL.implode(PHP_EOL,$this->componentGlobal).PHP_EOL."\t";
// add views to the compnent section
$component .= PHP_EOL.implode(PHP_EOL,$componentViews);
// be sure to reset again. (memory)
$this->componentHead = null;
$this->componentGlobal = null;
$this->permissionViews = null;
// return the build
return $component;
}
return false;
}
protected function addCustomButtonPermissions($settings, $nameView, $code)
{
// add the custom permissions to use the buttons of this view
if (isset($settings->custom_buttons) && ComponentbuilderHelper::checkArray($settings->custom_buttons))
{
foreach ($settings->custom_buttons as $custom_buttons)
{
$customButtonName = $custom_buttons['name'];
$customButtonCode = ComponentbuilderHelper::safeString($customButtonName);
$customButtonTitle = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($nameView.' '.$customButtonName.' Button Access','U');
$customButtonDesc = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($nameView.' '.$customButtonName.' Button Access','U').'_DESC';
$sortButtonKey = ComponentbuilderHelper::safeString($nameView.' '.$customButtonName.' Button Access');
$this->langContent['bothadmin'][$customButtonTitle] = $nameView.' '.$customButtonName.' Button Access';
$this->langContent['bothadmin'][$customButtonDesc] = ' Allows the users in this group to access the '.ComponentbuilderHelper::safeString($customButtonName,'w').' button.';
$this->componentGlobal[$sortButtonKey] = "\t\t".'';
}
}
}
public function buildPermissions(&$view, $nameView, $nameViews, $menuControllers, $type = 'admin')
{
if (isset($view['settings']->permissions) && ComponentbuilderHelper::checkArray($view['settings']->permissions) || (isset($view['port']) && $view['port']) || (isset($view['history']) && $view['history']))
{
// add export/import permissions to each view that has export/import options
if (isset($view['port']) && $view['port'])
{
// export
$exportView['action'] = 'view.export';
$exportView['implementation'] = '2';
if (ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$exportView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $exportView;
}
// import
$importView['action'] = 'view.import';
$importView['implementation'] = '2';
if (ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$importView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $importView;
}
}
// add version opstions to each view that has it added
if (isset($view['history']) && $view['history'])
{
// set version control
$versionView['action'] = 'view.version';
$versionView['implementation'] = '3';
if (ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$versionView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $versionView;
}
}
if ($type === 'admin')
{
// set batch control
$batchView['action'] = 'view.batch';
$batchView['implementation'] = '2';
if (ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions,$batchView);
}
else
{
$view['settings']->permissions = array();
$view['settings']->permissions[] = $batchView;
}
}
foreach ($view['settings']->permissions as $permission)
{
// set acction name
$arr = explode('.',trim($permission['action']));
if ($arr[0] != 'core' || $arr[0] === 'view')
{
array_shift($arr);
$actionMain = implode('.',$arr);
$action = $nameView.'.'.$actionMain;
}
else
{
if ($arr[0] === 'core')
{
// core is already set in global access
$permission['implementation'] = 1;
}
$action = $permission['action'];
}
// build action name
$actionNameBuilder = explode('.',trim($permission['action']));
array_shift($actionNameBuilder);
$nameBuilder = trim(implode('___',$actionNameBuilder));
$customName = trim(implode(' ',$actionNameBuilder));
if ($type === 'admin')
{
$W_NameList = ComponentbuilderHelper::safeString($view['settings']->name_list, 'W');
$w_NameList = ComponentbuilderHelper::safeString($customName.' '.$view['settings']->name_list, 'w');
$w_NameSingle = ComponentbuilderHelper::safeString($view['settings']->name_single, 'w');
}
elseif ($type === 'customAdmin')
{
$W_NameList = ComponentbuilderHelper::safeString($view['settings']->name, 'W');
$w_NameList = $view['settings']->name;
$w_NameSingle = $view['settings']->name;
}
switch ($nameBuilder)
{
case 'edit':
// set edit title
$permission['title'] = $W_NameList . ' Edit';
// set edit description
$permission['description'] = ' Allows the users in this group to edit the ' . $w_NameSingle;
break;
case 'edit___own':
// set edit title
$permission['title'] = $W_NameList . ' Edit Own';
// set edit description
$permission['description'] = ' Allows the users in this group to edit ' . $w_NameList . ' created by them';
break;
case 'edit___state':
// set edit title
$permission['title'] = $W_NameList . ' Edit State';
// set edit description
$permission['description'] = ' Allows the users in this group to update the state of the ' . $w_NameSingle;
break;
case 'edit___created_by':
// set edit title
$permission['title'] = $W_NameList . ' Edit Created By';
// set edit description
$permission['description'] = ' Allows the users in this group to update the created by of the ' . $w_NameList;
break;
case 'edit___created':
// set edit title
$permission['title'] = $W_NameList . ' Edit Created Date';
// set edit description
$permission['description'] = ' Allows the users in this group to update the created date of the ' . $w_NameList;
break;
case 'create':
// set edit title
$permission['title'] = $W_NameList . ' Create';
// set edit description
$permission['description'] = ' Allows the users in this group to create ' . $w_NameList;
break;
case 'delete':
// set edit title
$permission['title'] = $W_NameList . ' Delete';
// set edit description
$permission['description'] = ' Allows the users in this group to delete ' . $w_NameList;
break;
case 'access':
// set edit title
$permission['title'] = $W_NameList . ' Access';
// set edit description
$permission['description'] = ' Allows the users in this group to access ' . $w_NameList;
break;
case 'export':
// set edit title
$permission['title'] = $W_NameList . ' Export';
// set edit description
$permission['description'] = ' Allows the users in this group to export ' . $w_NameList;
break;
case 'import':
// set edit title
$permission['title'] = $W_NameList . ' Import';
// set edit description
$permission['description'] = ' Allows the users in this group to import ' . $w_NameList;
break;
case 'version':
// set edit title
$permission['title'] = $W_NameList . ' Edit Version';
// set edit description
$permission['description'] = ' Allows users in this group to edit versions of ' . $w_NameList;
break;
case 'batch':
// set edit title
$permission['title'] = $W_NameList . ' Batch Use';
// set edit description
$permission['description'] = ' Allows users in this group to use batch copy/update method of ' . $w_NameList;
break;
default:
// set edit title
$permission['title'] = $W_NameList . ' ' . ComponentbuilderHelper::safeString($customName, 'W');
// set edit description
$permission['description'] = ' Allows the users in this group to update the ' . ComponentbuilderHelper::safeString($customName, 'w') . ' of the ' . $w_NameSingle;
break;
}
// if core is not used update all core strings
$coreCheck = explode('.',$action);
$coreCheck[0] = 'core';
$coreTarget = implode('.',$coreCheck);
$this->permissionCore[$nameView][$coreTarget] = $action;
// set array sort name
$sortKey = ComponentbuilderHelper::safeString($permission['title']);
// set title
$title = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($permission['title'],'U');
// load the actions
if ($permission['implementation'] == 1)
{
// only related to view
$this->permissionViews[$nameView][] = '';
// load permission to action
$this->permissionBuilder[$action][$nameView] = $nameView;
}
elseif ($permission['implementation'] == 2)
{
// relation to whole component
$this->componentGlobal[$sortKey] = "\t\t".'';
// build permission switch
$this->permissionBuilder['global'][$action][$nameView] = $nameView;
// dashboard icon checker
if ($coreTarget === 'core.access')
{
$this->permissionDashboard[] = "'" . $nameViews . ".access' => '" . $action . "'";
$this->permissionDashboard[] = "'" . $nameView . ".access' => '" . $action . "'";
}
if ($coreTarget === 'core.create')
{
$this->permissionDashboard[] = "'" . $nameView . ".create' => '" . $action . "'";
}
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
if ($coreTarget === 'core.'.$menuController)
{
if ($menuController === 'dashboard_add')
{
$this->permissionDashboard[] = "'" . $nameView . ".".$menuController."' => '" . $action . "'";
}
else
{
$this->permissionDashboard[] = "'" . $nameViews . ".".$menuController."' => '" . $action . "'";
}
}
}
}
elseif ($permission['implementation'] == 3)
{
// only related to view
$this->permissionViews[$nameView][] = '';
// load permission to action
$this->permissionBuilder[$action][$nameView] = $nameView;
// relation to whole component
$this->componentGlobal[$sortKey] = "\t\t".'';
// build permission switch
$this->permissionBuilder['global'][$action][$nameView] = $nameView;
// dashboard icon checker
if ($coreTarget === 'core.access')
{
$this->permissionDashboard[] = "'" . $nameViews . ".access' => '" . $action . "'";
$this->permissionDashboard[] = "'" . $nameView . ".access' => '" . $action . "'";
}
if ($coreTarget === 'core.create')
{
$this->permissionDashboard[] = "'" . $nameView . ".create' => '" . $action . "'";
}
// add menu controll view that has menus options
foreach ($menuControllers as $menuController)
{
if ($coreTarget === 'core.'.$menuController)
{
if ($menuController === 'dashboard_add')
{
$this->permissionDashboard[] = "'" . $nameView . ".".$menuController."' => '" . $action . "'";
}
else
{
$this->permissionDashboard[] = "'" . $nameViews . ".".$menuController."' => '" . $action . "'";
}
}
}
}
// set to language file
$this->langContent['bothadmin'][$title] = trim($permission['title']);
$this->langContent['bothadmin'][$title.'_DESC'] = trim($permission['description']);
}
}
}
public function getFieldName($typeName,$xml,$alias)
{
// if category then name must be catid (only one per view)
if ($typeName === 'category')
{
return 'catid';
}
// if tag is set then enable all tag options for this view (only one per view)
elseif ($typeName === 'tag')
{
return 'tags';
}
// if the field is set as alias it must be called alias
elseif ($alias)
{
return 'alias';
}
elseif ($typeName === 'spacer')
{
// make sure the name is unique
return false;
}
else
{
return ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($xml,'name="','"'));
}
}
public function getFieldType($typeName,$xml,$property)
{
// make sure its lower case
$typeName = ComponentbuilderHelper::safeString($typeName);
if ($typeName === 'custom' || $typeName === 'customuser')
{
$xmlValue = ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($xml,'type="','"'));
}
// use field core type only if not found
elseif (ComponentbuilderHelper::checkString($typeName))
{
$xmlValue = $typeName;
}
// make sure none adjustable fields are set
elseif (isset($property['example']) && ComponentbuilderHelper::checkString($property['example']) && $property['adjustable'] == 0)
{
$xmlValue = $property['example'];
}
// fall back on the xml settings
else
{
$xmlValue = ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($xml,'type="','"'));
}
// check if the value is set
if (ComponentbuilderHelper::checkString($xmlValue))
{
// add the value
return $xmlValue;
}
else
{
// fall back to text
return 'text';
}
}
public function getInbetweenStrings($str, $start = '###', $end = '###')
{
$matches = array();
$regex = "/$start([a-zA-Z0-9_]*)$end/";
preg_match_all($regex, $str, $matches);
return $matches[1];
}
}