Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
Example #2
0
 public static function getAccessManager()
 {
     if (empty(self::$instance)) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
Example #3
0
 /**
  *	Visszadja a Registry objektumot
  */
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
Example #4
0
 /**
  * Возвращает единственный экземпляр класса.
  * @Возвращаем Registry.
  */
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new static();
     }
     return self::$instance;
 }
Example #5
0
 /**
  * 取得 Registry静态实例
  * @return object $this
  */
 private static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
Example #6
0
 public static function instance()
 {
     if (null == self::$instance) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
 /**
  * @return Registry
  */
 static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new Registry();
     }
     return self::$instance;
 }
Example #9
0
 /**
  * Retorna uma instância da classe Registry (padrão Singleton)
  * @return	Registry	retorna uma da própria classe
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #10
0
 function newCmtFormHlr($author = false, $email = false, $author_id = false, $article_id = false, $content = false, $date = false)
 {
     if ($content == false) {
         $content = $_REQUEST['comment_text'];
     }
     if ($article_id == false) {
         $article_id = $_REQUEST['id'];
     }
     $reg = Registry::instance();
     $_hinfo = $reg->get('hamster_info');
     $login_status = $reg->get('login_status');
     if ($login_status == 3) {
         $author = mysql_escape_string(htmlspecialchars($_hinfo['name']));
         $email = '';
         $author_id = intval($_hinfo['id']);
         if ($_REQUEST['comment_text'] == '') {
             return array();
         }
         require_once 'lib/markdown/markdown.php';
         $content = Markdown(strip_tags($content));
     } else {
         $content = '<p>' . htmlspecialchars($content) . '</p>';
         $email = mysql_escape_string(htmlspecialchars($_REQUEST['comment_email']));
         if ($_REQUEST['comment_name'] != '' && $name == false) {
             $author = mysql_escape_string(htmlspecialchars($_REQUEST['comment_name']));
         } else {
             $author = 'НЛО';
         }
         if (strpos($_REQUEST['comment_text'], 'http://') !== false || $_REQUEST['comment_text'] == '' || $_REQUEST['comment_sid'] != $_SESSION['comment_sid'] || !isset($_SESSION['comment_sid']) || time() - $_SESSION['comment_stamp'] < 2) {
             return array();
         }
     }
     $prs = array('author' => $author, 'email' => $email, 'author_id' => $author_id, 'article_id' => intval($article_id), 'content' => mysql_escape_string($content), 'date' => local2gm());
     return $prs;
 }
Example #11
0
 static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #12
0
 /**
  * Returns an instance of the registry
  *
  * @return Registry
  */
 public static function instance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #13
0
 public static function singleton()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #14
0
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         //there is no instance
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #15
0
 public static function singleton()
 {
     if (empty(self::$instance)) {
         $obj = __CLASS__;
         self::$instance = new $obj();
         return self::$instance;
     }
 }
Example #16
0
 /**
  * Initilizes or returns singleton of Registry class 
  */
 public static function get_instance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
         return self::$instance;
     } else {
         return self::$instance;
     }
 }
 public function testInstance()
 {
     $client = new SDK\CloudsearchClient(Core\Registry::instance()->getAccessKeyId(), Core\Registry::instance()->getAccessKeySecret(), array("host" => Registry::instance()->getAccessHost(), "debug" => true), Core\Registry::instance()->getAccessKeyType());
     $this->assertInstanceOf('CloudsearchClient', get_class($client));
     $appName = Core\Registry::instance()->getAppName();
     $this->assertEquals('wp', $appName);
     $search = new SDK\CloudsearchSearch($client);
     $this->assertInstanceOf('CloudsearchSearch', $search);
 }
Example #18
0
 /**
  * Creates a view for this action.
  * @param string className
  */
 function createView($class)
 {
     $registry =& Registry::instance();
     if (!$registry->isEntry('view')) {
         $registry->setEntry('view', new $class($this));
     }
     $this->view =& $registry->getEntry('view');
     //$this->view->setToiminto($this);
 }
Example #19
0
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
         return self::$instance;
     } else {
         return self::$instance;
     }
 }
Example #20
0
 static function instance()
 {
     if (self::$testmode) {
         return new MockRegistry();
     }
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #21
0
 function getPrivs()
 {
     $reg = Registry::instance();
     $h = $reg->get('hamster_info');
     if ($h['ban'] == 0) {
         $privs = $this->hamster->getPrivs();
         $privs['add_comment'] = true;
     }
     return $privs;
 }
Example #22
0
 public static function getInstance()
 {
     //there is no instance
     if (!self::$instance instanceof self) {
         self::$instance = new self();
         //return self::$instance;
     } else {
         return self::$instance;
     }
 }
Example #23
0
 /**
  * Constructor
  *
  * Fetches DB configuration dependent on the 'state' setting in app.php. If
  * appropriate adapter is available, it's used - else an exception is thrown.
  *
  * @return void
  */
 private function __construct()
 {
     $registry = Registry::instance();
     $params = $registry->config['db'];
     $adapter_class = 'ModelAdapters' . ucfirst($params['type']);
     $dsn = $params['type'] . ':host=' . $params['host'] . ';dbname=' . $params['database'];
     if (class_exists($adapter_class)) {
         $this->adapter = new $adapter_class($dsn, $params['user'], $params['password'], $params['database']);
     } else {
         throw new Exception('Adapter class ' . $adapter_class . ' (type ' . $params['type'] . ') not found.');
     }
 }
Example #24
0
 function &getInstance($pDBConfig = 0)
 {
     if (empty(SqlCommand::$theInstances[$pDBConfig])) {
         $registry =& Registry::instance();
         $db_configs = $registry->getEntry('database_connections');
         $dbconfig = $db_configs[$pDBConfig];
         $class_name = $dbconfig['DatabaseType'] . 'Command';
         if (!class_exists($class_name)) {
             die('不支持该数据库类型:' . $class_name . '!<br>支持类型:MySql MsSql');
         }
         SqlCommand::$theInstances[$pDBConfig] = new $class_name();
         SqlCommand::$theInstances[$pDBConfig]->resetDB($db_configs[$pDBConfig]);
     }
     return SqlCommand::$theInstances[$pDBConfig];
 }
Example #25
0
 function export_rss($rss_name, $cat_id)
 {
     $reg = Registry::instance();
     $categories = get_categories($reg->get('_CATEGORIES'));
     $stor = new Storage();
     $stor = $stor->storType(TE_STORTYPE);
     $art = $stor->make('article');
     $art->setProperty('approve', 1);
     $db = $art->getList(0, 15, 'stamp', false);
     cookFeed(SITE_NAME, SITE_URL . '/rss/' . $rss_name, INDEX_DIR . '/rss/' . $rss_name, $db);
     // последние 15 из данной категории
     $art->setProperty('category_id', $cat_id);
     $db2 = $art->getList(0, 15, 'stamp', false);
     cookFeed($categories[$cat_id]['name'] . '. ' . SITE_NAME, SITE_URL . '/rss/' . $cat_id . '.xml', INDEX_DIR . '/rss/' . $cat_id . '.xml', $db2);
 }
Example #26
0
 function get_article_list($type = '')
 {
     $reg = Registry::instance();
     $css = $reg->get('_CATEGORIES');
     $cats = get_categories($css);
     //Границы выборки (пропустить $start, взять $stop записей)
     if (isset($_REQUEST['list'])) {
         $_REQUEST['list'] = intval($_REQUEST['list']);
         $start = ($_REQUEST['list'] - 1) * ARTCLS_PER_PAGE;
     } else {
         $start = 0;
     }
     $stop = ARTCLS_PER_PAGE;
     $stor = new Storage();
     $stor = $stor->storType(TE_STORTYPE);
     if ($type == 'all') {
         $type = false;
     } else {
         $c = $stor->make('category');
         $c->setProperty('type', $type);
         $type_list = $c->getList('rank');
     }
     if (!isset($_REQUEST['category_id'])) {
         $a = $stor->make('article');
         $a->setProperty('approve', 1);
         $db = $a->getList($start, $stop, 'stamp', $type);
         if ($type !== 'all') {
             foreach ($type_list as $tl) {
                 $art_count = $art_count + $tl['cat_count'];
             }
         } else {
             foreach ($css as $all) {
                 $art_count = $art_count + $all['cat_count'];
             }
         }
     } else {
         $stor = new Storage();
         $stor = $stor->storType(TE_STORTYPE);
         $a = $stor->make('article');
         $a->setProperty('category_id', $_REQUEST['category_id']);
         $a->setProperty('approve', 1);
         $db = $a->getList($start, $stop, 'stamp', false);
         $art_count = $cats[$_REQUEST['category_id']]['cat_count'];
     }
     global $ARTICLE_NUMBER;
     define("ARTICLE_NUMBER", $art_count);
     return $db;
 }
Example #27
0
File: base.php Project: brego/prank
/**
 * Returns the filename with a relative path to the root of the page
 *
 * url([controller => controller_name]) // Assumes action = index
 * url([controller => controller_name, action => action_name])
 * url(action => action_name]) // Assumes current controller
 * url([controller => controller_name, action => action_name, param, param2])
 *
 * url('/controller/action')
 * url('action') // Assumes current controller, no '/' at first character
 *
 * @param  mixed $path A file or action/controller/param or an array
 * @return string Relative path to the file
 * @todo   This is far from being rock-solid... Could use some rethinking or
 *         refactoring...
 * @todo   Improve documentation
 **/
function url($path)
{
    $controller = Registry::instance()->current_controller;
    if (is_array($path)) {
        if (isset($path['controller']) && isset($path['action']) === false) {
            $path['action'] = 'index';
        } elseif (isset($path['action']) && isset($path['controller']) === false) {
            $path['controller'] = $controller->get_controller();
        } elseif (isset($path['controller']) === false && isset($path['action']) === false) {
            $path['action'] = $controller->action;
            $path['controller'] = $controller->get_controller();
        }
        $result = [$path['controller'], $path['action']];
        unset($path['controller'], $path['action']);
        if (isset($path['id']) === true) {
            $result[] = $path['id'];
            unset($path['id']);
        }
        if (count($path) > 0) {
            $result = array_merge($result, $path);
        }
        $path = implode('/', $result);
    } else {
        if ($path[0] !== '/') {
            $path = $controller->get_controller() . '/' . $path;
        } else {
            $path = substr($path, 1);
        }
    }
    if (isset($_SERVER['REQUEST_URI'])) {
        $request = explode('/', $_SERVER['REQUEST_URI']);
        $request = array_cleanup($request);
        $url = [];
        if (isset($_GET['url'])) {
            $url = explode('/', $_GET['url']);
            $url = array_cleanup($url);
        }
        $result = array_diff($request, $url);
        return '/' . implode('/', $result) . '/' . $path;
    } else {
        return '/' . $path;
    }
}
Example #28
0
File: html.php Project: brego/prank
/**
 * HTML helper
 *
 * @filesource
 * @copyright  Copyright (c) 2008-2014, Kamil "Brego" Dzieliński
 * @license    http://opensource.org/licenses/mit-license.php The MIT License
 * @author     Kamil "Brego" Dzieliński <*****@*****.**>
 * @link       http://prank.brego.dk/ Prank's project page
 * @link       http://github.com/brego/prank/ Prank's Git repository
 * @package    Prank
 * @subpackage Helpers
 * @since      Prank 0.25
 * @version    Prank 0.75
 */
function is_current_page($path)
{
    $controller = Registry::instance()->current_controller;
    if (is_string($path)) {
        $result = [];
        if ($path[0] === '/') {
            $result['controller'] = true;
        }
        $path = explode('/', $path);
        $path = array_cleanup($path);
        if (isset($result['controller']) && isset($path[0])) {
            $result['controller'] = $path[0];
            if (isset($path[1])) {
                $result['action'] = $path[1];
            }
        } elseif (isset($path[0])) {
            $result['action'] = $path[0];
        } else {
            return false;
        }
        $path = $result;
    }
    if (isset($path['controller']) === true && $path['controller'] === $controller->get_controller()) {
        if (isset($path['action']) === true) {
            if ($path['action'] === $controller->action) {
                return true;
            } else {
                return false;
            }
        } else {
            return true;
        }
    } elseif (isset($path['action']) === true && $path['action'] === $controller->action) {
        return true;
    } else {
        return false;
    }
}
Example #29
0
 public function getContent()
 {
     $result = false;
     if (strlen($this->mNode)) {
         import('carthag.core.Registry');
         $reg = Registry::instance();
         // Tries specified language catalog
         //
         if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . $this->mLanguage . '.helpnode')) {
             $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . $this->mLanguage . '.helpnode';
         } else {
             if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '.helpnode')) {
                 $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '.helpnode';
             } else {
                 if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . AMP_LANG . '.helpnode')) {
                     $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . AMP_LANG . '.helpnode';
                 } else {
                     if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_en.helpnode')) {
                         $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_en.helpnode';
                     } else {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('ampoliros.helpnode_library.helpnode_class.getcontent', 'Unable to find an help node file for the specified help node (' . $this->mNode . ') and language (' . $this->mLanguage . ') or fallback to another language', LOGGER_ERROR);
                     }
                 }
             }
         }
         if (!empty($help_node_file)) {
             $fh = @fopen($help_node_file, 'r');
             if ($fh) {
                 $result = file_get_contents($help_node_file);
                 @fclose($fh);
             }
         }
     }
     return $result;
 }
Example #30
0
<?php

/** [lib/window/ca.php] Редактор записей
* Права доступа: Администратор (admin)  	
*/
require_once TE_DIR . '/lib/cultivator.php';
$reg = Registry::instance();
$_hinfo = $reg->get('hamster_info');
if (isset($_SESSION['login']) && $_SESSION['status'] !== 'user') {
    $pre = false;
    //по умолчанию CKEditor показываем (нет <pre>);
    $CKEditor = '<script type="text/javascript">
            CKEDITOR.replace( "my_content" ,
            {
                toolbar :
                [
                    ["Source", "Styles", "PasteFromWord"],
                    ["Bold", "Italic", "Strike", "-", "NumberedList", "BulletedList", "-", "Link","Unlink", "Anchor", "Image", "PageBreak"],
                    ["JustifyBlock","JustifyLeft","JustifyCenter","JustifyRight", "-", "Preview", "-", "Maximize", "-", "Table"]
                ]
            });
        </script>';
    if (isset($_REQUEST['static'])) {
        /*
        //Страница
        if ((@$_REQUEST['action'] == "new") ) {
        	//Если нажата кнопка, создаем запись
        	if (isset($_REQUEST['sub'])) {
        		if ($_REQUEST['my_sef'] == '') $_REQUEST['my_sef'] = $_REQUEST['my_title'];
        		creat_static ();
        	}