function showImage($path) { if (strpos($path, "http") === 0) { return $path; } return Asset('public/image/') . '/' . $path; }
/** * Looks through the themes directory for valid themes and returns them as * an associative array of "Theme Name" => "Theme Info Array". It also adds * a "Folder" definition to the Theme Info Array for each. */ public function AvailableThemes() { if (!is_array($this->_AvailableThemes)) { $ThemeInfo = array(); $ThemeFolders = Gdn_FileSystem::Folders(PATH_THEMES); $ThemeAboutFiles = Gdn_FileSystem::FindAll(PATH_THEMES, 'about.php', $ThemeFolders); // Include them all right here and fill the theme info array $ThemeCount = is_array($ThemeAboutFiles) ? count($ThemeAboutFiles) : 0; for ($i = 0; $i < $ThemeCount; ++$i) { include $ThemeAboutFiles[$i]; // Define the folder name for the newly added item foreach ($ThemeInfo as $ThemeName => $Info) { if (array_key_exists('Folder', $ThemeInfo[$ThemeName]) === FALSE) { $Folder = substr($ThemeAboutFiles[$i], strlen(PATH_THEMES)); if (substr($Folder, 0, 1) == DS) { $Folder = substr($Folder, 1); } $Folder = substr($Folder, 0, strpos($Folder, DS)); $ThemeInfo[$ThemeName]['Folder'] = $Folder; // Add the screenshot. $ScreenshotPath = SafeGlob(PATH_THEMES . "/{$Folder}/screenshot.*", array('gif', 'jpg', 'png')); if (count($ScreenshotPath) > 0) { $ScreenshotPath = $ScreenshotPath[0]; $ThemeInfo[$ThemeName]['ScreenshotUrl'] = Asset(str_replace(PATH_ROOT, '', $ScreenshotPath)); } } } } $this->_AvailableThemes = $ThemeInfo; } return $this->_AvailableThemes; }
public function htmlMenu($menus = array(), $lft = 0, $rgt = null, $deep = 0) { global $treeMenu; if ($lft == 0 && $rgt == null && $deep == 0) { $treeMenu .= '<ul>'; } foreach ($menus as $key => $val) { if ($val['lft'] > $lft && ($val['rgt'] < $rgt || is_null($rgt)) && $val['deep'] == $deep + 1) { unset($menus[$key]); $treeMenu .= '<li>'; $treeMenu .= $val['name'] . ' ----------------------------------------------' . '<a href="' . Asset('admin/category/del/') . '/' . $val['id'] . '"> <button type="button" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i></button> </a>' . '<a href="' . Asset('admin/category/update/') . '/' . $val['id'] . '"> <button type="button" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-edit"></i></button> </a>'; if ($val['rgt'] != $val['lft'] + 1) { $treeMenu .= '<ul>'; } $this->htmlMenu($menus, $val['lft'], $val['rgt'], $val['deep']); if ($val['rgt'] != $val['lft'] + 1) { $treeMenu .= '</ul>'; } $treeMenu .= '</li>'; } } if ($lft == 0 && is_null($rgt) && $deep == 0) { $treeMenu .= '</ul>'; } return $treeMenu; }
private function _GetButton() { $ImgSrc = Asset('/plugins/GoogleSignIn/design/google-icon.png'); $ImgAlt = T('Sign In with Google'); $SigninHref = $this->_AuthorizeHref(); $PopupSigninHref = $this->_AuthorizeHref(TRUE); return "<a id=\"GoogleAuth\" href=\"{$SigninHref}\" class=\"PopupWindow\" title=\"{$ImgAlt}\" popupHref=\"{$PopupSigninHref}\" popupHeight=\"400\" popupWidth=\"800\" ><img src=\"{$ImgSrc}\" alt=\"{$ImgAlt}\" /></a>"; }
/** * Show full url of book image. * @param [string] $name * @return [string] full link to image */ function imageBook($url) { if (File::exists(base_path() . '/public/resourcebook/' . $url)) { return Asset('resourcebook/' . $url); } else { return Asset('resourcebook/question-mark.png'); } }
/** * Returns an img tag. */ function Img($Image, $Attributes = '', $WithDomain = FALSE) { if ($Attributes == '') { $Attributes = array(); } if (substr($Image, 0, 7) != 'http://' && $Image != '') { $Image = Asset($Image, $WithDomain); } return '<img src="' . $Image . '"' . Attribute($Attributes) . ' />'; }
/** * Add our script and css to every page. * * @param $Sender */ public function Base_Render_Before($Sender) { if (!C("Plugins.Vanoogle.CSE")) { return; } // Normally one would use ->AddJsFile or ->Head->AddScript, but these insert a version arg in the url that makes the google api barf. $Sender->Head->AddTag('script', array('src' => Asset('https://www.google.com/jsapi', FALSE, FALSE), 'type' => 'text/javascript', 'id' => C("Plugins.Vanoogle.CSE"))); $Sender->AddCssFile('vanoogle.css', 'plugins/Vanoogle'); $Sender->AddJsFile('vanoogle.js', 'plugins/Vanoogle'); }
/** * Setup some variables for instance. */ public function __construct() { parent::__construct(); $this->mediaCache = null; $this->mediaCacheExpire = 60 * 60 * 6; $this->AssetPath = Asset('/plugins/editor'); $this->pluginInfo = Gdn::pluginManager()->getPluginInfo('editor', Gdn_PluginManager::ACCESS_PLUGINNAME); $this->ForceWysiwyg = c('Plugins.editor.ForceWysiwyg', false); // Check for additional formats $this->EventArguments['formats'] =& $this->Formats; $this->fireEvent('GetFormats'); }
/** * * * @param $User * @return string */ function userPhotoDefaultUrl($User) { $Email = val('Email', $User); $Https = Gdn::request()->scheme() == 'https'; $Protocol = $Https ? 'https://secure.' : 'http://www.'; $Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . c('Garden.Thumbnail.Width', 50); if (c('Plugins.Gravatar.UseVanillicon', true)) { $Url .= '&default=' . urlencode(Gdn::request()->scheme() . '://vanillicon.com/' . md5($Email) . '.png'); } else { $Url .= '&default=' . urlencode(Asset(c('Plugins.Gravatar.DefaultAvatar', c('Garden.DefaultAvatar', 'plugins/Gravatar/default.png')), true)); } return $Url; }
function UserPhotoDefaultUrl($User) { $Email = GetValue('Email', $User); $HTTPS = GetValue('HTTPS', $_SERVER, ''); $Protocol = strlen($HTTPS) || GetValue('SERVER_PORT', $_SERVER) == 443 ? 'https://secure.' : 'http://www.'; $Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . C('Garden.Thumbnail.Width', 50); if (C('Plugins.Gravatar.UseVanillicon', FALSE)) { $Url .= '&default=' . urlencode(Asset('http://vanillicon.com/' . md5($User->Name) . '.png')); } else { $Url .= '&default=' . urlencode(Asset(C('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)); } return $Url; }
public function ProfileController_AfterAddSideMenu_Handler($Sender, $Args) { if (!$Sender->User->Photo) { $Email = GetValue('Email', $Sender->User); $Protocol = Gdn::Request()->Scheme() == 'https' ? 'https://secure.' : 'http://www.'; $Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . C('Garden.Profile.MaxWidth', 200); if (C('Plugins.Gravatar.UseVanillicon', TRUE)) { $Url .= '&default=' . urlencode(Gdn::Request()->Scheme() . '://vanillicon.com/' . md5($Email) . '_200.png'); } else { $Url .= '&default=' . urlencode(Asset(C('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default_250.png'), TRUE)); } $Sender->User->Photo = $Url; } }
/** * Override the default UserBuilder function with one that switches the photo * out with a gravatar url if the photo is empty. */ function UserBuilder($Object, $UserPrefix = '') { $User = new stdClass(); $UserID = $UserPrefix . 'UserID'; $Name = $UserPrefix . 'Name'; $Photo = $UserPrefix . 'Photo'; $Email = $UserPrefix . 'Email'; $User->UserID = $Object->{$UserID}; $User->Name = $Object->{$Name}; $User->Photo = property_exists($Object, $Photo) ? $Object->{$Photo} : ''; if ($User->Photo == '' && property_exists($Object, $Email)) { $User->Photo = 'http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Object->{$Email})) . '&default=' . urlencode(Asset(Gdn::Config('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)) . '&size=' . Gdn::Config('Garden.Thumbnail.Width', 40); } return $User; }
/** * Override the default UserBuilder function with one that switches the photo * out with a gravatar url if the photo is empty. */ function UserBuilder($Object, $UserPrefix = '') { $User = new stdClass(); $UserID = $UserPrefix . 'UserID'; $Name = $UserPrefix . 'Name'; $Photo = $UserPrefix . 'Photo'; $Email = $UserPrefix . 'Email'; $User->UserID = $Object->{$UserID}; $User->Name = $Object->{$Name}; $User->Photo = property_exists($Object, $Photo) ? $Object->{$Photo} : ''; $Protocol = strlen($_SERVER['HTTPS']) > 0 || $_SERVER['SERVER_PORT'] == 443 ? 'https://secure.' : 'http://www.'; if ($User->Photo == '' && property_exists($Object, $Email)) { $User->Photo = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Object->{$Email})) . '&default=' . urlencode(Asset(Gdn::Config('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)) . '&size=' . Gdn::Config('Garden.Thumbnail.Width', 40); } return $User; }
/** * Get all tutorials, or a specific one. */ function getTutorials($TutorialCode = '') { // Define all Tutorials $Tutorials = array(array('Code' => 'introduction', 'Name' => 'Introduction to Vanilla', 'Description' => 'This video gives you a brief overview of the Vanilla administrative dashboard and the forum itself.', 'VideoID' => '31043422'), array('Code' => 'using-the-forum', 'Name' => 'Using the Forum', 'Description' => 'Learn how to start, announce, close, edit and delete discussions and comments.', 'VideoID' => '31502992'), array('Code' => 'private-conversations', 'Name' => 'Private Conversations', 'Description' => 'Learn how to start new private conversations and add people to them.', 'VideoID' => '31498383'), array('Code' => 'user-profiles', 'Name' => 'User Profiles', 'Description' => 'Learn how to use and manage your user profile. ', 'VideoID' => '31499266'), array('Code' => 'appearance', 'Name' => 'Changing the appearance of your forum', 'Description' => 'This tutorial takes you through the "Appearance" section of the Vanilla Forums administrative dashboard.', 'VideoID' => '31089641'), array('Code' => 'roles-and-permissions', 'Name' => 'Managing Roles and Permissions in Vanilla', 'Description' => 'This tutorial walks you through how to create new roles and how to use permissions.', 'VideoID' => '31091056'), array('Code' => 'users', 'Name' => 'Finding & Managing Users', 'Description' => 'This tutorial shows you how to search for and manage users.', 'VideoID' => '31094514'), array('Code' => 'category-management-and-advanced-settings', 'Name' => 'Category Management & Advanced Settings', 'Description' => 'Learn how to add, edit, and manage categories. Also learn about advanced forum settings.', 'VideoID' => '31492046'), array('Code' => 'user-registration', 'Name' => 'User Registration', 'Description' => 'Learn to control how new users get into your community.', 'VideoID' => '31493119')); // Default Thumbnails $Thumbnail = Asset('applications/dashboard/design/images/help-tn-200.jpg'); $LargeThumbnail = Asset('applications/dashboard/design/images/help-tn-640.jpg'); for ($i = 0; $i < count($Tutorials); $i++) { $Tutorials[$i]['Thumbnail'] = $Thumbnail; $Tutorials[$i]['LargeThumbnail'] = $LargeThumbnail; } if ($TutorialCode != '') { $Keys = consolidateArrayValuesByKey($Tutorials, 'Code'); $Index = array_search($TutorialCode, $Keys); if ($Index === FALSE) { return FALSE; } // Not found! // Found it, so define it's thumbnail location $Tutorial = val($Index, $Tutorials); $VideoID = val('VideoID', $Tutorial); try { $videoInfo = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$Tutorial['VideoID']}.json")); if ($videoInfo && ($vimeo = array_shift($videoInfo))) { $Tutorial['Thumbnail'] = str_replace('http://', '//', val('thumbnail_medium', $vimeo)); $Tutorial['LargeThumbnail'] = str_replace('http://', '//', val('thumbnail_large', $vimeo)); } } catch (Exception $Ex) { // Do nothing } return $Tutorial; } else { // Loop through each tutorial populating the thumbnail image location try { foreach ($Tutorials as $Key => &$Tutorial) { $videoInfo = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$Tutorial['VideoID']}.json")); if ($videoInfo && ($vimeo = array_shift($videoInfo))) { $Tutorial['Thumbnail'] = str_replace('http://', '//', val('thumbnail_medium', $vimeo)); $Tutorial['LargeThumbnail'] = str_replace('http://', '//', val('thumbnail_large', $vimeo)); } } } catch (Exception $Ex) { // Do nothing } return $Tutorials; } }
function writeConnection($Row) { $c = Gdn::controller(); $Connected = val('Connected', $Row); ?> <li id="<?php echo "Provider_{$Row['ProviderKey']}"; ?> " class="Item"> <div class="Connection-Header"> <span class="IconWrap"> <?php echo img(val('Icon', $Row, Asset('/applications/dashboard/design/images/connection-64.png'))); ?> </span> <span class="Connection-Name"> <?php echo val('Name', $Row, t('Unknown')); if ($Connected) { echo ' <span class="Gloss Connected">'; if ($Photo = valr('Profile.Photo', $Row)) { echo ' ' . Img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall')); } echo ' ' . htmlspecialchars(GetValueR('Profile.Name', $Row)) . '</span>'; } ?> </span> <span class="Connection-Connect"> <?php echo ConnectButton($Row); ?> </span> </div> <!-- <div class="Connection-Body"> <?php // if (Debug()) { // decho(val($Row['ProviderKey'], $c->User->Attributes), 'Attributes'); // } ?> </div>--> </li> <?php }
/** * Override the default UserBuilder function with one that switches the photo * out with a gravatar url if the photo is empty. */ function UserBuilder($Object, $UserPrefix = '') { $Object = (object)$Object; $User = new stdClass(); $UserID = $UserPrefix.'UserID'; $Name = $UserPrefix.'Name'; $Photo = $UserPrefix.'Photo'; $Email = $UserPrefix.'Email'; $User->UserID = $Object->$UserID; $User->Name = $Object->$Name; $User->Photo = property_exists($Object, $Photo) ? $Object->$Photo : ''; $Protocol = (strlen(GetValue('HTTPS', $_SERVER, 'No')) != 'No' || GetValue('SERVER_PORT', $_SERVER) == 443) ? 'https://secure.' : 'http://www.'; if ($User->Photo == '' && property_exists($Object, $Email)) { $User->Photo = $Protocol.'gravatar.com/avatar.php?' .'gravatar_id='.md5(strtolower($Object->$Email)) .'&default='.urlencode(Asset(Gdn::Config('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)) .'&size='.Gdn::Config('Garden.Thumbnail.Width', 40); } return $User; }
/** * Setup some variables for instance. */ public function __construct() { parent::__construct(); $this->mediaCache = null; $this->mediaCacheExpire = 60 * 60 * 6; $this->AssetPath = Asset('/plugins/editor'); $this->pluginInfo = Gdn::pluginManager()->getPluginInfo('editor', Gdn_PluginManager::ACCESS_PLUGINNAME); $this->ForceWysiwyg = c('Plugins.editor.ForceWysiwyg', false); // Check upload permissions $this->canUpload = Gdn::session()->checkPermission('Plugins.Attachments.Upload.Allow', false); if ($this->canUpload) { $PermissionCategory = CategoryModel::permissionCategory(Gdn::controller()->data('Category')); if (!val('AllowFileUploads', $PermissionCategory, true)) { $this->canUpload = false; } } // Check against config, too if (!c('Garden.AllowFileUploads', false)) { $this->canUpload = false; } }
public function sendMail($email, $name, $token, $id) { $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->From = '*****@*****.**'; $mail->FromName = 'Reset Password'; $mail->addAddress($email, $name); $mail->isHTML(true); $mail->Subject = 'Reset Password!'; //tao noi dung mail $mail->Body = 'Click <a href="' . asset('/password') . "/" . $token . "/" . $id . '">here resetpassword </a> Or copy link <b> ' . Asset('/password') . "/" . $token . "/" . $id . '</b> to URL Browser. </br> '; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if ($mail->send()) { return true; } else { return false; } }
/** * * * @param $Path * @param $Controller */ public function init($Path, $Controller) { $Smarty = $this->smarty(); // Get a friendly name for the controller. $ControllerName = get_class($Controller); if (StringEndsWith($ControllerName, 'Controller', true)) { $ControllerName = substr($ControllerName, 0, -10); } // Get an ID for the body. $BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod))); $Smarty->assign('BodyID', $BodyIdentifier); //$Smarty->assign('Config', Gdn::Config()); // Assign some information about the user. $Session = Gdn::session(); if ($Session->isValid()) { $User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true); $Photo = $Session->User->Photo; if ($Photo) { if (!IsUrl($Photo)) { $Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s')); } } else { if (function_exists('UserPhotoDefaultUrl')) { $Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto'); } elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) { $Photo = Gdn_Upload::url($ConfigPhoto); } else { $Photo = Asset('/applications/dashboard/design/images/defaulticon.png', true); } } $User['Photo'] = $Photo; } else { $User = false; /*array( 'Name' => '', 'CountNotifications' => 0, 'SignedIn' => FALSE);*/ } $Smarty->assign('User', $User); // Make sure that any datasets use arrays instead of objects. foreach ($Controller->Data as $Key => $Value) { if ($Value instanceof Gdn_DataSet) { $Controller->Data[$Key] = $Value->resultArray(); } elseif ($Value instanceof stdClass) { $Controller->Data[$Key] = (array) $Value; } } $BodyClass = val('CssClass', $Controller->Data, '', true); $Sections = Gdn_Theme::section(null, 'get'); if (is_array($Sections)) { foreach ($Sections as $Section) { $BodyClass .= ' Section-' . $Section; } } $Controller->Data['BodyClass'] = $BodyClass; // Set the current locale for themes to take advantage of. $Locale = Gdn::locale()->Locale; $CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', $Locale)); if (class_exists('Locale')) { $CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale); $CurrentLocale['Region'] = Locale::getRegion($Locale); $CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale); $CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale); $CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale); } $Smarty->assign('CurrentLocale', $CurrentLocale); $Smarty->assign('Assets', (array) $Controller->Assets); $Smarty->assign('Path', Gdn::request()->path()); // Assign the controller data last so the controllers override any default data. $Smarty->assign($Controller->Data); $Smarty->Controller = $Controller; // for smarty plugins $Smarty->security = true; $Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('Category', 'CheckPermission', 'InSection', 'InCategory', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url')); $Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf')); $Smarty->secure_dir = array($Path); }
<form action="<?php echo Asset('test'); ?> "method="post"> <table> <tr> câu hỏi bạn chọn là: <input type="text" name ="question" id="question"/></br> <tr> <input type="submit" value ="submit" name="submit"/> </tr> </br> </table> </form>
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Fatal Error</title> <meta name="robots" content="noindex"/> <?php if ($CssPath !== FALSE) { echo '<link rel="stylesheet" type="text/css" href="', Asset($CssPath), '" />'; } ?> </head> <body> <div id="Frame"> <h1>Fatal Error in <?php echo $SenderObject, '.', $SenderMethod; ?> ();</h1> <div id="Content"> <h2><?php echo $SenderMessage; ?> </h2> <?php if ($SenderCode != '') { echo '<code>', htmlentities($SenderCode, ENT_COMPAT, 'UTF-8'), "</code>\n"; }
/** * Undocumented method. * * @todo Method RenderMaster() needs a description. */ public function RenderMaster() { // Build the master view if necessary if (in_array($this->_DeliveryType, array(DELIVERY_TYPE_ALL))) { $this->MasterView = $this->MasterView(); // Only get css & ui components if this is NOT a syndication request if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) { if (ArrayHasValue($this->_CssFiles, 'style.css')) { $this->AddCssFile('custom.css'); } if (ArrayHasValue($this->_CssFiles, 'admin.css')) { $this->AddCssFile('customadmin.css'); } $this->EventArguments['CssFiles'] =& $this->_CssFiles; $this->FireEvent('BeforeAddCss'); // And now search for/add all css files foreach ($this->_CssFiles as $CssInfo) { $CssFile = $CssInfo['FileName']; if (strpos($CssFile, '/') !== FALSE) { // A direct path to the file was given. $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile)))); } else { $CssGlob = preg_replace('/(.*)(\\.css)/', '\\1*\\2', $CssFile); $AppFolder = $CssInfo['AppFolder']; if ($AppFolder == '') { $AppFolder = $this->ApplicationFolder; } // CSS comes from one of four places: $CssPaths = array(); if ($this->Theme) { // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/ // $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob; // 2. Theme-wide theme view. eg. root/themes/theme_name/design/ // a) Check to see if a customized version of the css is there. if ($this->ThemeOptions) { $Filenames = GetValueR('Styles.Value', $this->ThemeOptions); if (is_string($Filenames) && $Filenames != '%s') { $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . ChangeBasename($CssFile, $Filenames); } } // b) Use the default filename. $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile; } // 3. Application or plugin. if (StringBeginsWith($AppFolder, 'plugins/')) { // The css is coming from a plugin. $AppFolder = substr($AppFolder, strlen('plugins/')); $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/design/{$CssFile}"; $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/{$CssFile}"; } else { // Application default. eg. root/applications/app_name/design/ $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile; } // 4. Garden default. eg. root/applications/dashboard/design/ $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile; } // Find the first file that matches the path. $CssPath = FALSE; foreach ($CssPaths as $Glob) { $Paths = SafeGlob($Glob); if (is_array($Paths) && count($Paths) > 0) { $CssPath = $Paths[0]; break; } } // Check to see if there is a CSS cacher. $CssCacher = Gdn::Factory('CssCacher'); if (!is_null($CssCacher)) { $CssPath = $CssCacher->Get($CssPath, $AppFolder); } if ($CssPath !== FALSE) { $CssPath = substr($CssPath, strlen(PATH_ROOT)); $CssPath = str_replace(DS, '/', $CssPath); $this->Head->AddCss($CssPath, 'all', TRUE, $CssInfo['Options']); } } // Add a custom js file. if (ArrayHasValue($this->_CssFiles, 'style.css')) { $this->AddJsFile('custom.js'); } // only to non-admin pages. // And now search for/add all JS files foreach ($this->_JsFiles as $Index => $JsInfo) { $JsFile = $JsInfo['FileName']; if (strpos($JsFile, '//') !== FALSE) { // This is a link to an external file. $this->Head->AddScript($JsFile); continue; } if (strpos($JsFile, '/') !== FALSE) { // A direct path to the file was given. $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS)); } else { $AppFolder = $JsInfo['AppFolder']; if ($AppFolder == '') { $AppFolder = $this->ApplicationFolder; } // JS can come from a theme, an any of the application folder, or it can come from the global js folder: $JsPaths = array(); if ($this->Theme) { // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/ $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile; // 2. Garden-wide theme view. eg. root/themes/theme_name/design/ $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'js' . DS . $JsFile; } // 3. The application or plugin folder. if (StringBeginsWith(trim($AppFolder, '/'), 'plugins/')) { $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/js/{$JsFile}"; $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/{$JsFile}"; } else { $JsPaths[] = PATH_APPLICATIONS . "/{$AppFolder}/js/{$JsFile}"; } // 4. Global JS folder. eg. root/js/ $JsPaths[] = PATH_ROOT . DS . 'js' . DS . $JsFile; // 5. Global JS library folder. eg. root/js/library/ $JsPaths[] = PATH_ROOT . DS . 'js' . DS . 'library' . DS . $JsFile; } // Find the first file that matches the path. $JsPath = FALSE; foreach ($JsPaths as $Glob) { $Paths = SafeGlob($Glob); if (is_array($Paths) && count($Paths) > 0) { $JsPath = $Paths[0]; break; } } if ($JsPath !== FALSE) { $JsSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $JsPath); $Options = (array) $JsInfo['Options']; $Options['path'] = $JsPath; $Version = GetValue('Version', $JsInfo); if ($Version) { TouchValue('version', $Options, $Version); } $this->Head->AddScript($JsSrc, 'text/javascript', $Options); } } } // Add the favicon $this->Head->SetFavIcon(C('Garden.FavIcon', Asset('themes/' . $this->Theme . '/design/favicon.png'))); // Make sure the head module gets passed into the assets collection. $this->AddModule('Head'); } // Master views come from one of four places: $MasterViewPaths = array(); if (strpos($this->MasterView, '/') !== FALSE) { $MasterViewPaths[] = CombinePaths(array(PATH_ROOT, str_replace('/', DS, $this->MasterView) . '.master*')); } else { if ($this->Theme) { // 1. Application-specific theme view. eg. root/themes/theme_name/app_name/views/ $MasterViewPaths[] = CombinePaths(array(PATH_THEMES, $this->Theme, $this->ApplicationFolder, 'views', $this->MasterView . '.master*')); // 2. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/ $MasterViewPaths[] = CombinePaths(array(PATH_THEMES, $this->Theme, 'views', $this->MasterView . '.master*')); } // 3. Application default. eg. root/app_name/views/ $MasterViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, $this->ApplicationFolder, 'views', $this->MasterView . '.master*')); // 4. Garden default. eg. root/dashboard/views/ $MasterViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', $this->MasterView . '.master*')); } // Find the first file that matches the path. $MasterViewPath = FALSE; foreach ($MasterViewPaths as $Glob) { $Paths = SafeGlob($Glob); if (is_array($Paths) && count($Paths) > 0) { $MasterViewPath = $Paths[0]; break; } } $this->EventArguments['MasterViewPath'] =& $MasterViewPath; $this->FireEvent('BeforeFetchMaster'); if ($MasterViewPath === FALSE) { trigger_error(ErrorMessage("Could not find master view: {$this->MasterView}.master*", $this->ClassName, '_FetchController'), E_USER_ERROR); } /// A unique identifier that can be used in the body tag of the master view if needed. $ControllerName = $this->ClassName; // Strip "Controller" from the body identifier. if (substr($ControllerName, -10) == 'Controller') { $ControllerName = substr($ControllerName, 0, -10); } // Strip "Gdn_" from the body identifier. if (substr($ControllerName, 0, 4) == 'Gdn_') { $ControllerName = substr($ControllerName, 4); } $this->SetData('CssClass', $this->Application . ' ' . $ControllerName . ' ' . $this->RequestMethod . ' ' . $this->CssClass, TRUE); // Check to see if there is a handler for this particular extension. $ViewHandler = Gdn::Factory('ViewHandler' . strtolower(strrchr($MasterViewPath, '.'))); if (is_null($ViewHandler)) { $BodyIdentifier = strtolower($this->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::AlphaNumeric(strtolower($this->RequestMethod))); include $MasterViewPath; } else { $ViewHandler->Render($MasterViewPath, $this); } }
/** * Generic save procedure. */ public function Save($FormPostValues, $Settings = FALSE) { // See if the user's related roles should be saved or not. $SaveRoles = ArrayValue('SaveRoles', $Settings); // Define the primary key in this model's table. $this->DefineSchema(); // Add & apply any extra validation rules: if (array_key_exists('Email', $FormPostValues)) { $this->Validation->ApplyRule('Email', 'Email'); } // Custom Rule: This will make sure that at least one role was selected if saving roles for this user. if ($SaveRoles) { $this->Validation->AddRule('OneOrMoreArrayItemRequired', 'function:ValidateOneOrMoreArrayItemRequired'); // $this->Validation->AddValidationField('RoleID', $FormPostValues); $this->Validation->ApplyRule('RoleID', 'OneOrMoreArrayItemRequired'); } // Make sure that the checkbox val for email is saved as the appropriate enum if (array_key_exists('ShowEmail', $FormPostValues)) { $FormPostValues['ShowEmail'] = ForceBool($FormPostValues['ShowEmail'], '0', '1', '0'); } // Validate the form posted values $UserID = ArrayValue('UserID', $FormPostValues); $Insert = $UserID > 0 ? FALSE : TRUE; if ($Insert) { $this->AddInsertFields($FormPostValues); } else { $this->AddUpdateFields($FormPostValues); } $this->EventArguments['FormPostValues'] = $FormPostValues; $this->FireEvent('BeforeSaveValidation'); $RecordRoleChange = TRUE; if ($this->Validate($FormPostValues, $Insert) === TRUE) { $Fields = $this->Validation->ValidationFields(); // All fields on the form that need to be validated (including non-schema field rules defined above) $RoleIDs = ArrayValue('RoleID', $Fields, 0); $Username = ArrayValue('Name', $Fields); $Email = ArrayValue('Email', $Fields); $Fields = $this->Validation->SchemaValidationFields(); // Only fields that are present in the schema // Remove the primary key from the fields collection before saving $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey); // Make sure to encrypt the password for saving... if (array_key_exists('Password', $Fields)) { $PasswordHash = new Gdn_PasswordHash(); $Fields['Password'] = $PasswordHash->HashPassword($Fields['Password']); } $this->EventArguments['Fields'] = $Fields; $this->FireEvent('BeforeSave'); // Check the validation results again in case something was added during the BeforeSave event. if (count($this->Validation->Results()) == 0) { // If the primary key exists in the validated fields and it is a // numeric value greater than zero, update the related database row. if ($UserID > 0) { // If they are changing the username & email, make sure they aren't // already being used (by someone other than this user) if (ArrayValue('Name', $Fields, '') != '' || ArrayValue('Email', $Fields, '') != '') { if (!$this->ValidateUniqueFields($Username, $Email, $UserID)) { return FALSE; } } $this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $UserID)); // Record activity if the person changed his/her photo $Photo = ArrayValue('Photo', $FormPostValues); if ($Photo !== FALSE) { AddActivity($UserID, 'PictureChange', '<img src="' . Asset('uploads/' . ChangeBasename($Photo, 't%s')) . '" alt="' . T('Thumbnail') . '" />'); } } else { $RecordRoleChange = FALSE; if (!$this->ValidateUniqueFields($Username, $Email)) { return FALSE; } // Define the other required fields: $Fields['Email'] = $Email; // And insert the new user $UserID = $this->_Insert($Fields); // Make sure that the user is assigned to one or more roles: $SaveRoles = TRUE; // Report that the user was created $Session = Gdn::Session(); AddActivity($UserID, 'JoinCreated', T('Welcome Aboard!'), $Session->UserID > 0 ? $Session->UserID : ''); } // Now update the role settings if necessary if ($SaveRoles) { // If no RoleIDs were provided, use the system defaults if (!is_array($RoleIDs)) { $RoleIDs = Gdn::Config('Garden.Registration.DefaultRoles'); } $this->SaveRoles($UserID, $RoleIDs, $RecordRoleChange); } $this->EventArguments['UserID'] = $UserID; $this->FireEvent('AfterSave'); } else { $UserID = FALSE; } } else { $UserID = FALSE; } return $UserID; }
/** * Returns the url prefix for a given type. * If there is a plugin that wants to store uploads at a different location or in a different way then they register themselves by subscribing to the Gdn_Upload_GetUrls_Handler event. * After that they will be available here. * * @param string $Type The type of upload to get the prefix for. * @return string The url prefix. */ public static function Urls($Type = NULL) { static $Urls = NULL; if ($Urls === NULL) { $Urls = array('' => Asset('/uploads', TRUE)); $Sender = new stdClass(); $Sender->Returns = array(); $Sender->EventArguments = array(); $Sender->EventArguments['Urls'] =& $Urls; Gdn::PluginManager()->CallEventHandlers($Sender, 'Gdn_Upload', 'GetUrls'); } if ($Type === NULL) { return $Urls; } if (isset($Urls[$Type])) { return $Urls[$Type]; } return FALSE; }
private function _GetButton() { $ImgSrc = Asset('/plugins/SinaConnect/design/weibo-signin.png'); $ImgAlt = T('Sign In with Sina'); $SigninHref = $this->_AuthorizeHref(); $PopupSigninHref = $this->_AuthorizeHref(TRUE); return "<a id=\"SinaAuth\" href=\"{$SigninHref}\" class=\"PopupWindow\" title=\"{$ImgAlt}\" popupHref=\"{$PopupSigninHref}\" popupHeight=\"400\" popupWidth=\"800\" ><img src=\"{$ImgSrc}\" alt=\"{$ImgAlt}\" /></a>"; }
</em></div> <div class="rateit" data-rateit-value="<?php echo $showreview->ratting; ?> " data-rateit-ispreset="true" data-rateit-readonly="true"></div> </div> <div class="text-info"> <h5><p><?php echo $showreview->content; ?> </p></h5> <?php if (isset(Auth::user()->role_id)) { if (Auth::user()->role_id == 1) { echo "<a href='" . Asset('del-review') . "/" . $showreview->id . "'>Xóa bình luận</a>"; } } else { echo ""; } ?> </div> </div> @endforeach <!-- BEGIN FORM--> <?php echo Form::open(array('url' => URL::to('review-product/' . $product['id'] . '/1.html'))); ?>
public static function Image($Url, $Attributes = '') { return '<img src="' . Asset($Url) . '"' . Attribute($Attributes) . ' />'; }
public function IndexSearchPath($SearchPath, &$ThemeInfo, $PathListing = NULL) { if (is_null($PathListing) || !is_array($PathListing)) { $PathListing = scandir($SearchPath, 0); sort($PathListing); } if ($PathListing === FALSE) { return FALSE; } foreach ($PathListing as $ThemeFolderName) { if (substr($ThemeFolderName, 0, 1) == '.') { continue; } $ThemePath = CombinePaths(array($SearchPath, $ThemeFolderName)); $ThemeFiles = $this->FindThemeFiles($ThemePath); if (GetValue('about', $ThemeFiles) === FALSE) { continue; } $ThemeAboutFile = GetValue('about', $ThemeFiles); $SearchThemeInfo = $this->ScanThemeFile($ThemeAboutFile); // Don't index archived themes. // if (GetValue('Archived', $SearchThemeInfo, FALSE)) // continue; // Add the screenshot. if (array_key_exists('screenshot', $ThemeFiles)) { $RelativeScreenshot = ltrim(str_replace(PATH_ROOT, '', GetValue('screenshot', $ThemeFiles)), '/'); $SearchThemeInfo['ScreenshotUrl'] = Asset($RelativeScreenshot, TRUE); } // Add the mobile screenshot. if (array_key_exists('mobilescreenshot', $ThemeFiles)) { $RelativeScreenshot = ltrim(str_replace(PATH_ROOT, '', GetValue('mobilescreenshot', $ThemeFiles)), '/'); $SearchThemeInfo['MobileScreenshotUrl'] = Asset($RelativeScreenshot, TRUE); } if (array_key_exists('hooks', $ThemeFiles)) { $SearchThemeInfo['HooksFile'] = GetValue('hooks', $ThemeFiles, FALSE); $SearchThemeInfo['RealHooksFile'] = realpath($SearchThemeInfo['HooksFile']); } if ($SearchThemeInfo === FALSE) { continue; } $ThemeInfo[$ThemeFolderName] = $SearchThemeInfo; } return md5(serialize($PathListing)); }
function FlashHtml($Movie, $Attributes = array(), $Params = array(), $FlashVars = False) { static $DefaultAttributes = array('width' => 400, 'height' => 300, 'type' => 'application/x-shockwave-flash'); static $DefaultParams = array('allowfullscreen' => 'true', 'allowscriptaccess' => 'always', 'quality' => 'best', 'menu' => 'false'); // BUG: 'wmode' => 'transparent' $ScriptRender = GetValue('ScriptRender', $Attributes, False, True); if (!is_array($Params)) { $Params = array(); } $Params = array_merge($DefaultParams, $Params); $Movie = Asset($Movie, True); // check size if (!array_key_exists('width', $Attributes) || !array_key_exists('height', $Attributes)) { $ImageInfo = GetImageSize($Movie); if ($ImageInfo != False) { $Attributes['width'] = $ImageInfo[0]; $Attributes['height'] = $ImageInfo[1]; } } $Attributes = array_merge($DefaultAttributes, $Attributes); $FlashVars = GetValue('FlashVars', $Attributes, $FlashVars, True); if ($FlashVars != False) { $FlashVars = Gdn_Format::ObjectAsArray($FlashVars); $Vars = array(); foreach ($FlashVars as $Name => $Value) { $Vars[] = $Name . '=' . $Value; } // encodeuricomponent $Params['flashvars'] = implode('&', $Vars); } $MSIE = strpos(ArrayValue('HTTP_USER_AGENT', $_SERVER), 'MSIE') > 0; if ($MSIE != False) { $Mode = GetValue('wmode', $Attributes, False, True); if ($Mode !== False) { $Params['wmode'] = $Mode; } $Params['movie'] = $Movie; $ObjectParams = ''; foreach ($Params as $Name => $Value) { $ObjectParams .= '<param name="' . $Name . '" value="' . $Value . '" />'; } // TODO: ADD CLASSID FOR IE $Result = '<object' . Attribute($Attributes) . '>' . $ObjectParams . '</object>'; } else { $Attributes['src'] = $Movie; $Attributes = array_merge($Attributes, $Params); $Result = '<embed' . Attribute($Attributes) . ' />'; } if ($ScriptRender) { $Result = JavaScript($Result, True); } // detect flash version you should manually return $Result; }
/** * */ protected function __construct() { // Initialize the canonical list. (emoji) $this->emoji = array('smile' => 'smile.png', 'smiley' => 'smiley.png', 'wink' => 'wink.png', 'blush' => 'blush.png', 'neutral' => 'neutral.png', 'relaxed' => 'relaxed.png', 'grin' => 'grin.png', 'joy' => 'joy.png', 'sweat_smile' => 'sweat_smile.png', 'lol' => 'lol.png', 'innocent' => 'innocent.png', 'naughty' => 'naughty.png', 'yum' => 'yum.png', 'relieved' => 'relieved.png', 'love' => 'love.png', 'sunglasses' => 'sunglasses.png', 'smirk' => 'smirk.png', 'expressionless' => 'expressionless.png', 'unamused' => 'unamused.png', 'sweat' => 'sweat.png', 'pensive' => 'pensive.png', 'confused' => 'confused.png', 'confounded' => 'confounded.png', 'kissing' => 'kissing.png', 'kissing_heart' => 'kissing_heart.png', 'kissing_smiling_eyes' => 'kissing_smiling_eyes.png', 'kissing_closed_eyes' => 'kissing_closed_eyes.png', 'tongue' => 'tongue.png', 'disappointed' => 'disappointed.png', 'worried' => 'worried.png', 'angry' => 'angry.png', 'rage' => 'rage.png', 'cry' => 'cry.png', 'persevere' => 'persevere.png', 'triumph' => 'triumph.png', 'frowning' => 'frowning.png', 'anguished' => 'anguished.png', 'fearful' => 'fearful.png', 'weary' => 'weary.png', 'sleepy' => 'sleepy.png', 'tired_face' => 'tired_face.png', 'grimace' => 'grimace.png', 'bawling' => 'bawling.png', 'open_mouth' => 'open_mouth.png', 'hushed' => 'hushed.png', 'cold_sweat' => 'cold_sweat.png', 'scream' => 'scream.png', 'astonished' => 'astonished.png', 'flushed' => 'flushed.png', 'sleeping' => 'sleeping.png', 'dizzy' => 'dizzy.png', 'no_mouth' => 'no_mouth.png', 'mask' => 'mask.png', 'star' => 'star.png', 'cookie' => 'cookie.png', 'warning' => 'warning.png', 'mrgreen' => 'mrgreen.png', 'heart' => 'heart.png', 'heartbreak' => 'heartbreak.png', 'kiss' => 'kiss.png', '+1' => '+1.png', '-1' => '-1.png', 'grey_question' => 'grey_question.png', 'trollface' => 'trollface.png'); // Some aliases self-referencing the canonical list. Use this syntax. // This is used in cases where emoji image cannot be found. $this->emoji['error'] =& $this->emoji['grey_question']; // Initialize the alias list. (emoticons) $this->aliases = array(':)' => 'smile', ':D' => 'lol', '=)' => 'smiley', ':(' => 'frowning', ';)' => 'wink', ':\\' => 'confused', ':/' => 'confused', ':o' => 'open_mouth', ':s' => 'confounded', ':p' => 'stuck_out_tongue', ":'(" => 'cry', ':|' => 'neutral', 'D:' => 'anguished', 'B)' => 'sunglasses', ':#' => 'grimace', ':*' => 'kiss', ':3' => 'blush', 'o:)' => 'innocent', '<3' => 'heart', '>:)' => 'naughty'); $this->archive = array('disappointed_relieved' => 'disappointed_relieved.png', 'dizzy_face' => 'dizzy.png', 'broken_heart' => 'heartbreak.png', 'grinning' => 'grin.png', 'heart_eyes' => 'love.png', 'neutral_face' => 'neutral.png', 'smiling_imp' => 'naughty.png', 'sob' => 'bawling.png', 'stuck_out_tongue' => 'tongue.png', 'stuck_out_tongue_winking_eye' => 'stuck_out_tongue_winking_eye.png', 'stuck_out_tongue_closed_eyes' => 'stuck_out_tongue_closed_eyes.png'); $this->editorList = array(':)' => 'smile', ':D' => 'lol', ':(' => 'disappointed', ';)' => 'wink', ':/' => 'confused', ':o' => 'open_mouth', ':s' => 'confounded', ':p' => 'stuck_out_tongue', ":'(" => 'cry', ':|' => 'neutral', 'B)' => 'sunglasses', ':#' => 'grimace', ':*' => 'kiss', '<3' => 'heart', 'o:)' => 'innocent', '>:)' => 'naughty'); if (C('Garden.EmojiSet') === 'none') { $this->enabled = false; } Gdn::pluginManager()->callEventHandlers($this, 'Emoji', 'Init', 'Handler'); // Add emoji to definition list for whole site. This used to be in the // advanced editor plugin, but since moving atmentions to core, had to // make sure they were still being added. This will make sure that // emoji autosuggest works. Note: emoji will not be core yet, so the only // way that this gets called is by the editor when it instantiates. Core // does not instantiate this class anywhere, so there will not be any // suggestions for emoji yet, but keep here for whenever Advanced Editor // is running. $c = Gdn::controller(); if ($c && $this->enabled) { $emojis = $this->getEmoji(); $emojiAssetPath = $this->getAssetPath(); $emoji = array(); foreach ($emojis as $name => $data) { $emoji[] = array("name" => "" . $name . "", "url" => Asset($emojiAssetPath . '/' . $data)); } $emoji = array('assetPath' => Asset($this->getAssetPath()), 'format' => $this->getFormat(), 'emoji' => $this->getEmoji()); $c->addDefinition('emoji', $emoji); } }