Esempio n. 1
0
 function getHostname()
 {
     if (!$this->hostname) {
         $this->hostname = \ManiaLib\Utils\Arrays::get($_SERVER, 'HTTP_HOST');
     }
     return $this->hostname;
 }
Esempio n. 2
0
 function preFilter()
 {
     foreach ($this->data as $data) {
         $ui = new Label($this->sizeX - $this->cardElementsPosX * 2, 6);
         $ui->setText(self::formatLine(Arrays::get($data, 0, ''), Arrays::get($data, 1, '')));
         $this->addCardElement($ui);
     }
     $this->setSizeY($this->sizeY + count($this->data) * 6 + 6);
 }
function maniapress_core_settings_validate($settings)
{
    $newsettings = array();
    $newsettings['manialink'] = \ManiaLib\Utils\Arrays::get($settings, 'manialink');
    $newsettings['manialink-name'] = \ManiaLib\Utils\Arrays::get($settings, 'manialink-name');
    $newsettings['google-analytics-id'] = \ManiaLib\Utils\Arrays::get($settings, 'google-analytics-id');
    $newsettings['api-username'] = \ManiaLib\Utils\Arrays::get($settings, 'api-username');
    $newsettings['api-password'] = \ManiaLib\Utils\Arrays::get($settings, 'api-password');
    $newsettings['theme-background'] = \ManiaLib\Utils\Arrays::get($settings, 'theme-background');
    $newsettings['theme-header'] = \ManiaLib\Utils\Arrays::get($settings, 'theme-background');
    return $settings;
}
Esempio n. 4
0
 /**
  * @param string A route like "/home/index/" or "/home/"
  * @return array[string] An array of (controller, action)
  */
 static function getActionAndControllerFromRoute($route)
 {
     $defaultController = Config::getInstance()->defaultController;
     if (substr($route, 0, 1) == '/') {
         $route = substr($route, 1);
     }
     if (substr($route, -1, 1) == '/') {
         $route = substr($route, 0, -1);
     }
     $route = explode('/', $route, 2);
     $controller = \ManiaLib\Utils\Arrays::getNotNull($route, 0, $defaultController);
     $controller = Route::separatorToUpperCamelCase($controller);
     $action = \ManiaLib\Utils\Arrays::get($route, 1);
     $action = $action ? Route::separatorToCamelCase($action) : null;
     return array($controller, $action);
 }
Esempio n. 5
0
 * @date        $Date$:
 */
use ManiaLib\Gui\Manialink;
use ManiaLib\Gui\Elements\Label;
get_header();
if (have_posts()) {
    $layout = new \ManiaLib\Gui\Layouts\Column();
    $layout->setMarginHeight(1);
    Manialink::beginFrame(-95, 50, 0.2, 1, $layout);
    while (have_posts()) {
        the_post();
        get_template_part('content', get_post_format());
    }
    Manialink::endFrame();
    $next = maniapress_html_decode(\ManiaLib\Utils\Arrays::get(explode('"', get_next_posts_link()), 1));
    $prev = maniapress_html_decode(\ManiaLib\Utils\Arrays::get(explode('"', get_previous_posts_link()), 1));
    $ui = new ManiaLib\Gui\Cards\PageNavigator();
    $ui->setPosition(0, -75, 0);
    $ui->arrowNext->setManialink($next);
    $ui->arrowPrev->setManialink($prev);
    $ui->save();
} else {
    $ui = new Label(120 / 1.5);
    $ui->setScale(1.5);
    $ui->setHalign('center');
    $ui->setPosition(0, 40, 0.2);
    $ui->enableAutonewline();
    $ui->setStyle(Label::TextButtonSmall);
    $ui->setText('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.');
    $ui->save();
}
Esempio n. 6
0
 /**
  * @param string $query
  * @return string Augmented query
  */
 protected function instrumentQuery($query)
 {
     $bt = debug_backtrace();
     if (count($bt) < 3) {
         return $query;
     }
     array_shift($bt);
     array_shift($bt);
     $frame = array_shift($bt);
     $class = \ManiaLib\Utils\Arrays::get($frame, 'class');
     $type = \ManiaLib\Utils\Arrays::get($frame, 'type');
     $function = \ManiaLib\Utils\Arrays::get($frame, 'function');
     $line = \ManiaLib\Utils\Arrays::get($frame, 'line');
     $queryHeader = sprintf("/* Function: %s%s%s(), Line: %d*/ ", $class, $type, $function, $line);
     $query = $queryHeader . trim($query);
     return $query;
 }
Esempio n. 7
0
 static function displayedInStation()
 {
     $userAgent = \ManiaLib\Utils\Arrays::get($_SERVER, 'HTTP_USER_AGENT');
     return strstr($userAgent, 'context: tablet') !== false;
 }
Esempio n. 8
0
 protected final function checkActionExists($actionName)
 {
     if (!array_key_exists($actionName, $this->reflectionMethods)) {
         try {
             $this->reflectionMethods[$actionName] = new \ReflectionMethod(get_class($this), $actionName);
         } catch (\Exception $e) {
             throw new ActionNotFoundException('Action not found: /' . $this->controllerName . '/' . $actionName . '/ ; ' . \ManiaLib\Utils\Arrays::get($_SERVER, 'HTTP_REFERER'));
         }
     }
     if (!$this->reflectionMethods[$actionName]->isPublic()) {
         throw new ActionNotFoundException('Action not found: /' . $this->controllerName . '/' . $actionName . '/ ; ' . \ManiaLib\Utils\Arrays::get($_SERVER, 'HTTP_REFERER'));
     }
     if ($this->reflectionMethods[$actionName]->isFinal()) {
         throw new ActionNotFoundException('Action not found: /' . $this->controllerName . '/' . $actionName . '/ ; ' . \ManiaLib\Utils\Arrays::get($_SERVER, 'HTTP_REFERER'));
     }
 }
Esempio n. 9
0
 /**
  * Loads cookie information
  * @see http://services.google.com/analytics/breeze/en/ga_cookies/index.html
  */
 function loadCookie()
 {
     $domainHash = $this->getDomainHash();
     $cookieRandom = rand(1000000000, 2147483647);
     //number under 2147483647
     $cookieUtma = '__utma' . $this->cookieNameSuffix;
     $cookieUtmb = '__utmb' . $this->cookieNameSuffix;
     $cookieUtmc = '__utmc' . $this->cookieNameSuffix;
     $cookieUtmz = '__utmz' . $this->cookieNameSuffix;
     $utma = Arrays::get($_COOKIE, $cookieUtma, '');
     $utma = $utma ? explode('.', $utma) : array();
     $utmb = Arrays::get($_COOKIE, $cookieUtmb, '');
     $utmb = $utmb ? explode('.', $utmb) : array();
     $utmc = Arrays::get($_COOKIE, $cookieUtmc, '');
     $utmc = $utmc ? explode('.', $utmc) : array();
     $utmz = array();
     $utma[0] = $domainHash;
     // Domain hash
     $utma[1] = Arrays::get($utma, 1, $cookieRandom);
     // Random unique ID
     $utma[2] = Arrays::get($utma, 2, time());
     // Time of initial visit
     $utma[3] = Arrays::get($utma, 3, time());
     // Begining of previous session
     $utma[4] = Arrays::get($utma, 4, time());
     // Begining of current session
     $utma[5] = Arrays::get($utma, 5, 0);
     // Session counter
     if (!$utmb || !$utmc) {
         // New session has started
         $utma[5]++;
         $utma[3] = $utma[4];
         $utma[4] = time();
     }
     $utmb[0] = $domainHash;
     $utmc[0] = $domainHash;
     $utmz[0] = $domainHash;
     // Domain hash
     $utmz[1] = time();
     // Timestamp
     $utmz[2] = $utma[5];
     // Session number
     $utmz[3] = 1;
     // Campaign number
     $utmz[4] = 'utmcsr=(direct)|' . 'utmccn=(direct)|' . 'utmcmd=(none)';
     //utm_medium'
     $__utma = implode('.', $utma);
     $__utmb = implode('.', $utmb);
     $__utmc = implode('.', $utmc);
     $__utmz = implode('.', $utmz);
     setcookie($cookieUtma, $__utma, strtotime('+2 years'));
     setcookie($cookieUtmb, $__utmb, strtotime('+30 minutes'));
     setcookie($cookieUtmc, $__utmb, 0);
     setcookie($cookieUtmz, $__utmz, strtotime('+6 months'));
     $this->__utma = $__utma . ';';
     $this->__utmb = $__utmb . ';';
     $this->__utmc = $__utmc . ';';
     $this->__utmz = $__utmz . ';';
 }