public function UserModel_BeforeDeleteUser_Handler($Sender) { $UserID = GetValue('UserID', $Sender->EventArguments); $Options = GetValue('Options', $Sender->EventArguments, array()); $Options = is_array($Options) ? $Options : array(); $DeleteMethod = GetValue('DeleteMethod', $Options, 'delete'); if ($DeleteMethod == 'delete') { $Sender->SQL->Delete('Conversation', array('InsertUserID' => $UserID)); $Sender->SQL->Delete('Conversation', array('UpdateUserID' => $UserID)); $Sender->SQL->Delete('UserConversation', array('UserID' => $UserID)); $Sender->SQL->Delete('ConversationMessage', array('InsertUserID' => $UserID)); } else if ($DeleteMethod == 'wipe') { $Sender->SQL->Update('ConversationMessage') ->Set('Body', T('The user and all related content has been deleted.')) ->Set('Format', 'Deleted') ->Where('InsertUserID', $UserID) ->Put(); } else { // Leave conversation messages } // Remove the user's profile information related to this application $Sender->SQL->Update('User') ->Set('CountUnreadConversations', 0) ->Where('UserID', $UserID) ->Put(); }
public function Render() { $RenderedCount = 0; foreach ($this->Items as $Item) { $this->EventArguments['AssetName'] = $this->AssetName; if (is_string($Item)) { if (!empty($Item)) { if ($RenderedCount > 0) { $this->FireEvent('BetweenRenderAsset'); } echo $Item; $RenderedCount++; } } elseif ($Item instanceof Gdn_IModule) { if (!GetValue('Visible', $Item, TRUE)) { continue; } $LengthBefore = ob_get_length(); $Item->Render(); $LengthAfter = ob_get_length(); if ($LengthBefore !== FALSE && $LengthAfter > $LengthBefore) { if ($RenderedCount > 0) { $this->FireEvent('BetweenRenderAsset'); } $RenderedCount++; } } else { throw new Exception(); } } unset($this->EventArguments['AssetName']); }
/** * Display the embedded forum. * * @since 2.0.18 * @access public */ public function Index() { $this->AddSideMenu('dashboard/embed'); $this->Title('Embed Vanilla'); $this->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Garden.TrustedDomains')); $this->Form->SetModel($ConfigurationModel); if ($this->Form->AuthenticatedPostBack() === FALSE) { // Format trusted domains as a string $TrustedDomains = GetValue('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 { // Format the trusted domains as an array based on newlines & spaces $TrustedDomains = $this->Form->GetValue('Garden.TrustedDomains'); $TrustedDomains = explode(' ', str_replace("\n", ' ', $TrustedDomains)); $TrustedDomains = array_unique(array_map('trim', $TrustedDomains)); $this->Form->SetFormValue('Garden.TrustedDomains', $TrustedDomains); if ($this->Form->Save() !== FALSE) { $this->InformMessage(T("Your settings have been saved.")); } // Reformat array as string so it displays properly in the form $this->Form->SetFormValue('Garden.TrustedDomains', implode("\n", $TrustedDomains)); } $this->Render(); }
/** */ function smarty_function_signin_link($Params, &$Smarty) { if (!Gdn::Session()->IsValid()) { $Wrap = GetValue('wrap', $Params, 'li'); return Gdn_Theme::Link('signinout', GetValue('text', $Params, ''), GetValue('format', $Params, Wrap('<a href="%url" rel="nofollow" class="%class">%text</a>', $Wrap)), $Params); } }
public function ToString() { if ($this->_UserData->NumRows() == 0) { return ''; } $String = ''; ob_start(); ?> <div class="Box"> <?php echo panelHeading(T('In this Discussion')); ?> <ul class="PanelInfo"> <?php foreach ($this->_UserData->Result() as $User) { ?> <li> <?php echo Anchor(Wrap(Wrap(Gdn_Format::Date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . Wrap(Wrap(GetValue('Name', $User), 'span', array('class' => 'Username')), 'span'), UserUrl($User)); ?> </li> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
/** * A placeholder for future menu items. * * @param array The parameters passed into the function. This currently takes no parameters. * @param Smarty The smarty object rendering the template. * @return */ function smarty_function_custom_menu($Params, &$Smarty) { $Controller = $Smarty->Controller; if (is_object($Menu = GetValue('Menu', $Controller))) { $Format = GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', GetValue('wrap', $Params, 'li'))); $Result = ''; foreach ($Menu->Items as $Group) { foreach ($Group as $Item) { // Make sure the item is a custom item. if (GetValueR('Attributes.Standard', $Item)) { continue; } // Make sure the user has permission for the item. if ($Permission = GetValue('Permission', $Item)) { if (!Gdn::Session()->CheckPermission($Permission)) { continue; } } if (($Url = GetValue('Url', $Item)) && ($Text = GetValue('Text', $Item))) { $Result .= Gdn_Theme::Link($Url, $Text, $Format); } } } return $Result; } return ''; }
/** * Create different sizes of user photos. */ public function processAvatars() { $UploadImage = new Gdn_UploadImage(); $UserData = $this->SQL->select('u.Photo')->from('User u')->where('u.Photo is not null')->get(); // Make sure the avatars folder exists. if (!file_exists(PATH_UPLOADS . '/userpics')) { mkdir(PATH_UPLOADS . '/userpics'); } // Get sizes $ProfileHeight = c('Garden.Profile.MaxHeight', 1000); $ProfileWidth = c('Garden.Profile.MaxWidth', 250); $ThumbSize = c('Garden.Thumbnail.Size', 40); // Temporarily set maximum quality saveToConfig('Garden.UploadImage.Quality', 100, false); // Create profile and thumbnail sizes foreach ($UserData->result() as $User) { try { $Image = PATH_ROOT . DS . 'uploads' . DS . GetValue('Photo', $User); $ImageBaseName = pathinfo($Image, PATHINFO_BASENAME); // Save profile size $UploadImage->SaveImageAs($Image, PATH_UPLOADS . '/userpics/p' . $ImageBaseName, $ProfileHeight, $ProfileWidth); // Save thumbnail size $UploadImage->SaveImageAs($Image, PATH_UPLOADS . '/userpics/n' . $ImageBaseName, $ThumbSize, $ThumbSize, true); } catch (Exception $ex) { } } }
public function TranslationCollectorLocale_BeforeTranslate_Handler($Sender) { $Application = $this->_EnabledApplication(); if (in_array($Application, $this->_SkipApplications)) { return; } $Code = GetValue('Code', $Sender->EventArguments, ''); if (substr($Code, 0, 1) == '@') { return; } if (array_key_exists($Code, $this->_Definition)) { return; } $Application = strtolower($Application); $File = dirname(__FILE__) . '/undefined/' . $Application . '.php'; if (!file_exists($File)) { $HelpText = "Translate, cut and paste this to /locales/your-locale/{$Application}.php"; file_put_contents($File, "<?php // {$HelpText} \n"); } $Definition = array(); include $File; if (!array_key_exists($Code, $Definition)) { // Should be escaped. $Code = var_export($Code, True); $PhpArrayCode = "\n\$Definition[" . $Code . "] = {$Code};"; file_put_contents($File, $PhpArrayCode, FILE_APPEND | LOCK_EX); } }
public function Get($Where = False, $Offset = False, $Limit = False, $OrderBy = 'p.PageID', $OrderDirection = 'desc') { $bCountQuery = GetValue('bCountQuery', $Where, False, True); if ($bCountQuery) { $this->SQL->Select('*', 'count', 'RowCount'); $Offset = $Limit = False; } if (GetValue('Browse', $Where, True, True) && !$bCountQuery) { $this->SQL->Select('p.PageID, p.Title, p.Visible, p.SectionID, p.URI')->Select('p.DateInserted, p.DateInserted, p.UpdateUserID, p.DateUpdated'); } if ($Join = GetValue('WithSection', $Where, False, True)) { if (!in_array($Join, array('left', 'inner'), True)) { $Join = 'left'; } $SectionTable = C('Candy.Sections.Table', 'Section'); $this->SQL->Join("{$SectionTable} s", 's.SectionID = p.SectionID', $Join); if (!$bCountQuery) { $this->SQL->Select('s.SectionID as SectionID')->Select('s.TreeLeft as SectionTreeLeft')->Select('s.TreeRight as SectionTreeRight')->Select('s.Depth as SectionDepth')->Select('s.ParentID as SectionParentID')->Select('s.Name as SectionName')->Select('s.RequestUri as SectionRequestUri'); } } $this->EventArguments['bCountQuery'] = $bCountQuery; $this->EventArguments['Where'] =& $Where; $this->FireEvent('BeforeGet'); if ($OrderBy !== False && !$bCountQuery) { $this->SQL->OrderBy($OrderBy, $OrderDirection); } if (is_array($Where)) { $this->SQL->Where($Where); } $Result = $this->SQL->From('Page p')->Limit($Limit, $Offset)->Get(); if ($bCountQuery) { $Result = $Result->FirstRow()->RowCount; } return $Result; }
public function UserInfoModule_OnBasicInfo_Handler(&$Sender) { $UserID = $Sender->User->UserID; $PostCount = GetValue("PostCount", Gdn::Database()->Query(sprintf("SELECT COALESCE(u.CountComments,0) + COALESCE(u.CountDiscussions,0) AS PostCount FROM GDN_User u WHERE UserID = %d", $UserID))->FirstRow(DATASET_TYPE_ARRAY), 0); echo "<dt>" . T(Plural($PostCount, 'Posts', 'Posts')) . "</dt>\n"; echo "<dd>" . number_format($PostCount) . "</dd>"; }
function DPRenderResults($Poll) { $TitleExists = GetValue('Title', $Poll, FALSE); $HideTitle = C('Plugins.DiscussionPolls.DisablePollTitle', FALSE); echo '<div class="DP_ResultsForm">'; if ($TitleExists || $HideTitle) { $TitleS = $Poll->Title; if (trim($Poll->Title) != FALSE) { $TitleS .= '<hr />'; } } else { $TitleS = Wrap(T('Plugins.DiscussionPolls.NotFound', 'Poll not found')); } echo $TitleS; echo '<ol class="DP_ResultQuestions">'; if (!$TitleExists && !$HideTitle) { //do nothing } else { if (!count($Poll->Questions)) { echo Wrap(T('Plugins.DiscussionPolls.NoReults', 'No results for this poll')); } else { foreach ($Poll->Questions as $Question) { RenderQuestion($Question); } } } echo '</ol>'; echo '</div>'; }
/** * Take a user object, and writes out an anchor of the user's name to the user's profile. */ function userAnchor($User, $CssClass = null, $Options = null) { static $NameUnique = null; if ($NameUnique === null) { $NameUnique = c('Garden.Registration.NameUnique'); } if (is_array($CssClass)) { $Options = $CssClass; $CssClass = null; } elseif (is_string($Options)) { $Options = array('Px' => $Options); } $Px = GetValue('Px', $Options, ''); $Name = GetValue($Px . 'Name', $User, t('Unknown')); // $Text = GetValue('Text', $Options, htmlspecialchars($Name)); // Allow anchor text to be overridden. $Text = GetValue('Text', $Options, ''); if ($Text == '') { // get all fields since that is better for caching! $profileFields = Gdn::userMetaModel()->getUserMeta($User->UserID, 'Profile.%', 'Profile.'); $Text = $profileFields['Profile.' . c('Nickname.Fieldname')]; if ($Text == '') { $Text = htmlspecialchars($Name); } // return } else { $Text = htmlspecialchars($Name); } $Attributes = array('class' => $CssClass, 'rel' => GetValue('Rel', $Options)); if (isset($Options['title'])) { $Attributes['title'] = $Options['title']; } $UserUrl = UserUrl($User, $Px); return '<a href="' . htmlspecialchars(Url($UserUrl)) . '"' . Attribute($Attributes) . '>' . $Text . '</a>'; }
public function GetPluginFolder($Absolute = TRUE) { $Folder = GetValue('Folder', Gdn::PluginManager()->GetPluginInfo(get_class($this), Gdn_PluginManager::ACCESS_CLASSNAME)); $PathParts = array($Folder); array_unshift($PathParts, $Absolute ? PATH_PLUGINS : 'plugins'); return implode(DS, $PathParts); }
public function DiscussionModel_BeforeGet_Handler($Sender) { $ArticleID = GetValue('ArticleID', $Sender); if (is_numeric($ArticleID) && $ArticleID > 0) { $Sender->SQL->Where('ArticleID', $ArticleID); } }
public function Get($Where = False, $Offset = False, $Limit = False, $OrderBy = False, $OrderDirection = 'desc') { $bCountQuery = GetValue('bCountQuery', $Where, False, True); if ($bCountQuery) { $this->SQL->Select('*', 'count', 'RowCount'); $Offset = False; $Limit = False; $OrderBy = False; } if (GetValue('Browse', $Where, True, True) && !$bCountQuery) { $this->SQL->Select('c.ChunkID, c.Name, c.Url, c.InsertUserID, c.DateInserted, c.UpdateUserID, c.DateUpdated'); } /* if (GetValue('InsertAuthor', $Where, False, True) && !$bCountQuery) { } if (GetValue('UpdateAuthor', $Where, False, True) && !$bCountQuery) { } */ $this->EventArguments['bCountQuery'] = $bCountQuery; $this->EventArguments['Where'] =& $Where; $this->FireEvent('BeforeGet'); if ($OrderBy !== False) { $this->SQL->OrderBy($OrderBy, $OrderDirection); } if (is_array($Where)) { $this->SQL->Where($Where); } $Result = $this->SQL->From($this->Name . ' c')->Limit($Limit, $Offset)->Get(); if ($bCountQuery) { $Result = $Result->FirstRow()->RowCount; } return $Result; }
function WriteConditionEdit($Condition, $Sender) { $Px = $Sender->Prefix; $Form = new Gdn_Form(); $Type = GetValue(0, $Condition, ''); $Field = GetValue(1, $Condition, ''); $Expr = GetValue(2, $Condition, ''); echo '<tr>'; // Type. echo '<td>', $Form->DropDown($Px . 'Type[]', $Sender->Types, array('Value' => $Type, 'Class' => 'CondType')), '</td>'; echo '<td>'; // Permission fields. echo '<div class="Cond_permission"' . _DN($Type, Gdn_Condition::PERMISSION) . '>', $Form->DropDown($Px . 'PermissionField[]', $Sender->Permissions, array('Value' => $Type == Gdn_Condition::PERMISSION ? $Field : '')), '</div>'; // Role fields. echo '<div class="Cond_role"' . _DN($Type, Gdn_Condition::ROLE) . '>', $Form->DropDown($Px . 'RoleField[]', $Sender->Roles, array('Value' => $Type == Gdn_Condition::ROLE ? $Field : '')), '</div>'; // Textbox field. echo '<div class="Cond_request"' . _DN($Type, Gdn_Condition::REQUEST) . '>', $Form->TextBox($Px . 'Field[]', array('Value' => $Type == Gdn_Condition::REQUEST ? $Field : '')); '</div>'; echo '</td>'; // Expression. echo '<td>', '<div class="Cond_request"' . _DN($Type, Gdn_Condition::REQUEST) . '>', $Form->TextBox($Px . 'Expr[]', array('Value' => $Type == Gdn_Condition::REQUEST ? $Expr : '')), '</div>', '</td>'; // Buttons. echo '<td align="right">', '<a href="#" class="DeleteCondition">', T('Delete'), '</a></td>'; echo '</tr>'; }
/** * Modify CountUnreadComments to account for DateAllViewed * * Required in DiscussionModel->Get() just before the return: * $this->EventArguments['Data'] = $Data; * $this->FireEvent('AfterAddColumns'); * @link http://vanillaforums.org/discussion/13227 */ function DiscussionModel_AfterAddColumns_Handler(&$Sender) { if (!C('Plugins.AllViewed.Enabled')) { return; } // Only for members $Session = Gdn::Session(); if (!$Session->IsValid()) { return; } // Recalculate New count with user's DateAllViewed $Sender->Data = GetValue('Data', $Sender->EventArguments, ''); $Result =& $Sender->Data->Result(); foreach ($Result as &$Discussion) { if (Gdn_Format::ToTimestamp($Discussion->DateLastComment) <= Gdn_Format::ToTimestamp($Session->User->DateAllViewed)) { $Discussion->CountUnreadComments = 0; // Covered by AllViewed } elseif ($Discussion->CountCommentWatch == 0) { // AllViewed used, but new comments since then $Discussion->CountCommentWatch = -1; // hack around "incomplete comment count" logic in WriteDiscussion $Discussion->CountUnreadComments = $Discussion->CountComments; } } }
/** */ function smarty_function_category_link($Params, &$Smarty) { $Path = GetValue('path', $Params, '', TRUE); $Text = GetValue('text', $Params, '', TRUE); $Wrap = GetValue('wrap', $Params, 'li'); return Gdn_Theme::Link('category', GetValue('text', $Params, ''), GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', $Wrap))); }
public function discount($price) { $discount_enable = GetValue('discount_enable'); //判断是否有折扣 $discount = 1; $r = array(); if ($discount_enable) { $model = D('Discount'); $list = $model->select(); foreach ($list as $k => $v) { if ($price >= $v['minmoney'] && $price <= $v['maxmoney']) { $discount = $v['discount']; break; } } } if ($discount < 1) { $r['price'] = round($price * $discount, 2); //保留两位 $r['text'] = getprice_str($price) . '*<Span style="color:red;font-weight:bold;">' . $discount * 100 . '%</span>=' . getprice_str($r['price']); } else { $r['price'] = $price; $r['text'] = ""; } return $r; }
/** * @copyright Copyright 2008, 2009 Vanilla Forums Inc. * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 */ function smarty_function_module($Params, &$Smarty) { $Name = GetValue('name', $Params); unset($Params['name']); $Result = Gdn_Theme::Module($Name, $Params); return $Result; }
function MostRecentString($Row) { if (!$Row['LastTitle']) { return ''; } $R = ''; $R .= '<span class="MostRecent">'; $R .= '<span class="MLabel">' . T('Most recent:') . '</span> '; $R .= Anchor(SliceString(Gdn_Format::Text($Row['LastTitle']), 150), $Row['LastUrl'], 'LatestPostTitle'); if (GetValue('LastName', $Row)) { $R .= ' '; $R .= '<span class="MostRecentBy">' . T('by') . ' '; $R .= UserAnchor($Row, 'UserLink', 'Last'); $R .= '</span>'; } if (GetValue('LastDateInserted', $Row)) { $R .= ' '; $R .= '<span class="MostRecentOn">'; $R .= T('on') . ' '; $R .= Anchor(Gdn_Format::Date($Row['LastDateInserted'], 'html'), $Row['LastUrl'], 'CommentDate'); $R .= '</span>'; } $R .= '</span>'; return $R; }
public function DiscussionsController_Participated_Create(&$Sender, $Args) { $Sender->Permission('Garden.SignIn.Allow'); $Page = GetValue(0, $Args); $Limit = GetValue(1, $Args); list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30)); // Get Discussions $DiscussionModel = new DiscussionModel(); $Sender->DiscussionData = $DiscussionModel->GetParticipated(Gdn::Session()->UserID, $Offset, $Limit); $Sender->SetData('Discussions', $Sender->DiscussionData); $CountDiscussions = $DiscussionModel->GetCountParticipated(Gdn::Session()->UserID); $Sender->SetData('CountDiscussions', $CountDiscussions); // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->EventArguments['PagerType'] = 'Pager'; $Sender->FireEvent('BeforeBuildPager'); $Sender->Pager = $PagerFactory->GetPager($Sender->EventArguments['PagerType'], $Sender); $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/participated/%1$s'); $Sender->FireEvent('AfterBuildPager'); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'discussions'; } // Add modules $Sender->AddModule('NewDiscussionModule'); $Sender->AddModule('CategoriesModule'); $BookmarkedModule = new BookmarkedModule($Sender); $BookmarkedModule->GetData(); $Sender->AddModule($BookmarkedModule); $Sender->Render($this->GetView('participated.php')); }
function DiscussionPollAnswerForm($PollForm, $Poll, $PartialAnswers) { echo '<div class="DP_AnswerForm">'; if (GetValue('Title', $Poll) || C('Plugins.DiscussionPolls.DisablePollTitle', FALSE)) { echo $Poll->Title; if (trim($Poll->Title) != FALSE) { echo '<hr />'; } } echo $PollForm->Open(array('action' => Url('/discussion/poll/submit/'), 'method' => 'post', 'ajax' => TRUE)); echo $PollForm->Errors(); $m = 0; // Render poll questions echo '<ol class="DP_AnswerQuestions">'; foreach ($Poll->Questions as $Question) { echo '<li class="DP_AnswerQuestion">'; echo $PollForm->Hidden('DP_AnswerQuestions[]', array('value' => $Question->QuestionID)); echo Wrap($Question->Title, 'span'); echo '<ol class="DP_AnswerOptions">'; foreach ($Question->Options as $Option) { if (GetValue($Question->QuestionID, $PartialAnswers) == $Option->OptionID) { //fill in partial answer echo Wrap($PollForm->Radio('DP_Answer' . $m, $Option->Title, array('Value' => $Option->OptionID, 'checked' => 'checked')), 'li'); } else { echo Wrap($PollForm->Radio('DP_Answer' . $m, $Option->Title, array('Value' => $Option->OptionID)), 'li'); } } echo '</ol>'; echo '</li>'; $m++; } echo '</ol>'; echo $PollForm->Close('Submit'); echo '</div>'; }
/** * Renders an asset from the controller. * * @param array The parameters passed into the function. * The parameters that can be passed to this function are as follows. * - <b>name</b>: The name of the asset. * - <b>tag</b>: The type of tag to wrap the asset in. * - <b>id</b>: The id of the tag if different than the name. * @param Smarty The smarty object rendering the template. * @return The rendered asset. */ function smarty_function_asset($Params, &$Smarty) { $Name = ArrayValue('name', $Params); $Tag = ArrayValue('tag', $Params, ''); $Id = ArrayValue('id', $Params, $Name); $Class = ArrayValue('class', $Params, ''); if ($Class != '') { $Class = ' class="' . $Class . '"'; } $Controller = $Smarty->Controller; $Controller->EventArguments['AssetName'] = $Name; $Result = ''; ob_start(); $Controller->FireEvent('BeforeRenderAsset'); $Result .= ob_get_clean(); $Asset = $Controller->GetAsset($Name); if (is_object($Asset)) { $Asset->AssetName = $Name; if (GetValue('Visible', $Asset, TRUE)) { $Asset = $Asset->ToString(); } else { $Asset = ''; } } if (!empty($Tag)) { $Result .= '<' . $Tag . ' id="' . $Id . '"' . $Class . '>' . $Asset . '</' . $Tag . '>'; } else { $Result .= $Asset; } ob_start(); $Controller->FireEvent('AfterRenderAsset'); $Result .= ob_get_clean(); return $Result; }
/** * Lesen von Wetterdaten anhand des Namens * * @param string $name Name der Variablen * @return string Wert der gelesen wurde */ function IPSWeatherFAT_GetValue($name) { $categoryId_Weather = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.Weather.IPSWeatherForcastAT'); $variableId = IPS_GetObjectIDByIdent($name, $categoryId_Weather); $value = GetValue($variableId); return $value; }
/** * Takes a route and prepends the web root (expects "/controller/action/params" as $Path). * * @param array The parameters passed into the function. * The parameters that can be passed to this function are as follows. * - <b>path</b>: The relative path for the url. There are some special paths that can be used to return "intelligent" links: * - <b>signinout</b>: This will return a signin/signout url that will toggle depending on whether or not the user is already signed in. When this path is given the text is automaticall set. * - <b>withdomain</b>: Whether or not to add the domain to the url. * - <b>text</b>: Html text to be put inside an anchor. If this value is set then an html <a></a> is returned rather than just a url. * - <b>id, class, etc.</b>: When an anchor is generated then any other attributes are passed through and will be written in the resulting tag. * @param Smarty The smarty object rendering the template. * @return The url. */ function smarty_function_link($Params, &$Smarty) { $Path = GetValue('path', $Params, '', TRUE); $Text = GetValue('text', $Params, '', TRUE); $NoTag = GetValue('notag', $Params, FALSE, TRUE); $CustomFormat = GetValue('format', $Params, FALSE, TRUE); if (!$Text && $Path != 'signinout' && $Path != 'signin') { $NoTag = TRUE; } if ($CustomFormat) { $Format = $CustomFormat; } else { if ($NoTag) { $Format = '%url'; } else { $Format = '<a href="%url" class="%class">%text</a>'; } } $Options = array(); if (isset($Params['withdomain'])) { $Options['WithDomain'] = $Params['withdomain']; } if (isset($Params['class'])) { $Options['class'] = $Params['class']; } if (isset($Params['tk'])) { $Options['TK'] = $Params['tk']; } if (isset($Params['target'])) { $Options['Target'] = $Params['target']; } $Result = Gdn_Theme::Link($Path, $Text, $Format, $Options); return $Result; }
function IPSWatering_Log($Msg) { $id_LogMessages = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.Log.LogMessages'); $id_LogId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.Log.LogId'); $Msg = htmlentities($Msg, ENT_COMPAT, 'ISO-8859-1'); $Msg = str_replace("\n", "<BR>", $Msg); $MsgList = GetValue($id_LogMessages); $TablePrefix = '<table width="100%" style="font-family:courier; font-size:10px;">'; $CurrentMsgId = GetValue($id_LogId)+1; SetValue($id_LogId, $CurrentMsgId); //2010-12-03 22:09 Msg ... $Out = '<tr id="'.$CurrentMsgId.'" style="color:#FFFFFF;">'; $Out .= '<td>'.date('Y-m-d H:i').'</td>'; $Out .= '<td>'.$Msg.'</td>'; $Out .= '</tr>'; //<table><tr><td>....</tr></table> if (strpos($MsgList, '</table>') === false) { $MsgList = ""; } else { $StrTmp = '<tr id="'.($CurrentMsgId-c_LogMessage_Count+1).'"'; if (strpos($MsgList, $StrTmp)===false) { $StrPos = strlen($TablePrefix); } else { $StrPos = strpos($MsgList, $StrTmp); } $StrLen = strlen($MsgList) - strlen('</table>') - $StrPos; $MsgList = substr($MsgList, $StrPos, $StrLen); } SetValue($id_LogMessages, $TablePrefix.$MsgList.$Out.'</table>'); }
public function Save($FormPostValues, $Settings = FALSE) { // Get the ID of an existing tag with the same name. $ExistingTag = $this->GetWhere(array('Name' => $FormPostValues['Name'], 'TagID <>' => GetValue('TagID', $FormPostValues)))->FirstRow(DATASET_TYPE_ARRAY); if ($ExistingTag) { if (!GetValue('TagID', $FormPostValues)) { return $ExistingTag['TagID']; } // This tag will be merged with the existing one. $Px = $this->Database->DatabasePrefix; $FromID = $FormPostValues['TagID']; $ToID = $ExistingTag['TagID']; try { $this->Database->BeginTransaction(); // Delete all of the overlapping tags. $Sql = "delete tg.*\n from {$Px}TagDiscussion tg\n join {$Px}TagDiscussion tg2\n on tg.DiscussionID = tg2.DiscussionID\n and tg.TagID = :FromID and tg2.TagID = :ToID"; $this->Database->Query($Sql, array(':FromID' => $FromID, ':ToID' => $ToID)); // Update the tagged discussions. $Sql = "update {$Px}TagDiscussion\n set TagID = :ToID\n where TagID = :FromID"; $this->Database->Query($Sql, array(':FromID' => $FromID, ':ToID' => $ToID)); // Update the counts. $Sql = "update {$Px}Tag t\n set CountDiscussions = (\n select count(DiscussionID)\n from {$Px}TagDiscussion td\n where td.TagID = t.TagID)\n where t.TagID = :ToID"; $this->Database->Query($Sql, array(':ToID' => $ToID)); // Delete the old tag. $Sql = "delete from {$Px}Tag where TagID = :FromID"; $this->Database->Query($Sql, array(':FromID' => $FromID)); $this->Database->CommitTransaction(); } catch (Exception $Ex) { $this->Database->RollbackTransaction(); throw $Ex; } } else { parent::Save($FormPostValues, $Settings); } }
public function Base_CheckSpam_Handler($Sender, $Args) { if ($Args['IsSpam']) { return; } // don't double check $RecordType = $Args['RecordType']; $Data =& $Args['Data']; $Result = FALSE; switch ($RecordType) { case 'Registration': $Data['Name'] = ''; $Data['Body'] = GetValue('DiscoveryText', $Data); if ($Data['Body']) { // Only check for spam if there is discovery text. $Result = $this->CheckMollom($RecordType, $Data); if ($Result) { $Data['Log_InsertUserID'] = $this->UserID(); } } break; case 'Comment': case 'Discussion': case 'Activity': case 'ActivityComment': $Result = $this->CheckMollom($RecordType, $Data); if ($Result) { $Data['Log_InsertUserID'] = $this->UserID(); } break; default: $Result = FALSE; } $Sender->EventArguments['IsSpam'] = $Result; }
function GoogleTranslate($Text, $Options = False) { static $LanguageCode; if (is_null($LanguageCode)) { $LanguageCode = LocaleLanguageCode(); } $ResetCache = ArrayValue('ResetCache', $Options, False); $From = ArrayValue('From', $Options, $LanguageCode); $To = ArrayValue('To', $Options, $LanguageCode); $String = rawurlencode($Text); if (!LoadExtension('curl')) { throw new Exception('You need to load/activate the cURL extension (http://www.php.net/cURL).'); } $Resource = curl_init(); $HTTPS = GetValue('HTTPS', $_SERVER, ''); $Protocol = strlen($HTTPS) || GetValue('SERVER_PORT', $_SERVER) == 443 ? 'https://' : 'http://'; $Host = GetValue('HTTP_HOST', $_SERVER, 'google.com'); $Referer = $Protocol . $Host; curl_setopt($Resource, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q={$String}&langpair={$From}%7C{$To}"); curl_setopt($Resource, CURLOPT_RETURNTRANSFER, 1); curl_setopt($Resource, CURLOPT_REFERER, $Referer); $Body = curl_exec($Resource); curl_close($Resource); $TranslatedText = GetValueR('responseData.translatedText', json_decode($Body)); $TranslatedText = html_entity_decode($TranslatedText, ENT_QUOTES, 'utf-8'); return $TranslatedText; }