function parse() { if (!$this->_is_parsed) { $cache_data = false; $cache_key = Misc::key('Q:', $this->selector); $cache = Cache::factory(); if (!Config::get('debug.Q_nocache', FALSE)) { $cache_data = $cache->get($cache_key); } if (false === $cache_data) { $query = $this->parse_selector(); $cache_data = array('name' => $query->name, 'SQL' => $query->SQL, 'count_SQL' => $query->count_SQL, 'sum_SQL' => $query->sum_SQL); if ($cache) { $cache->set($cache_key, $cache_data); } } $this->SQL = $cache_data['SQL']; $this->count_SQL = $cache_data['count_SQL']; $this->sum_SQL = $cache_data['sum_SQL']; $this->_is_parsed = TRUE; $this->name = $cache_data['name']; } }
function connected_with($object, $type = '', $approved_only = FALSE) { $name1 = $this->_name; $name2 = $object->_name; $id1 = $this->id; $id2 = $object->id; if (strcmp($name1, $name2) < 0) { $type = self::counterpart($type); list($name1, $name2) = array($name2, $name1); list($id1, $id2) = array($id2, $id1); } $db = self::db($name1); $key = Misc::key($db->name(), $name1, $id1, $name2, $id2, $type); if (isset(self::$conn_cache[$key])) { return $approved_only ? self::$conn_cache[$key] : isset(self::$conn_cache[$key]); } $table = self::RELA_PREFIX . $name1 . '_' . $name2; self::$conn_cache[$key] = $db->value('SELECT `approved` FROM `%s` WHERE `id1`=%d AND `id2`=%d AND `type`="%s"', $table, $id1, $id2, $type); return $approved_only ? self::$conn_cache[$key] : isset(self::$conn_cache[$key]); }
static function cache_content($f) { $files = array_unique(explode(' ', $f)); $content = ''; foreach ($files as $file) { $file = trim($file); list($category, $file) = explode(':', $file, 2); if (!$file) { $file = $category; $category = NULL; } if (!$file) { continue; } $path = Core::file_exists(PRIVATE_BASE . 'css/' . $file . '.css', $category); if ($path) { $content .= CSS::format(@file_get_contents($path)); } } $url_base = preg_replace('/[^\\/]*$/', '', $_SERVER['SCRIPT_NAME']); $content = preg_replace('/\\burl\\s*\\(\\s*(["\'])?\\s*([^:]+?)\\s*\\1?\\s*\\)/', 'url(' . $url_base . '\\2)', $content); $css_file = Misc::key('css', $f) . '.css'; Cache::cache_content($css_file, $content); return $content; }
static function cache_content($f) { $files = array_unique(explode(' ', $f)); $content = ''; foreach ($files as $file) { $file = trim($file); list($category, $file) = explode(':', $file, 2); if (!$file) { $file = $category; $category = NULL; } if (!$file) { continue; } $path = Core::file_exists(PRIVATE_BASE . 'js/' . $file . '.js', $category); if ($path) { $content .= self::format(@file_get_contents($path)); } } $js_file = Misc::key('js', $f) . '.js'; Cache::cache_content($js_file, $content); return $content; }