function display($tpl = null)
 {
     $option = JRequest::getCmd('option');
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $model = $this->getModel();
     $item =& $this->get('item');
     $form =& $this->get('form');
     $isNew = $item->id < 1;
     $edit = JRequest::getVar('edit', true);
     // fail if checked out not by 'me'
     if ($model->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->name);
         $mainframe->redirect('index.php?option=' . $option . '&view=statistics', $msg, 'error');
     }
     // Edit or Create?
     if (!$isNew) {
         $model->checkout($user->get('id'));
     }
     // icon
     //if there is no icon selected, use default icon
     $default = JoomleagueHelper::getDefaultPlaceholder("icon");
     if (empty($item->icon)) {
         $item->icon = $default;
     }
     if (!empty($item->class)) {
         /*
          * statistic class parameters
          */
         $class =& JLGStatistic::getInstance($item->class);
         $this->assign('calculated', $class->getCalculated());
     }
     $this->assignRef('item', $item);
     $this->assignRef('edit', $edit);
     $this->assignRef('form', $form);
     $this->assignRef('fieldsets', $form->getFieldsets());
     $this->assign('cfg_which_media_tool', JComponentHelper::getParams($option)->get('cfg_which_media_tool', 0));
     $this->addToolbar();
     JHTML::_('behavior.tooltip');
     parent::display($tpl);
 }
예제 #2
0
 function display($tpl = null)
 {
     $this->form = $this->get('form');
     $this->edit = JRequest::getVar('edit', true);
     // icon
     //if there is no icon selected, use default icon
     $default = JoomleagueHelper::getDefaultPlaceholder("icon");
     $icon = $this->form->getValue('icon');
     if (empty($icon)) {
         $this->form->setValue('icon', $default);
     }
     $class = $this->form->getValue('class');
     if (!empty($class)) {
         /*
          * statistic class parameters
          */
         $class = JLGStatistic::getInstance($class);
         $this->calculated = $class->getCalculated();
     }
     $this->addToolbar();
     JHtml::_('behavior.tooltip');
     parent::display($tpl);
 }
예제 #3
0
 function __construct()
 {
     parent::__construct();
 }
예제 #4
0
파일: match.php 프로젝트: hfmprs/JoomLeague
 function getInputStats()
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/statistics/base.php';
     $match = $this->getData();
     $project_id = $match->project_id;
     $query = ' SELECT stat.id,stat.name,stat.short,stat.class,stat.icon,stat.calculated,ppos.position_id AS posid' . ' FROM #__joomleague_statistic AS stat ' . ' INNER JOIN #__joomleague_position_statistic AS ps ON ps.statistic_id=stat.id ' . ' INNER JOIN #__joomleague_project_position AS ppos ON ppos.position_id=ps.position_id ' . ' WHERE ppos.project_id=' . $project_id . ' ORDER BY stat.ordering, ps.ordering ';
     $this->_db->setQuery($query);
     $res = $this->_db->loadObjectList();
     $stats = array();
     foreach ($res as $k => $row) {
         $stat = JLGStatistic::getInstance($row->class);
         $stat->bind($row);
         $stat->set('position_id', $row->posid);
         $stats[] = $stat;
     }
     return $stats;
 }
예제 #5
0
 protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
 {
     // Handle the optional arguments.
     $options['control'] = JArrayHelper::getValue($options, 'control', false);
     // Create a signature hash.
     $hash = md5($source . serialize($options));
     // Check if we can use a previously loaded form.
     if (isset($this->_forms[$hash]) && !$clear) {
         return $this->_forms[$hash];
     }
     // Get the form.
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     try {
         $form = JForm::getInstance($name, $source, $options, false, $xpath);
         // load base configuration xml for stats
         $form->loadFile(JLG_PATH_ADMIN . '/statistics/base.xml');
         // specific xml configuration depends on stat type
         $item = $this->loadFormData();
         if ($item && $item->class) {
             $class = JLGStatistic::getInstance($item->class);
             $xmlpath = $class->getXmlPath();
             $form->loadFile($xmlpath);
         }
         if (isset($options['load_data']) && $options['load_data']) {
             // Get the data for the form.
             $data = $this->loadFormData();
         } else {
             $data = array();
         }
         // Allow for additional modification of the form, and events to be triggered.
         // We pass the data because plugins may require it.
         $this->preprocessForm($form, $data);
         // Load the data into the form after the plugins have operated.
         $form->bind($data);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Store the form for later.
     $this->_forms[$hash] = $form;
     return $form;
 }
예제 #6
0
 /**
  * get all statistics types that are in use for the player in his/her whole career
  * @return array
  */
 function getCareerStats($person_id, $sports_type_id)
 {
     if (empty($this->_careerStats)) {
         $query = 'SELECT s.id,' . ' s.name,' . ' s.short,' . ' s.class,' . ' s.icon,' . ' s.calculated,' . ' ppos.id AS pposid,' . ' ppos.position_id AS position_id,' . ' s.params,' . ' s.baseparams' . ' FROM #__joomleague_person AS p' . ' INNER JOIN #__joomleague_team_player AS tp ON tp.person_id=p.id' . ' INNER JOIN #__joomleague_project_position AS ppos ON tp.project_position_id=ppos.id' . ' INNER JOIN #__joomleague_position AS pos ON ppos.position_id=pos.id' . ' INNER JOIN #__joomleague_position_statistic AS ps ON ps.position_id=pos.id' . ' INNER JOIN #__joomleague_statistic AS s ON ps.statistic_id=s.id' . ' WHERE p.id=' . $this->_db->Quote($person_id);
         if ($sports_type_id > 0) {
             $query .= ' AND pos.sports_type_id=' . $this->_db->Quote($sports_type_id);
         }
         $query .= ' GROUP BY s.id';
         $this->_db->setQuery($query);
         $this->_careerStats = $this->_db->loadObjectList();
     }
     $stats = array();
     if (count($this->_careerStats) > 0) {
         foreach ($this->_careerStats as $k => $row) {
             $stat = JLGStatistic::getInstance($row->class);
             $stat->bind($row);
             $stat->set('position_id', $row->position_id);
             $stats[$row->id] = $stat;
         }
     }
     return $stats;
 }
예제 #7
0
    /**
     * returns stats assigned to positions assigned to project
     * @param int statid 0 for all stats
     * @param int positionid 0 for all positions
     * @return array objects
     */
    function getProjectStats($statid = 0, $positionid = 0)
    {
        if (empty($this->_stats)) {
            require_once JLG_PATH_ADMIN . '/statistics/base.php';
            $project = $this->getProject();
            $project_id = $project->id;
            $query = '	SELECT	stat.id,
								stat.name,
								stat.short,
								stat.class,
								stat.icon,
								stat.calculated,
								ppos.id as pposid,
								ppos.position_id AS position_id,
								stat.params, stat.baseparams
						FROM #__joomleague_statistic AS stat
						INNER JOIN #__joomleague_position_statistic AS ps ON ps.statistic_id=stat.id
						INNER JOIN #__joomleague_project_position AS ppos ON ppos.position_id=ps.position_id
						  AND ppos.project_id=' . $project_id . '
						INNER JOIN #__joomleague_position AS pos ON pos.id=ps.position_id
						WHERE stat.published=1
						  AND pos.published =1
						  ';
            $query .= ' ORDER BY pos.ordering,ps.ordering ';
            $this->_db->setQuery($query);
            $this->_stats = $this->_db->loadObjectList();
        }
        // sort into positions
        $positions = $this->getProjectPositions();
        $stats = array();
        // init
        foreach ($positions as $pos) {
            $stats[$pos->id] = array();
        }
        if (count($this->_stats) > 0) {
            foreach ($this->_stats as $k => $row) {
                if (!$statid || $statid == $row->id || is_array($statid) && in_array($row->id, $statid)) {
                    $stat = JLGStatistic::getInstance($row->class);
                    $stat->bind($row);
                    $stat->set('position_id', $row->position_id);
                    $stats[$row->position_id][$row->id] = $stat;
                }
            }
            if ($positionid) {
                return isset($stats[$positionid]) ? $stats[$positionid] : array();
            } else {
                return $stats;
            }
        } else {
            return $stats;
        }
    }