本文整理汇总了PHP中Widget::has_extension方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::has_extension方法的具体用法?PHP Widget::has_extension怎么用?PHP Widget::has_extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::has_extension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->Title) {
$this->Title = Config::inst()->get($this->class, 'title');
}
if (Widget::has_extension('Versioned') && Versioned::current_stage() == 'Stage') {
$this->publishAfterWrite = true;
}
}
示例2: onBeforeDelete
public function onBeforeDelete()
{
if (Widget::has_extension('Versioned')) {
$currentStage = Versioned::current_stage();
Versioned::reading_stage('Stage');
parent::onBeforeDelete();
Versioned::reading_stage('Live');
parent::onBeforeDelete();
Versioned::reading_stage($currentStage);
} else {
parent::onBeforeDelete();
}
}
示例3: createDashboard
public function createDashboard($name, $createDefault = false)
{
$url = preg_replace('/ +/', '-', trim($name));
// Replace any spaces
$url = preg_replace('/[^A-Za-z0-9.+_\\-]/', '', $url);
// Replace non alphanumeric characters
$url = strtolower($url);
$existing = $this->getNamedDashboard($url);
if ($existing) {
return $existing;
}
$dashboard = new DashboardPage();
$dashboard->URLSegment = $url;
$dashboard->Title = trim($name);
$dashboard->OwnerID = $this->owner->ID;
$dashboard->write();
if ($createDefault) {
$currentStage = null;
if (Widget::has_extension('Versioned')) {
$currentStage = Versioned::current_stage();
Versioned::reading_stage('Stage');
}
$layout = Config::inst()->get('DashboardUser', 'default_layout');
if (count($layout)) {
foreach ($layout as $type => $properties) {
if (class_exists($type)) {
$dashlet = $type::create();
/* @var $dashlet Dashlet */
$dashletColumn = isset($properties['DashletColumn']) ? $properties['DashletColumn'] : 0;
$db = $dashboard->getDashboard($dashletColumn);
if ($db && $dashlet->canCreate()) {
$dashlet->ParentID = $db->ID;
if (is_array($properties)) {
$dashlet->update($properties);
}
$dashlet->write();
}
}
}
}
if ($currentStage) {
Versioned::reading_stage($currentStage);
}
$dashboard = $this->getNamedDashboard($url);
$this->owner->extend('updateCreatedDashboard', $dashboard);
}
return $dashboard;
}