更新drupal6的imagecachepresets到Drupal7的imagestyles_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了更新drupal6的imagecachepresets到Drupal7的imagestyles_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5805字,纯文字阅读大概需要9分钟。
内容图文
因为drupal6中的imagecache preset 已经整合到drupal7的核心中,接下来的这个解决方案是Vladimir提出的,你需要在你的drupal根目录下面创建一个php文件并将以下代码复制进去,执行这个文件.
[php]
define('DRUPAL_ROOT', getcwd());
require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
/////////////////////////////////////////////////
function imagecache_preset_actions($preset, $reset = FALSE) {
$actions_cache = array();
$result = db_query('SELECT * FROM {imagecache_action} where presetid = '.$preset['presetid'].' order by weight' );
foreach ($result as $row ) {
$row=(array)$row;
$row['data'] = unserialize($row['data']);
$actions_cache[$preset['presetid']][] = $row;
}
return isset(
$actions_cache[$preset['presetid']]) ? $actions_cache[$preset['presetid']] : array();
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
function imagecache_presets() {
$presets = array();
$normal_presets = array();
$result = db_query('SELECT * FROM {imagecache_preset} ORDER BY presetname');
foreach ($result as $preset) {
$preset=(array)$preset;
$presets[$preset['presetid']] = $preset;
$presets[$preset['presetid']]['actions'] = imagecache_preset_actions($preset);
$presets[$preset['presetid']]['storage'] = 0;
// Collect normal preset names so we can skip defaults and mark overrides accordingly
$normal_presets[$preset['presetname']] = $preset['presetid'];
}
return
$presets;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
$styles_cnt=0;
$effects_new_cnt=0;
$effects_ext_cnt=0;
$presets=imagecache_presets();
foreach($presets as $preset)
{
$styles_cnt++;// inc styles
$style=image_style_load($preset['presetname']);
$style['name']=$preset['presetname'];
$style=image_style_save($style);
if(!isset($style['effects']))
{
$style['effects']=array();
}
foreach($preset['actions'] as $action)
{
$action['action']=str_replace('imagecache','image',$action['action']);
$action['module']=str_replace('imagecache','image',$action['module']);
$effect_ieid=FALSE;// effect not exists
foreach($style['effects'] as $effect)
{
if($effect['name'] == $action['action'] &&
$effect['module'] == $action['module'] &&
$effect['weight'] == $action['weight'] &&
$effect['data'] == $action['data'] )
{
$effect_ieid=$effect['ieid'];// effect exists
}
}
$effect=array();
if($effect_ieid)
{
$effects_ext_cnt++;// inc exists
$effect=image_effect_load($effect_ieid,$style['name']);
}
else
{
$effects_new_cnt++;// inc new
$effect=image_effect_definition_load($action['action']);
}
$effect['isid'] = $style['isid'];
$effect['name'] = $action['action'];
$effect['module'] == $action['module'];
$effect['weight'] = $action['weight'];
$effect['data'] = $action['data'];
$effect = image_effect_save($effect);
$style['effects'][$effect['ieid']] = $effect;
}
$style=image_style_save($style);
}
print
"Styles: $styles_cnt, Effects new: $effects_new_cnt, Effects exists: $effects_ext_cnt \n";
?>
define('DRUPAL_ROOT', getcwd());
require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
/////////////////////////////////////////////////
function imagecache_preset_actions($preset, $reset = FALSE) {
$actions_cache = array();
$result = db_query('SELECT * FROM {imagecache_action} where presetid = '.$preset['presetid'].' order by weight' );
foreach ($result as $row ) {
$row=(array)$row;
$row['data'] = unserialize($row['data']);
$actions_cache[$preset['presetid']][] = $row;
}
return isset(
$actions_cache[$preset['presetid']]) ? $actions_cache[$preset['presetid']] : array();
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
function imagecache_presets() {
$presets = array();
$normal_presets = array();
$result = db_query('SELECT * FROM {imagecache_preset} ORDER BY presetname');
foreach ($result as $preset) {
$preset=(array)$preset;
$presets[$preset['presetid']] = $preset;
$presets[$preset['presetid']]['actions'] = imagecache_preset_actions($preset);
$presets[$preset['presetid']]['storage'] = 0;
// Collect normal preset names so we can skip defaults and mark overrides accordingly
$normal_presets[$preset['presetname']] = $preset['presetid'];
}
return
$presets;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
$styles_cnt=0;
$effects_new_cnt=0;
$effects_ext_cnt=0;
$presets=imagecache_presets();
foreach($presets as $preset)
{
$styles_cnt++;// inc styles
$style=image_style_load($preset['presetname']);
$style['name']=$preset['presetname'];
$style=image_style_save($style);
if(!isset($style['effects']))
{
$style['effects']=array();
}
foreach($preset['actions'] as $action)
{
$action['action']=str_replace('imagecache','image',$action['action']);
$action['module']=str_replace('imagecache','image',$action['module']);
$effect_ieid=FALSE;// effect not exists
foreach($style['effects'] as $effect)
{
if($effect['name'] == $action['action'] &&
$effect['module'] == $action['module'] &&
$effect['weight'] == $action['weight'] &&
$effect['data'] == $action['data'] )
{
$effect_ieid=$effect['ieid'];// effect exists
}
}
$effect=array();
if($effect_ieid)
{
$effects_ext_cnt++;// inc exists
$effect=image_effect_load($effect_ieid,$style['name']);
}
else
{
$effects_new_cnt++;// inc new
$effect=image_effect_definition_load($action['action']);
}
$effect['isid'] = $style['isid'];
$effect['name'] = $action['action'];
$effect['module'] == $action['module'];
$effect['weight'] = $action['weight'];
$effect['data'] = $action['data'];
$effect = image_effect_save($effect);
$style['effects'][$effect['ieid']] = $effect;
}
$style=image_style_save($style);
}
print
"Styles: $styles_cnt, Effects new: $effects_new_cnt, Effects exists: $effects_ext_cnt \n";
?>happy drupalling
http://www.bkjia.com/PHPjc/477273.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477273.htmlTechArticle因为drupal6中的imagecache preset 已经整合到drupal7的核心中,接下来的这个解决方案是Vladimir提出的,你需要在你的drupal根目录下面创建一个ph...
内容总结
以上是互联网集市为您收集整理的更新drupal6的imagecachepresets到Drupal7的imagestyles_PHP教程全部内容,希望文章能够帮你解决更新drupal6的imagecachepresets到Drupal7的imagestyles_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。