Jump to content
Larry Ullman's Book Forums

Edward

Members
  • Posts

    1115
  • Joined

  • Last visited

  • Days Won

    27

Everything posted by Edward

  1. Edward

    Yii And Js

    I decided in the end not to use this method as it doesn't work out with my current situation. Here was a good doc i found if anyone else was interested. This already comes with HTML5 so you don't need the Jquery plugins. http://www.simonbingham.me.uk/index.cfm/main/post/uuid/using-html5-local-storage-and-jquery-to-persist-form-data-47
  2. Edward

    My Project Diary

    Thanks for reading my project diary hope you stay tuned.
  3. Edward

    Yii And Js

    No problem, btw have you ever used that function before? Once you finish that Yii book ill buy another one.
  4. Edward

    Yii And Js

    jQuery.localStorage() That should do the trick. Thanks.
  5. Edward

    Yii And Js

    I have something i am trying to figure out. I have some hide and show division blocks on one of my yii forms. Now the problem is if i click on the form in real-time to say show a division block, when i submit the form and the validation does not clear because some model attributed are required the division block can now not be seen which means they are reset. So how to save the state of the jquery on the page after the submission of the form has been processed?
  6. Edward

    My Project Diary

    Saturday, 6th April 2013 Done bits and bobs of code in the week, managed to get together my final database plan for the listing of Items and reduce shipping from three to one table. I spent time also in the week reading the Yii chapters on Role Based Authentication, Extensions and got half way through the JS chapter. All the chapters have been good, the javascript chapter looks as though it covers most of what i need for my item page, thanks Larry. This week i was checking out on 3d games programming something i used to do in 2d about 16 years ago. I was searching for 3d game engines and found a few like UDK, Unity3d and CryEngine. I have decided to give Unity3d a go and have been working through the Stealth game tutorials. With Unity3d you have an IDE about like you have with the new adobe CS6. A lot of the work can be done visually for the 3d game environment you only have small scripts for editing or adding classes that can be written in C#, Javascript (the other one) or Boo. Basically Unity3d is similar to Yii but only about 50% of what it seems so far seems to be visually done rather than coding. Well i guess i am not into hard game logic yet! The good thing about Unity3d as well is they have an assets store, so you can buy character model, or vehicles or props whatever you need. I like web programming but if you try the Unity3d yourself you will see its a lot more fun. Now i just want to get my Yii coding done so i can spend all night on it. Here is some sample Unity C# Code using UnityEngine; using System.Collections; public class DoneAlarmLight : MonoBehaviour { public float fadeSpeed = 2f; // How fast the light fades between intensities. public float highIntensity = 2f; // The maximum intensity of the light whilst the alarm is on. public float lowIntensity = 0.5f; // The minimum intensity of the light whilst the alarm is on. public float changeMargin = 0.2f; // The margin within which the target intensity is changed. public bool alarmOn; // Whether or not the alarm is on. private float targetIntensity; // The intensity that the light is aiming for currently. void Awake () { // When the level starts we want the light to be "off". light.intensity = 0f; // When the alarm starts for the first time, the light should aim to have the maximum intensity. targetIntensity = highIntensity; } void Update () { // If the light is on... if(alarmOn) { // ... Lerp the light's intensity towards the current target. light.intensity = Mathf.Lerp(light.intensity, targetIntensity, fadeSpeed * Time.deltaTime); // Check whether the target intensity needs changing and change it if so. CheckTargetIntensity(); } else // Otherwise fade the light's intensity to zero. light.intensity = Mathf.Lerp(light.intensity, 0f, fadeSpeed * Time.deltaTime); } void CheckTargetIntensity () { // If the difference between the target and current intensities is less than the change margin... if(Mathf.Abs(targetIntensity - light.intensity) < changeMargin) { // ... if the target intensity is high... if(targetIntensity == highIntensity) // ... then set the target to low. targetIntensity = lowIntensity; else // Otherwise set the targer to high. targetIntensity = highIntensity; } } }
  7. Edward

    Ckeditor

    Well basically I copy an image from my computer by pressing ctrl + c then click on the CKEditor and press ctrl + v, the image is then posted into the editor. I looked at the HTML source and it should some base64 encoding for the whole image, the image was perfectly viewable now in the editor.
  8. Edward

    Ckeditor

    I was wondering if anyone knew how to diable image pasting into a CKEditor What you see is what you get Editor. I couldn't find anything online on how to directly do this. I managed to remove all plugins i didn't want in the config.js file /** * Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; config.skin = 'moono-light'; // Remove multiple plugins. config.removePlugins = 'about,image,imagepaste,div,flash,forms,horizontalrule,iframe,line,link,pagebreak,table,tabletools,save,scayt,templates'; };
  9. Thanks that was useful Larry, i will do it that way. One last thing, we can edit our main css from main.php in the layouts folder but what if we wanted to have some pages fixed width and other pages with fluid width. How would you personally go about handling such a situation in Yii? Also did you get my comment in YiiBook thread regarding the setting in the main.php config file, i couldn't find that mentioned in the book.
  10. I think i know what you mean, i have been working with YiiBooster today on other stuff, its certainly a big time saver. One thing though, should we go to change the main Yii layout files, main.php, column1.php and column2.php to the Boostrap css layouts. I did do this before but wondered if i should do this again? The only thing i could see we were taking out was the Page ID tag, which takes out some marginal padding, its nothing we couldn't add in ourselves.
  11. I did have that // preloading 'log' component 'preload'=>array('bootstrap','log'), but the css would not draw properly the way you wrote it.
  12. I am confused also with this, usually with YiiBooster a basic navbar wood be implemented by adding the code like i done below. Are you sure its not bootstrap when you call the widget and not zii? $this->widget('bootstrap.widgets.TbNavbar', array( 'brand' => 'Title', 'items' => array( array( 'class' => 'bootstrap.widgets.TbMenu', 'items' => array( array('label'=>'Home', 'url'=>'#', 'active'=>true), array('label'=>'Link', 'url'=>'#'), array('label'=>'Link', 'url'=>'#'), ) ) ) )); http://yii-booster.clevertech.biz/components.html#navbar
  13. I was fixing a small bug on my Yii site today, i did change the login page over to the user model to reduce the models like you said Larry on page 248 "Using the Existing Model". But this code only partially works, we also need to set the the default login page in our main.php file in config folder otherwise when we try to access a controller we need authentication to it will always take us back to site/login. 'user'=>array( 'loginUrl'=>array('user/login'), // enable cookie-based authentication 'allowAutoLogin'=>false, 'authTimeout' => (60*15) // session timeout 15 minutes ), Hope this helps out!
  14. Edward

    My Project Diary

    Saturday, 30th March 2013 Took a day of yesterday but got back onto it today, Ive just tested through and improved my code on the Forgotten Password, Forgotten Username and Password Reset Page. All of these including the Verfication and Registration Link page took up 8 new actions in my User controller, there were quite a lot of buggy issues that could arise from this area. So far everything is looking quite good. Currently i am not on any live server i was with RackSpace but they were costing the Bomb, so i decided to build locally for now. I will need to test my email with links later on the live server. I am also thinking of building an email class to handle system emails but that is a job that can be done later on. So now i will be starting the Item page again next. I will also need to rethink my shipping options and try to breakdown things into the simplest universal form in which they can be used by any particular person selling products.
  15. Edward

    My Project Diary

    Thanks for that Larry, now it makes more sense. Thursday, 28th March 2013 Today i had this thought to put extra comments inside a controller. We need to push all we can out of the controller into the model's beforeValidate, afterValidate, beforeSave and afterSave methods. So i thought here that it would be a good idea to put a note of what we were doing in the controller like this: $modelUser->validate(); // Generate password reset code - User::afterValidate() // Send email with password reset link - User::afterValidate() Yesterday i was adding in new routes in my config/main.php script 'user/emailusername/<email:.+>'=>'user/emailusername', 'user/registrationlink/<x:.+>'=>'user/registrationlink', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 'user/verify/<x:.+>/<y:\w+>'=>'user/verify', 'user/resetpassword/<x:.+>/<y:\w+>'=>'user/resetpassword', It appears that the order of which the routes are placed in Yii matters to how your site performs, i had to place two routes above the route '<controller:\w+>/<id:\d+>'=>'<controller>/view', otherwise they would not work and show the standard ugly urls. Just over the past few days my computer fan has been making these strange noises like vroom, vrooooooom, vrooooooooooooom, its in a repeatitive manner, and the noise has become very irritating. I have a HP desktop, its probably 2 - 3 years old.
  16. Wow your english has improved greatly over the past few months, some great vocubulary there. I have unfortanetly lost all mine being in a foreign country.
  17. Edward

    My Project Diary

    Wednesday, 27th March 2013 Last couple of days worked on the "Activation Send Link", "Forgot Password", "Forgot Username", ive only spent a couple of hours on it. It really is amazing working with a framework and an extension. I seem to be on a roll again and since i am using the correct Yii-Booster extension, now i don't see the need to go back and change all the css again, its working great now. Next week i will be starting my item listing page again, the page is extremely complicated as their are so many variables and its pretty much impossible for it to work without adding in jquery. I covered all the variables needed for listing items but some of them which may not be necessary for some members will need to be hidden or optional, i also have dynamic data in the form for a couple of parts, including shipping, images and attributes. My site wouldn't be able to work without fully completing this page, so i plan on just working on this now until its 100% and leaving other parts of the website till its done. I can't put a time on how long its going to take but from what i see it seems to have the hardest coding of my website. I am extremely looking forward to reading Larry's new implementing javascript into Yii chapter and hope it has some useful common how to's. This should be out within the next few weeks, so it will here in perfect time and should be useful for my jquery stuff which needs added. Ah i forgot to mention one cool thing about Yii-Booster is that you can easily add in a WYSIWYG Editor, like Redactor which is new and available to use for Yii projects. This will certainly be another timesaver and benefit of using extensions. Does anyone know what this Globbledegook means? ?UTF-8?B? I saw yii using it in their email headers in the contact form, does it mean what i think it does?
  18. Edward

    My Project Diary

    Monday, 25th March 2013 There have been many changes to my project since i have started with regards to the way i was coding then debating over using frameworks then learning and starting to use a framework for my project. I did give my project a go using the Yii framework using the knowledge i was able to gather from the Yii Definitive guide but after reading the Yii Book i found out that there was about 20% of the Yii stuff i needed to redo. I also found the Twitter Boostrap css framework which i implemented myself first of all and made my own customizations to Yii widgets, the trouble with this was i was changing files in the main framework folder which is not good to do, as when you upgrade Yii, you will have to change all the files again. Later through the help of others here i found the Yii-Booster extension, this works out better as i can just add in their extension without having to alter the main framework files, so everything would be ready if there was any Yii upgrade. At the moment i am building what i know is correct for my site and trying to use Yii in the correct way. I guess with all of us in the same sitution we have to be patient now and slow down a bit to wait to see how Larry finishes of his Yii Book and to get all the correct knowledge before bashing out our projects. I just try now to do a couple of hours a day on the Coding, i spent about 1 - 2 month trying to plan databases but now realize i need to change some things again, this is one reason i think its better to take the project slow. If you build too much and its wrong you only have to take more of it down. And for me when i have to do the same things again i find my brain seizing up and not wanting to do it. Today i worked on the page after registration that confirms an email was sent to you and you need to click on the link to activate your account. There was a way to breach security if you passed the user id to the registration link page, so i decided to pass the email of the user over to load up the model and again used routes as i discussed with verify. Off the record i just bought "The Walking Dead - Survival Instinct" for PS3 where you play the TV series guy Daryl Dixon along with his brother Meryl, its actually pretty good. Its good for clearing out the brain after some ours of coding and can make you jump as its quite intensive. Well if any of you have the time, i would recommend that game.
  19. Actually i am not messing around with CSS too much right now, as there is Yii-Boilerplate which they recommend you install rather than just Yii-Booster alone which i did. I have no idea how to install Yii-Boilerplate, don't understand what they are talking about at all, so wondered whether it was worth the hastle. The trouble with installing the Yii-Booster extension is that the Yii layout files main.php, column1.php and column2.php are still using blueprints css. I did wipe out the blueprints before and changed all to bootstrap but now like Jonathon i don't want to do too much incase i make too many mistakes, i really hate going back to redo the same stuff. That's why i wasn't here for a while, needed time to take a rest before i could start it all again.
  20. Thanks. I think i have found a situation where Yii-Booster extensions don't work, well you know we have to use the Yii encode function to protect against XSS attacks, well look at this situation. <?php Yii::app()->user->setFlash('warning', "<p>This is your email <strong>(echo CHtml::encode($modelUser->email);)</strong> </p>"); $this->widget('bootstrap.widgets.TbAlert', array( 'block'=>true, // display a larger alert block? 'fade'=>false, // use transitions? 'closeText'=>'false', // close link text - if set to false, no close link is displayed 'alerts'=>array( // configurations per alert type 'warning'=>array('block'=>true, 'fade'=>false, 'closeText'=>'false'), // success, info, warning, error or danger ), )); We can't add that encode function into the extension, it won't work, so we have to use the manual bootstrap css for alerts in this situation. ?>
  21. Check $dbc has a database connection so the mysqli_query function can return a result for the function of which you are receiving the error.
  22. I think that is correct having a creator id in the page class and then have a user class with the actual creaters user id. So having two is fine, and then have your getCreatorMethod in the page class is also %100. This is actually how Yii does it in its model classes it stores the attributes which relate to a database model in the class. And you should put related model methods or calls within the related class.
  23. Well YiiBooster seems to be quite stable, the only thing was when working with forms you only have to add: <?php echo $form->textFieldRow($modelUser,'email',array('class'=>'span5','maxlength'=>60)); ?> rather than all the standard: <?php echo $form->labelEx($modelUser,'email', array('class'=>'control-label')); ?> <?php echo $form->textField($modelUser,'email',array('size'=>60,'maxlength'=>60)); ?> <?php echo $form->error($modelUser,'email'); ?> So you can't get direct access to label or error as they have fitted all of them into textFieldRow. One other thing i forgot to mention yesterday was where in Yii should we add our own classes, i will definetly need to add some additional ones for my project to work. I thought of the top of my head that we might add them into components but i am not sure. I was also thinking yesterday if they were some small parts of my project i could not complete myself then possibly i could hire you for some small parts. It really depends whether i can get it done myself or not, but only small parts, nothing that would take up too much of your time.
  24. Edward

    My Project Diary

    I did think about what you said before i made the change but my verfication works by checking their email against the activation code. Most of the codes would be different, so i don't see how even if someone did have the same activation code as someone else how they would be able to guess the other personal's email. I thought the case would of been highly unlikely that is my reason for shortening it. So do you think that would stand or can you suggest of another way to get a unique 10 alphanumerical code?
  25. Thanks Larry and Jonathon, i changed mine to 'verify/<x:.+>/<y:\w+>' => 'user/verify', and now it works, i prefer to use the + over * as there has to be more than 1 character i guess it doesn't matter and comes down to your own personal preference.
×
×
  • Create New...