/**
  * This method looks for a backup of cacert.pem file created
  * by an prior release of this plugin, restoring it if found.
  *
  * @return void
  */
 public function onAfterInitialise()
 {
     $app = Factory::getApplication();
     if ($app->getName() === 'administrator') {
         OSSystemHelper::revertCARootFileToOriginal();
     }
 }
示例#2
0
文件: view.html.php 项目: lepca/OSMap
 /**
  * Display the view
  *
  * @access    public
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $version = new JVersion();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     JHTML::stylesheet('administrator/components/com_osmap/css/osmap.css');
     // Convert dates from UTC
     $offset = $app->getCfg('offset');
     if (intval($this->item->created)) {
         $this->item->created = JHtml::date($this->item->created, '%Y-%m-%d %H-%M-%S', $offset);
     }
     $this->_setToolbar();
     if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
         $tpl = 'legacy';
     }
     // Load the extension
     $extension = Factory::getExtension('OSMap', 'component');
     $extension->loadLibrary();
     $this->assignRef("extension", $extension);
     parent::display($tpl);
     JRequest::setVar('hidemainmenu', true);
 }
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         OSMapHelper::addSubmenu('sitemaps');
     }
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $version = new JVersion();
     $message = $this->get('ExtensionsMessage');
     if ($message) {
         JFactory::getApplication()->enqueueMessage($message);
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
             $tpl = 'legacy';
         }
         $this->addToolbar();
     }
     // Load the extension
     $extension = Factory::getExtension('OSMap', 'component');
     $extension->loadLibrary();
     $displayLegacyStats = (bool) $extension->params->get('display_legacy_stats', 0);
     $this->assignRef("extension", $extension);
     $this->assignRef("displayLegacyStats", $displayLegacyStats);
     parent::display($tpl);
 }
示例#4
0
 public function incrementDownloadCount($itemId)
 {
     $db = Factory::getDbo();
     $query = $db->getQuery(true)->update('#__osdownloads_documents')->set('downloaded = downloaded + 1')->where('id = ' . $db->quote($itemId));
     $db->setQuery($query);
     $db->execute();
 }
示例#5
0
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->model = $this->getModel();
     JTable::addIncludePath(JPATH_COMPONENT . '/tables');
     $mainframe = JFactory::getApplication();
     $cid = JRequest::getVar("cid");
     if (is_array($cid)) {
         $cid = $cid[0];
     }
     $item = JTable::getInstance("document", "OSDownloadsTable");
     $item->load($cid);
     if ($item->description_1) {
         $item->description_1 = $item->brief . "<hr id=\"system-readmore\" />" . $item->description_1;
     } else {
         $item->description_1 = $item->brief;
     }
     $this->form->bind($item);
     // Load the extension
     $extension = Factory::getExtension('OSDownloads', 'component');
     $extension->loadLibrary();
     // Add the agreementLink property
     if (!empty($item)) {
         $item->agreementLink = '';
         if ((bool) $item->require_agree) {
             $item->agreementLink = JRoute::_('index.php?option=com_content&view=article&id=' . (int) $item->agreement_article_id);
         }
     }
     $this->assignRef("item", $item);
     $this->assignRef("extension", $extension);
     $this->addToolbar();
     parent::display($tpl);
 }
示例#6
0
 public static function getExtensionForElement($element)
 {
     $info = static::getExtensionInfoFromElement($element);
     if (!empty($info['type']) && !empty($info['namespace'])) {
         return Factory::getExtension($info['namespace'], $info['type'], $info['group']);
     }
     return null;
 }
示例#7
0
 public function display($tpl = null)
 {
     // Add default admin CSS
     $cssPath = JPATH_SITE . "/media/{$this->option}/css/admin-default.css";
     if (file_exists($cssPath)) {
         $doc = Factory::getDocument();
         $doc->addStyleSheet($cssPath);
     }
     parent::display($tpl);
     $this->displayFooter();
 }
示例#8
0
 public function __construct($default = array())
 {
     parent::__construct($default);
     $this->registerTask('apply', 'save');
     $this->registerTask('unpublish', 'publish');
     $this->registerTask('orderup', 'reorder');
     $this->registerTask('orderdown', 'reorder');
     // Load the extension
     $this->extension = Factory::getExtension('OSDownloads', 'component');
     $this->extension->loadLibrary();
 }
示例#9
0
 protected function buildBreadcrumbs(&$paths, $item)
 {
     $this->buildPath($paths, $item->cate_id);
     $app = Factory::getApplication();
     $pathway = $app->getPathway();
     $itemID = JRequest::getVar("Itemid", null, 'default', 'int');
     $countPaths = count($paths) - 1;
     for ($i = $countPaths; $i >= 0; $i--) {
         $pathway->addItem($paths[$i]->title, JRoute::_("index.php?option=com_osdownloads&view=downloads&id={$paths[$i]->id}" . "&Itemid={$itemID}"));
     }
 }
示例#10
0
 public function addToMailchimpList()
 {
     $app = Factory::getApplication();
     $params = $app->getParams('com_osdownloads');
     $apiKey = $params->get("mailchimp_api", 0);
     $listId = $params->get("list_id", 0);
     if (!empty($this->email)) {
         $mc = new MailChimpAPI($apiKey);
         $merge_vars = array();
         $mc->listSubscribe($listId, $this->email, $merge_vars);
     }
 }
示例#11
0
 /**
  * Plugin that loads module positions within content
  *
  * @param   string   $context   The context of the content being passed to the plugin.
  * @param   object   &$article  The article object.  Note $article->text is also available
  * @param   mixed    &$params   The article params
  * @param   integer  $page      The 'page' number
  *
  * @return  mixed   true if there is an error. Void otherwise.
  *
  * @since   1.6
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     // Don't run this plugin when the content is being indexed
     if ($context == 'com_finder.indexer' || !$this->allowedToRun) {
         return true;
     }
     $versionUID = md5($this->extension->getVersion());
     JHtml::_('jquery.framework');
     $doc = Framework\Factory::getDocument();
     $doc->addStyleSheetVersion('media/plg_content_osembed/css/osembed.css', $versionUID);
     $doc->addScriptVersion('media/plg_content_osembed/js/osembed.js', $versionUID);
     $embedClass = $this->getEmbedClass();
     $article->text = $embedClass::parseContent($article->text, false);
 }
示例#12
0
 /**
  * Method to get the row form.
  *
  * @param   array    $data      Data for the form.
  * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  *
  * @return  mixed    A JForm object on success, false on failure
  *
  * @since   1.6
  */
 public function getForm($data = array(), $loadData = true)
 {
     // Get the form.
     $form = $this->loadForm('com_osdownloads.file', 'file', array('control' => 'jform', 'load_data' => $loadData));
     // Load the extension
     $extension = Factory::getExtension('OSDownloads', 'component');
     $extension->loadLibrary();
     if ($extension->isPro()) {
         $form->loadFile(JPATH_COMPONENT . '/models/forms/file_pro.xml', true);
     }
     if (empty($form)) {
         return false;
     }
     return $form;
 }
示例#13
0
 public function insert($email, $documentId)
 {
     $component = FreeComponentSite::getInstance();
     $row = $component->getTable('Email');
     $email = filter_var($email, FILTER_VALIDATE_EMAIL);
     if ($email !== false) {
         $row->email = $email;
         $row->document_id = (int) $documentId;
         $row->downloaded_date = Factory::getDate()->toSQL();
         $this->prepareRow($row);
         $row->store();
         return $row;
     }
     return false;
 }
示例#14
0
 public function getList()
 {
     $db = Factory::getDBO();
     $osdownloads = FreeComponentSite::getInstance();
     $model = $osdownloads->getModel('Item');
     $query = $model->getItemQuery();
     $query->where("cate_id = " . $db->quote($this->params->get('category', 0)));
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (!empty($rows)) {
         foreach ($rows as &$row) {
             $row->agreementLink = JRoute::_('index.php?option=com_content&view=article&id=' . (int) $row->agreement_article_id);
         }
     }
     return $rows;
 }
示例#15
0
 /**
  * Task to route the download workflow
  *
  * @return void
  */
 public function routedownload()
 {
     $app = Factory::getApplication();
     $component = FreeComponentSite::getInstance();
     $params = $app->getParams('com_osdownloads');
     $downloadEmailContent = $params->get("download_email_content", false);
     $id = (int) JRequest::getVar("id");
     $model = $component->getModel('Item');
     $item = $model->getItem($id);
     if (empty($item)) {
         JError::raiseWarning(404, JText::_("COM_OSDOWNLOADS_THIS_DOWNLOAD_ISNT_AVAILABLE"));
         return;
     }
     if ($this->processRequirements($item)) {
         $this->processEmailRequirement($item);
     }
     JRequest::setVar("view", "item");
     $this->display();
 }
示例#16
0
 public static function addCustomFooterIntoNativeComponentOutput($element)
 {
     // Check if the specified extension is from Alledia
     $extension = ExtensionHelper::getExtensionForElement($element);
     $footer = $extension->getFooterMarkup();
     if (!empty($footer)) {
         // Inject the custom footer
         if (version_compare(JVERSION, '3.0', 'lt')) {
             $body = JResponse::getBody();
             $body = preg_replace('#(<p\\salign="center">Joomla!\\s[0-9.\\s&;]*</p>)#i', $footer . '$1', $body);
             JResponse::setBody($body);
         } else {
             $app = Factory::getApplication();
             $body = $app->getBody();
             $body = str_replace('</section>', '</section>' . $footer, $body);
             $app->setBody($body);
         }
     }
 }
 public function getTable($type)
 {
     $db = Factory::getDbo();
     if ($this->isPro()) {
         $class = "Alledia\\{$this->namespace}\\Pro\\Joomla\\Table\\{$type}";
         if (class_exists($class)) {
             return new $class($db);
         }
     } else {
         $class = "Alledia\\{{$this->namespace}}\\Free\\Joomla\\Table\\{{$type}}";
         if (class_exists($class)) {
             return new $class($db);
         }
     }
     return BaseTable::getInstance($type, $this->namespace . 'Table');
 }
示例#18
0
 public function init()
 {
     $doc = Factory::getDocument();
     $doc->addStyleSheet(OSDOWNLOADS_MEDIA_URI . "/css/frontend.css");
     parent::init();
 }
示例#19
0
 /**
  * Method to load the extension data
  * @return void
  */
 protected function loadExtension()
 {
     if (!isset($this->extension)) {
         $this->extension = Factory::getExtension($this->namespace, 'plugin', $this->_type);
     }
 }