Ejemplo n.º 1
0
    /**
     * Undocumented method.
     *
     * @todo Method DefinitionList() needs a description.
     */
    public function DefinitionList()
    {
        $Session = Gdn::Session();
        if (!array_key_exists('TransportError', $this->_Definitions)) {
            $this->_Definitions['TransportError'] = T('Transport error: %s', 'A fatal error occurred while processing the request.<br />The server returned the following response: %s');
        }
        if (!array_key_exists('TransientKey', $this->_Definitions)) {
            $this->_Definitions['TransientKey'] = $Session->TransientKey();
        }
        if (!array_key_exists('WebRoot', $this->_Definitions)) {
            $this->_Definitions['WebRoot'] = CombinePaths(array(Gdn::Request()->Domain(), Gdn::Request()->WebRoot()), '/');
        }
        if (!array_key_exists('UrlFormat', $this->_Definitions)) {
            $this->_Definitions['UrlFormat'] = Url('{Path}');
        }
        if (!array_key_exists('Path', $this->_Definitions)) {
            $this->_Definitions['Path'] = Gdn::Request()->Path();
        }
        if (!array_key_exists('SignedIn', $this->_Definitions)) {
            if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
                $SignedIn = 2;
            } else {
                $SignedIn = (int) Gdn::Session()->IsValid();
            }
            $this->_Definitions['SignedIn'] = $SignedIn;
        }
        if (!array_key_exists('ConfirmHeading', $this->_Definitions)) {
            $this->_Definitions['ConfirmHeading'] = T('Confirm');
        }
        if (!array_key_exists('ConfirmText', $this->_Definitions)) {
            $this->_Definitions['ConfirmText'] = T('Are you sure you want to do that?');
        }
        if (!array_key_exists('Okay', $this->_Definitions)) {
            $this->_Definitions['Okay'] = T('Okay');
        }
        if (!array_key_exists('Cancel', $this->_Definitions)) {
            $this->_Definitions['Cancel'] = T('Cancel');
        }
        if (!array_key_exists('Search', $this->_Definitions)) {
            $this->_Definitions['Search'] = T('Search');
        }
        $Return = '<!-- Various definitions for Javascript //-->
<div id="Definitions" style="display: none;">
';
        foreach ($this->_Definitions as $Term => $Definition) {
            $Return .= '<input type="hidden" id="' . $Term . '" value="' . Gdn_Format::Form($Definition) . '" />' . "\n";
        }
        return $Return . '</div>';
    }
Ejemplo n.º 2
0
 /**
  * Creates a VALUE attribute for a form input and returns it in this format: [ value="VALUE"]
  *
  * @param string $FieldName The name of the field that contains the value in $this->_DataArray.
  * @param array $Attributes An associative array of attributes for the input. ie. maxlength, onclick,
  *    class, etc. If $Attributes contains a 'value' key, it will override the
  *    one automatically generated by $FieldName.
  * @return string
  */
 protected function _ValueAttribute($FieldName, $Attributes)
 {
     // Value from $Attributes overrides the datasource and the postback.
     return ' value="' . Gdn_Format::Form(ArrayValueI('value', $Attributes, $this->GetValue($FieldName))) . '"';
 }
Ejemplo n.º 3
0
    /**
     * Undocumented method.
     *
     * @todo Method DefinitionList() needs a description.
     */
    public function DefinitionList()
    {
        $Session = Gdn::Session();
        if (!array_key_exists('TransportError', $this->_Definitions)) {
            $this->_Definitions['TransportError'] = T('Transport error: %s', 'A fatal error occurred while processing the request.<br />The server returned the following response: %s');
        }
        if (!array_key_exists('TransientKey', $this->_Definitions)) {
            $this->_Definitions['TransientKey'] = $Session->TransientKey();
        }
        if (!array_key_exists('WebRoot', $this->_Definitions)) {
            $this->_Definitions['WebRoot'] = CombinePaths(array(Gdn::Request()->Domain(), Gdn::Request()->WebRoot()), '/');
        }
        if (!array_key_exists('UrlFormat', $this->_Definitions)) {
            $this->_Definitions['UrlFormat'] = Url('{Path}');
        }
        if (!array_key_exists('Path', $this->_Definitions)) {
            $this->_Definitions['Path'] = Gdn::Request()->Path();
        }
        if (!array_key_exists('Args', $this->_Definitions)) {
            $this->_Definitions['Args'] = http_build_query(Gdn::Request()->Get());
        }
        if (!array_key_exists('ResolvedPath', $this->_Definitions)) {
            $this->_Definitions['ResolvedPath'] = $this->ResolvedPath;
        }
        if (!array_key_exists('ResolvedArgs', $this->_Definitions)) {
            if (sizeof($this->ReflectArgs) && (isset($this->ReflectArgs[0]) && $this->ReflectArgs[0] instanceof Gdn_Pluggable || isset($this->ReflectArgs['Sender']) && $this->ReflectArgs['Sender'] instanceof Gdn_Pluggable || isset($this->ReflectArgs['sender']) && $this->ReflectArgs['sender'] instanceof Gdn_Pluggable)) {
                $ReflectArgs = json_encode(array_slice($this->ReflectArgs, 1));
            } else {
                $ReflectArgs = json_encode($this->ReflectArgs);
            }
            $this->_Definitions['ResolvedArgs'] = $ReflectArgs;
        }
        if (!array_key_exists('SignedIn', $this->_Definitions)) {
            if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
                $SignedIn = 2;
            } else {
                $SignedIn = (int) Gdn::Session()->IsValid();
            }
            $this->_Definitions['SignedIn'] = $SignedIn;
        }
        if (Gdn::Session()->IsValid()) {
            // Tell the client what our hour offset is so it can compare it to the user's real offset.
            TouchValue('SetHourOffset', $this->_Definitions, Gdn::Session()->User->HourOffset);
        }
        if (!array_key_exists('ConfirmHeading', $this->_Definitions)) {
            $this->_Definitions['ConfirmHeading'] = T('Confirm');
        }
        if (!array_key_exists('ConfirmText', $this->_Definitions)) {
            $this->_Definitions['ConfirmText'] = T('Are you sure you want to do that?');
        }
        if (!array_key_exists('Okay', $this->_Definitions)) {
            $this->_Definitions['Okay'] = T('Okay');
        }
        if (!array_key_exists('Cancel', $this->_Definitions)) {
            $this->_Definitions['Cancel'] = T('Cancel');
        }
        if (!array_key_exists('Search', $this->_Definitions)) {
            $this->_Definitions['Search'] = T('Search');
        }
        $Return = '<!-- Various definitions for Javascript //-->
<div id="Definitions" style="display: none;">
';
        foreach ($this->_Definitions as $Term => $Definition) {
            $Return .= '<input type="hidden" id="' . $Term . '" value="' . Gdn_Format::Form($Definition) . '" />' . "\n";
        }
        return $Return . '</div>';
    }