/** * * * @param $Name * @return mixed * @throws Exception */ public function __get($Name) { switch ($Name) { case 'CommentData': Deprecated('DiscussionController->CommentData', "DiscussionController->data('Comments')"); return $this->data('Comments'); break; } throw new Exception("DiscussionController->{$Name} not found.", 400); }
public function __get($Name) { switch ($Name) { case 'CommentData': Deprecated('ActivityController->CommentData', "ActivityController->Data('Activities')"); $Result = new Gdn_DataSet(array(), DATASET_TYPE_OBJECT); return $Result; case 'ActivityData': Deprecated('ActivityController->ActivityData', "ActivityController->Data('Activities')"); $Result = new Gdn_DataSet($this->Data('Activities'), DATASET_TYPE_ARRAY); $Result->DatasetType(DATASET_TYPE_OBJECT); return $Result; } }
/** * Returns a single Condition Expression for use in a 'where' or an 'on' clause. * * @param string $Field The name of the field on the left hand side of the expression. * If $Field ends with an operator, then it used for the comparison. Otherwise '=' will be used. * @param mixed $Value The value on the right side of the expression. This has different behaviour depending on the type. * <b>string</b>: The value will be used. If $EscapeValueSql is true then it will end up in a parameter. * <b>array</b>: DatabaseFunction => Value will be used. if DatabaseFunction contains a "%s" then sprintf will be used. * In this case Value will be assumed to be a string. * * <b>New Syntax</b> * The $Field and Value expressions can begin with special characters to do certain things. * <ul> * <li><b>=</b>: This means that the argument is a function call. * If you want to pass field reference arguments into the function then enclose them in square brackets. * ex. <code>'=LEFT([u.Name], 4)'</code> will call the LEFT database function on the u.Name column.</li> * <li><b>@</b>: This means that the argument is a literal. * This is useful for passing in literal numbers.</li> * <li><b>no prefix></b>: This will treat the argument differently depending on the argument. * - <b>$Field</b> - The argument is a column reference. * - <b>$Value</b> - The argument will become a named parameter. * </li></ul> * @return string The single expression. */ public function ConditionExpr($Field, $Value, $EscapeFieldSql = TRUE, $EscapeValueSql = TRUE) { // Change some variables from the old parameter style to the new one. // THIS PART OF THE FUNCTION SHOULD EVENTUALLY BE REMOVED. if ($EscapeFieldSql === FALSE) { $Field = '@' . $Field; } if (is_array($Value)) { //$ValueStr = var_export($Value, TRUE); $ValueStr = 'ARRAY'; Deprecated("Gdn_SQL->ConditionExpr(VALUE, {$ValueStr})", 'Gdn_SQL->ConditionExpr(VALUE, VALUE)'); if ($EscapeValueSql) { throw new Gdn_UserException('Invalid function call.'); } $FunctionCall = array_keys($Value); $FunctionCall = $FunctionCall[0]; $FunctionArg = $Value[$FunctionCall]; if ($EscapeValueSql) { $FunctionArg = '[' . $FunctionArg . ']'; } if (stripos($FunctionCall, '%s') === FALSE) { $Value = '=' . $FunctionCall . '(' . $FunctionArg . ')'; } else { $Value = '=' . sprintf($FunctionCall, $FunctionArg); } $EscapeValueSql = FALSE; } else { if (!$EscapeValueSql && !is_null($Value)) { $Value = '@' . $Value; } } // Check for a straight literal field expression. if (!$EscapeFieldSql && !$EscapeValueSql && is_null($Value)) { return substr($Field, 1); } // warning: might not be portable across different drivers $Expr = ''; // final expression which is built up $Op = ''; // logical operator // Try and split an operator out of $Field. $FieldOpRegex = "/(?:\\s*(=|<>|>|<|>=|<=)\\s*\$)|\\s+(like|not\\s+like)\\s*\$|\\s+(?:(is)\\s+(null)|(is\\s+not)\\s+(null))\\s*\$/i"; $Split = preg_split($FieldOpRegex, $Field, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); if (count($Split) > 1) { $Field = $Split[0]; $Op = $Split[1]; if (count($Split) > 2) { $Value = null; } } else { $Op = '='; } if ($Op == '=' && is_null($Value)) { // This is a special case where the value SQL is checking for an is null operation. $Op = 'is'; $Value = '@null'; $EscapeValueSql = FALSE; } // Add the left hand side of the expression. $Expr .= $this->_ParseExpr($Field, NULL, $EscapeFieldSql); // Add the expression operator. $Expr .= ' ' . $Op . ' '; if ($Op == 'is' || $Op == 'is not' && is_null($Value)) { $Expr .= 'null'; } else { // Add the right side of the expression. $Expr .= $this->_ParseExpr($Value, $Field, $EscapeValueSql); } return $Expr; }
/** * * * @since 2.0.18 * @acces public * @param string $Code Where condition. * @return object DataSet */ public function GetDescendantsByCode($Code) { Deprecated('CategoryModel::GetDescendantsByCode', 'CategoryModel::GetAncestors'); // SELECT title FROM tree WHERE lft < 4 AND rgt > 5 ORDER BY lft ASC; return $this->SQL->Select('c.ParentCategoryID, c.CategoryID, c.TreeLeft, c.TreeRight, c.Depth, c.Name, c.Description, c.CountDiscussions, c.CountComments, c.AllowDiscussions, c.UrlCode')->From('Category c')->Join('Category d', 'c.TreeLeft < d.TreeLeft and c.TreeRight > d.TreeRight')->Where('d.UrlCode', $Code)->OrderBy('c.TreeLeft', 'asc')->Get(); }
/** * Does actual de-authentication of a user. Used by SignOut(). * * @access public * @since 2.0.0 * * @param string $AuthenticationSchemeAlias * @param string $TransientKey Unique value to prove intent. */ public function Leave($AuthenticationSchemeAlias = 'default', $TransientKey = '') { Deprecated(__FUNCTION__); $this->EventArguments['AuthenticationSchemeAlias'] = $AuthenticationSchemeAlias; $this->FireEvent('BeforeLeave'); // Allow hijacking deauth type $AuthenticationSchemeAlias = $this->EventArguments['AuthenticationSchemeAlias']; try { $Authenticator = Gdn::Authenticator()->AuthenticateWith($AuthenticationSchemeAlias); } catch (Exception $e) { $Authenticator = Gdn::Authenticator()->AuthenticateWith('default'); } // Only sign the user out if this is an authenticated postback! Start off pessimistic $this->Leaving = FALSE; $Result = Gdn_Authenticator::REACT_RENDER; // Build these before doing anything desctructive as they are supposed to have user context $LogoutResponse = $Authenticator->LogoutResponse(); $LoginResponse = $Authenticator->LoginResponse(); $AuthenticatedPostbackRequired = $Authenticator->RequireLogoutTransientKey(); if (!$AuthenticatedPostbackRequired || Gdn::Session()->ValidateTransientKey($TransientKey)) { $Result = $Authenticator->DeAuthenticate(); $this->Leaving = TRUE; } if ($Result == Gdn_Authenticator::AUTH_SUCCESS) { $this->View = 'leave'; $Reaction = $LogoutResponse; } else { $this->View = 'auth/' . $Authenticator->GetAuthenticationSchemeAlias(); $Reaction = $LoginResponse; } switch ($Reaction) { case Gdn_Authenticator::REACT_RENDER: break; case Gdn_Authenticator::REACT_EXIT: exit; break; case Gdn_Authenticator::REACT_REMOTE: // Render the view, but set the delivery type to VIEW $this->_DeliveryType = DELIVERY_TYPE_VIEW; break; case Gdn_Authenticator::REACT_REDIRECT: default: // If we're just told to redirect, but not where... try to figure out somewhere that makes sense. if ($Reaction == Gdn_Authenticator::REACT_REDIRECT) { $Route = '/'; $Target = $this->Target(); if (!is_null($Target)) { $Route = $Target; } } else { $Route = $Reaction; } if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->RedirectUrl = Url($Route); } else { if ($Route !== FALSE) { Redirect($Route); } else { Redirect(Gdn::Router()->GetDestination('DefaultController')); } } break; } $this->Render(); }
/** * Default Gdn_Model::get() behavior. * * Prior to 2.0.18 it incorrectly behaved like GetID. * This method can be deleted entirely once it's been deprecated long enough. * * @since 2.0.0 * @return object DataSet */ public function get($OrderFields = '', $OrderDirection = 'asc', $Limit = false, $Offset = false) { if (is_numeric($OrderFields)) { // They're using the old version that was a misnamed GetID() Deprecated('UserModel->get()', 'UserModel->getID()'); $Result = $this->getID($OrderFields); } else { $Result = parent::get($OrderFields, $OrderDirection, $Limit, $Offset); } return $Result; }
function ThumbnailImage($Data, $Attributes = False) { if (function_exists('Debug') && Debug()) { Deprecated(__FUNCTION__, 'Thumbnail'); } $Width = ArrayValue('width', $Attributes, ''); $Height = ArrayValue('height', $Attributes, ''); if (Is_Array($Data)) { // group, todo // <ul><li><a></a></li> } $Prefix = substr($Data, 0, 7); //if(In_Array($Prefix, array('http://', 'https:/'))) {} //$bLocalImage = False; if ($Prefix != 'http://') { //$bLocalImage = True; $IncomingImage = $Data; $ImageFindPaths[] = 'uploads' . DS . $Data; $ImageFindPaths[] = $Data; foreach ($ImageFindPaths as $File) { if (file_exists($File) && is_file($File)) { $IncomingImage = $File; break; } } } else { $IncomingImage = $Data; } $CacheDirectory = 'uploads/cached'; if (!is_writable($CacheDirectory)) { mkdir($CacheDirectory, 0777, True); if (!is_writable($CacheDirectory)) { $ErrorMessage = ErrorMessage(sprintf(T('Directory (%s) is not writable.'), $CacheDirectory), 'PHP', __FUNCTION__); trigger_error($ErrorMessage, E_USER_ERROR); return ''; } } $Name = CleanupString(pathinfo($IncomingImage, PATHINFO_FILENAME) . ' ' . $Width . ' ' . $Height); $Extension = FileExtension($IncomingImage); $Target = $CacheDirectory . DS . $Name . '.' . $Extension; if (!file_exists($Target)) { Gdn_UploadImage::SaveImageAs($IncomingImage, $Target, $Height, $Width); } $Target = str_replace(DS, '/', $Target); if (!array_key_exists('alt', $Attributes)) { $Attributes['alt'] = pathinfo($Name, PATHINFO_FILENAME); } list($Width, $Height, $Type) = GetImageSize($IncomingImage); $Attributes['alt'] .= sprintf(' (%d×%d)', $Width, $Height); $Image = Img($Target, $Attributes); return Anchor($Image, Url($IncomingImage), '', '', True); }
private function PrepareCache($LocaleName = False) { if ($LocaleName === False) { $LocaleName = $this->_Locale->Current(); } $EnabledApplications = Gdn::Config('EnabledApplications', array()); $EnabledPlugins = Gdn::Config('EnabledPlugins', array()); $LocaleSources = array(); // Get application-based locale special definition files // 2.0.0+ (TODO: REMOVE) $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'distinctions.php')), $EnabledApplications); if ($ApplicationLocaleSources !== False) { if (C('Debug')) { Deprecated("Move all application's locale distinctions.php files to [applicationname]/locale/[localename].custom.php, distinctions.php filenames"); } $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources); } // 2.0.11+ (TODO: REMOVE) $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName . '.distinct.php')), $EnabledApplications); if ($ApplicationLocaleSources !== False) { if (C('Debug')) { Deprecated("Rename all application's locale [localename].distinct.php files to [localename].custom.php, [localename].distinct.php filenames"); } $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources); } // 2.0.18+ $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName . '.custom.php')), $EnabledApplications); if ($ApplicationLocaleSources !== False) { $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources); } // Get plugin-based locale special definition files // 2.0.0+ (TODO: REMOVE) $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'distinctions.php')), $EnabledPlugins); if ($PluginLocaleSources !== False) { if (C('Debug')) { Deprecated("Move all plugin's locale distinctions.php files to [pluginname]/locale/[localename].custom.php, distinctions.php filenames"); } $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources); } // 2.0.11+ (TODO: REMOVE) $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName . '.distinct.php')), $EnabledPlugins); if ($PluginLocaleSources !== False) { if (C('Debug')) { Deprecated("Rename all plugin's locale [localename].distinct.php files to [localename].custom.php, [localename].distinct.php filenames"); } $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources); } // 2.0.18+ $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName . '.custom.php')), $EnabledPlugins); if ($PluginLocaleSources !== False) { $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources); } // Get theme-based locale special definition files. $Theme = Gdn::Config('Garden.Theme'); if ($Theme) { // 2.0.11+, TODO: REMOVE $ThemeLocalePath = PATH_THEMES . "/{$Theme}/locale/{$LocaleName}.distinct.php"; if (file_exists($ThemeLocalePath)) { $LocaleSources[] = $ThemeLocalePath; if (C('Debug')) { Deprecated("Rename file to {$LocaleName}.custom.php, {$LocaleName}.distinct.php filename"); } } // 2.0.18+ $ThemeLocalePath = PATH_THEMES . "/{$Theme}/locale/{$LocaleName}.distinct.php"; if (file_exists($ThemeLocalePath)) { $LocaleSources[] = $ThemeLocalePath; } } // Get locale-based locale special definition files. $EnabledLocales = Gdn::Config('EnabledLocales'); if (is_array($EnabledLocales)) { foreach ($EnabledLocales as $Key => $Locale) { if ($Locale != $LocaleName) { continue; } // Grab all of the files in the locale's folder (subdirectory custom) $Paths = glob(PATH_ROOT . "/locales/{$Key}/custom/*.php"); if (is_array($Paths)) { foreach ($Paths as $Path) { $LocaleSources[] = $Path; } } } } $PhpLocaleName = var_export($LocaleName, True); $PhpLocaleSources = var_export($LocaleSources, True); $PhpArrayCode = "\n\$_[{$PhpLocaleName}] = {$PhpLocaleSources};"; $CacheFile = PATH_CACHE . '/customtranslation_map.ini'; if (!file_exists($CacheFile)) { $PhpArrayCode = '<?php' . $PhpArrayCode; } file_put_contents($CacheFile, $PhpArrayCode, FILE_APPEND | LOCK_EX); }
/** * Lookup the path to a CSS file and return its info array * * @param string $Filename name/relative path to css file * @param string $Folder optional. app or plugin folder to search * @param string $ThemeType mobile or desktop * @return array|bool */ public static function cssPath($Filename, $Folder = '', $ThemeType = '') { if (!$ThemeType) { $ThemeType = isMobile() ? 'mobile' : 'desktop'; } // 1. Check for a url. if (isUrl($Filename)) { return array($Filename, $Filename); } $Paths = array(); // 2. Check for a full path. if (strpos($Filename, '/') === 0) { $Filename = ltrim($Filename, '/'); // Direct path was given $Filename = "/{$Filename}"; $Path = PATH_ROOT . $Filename; if (file_exists($Path)) { Deprecated("AssetModel::CssPath() with direct paths"); return array($Path, $Filename); } return false; } // 3. Check the theme. $Theme = Gdn::ThemeManager()->ThemeFromType($ThemeType); if ($Theme) { $Path = "/{$Theme}/design/{$Filename}"; $Paths[] = array(PATH_THEMES . $Path, "/themes{$Path}"); } // 4. Static, Plugin, or App relative file if ($Folder) { if (in_array($Folder, array('resources', 'static'))) { $Path = "/resources/design/{$Filename}"; $Paths[] = array(PATH_ROOT . $Path, $Path); // A plugin-relative path was given } elseif (stringBeginsWith($Folder, 'plugins/')) { $Folder = substr($Folder, strlen('plugins/')); $Path = "/{$Folder}/design/{$Filename}"; $Paths[] = array(PATH_PLUGINS . $Path, "/plugins{$Path}"); // Allow direct-to-file links for plugins $Paths[] = array(PATH_PLUGINS . "/{$Folder}/{$Filename}", "/plugins/{$Folder}/{$Filename}", true); // deprecated // An app-relative path was given } else { $Path = "/{$Folder}/design/{$Filename}"; $Paths[] = array(PATH_APPLICATIONS . $Path, "/applications{$Path}"); } } // 5. Check the default application. if ($Folder != 'dashboard') { $Paths[] = array(PATH_APPLICATIONS . "/dashboard/design/{$Filename}", "/applications/dashboard/design/{$Filename}", true); // deprecated } foreach ($Paths as $Info) { if (file_exists($Info[0])) { if (!empty($Info[2])) { // This path is deprecated. unset($Info[2]); Deprecated("The css file '{$Filename}' in folder '{$Folder}'"); } return $Info; } } if (!(StringEndsWith($Filename, 'custom.css') || StringEndsWith($Filename, 'customadmin.css'))) { trace("Could not find file '{$Filename}' in folder '{$Folder}'."); } return false; }
public function Full($Fields = '', $Where = False) { if (Debug()) { Deprecated('Full', 'GetNodes'); } if ($Fields) { $Where['Fields'] = $Fields; } return $this->GetNodes($Where); }