/** * addItemeditorHelperApp * * @return string */ public static function addItemeditorHelperApp() { static $link = false; if ($link) { return $link; } $doc = JFactory::getDocument(); $app = JFactory::getApplication(); list($isAdmin, $option, $controller, $task, $view, $layout, $id) = AutotweetBaseHelper::getControllerParams(); $js = "var autotweetUrlRoot = '" . JUri::root() . "';\n"; $js .= "var autotweetUrlBase = '" . JUri::base() . "';\n"; $mediaPath = 'media/com_autotweet/js/itemeditor/templates/'; $ext = '.txt'; $joomlaPart = '.j' . (EXTLY_J3 ? '3' : '25'); $sitePart = $isAdmin ? '.admin' : '.site'; $tpl0 = $mediaPath . $option . $ext; $tpl1 = $mediaPath . $option . $joomlaPart . $ext; $tpl2 = $mediaPath . $option . $sitePart . $joomlaPart . $ext; $tpl3 = $mediaPath . $option . $sitePart . $ext; if (file_exists(JPATH_ROOT . '/' . $tpl2)) { $tpl = $tpl2; } elseif (file_exists(JPATH_ROOT . '/' . $tpl1)) { $tpl = $tpl1; } elseif (file_exists(JPATH_ROOT . '/' . $tpl3)) { $tpl = $tpl3; } elseif (file_exists(JPATH_ROOT . '/' . $tpl0)) { $tpl = $tpl0; } else { $tpl = $mediaPath . 'com_joocial-default' . $joomlaPart . $ext; } $tpl = JUri::root() . $tpl . '?version=' . CAUTOTWEETNG_VERSION; $js .= "var autotweetPanelTemplate = 'text!" . $tpl . "';\n"; $doc->addScriptDeclaration($js); $link = 'index.php?option=com_autotweet&view=itemeditor&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; // Add Advanced Attributes $params = null; // Case Request edit page if ($option == CAUTOTWEETNG && $view == 'request' && $task == 'edit') { $params = AdvancedattrsHelper::getAdvancedAttrByReq($id); } elseif ($id > 0) { $params = AdvancedattrsHelper::getAdvancedAttrs($option, $id); } if (!$params) { $params = new StdClass(); $params->description = ''; $params->hashtags = ''; $params->fulltext = ''; $params->postthis = EParameter::getComponentParam(CAUTOTWEETNG, 'joocial_postthis', PlgAutotweetBase::POSTTHIS_DEFAULT); $params->evergreen = PlgAutotweetBase::POSTTHIS_NO; $params->agenda = array(); $params->unix_mhdmd = ''; $params->repeat_until = ''; $params->image = ''; $params->image_url = ''; $params->channels = ''; $params->channels_text = ''; } // Migrating old objects if (!isset($params->description)) { $params->description = ''; } // Migrating old objects if (!isset($params->hashtags)) { $params->hashtags = ''; } // Migrating old objects if (!isset($params->fulltext)) { $params->fulltext = ''; } // Migrating old objects if (!isset($params->image_url)) { $params->image_url = ''; } $params->editorTitle = VersionHelper::getFlavourName() . ' ' . JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_TITLE'); $params->postthisLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_POSTTHIS'); $params->evergreenLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_EVERGREEN'); $params->agendaLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_SCHEDULER'); $params->unix_mhdmdLabel = JText::_('COM_XTCRONJOB_TASKS_FIELD_UNIX_MHDMD'); $params->repeat_untilLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_REPEAT_UNTIL'); $params->imageLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_IMAGES'); $params->channelLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_CHANNELS'); $params->postthisDefaultLabel = '<i class="xticon xticon-circle-o"></i> ' . JText::_('COM_AUTOTWEET_DEFAULT_LABEL'); $params->postthisYesLabel = '<i class="xticon xticon-check"></i> ' . JText::_('JYES'); $params->postthisNoLabel = '<i class="xticon xticon-times"></i> ' . JText::_('JNO'); $params->descriptionLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_MSG'); $params->hashtagsLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_HASHTAGS'); $params->fulltextLabel = JText::_('COM_AUTOTWEET_VIEW_ITEMEDITOR_FULLTEXT_DESC'); if (!isset($params->channels_text)) { $params->channels_text = ''; } AutotweetBaseHelper::convertUTCLocalAgenda($params->agenda); $js = 'var autotweetAdvancedAttrs = ' . json_encode($params) . ";\n"; $doc->addScriptDeclaration($js); $file = EHtml::getRelativeFile('js', 'com_autotweet/itemeditor.helper.min.js'); if ($file) { $paths = array(); $paths = array('text' => Extly::JS_LIB . 'require/text.min'); $deps = array('itemeditor.helper' => array('text', 'underscore')); Extly::getScriptManager(false); Extly::initApp(CAUTOTWEETNG_VERSION, $file, $deps, $paths); } return $link; }
/** * executeContentPolling * * @return boolean */ protected function executeContentPolling() { $automators = F0FModel::getTmpInstance('Automators', 'AutoTweetModel'); if ($automators->lastRunCheck('content', $this->interval)) { $check_from = $this->getContentPollingFrom(); // Set date for posts $post_old_mode = false; if ($this->post_old) { // Special case: posting for old articles is enabled $post_old_mode = true; $last_post = JFactory::getDate($this->post_old_date); // Disable old article posting $this->disablePostOld(); } else { $last_post = $check_from; } // Get new and changed articles form db $table_content = '#__content'; // Get articles only when they are not in the queue and not in the message log for time horizon $db = JFactory::getDBO(); $query = $this->getPollingQuery('autotweetcontent', $table_content, $last_post); $db->setQuery($query); $articles = $db->loadObjectList(); $logger = AutotweetLogger::getInstance(); $logger->log(JLog::INFO, 'PollingQuery: ' . $table_content . ' found ' . count($articles) . ' tasks.'); $ids = array(); // Post articles foreach ($articles as $article) { $ids[] = $article->id; if (AUTOTWEETNG_JOOCIAL) { $this->advanced_attrs = AdvancedattrsHelper::getAdvancedAttrs($this->extension_option, $article->id); } $this->postArticle($article); } $logger->log(JLog::INFO, 'PollingQuery: ' . print_r($ids, true) . ' results.'); } }