function addSportsType() { echo JText::_('Inserting default Sport-Types'); $status = 0; $db = JFactory::getDbo(); $extension = "com_joomleague_sport_types"; $lang = JFactory::getLanguage(); $source = JPATH_ADMINISTRATOR . '/components/' . $extension; $lang->load("{$extension}", JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension, $source, null, false, false) || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension, $source, $lang->getDefault(), false, false); $status = 1; $jllang = new JLLanguage(); $jllang->setLanguage($lang); $props = $jllang->getProperties(); $strings = $props['strings']; $praefix = 'COM_JOOMLEAGUE_ST_'; foreach ($strings as $key => $value) { // Add all Sport-types e.g. Soccer to #__joomleague_sports_type $pos = strpos($key, $praefix); if ($pos !== false) { $name = strtolower(substr($key, strlen($praefix))); $tblSportsType = JTable::getInstance("SportsType", "Table"); //fix for existing items $tblSportsType->load(array("name" => $key)); $tblSportsType->name = $key; $tblSportsType->icon = JPATH::clean('images/com_joomleague/database/sport_types/' . $name . '.png'); if (!$tblSportsType->store()) { //echo($tblSportsType->getError()); $status = 2; } JFolder::create(JPATH::clean(JPATH_ROOT . '/images/com_joomleague/database/events/' . $name)); } } return $status; }
public function display($tpl = null) { $option = JRequest::getCmd('option'); $app = JFactory::getApplication(); $document = JFactory::getDocument(); $version = urlencode(JoomleagueHelper::getVersion()); //support for global client side lang res JHtml::_('behavior.formvalidation'); // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); $lang = JFactory::getLanguage(); $jllang = new JLLanguage(); $jllang->setLanguage($lang); $props = $jllang->getProperties(); $strings =& $props['strings']; foreach ($strings as $key => $value) { if ($app->isAdmin()) { if (strpos($key, 'COM_JOOMLEAGUE_ADMIN_' . strtoupper($this->getName()) . '_CSJS') !== false) { JText::script($key, true); } } else { if (strpos($key, 'COM_JOOMLEAGUE_' . strtoupper($this->getName()) . '_CSJS_') !== false) { JText::script($key, true); } } } // General Joomleague CSS include $file = JPATH_COMPONENT . '/assets/css/joomleague.css'; if (file_exists(JPath::clean($file))) { $document->addStyleSheet($this->baseurl . '/components/' . $option . '/assets/css/joomleague.css?v=' . $version); } // Genereal CSS include per view $file = JPATH_COMPONENT . '/assets/css/' . $this->getName() . '.css'; if (file_exists(JPath::clean($file))) { //add css file $document->addStyleSheet($this->baseurl . '/components/' . $option . '/assets/css/' . $this->getName() . '.css?v=' . $version); } // General Joomleague JS include $file = JPATH_COMPONENT . '/assets/js/joomleague.js'; if (file_exists(JPath::clean($file))) { $js = $this->baseurl . '/components/' . $option . '/assets/js/joomleague.js?v=' . $version; $document->addScript($js); } // General JS include per view self::includeLanguageStrings(); $file = JPATH_COMPONENT . '/assets/js/' . $this->getName() . '.js'; if (file_exists(JPath::clean($file))) { $js = $this->baseurl . '/components/' . $option . '/assets/js/' . $this->getName() . '.js?v=' . $version; $document->addScript($js); } //extension management $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p')); foreach ($extensions as $e => $extension) { $JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . '/extensions/' . $extension; //General extension CSS include $file = $JLGPATH_EXTENSION . '/assets/css/' . $extension . '.css'; if (file_exists(JPath::clean($file))) { $document->addStyleSheet($this->baseurl . '/components/' . $option . '/extensions/' . $extension . '/assets/css/' . $extension . '.css?v=' . $version); } //CSS override $file = $JLGPATH_EXTENSION . '/assets/css/' . $this->getName() . '.css'; if (file_exists(JPath::clean($file))) { //add css file $document->addStyleSheet($this->baseurl . '/components/' . $option . '/extensions/' . $extension . '/assets/css/' . $this->getName() . '.css?v=' . $version); } //General extension JS include $file = $JLGPATH_EXTENSION . '/assets/js/' . $extension . '.js'; if (file_exists(JPath::clean($file))) { //add js file $document->addScript($this->baseurl . '/components/' . $option . '/extensions/' . $extension . '/assets/js/' . $extension . '.js?v=' . $version); } //JS override $file = $JLGPATH_EXTENSION . '/assets/js/' . $this->getName() . '.js'; if (file_exists(JPath::clean($file))) { //add js file $document->addScript($this->baseurl . '/components/' . $option . '/extensions/' . $extension . '/assets/js/' . $this->getName() . '.js?v=' . $version); } if ($app->isAdmin()) { $JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . '/extensions/' . $extension . '/admin'; //General extension CSS include $file = $JLGPATH_EXTENSION . '/assets/css/' . $extension . '.css'; if (file_exists(JPath::clean($file))) { $document->addStyleSheet($this->baseurl . '/../components/' . $option . '/extensions/' . $extension . '/admin/assets/css/' . $extension . '.css?v=' . $version); } //CSS override $file = $JLGPATH_EXTENSION . '/assets/css/' . $this->getName() . '.css'; if (file_exists(JPath::clean($file))) { //add css file $document->addStyleSheet($this->baseurl . '/../components/' . $option . '/extensions/' . $extension . '/admin/assets/css/' . $this->getName() . '.css?v=' . $version); } //General extension JS include $file = $JLGPATH_EXTENSION . '/assets/js/' . $extension . '.js'; if (file_exists(JPath::clean($file))) { //add js file $document->addScript($this->baseurl . '/../components/' . $option . '/extensions/' . $extension . '/admin/assets/js/' . $extension . '.js?v=' . $version); } //JS override $file = $JLGPATH_EXTENSION . '/assets/js/' . $this->getName() . '.js'; if (file_exists(JPath::clean($file))) { //add js file $document->addScript($this->baseurl . '/../components/' . $option . '/extensions/' . $extension . '/admin/assets/js/' . $this->getName() . '.js?v=' . $version); } } } parent::display($tpl); }