Skip to content

Instantly share code, notes, and snippets.

<?php
public function pluginSplit($name, $fallback = true) {
$plugin = null;
list($first, $second) = pluginSplit($name);
if (CakePlugin::loaded($first) === true) {
$name = $second;
$plugin = $first;
}
if (isset($this->plugin) && !$plugin && $fallback) {
$plugin = $this->plugin;
diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php
index f198f82..fb2952d 100644
--- a/lib/Cake/View/Helper.php
+++ b/lib/Cake/View/Helper.php
@@ -267,15 +267,29 @@ class Helper extends Object {
* @param array $options Options array. Possible keys:
* `fullBase` Return full url with domain name
* `pathPrefix` Path prefix for relative urls
+ * `ext` Asset extension to append
* @return string Generated url
<?php
public function beforeFilter() {
parent::beforeFilter();
// Painel de Controle
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
$this->layout = 'admin';
// Configuração do AuthComponent
<?php
public function inputDefaults($defaults = null, $merge = false) {
if (!is_null($defaults)) {
$this->_inputDefaults = array_merge($merge ? $this->_inputDefaults : array(), (array)$defaults);
}
return $this->_inputDefaults;
}
#celery\concurrency\processes\_win.py
from ctypes import byref, sizeof, windll, Structure, WinError, POINTER
from ctypes.wintypes import DWORD, c_size_t, LONG, c_char, c_void_p
### had to change to ####
from ctypes import c_size_t, c_char, c_void_p, byref, sizeof, windll, Structure, WinError, POINTER
from ctypes.wintypes import DWORD, LONG
diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php
index 42a2937..c1956c5 100644
--- a/lib/Cake/Routing/Router.php
+++ b/lib/Cake/Routing/Router.php
@@ -182,7 +182,10 @@ class Router {
* @throws RouterException
*/
protected static function _validateRouteClass($routeClass) {
- if (!class_exists($routeClass) || !is_subclass_of($routeClass, 'CakeRoute')) {
+ if (
@tigrang
tigrang / gist:3242448
Created August 3, 2012 00:10
Hyphenated actions in urls
<?php
App::uses('CakeRoute', 'Routing/Route');
class HyphenRoute extends CakeRoute {
public function parse($url) {
if ($route = parent::parse($url)) {
// don't allow camel-case actions in url to prevent duplicate urls pointed to same page
if (strtolower($route['action'] !== $route['action'])) {
throw new NotFoundException();
}
@tigrang
tigrang / gist:3763800
Created September 21, 2012 20:47
A terrible and terribly simple implementation of a route class that matches get params
<?php
App::uses('CakeRoute', 'Routing/Route');
/**
* QueryStringRoute
*
* Usage:
*
* App::uses('QueryRoute', 'Route');
* Router::connect('/', ['controller' => 'users'], ['routeClass' => 'QueryStringRoute', 'query' => ['foo' => 'bar']]);
*
<?php
App::uses('CakeRoute', 'Routing/Route');
class HyphenRoute extends CakeRoute {
public function parse($url) {
if ($route = parent::parse($url)) {
if (strtolower($route['action'] !== $route['action'])) {
throw new NotFoundException();
}
if (strpos($route['action'], '-') !== false) {
import os
import xml.etree.cElementTree as ET
wallpapers = ET.Element("wallpapers")
for root, dirs, files in os.walk(os.path.expanduser("~/Pictures")):
for file in files:
if (file.lower().endswith(('.png', '.jpg', '.jpeg'))):
wallpaper = ET.SubElement(wallpapers, "wallpaper")
wallpaper.set("deleted", "false")
name = ET.SubElement(wallpaper, "name")