Пример #1
1
function optimizeJS($scripts)
{
    if (!isNitroEnabled() || !getNitroPersistence('Mini.Enabled')) {
        return $scripts;
    }
    global $registry;
    $oc_root = dirname(DIR_APPLICATION);
    $cache = NULL;
    $cachefile = NULL;
    $filename = NULL;
    //load NitroCache
    require_once DIR_SYSTEM . 'nitro/core/cdn.php';
    $nitroSettings = getNitroPersistence();
    $excludes = explodeTrim("\n", getNitroPersistence('Mini.JSExclude'));
    if (getNitroPersistence('Mini.JS')) {
        $scripts = minify('js', $scripts, $excludes);
    }
    if (getNitroPersistence('Mini.JSCombine')) {
        $scripts = combine('js', $scripts, $excludes);
    }
    return nitroCDNResolve($scripts);
}
Пример #2
0
function getIgnoredRoutes()
{
    $ignoredRoutes = explodeTrim("\n", getNitroPersistence('PageCache.IgnoredRoutes'));
    $predefinedIgnoredRoutes = array('checkout/cart', 'checkout/checkout', 'checkout/success', 'account/register', 'account/login', 'account/edit', 'account/account', 'account/password', 'account/address', 'account/address/update', 'account/address/delete', 'account/wishlist', 'account/order', 'account/download', 'account/return', 'account/return/insert', 'account/reward', 'account/voucher', 'account/transaction', 'account/newsletter', 'account/logout', 'affiliate/login', 'affiliate/register', 'affiliate/account', 'affiliate/edit', 'affiliate/password', 'affiliate/payment', 'affiliate/tracking', 'affiliate/transaction', 'affiliate/logout', 'information/contact', 'product/compare', 'error/not_found');
    $ignoredRoutes = array_merge($predefinedIgnoredRoutes, $ignoredRoutes);
    return $ignoredRoutes;
}
Пример #3
0
function getIgnoredUrls()
{
    $ignoredUrls = explodeTrim("\n", getNitroPersistence('DisabledURLs'));
    $predefinedIgnoredUrls = array('/admin/', 'isearch');
    //See if we are in admin
    $dir = basename(DIR_APPLICATION);
    if (!in_array($dir, array('admin', 'catalog'))) {
        $predefinedIgnoredUrls[] = '/' . $dir . '/';
    }
    $ignoredUrls = array_merge($predefinedIgnoredUrls, $ignoredUrls);
    return $ignoredUrls;
}
 /**
  * Advanced settings.
  *
  * Allows setting configuration values via form elements.
  *
  * @since 2.0.0
  * @access public
  */
 public function advanced()
 {
     // Check permission
     $this->permission('Garden.Settings.Manage');
     // Load up config options we'll be setting
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Vanilla.Categories.MaxDisplayDepth', 'Vanilla.Discussions.PerPage', 'Vanilla.Comments.PerPage', 'Garden.Html.AllowedElements', 'Garden.EditContentTimeout', 'Vanilla.AdminCheckboxes.Use', 'Vanilla.Comment.MaxLength', 'Vanilla.Comment.MinLength', 'Garden.TrustedDomains'));
     // Set the model on the form.
     $this->Form->setModel($ConfigurationModel);
     // If seeing the form for the first time...
     if ($this->Form->authenticatedPostBack() === false) {
         // Format trusted domains as a string
         $TrustedDomains = val('Garden.TrustedDomains', $ConfigurationModel->Data);
         if (is_array($TrustedDomains)) {
             $TrustedDomains = implode("\n", $TrustedDomains);
         }
         $ConfigurationModel->Data['Garden.TrustedDomains'] = $TrustedDomains;
         // Apply the config settings to the form.
         $this->Form->setData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->applyRule('Vanilla.Categories.MaxDisplayDepth', 'Required');
         $ConfigurationModel->Validation->applyRule('Vanilla.Categories.MaxDisplayDepth', 'Integer');
         $ConfigurationModel->Validation->applyRule('Vanilla.Discussions.PerPage', 'Required');
         $ConfigurationModel->Validation->applyRule('Vanilla.Discussions.PerPage', 'Integer');
         $ConfigurationModel->Validation->applyRule('Vanilla.Comments.PerPage', 'Required');
         $ConfigurationModel->Validation->applyRule('Vanilla.Comments.PerPage', 'Integer');
         $ConfigurationModel->Validation->applyRule('Garden.EditContentTimeout', 'Integer');
         $ConfigurationModel->Validation->applyRule('Vanilla.Comment.MaxLength', 'Required');
         $ConfigurationModel->Validation->applyRule('Vanilla.Comment.MaxLength', 'Integer');
         // Format the trusted domains as an array based on newlines & spaces
         $TrustedDomains = $this->Form->getValue('Garden.TrustedDomains');
         $TrustedDomains = explodeTrim("\n", $TrustedDomains);
         $TrustedDomains = array_unique(array_filter($TrustedDomains));
         $TrustedDomains = implode("\n", $TrustedDomains);
         $this->Form->setFormValue('Garden.TrustedDomains', $TrustedDomains);
         // Save new settings
         $Saved = $this->Form->save();
         if ($Saved !== false) {
             $this->informMessage(t("Your changes have been saved."));
         }
         // Reformat array as string so it displays properly in the form
         $this->Form->setFormValue('Garden.TrustedDomains', $TrustedDomains);
     }
     $this->setHighlightRoute('vanilla/settings/advanced');
     $this->addJsFile('settings.js');
     $this->title(t('Advanced Forum Settings'));
     // Render default view (settings/advanced.php)
     $this->render();
 }
Пример #5
0
 /**
  * Add javascript to the post/edit discussion page so that tagging autocomplete works.
  *
  * @param PostController $Sender
  */
 public function postController_render_before($Sender)
 {
     $Sender->addJsFile('jquery.tokeninput.js');
     $Sender->addJsFile('tagging.js', 'plugins/Tagging');
     $Sender->addDefinition('PluginsTaggingAdd', Gdn::session()->checkPermission('Plugins.Tagging.Add'));
     $Sender->addDefinition('PluginsTaggingSearchUrl', Gdn::request()->Url('plugin/tagsearch'));
     // Make sure that detailed tag data is available to the form.
     $TagModel = TagModel::instance();
     $DiscussionID = val('DiscussionID', $Sender->Data['Discussion']);
     if ($DiscussionID) {
         $Tags = $TagModel->getDiscussionTags($DiscussionID, TagModel::IX_EXTENDED);
         $Sender->setData($Tags);
     } elseif (!$Sender->Request->isPostBack() && ($tagString = $Sender->Request->get('tags'))) {
         $tags = explodeTrim(',', $tagString);
         $types = array_column(TagModel::instance()->defaultTypes(), 'key');
         // Look up the tags by name.
         $tagData = Gdn::sql()->getWhere('Tag', array('Name' => $tags, 'Type' => $types))->resultArray();
         // Add any missing tags.
         $tagNames = array_change_key_case(array_column($tagData, 'Name', 'Name'));
         foreach ($tags as $tag) {
             $tagKey = strtolower($tag);
             if (!isset($tagNames[$tagKey])) {
                 $tagData[] = array('TagID' => $tag, 'Name' => $tagKey, 'FullName' => $tag, 'Type' => '');
             }
         }
         $Sender->setData('Tags', $tagData);
     }
 }
Пример #6
0
 private function get_clean_root()
 {
     $root = implode('/', explodeTrim('/', getNitroPersistence('CDNStandardFTP.Root')));
     return !empty($root) ? '/' . $root . '/' : '/';
 }