Friday, 15 June 2012

php - Loading a Parent Class in Symfony 2 -


I have set up a test root class in my Symfony 2 controller as follows:

  & Lt ;? Php namespace Zetcho \ AmColAnBundle \ controller; Use Symfony \ Bundle \ FrameworkBundle \ Controller \ Controller; Extends the class base controller controller {public function valid user () {$ user ['first_name'] = "name"; $ User ['signin'] = true; $ User return; }} Class extends the DefaultController BaseController {public function index action () {$ user = $ this-> ValidateUser (); $ DisplayParms ['user'] = $ user; $ $ Return - ('zetkoamcolnbundle: default: index.html.twig', $ displayParms); }}   

The code is in the code src / Zetcho / AmColAnBundle / Controller / DefaultController.php. The test code works now I want to take the parent class (base controller) from my original controller file So that I can reuse it in my other controllers. I want to place it in the same directory as other controllers and I would like to declare it the same way as in the above usage details, what is the best / accepted way to do this in the controller Symfony 2?

You do it in SimFony 2 the same way you would be with any PHP class. Split your classes into different files like this: -

src / Zetcho / AmColAnBundle / Controller / BaseController.FP

  Namespace Zetcho \ AmColAnBundle \ Controller; Use Symfony \ Bundle \ FrameworkBundle \ Controller \ Controller; Extends the class base controller controller {public function valid user () {$ user ['first_name'] = "name"; $ User ['signin'] = true; $ User return; }}   

src / Zetcho / AmColAnBundle / Controller / DefaultController.php

  Namespace Zetcho \ AmColAnBundle \ Controller; Use Zetcho \ AmColAnBundle \ Controller \ BaseController; The square spreads to the defaultController BaseController {public function index action () {$ user = $ this- & gt; Valid user (); $ DisplayParms ['user'] = $ user; $ $ Return - ('zetkoamcolnbundle: default: index.html.twig', $ displayParms); }}   

Once you know that really is very simple, remember that the controllers in symfony2 are only normal PHP classes, nothing special about them.

IIS 7.5 forces the http header CacheControl to Private -


My In the NET code, I have a custom handler that is in the process of the HTTP process and is called a custom HTML module to call the processor method in the HTTP cache header.

The HTTPS module sets the header in the preceded sequence header system with the following code

  http cache policy = cache = response Cache; If (cache! = Null) {cache.SetCacheability (HTTPCPL.Public); Cache.SetMaxAge (TimeSpan.FromSeconds (varnishDuration)); reaction. AppendHeader ("Edge-Control", String.Concat ("! No-store, max-age =", Akamai period, "S DCA = Nop")); }   

In IIS 7.5, with the pool in integrated mode, the cash control is forced to private. What I found here:

  curl -IXGET -H "host: myHostName" "http: // myServer / mypage" HTTP / 1.1 200 OK cache-control: Private server: Microsoft-IIS / 7.5 X-espant-version: 4.0.30319 edge-control:! No-store, max-age = 300 s dca = noop [...]   

I do not understand IIS changes the cache control in private.

My web My webserver section is in the config:

  & lt; Pre & gt; & Lt; System.webServer & gt; & Lt; Handler Access Policy = "Read, Script" & gt; & Lt; Add name = "Oxygen Handler" verb = "*" path = "*" type = "com.eurosport.oxygen.server.modules.OxygenHandlerFactory, OxygenServerModule" /> & Lt; / Operators & gt; & Lt; Run the moduleAll managed modules FOR ALLRequests = "true" & gt; & Lt; Add name = "WebServiceCachingModule" type = "com.eurosport.toolkit.WebServiceCachingModule, Eurosport.Toolkit" /> & Lt; / Module & gt; & Lt; /system.webServer> & Lt; / Pre & gt;   

I have been told here that tried to add SetSlidingExpiration but it does not help.

I have been able to work with this code in my module: < Pre> feedback Header. Remove ("cache-control"); reaction. AppendHeader ("Cash-Control", "Public, Maximum-Age =" + Varnish Dictor. Toastring () + ", s-max-age =" + varnishDuration.ToString ());

It looks dirty but it seems that reaction. Cash Control and Response The cache property is not used by IIS in integrated mode (or is overridden by some modules ...)

vb.net - How can I set the text for a label equal to the selected Item of a databound listBox? -


I set ValueMember for DisplayMember and "EmpID" columns for the ListBox for the "Employee" column. The list box stays fine, but the label never changes. I'm new on this and can not understand what I'm missing. Here is my code:

  Me.EmployeeTableAdapter.Fill (Me.TimeCards2DataSet.Employee) Label1.Text = lstEmployees.Selected.ToString    

You are probably looking for an index-playable event:

  Private sub-listpermessic index ( The sender in the form of the object, and event as an ARG) _LSEMFiGe are selected. The selected index changes if LSEMA employees. If selected, then there is nothing label 1. Text = string Leave blank label 1 text = lstEmployees.Verue selected.Stressing end and end   

Alternatively, if using data binding: / P>

  Label1 .DataBindings.Add ("Text", Me.TimeCards2DataSet.Employee, "Employee")    

c# - asp.net submit process -


I have 2 labels and a text box to start random numbers, to see if answer is random add After the number is correct. The problem I am facing represents the next set of random numbers and therefore the result is always wrong. Here's the code that I've done so far.

  name space _2nd grademate {public partial square default: system Web. UI Page {Random Random = New Random (); Protected Zero Page_Load (Object Sender, EventArgs e) {lblNum1.Text = random.Next (0, 10) .toString (); LblNum3.Text = random.Next (0, 10) .toString (); Int num1 = int.Parse (lblNum1.Text); Int num2 = int.Parse (lblNum3.Text); LblAnswer.Text = (num1 + num2) .ostring (); LblAnswer.Visible = false; } Secure Zero Button 1_Click (Object Sender, EventArgs E) {If (Textbox1.Text! = LBL Encore.text) {button. a quality. Add ("onclick", "javascript: alert ('wrong');"); } And if (text box text 1 == lbl Answers.Text) {button. a quality. Add ("OnClick", "Javascript: Alert ('Correct');"); } TextBox1.Text = ""; }}}    

To run the initial code only Use when the page is initially loaded:

  protected zero page_load (object sender, eventarges e) {if (IsPostBack) {lblNum1.Text = random.Next (0, 10) .ostrong (); LblNum3.Text = random.Next (0, 10) .toString (); Int num1 = int.Parse (lblNum1.Text); Int num2 = int.Parse (lblNum3.Text); LblAnswer.Text = (num1 + num2) .ostring (); LblAnswer.Visible = false; }}    

Django TypeError: 'int' object is not callable -


I am getting the following error:

Type error: 'int' is not an object File / user / user / document / workspace / livewire sms / sms / model / message

feedback = receiver (sign = self, sender = sender, ** name) file ", Line 156, my_handler example. Charge = instance.length (instance.content)

From this snippet of code:

  @receiver (Pre_save) , Sender = message) def my_handler (sender, ** kwargs): eg Runt = kwargs ['Examples'] If not, in case. Incharge: Example. Charge = instance.length (instance.content)   

This function is its calling:

  @property def Length (self): Return Lane (Self Contents) / 160 + 1   

Can someone explain the error? Thanks.

You found this error because length returns a object and you have Tried to call it.

  example.charge = instance.length # instead of the example. Long (instance.content)    

sql - Select all Users related to Company -


First of all, sorry for the meaningless title. Please do not think anything better, please take a look at my following tables:

User

  + ----- + ------- + ------- -------- + | ID | Name | Email | + ----- + ------- + --------------- + | 1 | Name A | Namea@srv.com | | 2 | Name b Nameb@srv.com | | 3 | NameC | Namec@srv.com | + ----- + ------- + --------------- +   

Department

  + ----- + --------- + ------- + --------- + | ID | Company | Name | Manager. + ----- + --------- + ------- + --------- + | 1 | 1 | DeptA | 1 | | 2 | 1 | DeptB | 2 | + ----- + --------- + ------- + --------- +   

Company

  + ----- + ------ + ------- + | ID | Name | Owner | + ----- + ------ + ------- + | 1 | Buzz | 3 | + ----- + ------- + ------ +   

I need to find all the users related to a company. Something like this:

  + --------- + ------------ + | User_id | Company_id | + --------- + ------------ + | 1 | 1 | | 2 | 1 | | 3 | 1 | + --------- + ------------ +   

How can I do this? I have read about different types of joints (internal, external, complete, etc.), but I did not know how to handle the "department table" in the middle of everything.

I will do it with two questions:

  select the department Please. As user_id Select department.com = company.ind union company. Company_ID as the company company, company    

JavaScript Exception not working -


I am trying to understand why the error message (page is empty) in my code and not displayed it Call it with the following statement:

add document.write ((10, wrong_input));

program.js <{P>

  var add = function (a, b) {if (typeof a! == 'number 'Typeof b! ==' number ') {Throwing {name:' TypeError 'Message:' Add number of needs'} (e) {document.writeln (e.name + ':' + e.message) ; }} Return A + b; }   

program.html

  & lt; Html & gt; & Lt; Body & gt; & Lt; Pre & gt; & Lt; Script src = "program.js" & gt; & Lt; / Script & gt; & Lt; / Pre & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

throw statement hold section, try you should throw and hold separately. For example:

  var add = function (a, b) {if (typeof a! == 'number' || typeof b! == 'number') {throw {name: TypeError ', Message:' Add required numbers'}} Come back; } Try {add ('foo', 1); } Grip (Pre) {Warning (ex.message); }   

Note that I replaced the document.writeln with the warning , because the former will overwrite the whole document if this page Runs after load. If you want to look something better, then directly manipulate the dome (by changing the internal HTML of some element, adding a node etc).

html - Anchor links inside iframe does nothing -


Is it possible to have a non-scrolling iframe inside a scrolling div, and anchor link inside the work of IFrame Are you right? The anchor link should be taken inside the IFrame inside the IFrame, I do not need them to point to the elements on the parent page.

Here are my JSfields a simple example:

and the code for that:

    

I have no relation with the hypergroup dot link used in my example, it was just one of the first examples, in which I used to sign an anchor with the ID / name syntax link Could get together

If you load JSFiddle and click on the "Go down from the bottom" link inside the ifframe, then it does nothing (tested with Firefox 19.0.2) when the various pages Testing with Firefox never works anytime, in Chrome it sometimes clicks for the first time, but clicks on it, but then if you scroll up and click again then it does not work is. This works most of the time (scrolls) in IE8.

If I give the scrollbar in the iframe (scrolling = "no"), scrolling works at the right time. This is not a practical solution for me, because I have content outside the frame, which I want to scroll with. In my actual code, I set the height of the IFrame to fill my content dynamically, in this way it appears more like content on my page.

Why do I need to do this:

I am making a web-based email client and displaying the HTML body of the email inside an iframe so far At least there are some problems, vs. trying to display inside a cell cell or diva. I want to work for these types of links. I have some control over the content, it comes from my server and I can modify it (but do not want to hack it too much). For example, I already modify all the links to open in a new window (but the link does not start with #, so my problem is not).

I know Gmail does not use IFrame, but my XFINITY (by Comcast Cable) web-based email client, and managed to work on them (but have not figured out yet That's what they're doing)

Look at this post:

If your iframe is a separate domain then You will be unable to use the Javascript solution to solve it, but if so, you can add target = "_parent" attribute to all anchors within the iframe.

  var iframe = document.getElementById ('iframeId'); Var doc = (iframe.contentDocument)? Iframe.contentDocument: iframe.contentWindow.document; Var anchor = doc.getElementsByTagName ('a'); For (var i = 0; i & lt; anchors.length; i ++) anchor [i] .target = '_parent';    

php - need help creating a mysql query -


Suppose I have a table called "user", which contains the following related columns:

    • Zip code

      Say I have a table called "Favorite_Shop" containing the following relevant columns:

      • shop_name
      • Username

        Assume I have an abstract called "zipData" The following are the following relevant columns:

        • Zipcode
        • Latitude
        • Loan

          Currently I have successfully Can run this code:

            $ lat = "49.886436"; // value "zipcode select zipcode = (users_zip_code)" or similar query should be obtained from zipData table $ lon = "- 97.14553"; // "Select from zipcode zipcode = (users_zip_code)" or the same question should be obtained from $ zodiac data by radius = 5; $ Query = "zipData WHERE (POW ((69.1 * lane - \" $ lon \ ") * cos ($ lat / 57.3), \" 2 \ ") + POW ((69.1 * (lat- \" $ Latitude \ "), \" 2 \ ")) & quot; ($ radius * $ radius)";   

          The above questions will display all other zip codes that are within the given radius of the supplied latitude / lamp, but I am not interested in knowing what other ZIP codes are ... I want to know what is inside the radius in the shops.

          Any help you can give will be greatly appreciated.

          ==== Because I realized that this is actually a bit more complex ====

          I need to do this ...

          • Recover the user's zipcode from the "Users" table
          • Locate the user
          • given in the "Username" column with the given user in a "Favorite_Shop" table Find all the shops within the radius P> Problems considering: In "Zipadata" There is no white space in the copy, but the zipcode in "users" and "shops" is white space for cosmetic reasons ... such as Canada's postal code in the format "A1A1A1"

            ==== Edit for posting solution ====

            The system says that I do not have permission to reply. My own question looks strange because with the help of others I already got the answer. As a work, I am editing the original post here is the solution ...

            OK, I understood it (answered with the help of people) ... this is what I did.

            This could possibly be a very simple and clean, so please feel better if you know better if you know better.

              $ query = "Select * Preferred_Shop WHERE 'Username' = '{$ _ session [' account_name ']}'"; $ Result = mysql_query ($ query); If (Mysql_errno ()) (die ( "Error". Mysql_errno ($ link). ":". Mysql_error ($ link));} $ Num_rows = mysql_num_rows ($ result); while ($ row = mysql_fetch_array ($ result) ) {// get the user's preferences and postal code $ query2 = "SELECT * FROM seekers WHERE 'username' = '{$ _ sESSION [' account_name ']}' '; $ Result2 = mysql_query ($ query2); If (mysql_errno ()) (die ( "error". Mysql_errno ($ link). ":". Mysql_error ($ link));} $ Num_rows2 = mysql_num_rows ($ result2); $ Row2 = mysql_fetch_array ($ result2); $ radius = $ Line2 ['radius']; // is not mentioned that column was in column but it does not make any difference ... it could have value from anywhere. Get the user's letters / logon // Remove white space from the postal code $ query3 = "SELECT * FROM zipData WHERE zipcode = replace ('{$ row2 [ 'postal']} ',' ',' ') "; $ Result3 = mysql_query ($ query3); If (mysql_errno ()) (die. (" error ". Mysql_errno ($ link)": ". Mysql_error ($ Link));} $ Num_rows3 = mysql_num_rows ($ result3); $ Row3 = mysql_fetch_array ($ result3); $ Axis = $ row3 ["lat"]; $ Longitude = $ row3 ["longitude"]; $ Query4 = "ZipData from the store_name, where in shops (paw ((69.1 * (loan - \" $ lon \ ") * cos ($ lat / 57.3)), \" 2 \ ") + pow ((69.1 * (* Lie - \ "$ Lieutenant \"), \ "2 \") & lt; ($ Radius * $ Radius) and Replace (stores .zipcode, '', '') = zipData.zipcode and Shops.shop_name = {$ line ['store_name']} "; $ Result4 = mysql_query ($ query4); If (mysql_errno ()) (die ( "Error". Mysql_errno ($ link). ":". Mysql_error ($ link));} $ Num_rows4 = mysql_num_rows ($ result4); $ Num_jobs = $ num_rows4; $ I 0 = ; while ($ row4 = mysql_fetch_array ($ result4)) {$ Dukanare [$ i] = $ row4 [ "shop_name"]; $ I ++;} Var_dump ($ shopArray);    

            You must be included in the table of stores

              SELECT shop_name FROM zipData, stores WHERE (POW (+ 69.1 * lon - \ "$ lon \") * cos ($ lat / 57.3)), + POW ((69.1 * \ "$ late \"), \ "2 \") & Lt; ($ Radius * $ radius) and stores. Zipcode = zipdata.zipcode    

javascript - Fancybox - Implementing afterClose callback -


My JavaScript syntax is cheaty level, but I am learning: & gt;

I get an inline & lt; Div id = "content" & gt; is using Fancybox 2.1.4 to appear. Traditionally, & lt; Div & gt; will be set to style = "display: none" and Fancybox will be changed to block if enabled, and when none is closed

In my case, I actually did that & lt; Div & gt; On the page there is a visible content in a different place (this is the correct project, I know that there are many opinions that can be there).

So, after disappearing the facebox, after disappearing

Div id = "content" & gt; needs to be placed (which disappears nude from it).

After some research, I came to know that by using the afterClose callback, I just click the id "content" to display: block < / Code> (which resolves the problem.

Problem ... my ugliness is:> I have tried for a lot of time and it is not sure where to put the code, and the correct syntax .

How do I add afterClose to my faxbox function?

  & lt; script type = "text / javascript"> gt; $ ( Document ) .ready (function () {$ (".fancybox"). Fancybox ();}); & lt; / scripts & gt;   

Very much for any help Thank you

This format is: