Beispiel #1
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_neno&view=groupselements');
     $toolbar = JToolbar::getInstance();
     $toolbar->addButtonPath(JPATH_NENO . '/button');
     $toolbar->appendButton('TC', NenoHelperApi::getTCAvailable());
 }
Beispiel #2
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     JToolbarHelper::addNew('addGroup', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_ADD_GROUP'));
     JToolbarHelper::custom('moveelementconfirm.show', 'move', 'move', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_MOVE_ELEMENTS'), true);
     $toolbar = JToolbar::getInstance();
     $toolbar->addButtonPath(JPATH_NENO . '/button');
     $toolbar->appendButton('TC', NenoHelperApi::getTCAvailable());
     $this->extraSidebar = NenoHelperBackend::getSidebarInfobox('groupselements');
 }
Beispiel #3
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     JToolbarHelper::addNew('addGroup', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_ADD_GROUP'));
     JToolbarHelper::custom('moveelementconfirm.show', 'move', 'move', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_MOVE_ELEMENTS'), true);
     JToolbarHelper::custom('groupselements.scanForContent', 'loop', 'loop', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_SCAN_FOR_CONTENT'), true);
     JToolbarHelper::custom('groupselements.moveTranslationsToTarget', 'download', 'download', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_MOVE_TRANSLATED_CONTENT'), true);
     JToolbarHelper::custom('groupselements.checkIntegrity', 'cogs', 'cogs', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_CHECK_INTEGRITY'), true);
     JToolbarHelper::custom('groupselements.refreshWordCount', 'refresh', 'refresh', JText::_('COM_NENO_VIEW_GROUPSELEMENTS_BTN_REFRESH_WORD_COUNT'), true);
     $toolbar = JToolbar::getInstance();
     $toolbar->addButtonPath(JPATH_NENO . '/button');
     $toolbar->appendButton('TC', NenoHelperApi::getTCAvailable());
     $this->extraSidebar = NenoHelperBackend::getSidebarInfobox('groupselements');
 }
Beispiel #4
0
 /**
  * Display the view
  *
  * @param   string $tpl Template
  *
  * @return void
  *
  * @throws Exception This will happen if there are errors during the process to load the data
  *
  * @since 1.0
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->tcNeeded = $this->get('TCNeeded');
     $this->comment = $this->get('Comment');
     $this->needsTc = NenoHelperApi::getTCAvailable() < $this->tcNeeded;
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     NenoHelperBackend::addSubmenu('externaltranslations');
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Beispiel #5
0
 /**
  * Display the view
  *
  * @param   string $tpl Template
  *
  * @return void
  *
  * @throws Exception This will happen if there are errors during the process to load the data
  *
  * @since 1.0
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->isLanguageSwitcherPublished = $this->get('IsSwitcherPublished');
     if (!$this->isLanguageSwitcherPublished) {
         $this->positionField = $this->get('PositionField');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     NenoHelperBackend::addSubmenu('dashboard');
     $toolbar = JToolbar::getInstance();
     $toolbar->addButtonPath(JPATH_NENO . '/button');
     $toolbar->appendButton('TC', NenoHelperApi::getTCAvailable());
     JToolbarHelper::custom('fixMenus', 'refresh', 'refresh', JText::_('COM_NENO_DASHBOARD_FIX_MENU_BUTTON'), false);
     JToolBarHelper::title(JText::_('COM_NENO_DASHBOARD_TITLE'), 'screen');
     $this->sidebar = JHtmlSidebar::render();
     $this->extraSidebar = NenoHelperBackend::getSidebarInfobox('dashboard');
     parent::display($tpl);
 }
Beispiel #6
0
 /**
  * Instanciate http client using Singleton approach
  *
  * @return void
  */
 protected static function getHttp()
 {
     if (self::$httpClient === null) {
         self::$httpClient = JHttpFactory::getHttp();
     }
 }
Beispiel #7
0
 /**
  * Send Job
  *
  * @return bool
  */
 public function sendJob()
 {
     $this->generateJobFile();
     $this->setSentTime(new DateTime())->setState(self::JOB_STATE_SENT);
     $data = array('filename' => $this->getFileName() . '.json.zip', 'words' => $this->getWordCount(), 'translation_method' => NenoHelper::convertTranslationMethodIdToName($this->getTranslationMethod()->id), 'source_language' => $this->getFromLanguage(), 'destination_language' => $this->getToLanguage());
     list($status, $response) = NenoHelperApi::makeApiCall('job', 'POST', $data);
     if ($status === false) {
         $this->setSentTime(null)->setState(self::JOB_STATE_GENERATED);
         if ($response['code'] == 402) {
             $this->setState(self::JOB_STATE_NO_TC);
         }
     }
     $this->persist();
     return $status !== false;
 }
 /**
  * Get the amount of link credits available
  *
  * @return int
  */
 public function getTCAvailable()
 {
     return NenoHelperApi::getTCAvailable();
 }
Beispiel #9
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     $bar = JToolbar::getInstance('toolbar');
     $bar->appendButton('Link', 'home', JText::_('COM_NENO_BACK_TO_DASHBOARD'), 'index.php?option=com_neno');
     $toolbar = JToolbar::getInstance();
     $toolbar->addButtonPath(JPATH_NENO . '/button');
     $toolbar->appendButton('TC', NenoHelperApi::getTCAvailable());
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_neno&view=editor');
 }
Beispiel #10
0
 /**
  * Send Job
  *
  * @return bool
  */
 public function sendJob()
 {
     $this->generateJobFile();
     $this->setSentTime(new DateTime())->setState(self::JOB_STATE_SENT);
     $data = array('filename' => JUri::root() . 'tmp/' . $this->getFileName() . '.json.zip', 'words' => $this->getWordCount(), 'translation_method' => NenoHelper::convertTranslationMethodIdToName($this->getTranslationMethod()->id), 'source_language' => $this->getFromLanguage(), 'destination_language' => $this->getToLanguage());
     list($status, $response) = NenoHelperApi::makeApiCall('job', 'POST', $data);
     if ($status === false) {
         $this->setSentTime(null)->setState(self::JOB_STATE_GENERATED);
         if ($response['code'] !== 200) {
             switch ($response['code']) {
                 // System disabled
                 case 501:
                     $this->setState(self::JOB_STATE_NOT_READY);
                     break;
                     // More TC needed
                 // More TC needed
                 case 402:
                     $this->setState(self::JOB_STATE_NO_TC);
                     break;
             }
         }
     }
     $this->persist();
     return $status !== false;
 }