tag:blogger.com,1999:blog-79770595179334868152024-03-18T11:40:52.748+05:30Viewers ChoiceA Technology BlogAnonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.comBlogger99125tag:blogger.com,1999:blog-7977059517933486815.post-71079585650115035072015-05-25T11:48:00.000+05:302015-05-25T11:48:33.365+05:30How to fix 500 internal privoxy errorI keep getting a 500 Internal Privoxy Error when I open a particular URL. I t<span style="background-color: white; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.25px;">ried several websites that promise a fix but only want to sell me some bullshit software for $29.95 that doesn't do anything.</span><span style="background-color: white; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.25px;"> </span><span style="background-color: white; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.25px;">The actual message is as follows</span><br />
<h2>
500 Internal Privoxy Error</h2>
Privoxy encountered an error while processing your request:<br />
<br />
Could not load template file connect-failed or one of its included components.<br />
<br />
Please contact your proxy administrator.<br />
<br />
If you are the proxy administrator, please put the required file(s)in the (confdir)/templates directory. The location of the (confdir) directory is specified in the main Privoxy config file. (It's typically the Privoxy install directory).<br />
<div>
<br /></div>
<div>
After spending so much of time and putting lots of effort at internet, finally I fixed it. The solutions is -- Disable proxy settings and check.</div>
<div>
<div>
<ol>
<li>Press “Windows Logo” + “R” keys on the keyboard, type “inetcpl.cpl” and press “Enter”.</li>
<li>Click the “Connections” tab, and then click “LAN settings”.</li>
<li>Uncheck the “Use a proxy server for your LAN” check box.</li>
<li>Click “Ok”.</li>
</ol>
</div>
<div>
Please let us know if the issue till persists.</div>
<div>
Thanks.</div>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com17tag:blogger.com,1999:blog-7977059517933486815.post-13739136125450537252015-05-13T18:04:00.001+05:302015-05-13T18:04:22.418+05:30How can you make 10 dollars per day with google Adsense?<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px; margin-right: 0.26cm;">
If you are reading my post, I think that you want to <b>increase your adsense income $0 to $10</b> <b>per day</b>. Most beginning bloggers might earn about one dollar a year. When you have several hundred posts and are starting to attract hundred or more visitors every day, you might see as much as ten dollars per month.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px; margin-right: 0.26cm;">
<br /></div>
<span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">But if you have a popular blog, with thousands</span><b style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;"> high ranking search engine posts</b><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">, and probably at least a thousand visitors each day, it will be able to earn $10 per day with a single blog. That means it’s totally depend on your </span><b style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">quality traffic and search engine ranking</b><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">. Once you learn how to consistently make $10 a day from the Internet you can change your goal to $20 a day and continue to increase your goal until you begin to earn a full-time income working from home.</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">1. How To Make $1 Per Day From Adsense:</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Your blog requires minimum 100 search engine visits and 250 Page views totally per day to reach one dollars daily.</span><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">2. How To Make $5 Per Day From Adsense:</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Your blog requires minimum 1000 search engine visits and 2500 Page views totally per day to reach five dollars daily.</span><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">3. How To Make $10 Per Day From Adsense:</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Your blog requires minimum 2000 search engine visits and 5000 Page views totally per day to reach ten dollars daily.</span><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">4. How To Make $20 Per Day From Adsense:</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Your blogs requires minimum 4000 search engine visits and 10000 Page views totally per day to reach twenty dollars daily.</span><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">5. How To Make $40 Per Day From Adsense:</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Your blog requires minimum 9000 search engine visits and 25000 Page views totally per day to reach fifty dollars daily.</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><strong style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">High Paying Adsense Keywords :</strong><br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">If you have high paying keyword and getting good search engine traffic for particular keyword, then may be two or three clicks enough to earn 10 dollars daily. So keywords are very important part for every blog and make money. Remember, if your blog </span><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">should high paying keywords. Your each click must bring 1-3 dollars per click, that means you can earn $ 5 easily per day from 250 Page views.</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">On the other hand, If you make $10 per day from adsense, create five niche blogs then your aim of making $10 per day can be achieved by making $2 per site everyday.</span><br />
<br style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;" /><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">Get these basic things done right and you will be on </span><b style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">your way to making $10 a day from Google AdSense</b><span style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 12.6099996566772px; line-height: 20.1759986877441px;">.</span>Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com1tag:blogger.com,1999:blog-7977059517933486815.post-23842144291550492592015-03-12T18:27:00.000+05:302015-03-12T18:27:09.475+05:30Modern Business: The Secret to Success<div style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; padding: 0px 0px 15px; text-align: justify;">
Running a successful modern business demands a number of different skills and you, as the business owner, must be ready to organize your time and be prepared to take any shift necessary because in these troubled economic times you are the most responsible figure for the success of your business. Teamwork skills are especially important, and managing the duties of every employee is something you should worry about, but the end line here is that you need to be able to quickly adapt.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/--MxjyInZn_U/VQGL9AbKa6I/AAAAAAAAEOs/14ZfCfooqhE/s1600/150.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/--MxjyInZn_U/VQGL9AbKa6I/AAAAAAAAEOs/14ZfCfooqhE/s1600/150.jpg" height="225" width="400" /></a></div>
<div style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; padding: 0px 0px 15px; text-align: justify;">
<br /></div>
<div style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; padding: 0px 0px 15px; text-align: justify;">
In this economic climate, ups and downs are a natural part of every major business, and some things can move increasingly fast, while others can require a tremendous amount of time to be fully implemented, especially new technologies that are important for your area of work. However, what are the most important aspects you need to work on? Well, there is no magical solution, but we have created a list of things you need to keep your eye on.</div>
<h2 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 30px; margin: 0px 0px 10px; padding: 0px;">
<b>The importance of market research</b></h2>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">Doing proper market research is of </span><a href="http://www.webpronews.com/why-is-market-research-important-2005-08" style="color: #0094d2; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; text-decoration: none;">crucial importance for the success of any business</a><span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;"> endeavor, and that will enable you to make the right decisions, and set a course for your business. IT is all about gathering large amounts of data on whether the customers are satisfied with your products and services, and whether anything can be changed in order to improve the general opinion of your product. This can also be a valuable way of collecting customer experiences, as it is a valuable source of information where you can gauge all those smaller, but necessary factors – what is right and what is not.</span></div>
<div>
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">Setting up and maintaining a good website is easier said than done, but still, there are a number of ways this can be done in a reliable, yet cost-effective way. The website will be your online business card, where all your merchandise will be presented, and this can easily generate revenue for you, and create a base of loyal customers. When combined with all other social media networks, you can easily create an excellent online presence, where people will not only have high opinion of your services, but will think of you as a kind of expert, and will actively seek your opinion. </span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">All the social networks have special options </span><span style="color: #333333; font-family: Droid Sans, sans-serif;"><span style="font-size: 13px; line-height: 22px;">for those willing to pay a little bit in order to advertise their businesses. This can be extremely good for your business, as you can carefully select the categories based on which you will create the target audience. Not to mention how great social networks can be for checking customer feedback, and keeping them engaged by offering them promotions or special offers.</span></span></div>
<div style="text-align: justify;">
<h2 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 30px; margin: 0px 0px 10px; padding: 0px; text-align: start;">
<b><br /></b></h2>
<h2 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 30px; margin: 0px 0px 10px; padding: 0px; text-align: start;">
<b>Outsourcing is your friend</b></h2>
<div>
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; text-align: start;">his is a process of hiring another company to do finish a certain task, either because you are not able to do it yourself financially, or you are understaffed. Outsourcing is a commonly used strategy, even by companies that have large budgets, simply because it offers solutions which are both cost-effective and simple. Outsourcing can actually help your company stay focused on its goals, while internal manpower can be used for other purposes, and this is why outsourcing has great strategic value.</span></div>
<div>
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; text-align: start;"><br /></span></div>
<div>
<h2 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 30px; margin: 0px 0px 10px; padding: 0px; text-align: start;">
<b>Team as the core of any business</b></h2>
</div>
</div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">People that work for you are actually those who are making everything happen, and the important thing is that all of you have the same goal – success. This can be achieved by </span><a href="http://www.entrepreneur.com/article/230982" style="color: #0094d2; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px; text-decoration: none;">proper motivation</a><span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">, because an unhappy worker will not be so interested in his or her performance. Those more active will become tired of time, especially if there are those who are more passive. </span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: 'Droid Sans', sans-serif; font-size: 13px; line-height: 22px;">This can easily be fixed with the introduction of monthly rewards to those who do their best, and it can easily increase work efficiency, as everyone will try to reach the same level of acknowledgment. Make sure to balance between teamwork and competition, as both of those can be used to create a healthy environment, which will help your business.</span></div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0tag:blogger.com,1999:blog-7977059517933486815.post-64735711474044334732014-07-17T16:39:00.003+05:302015-03-12T18:18:13.662+05:30Why your business should go Social<div style="text-align: justify;">
Word of mouth marketing is as old as business itself.
Consumers have always relied on conversations over the back fence and around the water cooler when making a
decision about the products and services they need, social media is about that conversation, it may change the fence but the idea remains.
Social media marketing gets your name in the minds of your friends and your friend's friends, easier and for less cost than traditional means.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-bSfC_eCSPWw/VQGK_N6pI1I/AAAAAAAAEOk/ng0FTL3hW98/s1600/why-your-business-must-go-social.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-bSfC_eCSPWw/VQGK_N6pI1I/AAAAAAAAEOk/ng0FTL3hW98/s1600/why-your-business-must-go-social.png" height="263" width="320" /></a></div>
<br />
<br />
Social Media marketing is about using the tools provided by social sites to build a repuation and create a buzz for you and your business,
it is about establishing yourself as an expert so people will recommend you in conversations over backyard fences and in online interactions.
<br />
<h4>
Same Old Word-of-Mouth Marketing
</h4>
Social Media has changed the way people connect, discover, and share information. Here’s what you need to know:
<br />
<ul>
<li>Social media is the technology that connects people—whether it’s to share content or just to chat.</li>
<li>Social networks, like Facebook, Twitter, LinkedIn, Instagram and Pinterest are the places where social interactions happen (discovering & sharing).</li>
<li>Social media marketing is the way to use that technology to build relationships, drive repeat business. and attract new customers through friends sharing with friends.</li>
<li>Sound familiar? That’s because social media marketing is really just word-of-mouth powered by technology.</li>
</ul>
<h4>
Still not convinced? Here are some quick pointers: </h4>
<ul>
<li>Consider this: 35% of the world’s population is online and the internet as a marketing channel reaches the largest number of people from varied demographics </li>
<li>The channel requires a low technical investment, has a great ROI and a low learning curve </li>
<li>It is a fairly simple way to increase your website traffic and search engine ranking </li>
<li>Lead generation and, thereby, sales can be improved </li>
<li>Connecting with media becomes easier </li>
<li>Promoting events becomes quicker and more effective </li>
<li>58% of small business owners reported a decrease in marketing costs after they migrated to social media</li>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-4554187160997319812013-03-19T11:42:00.001+05:302014-07-17T12:15:06.965+05:30create filter in controller symfony2<div style="text-align: justify;">
Sometimes you need to make changes to the Response object, after it is returned by your controller,
but before it is rendered as output to the client (e.g. the browser). You may want to set some extra
response headers, or "<b>completely mess up the content</b>" of the response. You can accomplish this by
creating an event listener that listens to the <code style="background: #f0f0f0; color: #009900;">kernel.response</code>
event. I give you a sample event listener which changes the <code style="background: #f0f0f0; color: #009900;">Content-Type</code>
header in case the requested format is json and the browser’s accepted response format contains "text/html" in that case, at least in my experience,
the browser doesn’t render the JSON string as plain text when the status code is 4xx or 5xx. So in
these situations, the event listener changes the “<b>Content-Type</b>” to “<b>text/plain</b>”, to be sure you always
get decent output in the browser.
<br />
<br />
Put the event listener in, for example <span style="background: #f0f0f0; color: #009900;">/src/Acme/DemoBundle/EventListener/ResponseListener.php</span>:
<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
namespace Acme\DemoBundle\EventListener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
class ResponseListener
{
public function onKernelResponse(FilterResponseEvent $event)
{
$request = $event->getRequest();
// only do something when the requested format is "json"
if ($request->getRequestFormat() != 'json') {
return;
}
// only do something when the client accepts "text/html" as response format
if (false === strpos($request->headers->get('Accept'), 'text/html')) {
return;
}
// set the "Content-Type" header of the response
$event->getResponse()->headers->set('Content-Type', 'text/plain');
}
}
</code></pre>
<br />
Now define the ResponseListener as a service in <code style="background-color: #f0f0f0; color: #009900;">/src/Acme/DemoBundle/Resources/services.xml</code>:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.filter_response_listener" class="Acme\DemoBundle\EventListener\ResponseListener">
<tag name="kernel.event_listener" event="kernel.response" method="onKernelResponse" />
</service>
</services>
</container>
</code></pre>
<br />
<br />
Notice the “tag” tag, by which the kernel recognizes this service as an event listener. The event attribute tells the
kernel which event this listener listens to. The “method” attribute tells which method should be called when the
<code style="background: #f0f0f0; color: #009900;">kernel.response</code> event occurs.
<br />
<br />
In case you don’t want any other events to tamper with the Response, add a call to <code style="background: #f0f0f0; color: #009900;">$event->stopPropagation().</code>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com1tag:blogger.com,1999:blog-7977059517933486815.post-63361382309922314192013-03-15T14:19:00.002+05:302013-03-15T14:19:44.263+05:30remove non ASCII characters from a StringHi guys<br />
<br />
I had a problem with removing non-utf8 characters from string, which are not displaying properly. Characters are like this 0x97 0x61 0x6C 0x6F (hex representation).<br />
<br />
I am getting some encoded value from url. Let assume it's encoded email and value is <code style="background: #f0f0f0; color: #009900;">ankitchauhan22@gmail.com</code><br />
When I tried to find out the length of this string as
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$email = somefunction($encodedStringFromUrl);
$length = strlen($email);
print $length;
</code>
</pre>
I was shocked. It's printing 37 instead of 24. Than I printed each index of this string on the string but after 24 character, nothing printed.
<br />
<br />
I used <code style="background: #f0f0f0; color: #009900;">trim()</code> to remove whitespace but didn't work.<br />
<br />
Then I tried something which worked for me.<br />
<br />
This is a little snippet that will remove any non-ASCII characters from a string.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$string = "ankitchauhan22@gmail.com äó";
$string = preg_replace('/[^(\x20-\x7F)]*/','', $string);
</code>
</pre>
Now It's printing 24.Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-61500938481560261692013-03-13T18:14:00.000+05:302013-03-13T18:49:40.810+05:30jQuery & JavaScript PDF Viewer plugin <div id="blog-content" style="text-align: justify;">
Hi guys<br />
<br />
In this Post I'm providing best jQuery PDF viewer plugin & tutorial with examples. Due to popularity of online document viewer like Google Docs some javascript developers develop a good and useful plugins to view pdf file on online pdf viewer.Here is some good list of online pdf viewers.
<br />
<br />
<ol>
<li><b>JavaScript PDF Reader : pdf.js</b><br />
It's an HTML5 experiment that explores building a faithful and efficient PDF renderer without native code assistance.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-vTm5DzkNrk4/UUBznOjxGqI/AAAAAAAABNc/peMtAHTOfHI/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="pdf.js" border="0" src="http://3.bp.blogspot.com/-vTm5DzkNrk4/UUBznOjxGqI/AAAAAAAABNc/peMtAHTOfHI/s1600/a.jpg" height="171" title="pdf.js" width="320" /></a></div>
<a class="readlink" href="https://github.com/mozilla/pdf.js" target="_blank" title="Read More Link">Read More</a> <a class="readlink" href="http://mozilla.github.com/pdf.js/web/viewer.html" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>jQuery Media Plugin</b><br />
The jQuery Media Plugin supports unobtrusive conversion of standard markup into rich media content. It can be used to embed virtually any media type, including Flash, Quicktime, Windows Media Player, Real Player, MP3, Silverlight, PDF and more, into a web page and is compatible with all web hosting services The plugin converts an element which holds the object, embed iframe tags neccessary to render the media content.<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-zODB5l5vRm0/UUB2mDR2J_I/AAAAAAAABNs/OkbltcB2rHE/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="jQuery Media Plugin" border="0" src="http://2.bp.blogspot.com/-zODB5l5vRm0/UUB2mDR2J_I/AAAAAAAABNs/OkbltcB2rHE/s1600/a.jpg" height="192" title="jQuery Media Plugin" width="320" /></a></div>
<a class="readlink" href="http://jquery.malsup.com/media/misc.html" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>PDFObject : Embeds PDF files into HTML documents</b><br />
A JavaScript library for dynamically embedding PDFs in HTML documents. Modeled after SWFObject.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-FKt3yXyEvWQ/UUB3bz7CmgI/AAAAAAAABN4/w_41JLYv3WI/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Embeds PDF files into HTML documents" border="0" src="http://3.bp.blogspot.com/-FKt3yXyEvWQ/UUB3bz7CmgI/AAAAAAAABN4/w_41JLYv3WI/s1600/a.jpg" height="199" title="Embeds PDF files into HTML documents" width="320" /></a></div>
<a class="readlink" href="http://pdfobject.com/examples/index.php" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>Google Docs Viewer plugin for jQuery</b><br />
The Google Docs Viewer is an embeddable browser-based viewer that requires only a URL to a file available online. This neatly bypasses the need for users to have compatible software on their machines for those file types and displays the document right in the browser.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-8K425BYJAJc/UUB55nlYPXI/AAAAAAAABOI/FHwJRHP5P6A/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Google Docs Viewer plugin for jQuery" border="0" src="http://4.bp.blogspot.com/-8K425BYJAJc/UUB55nlYPXI/AAAAAAAABOI/FHwJRHP5P6A/s1600/a.jpg" height="160" width="320" /></a></div>
<a class="readlink" href="http://www.jawish.org/blog/archives/394-Google-Docs-Viewer-plugin-for-jQuery.html" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>ZOHO Viewer plugin for jQuery</b><br />
The ZOHO Viewer is an embeddable browser-based viewer that requires only a URL to a file available online. This, just like Google Docs Viewer, bypasses the need for users to have compatible software on their machines for those file types and displays the document right in the browser. Automatically embeds the ZOHO viewer for viewing the doc, docx, xls, xlsx, ppt, pptx, pps, odt, ods, odp, sxw, sxc, sxi, wpd, pdf, rtf, txt, html, csv, tsv files it supports linked to by anchor tags.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-rGm2lZyX2Qg/UUB7yoMzMCI/AAAAAAAABOU/hfRZjoH79tI/s1600/a.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="ZOHO Viewer plugin for jQuery" border="0" src="http://4.bp.blogspot.com/-rGm2lZyX2Qg/UUB7yoMzMCI/AAAAAAAABOU/hfRZjoH79tI/s1600/a.jpeg" height="96" title="ZOHO Viewer plugin for jQuery" width="320" /></a></div>
<a class="readlink" href="http://www.jawish.org/blog/uploads/jquery.zohoviewer_demo.html" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>jsPDF : Generate PDF files using pure client-side JavaScript</b><br />
It is an open-source library written by our lead developer, James, for generating PDF documents using nothing but JavaScript. You can use it in a Firefox extension, in Server Side JavaScript and with Data URIs in some browsers.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-eKBgmYT42JA/UUB8wwu5OyI/AAAAAAAABOo/4QqpAXEX8oU/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="jsPDF : Generate PDF files using pure client-side JavaScript" border="0" src="http://1.bp.blogspot.com/-eKBgmYT42JA/UUB8wwu5OyI/AAAAAAAABOo/4QqpAXEX8oU/s1600/a.jpg" height="217" title="jsPDF : Generate PDF files using pure client-side JavaScript" width="320" /></a></div>
<a class="readlink" href="http://jspdf.com/" target="_blank" title="Demo Link">Demo</a>
</li>
<li><b>jQuery Document Viewer</b><br />
Document Viewer is a jQuery plugin that allows you to view several file formats directly in a web page.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-gEKYb1MDs74/UUB8TdY_ZgI/AAAAAAAABOc/QMclc0AGyFM/s1600/a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="jQuery Document Viewer" border="0" src="http://4.bp.blogspot.com/-gEKYb1MDs74/UUB8TdY_ZgI/AAAAAAAABOc/QMclc0AGyFM/s1600/a.jpg" height="206" title="jQuery Document Viewer" width="400" /></a></div>
<a class="readlink" href="http://codecanyon.net/item/jquery-document-viewer/1732515" target="_blank" title="Read More Link">Read More</a>
<a class="readlink" href="http://codecanyon.net/item/jquery-document-viewer/full_screen_preview/1732515" target="_blank" title="Demo Link">Demo</a>
</li>
</ol>
</div>
<style>
#blog-content a.readlink {
background: none repeat scroll 0 0 #DC005A;
border: 1px solid #DC005A !important;
border-radius: 3px 3px 3px 3px;
color: #FFFFFF;
display: block;
font: bold 11px/130% Arial,Helvetica,sans-serif;
margin: 0 7px 0 0;
padding: 2px 7px;
text-decoration: none;
float:left;
}
#blog-content li{width:100%;float:left;margin-bottom: 13px;}
</style>Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com7Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-6464839978844068412013-03-12T11:00:00.000+05:302013-03-13T11:12:25.228+05:30css3 tips and tricks collection<div id="blog-content">
You can never have too much of a good thing–and two good things we rely on in our work are tips and tricks. Nuggets of information, presented clearly and succinctly, help us build solutions and learn best practices.
<br />
<br />
CSS level 3 has been under development since December 15, 2005. CSS3 is modularized and consists of several separate recommendations. CSS3 is one of the more exciting and versatile developments for the web in some time. In this article I am going to create a huge list of CSS3 Tips, Tricks and Tutorials for Web Developers.
<br />
<br />
Useful Link : Be updated with these
<br />
<ol>
<li><a href="http://www.red-team-design.com/feature-table-design-with-css3" target="_blank">Featured Table Design With CSS3</a></li>
<li><a href="http://sixrevisions.com/css/basic-css3-techniques-that-you-should-know/" target="_blank">Basic CSS3 Techniques That You Should Know</a></li>
<li><a href="http://tutorialzine.com/2010/10/css3-animated-bubble-buttons/" target="_blank">CSS3 Animated Bubble Buttons</a></li>
<li><a href="http://sixrevisions.com/css/how-to-create-css3-christmas-tree-ornaments/" target="_blank">How To Create CSS3 Christmas Tree Ornaments</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-new-html5-form-features/" target="_blank">Quick Tip : New HTML5 Form Features</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/the-state-of-css3-in-email-templates/" target="_blank">The State Of CSS3 In Email Templates</a></li>
<li><a href="http://webstandard.kulando.de/post/2010/03/05/css3-transition-tutorial-menu-mit-slide-effekt-im-apple-style" target="_blank">CSS3 Transition Tutorial – Menü mit Slide-Effekt im Apple-Style</a></li>
<li><a href="http://sixrevisions.com/css/semantic-css3-lightboxes/" target="_blank">Semantic CSS3 Lightboxes</a></li>
<li><a href="http://blog.anomalyinnovations.com/2010/03/creating-a-realistic-looking-button-with-css3/" target="_blank">Creating A Realistic Looking Button With CSS3</a></li>
<li><a href="http://www.webdesignerwall.com/tutorials/css3-gradient-buttons/" target="_blank">CSS3 Gradient Buttons</a></li>
<li><a href="http://nicolasgallagher.com/pure-css-speech-bubbles/" target="_blank">Pure CSS3 Speech Bubbles</a></li>
<li><a href="http://owltastic.com/2009/12/shadows-and-css3/" target="_blank">Shadows And CSS3</a></li>
<li><a href="http://pushingpixels.at/experiments/dynamic_shadow/" target="_blank">Dynamic PNG Shadow Position And Opacity</a></li>
<li><a href="http://www.smashingmagazine.com/2009/06/15/take-your-design-to-the-next-level-with-css3/" target="_blank">Take Your Design To The Next Level With CSS3</a></li>
<li><a href="http://www.red-team-design.com/css3-font-face-or-how-to-use-a-custom-font-for-your-website" target="_blank">CSS3 Font-Face Or How To Use A Custom Font For Your Website</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/css-fundametals-css-3-transitions/" target="_blank">CSS3 Fundaments – CSS3 Transitions</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/design-a-prettier-web-form-with-css-3/" target="_blank">Design A Prettier Web Form With CSS3</a></li>
<li><a href="http://net.tutsplus.com/articles/news/create-a-sticky-note-effect-in-5-easy-steps-with-css3-and-html5/" target="_blank">Create A Sticky Note In 5 Easy Steps With CSS3 And HTML5</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-the-multi-column-css3-module/" target="_blank">Quick Tip : The Multi Column CSS3 Module</a></li>
<li><a href="http://www.noupe.com/css3/css3-exciting-functions-and-features-30-useful-tutorials.html" target="_blank">Exciting Functions And Features</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-understanding-css3-gradients/" target="_blank">Quick Tip : Understanding CSS3 Gradients</a></li>
<li><a href="http://sixrevisions.com/css/how-to-create-inset-typography-with-css3/" target="_blank">How To Create Inset Typography With CSS3</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/build-awesome-practical-css3-buttons/" target="_blank">Build Awesome Practical CSS3 Buttons</a></li>
<li><a href="http://net.tutsplus.com/tutorials/html-css-techniques/the-state-of-css3/" target="_blank">The State Of CSS3</a></li>
<li><a href="http://www.red-team-design.com/css-gradients-quick-tutorial" target="_blank">CSS3 Gradients : Quick Tutorial</a></li>
<li><a href="http://cssglobe.com/post/6089/3-easy-and-fast-css-techniques-for-faux-image" target="_blank">Easy And Fast CSS3 Techniques For Faux Image Cropping</a></li>
<li><a href="http://bluefaqs.com/2010/03/understanding-the-basics-of-css3/" target="_blank">Understanding The Basics Of CSS3</a></li>
<li><a href="http://www.smashingmagazine.com/2010/04/28/css3-solutions-for-internet-explorer/" target="_blank">CSS3 Solutions for Internet Explorer</a></li>
<li><a href="http://www.1stwebdesigner.com/tutorials/how-to-use-css3-orientation-media-queries/" target="_blank">How To Use CSS3 Orientation Media Queries</a></li>
<li><a href="http://samuli.hakoniemi.net/css3-transitions-are-we-there-yet/" target="_blank">CSS3 Transitions – Are We There Yet?</a></li>
<li><a href="http://designshack.co.uk/articles/css/create-a-color-changing-website-using-css3" target="_blank">Create A Color Changing Website Using CSS3</a></li>
<li><a href="http://www.webstuffshare.com/2010/04/photoshop-effect-vs-css3-properties/" target="_blank">Photoshop Effect vs CSS3 Properties</a></li>
<li><a href="http://www.devlounge.net/design/10-awesome-css3-techniques-to-improve-your-designs" target="_blank">10 Awesome CSS3 Techniques To Improve Your Design</a></li>
<li><a href="http://www.cssnewbie.com/cross-browser-rounded-buttons/" target="_blank">Cross- Browser Rounded Buttons With CSS3 And jQuery</a></li>
<li><a href="http://www.webstuffshare.com/2010/04/stylize-input-element-using-css3/" target="_blank">Stylize Input Element Using CSS3</a></li>
<li><a href="http://tutorialzine.com/2010/04/slideout-context-tips-jquery-css3/" target="_blank">Contextual Slideout Tips With CSS3 And jQuery</a></li>
<li><a href="http://www.smashingmagazine.com/2009/01/08/push-your-web-design-into-the-future-with-css3/" target="_blank">Push Your Web Design Into The Future With CSS3</a></li>
<li><a href="http://inspectelement.com/tutorials/a-look-at-some-of-the-new-selectors-introduced-in-css3/" target="_blank">A Look At Some Of The New Selectors Introduced In CSS3</a></li>
<li><a href="http://www.smashingmagazine.com/2009/07/13/css-3-cheat-sheet-pdf/" target="_blank">CSS3 Cheat Sheet (Pdf)</a></li>
<li><a href="http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba" target="_blank">Super Awesome Buttons With CSS3 And RGBA</a></li>
<li><a href="http://www.bloggingcss.com/en/tutorials/the-css3-border-radius-property/" target="_blank">CSS3 Border Radius Property</a></li>
<li><a href="http://www.javascriptkit.com/dhtmltutors/structuralcss.shtml" target="_blank">Overview Of CSS3 Structural Pseudo- Classes</a></li>
<li><a href="http://tutorialzine.com/2010/01/sweet-tabs-jquery-ajax-css/" target="_blank">Sweet Ajax Tabs With jQuery And CSS3</a></li>
<li><a href="http://www.pvmgarage.com/en/2010/01/how-to-create-depth-and-nice-3d-ribbons-only-using-css3/" target="_blank">3D Ribbons Only Using CSS3</a></li>
<li><a href="http://snook.ca/archives/html_and_css/css-text-rotation" target="_blank">Text Rotations With CSS3</a></li>
<li><a href="http://css-tricks.com/css3-clock/" target="_blank">Old School Clock With CSS3 And jQuery</a></li>
<li><a href="http://css-tricks.com/video-screencasts/74-editable-css3-image-gallery/" target="_blank">Editable CSS3 Image Gallery</a></li>
<li><a href="http://www.webdesignerwall.com/tutorials/css3-dropdown-menu/" target="_blank">Drop Down Menu Tutorial</a></li>
<li><a href="http://www.zenelements.co.uk/blog/css3-multiple-columns/" target="_blank">Multiple Columns</a></li>
<li><a href="http://group.mind-productions.com/articles/multiple_backgrounds__css3_/" target="_blank">Multiple Backgrounds</a></li>
<li><a href="http://www.thecssninja.com/css/accordian-effect-using-css" target="_blank">Create The Accordion Effect With CSS3</a></li>
<li><a href="http://www.exforsys.com/tutorials/css3/css3-opacity.html" target="_blank">CSS3 Opacity</a></li>
<li><a href="http://www.marcofolio.net/webdesign/creating_a_polaroid_photo_viewer_with_css3_and_jquery.html" target="_blank">Create A Polaroid Photo Viewer With CSS3 And jQuery</a></li>
<li><a href="http://www.marcofolio.net/webdesign/creating_a_polaroid_photo_viewer_with_css3_and_jquery.html" target="_blank">Sweet Tabbed Navigation Bar Using CSS3</a></li>
<li><a href="http://24ways.org/2006/rounded-corner-boxes-the-css3-way" target="_blank">Rounded Corner Boxes</a></li>
<li><a href="http://net.tutsplus.com/videos/screencasts/a-crash-course-in-advanced-css3-effects/" target="_blank">A Crash Course In Advanced CSS3 Effects</a></li>
<li><a href="http://tutorialzine.com/2010/01/halftone-navigation-menu-jquery-css/" target="_blank">Halftone Navigation Menu With CSS3 And jQuery</a></li>
<li><a href="http://www.zurb.com/playground/awesome-overlays" target="_blank">Awesome Overlays In CSS3</a></li>
<li><a href="http://www.skyrocketlabs.com/articles/css3-web-form-hints.php" target="_blank">Fancy Web Form With Field Hints Using Only CSS3</a></li>
<li><a href="http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/" target="_blank">CSS3 Gradients : No Image Aqua Button</a></li>
<li><a href="http://www.css3.info/preview/box-shadow/" target="_blank">Box Shadows</a></li>
<li><a href="http://www.1stwebdesigner.com/tutorials/how-to-use-css3-orientation-media-queries/" target="_blank">How To Use CSS3 Orientation Media Queries</a></li>
<li><a href="http://bluefaqs.com/2010/04/a-handful-of-css-trends-and-how-to-use-them/" target="_blank">A Handful Of CSS3 Trends And How To Use Them</a></li>
<li><a href="http://hacks.mozilla.org/2010/04/the-css-3-flexible-box-model/" target="_blank">The CSS3 Flexible Box Model</a></li>
<li><a href="http://inspectelement.com/tutorials/a-look-at-some-of-the-new-selectors-introduced-in-css3/" target="_blank">Selectors Introduced In CSS3</a></li>
<li><a href="http://www.queness.com/post/1696/create-a-beautiful-looking-custom-dialog-box-with-jquery-and-css3" target="_blank">Create A Beautiful Looking Custom Dialog Box With jQuery And CSS3</a></li>
<li><a href="http://www.netmag.co.uk/zine/develop-css/get-the-best-out-of-css3" target="_blank">Get The Best Out Of CSS3</a></li>
<li><a href="http://mattwilcox.net/archive/entry/id/1031/" target="_blank">Fundamental Problems With CSS3</a></li>
<li><a href="http://papermashup.com/pretty-css3-buttons/" target="_blank">Pretty CSS3 Buttons</a></li>
<li><a href="http://24ways.org/2009/going-nuts-with-css-transitions" target="_blank">Going Nuts With CSS3 Transitions</a></li>
</ol>
</div>
<style type="text/css">
#blog-content{text-align:justify;}
#blog-content a{text-decoration:none;color: #41B7D8;}
#blog-content a:hover{text-decoration:none;color: #41B7D8;font-weight:bold;}
</style>Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com3Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-91072774362938440272013-03-11T11:45:00.000+05:302013-03-11T11:45:33.823+05:30speed up symfony2 application with varnish<div style="text-align: justify;">
Hi everyone,<br />
<br />
Just a quick note about Varnish integration for symfony. I’m sure you have heard of Varnish reverse proxy server.<br />
<blockquote class="tr_bq">
Varnish is a web accelerator written with performance and flexibility in mind. It’s modern architecture gives it a significantly better performance than many of it’s competing products. Varnish store web pages in memory so the web servers don’t have to create the same web page over and over again. The web server only recreate a page when it is changed. Additionally Varnish can serve web pages much faster then any application server is capable of – giving the website a significant speed up.
</blockquote>
So in first order you may be interested to integrate Varnish to handle pages which don’t require authentication (for myself I’m still not sure if there is any advantage for integrating pages for logged in users):
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
sub vcl_recv {
set req.http.Surrogate-Capability = "abc=ESI/1.0";
}
sub vcl_fetch {
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
unset beresp.http.Surrogate-Control;
set beresp.do_esi = true;
}
}
</code>
</pre>
Symfony2's cache uses the standard HTTP cache headers, the Symfony2 Reverse Proxy can easily be replaced with any other reverse proxy. Varnish is a powerful, open-source, HTTP accelerator capable of serving cached content quickly and including support for Edge Side Includes.</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-9835116355592212512013-03-08T15:00:00.000+05:302013-03-08T15:00:00.248+05:30Creating a PrestaShop moduleA PrestaShop module consists of:<br />
<ul>
<li>A root folder, named after the module, which will hold all of the module's files, and will reside in PrestaShop's /modules folder.</li>
<li>A main PHP file, named after the module, located in that root folder. This PHP file should have the same name as its root folder.</li>
<li>An icon file, named logo.gif, representing this module.</li>
<li>Optional: some .tpl files, containing the module's theme.</li>
<li>Optional: language files, if the module or its theme have text to display (and therefore, that should be translatable).</li>
<li>Optional: in a /themes/modules folder, a folder with the same name as the module, containing .tpl and language files if necessary. This last folder is essential during modifications of existing module, so that you can adapt it without having to touch its original files. Notably, it enables you to handle the module's display in various ways, according to the current theme.</li>
</ul>
<div>
Now I am going to create a module named Testmodule.<br />
<br />
Your module can be called anything you like. My module will be called Testmoduleas that is what is will be doing - taking off line payments. So create a directory under your PrestaShop. <br />
<br />
C:\wamp\www\prestashop\modules\Testmodule see below for an example:-</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/--6DjJ7Uli28/UTmsZfQ6LBI/AAAAAAAABM0/US2Syblo3gA/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="prestashop folder" border="0" src="http://1.bp.blogspot.com/--6DjJ7Uli28/UTmsZfQ6LBI/AAAAAAAABM0/US2Syblo3gA/s1600/Capture.PNG" height="122" title="prestashop folder" width="400" /></a></div>
<h3>
Create your module's "class" .php file</h3>
PrestaShop modules must have one php file which contains the Class definition. This class definition contains the core functions of your module. The file needs to be given the same name as your module so in my case it must called testmodule.php and it needs to live in the root of the modules directory.<br />
<br />
Every PrestaShop module has to consist of three necessary functions:
<br />
<ol>
<li><b>__construct()</b> – here you provide all the information about your module – module name, version and description which are visible in the backend. In addition, you can choose in which tab to show your module, for example, Products.</li>
<li><b>install()</b> – this function also does not have parameters, but is very important. Here you have to register all the hooks you will be using, create necessary database table changes (create, add columns, prepare it and so on) and initiate default module options.</li>
<li><b>uninstall()</b> – the same as above, except here you have to delete all your tables if necessary. Do not forget to delete configuration options too.</li>
</ol>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
class TestModule extends SomeModule {
//this declares the class and specifies it will extend the some module
private $_html = '';
private $_postErrors = array();
function __construct()
{
$this->name = 'testmodule';
$this->tab = others;
$this->version = 1;
$this->author = 'Ankit Chauhan';
parent::__construct(); // The parent construct is required for translations
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Test Module');
$this->description = $this->l('Testing module check');
}
function install()
{
// your code here
}
function unstall()
{
// your code here
}
}
</code>
</pre>
<br />
Now you can upload everything to your server and install module from the backend.Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com1Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-84890479574286956132013-03-01T15:15:00.000+05:302013-03-01T15:42:27.924+05:30Styling Progress Bar With HTML5<style type="text/css">
.demo-wrapper {
width: 300px;
margin: 30px auto 0;
}
.html5-progress-bar {
padding: 15px 15px;
border-radius: 3px;
background-color: #fff;
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, .2);
}
.html5-progress-bar progress {
background-color: #f3f3f3;
border: 0;
width: 80%;
height: 18px;
border-radius: 9px;
}
.html5-progress-bar progress::-webkit-progress-bar {
background-color: #f3f3f3;
border-radius: 9px;
}
.html5-progress-bar progress::-webkit-progress-value {
background: #cdeb8e;
background: -moz-linear-gradient(top, #cdeb8e 0%, #a5c956 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#a5c956));
background: -webkit-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: -o-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: -ms-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: linear-gradient(to bottom, #cdeb8e 0%,#a5c956 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cdeb8e', endColorstr='#a5c956',GradientType=0 );
border-radius: 9px;
}
.html5-progress-bar progress::-moz-progress-bar {
background: #cdeb8e;
background: -moz-linear-gradient(top, #cdeb8e 0%, #a5c956 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#a5c956));
background: -webkit-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: -o-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: -ms-linear-gradient(top, #cdeb8e 0%,#a5c956 100%);
background: linear-gradient(to bottom, #cdeb8e 0%,#a5c956 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cdeb8e', endColorstr='#a5c956',GradientType=0 );
border-radius: 9px;
}
.html5-progress-bar .progress-value {
padding: 0px 5px;
line-height: 20px;
margin-left: 5px;
font-size: .8em;
color: #555;
height: 18px;
float: right;
}
</style>
<div class="demo-wrapper html5-progress-bar">
<div class="progress-bar-wrapper">
<progress id="progressbar" value="0" max="100"></progress>
<span class="progress-value">0%</span>
</div>
<button id="reload" style="margin-top: 15px; background-color: rgb(255, 255, 255); box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.2);">Reload</button>
</div>
<script src="https://sites.google.com/site/ankitchauhan22/modernizr.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
if(!Modernizr.meter){
alert('Sorry your brower does not support HTML5 progress bar');
} else {
_startLoading();
$('#reload').click(function(){
$('#progressbar').val(0);
_startLoading();
});
};
function _startLoading() {
var progressbar = $('#progressbar'),
max = progressbar.attr('max'),
time = (1000/max)*5,
value = progressbar.val();
var loading = function() {
value += 1;
addValue = progressbar.val(value);
$('.progress-value').html(value + '%');
if (value == max) {
clearInterval(animate);
}
};
var animate = setInterval(function() {
loading();
}, time);
}
});
</script>
<br />
<div style="text-align: justify;">
HTML5 introduced the progress bar element, which allows us to show the progress of certain tasks, like uploads or downloads, basically anything that is in progress
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-yFSKo8Q4_ns/UTBuMRJKDbI/AAAAAAAABME/tyA-WGI8ebU/s1600/progress-bar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="progress bar" border="0" src="http://3.bp.blogspot.com/-yFSKo8Q4_ns/UTBuMRJKDbI/AAAAAAAABME/tyA-WGI8ebU/s1600/progress-bar.png" height="89" title="progress bar" width="320" /></a></div>
<h4>
Basic Usage</h4>
The progress bar can be added with <code style="background-color: #ececec; font: .95em/1.5 'andale mono','lucida console',monospace; text-shadow: 1px 1px #fff;"><progress></code>; the progress value is determined with the value, min and max attributes, as follows.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<progress value="40" max="100"></progress>
</code>
</pre>
<br />
Since this is a native progress bar, the presentation is vary dependent on the platform. Below is how a native progress bar looks in Windows and OSX.<br />
<br />
<progress max="100" value="40"></progress><br />
<br />
Now, let's try styling this progress bar, so it has a consistent or similar look across all platform.
<br />
<h4>
Styling Progress Bar</h4>
In the stylesheet, we actually can use the element selector to target and add style rules to <code><progress></code> element. In this example, we change the background color, remove the border line, and make it rounded by adding a border radius at half of its height.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
progress {
background-color: #f3f3f3;
border: 0;
height: 18px;
border-radius: 9px;
}
</code>
</pre>
However, each browser handles this a bit differently.<br />
<br />
In <b>Firefox</b>, the styles affect the progress bar, while the progress meter / value is not affected.<br />
<br />
In <b>Chrome and Safari</b>, it will remove the native styles and presentation from the platform and replace it with the <b>Webkit styleshee</b>t, the styles above will not be applied (at least, at the moment).<br />
<br />
So, we need some more workaround in these cases.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-_oFRp68WIhE/UTB0GkyzbVI/AAAAAAAABMU/gvPxu8WRbKU/s1600/progress-styles.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="progress style" border="0" src="http://1.bp.blogspot.com/-_oFRp68WIhE/UTB0GkyzbVI/AAAAAAAABMU/gvPxu8WRbKU/s1600/progress-styles.jpg" height="202" title="progress style" width="320" /></a></div>
<br />
In Chrome and Safari, the progress element is translated this way.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<progress>
┗ <div> ::-webkit-progress-bar
┗ <div> ::-webkit-progress-value
</code>
</pre>
Thus, to change the progress bar and the progress value styles in these browsers, we need to add those Webkit pseudo-classes.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
progress::-webkit-progress-bar {
/* style rules */
}
progress::-webkit-progress-value {
/* style rules */
}
</code>
</pre>
Firefox also has its special pseudo-class that is ::-moz-progress-bar. Unlike Chrome and Safari, this pseudo-class in Firefox refers to the progress meter/value.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
progress::-moz-progress-bar {
/* style rules */
}
</code>
</pre>
To conclude, these are currently the entire selectors for styling HTML5 progress bar.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
progress {
/* style rules */
}
progress::-webkit-progress-bar {
/* style rules */
}
progress::-webkit-progress-value {
/* style rules */
}
progress::-moz-progress-bar {
/* style rules */
}
</code>
</pre>
<h4>
Animate The Progress</h4>
Next, we will see how to animate the progress bar. Typically, the progress bar expands from left to right as the task progresses.
<br />
<br />
The idea is, the progress bar will expand from 0 and stop once it reaches the maximum value. We will also display the value number as it is progressing. Below is the HTML structure.<br />
<b><br /></b>
<b>HTML</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<progress id="progressbar" value="0" max="100"></progress>
</code>
</pre>
<b><br /></b>
<b>CSS</b><br />
<br />
In this example, we will use jQuery to animate the progress bar. So, we should also not forget to insert the jQuery, like so.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<script src="path_to_folder/jquery.js" type="text/javascript"></script>
</code>
</pre>
Then, we add the scripts to make the progress bar expand. First, we store the progress bar element, the progressbar value as well the maximum value, and the timeframe, in Variables.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
var progressbar = $('#progressbar'),
max = progressbar.attr('max'),
value = progressbar.val(),
time = (1000/max)*5;
</code>
</pre>
Next, we create a variable that store the animation function. In this example, we call the variable loading.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
var loading = function() {
}
</code>
</pre>
Inside the above function, we set the progress interval. We will increase the value by 1 per timeframe — you can increase the value to make the progress run faster.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
value += 1;
</code>
</pre>
And then, we add the result to the progress bar.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
addValue = progressbar.val(value);
</code>
</pre>
We also show the value inside, next to the progress bar.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$('.progress-value').html(value + '%');
</code>
</pre>
Next, we create a new function to run the animation function.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
setInterval(function() {
loading();
}, time);
</code>
</pre>
At this point, the animation is already functioning. However, the value will keep increasing infinitely. So, we need to create a conditional statement for the animation to stop when it reaches its maximum value.
<br />
First, let's store the above function in a variable like so.
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
var animate = setInterval(function() {
loading();
},
</code>
</pre>
And, inside the loading variable, we add the conditional statement, as follow.
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
if (value == max) {
clearInterval(animate);
}
</code>
</pre>
The above script states that once the value is equal to the maximum value, clear the interval, which will stop the animation function.
<br />
That's it and here are all the codes to animate the progress bar.
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$(document).ready(function() {
var progressbar = $('#progressbar'),
max = progressbar.attr('max'),
time = (1000/max)*5,
value = progressbar.val();
var loading = function() {
value += 1;
addValue = progressbar.val(value);
$('.progress-value').html(value + '%');
if (value == max) {
clearInterval(animate);
}
};
var animate = setInterval(function() {
loading();
}, time);
};
</code>
</pre>
<br /><br /><br />
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-29342581212495880532013-02-27T14:05:00.000+05:302013-02-27T14:06:48.360+05:30creating stick stylish button using css3<style type="text/css">
.css3 a{
padding: 6px 12px;
margin: 4px;
color: #fff;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 12px;
text-shadow: 1px 1px 2px #000;
text-decoration: none;
font-weight: bold;
line-height: 3em;
}
.gradient {
background-image: -moz-linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.3));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.gradient:hover {
background-image: -moz-linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.2));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.gradient:active {
background-image: -moz-linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0,2)), to(rgba(0, 0, 0, 0)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.button {
padding: 6px 10px;
margin: 2px;
color: #fff;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 12px;
text-shadow: 1px 1px 2px #000;
text-decoration: none;
font-weight: bold;
}
.red { background-color: #F20C0C; }
.green { background-color: #30AC04; }
.blue { background-color: #0F9BF2; }
.pink { background-color: #FD13DC; }
.yellow { background-color: #FEF95B; }
.large-corners {
border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px 20px;
}
.medium-corners {
border-radius: 12px;
-moz-border-radius: 12px;
-webkit-border-radius: 12px 12px;
}
.small-corners {
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px 6px;
}
.button-small {
font-size: 10px !important;
padding: 5px 10px !important;
}
.button-medium {
font-size: 12px !important;
padding: 8px 12px !important;
}
.button-large {
font-size: 16px !important;
}
.button-xlarge {
font-size: 24px !important;
}
.shadow {
box-shadow: 0px 0px 4px 2px #aaa;
-webkit-box-shadow: 0px 0px 4px 2px #aaa;
-moz-box-shadow: 0px 0px 4px 2px #aaa;
}
.alt-gradient {
background-color: #ee432e;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ee432e 0%), to(#c63929 50%));
background-image: -webkit-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -moz-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -ms-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -o-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
border: 1px solid #951100;
}
.push {
box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
-webkit-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
-moz-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
display: inline-block;
margin-bottom: 10px
padding: 10px 0 12px 0;
}
.push:hover {
box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
-webkit-box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
-moz-box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
}
.push:active {
box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
-webkit-box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
-moz-box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
</style>
<div class="css3" style="text-align: justify;">
CSS3 is rapidly expanding the toolkit that web developers and designers have to make visually appealing components without the use of images, Photoshop, or CSS sprites. While all of those have their place, and will never be completely removed from the development process, buttons are one component of a website that we can make dynamic, slick and scalable – exclusively in code.<br />
<br />
All of the CSS3 buttons that we create today will be styled forms of anchor tags. Some like to use <code style="background-color: #f0f0f0; color: #009900;">button</code> elements for these, but I find it’s easiest to use <code style="background-color: #f0f0f0; color: #009900;">anchor</code> tags so you can easily add the <code style="background-color: #f0f0f0; color: #009900;">:hover</code> and <code style="background-color: #f0f0f0; color: #009900;">:active</code> pseudo classes and quickly add <code style="background-color: #f0f0f0; color: #009900;">href</code> to it to complete the button.<br />
<h4>
What We're Creating</h4>
For this tutorial, we’ll be creating several different CSS3 buttons, all of which can have different colors, shadows, sizes – all using pure CSS3. We will be using the following properties: <code style="background: #f0f0f0; color: #009900;">border-radius</code>, <code style="background: #f0f0f0; color: #009900;">linear-gradient</code>, <code style="background: #f0f0f0; color: #009900;">box-shadow</code>, <code style="background: #f0f0f0; color: #009900;">text-shadow</code> and <code style="background: #f0f0f0; color: #009900;">opacity</code>.
you might want to change some of these to fit your purpose, and for light colored buttons, a different color would likely be a wise choice. But that’s for you to decide.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
a{
padding: 6px 12px;
margin: 4px;
color: #fff;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 12px;
text-shadow: 1px 1px 2px #000;
text-decoration: none;
font-weight: bold;
}
</code>
</pre>
<h4>
Creating the Gradient Class</h4>
In order to maintain our sanity when working in stylesheets, we’ll create a .gradient class that we can attach to any of our buttons. This uses CSS3's linear-gradient and opacity to create a dynamic background that will give the effect of a gradient to practically anything you attach it to, allowing the background color to shine through.
<br />
<br />
To someone that hasn’t looked at a lot of CSS3 markup, this code may look daunting, but I assure you, it’s not. If you want to brush up on your properties syntax and browser prefixes (those <code style="background-color: #f0f0f0; color: #009900;">-moz</code>, <code style="background-color: #f0f0f0; color: #009900;">-webkit</code>, <code style="background-color: #f0f0f0; color: #009900;">-o</code> things you see here), check out.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.gradient {
background-image: -moz-linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.3));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.3));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.gradient:hover {
background-image: -moz-linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.2));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.2));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.gradient:active {
background-image: -moz-linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0));
background-image: -webkit-linear-gradient-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(0, 0, 0, 0,2)), to(rgba(0, 0, 0, 0)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0));
background-image: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.2);
}
</code>
</pre>
The <code style="background-color: #f0f0f0; color: #009900;">:hover</code> pseudo class changes the opacity at the top from 10% to 0% and at the bottom of the gradient from 30% to 20%, giving it a highlighted look. Finally, the <code style="background-color: #f0f0f0; color: #009900;">:active</code> pseudo class flips the gradient <em>(making it darker at the top, and lighter at the bottom)</em>, giving it a nice depressed look.
<br />
<h4>
Adding a Splash of Color</h4>
We've got the anchor tag and the gradient classes, now let's add some color to our buttons. This is where the true beauty of our <code style="background-color: #f0f0f0; color: #009900;">linear-gradient</code> with opacity shines through absolutely intended.
<br />
<br />
For my colors here, I’m just going to hop on to <a href="http://kuler.adobe.com/#themes/mostpopular?time=30">Kuler</a> and grab five vibrant colors. Let’s create classes and specify the <code style="background-color: #f0f0f0; color: #009900;">background-color</code> property to that color.
<br />
The CSS:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
/*--- The Colors ---*/
.red { background-color: #F20C0C; }
.green { background-color: #30AC04; }
.blue { background-color: #0F9BF2; }
.pink { background-color: #FD13DC; }
.yellow { background-color: #FEF95B; }
</code>
</pre>
<br />
The markup:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<a href="#" class="button red gradient">This is a Red Button</a>
<a href="#" class="button green gradient">This is a Green Button</a>
<a href="#" class="button blue gradient">This is a Blue Button</a>
<a href="#" class="button yellow gradient">This is a Yellow Button</a>
<a href="#" class="button pink gradient">This is a Pink Button</a>
</code>
</pre>
See the example here<br />
<br />
<a class="button red gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Red Button</a><br />
<a class="button green gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Green Button</a><br />
<a class="button blue gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Blue Button</a><br />
<a class="button yellow gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Yellow Button</a><br />
<a class="button pink gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Pink Button</a>
<br />
<h4>
Rounding the Corners</h4>
The <code style="background-color: #f0f0f0; color: #009900;">border-radius</code> property is one of the widely adopted CSS3 properties that almost all modern browsers use <em>(except, of course, for Internet Explorer 8 and previous)</em>. iOS Safari and older versions of Safari and Firefox still use the <code style="background-color: #f0f0f0; color: #009900;">-webkit</code> and <code style="background-color: #f0f0f0; color: #009900;">-moz</code> prefixes, so we'll use them here to insure compatibility. <a href="http://caniuse.com/border-radius">CanIUse</a>’s support grid shows 61.1% support across users. That number should continue to rise as the most updated version of every major browser supports border-radius and our code gracefully degrades to display the nice box button in the previous example.<br />
<br />
Leveraging the flexibility of classes, we’ll create three classes for rounded corners, which gives you flexibility when deciding how you want your button to look.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.large-corners {
border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px 20px;
}
.medium-corners {
border-radius: 12px;
-moz-border-radius: 12px;
-webkit-border-radius: 12px 12px;
}
.small-corners {
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px 6px;
}
</code>
</pre>
<br />
So by simply attaching these classes to your buttons, you can quickly switch between a button with large <code style="background-color: #f0f0f0; color: #009900;">20px</code> rounded corners, to one with small <code style="background-color: #f0f0f0; color: #009900;">6px</code> corners, or leave the class off all together and get a button with square corners. Plus, throwing the color classes in there <em>(and the ability to make more color classes)</em> gives you a complete tool set to create an unlimited number of buttons.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<a href="#" class="button green gradient">This is a Green Button</a>
<a href="#" class="button blue gradient small-corners">This is a Blue Button</a>
<a href="#" class="button yellow gradient medium-corners">This is a Yellow Button</a>
<a href="#" class="button pink gradient large-corners">This is a Pink Button</a>
</code>
</pre>
<a class="button green gradient" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Green Button</a><br />
<a class="button blue gradient small-corners" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Blue Button</a><br />
<a class="button pink gradient medium-corners" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Pink Button</a><br />
<a class="button yellow gradient large-corners" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Yellow Button</a>
<br />
<h4>
Dynamic Sizing</h4>
The greatest part about using CSS3 to create your buttons is the freedom it allows you to change things up on the fly. No more firing up Photoshop every time you want to create a larger button for an emphasized call to action, or a smaller button to link to the rest of a story. To create different buttons here, simply create different classes, with varying text size. Since the <code style="background-color: #f0f0f0; color: #009900;">.button</code> class already has a padding of <code style="background-color: #f0f0f0; color: #009900;">10px</code> on the top and bottom and <code style="background-color: #f0f0f0; color: #009900;">20px</code> on the left and right, the gradient button will automatically resize.<br />
<br />
For this example, I've created four new classes (<code style="background-color: #f0f0f0; color: #009900;">.button-small</code>, <code style="background-color: #f0f0f0; color: #009900;">.button-medium</code>, <code style="background-color: #f0f0f0; color: #009900;">.button-large</code>, and <code style="background-color: #f0f0f0; color: #009900;">.button-xlarge</code>) and simply altered the font-size property. Additionally, to keep the visuals looking good, I've altered the padding on the smaller two buttons, so the button size doesn't overwhelm the call to action <em>(the text)</em>.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.button-small {
font-size: 10px;
padding: 5px 10px !important;
}
.button-medium {
font-size: 12px;
padding: 8px 12px !important;
}
.button-large {
font-size: 16px;
}
.button-xlarge {
font-size: 24px;
}
</code>
</pre>
<br />
To activate these classes, simply attach them to the anchor tags in your code.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<a href="#" class="button gradient green button-small">This is a small button</a>
<a href="#" class="button gradient blue button-medium">This is a medium button</a>
<a href="#" class="button gradient pink button-large">This is a large button</a>
<a href="#" class="button gradient yellow button-xlarge">This is a XL button</a>
</code>
</pre>
<a class="button gradient green button-small" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a small button</a><br />
<a class="button gradient blue button-medium" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a medium button</a><br />
<a class="button gradient pink button-large" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a large button</a><br />
<a class="button gradient yellow button-xlarge" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a XL button</a>
<br />
<h4>
Drop that Shadow</h4>
Time to make another class. Getting sick of them yet? It may seem like a lot, but when you think about the flexibility that it provides you to literally be able to have any type of button on your website, a little leg work in the stylesheet pays off.<br />
<br />
So we’ll create a .shadow class with the CSS3 <code style="background-color: #f0f0f0; color: #009900;">box-shadow</code> property. For details on this property, check out <a href="http://www.css3files.com/shadow/">CSS3Files.com</a>.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.shadow {
box-shadow: 0px 0px 4px 2px #aaa;
-webkit-box-shadow: 0px 0px 4px 2px #aaa;
-moz-box-shadow: 0px 0px 4px 2px #aaa;
}
<a href="#" class="button pink gradient medium-corners button-xlarge shadow">This is a Pink Button</a>
</code>
</pre>
<a class="button pink gradient medium-corners button-xlarge shadow" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">This is a Pink Button</a>
<br />
<h4>
A Gradient Twist</h4>
Another popular method of using gradients is to make the background come to a ‘point’ in the middle. This is done by using the <code style="background-color: #f0f0f0; color: #009900;">linear-gradient</code> property with a <code style="background-color: #f0f0f0; color: #009900;">50%</code> stop. For these, you will need to specify specific colors.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.alt-gradient {
background-color: #ee432e;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ee432e 0%), to(#c63929 50%));
background-image: -webkit-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -moz-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -ms-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: -o-linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
background-image: linear-gradient(top, #ee432e 0%, #c63929 50%, #b51700 50%, #891100 100%);
border: 1px solid #951100;
}
</code>
</pre>
<a class="button blue alt-gradient button-xlarge shadow" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">Another Button</a>
<br />
<h4>
Breaking the Mold: Adding 3D Depth</h4>
Now is when we start to experiment a little bit more. By using the <code style="background-color: #f0f0f0; color: #009900;">box-shadow</code> property and defining multiple shadows separated by a comma, we can add an inset <code style="background-color: #f0f0f0; color: #009900;">box-shadow</code> <em>(like an Inner Shadow in Photoshop)</em>, a light shadow on the top and sides, and a deep shadow below. While this may not look like much, when you "erase" that deep shadow, while offsetting it with some margin and padding, you really get the effect of a 3-dimensional button that you’re pushing down. Check it out.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
.push {
box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
-webkit-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
-moz-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
display: inline-block;
margin-bottom: 10px
padding: 10px 0 12px 0;
}
.push:hover {
box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
-webkit-box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
-moz-box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111 !important;
}
.push:active {
box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
-webkit-box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
-moz-box-shadow: inset 0 1px 10px 1px #5c8bee, 0 1px 0 #1d2c4d, 0 2px 0 #1f3053, 0 4px 3px 0 #111111 !important;
margin-top: 8px;
}
</code>
</pre>
<a class="button blue gradient button-xlarge push" href="http://ankitchauhan22.blogspot.in/2013/02/creating-stick-stylish-button-using-css3.html#">Another Button</a>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-72057866932642743342013-02-21T07:00:00.000+05:302013-02-21T07:00:01.783+05:30Controllers as Services in Symfony2<div style="text-align: justify;">
Controller as a service is continually touted as the best practice.<br />
<br />
But why would I wrap a controller into a service? That's good question.<br />
<br />
Well, the point of doing this in general is not having to inject the DI container into your controllers (instead, you inject the dependencies into the controller directly). Thus the controller no longer depends on the container.
<br />
<ol>
<li>Good: You get added flexibility. You no longer hard-code which services to use into your controller. You can specify that in the DI configuration instead. Example: You inject a UserProvider into the UserController for /profile, but inject a FacebookUserProvider into the same UserController for /profile/facebook.</li>
<li>Bad: You must manually configure your dependencies in the DIC config. You need to manually assign the injected dependencies. Optional dependencies are no longer lazy-loaded.</li>
</ol>
This is basically just a proof of concept to show how it could be done.
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
namespace Acme\DemoBundle\Controller;
class FooController
{
public function __construct($container, ...)
{
$this->container = $container;
// ... deal with any more arguments etc here
}
public function foo($params)
{
// ...
return $x;
}
protected function get($service)
{
return $this->container->get($service);
}
}
</code>
</pre>
<br />
Ditto for the <code>bar()</code> and <code>something()</code> methods, each in their own controller. Then, add them to your application as a service. Eg in your <code>config.yml</code> (other methods available):<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
services:
my.foo.service:
class: Acme\FooBundle\Controller\FooController
arguments:
container: "@service_container"
</code>
</pre>
<br />
See the Symfony docs for <a href="http://symfony.com/doc/current/book/service_container.html#creating-configuring-services-in-the-container" rel="nofollow">more details</a> about how you can construct this entry, including injecting any dependencies such as an entity manager or similar. Now, you can get an instance of this from the container:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
public function yourMainAction()
{
// ...
$newData = $this->get("my.foo.service")->fooAction($someData);
// ...
return new Response(json_encode($newData), ...);
}
</code>
</pre>
<br />
Likewise again for BarController and SomethingController. The advantage now is that this service can be made available at any point in your application (whether via the container as above, or as an injected service), across bundles, without needing to instantiate the class manually yourself and provide any dependencies.
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com4Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-47619846200199710722013-02-20T14:21:00.000+05:302013-02-21T10:32:26.493+05:30run symfony command from controller<div style="text-align: justify;">
Hi Friends,<br />
Few month back I was trying to execute <a href="http://ankitchauhan22.blogspot.in/2013/02/create-and-execute-command-in-symfony-2.html">Symfony2 command</a> in my controller. See how can we do that.
<br />
<h3>
Step 1</h3>
Register you command as service
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
MyCommandService:
class: MyBundle\Command\MyCommand
calls:
- [setContainer, ["@service_container"] ]
</code>
</pre>
<h3>
Step 2</h3>
In your controller, you'll just have to get this service, and call the execute method with the rights arguments.
Set the input with setArgument method:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
.
.
.
public function myAction() {
$command = $this->get('MyCommandService');
$input = new ArgvInput(array('arg1'=> 'value'));
$output = new ConsoleOutput();
$command->run($input, $output);
}
</code>
</pre>
<h3>
Step 3</h3>
Either you can use the execute method of command:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$command->execute($input, $ouput);
</code>
</pre>
But see the defination of run() and execute() methods.<br />
<br />
<ul>
<li><b>run ()</b> -: The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class. </li>
<li><b>execute ()</b> -: This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.</li>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com1Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312283599999997 77.068302999999958 28.7587486 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-42078449290266251082013-02-19T12:53:00.000+05:302013-02-19T12:53:48.961+05:30protecting php file with ionCube encoder<div style="text-align: justify;">
One of the issues PHP developers face is that PHP is an interpreted language, meaning PHP source code is readable by anybody who downloads your applications. In this article I will show you how to protect your intellectual property by encoding your PHP source code.<br />
<br />
The tool we are going to use to protect our code is <a href="http://ioncube.com/sa_encoder.php?xp=FFBMHF">ionCube PHP Encoder</a>. Before releasing your PHP software, you use the encoder to convert your plain-text PHP files into special encrypted files.<b>While ionCube PHP Encoder is a commercial product, there is a <a href="http://ioncube.com/encoder_eval_download.php?xp=FFBMHF">time-limited trial available for download</a>.</b><br />
<b><br /></b>
Because your PHP is encoded into a special byte-code (as opposed to just being obfuscated), a loader must be installed on your web server. A loader is a PHP module that must be installed. Fortunately, ionCube PHP Encoder is commonly used and therefore many web hosts will already have a loader installed.<br />
<br />
On the ionCube website there is a <a href="http://ioncube.com/loaders.php?xp=FFBMHF">loaders page</a> which contains the latest versions of the loader for all supported platforms (you must install the correct loader for your platform). You will need the loader for your platform installed in order to be able to run code you encode from this article.<br />
<br />
Before we proceed, let's take a quick look at an encoded file. Snippet 1 shows a basic PHP script.<br />
<b>Snippet 1</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<?php
echo "Hello, world!\n";
?>
</code>
</pre>
<br />
We can then run this script through the encoder. While there are many different options available, encoding a script with the default options yields the following PHP file.<br />
<b>Snippet 2</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
<?php //000a8
echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.
basename($__ln).' to be installed by the site administrator.');exit(199);
?>
4+oV5BgRgd22U2z7JoK/KmKPIcszhD8pg3hvN+5vc4HFcsGMn/El/4CMYaLFFzaqguLCeb9su8xn
i0+eWxJg/kwNHRkiBvY1aMf1AvwPf14DIwCvegtJC7cbx9cN5jBjwSspVjhVsQnxFx9oBut6R0Kc
V+OLw6XBTNm5sKpbL6DVm2jqk8Wasm9oJgKLZxBtvVBeP5vZrOiod+L7SoplcmTgtyr5wzS3sEzj
r7ixXPUY4H82MyuzZyjYTkSKkz9qlMzWHddrUHJX3y0zPfDqWDUeD1BibJQJ9BXkP7jb4pdKQv/h
sMqhthNQQRSp6nOJHq8oDDYLE+p403GYs2As9qEI2wNAg6j6ln0BRP7shcbNTb5a8O4VjjLhGDwG
1AYOxaM4R5QneCFr+xYdtEYSep8FW1i9IBzF1FuDa7eMoPDqaQdjTLAPsy5O831yGpAHohx3FzUK
aewZTV+tdru=
</code>
</pre>
<br />
While you cannot understand what this code does just by looking at it, your PHP installation with the correct loader installed interprets this just as if it was the code in Snippet 1.<br />
<h3>
Encoding Your PHP Files</h3>
The ionCube PHP Encoder is a command-line script you run either one or more files, or on an entire set of folders. If you're encoding an entire PHP application you would typically run it on the original source folder. The encoder will duplicate the entire tree, except the PHP code will be encoded.</div>
<br />
In the previous section I showed you what the encoded PHP code from a basic "Hello World" script looks like. The command I used to generate this encoded script is as shown in Snippet 3<br />
<b>Snippet 3</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
/usr/local/ioncube/ioncube_encoder5 helloworld.php -o helloworld-enc.php
</code>
</pre>
<br />
In this example, the -o specified the output location. In this example I just created the encoded file in the same directory with a different filename. Typically you would want to create the file with the same filename as the original (without replacing the original source code).<br />
<br />
To achieve this, set the input and output both to be a directory. The encoder will automatically recurse through all directories in the input directory and encode all PHP files.<br />
<br />
To demonstrate this, let's assume <b>helloworld.php</b> is in a directory called <b>src</b>. Snippet 4 shows the command we use to encode this entire path. The example outputs the encoded files to the build directory.<br />
<b>Snippet 4</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
/usr/local/ioncube/ioncube_encoder5 src -o build
</code>
</pre>
<h3>
Protecting Non-PHP Code</h3>
Depending on how your web application has been designed, there may be some non-PHP files you would to prevent users from being able to read. A good example of such files is XML files or Smarty template files.<br />
The ionCube PHP Encoder includes an encryption option. This feature is used to protect non-PHP files (but it differs from the PHP encoding since the output isn't a bytecode format format).<br />
<br />
To encrypt files, the <b>--encrypt</b> command-line option is used. You can then specify a file pattern that will be encrypted. For example, if you want to encrypt every file with extension tpl you would specify <b>--encrypt "*.tpl".</b> Without doing so, the encoder would simply copy all <b>tpl</b> files exactly as-is into the target directory.<br />
<br />
Snippet 5 shows the command we can now type on our src directory. The directory contains the helloworld.php script and a template called index.tpl.<br />
<br />
<b>Snippet 5</b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
/usr/local/ioncube/ioncube_encoder5 src/ -o build --encrypt "*.tpl"
</code>
</pre>
<br />
Your application must be able to handle these encrypted files. Fortunately, when a loader is present in a PHP installation, a number of additional functions are made available that allow you to deal with encrypted files.<br />
<br />
The <b>ioncube_read_file()</b> will decrypt files that have been previously encrypted. This function accepts a filesystem path as its only argument and will return the decrypted data. If the input path was not encrypted it will be returned as-is.<br />
<h3>
Summary</h3>
In this article I showed you how you can protect your PHP code using the ionCube PHP Encoder. While I only showed your the absolute basics, there are many other features available with the encoder that make it ideal for projects of all sizes.<br />
<br />
Some of those features include:<br />
<ol>
<li>Adding a licensing mechanism to your code so only license-holders can use your code</li>
<li>Handling various events in the loading process (such as if the loader isn't found)</li>
<li>Writing custom properties to an encoded file</li>
</ol>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-47098204443114197892013-02-18T17:48:00.000+05:302013-02-18T17:48:59.749+05:30multiple cron job using same file<div style="text-align: justify;">
Hi guys, Today I am posting something about cron. 1 year back, I was getting some trouble in my project in scheduling cron. I had lots of task to be managed by cron, for that I was making multiple files. But after some research I managed those task by a single file.<br />
<br />
If your cron job accomplish similar tasks or requires the same libraries you will have to include the same files over and over to all your cronjobs ... or use this solution.<br />
<br />
Let say you have these cron jobs:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php
15 1 * * * /etc/lib/php -q /home/user/cron/cron2.php
30 1 * * * /etc/lib/php -q /home/user/cron/cron3.php
0 2 * * * /etc/lib/php -q /home/user/cron/cron4.php
</code>
</pre>
<br />
And each of these cron jobs perform different tasks but use the same libraries like phpmailer, pdf creator, geoip, payment verification etc...<br />
<br />
The idea is simple, separate tasks or commands using parameters:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php --task=task1
15 1 * * * /etc/lib/php -q /home/user/cron/cron2.php --task=task2 --filter=cron3
30 1 * * * /etc/lib/php -q /home/user/cron/cron3.php --task=task3 --param=cron3
0 2 * * * /etc/lib/php -q /home/user/cron/cron4.php --task=task4
</code>
</pre>
<br />
In order to accomplish this, the main cronjob file will required the following PHP code:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
function getArguments() {
$argument = array();
for($i = 1; $i < $_SERVER['argc']; ++$i) {
if(preg_match('#--([^=]+)=(.*)#', $_SERVER['argv'][$i], $reg)) {
$argument[$reg[1]] = $reg[2];
}
}
return $argument;
}
$argv = getArguments();
</code>
</pre>
<br />
Then in your cron.php simply use this code to separate tasks or commands:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
// include libraries
if($argv['task'] == 'task1') {
// do task
}
elseif($argv['task'] == 'task2') {
require('/path/to/cron/task2.php');
}
// etc...
</code>
</pre>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-62406891576769908882013-02-15T15:55:00.000+05:302013-02-15T15:55:22.994+05:30connect to multiple database from drupal<div style="text-align: justify;">
Drupal has the ability to connect to multiple databases, allowing you to use Drupal’s built in database abstraction layer on more than just Drupal's primary database.<br />
<br />
Preferably you would add your configuration in the settings.php file for your site, so that all modules can interact with the new database.<br />
<h3>
Drupal 7</h3>
In your settings.php:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$databases = array();
$databases['default']['default'] = array(
// Drupal's default credentials here.
// This is where the Drupal core will store it's data.
);
$databases['alternate_db']['default'] = array(
// Your secondary database's credentials here.
// You will be able to explicitly connect to this database from your modules.
);
</code>
</pre>
<br />
The way to use it in module:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
// Use the database we set up earlier
db_set_active('alternate_db');
// Run some queries, process some data
db_query('...............');
//Switch back to the default connection when finished.
// otherwise Drupal will not be able to access it's own data later on.
db_set_active();
</code>
</pre>
<br />
You can setup databases on the fly when you need it<br />
<br />
If only one of your module is using alternate database, you can define the connection directly there in module as:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$alternate_db = array(
'database' => 'databasename',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'driver' => 'mysql',
);
// replace 'AlternateDatabaseKey' with something that's unique to your module
Database::addConnectionInfo('AlternateDatabaseKey', 'default', $alternate_db);
db_set_active('AlternateDatabaseKey');
// execute queries here
db_set_active(); // without the paramater means set back to the default for the site
drupal_set_message(t('The queries have been made.'));
</code>
</pre>
<br />
If you are using <b>Drupal 6</b> or older version of Drupal than it's little different. You can use it by editing <code style="background-color: #eeeeee; font-weight: bold;">$db_url</code> string in configuration file (setting.php of conf.php). There is by default single connection is defined.<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
$db_url['default'] = 'mysqli://user:password@localhost/drupal';
// you can add another connection as
$db_url['alternate_db'] = 'mysqli://user:password@localhost/alternate_db';
</code>
</pre>
<br />
To query a different database, simply set it as active by referencing the key name.<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code>
// Use the database we set up earlier
db_set_active('alternate_db');
// Run some queries, process some data
db_query('...............');
//Switch back to the default connection when finished.
// otherwise Drupal will not be able to access it's own data later on.
db_set_active('default');
</code>
</pre>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com2Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-42478223890696304442013-02-14T13:22:00.000+05:302013-02-14T18:54:58.209+05:30create and execute a command in symfony 2<div style="text-align: justify;">
In Symfony 1.x a task is a command line tool to help perform tasks around the application. The same is in Symfony 2. Unfortunately in Symfony2 there is no tool to auto-generate some code for these. To create a Symfony2 Command you must to have or to create in your Bundle a folder named Command.<br />
<br />
Symfony 2 is mainly used to create web application, however, sometimes you need to extend your app and need a command line tool to help perform tasks around the application.<br />
<br />
It's one of the most stable parts of the framework and many people have already been using it for several months in many projects as it makes it really easy to develop this kind of software. And of course, everything is done in a really cool way, as many of the parts of Symfony2.<br />
<br />
Let’s see how can extremely easy create a new Command Task and custom our output.<br />
<br />
Create a file in Command Folder, for instance NewsletterCommand.php and fill it with an empty Command structure as follows<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
namespace Ankit\NewsletterBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class NewsletterCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('send:newsletter')
->setDescription('Sends our daily newsletter to our registered users')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Starting Newsletter process');
}
}
</code></pre>
You can execute it as:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
app/console send:newsletter
The output will be as:
Starting Newsletter process
</code></pre>
You can pass some arguments form command too. Lets see how<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
//addArgument in configure() as
$this
->setName('send:newsletter')
->setDescription('Sends our daily newsletter to our registered users')
->addArgument('region', InputArgument::OPTIONAL, 'Where to send?')
;
//and get this argument in execute() as
$region = $input->getArgument('region');
$output->writeln('Sending newsletter to '.$region.' region');
</code></pre>
You can execute it as:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
app/console send:newsletter India
The output will be as:
Starting Newsletter process
Sending newsletter to India region
</code></pre>
Unlike arguments, options are not ordered (meaning you can specify them in any order) and are specified with two dashes (e.g. --India - you can also declare a one-letter shortcut that you can call with a single dash like -I).<br />
<br />
Symfony2 will automatically locate and include the command as part of the console commands.</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-21084619552503942972013-02-13T19:00:00.000+05:302013-03-19T11:42:13.238+05:30how to use claim token in technorati<div style="text-align: justify;">
<div>
It's very easy to verify your blog using claim token in technorati.<br />
<br /></div>
<div>
although technorati doesn’t show you how to claim your token to verify your blog in technorati. Here I’m going to tell you how to verify your blog listing in technorati using claim token.<br />
<br /></div>
<div>
after creating an account in technorati, you recieve a mail having the text following from them.<br />
<br /></div>
<div>
This is an automatically-generated email.<br />
<br /></div>
<div>
Thank you for submitting your blog claim on <span class="il">Technorati</span>. <span class="il">Technorati</span> will need to verify that you are an author of the site <a href="http://ankitchauhan22.blogspot.in/" target="_blank">http://ankitchauhan22.<wbr></wbr>blogspot.in</a> by looking for a unique code. We have just assigned the claim token ############## to this claim. Please visit <a href="http://technorati.com/account/" target="_blank">http://<span class="il">technorati</span>.com/account/</a> for more details, including how to use the claim token.<br />
<br /></div>
<div>
Follow these steps to verify your blog using claim token.</div>
<ol>
<li>Create a new post (such as this) using your blog panel.</li>
<li>Copy the claim code from your email.</li>
<li>Paste your 12-digit technorati claim token in the body of the post.</li>
<li>Your blog will be verify by following these steps</li>
</ol>
<div>
After the verrification, you will recieve an mail from technorati saying something like this.<br />
<br /></div>
<div>
Thank you for submitting your blog claim on Technorati. We have successfully crawled your blog and found the claim token, and your claim is now awaiting review.<br />
<br /></div>
<div>
My Technorati Claim Token : XXXXXXXXXXXX<br />
---------------------------------------------------------<br />
<br />
<b><u>Message after claiming Token</u></b>:-<br />
<br /></div>
<div>
We have successfully crawled your blog and found the claim token, and your claim is now awaiting final review. You may now remove the claim token from your feed.<br />
<br />
<u><b>The final message by technorati</b></u><br />
<br />
This is an automatically-generated email.<br />
<br />
Congratulations, your claim is now complete! Please allow 24 to 48 hours for Authority and recent posts to begin showing for your site now that it has been successfully claimed. Once they are there, we will update your site's Authority once per day.<br />
<br />
At first you may not see your site listed in the Technorati Blog Directory for all of the categories you've selected. As you write blog posts around those topics, you should see your Topical Authority in those categories begin to rise.
<br />
<br />
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com2Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312280599999998 77.068302999999958 28.7587516 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-49680272034684984352013-01-18T11:53:00.000+05:302013-01-18T11:53:36.843+05:30create subdomains using htaccessIts very quick and easy. Here we go<br />
<br />
<ol>
<li>You need to create a wildcard domain on your DNS server *.website.com </li>
<li>Then in your vhost container you will need to specify the wildcard aswell *.website.com - This is done in the <a href="http://httpd.apache.org/docs/current/mod/core.html#serveralias" rel="nofollow">ServerAlias DOCs </a></li>
<li>Then extract and verify the subdomain in PHP and display the appropriate data</li>
</ol>
<div>
Here we go in some detail.</div>
<div>
<ul>
<li><b>Create a wildcard DNS entry - </b>In your DNS settings you need to create a <a href="http://en.wikipedia.org/wiki/Wildcard_DNS_record" rel="nofollow">wildcard domain entry</a> such as *.example.com. A wildcard entry looks like this: <pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code> *.example.com. 3600 A 127.0.0.1</code></pre>
</li>
<li><b>Include the wildcard in vhost -</b> Next up in the Apache configuration you need to set up a vhost container that specifies the wildcard in the ServerAlias DOCs directive. An example vhost container:<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); overflow: auto; padding: 5px; width: 100%;"><code><span style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace;"><span style="font-size: 12px; line-height: 14px;"><virtualhost>
ServerName server.example.com
ServerAlias *.example.com
UseCanonicalName Off
</VirtualHost></span></span><span style="font-family: Times New Roman;"><span style="white-space: normal;">
</span></span></code></pre>
</li>
<li><b>Work out which subdomain you are on in PHP</b> - Then in your PHP scripts you can find out the domain by looking in the $_SERVER super global variable. Here is an example of grabbing the subdomain in PHP: <pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>preg_match('/([^.]+)\.example\.com/', $_SERVER['SERVER_NAME'], $matches);
if(isset($matches[1])) {
$subdomain = $matches[1];
}</code></pre>
I have used regex here to to allow for people hitting your site via www.subdomain.example.com or subdomain.example.com.<br />
If you never anticipate having to deal with www. (or other subdomains) then you could simply use a substring like so:
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>$subdomain = substr(
$_SERVER['SERVER_NAME'], 0,
strpos($_SERVER['SERVER_NAME'], '.')
);</code></pre>
</li>
</ul>
<div>
I did it in php. For java or dot net, you need to change my php code to respective java or dot net code.</div>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com0Noida, Uttar Pradesh, India28.5355161 77.39102649999995328.312283599999997 77.068302999999958 28.7587486 77.713749999999948tag:blogger.com,1999:blog-7977059517933486815.post-3907818327358713992012-11-09T12:51:00.001+05:302012-11-09T12:56:35.395+05:30Drupal 8 with symfony<div style="font-family: calibri; font-size: 14px; text-align: justify;">
We all know that Symfony is already in the core of Drupal 8 but how it works and how both systems work? Not that many people understand fully this integration. Me neither but I would like to pubilsh my research notes about how Drupal 8 works now. Surely this material is based on the snapshot of beginning September and I really hope that more things will happen so this information is relevant only for some time.<br />
<br />
I have little experience of the building projects with Symfony so my knowledge is very close to majority of drupal developers.
<br />
<br />
So lets start.
<br />
<br />
First changes we see in index.php that bootstrap is done on the level of DRUPAL_BOOTSTRAP_CODE instead of DRUPAL_BOOTSTRAP_FULL like in Drupal 7. From documentation about phases of bootstrap of Drupal 8 we can see that phase that "initialize language, path, theme, and modules" is not done yet.
<br />
<br />
Next thing we see that we instantiate object of the DrupalKernel class (inherits from Symfony Kernel class)
<br />
Kernel class in Symfony is responsible for building Dependency Injection Container and registering bundles. We will come back to Dependency Injection Container later. Bundles are like "modules" of drupal world.
<br />
<br />
Next thing that happens that we instantiate Request object (instance of Symfony HttpFoundation component). This is the object that grabs all global variables form the request and has methods to retrieve them. The idea behind it is that we do not use any global variables in the code anywhere but interact only with this object as a source.
<br />
<br />
Next part is simple ask kernel object to handle our request
<br />
<div style="background-color: #f8f8f8; border: 1px solid #CCC; color: #222222; display: block; line-height: 1.3; margin: 0.5em; overflow: auto; padding: 0.5em;">
<pre style="font-family: monospace;"><span style="color: blue;">$response</span> = <span style="color: blue;">$kernel</span>-<span style="color: #66cc66;">></span><span style="color: #006600;">handle</span><span style="color: #66cc66;">(</span><span style="color: blue;">$request</span><span style="color: #66cc66;">)</span>-<span style="color: #66cc66;">></span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">(</span><span style="color: blue;">$request</span><span style="color: #66cc66;">)</span>-<span style="color: #66cc66;">></span><span style="color: #006600;">send</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: blue;">$kernel</span>-<span style="color: #66cc66;">></span><span style="color: #006600;">terminate</span><span style="color: #66cc66;">(</span><span style="color: blue;">$request</span>, <span style="color: blue;">$response</span><span style="color: #66cc66;">)</span>;</pre>
</div>
<br />
Now lets take a look of internals of the kernel object and what it does to handle our request.
<br />
<br />
Kernel handle method calls $this->boot() method and then $this->getHttpKernel()->handle($request, $type, $catch);
<br />
<br />
Booting of the Kernel consists of following steps:
<br />
<ul>
<li><b>Registering Bundles:</b> Bundles are like modules in drupal world. DrupalKernel overrides method registerBundles() to register CoreBundle and allows other modules to provide Symfony-like bundles to the system.</li>
<li><b>Initialize Dependency Injection Container:</b> Container is the object that handles all information about dependencies between objects. So when you want to initiate object of class A but in order to do that system should pass object B to constructor of the object A, Container knows about this dependency and does it for you. In Symfony code this is also called Service Container. Documentation I have found about it is here (<a href="http://symfony.com/doc/current/components/dependency_injection/introduction.html"><span style="color: red;">Dependency Injection</span></a>).</li>
<li>Also Container is statically cached with drupal_container() function so we can access it in any place of the code. Minimal available Container will consist of information about config system of drupal (config.storage.options). Every bundle also registers new components to Container (see CoreBundle:: build() method for that. It registers services: 'request', 'dispatcher' (<a href="http://symfony.com/doc/current/components/event_dispatcher/introduction.html"><span style="color: red;">Event Dispatcher</span></a>), , 'resolver', 'http_kernel', 'language_manager'. We can also see that plenty subscribers registered. In terms of this is similar to our hooks system. Here event is fired and dispatcher knows what subscribers are 'registered' for which events and executes their correspond methods (see Drupal\Core\EventSubscriber\PathSubscriber for example).</li>
<li>Pass Container to all registered bundles (it is saved in bundle's container property) and call boot() method on bundles. boot() method doesn't do anything at the moment.</li>
</ul>
<br />
After booting the kernel we run its handler method. It comes down firing KernelEvents::REQUEST event where our routing system plays its role. I believe new routing system deserves separate article. After event we have controller we fire event KernelEvents::CONTROLLER that resolves menu callback (in terms of our old menu system). After executing menu callback we fire KernelEvents::VIEW event and our subscribers prepare $response object that is finally returned.
<br />
<br />
Having response object avaialble we run prepare( ) method that prepares headers, and run send( ) method that prints rendered output.
<br />
<br />
Finally we run kernel's terminate method that in the end fire KernelEvents::TERMINATE event.
<br />
<br />
This is very brief overview from the beginner point of view to the system. I hope it made some feeling of understanding of how things work now or at least triggered your interest to learn more about it. Also please remember that things are changing as this are parts that are in active development right now.
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com1tag:blogger.com,1999:blog-7977059517933486815.post-15856537742702367722012-11-07T17:54:00.000+05:302012-11-07T17:54:37.416+05:30How does caching work in Drupal?<div style="background-color: white; text-align: justify;">
<div style="color: #3b3b3b; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 15px; line-height: 22px;">
In my experience, there seems to be a lot of misunderstanding how Drupal caching works. I'm not talking about advanced caching mechanisms like Varnish, APC or memcache here, I'm talking about the core Drupal caching: page cache and block cache which are available in Drupal 7 core. Drupal 6 is similar but works a but differently because page caching was simplified for Drupal 7 (e.g. aggresive mode is now a available as a settings.php var) and the entire system also has become pluggable.<br />
<br /></div>
<div style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 15px; line-height: 22px;">
<span style="color: #3b3b3b;">Everybody knows this screen and the settings. But what do they exactly mean? What difference do they actually make? What do they do? Here is an attempt to explain the settings at </span><i><b><span style="color: #0b5394;">'/admin/config/development/performance'</span></b></i><span style="color: #3b3b3b;">.</span><br />
<div style="color: #3b3b3b;">
<br /></div>
</div>
<div style="color: #3b3b3b; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 15px; line-height: 22px;">
<a href="http://4.bp.blogspot.com/-ZcFoemtvlbg/UJpQ-RmVLEI/AAAAAAAAA5s/n8ym-p2q-ks/s1600/drupal-cache-settings-explained.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="192" src="http://4.bp.blogspot.com/-ZcFoemtvlbg/UJpQ-RmVLEI/AAAAAAAAA5s/n8ym-p2q-ks/s1600/drupal-cache-settings-explained.png" width="400" /></a></div>
<div style="color: #3b3b3b; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 15px; line-height: 22px;">
<b>Page Caching:</b></div>
<ul>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">If enables, page caching will only be used for anonymous users.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">If you enable page caching, the entire HTML of each page will be stored in the database. This significantly reduces the amount of queries needed.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">This automatically means that blocks will also get cached, disregarded their own cache settings.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">If Varnish is configured, this will also enable varnish caching</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">The page cache max-age will be used (see below) for each page.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal; text-align: left;">You can check the "X-Drupal-Cache" HTTP header to check if this cache is HIT.</span></b></span></span></li>
</ul>
<div style="text-align: left;">
<span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b>Block Caching:</b></span></span></div>
<div style="text-align: left;">
<ul>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal;">If you enable block caching, without enabling page caching, the block cache settings will be used (for anonymous and authenticated).</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal;">The defaults for most blocks is "don't cache" because that is the default for blocks who don't have their cache settings specifically declared.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;">You can use block_cache_alter module to set this for each block.</span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;">When it's block created by Views, you can set the cache settings for a block in Views.</span></span></li>
</ul>
<div>
<span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b>Minimum Cache Lifetime:</b></span></span></div>
<div>
<ul>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;">This is the amount of time before the page cache is cleared.</span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;">Page caches are cleared on each cron run</span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;">Be warned: incorrect settings of your cron and this setting might kill your website performance.</span></span></li>
</ul>
<div>
<span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b>Expiration of Cached Page:</b></span></span></div>
</div>
<div>
<ul>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal;">This only applies for external caching mechanisms, for example your browser cache or Varnish.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal;">It sets the Cache-Control max-age value in the HTTP-HEADERS.</span></b></span></span></li>
<li><span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><b><span style="font-weight: normal;">This setting only takes effect when page caching is turned on.</span></b></span></span></li>
</ul>
<div>
<span style="color: #3b3b3b; font-family: Georgia, Times New Roman, Times, serif;"><span style="font-size: 15px; line-height: 22px;"><br /></span></span></div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com8NOIDA, Uttar Pradesh, India28.5355161 77.391026528.3122886 77.0751695 28.7587436 77.706883499999989tag:blogger.com,1999:blog-7977059517933486815.post-69935313773584367002012-02-10T16:09:00.000+05:302013-02-11T16:45:12.606+05:30Theming Views 2 – The Basics<div style="text-align: justify;">
Views 2 provides a well structured theming environment allowing presentation control for each element of your view. And in my humble opinion, it rocks!<br />
Those with no past experience with Views 1 will find Views 2 uses standard PHPTemplate theming techniques. All of your experience theming Drupal can be used with Views.<br />
Views 1 themers starting with Views 2 might be a bit confused at first. I was. The single callback in template.php where everything happened is gone, refactored into a consistent framework of template files. All of the freedom that existed in the single function still exists with the added benefit of a well defined structure<br />
<b>Overview:</b><br />Views handles querying the database and organizing the information for display. It creates the output display by converting retrieved data into variables and passing them through a series of templates. Each template handles a different "level" of output creation. The number of templates used to create a view's output depends on the view's type and style, as well as the number of fields involved. These templates exist as files (with a .tpl.php extension), in either the module's or the theme's directory, and follow PHPTemplate's theming conventions.<br />
Generally speaking, the template levels are:
<br />
<ol>
<li>Field: When fields are used in the view ("Row style" = Fields), each field can be themed with a field specific template file. If "Row style" = Node, the node's .tpl.php file is used.</li>
<li>Row: Controls how the individual fields are assembled together into a row. This template isn't used for table styles</li>
<li>Style: Controls how the rows are assembled into the output. For example, in a list view a foreach loop places each row entry into the list entry (<li>) of an unordered list (<ul>).</li>
<li>Display: Controls the other information making up the view such as title, header and footer.</li>
</ol>
<br />
Each level becomes input variables for the next level up. The output of field templates are input variables for the row template, the output for the row template becomes input variables for the style template, and so on. There are also level specific variables available, such as row number. A diagram is available at
<a href="http://views-help.doc.logrus.com/help/views/analyze-theme">http://views-help.doc.logrus.com/help/views/analyze-theme.</a><br />
A template file naming convention is used to make the template highly specific or highly general. Through appropriate naming, a template file can apply to all views, a view of a specific type, or a specific display of a specific view. Where multiple files might apply to a view, the one with the most specific name is used.<br />
Template Files <br />Each theming level has a default template file. The default templates are located in the theme directory of the Views module. e.g., /root/sites/all/modules/views/theme. These files can provide both a starting point and an example for customization, though their general nature sometimes makes them less useful than one would hope.<br />
<div style="text-align: center;">
<span class="Apple-style-span" style="color: #444444; line-height: 19px;"><a href="http://1.bp.blogspot.com/-Lsw3fiBg3Rw/TzTuk56amaI/AAAAAAAAASU/ZWvfPA6fwRc/s1600/1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><img alt="Views Module Theme Files" border="0" src="http://1.bp.blogspot.com/-Lsw3fiBg3Rw/TzTuk56amaI/AAAAAAAAASU/ZWvfPA6fwRc/s320/1.gif" height="302" width="320" /></span></a></span>
</div>
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-style: inherit; margin-bottom: 10px; margin-top: 10px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center; vertical-align: baseline;">
<strong><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Views Module Theme Files</span></strong></div>
The theme information link on the Views 2 interface shows views theme file information. Each display has slightly different theming information, so make sure the correct display is selected.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-V9mjENvG_Wg/TzTulrFO-FI/AAAAAAAAASY/KUAiht54gr4/s1600/2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><img alt="Theme Information Link" border="0" src="http://2.bp.blogspot.com/-V9mjENvG_Wg/TzTulrFO-FI/AAAAAAAAASY/KUAiht54gr4/s320/2.gif" height="300" width="320" /></span></a></div>
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-style: inherit; margin-bottom: 10px; margin-top: 10px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center; vertical-align: baseline;">
<strong><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Theme Information Link</span></strong></div>
Clicking the link produces a display pane (shown below). It shows, in bold, the template file used at each level and provides a list of template file names that will override the default templates.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-gPb3-VUBVsg/TzTumFyAtJI/AAAAAAAAASk/Q_W8xRKMWWg/s1600/3.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><img alt="Theme Template Information Pane" border="0" src="http://3.bp.blogspot.com/-gPb3-VUBVsg/TzTumFyAtJI/AAAAAAAAASk/Q_W8xRKMWWg/s320/3.gif" height="275" width="320" /></span></a></div>
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-style: inherit; margin-bottom: 10px; margin-top: 10px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center; vertical-align: baseline;">
<strong><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Theme Template Information Pane</span></strong></div>
When you're ready to theme your view, click the theme information link and decide on the appropriate template file name to use. Generally you'll be theming a particular display of a particular view and will select one of the more specific names, if not the most specific name.<br />
Once you've identified the appropriate level to theme, copy the default template file from the modules/views/theme directory to your theme directory and rename it to your chosen name.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-MfvOurhjCjA/TzTunR2Ge4I/AAAAAAAAASs/TyDgdFA9gm4/s1600/4.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><img alt="Identifying and Copying a Template File" border="0" src="http://3.bp.blogspot.com/-MfvOurhjCjA/TzTunR2Ge4I/AAAAAAAAASs/TyDgdFA9gm4/s320/4.gif" height="274" width="320" /></span></a></div>
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-style: inherit; margin-bottom: 10px; margin-top: 10px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center; vertical-align: baseline;">
<strong><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Identifying and Copying a Template File</span></strong></div>
Pressing the Rescan button in the Information section will refresh the cached information and confirm the file you just copied and renamed has been detected by Views.<br />
You can now modify the template file to your required specifications.<br />
In addition to the recognizing the theme directory as a template file location, Views will also recognize template files in a subdirectory named "views". Placing your views template files in a views subdirectory aids file organization if you have a lot of theme files<br />
<h3>
Template Variables</h3>
Seeing what's used in the default template code is a good starting place but might not give you an idea of all your options. The default templates are highly generalized, as they must be, and it's sometimes difficult to glean useful information from the variables in the for-each loops. Fortunately there are some simple techniques for displaying available variables.<br />
First, don't ignore the comments at the head of the file. For example, the comments in the row template named views-view-fields.tpl.php tell you how the field objects are structured. But good comments can't tell you the specific name of field related variables.<br />
The most tempting course is to place something like this in your template:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php print print_r(get_defined_vars(), 1) ?>
</code></pre>
Unfortunately, the variables available include the view object, which contains references to itself. The recursion in the resulting output is so long that it's difficult to scan and it can produce memory exceeded errors. A safer approach is using:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
print print_r(array_keys(get_defined_vars()), 1);
// Or if you have the developer module installed
dsm(array_keys(get_defined_vars()));
?>
</code></pre>
Each array key is the name of a variable. e.g., an array key named 'field' appears in the template file as $field. This will give you a safe starting point for exploring variables.<br />
If your view templates has a $fields variable you can repeat this trick to get a list of field names:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
print print_r(array_keys($fields), 1);
// Or if you have the developer module installed
dsm(array_keys($fields));
?>
</code></pre>
Depending on how you're displaying the information, you may want to wrap the output in a tag and use the htmlentities function if the variable contains HTML:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
print '' . htmlentities(print_r($rows, 1)) . '';
?>
</code></pre>
Since Views 2 uses standard PHPTemplate theming, you can use variable preprocessor functions in template.php. More information of preprocessors: http://drupal.org/node/223430. The hook name is the template file name minus .tpl.php and with hyphens converted to underscores. In the example above where the template file is named views-view-list--comments-recent--page.tpl.php, the preprocessor function for template.php is:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
function phptemplate_preprocess_views_view_list__comments_recent__page(&$vars) {
// code
}
?>
</code></pre>
<br />
<h3>
Views 1 to Views 2</h3>
Some quick differences Views 1 themers might find useful:
<ol>
<li>Theming is now handled by template files, not functions in template.php</li>
<li>Views theming is now consistant with the way nodes are themed (i.e., PHPTemplate)</li>
<li>Where Views 1 theming provided sample code and naming instructions via the "Theme wizard" tab, Views 2 uses the Information button and default files in views/theme directory</li>
<li>The closest equivalent template file to the Views 1 theming function is the "Row style output" template file</li>
</ol>
<h3>
Summary</h3>
Basic steps for theming a Views 2 view:
<ol>
<li>Use the theme information link to determine your template file starting point and naming options</li>
<li>Copy the default template file from modules/views/theme to your theme directory</li>
<li>Rename the file with your selected name</li>
<li>Press rescan to reload the cache and confirm you've done the copy/rename correctly</li>
<li>Read the template file comments and use:
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
<?php
print print_r(array_keys(get_defined_vars()), 1); // Or if you have the developer module installed
dsm(array_keys(get_defined_vars()));
?>
</code></pre>
to find variable names - Use a views subdirectory in your theme directory to keep your theme files organized
</li>
</ol>
<br />
<span class="Apple-style-span" style="color: #cc0000;">Article taken from <a href="http://www.group42.ca/theming_views_2_the_basics" target="_blank">http://www.group42.ca/theming_views_2_the_basics</a></span>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com2tag:blogger.com,1999:blog-7977059517933486815.post-76889266573296371372011-11-29T11:05:00.000+05:302013-01-29T14:51:17.060+05:30Drupal Bootstrap Database<div class="post-body entry-content">
<style type="text/css">
.post-content-inner {
width:100%;
}
.post-content, .post-content-inner {
background:none repeat scroll 0 0 #FFFFFF;
border-left:2px solid #B5CAD0;
float:left;
margin:0 0 10px;
padding:20px 20px 10px;
position:relative;
}
.post-content-inner-mini {
background:none repeat scroll 0 0 #FFFFFF;
float:left;
margin:0 0 10px;
padding:20px 20px 10px;
position:relative;
width:97%;
text-align:justify;
}
p {
color:#4A586C;
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:1em;
line-height:20px;
margin:0;
padding:5px 0;
text-align:justify;
}
a {
color:#F05681;
text-decoration:none;
}
.post-content-inner-mini ul li {
list-style-type:square;
text-align:justify;
font-style: italic;
font-size:12px;
}
.post-content-inner-mini a{
color:#ff0000;
}
.page-links {
border-top: 1px solid #888;
border-bottom: 1px solid #888;
text-align: center;
padding: 0.5em;
float: left;
width: 100%;
}
.clear-block {
display: block;
}
.page-links .page-previous {
text-align: left;
width: 47%;
display: block;
float: left;
}
.page-links a:link, a:visited {
color: #6C420E;
text-decoration: none;
font-size: 11px;
}
.page-links .page-up {
width: 4%;
display: block;
float: left;
}
.page-links .page-next {
text-align: right;
width: 40%;
display: block;
float: right;
}
</style><br />
<div class="post-content-inner-mini">
This is the 3rd article in the series covering DRUPAL v6 bootstrap process. As the bootstrap name implies, this phase covers initializing a connection to a database. <br />
<br />
The phase begins by including <b><i>'database.inc'</i></b>, which is a database abstraction layer allowing developers to use different database servers with the same code base. One of the functions defined by this library is the db_set_active() function, which is invoked by the bootstrap database phase. This function is used to activate a database used by queries in later phases or during page building and rendering. The function begins by checking if the global variable $db_url is empty. Recall that in the phase #1 - DRUPAL_BOOTSTRAP_CONFIGURATION, this variable is set to the value specified in settings.php unless it is still set to the default string of '<i><b>mysql://username:password@localhost/databasename'</b></i>. In that case, $db_url is simply set to empty string ''. This would indicate a first time installation, and as a result the <b><i>'install.inc'</i></b> file would be included and user redirected to install.php.<br />
<br />
Assuming installation had been previously completed, the function proceeds to set $db_conns associative array and initializes a connection to the database specified by the URL. It first determines the connection URL based on the named connection provided to the function as an argument. For the bootstrap phase, no argument is provided and consequently the named connection is set to 'default'. It is interesting to note that an array of connections can be defined in settings.php by defining $db_url as an associative array of key values where the keys are the named connections and the values are the connection URL's. This would be the case where multiple database servers are used to manage content for a site. Drupal expects one of the key values to be named 'default', however. The database type is then extracted from the URL and stored in $db_type global variable. For this example, you can assume that MYSQL is the specified type and therefore 'mysql' would be stored in the variable. Based on the type, the appropriate handler code is then included (again, for this example it would be '<i><b>database.mysql.inc</b></i>'). This file contains the actual code to interface to the specified database.<br />
<br />
A connection to the database is then initialized using the handler's <b><i>db_connect()</i></b> function using the URL as an argument. This function parses the URL into an array of components (i.e., scheme, host, username, password, and path). It then validates that the specified database type is supported by PHP. Finally, if the given URL contains URL-encoded info, it is then decoded.<br />
<br />
A new connection is then opened using the parsed information previously extracted from the URL. If connection to the database was not successful, or if database name not present then Drupal redirects to an error page and terminates.<br />
<br />
If everything was successful up until this point, utf8 character encoding support is enabled for this database connection. The connection resource type is then returned to <b><i>db_set_active()</i></b> to be assigned to $db_conns static associative array for the specified named connection ('default' for bootstrap phase). The $previous_name variable is set to the name of the previously active connection. In our case this is set to false as there is no previously active connection at this stage of the bootstrap process. The static $active_name is then set to the name of the current connection. Next the global $active_db variable is set with the current connection resource type identifier, which can then be used to execute various DB queries to handle the page request. Finally, the $previous_name variable is returned to the bootstrap function. This return value would be useful for situations where there was a pre-existing DB connection and one wanted to switch to another connection to perform certain actions and then restore the original one once completed. For the bootstrap phase, there shouldn't be a pre-existing connection and the return value is simply discarded.<br />
<br />
Until next time.. Stay tuned!<br />
<div class="page-links clear-block">
<a class="page-previous" href="http://ankitchauhan22.blogspot.com/2011/09/drupal-6-bootstrap-process.html" title="Go to previous page">< Drupal 6 Bootstrap Process</a><a class="page-up" href="http://ankitchauhan22.blogspot.com/2011/09/drupal-bootstrap-early-page-cache.html" title="Go to parent page">up</a><a class="page-next" href="http://ankitchauhan22.blogspot.in/2011/11/drupal-bootstrap-database.html" title="Go to next page">DRUPAL_BOOTSTRAP_DATABASE ></a></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com7tag:blogger.com,1999:blog-7977059517933486815.post-21440666587602679942011-10-29T15:15:00.000+05:302011-10-29T15:15:30.959+05:30get XML Namespace Elements using PHP SimpleXML<style type="text/css">
.entry-content {
margin-top: 24px;
text-align: left;
}
p {
text-align: justify;
}
.wp_syntax {
overflow-x: auto;
overflow-y: hidden;
width: 590px;
}
.wp_syntax {
background-color: #F9F9F9;
border: 1px solid silver;
color: #110000;
margin: 0 0 1.5em;
overflow: auto;
}
.wp_syntax pre {
clear: none;
float: none;
font-size: 12px;
line-height: 1.333;
margin: 0;
overflow: visible;
white-space: pre;
width: auto;
color: #666666;
margin-bottom: 15px;
}
.wp_syntax .line_numbers {
background-color: #DDEEFF;
color: gray;
overflow: visible;
text-align: right;
}
.wp_syntax .line_numbers {
background-color: #DDEEFF;
color: gray;
overflow: visible;
text-align: right;
}
.wp_syntax div, .wp_syntax td {
padding: 2px 4px;
vertical-align: top;
}
.wp_syntax table {
border-collapse: collapse;
}
</style><br />
<div class="entry-content">PHP has a great <a href="http://php.net/manual/en/ref.simplexml.php">SimpleXML library</a> that converts XML to an object that can be processed with normal property selectors and array iterators. I’ve been using this quite a bit lately to process some XML documents.<br />
The library documentation isn’t that great when it comes to processing Namespace Elements within your XML document. An example of such use case is when you are parsing an <a href="http://en.wikipedia.org/wiki/RSS">RSS</a> feed that has <a href="http://en.wikipedia.org/wiki/XML_namespace">XML Namespace elements</a>.<br />
Consider the following example:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="xml" style="font-family: monospace;"><span style="color: #009900;"><span style="color: black; font-weight: bold;"><?xml</span> <span style="color: #000066;">version</span>=<span style="color: red;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: red;">"UTF-8"</span><span style="color: black; font-weight: bold;">?></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><rss</span> <span style="color: #000066;">version</span>=<span style="color: red;">"2.0"</span> <span style="color: #000066;">xmlns:opensearch</span>=<span style="color: red;">"http://a9.com/-/spec/opensearch/1.1/"</span> <span style="color: #000066;">xmlns:dc</span>=<span style="color: red;">"http://purl.org/dc/elements/1.1/"</span><span style="color: black; font-weight: bold;">></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><channel<span style="color: black; font-weight: bold;">></span></span></span>
....
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><item<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><title<span style="color: black; font-weight: bold;">></span></span></span>My Title<span style="color: #009900;"><span style="color: black; font-weight: bold;"></title<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><description<span style="color: black; font-weight: bold;">></span></span></span>My Item<span style="color: #009900;"><span style="color: black; font-weight: bold;"></description<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><dc:publisher<span style="color: black; font-weight: bold;">></span></span></span>ABC<span style="color: #009900;"><span style="color: black; font-weight: bold;"></dc:publisher<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><dc:creator<span style="color: black; font-weight: bold;">></span></span></span>DEF<span style="color: #009900;"><span style="color: black; font-weight: bold;"></dc:creator<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"><dc:date<span style="color: black; font-weight: bold;">></span></span></span>2009-02-12T16:53:25Z<span style="color: #009900;"><span style="color: black; font-weight: bold;"></dc:date<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"></item<span style="color: black; font-weight: bold;">></span></span></span>
...
<span style="color: #009900;"><span style="color: black; font-weight: bold;"></channel<span style="color: black; font-weight: bold;">></span></span></span>
<span style="color: #009900;"><span style="color: black; font-weight: bold;"></rss<span style="color: black; font-weight: bold;">></span></span></span></pre></td></tr>
</tbody></table></div><br />
For me to access things like the Title and Description elements, its as simple as:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family: monospace;"><span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">(</span><span style="color: blue;">"http://linkto.my.feed"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: black; font-weight: bold;">new</span> SimpleXmlElement<span style="color: #009900;">(</span><span style="color: #000088;">$feed</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-></span><span style="color: #004000;">channel</span><span style="color: #339933;">-></span><span style="color: #004000;">item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">title</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">description</span><span style="color: #339933;">;</span>
<span style="color: #009900;">}</span></pre></td></tr>
</tbody></table></div><br />
But what if I want to access my namespace elements such as dc:publisher or dc:creator? You would think it ‘could’ be as simple as this:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family: monospace;"><span style="color: #666666; font-style: italic;">//This doesn't work</span>
<span style="color: #339933;">...</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-></span><span style="color: #004000;">channel</span><span style="color: #339933;">-></span><span style="color: #004000;">item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">publisher</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">creator</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
<span style="color: #009900;">}</span></pre></td></tr>
</tbody></table></div><br />
The code above doesn't work because the publisher and creator elements sit inside different namespaces. So how do we do this? If you recall, the second line of our feed had this:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family: monospace;">.... xmlns:dc="http://purl.org/dc/elements/1.1/"></pre></td></tr>
</tbody></table></div><br />
So we know from above that anything in the dc namespace refers this URL: http://purl.org/dc/elements/1.1. Now that we know this, we can easily do this:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family: monospace;"><span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">(</span><span style="color: blue;">"http://linkto.my.feed"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: black; font-weight: bold;">new</span> SimpleXmlElement<span style="color: #009900;">(</span><span style="color: #000088;">$feed</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-></span><span style="color: #004000;">channel</span><span style="color: #339933;">-></span><span style="color: #004000;">item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">title</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">description</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Use that namespace</span>
<span style="color: #000088;">$dc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">children</span><span style="color: #009900;">(</span>‘http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//purl.org/dc/elements/1.1/');</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dc</span><span style="color: #339933;">-></span><span style="color: #004000;">publisher</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dc</span><span style="color: #339933;">-></span><span style="color: #004000;">creator</span><span style="color: #339933;">;</span>
<span style="color: #009900;">}</span></pre></td></tr>
</tbody></table></div><br />
That would work. Now a cleaner way is to read the namespace URI form the document itself using the <a href="http://php.net/manual/en/function.simplexml-element-getNamespaces.php">getNamespaces</a> method:<br />
<br />
<div class="wp_syntax"><table><tbody>
<tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family: monospace;"><span style="color: #339933;">...</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-></span><span style="color: #004000;">channel</span><span style="color: #339933;">-></span><span style="color: #004000;">item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
<span style="color: #339933;">...</span>
<span style="color: #666666; font-style: italic;">//Use that namespace</span>
<span style="color: #000088;">$namespaces</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">getNameSpaces</span><span style="color: #009900;">(</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Now we don't have the URL hard-coded</span>
<span style="color: #000088;">$dc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-></span><span style="color: #004000;">children</span><span style="color: #009900;">(</span><span style="color: #000088;">$namespaces</span><span style="color: #009900;">[</span><span style="color: blue;">'dc'</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dc</span><span style="color: #339933;">-></span><span style="color: #004000;">publisher</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dc</span><span style="color: #339933;">-></span><span style="color: #004000;">creator</span><span style="color: #339933;">;</span>
<span style="color: #009900;">}</span></pre></td></tr>
</tbody></table></div><br />
That's it! I found this useful when getting an RSS feed using SimpleXML and wanting to parse the XML Namespace elements.</div>Anonymoushttp://www.blogger.com/profile/13399098936728363767noreply@blogger.com2