";
+ $script['view'][] = "\t";
+ $script['view'][] = "\t\t
";
+ $script['view'][] = "\t";
+ $script['view'][] = "";
+ $script['view'][] = "\n\thasPackage && ###-#-#-Component###Helper::checkArray(\$this->headerList) && ###-#-#-Component###Helper::checkArray(\$this->headers)) : ?>";
+ $script['view'][] = "\t\t
";
+ $script['view'][] = "\t\t
";
+ $script['view'][] = "\t";
+ $script['view'][] = "\t\t 'upload')); ?>";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t\t
";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t\t
";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "";
+ $script['view'][] = "\n\t\t";
+ $script['view'][] = "\t\t\t
";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t";
+ $script['view'][] = "\t\t
";
+ $script['view'][] = "\t";
+ $script['view'][] = "\t
";
+ $script['view'][] = "\t";
+ $script['view'][] = "";
+ $script['view'][] = "
";
+ }
+ elseif ('import' === $type)
+ {
+ $script['import'] = array();
+ $script['import'][] = "\t/**";
+ $script['import'][] = "\t * Import an spreadsheet from either folder, url or upload.";
+ $script['import'][] = "\t *";
+ $script['import'][] = "\t * @return boolean result of import";
+ $script['import'][] = "\t *";
+ $script['import'][] = "\t */";
+ $script['import'][] = "\tpublic function import()";
+ $script['import'][] = "\t{";
+ $script['import'][] = "\t\t\$this->setState('action', 'import');";
+ $script['import'][] = "\t\t\$app \t\t= JFactory::getApplication();";
+ $script['import'][] = "\t\t\$session \t= JFactory::getSession();";
+ $script['import'][] = "\t\t\$package \t= null;";
+ $script['import'][] = "\t\t\$continue\t= false;";
+ $script['import'][] = "\t\t// get import type";
+ $script['import'][] = "\t\t\$this->getType = \$app->input->getString('gettype', NULL);";
+ $script['import'][] = "\t\t// get import type";
+ $script['import'][] = "\t\t\$this->dataType\t= \$session->get('dataType_VDM_IMPORTINTO', NULL);";
+ $script['import'][] = "\n\t\tif (\$package === null)";
+ $script['import'][] = "\t\t{";
+ $script['import'][] = "\t\t\tswitch (\$this->getType)";
+ $script['import'][] = "\t\t\t{";
+ $script['import'][] = "\t\t\t\tcase 'folder':";
+ $script['import'][] = "\t\t\t\t\t// Remember the 'Import from Directory' path.";
+ $script['import'][] = "\t\t\t\t\t\$app->getUserStateFromRequest(\$this->_context . '.import_directory', 'import_directory');";
+ $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromFolder();";
+ $script['import'][] = "\t\t\t\t\tbreak;";
+ $script['import'][] = "\n\t\t\t\tcase 'upload':";
+ $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromUpload();";
+ $script['import'][] = "\t\t\t\t\tbreak;";
+ $script['import'][] = "\n\t\t\t\tcase 'url':";
+ $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromUrl();";
+ $script['import'][] = "\t\t\t\t\tbreak;";
+ $script['import'][] = "\n\t\t\t\tcase 'continue':";
+ $script['import'][] = "\t\t\t\t\t\$continue \t= true;";
+ $script['import'][] = "\t\t\t\t\t\$package\t= \$session->get('package', null);";
+ $script['import'][] = "\t\t\t\t\t\$package\t= json_decode(\$package, true);";
+ $script['import'][] = "\t\t\t\t\t// clear session";
+ $script['import'][] = "\t\t\t\t\t\$session->clear('package');";
+ $script['import'][] = "\t\t\t\t\t\$session->clear('dataType');";
+ $script['import'][] = "\t\t\t\t\t\$session->clear('hasPackage');";
+ $script['import'][] = "\t\t\t\t\tbreak;";
+ $script['import'][] = "\n\t\t\t\tdefault:";
+ $script['import'][] = "\t\t\t\t\t\$app->setUserState('com_###-#-#-component###.message', JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_NO_IMPORT_TYPE_FOUND'));";
+ $script['import'][] = "\n\t\t\t\t\treturn false;";
+ $script['import'][] = "\t\t\t\t\tbreak;";
+ $script['import'][] = "\t\t\t}";
+ $script['import'][] = "\t\t}";
+ $script['import'][] = "\t\t// Was the package valid?";
+ $script['import'][] = "\t\tif (!\$package || !\$package['type'])";
+ $script['import'][] = "\t\t{";
+ $script['import'][] = "\t\t\tif (in_array(\$this->getType, array('upload', 'url')))";
+ $script['import'][] = "\t\t\t{";
+ $script['import'][] = "\t\t\t\t\$this->remove(\$package['packagename']);";
+ $script['import'][] = "\t\t\t}";
+ $script['import'][] = "\n\t\t\t\$app->setUserState('com_###-#-#-component###.message', JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));";
+ $script['import'][] = "\t\t\treturn false;";
+ $script['import'][] = "\t\t}";
+ $script['import'][] = "\t\t";
+ $script['import'][] = "\t\t// first link data to table headers";
+ $script['import'][] = "\t\tif(!\$continue){";
+ $script['import'][] = "\t\t\t\$package\t= json_encode(\$package);";
+ $script['import'][] = "\t\t\t\$session->set('package', \$package);";
+ $script['import'][] = "\t\t\t\$session->set('dataType', \$this->dataType);";
+ $script['import'][] = "\t\t\t\$session->set('hasPackage', true);";
+ $script['import'][] = "\t\t\treturn true;";
+ $script['import'][] = "\t\t}";
+ $script['import'][] = "\t\t// set the data";
+ $script['import'][] = "\t\t\$headerList = json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false), true);";
+ $script['import'][] = "\t\tif (!\$this->setData(\$package,\$this->dataType,\$headerList))";
+ $script['import'][] = "\t\t{";
+ $script['import'][] = "\t\t\t// There was an error importing the package";
+ $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_ERROR');";
+ $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);";
+ $script['import'][] = "\t\t\tif (\$back)";
+ $script['import'][] = "\t\t\t{";
+ $script['import'][] = "\t\t\t\t\$app->setUserState('com_###-#-#-component###.redirect_url', 'index.php?option=com_###-#-#-component###&view='.\$back);";
+ $script['import'][] = "\t\t\t\t\$session->clear('backto_VDM_IMPORT');";
+ $script['import'][] = "\t\t\t}";
+ $script['import'][] = "\t\t\t\$result = false;";
+ $script['import'][] = "\t\t}";
+ $script['import'][] = "\t\telse";
+ $script['import'][] = "\t\t{";
+ $script['import'][] = "\t\t\t// Package imported sucessfully";
+ $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::sprintf('COM_###-#-#-COMPONENT###_IMPORT_SUCCESS', \$package['packagename']);";
+ $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);";
+ $script['import'][] = "\t\t\tif (\$back)";
+ $script['import'][] = "\t\t\t{";
+ $script['import'][] = "\t\t\t \$app->setUserState('com_###-#-#-component###.redirect_url', 'index.php?option=com_###-#-#-component###&view='.\$back);";
+ $script['import'][] = "\t\t\t \$session->clear('backto_VDM_IMPORT');";
+ $script['import'][] = "\t\t\t}";
+ $script['import'][] = "\t\t\t\$result = true;";
+ $script['import'][] = "\t\t}";
+ $script['import'][] = "\n\t\t// Set some model state values";
+ $script['import'][] = "\t\t\$app->enqueueMessage(\$msg);";
+ $script['import'][] = "\n\t\t// remove file after import";
+ $script['import'][] = "\t\t\$this->remove(\$package['packagename']);";
+ $script['import'][] = "\t\t\$session->clear(\$this->getType.'_VDM_IMPORTHEADERS');";
+ $script['import'][] = "\t\treturn \$result;";
+ $script['import'][] = "\t}";
+ }
+ elseif ('ext' === $type)
+ {
+ $script['ext'][] = "\t/**";
+ $script['ext'][] = "\t * Check the extension";
+ $script['ext'][] = "\t *";
+ $script['ext'][] = "\t * @param string \$file Name of the uploaded file";
+ $script['ext'][] = "\t *";
+ $script['ext'][] = "\t * @return boolean True on success";
+ $script['ext'][] = "\t *";
+ $script['ext'][] = "\t */";
+ $script['ext'][] = "\tprotected function checkExtension(\$file)";
+ $script['ext'][] = "\t{";
+ $script['ext'][] = "\t\t// check the extention";
+ $script['ext'][] = "\t\tswitch(strtolower(pathinfo(\$file, PATHINFO_EXTENSION)))";
+ $script['ext'][] = "\t\t{";
+ $script['ext'][] = "\t\t\tcase 'xls':";
+ $script['ext'][] = "\t\t\tcase 'ods':";
+ $script['ext'][] = "\t\t\tcase 'csv':";
+ $script['ext'][] = "\t\t\treturn true;";
+ $script['ext'][] = "\t\t\tbreak;";
+ $script['ext'][] = "\t\t}";
+ $script['ext'][] = "\t\treturn false;";
+ $script['ext'][] = "\t}";
+ }
+ // return the needed script
+ if (isset($script[$type]))
+ {
+ return str_replace('-#-#-', '', implode("\n",$script[$type]));
+ }
+ return false;
+ }
+
+ /**
+ * set the session defaults if not set
+ **/
+ protected static function setSessionDefaults()
+ {
+ // noting for now
+ return true;
+ }
+
+ /**
+ * the Butler
+ **/
+ public static $session = array();
+
+ /**
+ * the Butler Assistant
+ **/
+ protected static $localSession = array();
+
+ /**
+ * start a session if not already set, and load with data
+ **/
+ public static function loadSession()
+ {
+ if (!isset(self::$session) || !self::checkObject(self::$session))
+ {
+ self::$session = JFactory::getSession();
+ }
+ // set the defaults
+ self::setSessionDefaults();
+ }
+
+ /**
+ * give Session more to keep
+ **/
+ public static function set($key, $value)
+ {
+ // set to local memory to speed up program
+ self::$localSession[$key] = $value;
+ // load to session for later use
+ return self::$session->set($key, self::$localSession[$key]);
+ }
+
+ /**
+ * get info from Session
+ **/
+ public static function get($key, $default = null)
+ {
+ // check if in local memory
+ if (!isset(self::$localSession[$key]))
+ {
+ // set to local memory to speed up program
+ self::$localSession[$key] = self::$session->get($key, $default);
+ }
+ return self::$localSession[$key];
+ }
+
+
+ /**
+ * check if it is a new hash
+ **/
+ public static function newHash($hash, $name = 'backup', $type = 'hash', $key = '', $fileType = '.txt')
+ {
+ // make sure we have a hash
+ if (self::checkString($hash))
+ {
+ // first get the file path
+ $path_filename = self::getFilePath($name, $type, $key, $fileType, JPATH_COMPONENT_ADMINISTRATOR);
+ // set as read if not already set
+ if (($content = @file_get_contents($path_filename)) !== FALSE)
+ {
+ if ($hash == $content)
+ {
+ return false;
+ }
+ }
+ // set the hash
+ return self::writeFile($path_filename, $hash);
+ }
+ return false;
+ }
+
+ public static function jsonToString($value, $sperator = ", ", $table = null)
+ {
+ // check if string is JSON
+ $result = json_decode($value, true);
+ if (json_last_error() === JSON_ERROR_NONE)
+ {
+ // is JSON
+ if (self::checkArray($result))
+ {
+ if (self::checkString($table))
+ {
+ $names = array();
+ foreach ($result as $val)
+ {
+ if ($name = self::getVar($table, $val, 'id', 'name'))
+ {
+ $names[] = $name;
+ }
+ }
+ if (self::checkArray($names))
+ {
+ return (string) implode($sperator,$names);
+ }
+ }
+ return (string) implode($sperator,$result);
+ }
+ return (string) json_decode($value);
+ }
+ return $value;
+ }
+
+ /**
+ * Load the Component xml manifest.
+ **/
+ public static function manifest()
+ {
+ $manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml";
+ return simplexml_load_file($manifestUrl);
+ }
+
+ /**
+ * Load the Contributors details.
+ **/
+ public static function getContributors()
+ {
+ // get params
+ $params = JComponentHelper::getParams('com_componentbuilder');
+ // start contributors array
+ $contributors = array();
+ // get all Contributors (max 20)
+ $searchArray = range('0','20');
+ foreach($searchArray as $nr)
+ {
+ if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3))
+ {
+ // set link based of selected option
+ if($params->get("useContributor".$nr) == 1)
+ {
+ $link_front = '
';
+ $link_back = '';
+ }
+ elseif($params->get("useContributor".$nr) == 2)
+ {
+ $link_front = '
';
+ $link_back = '';
+ }
+ else
+ {
+ $link_front = '';
+ $link_back = '';
+ }
+ $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr));
+ $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
+ }
+ }
+ return $contributors;
+ }
+
+ /**
+ * Load the Component Help URLs.
+ **/
+ public static function getHelpUrl($view)
+ {
+ $user = JFactory::getUser();
+ $groups = $user->get('groups');
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url'));
+ $query->from('#__componentbuilder_help_document AS a');
+ $query->where('a.site_view = '.$db->quote($view));
+ $query->where('a.location = 2');
+ $query->where('a.published = 1');
+ $db->setQuery($query);
+ $db->execute();
+ if($db->getNumRows())
+ {
+ $helps = $db->loadObjectList();
+ if (self::checkArray($helps))
+ {
+ foreach ($helps as $nr => $help)
+ {
+ if ($help->target == 1)
+ {
+ $targetgroups = json_decode($help->groups, true);
+ if (!array_intersect($targetgroups, $groups))
+ {
+ // if user not in those target groups then remove the item
+ unset($helps[$nr]);
+ continue;
+ }
+ }
+ // set the return type
+ switch ($help->type)
+ {
+ // set joomla article
+ case 1:
+ return self::loadArticleLink($help->article);
+ break;
+ // set help text
+ case 2:
+ return self::loadHelpTextLink($help->id);
+ break;
+ // set Link
+ case 3:
+ return $help->url;
+ break;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the Article Link.
+ **/
+ protected static function loadArticleLink($id)
+ {
+ return JURI::root().'index.php?option=com_content&view=article&id='.$id.'&tmpl=component&layout=modal';
+ }
+
+ /**
+ * Get the Help Text Link.
+ **/
+ protected static function loadHelpTextLink($id)
+ {
+ $token = JSession::getFormToken();
+ return 'index.php?option=com_componentbuilder&task=help.getText&id=' . (int) $id . '&token=' . $token;
+ }
+
+ /**
+ * Get any component's model
+ **/
+ public static function getModel($name, $path = JPATH_COMPONENT_SITE, $component = 'componentbuilder')
+ {
+ // full path
+ $fullPath = $path . '/models';
+ // load the model file
+ JModelLegacy::addIncludePath($fullPath);
+ // get instance
+ $model = JModelLegacy::getInstance( $name, $component.'Model' );
+ // if model not found
+ if ($model == false)
+ {
+ require_once $fullPath.'/'.strtolower($name).'.php';
+ // build class name
+ $class = $prefix.$name;
+ // initialize the model
+ new $class();
+ $model = JModelLegacy::getInstance($name, $prefix);
+ }
+ return $model;
+ }
+
+ /**
+ * Add to asset Table
+ */
+ public static function setAsset($id,$table)
+ {
+ $parent = JTable::getInstance('Asset');
+ $parent->loadByName('com_componentbuilder');
+
+ $parentId = $parent->id;
+ $name = 'com_componentbuilder.'.$table.'.'.$id;
+ $title = '';
+
+ $asset = JTable::getInstance('Asset');
+ $asset->loadByName($name);
+
+ // Check for an error.
+ $error = $asset->getError();
+
+ if ($error)
+ {
+ $this->setError($error);
+
+ return false;
+ }
+ else
+ {
+ // Specify how a new or moved node asset is inserted into the tree.
+ if ($asset->parent_id != $parentId)
+ {
+ $asset->setLocation($parentId, 'last-child');
+ }
+
+ // Prepare the asset to be stored.
+ $asset->parent_id = $parentId;
+ $asset->name = $name;
+ $asset->title = $title;
+ // get the default asset rules
+ $rules = self::getDefaultAssetRules('com_componentbuilder',$table);
+ if ($rules instanceof JAccessRules)
+ {
+ $asset->rules = (string) $rules;
+ }
+
+ if (!$asset->check() || !$asset->store())
+ {
+ JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning');
+ return false;
+ }
+ else
+ {
+ // Create an asset_id or heal one that is corrupted.
+ $object = new stdClass();
+
+ // Must be a valid primary key value.
+ $object->id = $id;
+ $object->asset_id = (int) $asset->id;
+
+ // Update their asset_id to link to the asset table.
+ return JFactory::getDbo()->updateObject('#__componentbuilder_'.$table, $object, 'id');
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Gets the default asset Rules for a component/view.
+ */
+ protected static function getDefaultAssetRules($component,$view)
+ {
+ // Need to find the asset id by the name of the component.
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
+ ->select($db->quoteName('id'))
+ ->from($db->quoteName('#__assets'))
+ ->where($db->quoteName('name') . ' = ' . $db->quote($component));
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->loadRowList())
+ {
+ // asset alread set so use saved rules
+ $assetId = (int) $db->loadResult();
+ $result = JAccess::getAssetRules($assetId);
+ if ($result instanceof JAccessRules)
+ {
+ $_result = (string) $result;
+ $_result = json_decode($_result);
+ foreach ($_result as $name => &$rule)
+ {
+ $v = explode('.', $name);
+ if ($view !== $v[0])
+ {
+ // remove since it is not part of this view
+ unset($_result->$name);
+ }
+ else
+ {
+ // clear the value since we inherit
+ $rule = array();
+ }
+ }
+ // check if there are any view values remaining
+ if (count($_result))
+ {
+ $_result = json_encode($_result);
+ $_result = array($_result);
+ // Instantiate and return the JAccessRules object for the asset rules.
+ $rules = new JAccessRules($_result);
+
+ return $rules;
+ }
+ return $result;
+ }
+ }
+ return JAccess::getAssetRules(0);
+ }
+
+ public static function renderBoolButton()
+ {
+ $args = func_get_args();
+
+ // get the radio element
+ $button = JFormHelper::loadFieldType('radio');
+
+ // setup the properties
+ $name = self::htmlEscape($args[0]);
+ $additional = isset($args[1]) ? (string) $args[1] : '';
+ $value = $args[2];
+ $yes = isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES';
+ $no = isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO';
+
+ // prepare the xml
+ $element = new SimpleXMLElement('
');
+
+ // run
+ $button->setup($element, $value);
+
+ return $button->input;
+
+ }
+
+ /**
+ * UIKIT Component Classes
+ **/
+ public static $uk_components = array(
+ 'data-uk-grid' => array(
+ 'grid' ),
+ 'uk-accordion' => array(
+ 'accordion' ),
+ 'uk-autocomplete' => array(
+ 'autocomplete' ),
+ 'data-uk-datepicker' => array(
+ 'datepicker' ),
+ 'uk-form-password' => array(
+ 'form-password' ),
+ 'uk-form-select' => array(
+ 'form-select' ),
+ 'data-uk-htmleditor' => array(
+ 'htmleditor' ),
+ 'data-uk-lightbox' => array(
+ 'lightbox' ),
+ 'uk-nestable' => array(
+ 'nestable' ),
+ 'UIkit.notify' => array(
+ 'notify' ),
+ 'data-uk-parallax' => array(
+ 'parallax' ),
+ 'uk-search' => array(
+ 'search' ),
+ 'uk-slider' => array(
+ 'slider' ),
+ 'uk-slideset' => array(
+ 'slideset' ),
+ 'uk-slideshow' => array(
+ 'slideshow',
+ 'slideshow-fx' ),
+ 'uk-sortable' => array(
+ 'sortable' ),
+ 'data-uk-sticky' => array(
+ 'sticky' ),
+ 'data-uk-timepicker' => array(
+ 'timepicker' ),
+ 'data-uk-tooltip' => array(
+ 'tooltip' ),
+ 'uk-placeholder' => array(
+ 'placeholder' ),
+ 'uk-dotnav' => array(
+ 'dotnav' ),
+ 'uk-slidenav' => array(
+ 'slidenav' ),
+ 'uk-form' => array(
+ 'form-advanced' ),
+ 'uk-progress' => array(
+ 'progress' ),
+ 'upload-drop' => array(
+ 'upload', 'form-file' )
+ );
+
+ /**
+ * Add UIKIT Components
+ **/
+ public static $uikit = false;
+
+ /**
+ * Get UIKIT Components
+ **/
+ public static function getUikitComp($content,$classes = array())
+ {
+ if (strpos($content,'class="uk-') !== false)
+ {
+ // reset
+ $temp = array();
+ foreach (self::$uk_components as $looking => $add)
+ {
+ if (strpos($content,$looking) !== false)
+ {
+ $temp[] = $looking;
+ }
+ }
+ // make sure uikit is loaded to config
+ if (strpos($content,'class="uk-') !== false)
+ {
+ self::$uikit = true;
+ }
+ // sorter
+ if (self::checkArray($temp))
+ {
+ // merger
+ if (self::checkArray($classes))
+ {
+ $newTemp = array_merge($temp,$classes);
+ $temp = array_unique($newTemp);
+ }
+ return $temp;
+ }
+ }
+ if (self::checkArray($classes))
+ {
+ return $classes;
+ }
+ return false;
+ }
+
+ public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder')
+ {
+ if(!$where)
+ {
+ $where = JFactory::getUser()->id;
+ }
+ // Get a db connection.
+ $db = JFactory::getDbo();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->select($db->quoteName(array($what)));
+ if (empty($table))
+ {
+ $query->from($db->quoteName('#__'.$main));
+ }
+ else
+ {
+ $query->from($db->quoteName('#__'.$main.'_'.$table));
+ }
+ if (is_numeric($where))
+ {
+ $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
+ }
+ elseif (is_string($where))
+ {
+ $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
+ }
+ else
+ {
+ return false;
+ }
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->getNumRows())
+ {
+ return $db->loadResult();
+ }
+ return false;
+ }
+
+ public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true)
+ {
+ if(!$where)
+ {
+ $where = JFactory::getUser()->id;
+ }
+
+ if (!self::checkArray($where) && $where > 0)
+ {
+ $where = array($where);
+ }
+
+ if (self::checkArray($where))
+ {
+ // prep main <-- why? well if $main='' is empty then $table can be categories or users
+ if (self::checkString($main))
+ {
+ $main = '_'.ltrim($main, '_');
+ }
+ // Get a db connection.
+ $db = JFactory::getDbo();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+
+ $query->select($db->quoteName(array($what)));
+ if (empty($table))
+ {
+ $query->from($db->quoteName('#__'.$main));
+ }
+ else
+ {
+ $query->from($db->quoteName('#__'.$main.'_'.$table));
+ }
+ $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')');
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->getNumRows())
+ {
+ if ($unique)
+ {
+ return array_unique($db->loadColumn());
+ }
+ return $db->loadColumn();
+ }
+ }
+ return false;
+ }
+
+ public static function isPublished($id,$type)
+ {
+ if ($type == 'raw')
+ {
+ $type = 'item';
+ }
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query->select(array('a.published'));
+ $query->from('#__componentbuilder_'.$type.' AS a');
+ $query->where('a.id = '. (int) $id);
+ $query->where('a.published = 1');
+ $db->setQuery($query);
+ $db->execute();
+ $found = $db->getNumRows();
+ if($found)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static function getGroupName($id)
+ {
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+ $query->select(array('a.title'));
+ $query->from('#__usergroups AS a');
+ $query->where('a.id = '. (int) $id);
+ $db->setQuery($query);
+ $db->execute();
+ $found = $db->getNumRows();
+ if($found)
+ {
+ return $db->loadResult();
+ }
+ return $id;
+ }
+
+ /**
+ * Get the actions permissions
+ **/
+ public static function getActions($view,&$record = null,$views = null)
+ {
+ jimport('joomla.access.access');
+
+ $user = JFactory::getUser();
+ $result = new JObject;
+ $view = self::safeString($view);
+ if (self::checkString($views))
+ {
+ $views = self::safeString($views);
+ }
+ // get all actions from component
+ $actions = JAccess::getActions('com_componentbuilder', 'component');
+ // set acctions only set in component settiongs
+ $componentActions = array('core.admin','core.manage','core.options','core.export');
+ // loop the actions and set the permissions
+ foreach ($actions as $action)
+ {
+ // set to use component default
+ $fallback = true;
+ if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name,$componentActions))
+ {
+ // The record has been set. Check the record permissions.
+ $permission = $user->authorise($action->name, 'com_componentbuilder.'.$view.'.' . (int) $record->id);
+ if (!$permission) // TODO removed && !is_null($permission)
+ {
+ if ($action->name == 'core.edit' || $action->name == $view.'.edit')
+ {
+ if ($user->authorise('core.edit.own', 'com_componentbuilder.'.$view.'.' . (int) $record->id))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise($view.'edit.own', 'com_componentbuilder.'.$view.'.' . (int) $record->id))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise('core.edit.own', 'com_componentbuilder'))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise($view.'edit.own', 'com_componentbuilder'))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ }
+ }
+ elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
+ {
+ // make sure we use the core. action check for the categories
+ if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
+ $coreCheck = explode('.',$action->name);
+ $coreCheck[0] = 'core';
+ $categoryCheck = implode('.',$coreCheck);
+ }
+ else
+ {
+ $categoryCheck = $action->name;
+ }
+ // The record has a category. Check the category permissions.
+ $catpermission = $user->authorise($categoryCheck, 'com_componentbuilder.'.$views.'.category.' . (int) $record->catid);
+ if (!$catpermission && !is_null($catpermission))
+ {
+ if ($action->name == 'core.edit' || $action->name == $view.'.edit')
+ {
+ if ($user->authorise('core.edit.own', 'com_componentbuilder.'.$views.'.category.' . (int) $record->catid))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise($view.'edit.own', 'com_componentbuilder.'.$views.'.category.' . (int) $record->catid))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise('core.edit.own', 'com_componentbuilder'))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ elseif ($user->authorise($view.'edit.own', 'com_componentbuilder'))
+ {
+ // If the owner matches 'me' then allow.
+ if (isset($record->created_by) && $record->created_by > 0 && ($record->created_by == $user->id))
+ {
+ $result->set($action->name, true);
+ // set not to use component default
+ $fallback = false;
+ }
+ else
+ {
+ $result->set($action->name, false);
+ // set not to use component default
+ $fallback = false;
+ }
+ }
+ }
+ }
+ }
+ }
+ // if allowed then fallback on component global settings
+ if ($fallback)
+ {
+ $result->set($action->name, $user->authorise($action->name, 'com_componentbuilder'));
+ }
+ }
+ return $result;
+ }
+
+ public static function checkJson($string)
+ {
+ if (self::checkString($string))
+ {
+ json_decode($string);
+ return (json_last_error() === JSON_ERROR_NONE);
+ }
+ return false;
+ }
+
+ public static function checkObject($object)
+ {
+ if (isset($object) && is_object($object) && count($object) > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static function checkArray($array, $removeEmptyString = false)
+ {
+ if (isset($array) && is_array($array) && count($array) > 0)
+ {
+ // also make sure the empty strings are removed
+ if ($removeEmptyString)
+ {
+ foreach ($array as $key => $string)
+ {
+ if (empty($string))
+ {
+ unset($array[$key]);
+ }
+ }
+ return self::checkArray($array, false);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static function checkString($string)
+ {
+ if (isset($string) && is_string($string) && strlen($string) > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static function mergeArrays($arrays)
+ {
+ if(self::checkArray($arrays))
+ {
+ $arrayBuket = array();
+ foreach ($arrays as $array)
+ {
+ if (self::checkArray($array))
+ {
+ $arrayBuket = array_merge($arrayBuket, $array);
+ }
+ }
+ return $arrayBuket;
+ }
+ return false;
+ }
+
+ // typo sorry!
+ public static function sorten($string, $length = 40, $addTip = true)
+ {
+ return self::shorten($string, $length, $addTip);
+ }
+
+ public static function shorten($string, $length = 40, $addTip = true)
+ {
+ if (self::checkString($string))
+ {
+ $initial = strlen($string);
+ $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
+ $words_count = count($words);
+
+ $word_length = 0;
+ $last_word = 0;
+ for (; $last_word < $words_count; ++$last_word)
+ {
+ $word_length += strlen($words[$last_word]);
+ if ($word_length > $length)
+ {
+ break;
+ }
+ }
+
+ $newString = implode(array_slice($words, 0, $last_word));
+ $final = strlen($newString);
+ if ($initial != $final && $addTip)
+ {
+ $title = self::shorten($string, 400 , false);
+ return '
'.trim($newString).'...';
+ }
+ elseif ($initial != $final && !$addTip)
+ {
+ return trim($newString).'...';
+ }
+ }
+ return $string;
+ }
+
+ public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true)
+ {
+ if ($replaceNumbers === true)
+ {
+ // remove all numbers and replace with english text version (works well only up to millions)
+ $string = self::replaceNumbers($string);
+ }
+ // 0nly continue if we have a string
+ if (self::checkString($string))
+ {
+ // create file name without the extention that is safe
+ if ($type === 'filename')
+ {
+ // make sure VDM is not in the string
+ $string = str_replace('VDM', 'vDm', $string);
+ // Remove anything which isn't a word, whitespace, number
+ // or any of the following caracters -_()
+ // If you don't need to handle multi-byte characters
+ // you can use preg_replace rather than mb_ereg_replace
+ // Thanks @Ćukasz Rysiak!
+ // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
+ $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
+ // http://stackoverflow.com/a/2021729/1429677
+ return preg_replace('/\s+/', ' ', $string);
+ }
+ // remove all other characters
+ $string = trim($string);
+ $string = preg_replace('/'.$spacer.'+/', ' ', $string);
+ $string = preg_replace('/\s+/', ' ', $string);
+ $string = preg_replace("/[^A-Za-z ]/", '', $string);
+ // select final adaptations
+ if ($type === 'L' || $type === 'strtolower')
+ {
+ // replace white space with underscore
+ $string = preg_replace('/\s+/', $spacer, $string);
+ // default is to return lower
+ return strtolower($string);
+ }
+ elseif ($type === 'W')
+ {
+ // return a string with all first letter of each word uppercase(no undersocre)
+ return ucwords(strtolower($string));
+ }
+ elseif ($type === 'w' || $type === 'word')
+ {
+ // return a string with all lowercase(no undersocre)
+ return strtolower($string);
+ }
+ elseif ($type === 'Ww' || $type === 'Word')
+ {
+ // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre)
+ return ucfirst(strtolower($string));
+ }
+ elseif ($type === 'WW' || $type === 'WORD')
+ {
+ // return a string with all the uppercase(no undersocre)
+ return strtoupper($string);
+ }
+ elseif ($type === 'U' || $type === 'strtoupper')
+ {
+ // replace white space with underscore
+ $string = preg_replace('/\s+/', $spacer, $string);
+ // return all upper
+ return strtoupper($string);
+ }
+ elseif ($type === 'F' || $type === 'ucfirst')
+ {
+ // replace white space with underscore
+ $string = preg_replace('/\s+/', $spacer, $string);
+ // return with first caracter to upper
+ return ucfirst(strtolower($string));
+ }
+ elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
+ {
+ // convert all words to first letter uppercase
+ $string = ucwords(strtolower($string));
+ // remove white space
+ $string = preg_replace('/\s+/', '', $string);
+ // now return first letter lowercase
+ return lcfirst($string);
+ }
+ // return string
+ return $string;
+ }
+ // not a string
+ return '';
+ }
+
+ public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
+ {
+ if (self::checkString($var))
+ {
+ $filter = new JFilterInput();
+ $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML');
+ if ($shorten)
+ {
+ return self::shorten($string,$length);
+ }
+ return $string;
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ public static function replaceNumbers($string)
+ {
+ // set numbers array
+ $numbers = array();
+ // first get all numbers
+ preg_match_all('!\d+!', $string, $numbers);
+ // check if we have any numbers
+ if (isset($numbers[0]) && self::checkArray($numbers[0]))
+ {
+ foreach ($numbers[0] as $number)
+ {
+ $searchReplace[$number] = self::numberToString((int)$number);
+ }
+ // now replace numbers in string
+ $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string);
+ // check if we missed any, strange if we did.
+ return self::replaceNumbers($string);
+ }
+ // return the string with no numbers remaining.
+ return $string;
+ }
+
+ /**
+ * Convert an integer into an English word string
+ * Thanks to Tom Nicholson
+ *
+ * @input an int
+ * @returns a string
+ **/
+ public static function numberToString($x)
+ {
+ $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
+ "eight", "nine", "ten", "eleven", "twelve", "thirteen",
+ "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
+ "nineteen", "twenty", 30 => "thirty", 40 => "forty",
+ 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
+ 90 => "ninety" );
+
+ if(!is_numeric($x))
+ {
+ $w = $x;
+ }
+ elseif(fmod($x, 1) != 0)
+ {
+ $w = $x;
+ }
+ else
+ {
+ if($x < 0)
+ {
+ $w = 'minus ';
+ $x = -$x;
+ }
+ else
+ {
+ $w = '';
+ // ... now $x is a non-negative integer.
+ }
+
+ if($x < 21) // 0 to 20
+ {
+ $w .= $nwords[$x];
+ }
+ elseif($x < 100) // 21 to 99
+ {
+ $w .= $nwords[10 * floor($x/10)];
+ $r = fmod($x, 10);
+ if($r > 0)
+ {
+ $w .= ' '. $nwords[$r];
+ }
+ }
+ elseif($x < 1000) // 100 to 999
+ {
+ $w .= $nwords[floor($x/100)] .' hundred';
+ $r = fmod($x, 100);
+ if($r > 0)
+ {
+ $w .= ' and '. self::numberToString($r);
+ }
+ }
+ elseif($x < 1000000) // 1000 to 999999
+ {
+ $w .= self::numberToString(floor($x/1000)) .' thousand';
+ $r = fmod($x, 1000);
+ if($r > 0)
+ {
+ $w .= ' ';
+ if($r < 100)
+ {
+ $w .= 'and ';
+ }
+ $w .= self::numberToString($r);
+ }
+ }
+ else // millions
+ {
+ $w .= self::numberToString(floor($x/1000000)) .' million';
+ $r = fmod($x, 1000000);
+ if($r > 0)
+ {
+ $w .= ' ';
+ if($r < 100)
+ {
+ $w .= 'and ';
+ }
+ $w .= self::numberToString($r);
+ }
+ }
+ }
+ return $w;
+ }
+
+ /**
+ * Random Key
+ *
+ * @returns a string
+ **/
+ public static function randomkey($size)
+ {
+ $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
+ $key = array();
+ $bagsize = strlen($bag) - 1;
+ for ($i = 0; $i < $size; $i++)
+ {
+ $get = rand(0, $bagsize);
+ $key[] = $bag[$get];
+ }
+ return implode($key);
+ }
+
+ public static function getCryptKey($type, $default = null)
+ {
+ if ('basic' === $type)
+ {
+ // Get the global params
+ $params = JComponentHelper::getParams('com_componentbuilder', true);
+ $basic_key = $params->get('basic_key', $default);
+ if ($basic_key)
+ {
+ return $basic_key;
+ }
+ }
+ return false;
+ }
+}
diff --git a/site/helpers/headercheck.php b/site/helpers/headercheck.php
new file mode 100644
index 000000000..6236cebdd
--- /dev/null
+++ b/site/helpers/headercheck.php
@@ -0,0 +1,85 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+class componentbuilderHeaderCheck
+{
+ function js_loaded($script_name)
+ {
+ // UIkit check point
+ if (strpos($script_name,'uikit') !== false)
+ {
+ $app = JFactory::getApplication();
+ $getTemplateName = $app->getTemplate('template')->template;
+
+ if (strpos($getTemplateName,'yoo') !== false)
+ {
+ return true;
+ }
+ }
+
+ $document = JFactory::getDocument();
+ $head_data = $document->getHeadData();
+ foreach (array_keys($head_data['scripts']) as $script)
+ {
+ if (stristr($script, $script_name))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function css_loaded($script_name)
+ {
+ // UIkit check point
+ if (strpos($script_name,'uikit') !== false)
+ {
+ $app = JFactory::getApplication();
+ $getTemplateName = $app->getTemplate('template')->template;
+
+ if (strpos($getTemplateName,'yoo') !== false)
+ {
+ return true;
+ }
+ }
+
+ $document = JFactory::getDocument();
+ $head_data = $document->getHeadData();
+
+ foreach (array_keys($head_data['styleSheets']) as $script)
+ {
+ if (stristr($script, $script_name))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/site/helpers/index.html b/site/helpers/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/helpers/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/helpers/route.php b/site/helpers/route.php
new file mode 100644
index 000000000..da287a82d
--- /dev/null
+++ b/site/helpers/route.php
@@ -0,0 +1,262 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+// Component Helper
+jimport('joomla.application.component.helper');
+jimport('joomla.application.categories');
+
+/**
+ * Componentbuilder Route Helper
+ **/
+abstract class ComponentbuilderHelperRoute
+{
+ protected static $lookup;
+
+ /**
+ * @param int The route of the Api
+ */
+ public static function getApiRoute($id = 0, $catid = 0)
+ {
+ if ($id > 0)
+ {
+ // Initialize the needel array.
+ $needles = array(
+ 'api' => array((int) $id)
+ );
+ // Create the link
+ $link = 'index.php?option=com_componentbuilder&view=api&id='. $id;
+ }
+ else
+ {
+ // Initialize the needel array.
+ $needles = array();
+ //Create the link but don't add the id.
+ $link = 'index.php?option=com_componentbuilder&view=api';
+ }
+ if ($catid > 1)
+ {
+ $categories = JCategories::getInstance('componentbuilder.api');
+ $category = $categories->get($catid);
+ if ($category)
+ {
+ $needles['category'] = array_reverse($category->getPath());
+ $needles['categories'] = $needles['category'];
+ $link .= '&catid='.$catid;
+ }
+ }
+
+ if ($item = self::_findItem($needles))
+ {
+ $link .= '&Itemid='.$item;
+ }
+
+ return $link;
+ }
+
+ /**
+ * Get the URL route for componentbuilder category from a category ID and language
+ *
+ * @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode
+ * @param mixed $language The id of the language being used.
+ *
+ * @return string The link to the contact
+ *
+ * @since 1.5
+ */
+ public static function getCategoryRoute_keep_for_later($catid, $language = 0)
+ {
+ if ($catid instanceof JCategoryNode)
+ {
+ $id = $catid->id;
+ $category = $catid;
+ }
+ else
+ {
+ throw new Exception('First parameter must be JCategoryNode');
+ }
+
+ $views = array(
+ "com_componentbuilder.fields" => "field",
+ "com_componentbuilder.fieldtypes" => "fieldtype");
+ $view = $views[$category->extension];
+
+ if ($id < 1 || !($category instanceof JCategoryNode))
+ {
+ $link = '';
+ }
+ else
+ {
+ //Create the link
+ $link = 'index.php?option=com_componentbuilder&view='.$view.'&category='.$category->slug;
+
+ $needles = array(
+ $view => array($id),
+ 'category' => array($id)
+ );
+
+ if ($language && $language != "*" && JLanguageMultilang::isEnabled())
+ {
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
+ ->select('a.sef AS sef')
+ ->select('a.lang_code AS lang_code')
+ ->from('#__languages AS a');
+
+ $db->setQuery($query);
+ $langs = $db->loadObjectList();
+ foreach ($langs as $lang)
+ {
+ if ($language == $lang->lang_code)
+ {
+ $link .= '&lang='.$lang->sef;
+ $needles['language'] = $language;
+ }
+ }
+ }
+
+ if ($item = self::_findItem($needles,'category'))
+ {
+
+ $link .= '&Itemid='.$item;
+ }
+ else
+ {
+ if ($category)
+ {
+ $catids = array_reverse($category->getPath());
+ $needles = array(
+ 'category' => $catids
+ );
+ if ($item = self::_findItem($needles,'category'))
+ {
+ $link .= '&Itemid='.$item;
+ }
+ elseif ($item = self::_findItem(null, 'category'))
+ {
+ $link .= '&Itemid='.$item;
+ }
+ }
+ }
+ }
+ return $link;
+ }
+
+ protected static function _findItem($needles = null,$type = null)
+ {
+ $app = JFactory::getApplication();
+ $menus = $app->getMenu('site');
+ $language = isset($needles['language']) ? $needles['language'] : '*';
+
+ // Prepare the reverse lookup array.
+ if (!isset(self::$lookup[$language]))
+ {
+ self::$lookup[$language] = array();
+
+ $component = JComponentHelper::getComponent('com_componentbuilder');
+
+ $attributes = array('component_id');
+ $values = array($component->id);
+
+ if ($language != '*')
+ {
+ $attributes[] = 'language';
+ $values[] = array($needles['language'], '*');
+ }
+
+ $items = $menus->getItems($attributes, $values);
+
+ foreach ($items as $item)
+ {
+ if (isset($item->query) && isset($item->query['view']))
+ {
+ $view = $item->query['view'];
+
+ if (!isset(self::$lookup[$language][$view]))
+ {
+ self::$lookup[$language][$view] = array();
+ }
+
+ if (isset($item->query['id']))
+ {
+ /**
+ * Here it will become a bit tricky
+ * language != * can override existing entries
+ * language == * cannot override existing entries
+ */
+ if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
+ {
+ self::$lookup[$language][$view][$item->query['id']] = $item->id;
+ }
+ }
+ }
+ }
+ }
+
+ if ($needles)
+ {
+ foreach ($needles as $view => $ids)
+ {
+ if (isset(self::$lookup[$language][$view]))
+ {
+ foreach ($ids as $id)
+ {
+ if (isset(self::$lookup[$language][$view][(int) $id]))
+ {
+ return self::$lookup[$language][$view][(int) $id];
+ }
+ }
+ }
+ }
+ }
+
+ if ($type)
+ {
+ // Check if the global menu item has been set.
+ $params = JComponentHelper::getParams('com_componentbuilder');
+ if ($item = $params->get($type.'_menu', 0))
+ {
+ return $item;
+ }
+ }
+
+ // Check if the active menuitem matches the requested language
+ $active = $menus->getActive();
+
+ if ($active
+ && $active->component == 'com_componentbuilder'
+ && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
+ {
+ return $active->id;
+ }
+
+ // If not found, return language specific home link
+ $default = $menus->getDefault($language);
+
+ return !empty($default->id) ? $default->id : null;
+ }
+}
diff --git a/site/index.html b/site/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/language/en-GB/en-GB.com_componentbuilder.ini b/site/language/en-GB/en-GB.com_componentbuilder.ini
new file mode 100644
index 000000000..413e48851
--- /dev/null
+++ b/site/language/en-GB/en-GB.com_componentbuilder.ini
@@ -0,0 +1,53 @@
+COM_COMPONENTBUILDER="Component Builder"
+COM_COMPONENTBUILDER_API="Api"
+COM_COMPONENTBUILDER_API_DESC="Sync Portal API"
+COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator."
+COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully"
+COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there."
+COM_COMPONENTBUILDER_COMPANY_S="Company: %s"
+COM_COMPONENTBUILDER_COPYRIGHT_S="Copyright: %s"
+COM_COMPONENTBUILDER_CREATE_NEW_S="Create New %s"
+COM_COMPONENTBUILDER_EDIT_S="Edit %s"
+COM_COMPONENTBUILDER_EMAIL_S="Email: %s"
+COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SEND="Email with the new key was send"
+COM_COMPONENTBUILDER_EMCOMPANYEM_BSB="Company: %s"
+COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB="Copyright: %s"
+COM_COMPONENTBUILDER_EMEMAILEM_BSB="Email: %s"
+COM_COMPONENTBUILDER_EMLICENSEEM_BSB="License: %s"
+COM_COMPONENTBUILDER_EMOWNEREM_BSB="Owner: %s"
+COM_COMPONENTBUILDER_EMWEBSITEEM_BSB="Website: %s"
+COM_COMPONENTBUILDER_ERROR="Error!"
+COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY="Joomla Component Builder - Backup Key"
+COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED="Key has not changed"
+COM_COMPONENTBUILDER_LICENSE_S="License: %s"
+COM_COMPONENTBUILDER_NEW="New"
+COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="No keys were found. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
+COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET="Owner details was set"
+COM_COMPONENTBUILDER_OWNER_S="Owner: %s"
+COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS="Package Owner Details"
+COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set"
+COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it."
+COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it."
+COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
+COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
+COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE="The package key is: %s
"
+COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S="The package key is: %s"
+COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key."
+COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there."
+COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there."
+COM_COMPONENTBUILDER_WEBSITE_S="Website: %s"
+COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY_WITHOUT_THIS_KEY_IT_WILL_TAKE_THE_CURRENT_TECHNOLOGY_WITH_A_BRUTE_FORCE_ATTACK_METHOD_MORE_THEN_A_HREFHTTPRANDOMIZECOMHOWLONGTOHACKPASS_TARGET_BLANK_TITLEHOW_LONG_TO_HACK_PASSSEVEN_HUNDRED_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZEROA_YEARS_TO_CRACK_THEORETICALLY_UNLESS_THEY_HAVE_THIS_KEY_ABOVE_SO_DO_KEEP_IT_SAFE="Your data is encrypted with a AES 128 bit encryption using the above 32 character key. Without this key it will take the current technology with a brute force attack method more then 700 000 000 000 000 000 000 000 000 000 000 years to crack theoretically. Unless they have this key above, so do keep it safe."
+COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS="You should add the correct owner details."
+COM_CONTENT_FIELD_MODIFIED_DESC="The last date this item was modified."
+JGLOBAL_FIELD_ID_DESC="Record number in the database."
+JGLOBAL_FIELD_ID_LABEL="ID"
+JGLOBAL_FIELD_MODIFIED_BY_DESC="The user who did the last modification."
+JGLOBAL_FIELD_MODIFIED_BY_LABEL="Modified By"
+JGLOBAL_FIELD_MODIFIED_LABEL="Modified Date"
+JTOOLBAR_APPLY="Save"
+JTOOLBAR_CANCEL="Cancel"
+JTOOLBAR_CLOSE="Close"
+JTOOLBAR_HELP="Help"
+JTOOLBAR_SAVE="Save & Close"
+JTOOLBAR_SAVE_AND_NEW="Save & New"
+JTOOLBAR_SAVE_AS_COPY="Save as Copy"
diff --git a/site/language/en-GB/en-GB.com_componentbuilder.sys.ini b/site/language/en-GB/en-GB.com_componentbuilder.sys.ini
new file mode 100644
index 000000000..d00ef7909
--- /dev/null
+++ b/site/language/en-GB/en-GB.com_componentbuilder.sys.ini
@@ -0,0 +1 @@
+COM_COMPONENTBUILDER="Component Builder"
diff --git a/site/language/en-GB/index.html b/site/language/en-GB/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/language/en-GB/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/language/index.html b/site/language/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/language/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/layouts/index.html b/site/layouts/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/layouts/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/models/api.php b/site/models/api.php
new file mode 100644
index 000000000..1948e8044
--- /dev/null
+++ b/site/models/api.php
@@ -0,0 +1,176 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+// import Joomla modelitem library
+jimport('joomla.application.component.modelitem');
+
+/**
+ * Componentbuilder Api Model
+ */
+class ComponentbuilderModelApi extends JModelItem
+{
+ /**
+ * Model context string.
+ *
+ * @var string
+ */
+ protected $_context = 'com_componentbuilder.api';
+
+ /**
+ * Model user data.
+ *
+ * @var strings
+ */
+ protected $user;
+ protected $userId;
+ protected $guest;
+ protected $groups;
+ protected $levels;
+ protected $app;
+ protected $input;
+ protected $uikitComp;
+
+ /**
+ * @var object item
+ */
+ protected $item;
+
+ /**
+ * Method to auto-populate the model state.
+ *
+ * Note. Calling getState in this method will result in recursion.
+ *
+ * @since 1.6
+ *
+ * @return void
+ */
+ protected function populateState()
+ {
+ $this->app = JFactory::getApplication();
+ $this->input = $this->app->input;
+ // Get the itme main id
+ $id = $this->input->getInt('id', null);
+ $this->setState('api.id', $id);
+
+ // Load the parameters.
+ $params = $this->app->getParams();
+ $this->setState('params', $params);
+ parent::populateState();
+ }
+
+ /**
+ * Method to get article data.
+ *
+ * @param integer $pk The id of the article.
+ *
+ * @return mixed Menu item data object on success, false on failure.
+ */
+ public function getItem($pk = null)
+ {
+ $this->user = JFactory::getUser();
+ $this->userId = $this->user->get('id');
+ $this->guest = $this->user->get('guest');
+ $this->groups = $this->user->get('groups');
+ $this->authorisedGroups = $this->user->getAuthorisedGroups();
+ $this->levels = $this->user->getAuthorisedViewLevels();
+ $this->initSet = true;
+
+ $pk = (!empty($pk)) ? $pk : (int) $this->getState('api.id');
+
+ if ($this->_item === null)
+ {
+ $this->_item = array();
+ }
+
+ if (!isset($this->_item[$pk]))
+ {
+ try
+ {
+ // Get a db connection.
+ $db = JFactory::getDbo();
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+
+ // Get from #__componentbuilder_joomla_component as a
+ $query->select($db->quoteName(
+ array('a.ordering'),
+ array('ordering')));
+ $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
+
+ // Reset the query using our newly populated query object.
+ $db->setQuery($query);
+ // Load the results as a stdClass object.
+ $data = $db->loadObject();
+
+ if (empty($data))
+ {
+ $app = JFactory::getApplication();
+ // If no data is found redirect to default page and show warning.
+ $app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
+ $app->redirect(JURI::root());
+ return false;
+ }
+
+ // set data object to item.
+ $this->_item[$pk] = $data;
+ }
+ catch (Exception $e)
+ {
+ if ($e->getCode() == 404)
+ {
+ // Need to go thru the error handler to allow Redirect to work.
+ JError::raiseWaring(404, $e->getMessage());
+ }
+ else
+ {
+ $this->setError($e);
+ $this->_item[$pk] = false;
+ }
+ }
+ }
+
+ return $this->_item[$pk];
+ }
+
+
+ /**
+ * Get the uikit needed components
+ *
+ * @return mixed An array of objects on success.
+ *
+ */
+ public function getUikitComp()
+ {
+ if (isset($this->uikitComp) && ComponentbuilderHelper::checkArray($this->uikitComp))
+ {
+ return $this->uikitComp;
+ }
+ return false;
+ }
+}
diff --git a/site/models/index.html b/site/models/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/models/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/router.php b/site/router.php
new file mode 100644
index 000000000..0b0649571
--- /dev/null
+++ b/site/router.php
@@ -0,0 +1,240 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+/**
+ * Routing class from com_componentbuilder
+ *
+ * @since 3.3
+ */
+class ComponentbuilderRouter extends JComponentRouterBase
+{
+ /**
+ * Build the route for the com_componentbuilder component
+ *
+ * @param array &$query An array of URL arguments
+ *
+ * @return array The URL arguments to use to assemble the subsequent URL.
+ *
+ * @since 3.3
+ */
+ public function build(&$query)
+ {
+ $segments = array();
+
+ // Get a menu item based on Itemid or currently active
+ $params = JComponentHelper::getParams('com_componentbuilder');
+
+ if (empty($query['Itemid']))
+ {
+ $menuItem = $this->menu->getActive();
+ }
+ else
+ {
+ $menuItem = $this->menu->getItem($query['Itemid']);
+ }
+
+ $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
+ $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
+
+ if (isset($query['view']))
+ {
+ $view = $query['view'];
+
+ if (empty($query['Itemid']))
+ {
+ $segments[] = $query['view'];
+ }
+
+ unset($query['view']);
+ }
+
+ // Are we dealing with a item that is attached to a menu item?
+ if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id']))
+ {
+ unset($query['view']);
+ unset($query['catid']);
+ unset($query['id']);
+ return $segments;
+ }
+
+ if (isset($view) && isset($query['id']) && ($view === 'api'))
+ {
+ if ($mId != (int) $query['id'] || $mView != $view)
+ {
+ if (($view === 'api'))
+ {
+ $segments[] = $view;
+ $id = explode(':', $query['id']);
+ if (count($id) == 2)
+ {
+ $segments[] = $id[1];
+ }
+ else
+ {
+ $segments[] = $id[0];
+ }
+ }
+ }
+ unset($query['id']);
+ }
+
+ $total = count($segments);
+
+ for ($i = 0; $i < $total; $i++)
+ {
+ $segments[$i] = str_replace(':', '-', $segments[$i]);
+ }
+
+ return $segments;
+
+ }
+
+ /**
+ * Parse the segments of a URL.
+ *
+ * @param array &$segments The segments of the URL to parse.
+ *
+ * @return array The URL attributes to be used by the application.
+ *
+ * @since 3.3
+ */
+ public function parse(&$segments)
+ {
+ $count = count($segments);
+ $vars = array();
+
+ //Handle View and Identifier
+ switch($segments[0])
+ {
+ case 'api':
+ $vars['view'] = 'api';
+ if (is_numeric($segments[$count-1]))
+ {
+ $vars['id'] = (int) $segments[$count-1];
+ }
+ elseif ($segments[$count-1])
+ {
+ $id = $this->getVar('joomla_component', $segments[$count-1], 'alias', 'id');
+ if($id)
+ {
+ $vars['id'] = $id;
+ }
+ }
+ break;
+ }
+
+ return $vars;
+ }
+
+ protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'componentbuilder')
+ {
+ if(!$where || !$what || !$whereString)
+ {
+ return false;
+ }
+ // Get a db connection.
+ $db = JFactory::getDbo();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+
+ $query->select($db->quoteName(array($what)));
+ if ('categories' == $table || 'category' == $table || $category)
+ {
+ $getTable = '#__categories';
+ $query->from($db->quoteName($getTable));
+ }
+ else
+ {
+ // we must check if the table exist (TODO not ideal)
+ $tables = $db->getTableList();
+ $app = JFactory::getApplication();
+ $prefix = $app->get('dbprefix');
+ $check = $prefix.$main.'_'.$table;
+ if (in_array($check, $tables))
+ {
+ $getTable = '#__'.$main.'_'.$table;
+ $query->from($db->quoteName($getTable));
+ }
+ else
+ {
+ return false;
+ }
+ }
+ if (is_numeric($where))
+ {
+ return false;
+ }
+ elseif ($this->checkString($where))
+ {
+ // we must first check if this table has the column
+ $columns = $db->getTableColumns($getTable);
+ if (isset($columns[$whereString]))
+ {
+ $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->getNumRows())
+ {
+ return $db->loadResult();
+ }
+ return false;
+ }
+
+ protected function checkString($string)
+ {
+ if (isset($string) && is_string($string) && strlen($string) > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+}
+
+function ComponentbuilderBuildRoute(&$query)
+{
+ $router = new ComponentbuilderRouter;
+
+ return $router->build($query);
+}
+
+function ComponentbuilderParseRoute($segments)
+{
+ $router = new ContentRouter;
+
+ return $router->parse($segments);
+}
\ No newline at end of file
diff --git a/site/views/api/index.html b/site/views/api/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/views/api/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/views/api/submitbutton.js b/site/views/api/submitbutton.js
new file mode 100644
index 000000000..2151e1a73
--- /dev/null
+++ b/site/views/api/submitbutton.js
@@ -0,0 +1,49 @@
+/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
+ __ __ _ _____ _ _ __ __ _ _ _
+ \ \ / / | | | __ \ | | | | | \/ | | | | | | |
+ \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
+ \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
+ \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
+ \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
+ | |
+ |_|
+/-------------------------------------------------------------------------------------------------------------------------------/
+
+ @version 2.4.10
+ @build 19th August, 2017
+ @created 30th April, 2015
+ @package Component Builder
+ @subpackage submitbutton.js
+ @author Llewellyn van der Merwe
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+Joomla.submitbutton = function(task)
+{
+ if (task == ''){
+ return false;
+ } else {
+ var isValid=true;
+ var action = task.split('.');
+ if (action[1] != 'cancel' && action[1] != 'close'){
+ var forms = $$('form.form-validate');
+ for (var i=0;i
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+?>
+
+
+
+
diff --git a/site/views/api/tmpl/index.html b/site/views/api/tmpl/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/views/api/tmpl/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/views/api/view.html.php b/site/views/api/view.html.php
new file mode 100644
index 000000000..e91eeff6d
--- /dev/null
+++ b/site/views/api/view.html.php
@@ -0,0 +1,129 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ Builds Complex Joomla Components
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+// import Joomla view library
+jimport('joomla.application.component.view');
+
+/**
+ * Componentbuilder View class for the Api
+ */
+class ComponentbuilderViewApi extends JViewLegacy
+{
+ // Overwriting JView display method
+ function display($tpl = null)
+ {
+ // get combined params of both component and menu
+ $this->app = JFactory::getApplication();
+ $this->params = $this->app->getParams();
+ $this->menu = $this->app->getMenu()->getActive();
+ // get the user object
+ $this->user = JFactory::getUser();
+ // Initialise variables.
+ $this->item = $this->get('Item');
+
+ // Check for errors.
+ if (count($errors = $this->get('Errors')))
+ {
+ JError::raiseError(500, implode(PHP_EOL, $errors));
+ return false;
+ }
+
+ // Set the toolbar
+ $this->addToolBar();
+
+ // set the document
+ $this->_prepareDocument();
+
+ parent::display($tpl);
+ }
+
+ /**
+ * Prepares the document
+ */
+ protected function _prepareDocument()
+ {
+
+ // always make sure jquery is loaded.
+ JHtml::_('jquery.framework');
+ // Load the header checker class.
+ require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );
+ // Initialize the header checker.
+ $HeaderCheck = new componentbuilderHeaderCheck;
+
+ // Load uikit options.
+ $uikit = $this->params->get('uikit_load');
+ // Set script size.
+ $size = $this->params->get('uikit_min');
+ // Set css style.
+ $style = $this->params->get('uikit_style');
+
+ // The uikit css.
+ if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addStyleSheet(JURI::root(true) .'/media/com_componentbuilder/uikit/css/uikit'.$style.$size.'.css');
+ }
+ // The uikit js.
+ if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addScript(JURI::root(true) .'/media/com_componentbuilder/uikit/js/uikit'.$size.'.js');
+ }
+ // add the document default css file
+ $this->document->addStyleSheet(JURI::root(true) .'/components/com_componentbuilder/assets/css/api.css');
+ }
+
+ /**
+ * Setting the toolbar
+ */
+ protected function addToolBar()
+ {
+ // adding the joomla toolbar to the front
+ JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
+
+ // set help url for this view if found
+ $help_url = ComponentbuilderHelper::getHelpUrl('api');
+ if (ComponentbuilderHelper::checkString($help_url))
+ {
+ JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url);
+ }
+ // now initiate the toolbar
+ $this->toolbar = JToolbar::getInstance();
+ }
+
+ /**
+ * Escapes a value for output in a view script.
+ *
+ * @param mixed $var The output to escape.
+ *
+ * @return mixed The escaped value.
+ */
+ public function escape($var, $sorten = false, $length = 40)
+ {
+ // use the helper htmlEscape method instead.
+ return ComponentbuilderHelper::htmlEscape($var, $this->_charset, $sorten, $length);
+ }
+}
diff --git a/site/views/index.html b/site/views/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/views/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file