本文整理汇总了PHP中Setting::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::factory方法的具体用法?PHP Setting::factory怎么用?PHP Setting::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::factory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_languages_setting
private function update_languages_setting()
{
//get language setting
$lngsett = Setting::factory("default_language");
//get all languages
$languages = Language::factory()->get();
$lngsettarr = array();
foreach ($languages as $lng) {
$lngsettarr[] = $lng->name;
}
$lngsett->set_options($lngsettarr)->save();
}
示例2: init
public function init()
{
header("Content-Type: application/x-javascript");
echo "var IU_SITE_URL = '" . str_replace("'", "\\'", rtrim(site_url(), '/')) . "';\n";
echo "var IU_BASE_URL = '" . str_replace("'", "\\'", base_url()) . "';\n";
echo "var IU_GLOBALS = {}; //throw anything in here\n";
$pages = Page::factory()->get();
$pages_arr = array();
foreach ($pages as $p) {
$page = new stdClass();
$page->uri = $p->uri;
$page->label = $p->title . ' ' . $p->uri;
$page->url = site_url($p->uri);
$page->title = character_limiter($p->title, 50);
$page->id = $p->id;
$pages_arr[] = $page;
}
echo "var IU_PAGES = " . json_encode($pages_arr) . ";\n";
$settings = Setting::factory()->where('group !=', 'hidden')->where('group !=', 'branding')->get();
$setts = array();
foreach ($settings as $s) {
$setts[$s->name] = $s->value;
}
echo "var IU_SETTINGS = " . json_encode($setts) . ";\n";
if (!empty($this->user)) {
$juser = $this->user->stored;
unset($juser->salt);
unset($juser->password);
unset($juser->key);
unset($juser->active);
echo "var IU_USER = " . json_encode($juser) . ";\n";
$perms = Permission::factory()->where_related_user('id', $this->user->id)->get();
$permarr = array();
foreach ($perms as $p) {
$permarr[] = $p->key;
}
echo "var IU_USER_PERMISSIONS = " . json_encode($permarr) . ";\n";
}
}
示例3: update_templates
private function update_templates()
{
return true;
$tmplts = scandir('./iu-application/views/');
array_shift($tmplts);
// remove '.' from array
array_shift($tmplts);
// remove '..' from array
$templates = $tmplts;
for ($i = 0; $i < count($tmplts); $i++) {
if (!is_dir('./iu-application/views/' . $tmplts[$i])) {
unset($templates[$i]);
}
if (in_array($tmplts[$i], array('administration', 'setup'))) {
unset($templates[$i]);
}
}
//get template setting
$lngsett = Setting::factory("default_template");
//save with new options
$lngsett->set_options($templates)->save();
}
示例4: index
public function index()
{
//get stats
$last15 = Hit::factory()->fetch(time() - 60 * 15)->unique()->cnt();
$last15bymin = Hit::timeflow(time() - 60 * 15, null, 15);
$last4hrs = Hit::factory()->fetch(time() - 3600 * 4)->unique()->cnt();
$last4hrsbymin = Hit::timeflow(time() - 3600 * 4, null, 16);
$today = Hit::factory()->fetch(mktime(0, 0, 0))->unique()->cnt();
$todaybymin = Hit::timeflow(mktime(0, 0, 0), null, 24);
$yesterday = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0))->unique()->cnt();
$yesterdaybymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24, mktime(0, 0, 0), 24);
$lastweek = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 7)->unique()->cnt();
$lastweekbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 14);
$lastmonth = Hit::factory()->fetch(mktime(0, 0, 0) - 3600 * 24 * 30)->unique()->cnt();
$lastmonthbymin = Hit::timeflow(mktime(0, 0, 0) - 3600 * 24 * 7, null, 30);
$returning = Hit::factory()->fetch(time() - 3600 * 24 * 30)->unique()->where('returning', true)->cnt();
$new_pages = Page::factory()->where('created >=', time() - 3600 * 24 * 30)->get()->result_count();
$countries = Hit::factory()->fetch(time() - 3600 * 24 * 30)->group_by('country')->cnt();
$pagehits = Hit::factory()->select('*,count(page_id) as cnt')->include_related('page', null, TRUE, TRUE)->where('page_id >', 0)->fetch(time() - 3600 * 24 * 7)->group_by('page_id')->limit(1)->get();
$this->templatemanager->assign('pagehits', $pagehits);
$ping = false;
$pingset = Setting::factory('last_ping');
$lastping = (int) $pingset->value;
if (time() - $lastping > 3600 * 24 * 7) {
$ping = true;
}
$pingset->value = time();
$pingset->save();
$this->templatemanager->assign('last15', $last15);
$this->templatemanager->assign('last15bymin', $last15bymin);
$this->templatemanager->assign('last4hrs', $last4hrs);
$this->templatemanager->assign('last4hrsbymin', $last4hrsbymin);
$this->templatemanager->assign('today', $today);
$this->templatemanager->assign('todaybymin', $todaybymin);
$this->templatemanager->assign('yesterday', $yesterday);
$this->templatemanager->assign('yesterdaybymin', $yesterdaybymin);
$this->templatemanager->assign('lastweek', $lastweek);
$this->templatemanager->assign('lastweekbymin', $lastweekbymin);
$this->templatemanager->assign('lastmonth', $lastmonth);
$this->templatemanager->assign('lastmonthbymin', $lastmonthbymin);
$this->templatemanager->assign('returning', $returning);
$this->templatemanager->assign('new_pages', $new_pages);
$this->templatemanager->assign('countries', $countries);
$this->templatemanager->assign('ping', $ping);
//latest repeatables
$last_repeatables = RepeatableItem::factory()->order_by('timestamp DESC')->limit(5)->get();
$this->templatemanager->assign('last_repeatables', $last_repeatables);
//latest contents updated
$last_contents = Content::factory()->where_related_contenttype('classname', 'Html')->order_by('updated DESC, created DESC')->limit(10)->get();
$this->templatemanager->assign('last_contents', $last_contents);
//count content updates (revisions)
$revs = ContentRevision::factory()->count();
$this->templatemanager->assign('revisions', $revs);
//if geoip is old, notify
$geoip_db_filename = './iu-resources/geoip/GeoIP.dat';
if (is_file($geoip_db_filename)) {
$month_earlier = time() - 3600 * 24 * 30;
$filemtime = filemtime($geoip_db_filename);
if ($this->user->can('edit_settings') && $filemtime <= $month_earlier) {
$lnk = site_url('administration/maintenance');
$this->templatemanager->notify(__("Your GeoIP database is now older than one month! Consider <a href='{$lnk}'>updating it</a>!"), 'information');
}
}
//get latest users
$users = User::factory()->order_by('created DESC')->limit(5)->get();
$this->templatemanager->assign('users', $users);
$this->templatemanager->show_template("dashboard");
}