当前位置: 首页>>代码示例>>PHP>>正文


PHP val函数代码示例

本文整理汇总了PHP中val函数的典型用法代码示例。如果您正苦于以下问题:PHP val函数的具体用法?PHP val怎么用?PHP val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_link

/**
 * Takes a route and prepends the web root (expects "/controller/action/params" as $Path).
 *
 * @param array $Params 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 $Smarty The smarty object rendering the template.
 * @return The url.
 */
function smarty_function_link($Params, &$Smarty)
{
    $Path = val('path', $Params, '', true);
    $Text = val('text', $Params, '', true);
    $NoTag = val('notag', $Params, false, true);
    $CustomFormat = val('format', $Params, false, true);
    if (!$Text && $Path != 'signinout' && $Path != 'signin') {
        $NoTag = true;
    }
    if ($CustomFormat) {
        $Format = $CustomFormat;
    } elseif ($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;
}
开发者ID:caidongyun,项目名称:vanilla,代码行数:45,代码来源:function.link.php

示例2: Gdn_Dispatcher_beforeDispatch_handler

 /**
  * Map an API request to a resource
  *
  * @since  0.1.0
  * @access public
  * @param  Gdn_Dispatcher $sender
  * @return void
  */
 public function Gdn_Dispatcher_beforeDispatch_handler($sender)
 {
     $path = APIEngine::getRequestURI();
     // Set the call and resource paths if they exist
     $call = val(0, $path);
     $resource = val(1, $path);
     // Abandon the dispatch if this isn't an API call with a valid resource
     if ($call != "api" || !$resource) {
         return;
     }
     APIEngine::setRequestHeaders();
     try {
         // Mark the dispatch with the API version
         $sender->API = c("API.Version", "Undefined");
         // Attempt dispatching the API request
         APIEngine::dispatchRequest();
     } catch (Exception $exception) {
         // As we can"t pass an object to WithControllerMethod(), we extract
         // the values we need manually before passing them on. The exception
         // message is Base64 encoded as WithControllerMethod() mangles
         // the formatting.
         $code = $exception->getCode();
         $message = base64_encode($exception->getMessage());
         $arguments = [$code, $message];
         // Call the Exception method if an exception is thrown
         Gdn::request()->withControllerMethod("API", "Exception", $arguments);
     }
 }
开发者ID:hcxiong,项目名称:vanilla-api,代码行数:36,代码来源:class.hooks.php

示例3: smarty_function_signin_link

/**
 *
 *
 * @param array $Params
 * @param object $Smarty
 * @return string
 */
function smarty_function_signin_link($Params, &$Smarty)
{
    if (!Gdn::session()->isValid()) {
        $Wrap = val('wrap', $Params, 'li');
        return Gdn_Theme::link('signinout', val('text', $Params, ''), val('format', $Params, wrap('<a href="%url" rel="nofollow" class="%class">%text</a>', $Wrap)), $Params);
    }
}
开发者ID:sitexa,项目名称:vanilla,代码行数:14,代码来源:function.signin_link.php

示例4: authenticateRequest

 /**
  * Token-based, per-request authentication
  *
  * This method takes the entire request string and turns the query into an
  * array of data. It then uses all the data to generate a signature the same
  * way it got generated on the client. If the server signature and client
  * token match, the client is considered legimate and the request is served.
  *
  * Based on initial work by Diego Zanella
  * @link http://careers.stackoverflow.com/diegozanella
  *
  * @since  0.1.0
  * @access public
  * @throws Exception
  * @return void
  * @static
  */
 public static function authenticateRequest()
 {
     $username = getIncomingValue("username");
     $email = getIncomingValue("email");
     if (!$username && !$email) {
         throw new Exception(t("API.Error.User.Missing"), 401);
     }
     if (!($userID = static::getUserID($username, $email))) {
         throw new Exception(t("API.Error.User.Invalid"), 401);
     }
     if (!($timestamp = getIncomingValue("timestamp"))) {
         throw new Exception(t("API.Error.Timestamp.Missing"), 401);
     }
     // Make sure that request is still valid
     if (abs($timestamp - time()) > c("API.Expiration")) {
         throw new Exception(t("API.Error.Timestamp.Invalid"), 401);
     }
     if (!($token = getIncomingValue("token"))) {
         throw new Exception(t("API.Error.Token.Missing"), 401);
     }
     $parsedUrl = parse_url(Gdn::request()->pathAndQuery());
     // Turn the request query data into an array to be used in the token
     // generation
     parse_str(val("query", $parsedUrl, []), $data);
     // Unset the values we don't want to include in the token generation
     unset($data["token"], $data["DeliveryType"], $data["DeliveryMethod"]);
     if ($token != ($signature = static::generateSignature($data))) {
         throw new Exception(t("API.Error.Token.Invalid"), 401);
     }
     // Now that the client has been thoroughly verified, start a session for
     // the duration of the request using the User ID specified earlier
     if ($token == $signature) {
         Gdn::session()->start(intval($userID), false);
     }
 }
开发者ID:hcxiong,项目名称:vanilla-api,代码行数:52,代码来源:class.apiauth.php

示例5: _checkTable

/**
 *
 *
 * @param $Data
 */
function _checkTable($Data)
{
    echo "<table class='Data' width='100%' style='table-layout: fixed;'>\n";
    echo "<thead><tr><td width='20%'>Field</td><td width='45%'>Current</td><td width='35%'>File</td></tr></thead>";
    $First = true;
    foreach ($Data as $Key => $Value) {
        if (stringBeginsWith($Key, 'File_') || is_array($Value) || $Key == 'Name') {
            continue;
        }
        $Value = Gdn_Format::html($Value);
        $FileValue = Gdn_Format::html(val('File_' . $Key, $Data));
        if ($Key == 'MD5') {
            $Value = substr($Value, 0, 10);
            $FileValue = substr($FileValue, 0, 10);
        }
        if ($Key == 'FileSize') {
            $Value = Gdn_Upload::FormatFileSize($Value);
        }
        echo "<tr><td>{$Key}</td><td>{$Value}</td>";
        if ($Error = val('File_Error', $Data)) {
            if ($First) {
                echo '<td rowspan="4">', htmlspecialchars($Error), '</td>';
            }
        } else {
            echo "<td>{$FileValue}</td></tr>";
        }
        echo "\n";
        $First = false;
    }
    echo '</table>';
}
开发者ID:vanilla,项目名称:community,代码行数:36,代码来源:check.php

示例6: register

 /**
  * Register API endpoints
  *
  * @since  0.1.0
  * @access public
  * @param  array $data
  * @return void
  * @static
  */
 public static function register($data)
 {
     static::get("/bans", ["controller" => "Settings", "method" => "bans", "arguments" => ["Page" => val("Page", $data)]]);
     static::post("/bans", ["controller" => "Settings", "method" => "bans", "arguments" => ["Action" => "add"]]);
     static::put("/bans/[i:ID]", ["controller" => "Settings", "method" => "bans", "arguments" => ["Action" => "edit"]]);
     static::delete("/bans/[i:ID]", ["controller" => "Settings", "method" => "bans", "arguments" => ["Action" => "delete"]]);
 }
开发者ID:hcxiong,项目名称:vanilla-api,代码行数:16,代码来源:class.moderationapi.php

示例7: userPhotoDefaultUrl

 /**
  * Calculate the user's default photo url.
  *
  * @param array|object $user The user to examine.
  * @param array $options An array of options.
  * - Size: The size of the photo.
  * @return string Returns the vanillicon url for the user.
  */
 function userPhotoDefaultUrl($user, $options = array())
 {
     static $iconSize = null, $type = null;
     if ($iconSize === null) {
         $thumbSize = c('Garden.Thumbnail.Size');
         $iconSize = $thumbSize <= 50 ? 50 : 100;
     }
     if ($type === null) {
         $type = c('Plugins.Vanillicon.Type');
     }
     $size = val('Size', $options, $iconSize);
     $email = val('Email', $user);
     if (!$email) {
         $email = val('UserID', $user, 100);
     }
     $hash = md5($email);
     $px = substr($hash, 0, 1);
     switch ($type) {
         case 'v2':
             $photoUrl = "//w{$px}.vanillicon.com/v2/{$hash}.svg";
             break;
         default:
             $photoUrl = "//w{$px}.vanillicon.com/{$hash}_{$size}.png";
             break;
     }
     return $photoUrl;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:35,代码来源:class.vanillicon.plugin.php

示例8: UserModel_AfterSave_Handler

 public function UserModel_AfterSave_Handler($Sender)
 {
     $FormValues = $Sender->EventArguments['FormPostValues'];
     $UserID = val('UserID', $FormValues, 0);
     $ThemeChooser = val('ThemeChooser', $FormValues, false);
     $this->SetUserMeta($UserID, 'Theme', $ThemeChooser);
 }
开发者ID:Nordic-T,项目名称:vanilla-ThemeChooser,代码行数:7,代码来源:class.themechooser.plugin.php

示例9: smarty_function_dashboard_link

/**
 *
 *
 * @param array $Params
 * @param object $Smarty
 * @return string
 */
function smarty_function_dashboard_link($Params, &$Smarty)
{
    $Path = val('path', $Params, '', true);
    $Text = val('text', $Params, '', true);
    $Wrap = val('wrap', $Params, 'li');
    return Gdn_Theme::link('dashboard', val('text', $Params, ''), val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', $Wrap)));
}
开发者ID:korelstar,项目名称:vanilla,代码行数:14,代码来源:function.dashboard_link.php

示例10: smarty_function_nomobile_link

/**
 *
 *
 * @param array $Params
 * @param object $Smarty
 * @return string
 */
function smarty_function_nomobile_link($Params, &$Smarty)
{
    $Path = val('path', $Params, '', true);
    $Text = val('text', $Params, '', true);
    $Wrap = val('wrap', $Params, 'li');
    return Gdn_Theme::link('profile/nomobile', val('text', $Params, t("Full Site")), val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', $Wrap)));
}
开发者ID:sitexa,项目名称:vanilla,代码行数:14,代码来源:function.nomobile_link.php

示例11: smarty_function_searchbox

/**
 * Writes the search box to the page.
 *
 * @param array The parameters passed into the function. This currently takes no parameters.
 * @param $smarty The smarty object rendering the template.
 * @return The url.
 */
function smarty_function_searchbox($params, &$smarty)
{
    $placeholder = array_key_exists('placeholder', $params) ? val('placeholder', $params, '', true) : t('SearchBoxPlaceHolder', 'Search');
    $form = Gdn::factory('Form');
    $result = $form->open(array('action' => url('/search'), 'method' => 'get')) . $form->textBox('Search', array('placeholder' => $placeholder, 'accesskey' => '/')) . $form->button('Go', array('Name' => '')) . $form->close();
    return $result;
}
开发者ID:korelstar,项目名称:vanilla,代码行数:14,代码来源:function.searchbox.php

示例12: writeConditionEdit

function writeConditionEdit($Condition, $Sender)
{
    $Px = $Sender->Prefix;
    $Form = new Gdn_Form();
    $Type = val(0, $Condition, '');
    $Field = val(1, $Condition, '');
    $Expr = val(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>';
}
开发者ID:caidongyun,项目名称:vanilla,代码行数:25,代码来源:condition.php

示例13: smarty_function_asset

/**
 * Renders an asset from the controller.
 *
 * @param array $Params 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 object $Smarty Smarty The smarty object rendering the template.
 * @return string The rendered asset.
 */
function smarty_function_asset($Params, &$Smarty)
{
    $Name = val('name', $Params);
    $Tag = val('tag', $Params, '');
    $Id = val('id', $Params, $Name);
    $Class = val('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 (val('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;
}
开发者ID:caidongyun,项目名称:vanilla,代码行数:45,代码来源:function.asset.php

示例14: delete

 /**
  * Delete a single draft.
  *
  * Redirects user back to Index unless DeliveryType is set.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DraftID Unique ID of draft to be deleted.
  * @param string $TransientKey Single-use hash to prove intent.
  */
 public function delete($DraftID = '', $TransientKey = '')
 {
     $Form = Gdn::factory('Form');
     $Session = Gdn::session();
     if (is_numeric($DraftID) && $DraftID > 0) {
         $Draft = $this->DraftModel->getID($DraftID);
     }
     if ($Draft) {
         if ($Session->validateTransientKey($TransientKey) && (val('InsertUserID', $Draft) == $Session->UserID || checkPermission('Garden.Community.Manage'))) {
             // Delete the draft
             if (!$this->DraftModel->deleteID($DraftID)) {
                 $Form->addError('Failed to delete draft');
             }
         } else {
             throw permissionException('Garden.Community.Manage');
         }
     } else {
         throw notFoundException('Draft');
     }
     // Redirect
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/drafts');
         redirect($Target);
     }
     // Return any errors
     if ($Form->errorCount() > 0) {
         $this->setJson('ErrorMessage', $Form->errors());
     }
     // Render default view
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:42,代码来源:class.draftscontroller.php

示例15: events

 public function events()
 {
     if (!env('student')) {
         redirect('m=login');
     }
     $updisciplineId = val($_REQUEST, 'updisciplineId');
     $learningMode = val($_REQUEST, 'learningMode');
     if (empty($updisciplineId) || empty($learningMode)) {
         throw new Exception('Missed required param', 404);
     }
     $updiscipline = entry_sql('SELECT * FROM updiscipline WHERE updisciplineId=:updisciplineId', array(':updisciplineId' => $updisciplineId));
     if (empty($updiscipline)) {
         throw new Exception('Updiscipline not found', 404);
     }
     $groupPeriod = entry_sql('SELECT gp.* FROM group_history gh INNER JOIN group_period gp USING(groupPeriodId) WHERE gh.studentId=:studentId AND gp.sersemester=:sersemester', array('studentId' => studentId(), 'sersemester' => $updiscipline['sersemester']));
     if (empty($groupPeriod)) {
         throw new Exception('Cannot detect groupPeriod', 404);
     }
     $events = entries_sql('SELECT * FROM event WHERE updisciplineId=:updisciplineId AND groupPeriodId=:groupPeriodId AND learningMode=:learningMode', array('groupPeriodId' => $groupPeriod['groupPeriodId'], 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode));
     array_walk($events, function (&$event, $k, $studentId) {
         $event['c'] = material::i($event['instanceType'])->c();
         $event['grade'] = material::i($event['instanceType'])->get_grade($event['instanceId'], $studentId);
     }, studentId());
     env('breadcrumbs', array(array(lng('up:disciplines'), '/?c=up'), array($updiscipline['disciplineName'], '/?c=up&amp;m=events&amp;updisciplineId=' . $updisciplineId . '&amp;learningMode=' . $learningMode), lng('up:events')));
     tpl('up/events', array('updiscipline' => $updiscipline, 'events' => $events, 'result' => entry_sql('SELECT * FROM result WHERE studentId=:studentId AND updisciplineId=:updisciplineId AND learningMode=:learningMode', array('studentId' => studentId(), 'updisciplineId' => $updiscipline['updisciplineId'], 'learningMode' => $learningMode))));
 }
开发者ID:vealexeev,项目名称:quiz_engine_light,代码行数:26,代码来源:up.php


注:本文中的val函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。