本文整理汇总了PHP中css::extractSelectorRules方法的典型用法代码示例。如果您正苦于以下问题:PHP css::extractSelectorRules方法的具体用法?PHP css::extractSelectorRules怎么用?PHP css::extractSelectorRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类css
的用法示例。
在下文中一共展示了css::extractSelectorRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addBlockAction
/**
* Add a block
* @param string $popBlock
* @param string $parentBlock
* @param string $idBlock
* @param string $id_next_block
* @param string $stop_typecont
* @return string
*/
protected function addBlockAction($popBlock, $parentBlock, $idBlock, $id_next_block, $stop_typecont, $content, $MODULE, $THEMEMODULE, $THEME)
{
$this->initObjects();
$idBlock = strtolower($idBlock);
if ($stop_typecont === 'page') {
/* block id in page have to start with a capital */
$idBlock = ucfirst($idBlock);
}
$tempBlock = new $popBlock($idBlock);
$idBlock = $tempBlock->getId();
/* To sanitize id */
if (method_exists($tempBlock, 'onMove')) {
/* init path of views */
if ($stop_typecont === 'theme') {
if ($tempBlock->onMove('theme', $THEMEMODULE, $THEME)) {
return $this->returnResult(array('notification' => t('ID block already exists in this theme, please choose antother')));
}
} else {
if ($tempBlock->onMove('page', $MODULE, $this->page->getId())) {
return $this->returnResult(array('notification' => t('ID block already exists in this page, please choose antother')));
}
}
}
if (!empty($content) && method_exists($tempBlock, 'setContent')) {
/* external DND */
$tempBlock->setContent($content);
}
$block = $this->{$stop_typecont}->searchBlock($parentBlock);
$block->addBlock($tempBlock, $id_next_block);
/* If exists : Add default block CSS in current theme */
if (is_file('modules/' . str_replace('\\', '/', $popBlock) . '/default.css')) {
$css = new \css('modules/' . str_replace('\\', '/', $popBlock) . '/default.css');
if (!is_file(PROFILE_PATH . $THEMEMODULE . '/themes/' . $THEME . '/style.css') && is_file('modules/' . $this->theme->getModule() . '/themes/' . $this->theme->getName() . '/style.css')) {
file_put_contents(PROFILE_PATH . $THEMEMODULE . '/themes/' . $THEME . '/style.css', file_get_contents('modules/' . $this->theme->getModule() . '/themes/' . $this->theme->getName() . '/style.css'));
}
$cssCurrentTheme = new \css(PROFILE_PATH . $THEMEMODULE . '/themes/' . $THEME . '/style.css');
foreach ($css->getAllSselectors() as $selector) {
$rules = $css->extractSelectorRules($selector);
if (!empty($rules)) {
$newSelector = '#' . $idBlock . ' ' . str_replace(':host', '', $selector);
if (!$cssCurrentTheme->selectorExists($newSelector)) {
$cssCurrentTheme->addSelector($newSelector);
}
foreach ($rules as $property => $value) {
$value = str_replace('BASE_PATH', BASE_PATH, $value);
if (!$cssCurrentTheme->propertyExists($newSelector, $property)) {
$cssCurrentTheme->addProperty($newSelector, $property, $value);
} else {
$cssCurrentTheme->updateProperty($newSelector, $property, $value);
}
}
}
}
$cssCurrentTheme->save();
}
$response = $tempBlock->ajaxRefresh('add');
/* Get content before __sleep() */
$this->saveAll();
if ($this->{$stop_typecont}->searchBlock($idBlock) != NULL) {
$return = array('eval' => $response, 'notification' => t('The Block is saved'), 'notificationType' => 'positive');
} else {
$return = array('notification' => t('Error on drop'), 'notificationType' => 'negative');
}
return $this->returnResult($return);
}