public function SettingsController_PageSpeed_Create($Sender) { $Sender->Permission('Garden.Plugins.Manage'); if ('cleancache' == GetValue(0, $Sender->RequestArgs)) { self::CleanCache(); Redirect('settings/pagespeed'); } elseif ('disable' == GetValue(0, $Sender->RequestArgs)) { SaveToConfig('EnabledPlugins.PageSpeed', False); Redirect('/dashboard/settings/plugins'); } $Sender->AddSideMenu(); $Sender->Title('Page Speed'); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $Sender->Form->SetModel($ConfigurationModel); $ConfigurationModel->SetField(array('Plugins.PageSpeed.AllInOne', 'Plugins.PageSpeed.DeferJavaScript', 'Plugins.PageSpeed.ParallelizeEnabled', 'Plugins.PageSpeed.ParallelizeHosts', 'Plugins.PageSpeed.CDN.jquery', 'Plugins.PageSpeed.CDN.jqueryui', 'Plugins.PageSpeed.CDN.jqueryui-theme')); if ($Sender->Form->AuthenticatedPostBack()) { //$Validation->ApplyRule('Plugin.Example.RenderCondition', 'Required'); $FormValues = $Sender->Form->FormValues(); $Integer = array('Plugins.PageSpeed.AllInOne', 'Plugins.PageSpeed.DeferJavaScript'); foreach ($Integer as $Name) { settype($FormValues[$Name], 'int'); } settype($FormValues['Plugins.PageSpeed.ParallelizeEnabled'], 'bool'); $ParallelizeHosts = SplitUpString($FormValues['Plugins.PageSpeed.ParallelizeHosts'], ',', 'trim strtolower'); if (count($ParallelizeHosts) == 0) { SetValue('Plugins.PageSpeed.ParallelizeHosts', $FormValues, Null); SetValue('Plugins.PageSpeed.ParallelizeEnabled', $FormValues, False); } else { SetValue('Plugins.PageSpeed.ParallelizeHosts', $FormValues, implode(', ', $ParallelizeHosts)); } $Sender->Form->FormValues($FormValues); $Sender->Form->Save(); $Sender->InformMessage(T('Saved'), array('Sprite' => 'Check', 'CssClass' => 'Dismissable AutoDismiss')); } else { $Sender->Form->SetData($ConfigurationModel->Data); } $Sender->SetData('GroupingItems', array('Three groups (library, applications, plugins)', 'All css and javascript files combined into one file', 'Minify javascript only')); $Sender->SetData('DeferJavaScriptItems', array(0 => 'Disabled', 1 => htmlspecialchars('Just put <script> tags at bottom'), 2 => 'Dynamic loading (Dangerous! Something may not work)')); $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'settings.php'; $Sender->Render(); }
public function Get($Conditions = False, $Offset = False, $Limit = False, $OrderBy = False, $OrderDirection = 'desc') { $bCountQuery = GetValue('bCountQuery', $Conditions, False, True); $SelectFields = GetValue('SelectFields', $Conditions, False, True); $SQL = $this->SQL; $Alias = $this->GetAlias(); if ($bCountQuery) { $this->SQL->Select('*', 'count', 'RowCount'); $Offset = False; $Limit = False; $OrderBy = False; } if ($SelectFields && !$bCountQuery) { $this->SQL->Select($SelectFields); } if (is_array($Conditions)) { $SQL->Where($Conditions); } if ($OrderBy !== False) { $OrderBys = SplitUpString($OrderBy, ',', 'trim'); foreach ($OrderBys as $OrderBy) { if (!strpos($OrderBy, ' ')) { $OrderBy .= ' ' . $OrderDirection; } list($Field, $Direction) = explode(' ', $OrderBy); $this->SQL->OrderBy($Field, $Direction); } } $this->EventArguments['bCountQuery'] = $bCountQuery; $this->EventArguments['Conditions'] =& $Conditions; $this->FireEvent('BeforeGet'); $Result = $this->SQL->From($this->Name . ' ' . $Alias)->Limit($Limit, $Offset)->Get(); if ($bCountQuery) { $Result = $Result->FirstRow()->RowCount; } return $Result; }
/** * Get max AUTO_INCREMENT from $Tables. * $Tables is null means all tables. * * @param mixed $Tables * @return mixed $Result. */ function MaxAutoIncrement($Tables = Null, $Options = False) { if (is_string($Tables)) { $Tables = SplitUpString($Tables, ',', 'trim'); } $SQL = Gdn::SQL(); if (!is_null($Tables)) { $Px = $SQL->Database->DatabasePrefix; $Tables = array_map(create_function('$S', "return '{$Px}'.\$S;"), $Tables); $SQL->WhereIn('TABLE_NAME', $Tables); } DatabasePrefix(); $Select = $SQL->Select('AUTO_INCREMENT', 'max', 'MaxAutoIncrement')->From('information_schema.TABLES i')->Where('TABLE_SCHEMA', C('Database.Name'))->GetSelect(); DatabasePrefix(); $Select = $SQL->ApplyParameters($Select); $SQL->Reset(); if (GetValue('GetQuery', $Options)) { return $Select; } $Result = $SQL->Query($Select)->Value('MaxAutoIncrement'); return $Result; }
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender) { $Request = Gdn::Request(); $RequestUri = $Request->RequestUri(); if (Gdn::Router()->GetRoute($RequestUri) === False) { $RequestArgs = SplitUpString($RequestUri, '/', 'strtolower'); if (array_key_exists(0, $RequestArgs)) { $ApplicationFolders = $Sender->EnabledApplicationFolders(); $bFoundApplication = in_array($RequestArgs[0], $ApplicationFolders); if ($bFoundApplication === False) { $PathParts = array('controllers', 'class.' . $RequestArgs[0] . 'controller.php'); $ControllerFileName = CombinePaths($PathParts); $ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ApplicationFolders, $ControllerFileName); if (!$ControllerPath || !file_exists($ControllerPath)) { $Sender->EventArguments['RequestUri'] =& $RequestUri; $Sender->FireEvent('BeforeGetRoute'); $NewRequest = CandyModel::GetRouteRequestUri($RequestUri); if ($NewRequest) { $Request->WithURI($NewRequest); } } } } } }