/** * onBeforeDispatch. * * @return bool */ public function onBeforeDispatch() { $result = parent::onBeforeDispatch(); if ($result && !F0FPlatform::getInstance()->isCli()) { $view = $this->input->getCmd('view'); Extly::loadStyle(true, $view != 'composer'); $document = JFactory::getDocument(); $document->addStyleSheet(JUri::root() . 'media/com_autotweet/css/style.css?version=' . CAUTOTWEETNG_VERSION); Extly::getScriptManager(true, false, true); } return $result; }
/** * onAdd. * * @param string $tpl Param * * @return void */ public function onAdd($tpl = null) { $result = parent::onAdd($tpl); Extly::loadAwesome(); JHtml::stylesheet('lib_extly/ng-table.min.css', false, true); $file = EHtml::getRelativeFile('js', 'com_autotweet/composer/app.min.js'); if ($file) { $this->assign('extensionmainjs', $file); $dependencies = array(); $paths = array(); // Libraries $paths['angular'] = 'media/lib_extly/js/angular/angular.min'; $paths['angular-resource'] = 'media/lib_extly/js/angular/angular-resource.min'; $dependencies['angular-resource'] = array('angular'); $paths['ng-table'] = 'media/lib_extly/js/angular/ng-table-noamd.min'; $dependencies['ng-table'] = array('angular'); // App $paths['requests-service'] = 'media/com_autotweet/js/composer/requests-service.min'; $dependencies['requests-service'] = array('angular-resource', 'extlycore'); $paths['agendas-service'] = 'media/com_autotweet/js/composer/agendas-service.min'; $dependencies['agendas-service'] = array('angular'); $paths['directives'] = 'media/com_autotweet/js/composer/directives.min'; $dependencies['directives'] = array('angular'); $paths['editor-controller'] = 'media/com_autotweet/js/composer/editor-controller.min'; $dependencies['editor-controller'] = array('angular'); $paths['requests-controller'] = 'media/com_autotweet/js/composer/requests-controller.min'; $dependencies['requests-controller'] = array('ng-table', 'requests-service'); $paths['agendas-controller'] = 'media/com_autotweet/js/composer/agendas-controller.min'; $dependencies['agendas-controller'] = array('agendas-service'); $scriptManager = Extly::getScriptManager(); $scriptManager->setFramework(DependencyManager::JS_ANGULAR); $scriptManager->initApp(CAUTOTWEETNG_VERSION, $file, $dependencies, $paths); $list_limit = JFactory::getConfig()->get('list_limit'); $scriptManager->addPostRequireScript("angular.bootstrap(document, ['composerApp']);\n\t\t\t\t\twindow.xtListLimit = {$list_limit};\n\t\t\t\t\tjQuery('.post-attrs-group a').click(function(e) {\n\t\t\t\t\t\tvar btn = jQuery(e.target), v;\n\n\t\t\t\t\t\tif (btn.hasClass('xticon')) {\n\t\t\t\t\t\t \tbtn = btn.parent('a');\n\t\t\t\t\t\t }\n\n\t\t\t\t\t\t v = btn.attr('data-value');\n\n\t\t\t\t\t\tjQuery('.xt-subform').hide();\n\t\t\t\t\t\tjQuery('.xt-subform-' + v).show();\n\t\t\t\t\t});"); } $document = JFactory::getDocument(); $document->addScript('//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/md5.js'); $platform = F0FPlatform::getInstance(); $this->assign('editown', $platform->authorise('core.edit.own', $this->input->getCmd('option', 'com_foobar'))); $this->assign('editstate', $platform->authorise('core.edit.state', $this->input->getCmd('option', 'com_foobar'))); return $result; }
/** * 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; }