本文整理汇总了PHP中Railpage\AppCore类的典型用法代码示例。如果您正苦于以下问题:PHP AppCore类的具体用法?PHP AppCore怎么用?PHP AppCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateLocomotive
/**
* Return a locomotive
*
* @since Version 3.9.1
* @return \Railpage\Locos\Locomotive
*
* @param int|bool $id
* @param string|bool $class
* @param string|bool $number
*/
public static function CreateLocomotive($id = false, $class = false, $number = false)
{
$Redis = AppCore::getRedis();
$Registry = Registry::getInstance();
if (!filter_var($id, FILTER_VALIDATE_INT)) {
$id = Utility\LocomotiveUtility::getLocoId($class, $number);
}
if ($id = filter_var($id, FILTER_VALIDATE_INT)) {
$regkey = sprintf(Locomotive::REGISTRY_KEY, $id);
try {
$Loco = $Registry->get($regkey);
} catch (Exception $e) {
$cachekey = sprintf(Locomotive::CACHE_KEY, $id);
if (!self::USE_REDIS || !($Loco = $Redis->fetch($cachekey))) {
$Loco = new Locomotive($id);
if (self::USE_REDIS) {
$Redis->save($cachekey, $Loco);
}
}
$Registry->set($regkey, $Loco);
}
return $Loco;
}
return false;
}
示例2: __construct
/**
* Constructor
* @param string $slug
*/
public function __construct($slug)
{
$Database = AppCore::GetDatabase();
$Cache = AppCore::GetMemcached();
$mckey = "railpage:news.article_slug=" . $slug;
$loaded = false;
if ($story_id = $Cache->fetch($mckey)) {
try {
parent::__construct($story_id);
$loaded = true;
} catch (Exception $e) {
}
}
/**
* Fall back to a database query if we can't load the news article from Memcached
*/
if (!$loaded) {
$story_id = $Database->fetchOne("SELECT sid FROM nuke_stories WHERE slug = ?", $slug);
if (filter_var($story_id, FILTER_VALIDATE_INT)) {
$Cache->save($mckey, $story_id, strtotime("+6 months"));
parent::__construct($story_id);
} else {
throw new Exception("Could not find a story matching URL slug " . $slug);
return false;
}
}
}
示例3: CreateOrganisation
/**
* Return an event
* @since Version 3.9.1
* @return \Railpage\Organisations\Organisation
* @param int|string $id
*/
public static function CreateOrganisation($id = false)
{
$Memcached = AppCore::getMemcached();
$Redis = AppCore::getRedis();
$Registry = Registry::getInstance();
if (!filter_var($id, FILTER_VALIDATE_INT)) {
$slugkey = sprintf(Organisation::REGISTRY_KEY, $id);
try {
$id = $Registry->get($slugkey);
} catch (Exception $e) {
$Database = (new AppCore())->getDatabaseConnection();
$id = $Database->fetchOne("SELECT organisation_id FROM organisation WHERE organisation_slug = ?", $id);
$Registry->set($slugkey, $id);
}
}
$regkey = sprintf(Organisation::REGISTRY_KEY, $id);
try {
$Organisation = $Registry->get($regkey);
} catch (Exception $e) {
$cachekey = sprintf(Organisation::CACHE_KEY, $id);
if (!self::USE_REDIS || !($Organisation = $Redis->fetch($cachekey))) {
$Organisation = new Organisation($id);
if (self::USE_REDIS) {
$Redis->save($cachekey, $Organisation);
}
}
$Registry->set($regkey, $Organisation);
}
return $Organisation;
}
示例4: getCoverImageOfObject
/**
* Get the cover image of the supplied object
* @since Version 3.9.1
* @param object $Object
* @return array
*/
public static function getCoverImageOfObject($Object)
{
if (!self::hasCoverImage($Object)) {
return false;
}
$cachekey = sprintf("railpage:%s=%d;coverimage", $Object->namespace, $Object->id);
$Memcached = AppCore::getMemcached();
$Redis = AppCore::GetRedis();
#printArray($cachekey);die;
if ($result = $Memcached->fetch($cachekey)) {
return $result;
}
if ($result = $Redis->fetch($cachekey)) {
return $result;
}
$photoidvar = isset($Object->flickr_image_id) ? "flickr_image_id" : "photo_id";
if (isset($Object->meta['coverimage'])) {
$Image = ImageFactory::CreateImage($Object->meta['coverimage']['id']);
} elseif ($Object->Asset instanceof Asset) {
$Image = $Object->Asset;
} elseif (isset($Object->{$photoidvar}) && filter_var($Object->{$photoidvar}, FILTER_VALIDATE_INT) && $Object->{$photoidvar} > 0) {
$Image = ImageFactory::CreateImage($Object->{$photoidvar}, "flickr");
}
$return = array("type" => "image", "provider" => $Image instanceof Image ? $Image->provider : "", "title" => $Image instanceof Image ? $Image->title : $Asset->meta['title'], "author" => array("id" => "", "username" => "", "realname" => "", "url" => ""));
if ($Image instanceof Image) {
$return = array_merge($return, array("author" => array("id" => $Image->author->id, "username" => $Image->author->username, "realname" => isset($Image->author->realname) ? $Image->author->realname : $Image->author->username, "url" => $Image->author->url), "image" => array("id" => $Image->id), "sizes" => $Image->sizes, "url" => $Image->url->getURLs()));
}
if ($Object->Asset instanceof Asset) {
$return = array_merge($return, array("sizes" => array("large" => array("source" => $Asset->meta['image']), "original" => array("source" => $Asset->meta['original'])), "url" => array("url" => $Asset['meta']['image'])));
}
$Memcached->save($cachekey, $return, strtotime("+1 hour"));
$Redis->save($cachekey, $return, strtotime("+1 hour"));
return $return;
}
示例5: __construct
/**
* Constructor
* @since Version 3.10.0
* @return \Railpage\Railcams\Storage
*/
public function __construct($id = null)
{
$this->db = AppCore::GetDatabase();
if (filter_var($id, FILTER_VALIDATE_INT)) {
$this->id = $id;
$this->getConfig();
}
}
示例6: __construct
/**
* Constructor
* @since Version 3.10.0
* @param \Railpage\Railcams\Camera $cameraObject
* @param int|null $id
*/
public function __construct(Camera $cameraObject, $id = null)
{
$this->setCamera($cameraObject);
$this->db = AppCore::GetDatabase();
if (filter_var($id, FILTER_VALIDATE_INT)) {
$this->id = $id;
$this->getFootage();
}
}
示例7: __construct
public function __construct()
{
$host = "cache.railpage.com.au";
$port = 6379;
$this->Cache = new Redis();
$this->Cache->connect($host, $port);
$Smarty = AppCore::GetSmarty();
$Smarty->caching_type = "redis";
}
示例8: __construct
/**
* Constructor
* @since Version 3.9.1
* @param int $correction_id
*/
public function __construct($correction_id = false)
{
parent::__construct();
if ($this->id = filter_var($correction_id, FILTER_VALIDATE_INT)) {
$this->populate();
}
}
示例9: __construct
/**
* Constructor
* @since Version 3.8.7
* @param string $type
*/
public function __construct($type = null)
{
parent::__construct();
$this->Module = new Module("glossary");
if ($type == null) {
return $this;
}
$this->url = new Url(sprintf("%s?mode=type&type=%s", $this->Module->url, $type));
$this->id = $type;
switch ($type) {
case "code":
case "acronym":
case "station":
$this->name = ucfirst($type . "s");
break;
case "slang":
case "general":
$this->name = ucfirst($type);
break;
case "term":
$this->name = "Terminology";
break;
default:
$this->name = "General";
break;
}
}
示例10: __construct
/**
* Constructor
* @since Version 3.8.7
* @param int $id
*/
public function __construct($id = false)
{
parent::__construct();
$this->Module = new Module("glossary");
if (filter_var($id, FILTER_VALIDATE_INT)) {
$this->id = $id;
$this->mckey = sprintf("%s.entry=%d", $this->Module->namespace, $this->id);
deleteMemcacheObject($this->mckey);
if ($row = getMemcacheObject($this->mckey)) {
} else {
$query = "SELECT type, short, full, example, date, author FROM glossary WHERE id = ?";
$row = $this->db->fetchRow($query, $this->id);
setMemcacheObject($this->mckey, $row);
}
if (isset($row) && is_array($row)) {
$this->name = $row['short'];
$this->text = $row['full'];
$this->example = $row['example'];
$this->Type = new Type($row['type']);
$this->url = sprintf("%s?mode=entry&id=%d", $this->Module->url, $this->id);
if ($row['date'] == "0000-00-00 00:00:00") {
$this->Date = new DateTime();
$this->commit();
} else {
$this->Date = new DateTime($row['date']);
}
$this->Author = new User($row['author']);
}
}
}
示例11: __construct
/**
* Constructor
* @since Version 3.8.7
* @param string $type
*/
public function __construct($type = false)
{
parent::__construct();
$this->Module = new Module("glossary");
if ($type) {
$this->url = sprintf("%s?mode=type&type=%s", $this->Module->url, $type);
$this->id = $type;
switch ($type) {
case "code":
$this->name = "Codes";
break;
case "term":
$this->name = "Terminology";
break;
case "acronym":
$this->name = "Acronyms";
break;
case "station":
$this->name = "Stations";
break;
case "slang":
$this->name = "Slang";
break;
}
}
}
示例12: __construct
/**
* Constructor
* @since Version 3.8.6
* @param int|string $id
*/
public function __construct($id = false)
{
parent::__construct();
if ($id) {
$mckey = "railpage:fwlink=" . md5($id);
if ($row = getMemcacheObject($mckey)) {
$this->id = $row['id'];
$this->url = $row['url'];
$this->title = $row['title'];
} else {
if (filter_var($id, FILTER_VALIDATE_INT)) {
$query = "SELECT * FROM fwlink WHERE id = ?";
} else {
$query = "SELECT * FROM fwlink WHERE url = ?";
}
if ($row = $this->db->fetchRow($query, $id)) {
$this->id = $row['id'];
$this->url = $row['url'];
$this->title = $row['title'];
setMemcacheObject($mckey, $row, strtotime("+1 month"));
}
}
if (!empty($this->url)) {
$this->url_canonical = sprintf("http://%s%s", RP_HOST, $this->url);
$this->url_short = sprintf("http://%s/fwlink?id=%d", RP_HOST, $this->id);
}
}
}
示例13: __construct
/**
* Constructor
*
* @since Version 3.8.7
*
* @param string $module
*/
public function __construct($module)
{
parent::__construct();
if (!is_string($module)) {
return;
}
$this->Colours = new stdClass();
$this->Colours->primary = "#666";
$this->Colours->accent = "#ddd";
$this->Colours->inverse = "#333";
$module = self::getModuleAlternateName($module);
$this->name = ucwords($module);
$this->url = self::getModuleUrl($module);
if (self::getModuleId($module)) {
$this->id = self::getModuleId($module);
}
switch (strtolower($module)) {
case "images.competitions":
$this->name = "Photo competitions";
$this->namespace = "railpage.images.competitions";
break;
case "locations":
$this->Colours->primary = "#116416";
$this->Colours->accent = "#54A759";
$this->Colours->inverse = "#004304";
break;
case "locos":
$this->Colours->primary = "#3D0CE8";
$this->Colours->accent = "#576BFF";
$this->Colours->inverse = "#1B054E";
break;
case "news":
$this->Colours->primary = "#8A2E60";
$this->Colours->accent = "#CE8AAF";
$this->Colours->inverse = "#450026";
break;
case "privatemessages":
$this->name = "Private Messages";
break;
}
/**
* Lazy populate the namespace
*/
if (empty($this->namespace) && !empty($this->name)) {
$this->namespace = sprintf("railpage.%s", strtolower($this->name));
}
/**
* Lazy populate the URL
*/
if (empty($this->url) && !empty($this->name)) {
$this->url = sprintf("modules.php?name=%s", $this->name);
}
/**
* Create and populate the filesystem paths
*/
$this->Paths = new stdClass();
$this->Paths->module = sprintf("%s/modules/%s", RP_SITE_ROOT, $this->name);
$this->Paths->html = sprintf("%s/modules/%s/html", RP_SITE_ROOT, $this->name);
}
示例14: __construct
/**
* Constructor
* @since Version 3.9.1
* @param string $url
*/
public function __construct($url = false)
{
parent::__construct();
$this->GuzzleClient = new Client();
if ($url) {
$this->addFeed($url);
}
}
示例15: __construct
/**
* Constructor
* @since Version 3.9
*/
public function __construct()
{
parent::__construct();
$this->Module = new Module("timetables");
$this->url = new Url($this->Module->url);
$this->url->import = sprintf("%s?mode=import", $this->url->url);
$this->url->location = sprintf("%s?mode=location", $this->url->url);
}