Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Whats wrong with this code?

SrggamerSrggamer HardCore Gamer ✭✭✭

public function Base_Render_Before($Sender) { $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE)); }

Need help, http://dragonx.net/community

http://gyazo.com/fae0c5c11675c9d0378ed2ac180fd644

«1

Comments

  • Options
    businessdadbusinessdad Stealth contributor MVP

    I'm afraid that, without the context, it's hard to figure out what's wrong.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    A wild stab in the dark is that the function declaration isn't in the scope of a class. Have you modified the WhosOnline plugin at all?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    best not work on a live site.

    grep is your friend.

  • Options
    peregrineperegrine MVP
    edited March 2013

    @Srggamer

    parse error - indicates problems with {};, etc.

    I suspect it is the lines above it causing the problem -

    I bet:

    T_PUBLIC happens

    you missed closing bracket "}" on a previous function or put too many {} in. Usually a bracket mismatch

    T_STRING errors

    happens when you mess up your quotes " ' . or mismatch them

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭
    edited March 2013

    What I am trying to do, is make a modification of the Whosonline plugin to make it instead of names, Profile pictures, What I am trying now to implement is the Custom CSS, that Includes the showing of the images the layout and so on. Because I do not wish to add the Custom CSS, into my theme.

    http://pastebin.com/QaruHHyh

    This Is how the code looks like.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @hgtonight said:
    A wild stab in the dark is that the function declaration isn't in the scope of a class. Have you modified the WhosOnline plugin at all?

    Thats what I am currently trying to do.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @x00 said:
    best not work on a live site.

    Yes I agree, but working on a live site allows me to be able to see it with other plugins in operation. Though installing a LocalHost Vanilla Forum may be the way to go with Plugin development, or modification which I am currently trying to learn.

  • Options
    hgtonighthgtonight ∞ · New Moderator
    edited March 2013

    @Srggamer

      include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
      $WhosOnlineModule = new WhosOnlineModule($Sender);
      $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
      echo $WhosOnlineModule->ToString();
    ]
    public function Base_Render_Before($Sender) {
      $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE));
    }
    

    That square bracket, ], on the line 5 is causing the parsing error. Looks like it should be a closing curly brace instead }.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    around line 29

    // why the ]

    ] public function Base_Render_Before($Sender) {

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    For large code pastes like this, I would suggest a service like pastebin.com and just linking it

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @hgtonight said:
    For large code pastes like this, I would suggest a service like pastebin.com and just linking it

    http://pastebin.com/QaruHHyh

    Uploaded to this, thanks for tip.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @hgtonight said:
    Srggamer

      include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
      $WhosOnlineModule = new WhosOnlineModule($Sender);
      $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
      echo $WhosOnlineModule->ToString();
    ]
    public function Base_Render_Before($Sender) {
      $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE));
    }
    

    That square bracket, ], on the line 5 is causing the parsing error. Looks like it should be a closing curly brace instead }.

    Removed it still causing error. On anew line of course.

    http://gyazo.com/1b483dfd90dbab0bfdfa12a7c0333a06

  • Options
    peregrineperegrine MVP
    edited March 2013
        // Define the plugin: $PluginInfo['WhosOnline'] = array( 'Name' => 'WhosOnline', 'Description' => "Lists the users currently browsing the forum.", 'Version' => '1.3', 'Author' => "Gary Mardell", 'AuthorEmail' => 'gary@vanillaplugins.com', 'AuthorUrl' => 'http://vanillaplugins.com', 'RegisterPermissions' => array('Plugins.WhosOnline.ViewHidden', 'Plugins.WhosOnline.Manage'), 'SettingsPermission' => array('Plugins.WhosOnline.Manage') );
    
        /** * TODO: * Admin option to allow users it hide the module * User Meta table to store if they are hidden or not */
    
        class WhosOnlinePlugin extends Gdn_Plugin {
    
        public function PluginController_WhosOnline_Create(&$Sender) { $Sender->Permission('Plugins.WhosOnline.Manage'); $Sender->AddSideMenu('plugin/whosonline'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('WhosOnline.Location.Show', 'WhosOnline.Frequency', 'WhosOnline.Hide')); $Sender->Form->SetModel($ConfigurationModel);
    
            if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
            $Sender->Form->SetData($ConfigurationModel->Data);
            } else {
            $Data = $Sender->Form->FormValues();
            $ConfigurationModel->Validation->ApplyRule('WhosOnline.Frequency', array('Required', 'Integer'));
            $ConfigurationModel->Validation->ApplyRule('WhosOnline.Location.Show', 'Required');
            if ($Sender->Form->Save() !== FALSE)
            $Sender->StatusMessage = T("Your settings have been saved.");
            }
            // creates the page for the plugin options such as display options
            $Sender->Render($this->GetView('whosonline.php'));
    
        }
    
        public function PluginController_ImOnline_Create(&$Sender) {
    
            $Session = Gdn::Session();
            $UserMetaData = $this->GetUserMeta($Session->UserID, '%');
            // render new block and replace whole thing opposed to just the data
            include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
            $WhosOnlineModule = new WhosOnlineModule($Sender);
            $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
            echo $WhosOnlineModule->ToString();
    
        ] public function Base_Render_Before($Sender) { $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE)); }
    
        }
    
        public function Base_Render_Before(&$Sender) { $ConfigItem = C('WhosOnline.Location.Show', 'every'); $Controller = $Sender->ControllerName; $Application = $Sender->ApplicationFolder; $Session = Gdn::Session();
    
            // Check if its visible to users
            if (C('WhosOnline.Hide', TRUE) && !$Session->IsValid()) {
            return;
            }
            $ShowOnController = array();
            switch($ConfigItem) {
            case 'every':
            $ShowOnController = array(
            'discussioncontroller',
            'categoriescontroller',
            'discussionscontroller',
            'profilecontroller',
            'activitycontroller'
            );
            break;
            case 'discussion':
            default:
            $ShowOnController = array(
            'discussioncontroller',
            'discussionscontroller',
            'categoriescontroller'
            );
            }
            if (!InArrayI($Controller, $ShowOnController)) return;
            $UserMetaData = $this->GetUserMeta($Session->UserID, '%');
            include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
            $WhosOnlineModule = new WhosOnlineModule($Sender);
            $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
            $Sender->AddModule($WhosOnlineModule);
            $Sender->AddJsFile('/plugins/WhosOnline/whosonline.js');
            $Frequency = C('WhosOnline.Frequency', 4);
            if (!is_numeric($Frequency))
            $Frequency = 4;
            $Sender->AddDefinition('WhosOnlineFrequency', $Frequency);
    
        }
    
        public function Base_GetAppSettingsMenuItems_Handler(&$Sender) { $Menu = $Sender->EventArguments['SideMenu']; $Menu->AddLink('Add-ons', 'Whos Online', 'plugin/whosonline', 'Garden.Themes.Manage'); }
    
        // User Settings public function ProfileController_AfterAddSideMenu_Handler(&$Sender) { $SideMenu = $Sender->EventArguments['SideMenu']; $Session = Gdn::Session(); $ViewingUserID = $Session->UserID;
    
            if ($Sender->User->UserID == $ViewingUserID) {
            $SideMenu->AddLink('Options', T('Who\'s Online Settings'), '/profile/whosonline', FALSE, array('class' => 'Popup'));
            }
    
        }
    
        public function ProfileController_Whosonline_Create(&$Sender) {
    
            $Session = Gdn::Session();
            $UserID = $Session->IsValid() ? $Session->UserID : 0;
            // Get the data
            $UserMetaData = $this->GetUserMeta($UserID, '%');
            $ConfigArray = array(
            'Plugin.WhosOnline.Invisible' => NULL
            );
            if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
            // Convert to using arrays if more options are added.
            $ConfigArray = array_merge($ConfigArray, $UserMetaData);
            $Sender->Form->SetData($ConfigArray);
            }
            else {
            $Values = $Sender->Form->FormValues();
            $FrmValues = array_intersect_key($Values, $ConfigArray);
            foreach($FrmValues as $MetaKey => $MetaValue) {
            $this->SetUserMeta($UserID, $this->TrimMetaKey($MetaKey), $MetaValue);
            }
            $Sender->StatusMessage = T("Your changes have been saved.");
            }
            $Sender->Render($this->GetView('settings.php'));
    
        }
    
        public function Setup() { $Structure = Gdn::Structure(); $Structure->Table('Whosonline') ->Column('UserID', 'int(11)', FALSE, 'primary') ->Column('Timestamp', 'datetime') ->Column('Invisible', 'int(1)', 0) ->Set(FALSE, FALSE); } } `
    

    if you leave the top line out with the php it is easier to paste the complete code.

    or use

     "&lt" with a ";"  

    for <

    and hgtonight beat me to the bracket.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator
    edited March 2013

    In your pastebin link, you should just remove that curly brace.

    peregrine already mentioned this

    @peregrine said:
    Srggamer

    parse error - indicates problems with {};, etc.

    I suspect it is the lines above it causing the problem -

    I bet:

    T_PUBLIC happens

    you missed closing bracket "}" on a previous function or put too many {} in. Usually a bracket mismatch

    T_STRING errors

    happens when you mess up your quotes " ' . or mismatch them

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    Okay. I decide to download the official version. Can someone tell me how I can make a CSS request?

  • Options

    the way you did it, just don't add syntax errors. Your routine you posted at the top was fine, you just messed up the code above it. to produce the error you got.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    Finished made, it work. I wonder am I allowed to release this plugin, even though I did not fully code it?

  • Options
    422422 Developer MVP

    yeah just give attribution to the other coder within the about.php

    There was an error rendering this rich post.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @422 said:
    yeah just give attribution to the other coder within the about.php

    Thanks!

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @422 said:
    yeah just give attribution to the other coder within the about.php

    /default.php: The addon's key is not the same as its folder name.

    Any thing I can read somewhere? About this.

Sign In or Register to comment.