function __initialize()
 {
     parent::__initialize();
     $links = array();
     $links[] = $this->CreateLink("TwitThis", "http://twitter.com/home?status={url}", resFile("socialbookmarks/twitter.png"));
     $links[] = $this->CreateLink("LinkedIn", "http://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}&source={domain}&summary=EXCERPT", resFile("socialbookmarks/linkedin.png"));
     $links[] = $this->CreateLink("MySpace", "http://www.myspace.com/Modules/PostTo/Pages/?u={url}&t={title}", resFile("socialbookmarks/myspace.png"));
     $links[] = $this->CreateLink("del.icio.us", "http://delicious.com/post?url={url}&title={title}", resFile("socialbookmarks/delicious.png"));
     $links[] = $this->CreateLink("Digg", "http://digg.com/submit?phase=2&url={url}&title={title}", resFile("socialbookmarks/digg.png"));
     $links[] = $this->CreateLink("StumbleUpon", "http://www.stumbleupon.com/submit.php?url={url}", resFile("socialbookmarks/stumbleupon.png"));
     $links[] = $this->CreateLink("Reddit", "http://reddit.com/submit?url={url}&title={title}", resFile("socialbookmarks/reddit.png"));
     $links[] = $this->CreateLink("Y!GG", "http://yigg.de/neu?exturl={url}&exttitle={title}", resFile("socialbookmarks/yigg.png"));
     $links[] = $this->CreateLink("Google Bookmarks", "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk={url}&title={title}", resFile("socialbookmarks/google.png"));
     $links[] = $this->CreateLink("Webnews", "http://www.webnews.de/einstellen?url={url}&title={title}", resFile("socialbookmarks/webnews.png"));
     $links[] = $this->CreateLink("YahooMyWeb", "http://myweb2.search.yahoo.com/myresults/bookmarklet?u={url}&={title}", resFile("socialbookmarks/yahoomyweb.png"));
     $links[] = $this->CreateLink("Furl", "http://www.furl.net/storeIt.jsp?u={url}&t={title}", resFile("socialbookmarks/furl.png"));
     $links[] = $this->CreateLink("Live-MSN", "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=1", resFile("socialbookmarks/live.png"));
     $links[] = $this->CreateLink("BlinkList", "http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url={url}&Title={title}", resFile("socialbookmarks/blinklist.png"));
     $links[] = $this->CreateLink("co.mments", "http://co.mments.com/track?url={url}&title={title}", resFile("socialbookmarks/co.mments.png"));
     $links[] = $this->CreateLink("Facebook", "http://www.facebook.com/share.php?u={url}", resFile("socialbookmarks/facebook.png"));
     $links[] = $this->CreateLink("Faves", "http://faves.com/Authoring.aspx?u={url}&title={title}", resFile("socialbookmarks/faves.png"));
     $links[] = $this->CreateLink("Folkd", "http://www.folkd.com/submit/{url}", resFile("socialbookmarks/folkd.png"));
     $links[] = $this->CreateLink("Squidoo", "http://www.squidoo.com/lensmaster/bookmark?{url}", resFile("socialbookmarks/squidoo.png"));
     $links[] = $this->CreateLink("Wikio", "http://www.wikio.com/vote?url={url}", resFile("socialbookmarks/wikio.png"));
     $links[] = $this->CreateLink("Ma.gnolia", "http://ma.gnolia.com/bookmarklet/add?url={url}&title={title}", resFile("socialbookmarks/magnolia.png"));
     $links[] = $this->CreateLink("NewsVine", "http://www.newsvine.com/_tools/seed&save?u={url}&h={title}", resFile("socialbookmarks/newsvine.png"));
     $links[] = $this->CreateLink("Shadows", "http://www.shadows.com/features/tcr.htm?url={url}&title={title}", resFile("socialbookmarks/shadows.png"));
     $this->set("links", $links);
 }
Пример #2
0
 /**
  * Lists all items in the basket.
  * @attribute[RequestParam('error','string',false)]
  */
 function Index($error)
 {
     // display any given error message
     if ($error) {
         $this->content(uiMessage::Error($error));
     }
     // prepare basket variable
     if (!isset($_SESSION['basket'])) {
         $_SESSION['basket'] = array();
     }
     if (count($_SESSION['basket']) == 0) {
         $this->content(uiMessage::Hint('Basket is empty'));
     } else {
         // list all items in the basket ...
         $ds = model_datasource('system');
         $price_total = 0;
         foreach ($_SESSION['basket'] as $id => $amount) {
             $prod = $ds->Query('products')->eq('id', $id)->current();
             //... each using a template
             $this->content(Template::Make('product_basket'))->set('title', $prod->title)->set('amount', $amount)->set('price', $prod->price)->set('image', resFile($prod->image))->set('add', buildQuery('Basket', 'Add', array('id' => $prod->id)))->set('remove', buildQuery('Basket', 'Remove', array('id' => $prod->id)));
             $price_total += $amount * $prod->price;
         }
         // display total price and the button to go on
         $this->content("<div class='basket_total'>Total price: {$price_total}</div>");
         $this->content(uiButton::Make("Buy now"))->onclick = "location.href = '" . buildQuery('Basket', 'BuyNow') . "'";
     }
 }
Пример #3
0
 /**
  * @param string $title Page title
  * @param string $body_class Optional value for the class attribute of the &lt;body&gt; element
  */
 function __initialize($title = "", $body_class = false)
 {
     // this makes HtmlPage.tpl.php the 'one and only' template
     // for all derivered classes, unless they override it after
     // parent::__initialize with $this->file = X
     $file = str_replace(".class.php", ".tpl.php", __FILE__);
     parent::__initialize($file);
     $this->set("title", $title);
     $this->set("meta", $this->meta);
     $this->set("js", $this->js);
     $this->set("css", $this->css);
     $this->set("content", array());
     $this->set("docready", $this->docready);
     $this->set("plaindocready", $this->plaindocready);
     $this->set("inlineheaderpre", $this->inlineheaderpre);
     $this->set("inlineheader", $this->inlineheader);
     if ($body_class) {
         $this->set("bodyClass", "{$body_class}");
     }
     if (resourceExists("favicon.ico")) {
         $this->set("favicon", resFile("favicon.ico"));
     }
     // set up correct display on mobile devices: http://stackoverflow.com/questions/8220267/jquery-detect-scroll-at-bottom
     $this->addMeta("viewport", "width=device-width, height=device-height, initial-scale=1.0");
 }
Пример #4
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)));
 }
Пример #5
0
 function __construct()
 {
     global $CONFIG;
     parent::__construct();
     if (!isset($CONFIG["payment"]["gate2shop"]["merchant_id"])) {
         WdfException::Raise("Gate2Shop: Missing merchant_id");
     }
     if (!isset($CONFIG["payment"]["gate2shop"]["merchant_site_id"])) {
         WdfException::Raise("Gate2Shop: Missing merchant_site_id");
     }
     if (!isset($CONFIG["payment"]["gate2shop"]["secret_key"])) {
         WdfException::Raise("Gate2Shop: Missing secret_key");
     }
     $this->small_image = resFile("payment/gate2shop.png");
 }
Пример #6
0
 function __construct()
 {
     global $CONFIG;
     parent::__construct();
     if (!isset($CONFIG["payment"]["paypal"]["paypal_id"])) {
         WdfException::Raise("PayPal: Missing paypal_id");
     }
     if (!isset($CONFIG["payment"]["paypal"]["notify_handler"])) {
         WdfException::Raise("PayPal: Missing notify_handler");
     }
     if (!isset($CONFIG["payment"]["paypal"]["use_sandbox"])) {
         $CONFIG["payment"]["paypal"]["use_sandbox"] = false;
     }
     if (!isset($CONFIG["payment"]["paypal"]["custom"])) {
         $CONFIG["payment"]["paypal"]["custom"] = "";
     }
     $this->small_image = resFile("payment/paypal.gif");
 }
Пример #7
0
/**
 * @internal Collects dependencies from a file
 */
function minify_collect_from_file($kind, $f, $debug_path = '')
{
    global $dependency_info, $res_file_storage, $ext_resources;
    if (!$f) {
        return;
    }
    $classname = fq_class_name(array_shift(explode('.', basename($f))));
    if (isset($res_file_storage[$classname]) || minify_forbidden($classname)) {
        return;
    }
    $order = array('static', 'inherited', 'instanciated', 'self');
    //:array('self','incontent','instanciated','inherited');
    $res_file_storage[$classname] = array();
    $content = file_get_contents($f);
    // remove block-comments
    $content = preg_replace("|/\\*.*\\*/|sU", "", $content);
    do {
        $c2 = preg_replace("|(.*)//.*\$|m", "\$1", $content);
        if ($content == $c2) {
            break;
        }
        $content = $c2;
    } while (true);
    foreach ($order as $o) {
        switch ($o) {
            case 'inherited':
                if (preg_match_all('/class\\s+[^\\s]+\\s+extends\\s+([^\\s]+)/', $content, $matches, PREG_SET_ORDER)) {
                    foreach ($matches as $m) {
                        $file_for_class = __search_file_for_class($m[1]);
                        if (!$file_for_class) {
                            continue;
                        }
                        $dependency_info[$classname][] = strtolower($m[1]);
                        minify_collect_from_file($kind, $file_for_class, $debug_path . '/' . $classname);
                    }
                }
                break;
            case 'instanciated':
                $matches = array();
                if (preg_match_all('/new\\s+([^\\(]+)\\(/', $content, $by_new, PREG_SET_ORDER)) {
                    $matches = array_merge($matches, $by_new);
                }
                if (preg_match_all('/\\s+([^:\\s\\(\\)]+)::Make\\(/Ui', $content, $by_make, PREG_SET_ORDER)) {
                    $matches = array_merge($matches, $by_make);
                }
                if (count($matches) > 0) {
                    foreach ($matches as $m) {
                        $file_for_class = __search_file_for_class($m[1]);
                        if (!$file_for_class) {
                            continue;
                        }
                        $dependency_info[$classname][] = strtolower($m[1]);
                        minify_collect_from_file($kind, $file_for_class, $debug_path . '/' . $classname);
                    }
                }
                break;
            case 'self':
                $simplecls = array_pop(explode("\\", $classname));
                if (resourceExists(strtolower("{$simplecls}.{$kind}"))) {
                    $tmp = resFile(strtolower("{$simplecls}.{$kind}"));
                    if (!in_array($tmp, $res_file_storage[$classname])) {
                        $res_file_storage[$classname][] = $tmp;
                    }
                }
                break;
            case 'static':
                try {
                    foreach (ResourceAttribute::Collect($classname) as $resource) {
                        $b = $resource->Resolve();
                        if ($resource instanceof \ScavixWDF\Reflection\ExternalResourceAttribute) {
                            $ext_resources[] = $b;
                            continue;
                        }
                        if (!ends_with($b, $kind)) {
                            continue;
                        }
                        $b = strtolower($b);
                        if (!in_array($b, $res_file_storage[$classname])) {
                            $res_file_storage[$classname][] = $b;
                        }
                    }
                } catch (Exception $ex) {
                }
                break;
        }
    }
}
Пример #8
0
/**
 * @internal Collects dependencies from a file
 */
function minify_collect_from_file($kind, $f, $debug_path = '')
{
    global $dependency_info, $res_file_storage;
    if (!$f) {
        return;
    }
    $classname = strtolower(basename($f, ".class.php"));
    if (isset($res_file_storage[$classname]) || minify_forbidden($classname)) {
        return;
    }
    $order = array('static', 'inherited', 'instanciated', 'self');
    //:array('self','incontent','instanciated','inherited');
    $res_file_storage[$classname] = array();
    $content = file_get_contents($f);
    // remove block-comments
    $content = preg_replace("|/\\*.*\\*/|sU", "", $content);
    do {
        $c2 = preg_replace("|(.*)//.*\$|m", "\$1", $content);
        if ($content == $c2) {
            break;
        }
        $content = $c2;
    } while (true);
    foreach ($order as $o) {
        switch ($o) {
            case 'inherited':
                if (preg_match_all('/class\\s+[^\\s]+\\s+extends\\s+([^\\s]+)/', $content, $matches, PREG_SET_ORDER)) {
                    //					log_debug("minify_collect_from_file [$debug_path/$classname]: INHERITED",$matches);
                    foreach ($matches as $m) {
                        $file_for_class = __search_file_for_class($m[1]);
                        if (!$file_for_class) {
                            continue;
                        }
                        $dependency_info[$classname][] = strtolower($m[1]);
                        minify_collect_from_file($kind, $file_for_class, $debug_path . '/' . $classname);
                    }
                }
                break;
            case 'instanciated':
                if (preg_match_all('/new\\s+([^\\(]+)\\(/', $content, $matches, PREG_SET_ORDER)) {
                    //					log_debug("minify_collect_from_file [$debug_path/$classname]: INSTANCIATED",$matches);
                    foreach ($matches as $m) {
                        $file_for_class = __search_file_for_class($m[1]);
                        if (!$file_for_class) {
                            continue;
                        }
                        $dependency_info[$classname][] = strtolower($m[1]);
                        minify_collect_from_file($kind, $file_for_class, $debug_path . '/' . $classname);
                    }
                }
                break;
            case 'self':
                if (resourceExists(strtolower("{$classname}.{$kind}"))) {
                    $tmp = resFile(strtolower("{$classname}.{$kind}"));
                    if (!in_array($tmp, $res_file_storage[$classname])) {
                        $res_file_storage[$classname][] = $tmp;
                    }
                }
                break;
            case 'static':
                try {
                    $buf = ResourceAttribute::ResolveAll(ResourceAttribute::Collect($classname));
                    foreach ($buf as $b) {
                        if (!ends_with($b, $kind)) {
                            continue;
                        }
                        $b = strtolower($b);
                        if (!in_array($b, $res_file_storage[$classname])) {
                            $res_file_storage[$classname][] = $b;
                        }
                    }
                } catch (Exception $ex) {
                }
                break;
        }
    }
}
Пример #9
0
 private function __collectResourcesInternal($template)
 {
     $res = array();
     if (is_object($template)) {
         $classname = get_class($template);
         // first collect statics from the class definitions
         $static = ResourceAttribute::ResolveAll(ResourceAttribute::Collect($classname));
         $res = array_merge($res, $static);
         if ($template instanceof Renderable) {
             // then check all contents and collect theis includes
             foreach ($template->__getContentVars() as $varname) {
                 $sub = array();
                 foreach ($template->{$varname} as $var) {
                     if (is_object($var) || is_array($var)) {
                         $sub = array_merge($sub, $this->__collectResourcesInternal($var));
                     }
                 }
                 $res = array_merge($res, $sub);
             }
             // for Template class check the template file too
             if ($template instanceof Template) {
                 $fnl = strtolower(array_shift(explode(".", basename($template->file))));
                 if (get_class_simple($template, true) != $fnl) {
                     if (resourceExists("{$fnl}.css")) {
                         $res[] = resFile("{$fnl}.css");
                     } elseif (resourceExists("{$fnl}.less")) {
                         $res[] = resFile("{$fnl}.less");
                     }
                     if (resourceExists("{$fnl}.js")) {
                         $res[] = resFile("{$fnl}.js");
                     }
                 }
             }
             // finally include the 'self' stuff (<classname>.js,...)
             // Note: these can be forced to be loaded in static if they require to be loaded before the contents resources
             $classname = get_class_simple($template);
             $parents = array();
             $cnl = strtolower($classname);
             do {
                 if (resourceExists("{$cnl}.css")) {
                     $parents[] = resFile("{$cnl}.css");
                 } elseif (resourceExists("{$cnl}.less")) {
                     $parents[] = resFile("{$cnl}.less");
                 }
                 if (resourceExists("{$cnl}.js")) {
                     $parents[] = resFile("{$cnl}.js");
                 }
                 $classname = array_pop(explode('\\', get_parent_class(fq_class_name($classname))));
                 $cnl = strtolower($classname);
             } while ($classname != "");
             $res = array_merge($res, array_reverse($parents));
         }
     } elseif (is_array($template)) {
         foreach ($template as $var) {
             if (is_object($var) || is_array($var)) {
                 $res = array_merge($res, $this->__collectResourcesInternal($var));
             }
         }
     }
     return array_unique($res);
 }
Пример #10
0
 /**
  * @internal Compiles a LESS file to CSS and delivers that to the browser
  * @attribute[RequestParam('file','string')]
  */
 function CompileLess($file)
 {
     $less = resFile(basename($file), true);
     $css = sys_get_temp_dir() . '/' . md5($file) . '.css';
     $cacheFile = sys_get_temp_dir() . '/' . md5($file) . '.cache';
     header('Content-Type: text/css');
     if (file_exists($css) && file_exists($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = $less;
     }
     require_once __DIR__ . '/lessphp/lessc.inc.php';
     $compiler = new \lessc();
     $newCache = $compiler->cachedCompile($cache);
     if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
         file_put_contents($cacheFile, serialize($newCache));
         file_put_contents($css, $newCache['compiled']);
     }
     WdfResource::ValidatedCacheResponse($less);
     readfile($css);
     die;
 }
 /**
  * Resolves this resource to a URL
  * 
  * Will call <resFile>() to do so, so result will be callable from the current location.
  * @return string URL to resource
  */
 function Resolve()
 {
     return resFile($this->Path);
 }