I would like to add a feature to a web app I am developing to allow the user to create rules with an expression builder. Such as the one used in Magento (picture in link below).
http://i.stack.imgur.com/ZWgcG.png
I want to allows them to be able to create the expressions or if statements using column names from a table in a Database, then be able to do comparisons and what not. The expression built in the user interface would then evaluate to code that would be evaluated by a PHP script or Javascript or Perl
I searched the web for things like this that are javascript (ajax) based. I figures there has to be a module or something out on the internet somewhere for jQuery or something similar, but I haven't been able to find anything. I am also not quite sure what something like this is called besides "Expression Builder". If there is something like this out there it would save me a lot of time compared to writing it from scratch.
In Mac OS X terms it is called a “predicate editor”, and can be found in Mail.app and iTunes. I had need for one a while ago, and scoured the web from end to end without finding one. I ended up building my own using jQuery, and it looks like this (text is in norwegian, sorry):
Sadly this is used in an internal project and the source code is not available as it is very application-specific. There is a need for a free component like this though, so if I get around to it I will try to clean this up and release it.
This here should be exactly what you're looking for?
Demo: https://github.com/chrisjpowers/business-rules
Code: https://github.com/chrisjpowers/business-rules
https://packagist.org/packages/ruler/ruler
https://github.com/bobthecow/Ruler
This is very similar to magento one and we are going to use it in our laravel application.more guidance for implementation you can find there.
This fits the bill: (jquery) predicate-builder
No mainstream tool out there for PHP... except the ones we make for ourselves :)...Its easy to implement a decent one... Just need to decide where you will store the rules... I had built one for myself with the Rule definition stored in XML ... Then updated it a few months back to store that in JSON .... You write "smarty like" templates for the output you want... 2 cases where I used this was for an Active Record implementation as well as PDF generation ... the move to JSON was because most of the newer usage scenarios were related to throwing out javascript for the pages to consume...
Related
I have simple, 1 table, data source that I want to be able to query through an API.
I want to be able to query on any one of the columns. Ideally, I could query for multiple values per column. One column has text, for which I need to be able to do partial and approximate matches (as well as handle diacriticals)
I am wondering what packages people recommend for building this. I realize its something simple, but it seems like a common enough goal that I thought there would be something available to do all the heavy lifting.
Ideally, I'd like to work with python/django, but could also do PHP. Is there something available to help with this?
I assume since you mentioned django, that you are asking to create a web facing API (like what twitter and facebook provide), if that's the case there are a few options:
You may not have to write anything at all. There are platforms like apigee that allow you to create an API just by clicking a few links. They have free accounts, like almost everyone on the net.
If that doesn't work for you, you can use flask-rest (optimized for the Flask microframework) or tastypie which works great with django for Python. Both will allow you to easily create APIs for your data source and they will take care of most of the boilerplate code for you.
For PHP, someone already asked the same question earlier so that would be a good resource.
If you just want to create an API on top of an existing database and use this API to query the database in other applications, then the de-facto standard for Python is SQLAlchemy.
Probably you may want to check out this link, that will give you some lights about structuring and some template code (in PHP) for building an API:
http://net.tutsplus.com/tutorials/php/creating-an-api-centric-web-application/
From the formatting of the URL to the call of the methods called in it. I.e.:
$controller = ucfirst(strtolower($params['controller']));
import sqlite3
conn = sqlite3.connect("some_db.sqlite")
conn.execute("SELECT * FROM TABLE WHERE some_field=?",('field_value',)) #this should properly escape values
# or
conn.execute("SELECT * FROM TABLE WHERE some_field LIKE ?",('%parial_match%',))
not sure if thats what you are asking for (this is python)
I've built a fairly complex web app (html, javascript, jQuery, php, mySQL) and use several mechanisms for navigating through the site (e.g. anchor/links, submit buttons, window.location, window.open). I'm looking for two things:
What are all the mechanisms possible for moving around a site or a source that will allow me to find such a list
What, if any, documentation standards are there for documenting such actions; something like the flow charts used to document procedural code.
I'm not sure either by what you mean in "thing 1". The best tool to map all the paths is the UML Sequence Diagram.
Services such as Omniture and Google Analytics let you visualize such paths of user navigation. You could explore that option. Basically they work by tracking a page's URL and its referrer URL (accessible via document.referrer) and then making the connection.
If I understand your comment on dj_segfault properly, I'm not even sure you understand the concept of server/client interaction.
I don't think there is an answer to this because the technology is changing all the time and it is different depending on what devices you are using.
You only have to look at Node.js (if you understand the technology) to see that the lines between server and client can be blurred, and that it's just not a simple answer.
The bottom line is in fact there are no navigation "things" unless you program them, and how you program them is your choice depending on requirement.
For example a vanilla link
Google
Can either be static HTML content or echo'ed from a php script which was used to select the data from a database to get the URL and print it. But it doesn't have to be either of these.
If you wanted to navigate to google you could use a button with an onClick javascript or an event listener with data collected by AJAX. It could be derived from other content values on-the-fly or be a string. I could probably imagine 20 different possibilities but that doesn't make them all suitable for the application.
Just keep incrementally improving your project, use this forum to answer specific questions and you'll learn a lot. I did.
I'm developing a web application and I'm using PHP and Javascript. Today, I'm starting to draw all the design class diagrams, but I don't know exactly how to mix both technologies.
I think that something like the following should be good:
But, really, I'm not sure if typing the .php extension in the class name is sufficiently clear, or what I need is to separate diagrams in two: one for Javascript classes and another one for PHP classes.
I'm using CodeIgniter (MVC pattern) and Javascript. Any suggestion will be really appreciated.
Thanks!
Usually, you don't want to do this. It's a problem of latency when viewing the web page in a browser. Each separate javascript file defeats caching and requires additional transfer time before a page can load. It's commonly advised to combine JS files wherever possible and practical to better take advantage of browser caching. So my first suggestion is to not arbitrarily split up your JS for architectural reasons...
Now, with that said, to answer you question in entirety, I think it depends on how you view JS. If you're looking at it form the perspective that it enhances your PHP application, then dividing it up along side your views is not bad (the above suggestion not withstanding).
However, I usually see JS as a separate application layer on top of the PHP application. The JS interacts with the PHP layer through defined APIs. So it's basically just a full blown GUI application that just so happens to use the API defined by the PHP application. So with that in mind, I usually build the JS application with its own architecture that's more dependent on itself then the PHP application. So in other words, just because a piece of the JS application interacts with PHP doesn't mean that the piece of code belongs with the PHP application.
Does that make sense?
Trying to put all your classes (even within one application - you have two: a PHP applicatoin and a JS application) on one UML diagram is pretty much a way to waste a lot of time and gain nothing.
Use UML to show dependecies within a package or a group of classes working together, but don't try to do it for a whole app.
I don't know the way you do things usually but in my projects, I tend to separate PHP and JS. First of all, its easier to develop and debug if you go that way, secondly, if you treat javascript as a second layer instead of being on the same level of programming as PHP you will get a working fallback in the case that your JS doesn't work, or the user of your web app have javascript disabled.
I tend to make everything work in PHP and later on I override some actions with javascript to get them working through ajax instead of the traditionnal way of working in old school Web.
--- Revision following first comment ---
Then, you might want to treat the PHP and the Javascript part as separates applications. The first system (PHP) generate the initial state. Upon user action the second system (JS) makes a query to the first one and wait for the answer, this way, you will setup some sort of API that will standardise your transactions.
I used to work with design information specialists and they often refer to Jesse James Garrett as a "Guru" in that field of expertise, you might want to check his site (there are premade stencils for omnigraffle, visio and few others).
Through his writing and example you might be able to find the right symbols and elements to represent your system.
Jesse James Garrett's website
I have been using .net for the past couple of years, and I like the way you can add controls at any point in the page from anywhere. For example, you can say Head.Controls.add(new LiteralControl("<link rel='stylesheet' type='text/css' href='styles.css' />")) even if there is already a body.
Is it possible to do this kind of thing in php? My site is set up so that we have agents, customers and artists (this is for a card manufacturing company who wants a customer application for use offline at tradeshows). The add agent form may have different styles to the add customer form. I want to therefore have each type in a different folder (for example agents, customers and artists) each with their own stylesheet. There will be one form page which takes GET parameters of type (artist, customer etc), mode (create, edit) and an optional parameter of ID (when in edit mode). I would like to be able to call $agentForm->generateForm() and $agentForm->generateStyleTag() in one go, rather than what I am currently doing which is to call $agentForm->generateForm() in the body and $agentForm->generateStyleTag when in the head (without even the start body tag being generated yet).
A good way to put this is that I have a Head tag and a Body tag. In another function called $agentForm->generateHTML() I want to say Body->addChild("bla") and Head->addChild("bla"). This makes developing a new page a lot easier since it ensures the styles are there and are correct for the section of the site the user is in.
Is it possible to achieve this, or is this one of the major differences between php and .net?
PHP is in essence designed just to throw strings into STDOUT, unless buffered. To make this work, you'd have to use a templating system that supports this, or roll your own. There is no 'built-in' templating system unless you count loading the whole thing in DOMDocumentor something, and do major raw DOM manipulations, which would be quite a lot slower, and which I wouldn't recommend unless you plan to do a whole lot of other DOM modifications. Google around for PHP templating systems and check which one supports your needs.
You need to realize something. .NET is a framework, not a programming language. The question is identical to Can you do this in C#. Realize that you're comparing Apples to Oranges.
The PHP language is Turing complete, so yes you can do it. That doesn't mean the code to do it is written yet (it may be) or that it will be easy (who knows). It only means it's possible.
With that said, you need to find a framework to do what you want. No language will come with that kind of operation (since it is far too limiting to the language as a whole). So your task is no longer "Can PHP do this", but "I need to find a framework to do this". Try looking into frameworks, and I'll bet you'll find your answer quite easily...
Have a look at the PRADO framework and the Yii framework. They have a hierarchical, component-based philosphy that allows nesting and composition, essentialling building a whole site from smaller, pluggable components.
As has already been pointed out, PHP is a language, while .Net is a framework. The two are very different things.
If you want to use PHP as a scripting language for .Net, there's always Phalanger
I've been googling around for a really simple way of making what is, in effect, nothing more than an enhanced phpMyAdmin.
In a mysql database, I have:
Name, address, phone, website etc, plus 2 or 3 custom fields. This data is pulled out to make a website.
All I want is to be able to make a freeform form, a bit like Access, but for the web, and the only thing I want to do over and above normal field editing would be to have a list of when I contact them, what was said, and perhaps a reminder when the next action is due. It also needs to implement some basic permissions so that different users can access different subsets of the data.
I've looked at so many CRMs my mind is boggling, and they all do WAY more than I need. I don't have leads or accounts, all I have is the need to make sure than when I update the person's details, and for that data to be in the same DB as my site is generate from.
I'm happy to learn if I can get pointed in the right direction, and I have a feeling that something like what I want might lie in the direction of jquery. It's just that there's so much good jquery stuff about, I can't see the wood for the trees!
Thanks.
If phpMyAdmin doesn't quite do it for you, it sounds like you just want a simple little web application.
jQuery is probably barking up the wrong tree. It's just a javascript library. While you could certainly use it to spiff up your little application, it's not going to get you the core functionality you need.
I would just dig in and write a little PHP script that does exactly what you want. Even if you're not very experienced, this would be a great learning project.
There are lots of tools which will generate forms including Phpeanuts, phpFormGen, Delphi for PHP, PfP Studio, FormFields, phpMyEdit (and many more).
I've not looked at Radria for some time - previously, it was more of a CMS/page layout/mashup thing rather than a form generator though.
C.
As has been said, you need to build a web interface.
One simple thing you can use is something like Django's admin panel or Ruby on Rails' script/generate scaffold functionality. If you can run Rails or Django, try those.
If you are tied into PHP, consider using one of the PHP frameworks. I'm no expert on them - some of my PHP-using friends have good stuff to say about Symfony (the alternatives: Cake, CodeIgniter, Zend). A bit of random Googling tells me that Symfony has an admin generator that may be quite like that of Django.
As has been said, jQuery won't do what you need, although you can use it.