本文整理汇总了PHP中Model::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::instance方法的具体用法?PHP Model::instance怎么用?PHP Model::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Instance
public static function Instance()
{
if (self::$instance == null) {
self::$instance = new Model();
}
return self::$instance;
}
示例2: get_instance
public static function get_instance()
{
if (self::$instance == null) {
self::$instance = new self();
}
return self::$instance;
}
示例3: getInstance
/**
* Singleton constructor
* @return static
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new static();
}
return self::$instance;
}
示例4: getInstance
public static function getInstance()
{
if (self::$instance == NULL) {
self::$instance = new Model();
}
return self::$instance;
}
示例5: index
public function index()
{
$model = Model::instance();
ipAddJs('Ip/Internal/Grid/assets/grid.js');
ipAddJs('Ip/Internal/Grid/assets/gridInit.js');
ipAddJs('Ip/Internal/Grid/assets/subgridField.js');
$notes = array();
if (isset($_SESSION['Ip']['notes']) && is_array($_SESSION['Ip']['notes'])) {
$notes = $_SESSION['Ip']['notes'];
}
unset($_SESSION['Ip']['notes']);
$enableUpdate = !defined('MULTISITE_WEBSITES_DIR');
// Disable update in MultiSite installation.
$trash = array('size' => \Ip\Internal\Pages\Service::trashSize());
$data = array('notes' => $notes, 'version' => \Ip\ServiceLocator::storage()->get('Ip', 'version'), 'changedUrl' => $model->getOldUrl() != $model->getNewUrl(), 'oldUrl' => $model->getOldUrl(), 'newUrl' => $model->getNewUrl(), 'migrationsAvailable' => \Ip\Internal\Update\Service::migrationsAvailable(), 'migrationsUrl' => ipActionUrl(array('pa' => 'Update')), 'recoveryPageForm' => \Ip\Internal\System\Helper::recoveryPageForm(), 'emptyPageForm' => \Ip\Internal\System\Helper::emptyPageForm(), 'trash' => $trash);
$content = ipView('view/index.php', $data)->render();
if ($enableUpdate) {
ipAddJs('Ip/Internal/System/assets/update.js');
}
if ($trash['size'] > 0) {
ipAddJs('Ip/Internal/Core/assets/js/angular.js');
ipAddJs('Ip/Internal/System/assets/trash.js');
}
ipAddJs('Ip/Internal/System/assets/migrations.js');
ipAddJs('assets/cache.js');
return $content;
}
示例6: checkForUpdates
private static function checkForUpdates()
{
$module = Model::instance();
$systemInfo = $module->getIpNotifications();
if ($systemInfo != '') {
//send an email
$md5 = \Ip\ServiceLocator::storage()->get('Ip', 'lastSystemMessageSent');
if (!$md5 || $md5 != md5(serialize($systemInfo))) {
//we have a new message
$message = '';
$messages = $systemInfo;
if (is_array($messages)) {
foreach ($messages as $messageVal) {
$message .= '<p>' . $messageVal->message . '</p>';
}
$onlyStatusMessages = true;
foreach ($messages as $messageVal) {
if ($messageVal->type != 'status') {
$onlyStatusMessages = false;
}
}
if ($onlyStatusMessages) {
return;
//TODO replace to something that would not terminate execution of following scripts if they will be there some day
}
} else {
return;
//TODO replace to something that would not terminate execution of following scripts if they will be there some day
}
ipEvent('ipSystemMessages', array('messages' => $messages));
\Ip\ServiceLocator::storage()->set('Ip', 'lastSystemMessageSent', md5(serialize($systemInfo)));
}
}
}
示例7: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Model();
}
return self::$instance;
}
示例8: downloadTheme
public function downloadTheme($name, $url, $signature)
{
$model = Model::instance();
//download theme
$net = new \Ip\Internal\NetHelper();
$themeTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
if (!$themeTempFilename) {
throw new \Ip\Exception('Theme file download failed.');
}
$archivePath = ipFile('file/secure/tmp/' . $themeTempFilename);
//check signature
$fileMd5 = md5_file($archivePath);
$rsa = new \Crypt_RSA();
$rsa->loadKey($this->publicKey);
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$verified = $rsa->verify($fileMd5, base64_decode($signature));
if (!$verified) {
throw new \Ip\Exception('Theme signature verification failed.');
}
//extract
$helper = Helper::instance();
$secureTmpDir = ipFile('file/secure/tmp/');
$tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
\Ip\Internal\Helper\Zip::extract($secureTmpDir . $themeTempFilename, $secureTmpDir . $tmpExtractedDir);
unlink($archivePath);
//install
$extractedDir = $helper->getFirstDir($secureTmpDir . $tmpExtractedDir);
$installDir = $model->getThemeInstallDir();
$newThemeDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newThemeDir);
}
示例9: getAdminNavbarHtml
protected static function getAdminNavbarHtml()
{
$requestData = \Ip\ServiceLocator::request()->getRequest();
$curModTitle = '';
$curModUrl = '';
$curModIcon = '';
if (!empty($requestData['aa'])) {
$parts = explode('.', $requestData['aa']);
$curModule = $parts[0];
} else {
$curModule = "Content";
}
if (isset($curModule) && $curModule) {
$title = $curModule;
$plugin = \Ip\Internal\Plugins\Service::getPluginConfig($curModule);
if ($plugin) {
$title = $plugin['title'];
}
$curModTitle = __($title, 'Ip-admin', false);
$curModUrl = ipActionUrl(array('aa' => $curModule . '.index'));
$curModIcon = Model::getAdminMenuItemIcon($curModule);
}
$navbarButtons = array(array('text' => '', 'hint' => __('Logout', 'Ip-admin', false), 'url' => ipActionUrl(array('sa' => 'Admin.logout')), 'class' => 'ipsAdminLogout', 'faIcon' => 'fa-power-off'));
$navbarButtons = ipFilter('ipAdminNavbarButtons', $navbarButtons);
$navbarCenterElements = ipFilter('ipAdminNavbarCenterElements', array());
$data = array('menuItems' => Model::instance()->getAdminMenuItems($curModule), 'curModTitle' => $curModTitle, 'curModUrl' => $curModUrl, 'curModIcon' => $curModIcon, 'navbarButtons' => array_reverse($navbarButtons), 'navbarCenterElements' => $navbarCenterElements);
$html = ipView('view/navbar.php', $data)->render();
return $html;
}
示例10: initConfig
protected static function initConfig()
{
ipAddCss('Ip/Internal/Core/assets/admin/admin.css');
ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
ipAddJsVariable('ipTranslationSaving', __('Saving...', 'Ip-admin', false));
ipAddJs('Ip/Internal/Design/assets/optionsBox.js');
ipAddJsVariable('ipModuleDesignConfiguration', Helper::getConfigurationBoxHtml());
if (file_exists(ipThemeFile(Model::INSTALL_DIR . 'Options.js'))) {
ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'Options.js'));
} elseif (file_exists(ipThemeFile(Model::INSTALL_DIR . 'options.js'))) {
ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'options.js'));
}
$model = Model::instance();
$theme = $model->getTheme(ipConfig()->theme());
if (!$theme) {
throw new \Ip\Exception("Theme doesn't exist");
}
$options = $theme->getOptionsAsArray();
$fieldNames = array();
foreach ($options as $option) {
if (empty($option['name'])) {
continue;
}
$fieldNames[] = $option['name'];
}
ipAddJsVariable('ipModuleDesignOptionNames', $fieldNames);
}
示例11: compileFile
/**
* @param string $themeName
* @param string $lessFile
* @return string
*/
public function compileFile($themeName, $lessFile)
{
$model = Model::instance();
$theme = $model->getTheme($themeName);
$options = $theme->getOptionsAsArray();
$configModel = ConfigModel::instance();
$config = $configModel->getAllConfigValues($themeName);
$less = "@import '{$lessFile}';";
$less .= $this->generateLessVariables($options, $config);
$css = '';
try {
require_once ipFile('Ip/Lib/less.php/Less.php');
$themeDir = ipFile('Theme/' . $themeName . '/assets/');
$ipContentDir = ipFile('Ip/Internal/Core/assets/ipContent/');
// creating new context to pass theme assets directory dynamically to a static callback function
$context = $this;
$callback = function ($parseFile) use($context, $themeDir) {
return $context->overrideImportDirectory($themeDir, $parseFile);
};
$parserOptions = array('import_callback' => $callback, 'cache_dir' => ipFile('file/tmp/less/'), 'relativeUrls' => false, 'sourceMap' => true);
$parser = new \Less_Parser($parserOptions);
$directories = array($themeDir => '', $ipContentDir => '');
$parser->SetImportDirs($directories);
$parser->parse($less);
$css = $parser->getCss();
$css = "/* Edit {$lessFile}, not this file. */" . "\n" . $css;
} catch (\Exception $e) {
ipLog()->error('Less compilation error: Theme - ' . $e->getMessage());
}
return $css;
}
示例12: self
static function get_instance()
{
if (self::$instance instanceof self) {
return self::$instance;
}
return self::$instance = new self();
}
示例13: __callStatic
public static function __callStatic($function, $arguments)
{
// avoid cap errors
if (strtolower($function) == strtolower(get_called_class())) {
// call the constructor from an instance
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
}
示例14: urlHasChanged
public static function urlHasChanged()
{
$model = Model::instance();
$oldUrl = $model->getOldUrl();
$newUrl = $model->getNewUrl();
if ($oldUrl != $newUrl) {
return true;
} else {
return false;
}
}
示例15: getTheme
public function getTheme($name = null, $dir = null, $url = null)
{
if ($name == null) {
$name = ipConfig()->theme();
}
if ($dir == null) {
$dir = ipFile('Theme/');
}
$model = Model::instance();
$theme = $model->getTheme($name, $dir, $url);
return $theme;
}