참고 : http://wiki.redjini.com/linux/script

사용법

function name(){
  shell command
}

예제

function my_function(){
   echo "my function"
}

my_function

지역변수 (Local variables)

value=1234;

function my_function(){
   local value=5678
   echo "function: value= ${value}"
}

echo "before  : value= ${value}"

# call my_function
my_function

echo "after   : value= ${value}"

실행결과

before  : value= 1234
function: value= 5678
after   : value= 1234

인자 : parameters

function my_function(){
   local value=$1
   echo "my_function= ${value}"
}

# call my_function
my_function 5678

결과 전달받기

#!/bin/sh
function my_function(){
   local value=$1
   echo "my_function= ${value}"
}

# call my_function
result=$(my_function 5678)

echo "my_function [ ${result} ]"

function my_function(){
    echo "argv: $1 $2"
    return 10
}

# call my_function
my_function "myname" "acepro"
result=$?

echo "my_function [ ${result} ]"

function my_function(){
    echo "argv: $1 $2"
    eval "$3='result'"
}

# call my_function
result=""
my_function "myname" "acepro" result

echo "my_function [ ${result} ]"

2014/01/09 18:23 2014/01/09 18:23
태그 : , , ,
글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

interface/common/blog/list.php 파일 수정

 
foreach ($list['items'] as $item) {    
    //== ACEPRO ================================================================
    $visible = _t('visible etc');
    if (isset($item['visibility'])) {
        if($item['visibility']==0){
            $visible = _t('visible private'   );
        }else
        if($item['visibility']==1){
            $visible = _t('visible protected' );
        }else
        if($item['visibility']==2){
            $visible = _t('visible public'    );
        }else
        if($item['visibility']==3){
            $visible = _t('visible syndicated');
        }
    }
    //== ACEPRO ================================================================

    $author        = User::getName($item['userid']);
    $itemsView .= str_replace(
        array(
            '[##_list_rep_regdate_##]',
            '[##_list_rep_name_##]',
            '[##_list_rep_author_##]',
            '[##_list_rep_link_##]',
            '[##_list_rep_title_##]',
            '[##_list_rep_rp_cnt_##]',
            '[##_list_rep_visible_##]'
        ),
        array(
            fireEvent('ViewListDate', Timestamp::formatDate($item['published']), $item['published']),
            fireEvent('ViewListName', htmlspecialchars($author)),
            fireEvent('ViewListName', htmlspecialchars($author)),
            ((!empty($skinSetting['showListWithTotalEntries'])) ? "#entry_".$item['id'] :
            "$blogURL/" . ($blog['useSloganOnPost'] ? 'entry/' . URL::encode($item['slogan'],$service['useEncodedURL']) : $item['id'])).(isset($list['category']) ? '?category='.$list['category'] : ''),
            fireEvent('ViewListTitle', htmlspecialchars($item['title'])),
            ($item['comments'] > 0) ? "({$item['comments']})" : '',
            $visible
        ),
        $skin->listItem
    );
}

library/model/blog.entry.php 수정

SQL에 문에 e.visibility 항목 추가

function getEntryListWithPagingByCategory($blogid, $category, $page, $count) {
    global $database, $suri, $folderURL, $blog;
    if ($category === null)
        return array();
    if (!doesHaveOwnership() && getCategoryVisibility($blogid, $category) < 2 && $category != 0)
        return array();
    if ($category > 0) {
        $categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = $blogid AND parent = $category");
        array_push($categories, $category);
        if(!doesHaveOwnership()) 
            $categories = array_diff($categories, getCategoryVisibilityList($blogid, 'private'));
        $cond = 'AND e.category IN (' . implode(', ', $categories) . ')';
        $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0';
    } else {
        $cond = 'AND e.category >= 0';
        $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0'.getPrivateCategoryExclusionQuery($blogid);
    }
    $visibility .= (doesHaveOwnership() && !Acl::check('group.editors')) ? ' AND (e.userid = '.getUserId().' OR e.visibility > 0)' : '';

    $sql = "SELECT e.blogid,e.userid,e.id,e.title,e.comments,e.slogan,e.published,e.visibility
            FROM {$database['prefix']}Entries e 
            WHERE e.blogid = $blogid AND e.draft = 0 $visibility $cond 
            ORDER BY e.published DESC";
    return Paging::fetch($sql, $page, $count, "$folderURL/".((!getBlogSetting('useSloganOnCategory',true) && isset($suri['id'])) ? $suri['id'] : $suri['value']));
}

interface/common/blog/entries.php 수정

            if (doesHaveOwnership() && ($entry['userid'] == getUserId() || Acl::check('group.editors')===true)) {
                $managementView = $skin->management;
                $useEncodedURL = false;
                if( isset($service['useEncodedURL'])) {
                    $useEncodedURL = $service['useEncodedURL'];
                }
                dress('s_ad_m_link', "$blogURL/owner/entry/edit/{$entry['id']}?returnURL=" . ($useEncodedURL ? $permalink : str_replace('%2F', '/', rawurlencode($permalink))), $managementView);
                dress('s_ad_m_onclick', "editEntry({$entry['id']},'".($useEncodedURL ? $permalink : str_replace('%2F', '/', rawurlencode($permalink)))."'); return false;", $managementView);
                dress('s_ad_s1_label', getEntryVisibilityName($entry['visibility']), $managementView);
                if ($entry['visibility'] < 2) {
                    dress('s_ad_s2_label', _text('공개로 변경합니다'), $managementView);
                    dress('s_ad_s2_onclick', "changeVisibility({$entry['id']}, 2); return false;", $managementView);
                } else {
                    dress('s_ad_s2_label', _text('비공개로 변경합니다'), $managementView);
                    dress('s_ad_s2_onclick', "changeVisibility({$entry['id']}, 0); return false;", $managementView);
                }
                dress('s_ad_t_onclick', "sendTrackback({$entry['id']}); return false;", $managementView);
                dress('s_ad_d_onclick', "deleteEntry({$entry['id']}); return false;", $managementView);
                
                //== ACEPRO ===============================================
                if($entry['visibility']==0){
                    dress('s_ad_m_visible', "visible private"    , $managementView);
                }else
                if($entry['visibility']==1){
                    dress('s_ad_m_visible', "visible protected"    , $managementView);
                }else
                if($entry['visibility']==2){
                    dress('s_ad_m_visible', "visible public"    , $managementView);
                }else
                if($entry['visibility']==3){
                    dress('s_ad_m_visible', "visible syndicated", $managementView);
                }
                //== ACEPRO ===============================================
                dress('ad_div', $managementView, $entryView);
            }
            $author = User::getName($entry['userid']);
            dress('article_rep_author', fireEvent('ViewPostAuthor', $author, $entry['id']), $entryView);
            dress('article_rep_author_link', $blogURL."/author/".rawurlencode($author), $entryView);
            dress('article_rep_id', $entry['id'], $entryView);
            dress('article_rep_link', $permalink, $entryView);
            dress('article_rep_rp_rssurl', $defaultURL.'/rss/comment/'.$entry['id'], $entryView);
            dress('article_rep_tb_rssurl', $defaultURL.'/rss/trackback/'.$entry['id'], $entryView);
            dress('article_rep_response_rssurl', $defaultURL.'/rss/response/'.$entry['id'], $entryView);
            dress('article_rep_rp_atomurl', $defaultURL.'/atom/comment/'.$entry['id'], $entryView);
            dress('article_rep_tb_atomurl', $defaultURL.'/atom/trackback/'.$entry['id'], $entryView);
            dress('article_rep_response_atomurl', $defaultURL.'/atom/response/'.$entry['id'], $entryView);
            dress('article_rep_category_body_id',getCategoryBodyIdById($blogid,$entry['category']) ? getCategoryBodyIdById($blogid,$entry['category']) : 'tt-body-category',$entryView);
            dress('article_rep_title', htmlspecialchars(fireEvent('ViewPostTitle', $entry['title'], $entry['id'])), $entryView);
            // 사용자가 작성한 본문은 interface/common/blog/end.php의 removeAllTags() 다음에 처리하기 위한 조치.
            $contentContainer["article_{$entry['id']}"] = getEntryContentView($blogid, $entry['id'], $entry['content'], $entry['contentformatter'], getKeywordNames($blogid));
            dress('article_rep_desc', setTempTag("article_{$entry['id']}"), $entryView);
            dress('article_rep_category', htmlspecialchars(empty($entry['category']) ? _text('분류없음') : $entry['categoryLabel'], $entry['id']), $entryView);
            dress('article_rep_category_link', "$blogURL/category/".(empty($entry['category']) ? "" : ($blog['useSloganOnCategory'] ? URL::encode($entry['categoryLabel'],$service['useEncodedURL']) : $entry['category'])),$entryView);
            dress('article_rep_category_rssurl', "$defaultURL/rss/category/".(empty($entry['category']) ? "" : ($blog['useSloganOnCategory'] ? URL::encode($entry['categoryLabel'],$service['useEncodedURL']) : $entry['category'])),$entryView);
            dress('article_rep_category_atomurl', "$defaultURL/atom/category/".(empty($entry['category']) ? "" : ($blog['useSloganOnCategory'] ? URL::encode($entry['categoryLabel'],$service['useEncodedURL']) : $entry['category'])),$entryView);
            dress('article_rep_microformat_published', Timestamp::getISO8601($entry['published']), $entryView);
            dress('article_rep_microformat_updated', Timestamp::getISO8601($entry['modified']), $entryView);
            dress('article_rep_date', fireEvent('ViewPostDate', Timestamp::format5($entry['published']), $entry['published']), $entryView);
            dress('article_rep_date_modified', fireEvent('ViewPostDate', Timestamp::format5($entry['modified']), $entry['modified']), $entryView);
            dress('entry_archive_link', "$blogURL/archive/" . Timestamp::getDate($entry['published']), $entryView);
            //== ACEPRO ===============================================
            dress('article_rep_category_id', empty($entry['category']) ? "" : $entry['category'],$entryView);
            //== ACEPRO ===============================================

skin.html 파일 수정

<s_list> <!-- 글검색(Content) -->
    <div id="searchList">
        <h1>'[##_list_conform_##]'에 관한 글 [##_list_count_##]개</h1>
        <ul>
            <s_list_rep>
                <li>
                    <span class="date [##_list_rep_visible_##]">[##_list_rep_regdate_##]</span>
                    <a href="[##_list_rep_link_##]">[##_list_rep_title_##]</a>
                    <span class="cnt">[##_list_rep_rp_cnt_##]</span>
                </li>
            </s_list_rep>
        </ul>
    </div>
</s_list> 

style.css 파일 수정

아이콘 이미지 파일은 skin/admin/whitedream/image에 있는 아이콘 파일을 이용.

#searchList .date.visible{
    display: inline-block;
    width  : 65px;
    padding-left       : 22px;
    background-repeat  : no-repeat;
}
#searchList .date.public{
    background-image : url("/resources/image/icon/icon_public.gif");
}
#searchList .date.private{
    background-image : url("/resources/image/icon/icon_private.gif");
    background-position: left bottom;
}
#searchList .date.protected{
    background-image : url("/resources/image/icon/icon_protected.gif");
}
#searchList .date.syndicated{
    background-image : url("/resources/image/icon/icon_syndicated.gif");
}

적용결과

사용자 삽입 이미지

2014/01/06 23:47 2014/01/06 23:47
글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

[jQuery] jQuery.load

문법

    .load( url [, data ] [, complete(responseText, textStatus, XMLHttpRequest) ] )  Returns: jQuery
  • url
    Type: String
    A string containing the URL to which the request is sent.
  • data
    Type: PlainObject or String
    A plain object or string that is sent to the server with the request.
  • complete(responseText, textStatus, XMLHttpRequest)
    Type: Function()
    A callback function that is executed when the request completes.

셈플

  1. subpage/page_01.php 내용
    <div id="div_sub1"> 
        div: id=div_sub1
        <p> p: test 1</p>
        <p> p: test 2</p>
    </div>
    <div id="div_sub2"> div: id=div_sub2</div>
    <div id="div_sub3"> div: id=div_sub3</div>
    
  2. subpage/page_01.php의 모든 내용 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php", function(res, status, xhr){
            console.log( xhr );
        });
    });
    
  3. subpage/page_01.php의 모든 내용중 P Tag element만 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php p", function(res, status, xhr){
            console.log( xhr );
        });
    });
    
  4. subpage/page_01.php의 모든 내용중 P Tag, ID가 div_sub2인 element만 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php p,#div_sub3", function(res, status, xhr){
            console.log( xhr );
        });
    });
    

 참고

"JavaScript / jQuery" 분류의 다른 글

[jQuery] jQuery가 지원하는 셀렉터들 (0)2014/01/02
[jQuery] DatePicker (0)2013/12/03
2014/01/03 12:45 2014/01/03 12:45
태그 : ,
글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다