/** * A general Utility method that merges HTML_Template_Flexy_Elements * Static method - no native debug avaiable.. * * @param HTML_Template_Flexy_Element $original (eg. from getElements()) * @param HTML_Template_Flexy_Element $new (with data to replace/merge) * @return HTML_Template_Flexy_Element the combined/merged data. * @static * @access public */ function mergeElement($original, $new) { // no original - return new if (!$original) { return $new; } // no new - return original if (!$new) { return $original; } // If the properties of $original differ from those of $new and // they are set on $new, set them to $new's. Otherwise leave them // as they are. if ($new->tag && $new->tag != $original->tag) { $original->tag = $new->tag; } if ($new->override !== false) { $original->override = $new->override; } if (count($new->children)) { //echo "<PRE> COPY CHILDREN"; print_r($from->children); $original->children = $new->children; } if (is_array($new->attributes)) { foreach ($new->attributes as $key => $value) { $original->attributes[$key] = $value; } } // originals never have prefixes or suffixes.. $original->prefix = $new->prefix; $original->suffix = $new->suffix; if ($new->value !== null) { $original->setValue($new->value); } return $original; }
public static function imgManager($img, $status) { global $_conf; $is_xhtml = !$_conf['ktai']; global $ini; $mng = array(); // フォーム要素の属性 $mfa_input = array('flexy:xhtml' => $is_xhtml, '/' => $is_xhtml); $mfa_checkbox = array_merge($mfa_input, array('type' => 'checkbox', 'name' => 'change[]', 'id' => "img{$img['id']}_change", 'value' => $img['id'], 'onclick' => "if(this.checked==false){resetRow('img{$img['id']}', {$status['rank']})}")); $mfa_remove = array_merge($mfa_input, array('type' => 'checkbox', 'name' => "img[{$img['id']}][remove]", 'id' => "img{$img['id']}_remove", 'value' => 1, 'onclick' => "var b=document.getElementById('img{$img['id']}_black');if(this.checked==true){b.disabled=false;updateDB('img{$img['id']}');}else{b.disabled=true;}")); $mfa_black = array_merge($mfa_input, array('type' => 'checkbox', 'name' => "img[{$img['id']}][black]", 'id' => "img{$img['id']}_black", 'value' => 1, 'onclick' => "updateDB('img{$img['id']}')", 'disabled' => true)); $mfa_radio = array_merge($mfa_input, array('type' => 'radio', 'onclick' => "updateDB('img{$img['id']}')")); $mfa_hidden_rank = array_merge($mfa_input, array('type' => 'hidden', 'name' => "img[{$img['id']}][hidden_rank]", 'id' => "img{$img['id']}_hidden_rank", 'disabled' => true)); $mfa_hidden_msg = array_merge($mfa_input, array('type' => 'hidden', 'name' => "img[{$img['id']}][hidden_msg]", 'id' => "img{$img['id']}_hidden_msg", 'disabled' => true)); $mfa_textarea = array('name' => "img[{$img['id']}][memo]", 'id' => "img{$img['id']}_memo", 'cols' => $ini['Manager']['cols'], 'rows' => $ini['Manager']['rows'], 'onchange' => "updateDB('img{$img['id']}')", 'flexy:xhtml' => $is_xhtml); // DBを更新するチェックボックス $mf_change = new HTML_Template_Flexy_Element('input', $mfa_checkbox); $mng['f_change'] = $mf_change->toHtml(); // あぼーん(rankを-1にして画像を削除)するラジオボタン $mf_aborn = new HTML_Template_Flexy_Element('input', $mfa_radio); $mf_aborn->setAttributes(array('name' => "img[{$img['id']}][rank]", 'id' => "img{$img['id']}_aborn", 'value' => -1)); if ($status['rank'] == -1) { $mf_aborn->setAttributes('checked'); } $mng['f_aborn'] = $mf_aborn->toHtml(); // ランクを変更するラジオボタン $mng['f_rank'] = array(); for ($i = 0; $i < 6; $i++) { $mf_rank = new HTML_Template_Flexy_Element('input', $mfa_radio); $mf_rank->setAttributes(array('name' => "img[{$img['id']}][rank]", 'id' => "img{$img['id']}_rank{$i}", 'value' => $i)); if ($status['rank'] == $i) { $mf_rank->setAttributes('checked'); $mfa_hidden_rank['value'] = $i; } $mng['f_rank'][] = $mf_rank->toHtml(); } $mf_hidden_rank = new HTML_Template_Flexy_Element('input', $mfa_hidden_rank); $mng['f_hidden_rank'] = $mf_hidden_rank->toHtml(); // メモ内容を変更するテキストエリア $mf_memo = new HTML_Template_Flexy_Element('textarea', $mfa_textarea); $mf_memo->setValue($status['memo']); $mng['f_memo'] = $mf_memo->toHtml(); // メモ内容の初期状態を保存する隠し要素 $mf_hidden_msg = new HTML_Template_Flexy_Element('input', $mfa_hidden_msg); $mf_hidden_msg->setValue($status['memo']); $mng['f_hidden_msg'] = $mf_hidden_msg->toHtml(); // 画像を削除するチェックボックス $mf_remove = new HTML_Template_Flexy_Element('input', $mfa_remove); $mng['f_remove'] = $mf_remove->toHtml(); $mf_black = new HTML_Template_Flexy_Element('input', $mfa_black); $mng['f_black'] = $mf_black->toHtml(); return $mng; }