Example #1
0
 /**
  * Shows product details
  * @attribute[RequestParam('id','int')]
  */
 function Details($id)
 {
     // check if product really exists
     $ds = model_datasource('system');
     $prod = $ds->Query('products')->eq('id', $id)->current();
     if (!$prod) {
         redirect('Products', 'Index', array('error' => 'Product not found'));
     }
     // create a template with product details
     $this->content(Template::Make('product_details'))->set('title', $prod->title)->set('description', $prod->body)->set('image', resFile($prod->image))->set('link', buildQuery('Basket', 'Add', array('id' => $prod->id)));
 }
 /**
  * @internal New string page
  */
 function NewStrings()
 {
     $this->_contentdiv->content("<h1>New strings</h1>");
     $ds = model_datasource($GLOBALS['CONFIG']['translation']['sync']['datasource']);
     foreach ($ds->Query('wdf_unknown_strings')->all() as $row) {
         $ns = Template::Make('translationnewstring');
         foreach ($row->GetColumnNames() as $col) {
             $ns->set($col, $row->{$col});
         }
         $this->_contentdiv->content($ns);
     }
     if (!isset($row)) {
         $this->_contentdiv->content("<p>no requested strings found</p>");
     }
     $this->_contentdiv->content("<h1>Manually add string</h1>");
     Template::Make('translationnewstringmanually')->appendTo($this->_contentdiv);
 }
 /**
  * @internal New string page
  */
 function NewStrings()
 {
     $this->_contentdiv->content("<h1>New strings</h1>");
     $this->_contentdiv->content("<p>Default language is '{$GLOBALS['CONFIG']['localization']['default_language']}', so please create new strings accordingly.</p>");
     $ds = model_datasource($GLOBALS['CONFIG']['translation']['sync']['datasource']);
     foreach ($ds->Query('wdf_unknown_strings')->all() as $row) {
         $ns = Template::Make('translationnewstring');
         foreach ($row->GetColumnNames() as $col) {
             $ns->set($col, $row->{$col});
         }
         $this->_contentdiv->content($ns);
     }
     if (!isset($row)) {
         $this->_contentdiv->content("<p>no requested strings found</p>");
     }
     $this->_contentdiv->content("<h1 style='clear:both'>Manually add string</h1>");
     Template::Make('translationnewstringmanually')->appendTo($this->_contentdiv);
 }
Example #4
0
 /**
  * Entrypoint for the checkout process.
  * 
  * Requests customers address details and asks for payment processor.
  */
 function BuyNow()
 {
     // displays the chechout form, which has all inputs for address on it
     $this->content(Template::Make('checkout_form'));
 }
Example #5
0
/**
 * Checks if minifying a classes resources is explicitely forbidden
 * 
 * Uses NoMinify attribute to check that
 * @param string $classname Classname to check for
 * @return bool true or false
 */
function minify_forbidden($classname)
{
    if (is_string($classname) && strpos($classname, '.') !== false) {
        $classname = explode('.', $classname);
        $classname = $classname[0];
    }
    try {
        $ref = WdfReflector::GetInstance($classname);
        return count($ref->GetClassAttributes('NoMinify')) > 0;
    } catch (Exception $ignored) {
        try {
            Template::Make($classname);
            // check if the name refers to an anonymous template
            return false;
        } catch (Exception $ex) {
            WdfException::Log("minify_forbidden({$classname})", $ex);
            return false;
        }
    }
}
Example #6
0
 function Init()
 {
     $this->content(Template::Make('intro'))->set("run", new Anchor(buildQuery('DocMain', 'Run'), 'Run'));
 }
Example #7
0
 /**
  * @attribute[RequestParam('title','string',false)]
  * @attribute[RequestParam('tagline','string',false)]
  * @attribute[RequestParam('body','text',false)]
  * @attribute[RequestParam('price','double',false)]
  */
 function AddProduct($title, $tagline, $body, $price)
 {
     $this->_login();
     // require admin to be logged in
     // This is a quite simple condition: You MUST provide each of the variables
     if ($title && $tagline && $body && $price) {
         // store the uploaded image if present
         if (isset($_FILES['image']) && $_FILES['image']['name']) {
             $i = 1;
             $image = __DIR__ . '/../images/' . $_FILES['image']['name'];
             while (file_exists($image)) {
                 $image = __DIR__ . '/../images/' . $i++ . '_' . $_FILES['image']['name'];
             }
             move_uploaded_file($_FILES['image']['tmp_name'], $image);
             $image = basename($image);
         } else {
             $image = '';
         }
         // store the new product into the database
         $ds = model_datasource('system');
         $ds->ExecuteSql("INSERT INTO products(title,tagline,body,image,price)VALUES(?,?,?,?,?)", array($title, $tagline, $body, $image, $price));
         redirect('Admin');
     }
     // create a dialog and put a template on it.
     $dlg = new uiDialog('Add product', array('width' => 600, 'height' => 450));
     $dlg->content(Template::Make('admin_product_add'));
     $dlg->AddButton('Add product', "\$('#frm_add_product').submit()");
     // frm_add_product is defined in the template
     $dlg->AddCloseButton("Cancel");
     return $dlg;
 }
Example #8
0
 function NewPost()
 {
     log_debug("New Post");
     $this->content(Template::Make('newpostform'));
 }
Example #9
0
 /**
  * @internal SysAdmin login page.
  * @attribute[RequestParam('username','string',false)]
  * @attribute[RequestParam('password','string',false)]
  */
 function Login($username, $password)
 {
     global $CONFIG;
     if ($username === false || $password === false) {
         $this->content("<br/><br/>");
         $this->content(Template::Make('sysadminlogin'));
         return;
     }
     if ($username != $CONFIG['system']['admin']['username'] || $password != $CONFIG['system']['admin']['password']) {
         redirect(get_class_simple($this), 'login');
     }
     $_SESSION['admin_handler_username'] = $username;
     $_SESSION['admin_handler_password'] = $password;
     redirect(get_class_simple($this));
 }