Example #1
0
 public function render($handle)
 {
     if ($this->isRendered($handle)) {
         return '';
     }
     if (!$this->isRegistered($handle)) {
         trigger_error("Cannot render asset '{$handle}' - not set.", E_USER_NOTICE);
         return '';
     }
     // get url & attributes
     list($url, $attrs) = $this->assets[$handle];
     $attrs['id'] = $handle;
     if (0 !== strpos($url, '/') && false === strpos($url, '://')) {
         $url = \Phpf\Util\Path::url($url);
     }
     $html = '';
     if (Str::endsWith($url, '.css')) {
         $html = Html::link($url, $attrs);
     } elseif (Str::endsWith($url, '.js')) {
         $html = Html::script($url, $attrs);
     }
     $this->rendered[$handle] = $handle;
     return $html;
 }
Example #2
0
 public function set($id, $value, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL)
 {
     $this->cache[$group][$id] = Str::maybeSerialize($value);
 }
Example #3
0
 /**
  * Escapes an attribute value.
  *
  * Note htmlentities() is applied with ENT_QUOTES in order to avoid
  * XSS through single-quote injection. However, it does not prevent strings
  * containing javascript within single quotes on certain attributes like 'href'.
  * Hence the strict option.
  */
 public static function escape($str, $strict = false)
 {
     $str = htmlentities(Str::esc(trim($str)), ENT_QUOTES);
     return $strict ? str_replace(array('javascript:', 'document.write'), '', $str) : $str;
 }
Example #4
0
/**
 * Check value to find if it was serialized.
 *
 * @param mixed $data Value to check to see if was serialized.
 * @param bool $strict Optional. Whether to be strict about the end of the
 * string. Defaults true.
 * @return bool False if not serialized and true if it was.
 */
function is_serialized($data, $strict = true)
{
    return \Phpf\Util\Str::isSerialized($data, $strict);
}