Improved Elgg Profile plugin/改进的Profile插件 v0.1

Release Notes

New version here:Improved Elgg Profile plugin/改进的Profile插件

New config way:

  • Which profile field config in a ElggObject with a 'profilefield' subtype,title,valuetype,category and isUnique metadata
  • function profilefield($title,$valuetype,$category,$isUnique = FALSE,$options = '') in lib.php for make field objects
  • $CONFIG->profile now is a array of profilefield object 

Pulldown type support

  • Appoint the second param of profilefield() as 'pulldown' and pass an array of options to the profilefield() funtion at the last param,it'll return a pulldown type profile field.In edit page,u got a pulldown with those options.

Birthday

  • In edit page,birthday field was split into three pulldown with year,month and day.
  • In userdetail page,it show as a text type.
  • Especially,it compute your Chinese Lunar calendar birthday and show after the Gegorian calendar birthday : )

Category

  • Profile items was shown in sections with category title in userdetials and edit page.

string_to_array()

  • In lib.php there is a mod of string_of_array(),which split string also by ',' and ' '.

Triggers

  • In edit action,before save data to database and after save done,there are plugin hooks.

特性列表:

  • 调用lib.php里的profilefield()方法得到一个详细信息条目对象,可以这个对象指定名称、类型、分类、是否全站唯一,如果是下拉列表类型还可以传递一个数组作为可选值。
  • profilefield()方法生成的'profilefield'对象的数组已经取代了原有的字符串数组作为$CONFIG->profile中保存的配置
  • 支持下拉菜单类型的条目,只需要在调用profilefield()生成一个条目对象的时候指定第二个参数为'pulldown'并给最后一个形参传递一个可选值数组
  • 添加了生日,在编辑页面显示为三个下拉列表,分别选择年、月、日
  • 在个人信息页面,公历生日后面会显示计算得到的农历生日
  • 现在可以给个人信息条目指定分类,并且在个人信息和编辑页面每个分类之间会有简单的分隔
  • tag类型的条目现在用全角逗号和空格也可以分割字符串,这是为了照顾中国用户的使用习惯做的改动。
  • 在action/edit里,保存数据之前和之后各添加了一个插件勾。

我的英语不够好,哪位大大看到我上面的英文有错的话,麻烦用任何方法联络我告知,谢谢谢谢~

  • Nice work but some problems.

    1. "甲寅(虎)年 三月十九" this is showing after the birthdatefield in the profile page.

    2. "Edit profile items" link in admin menu is gone.

    3. most of the variables are in chinese in the lib.php file. For example

    function cyclical($num) {
                $Gan = Array ("甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" );
                $Zhi = Array ("子(鼠)", "丑(牛)", "寅(虎)", "卯(兔)", "辰(龙)", "巳(蛇)", "午(马)", "未(羊)", "申(猴)", "酉(鸡)", "戌(狗)", "亥(猪)" );
                return $Gan [$num % 10] . $Zhi [$num % 12];
            }
       
            function display() {
                $nStr = array ('   ', '正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '腊' );
                $nl = sprintf ( "%s年\n%s%s月%s\n", $this->cyclical ( $this->yearCyl ), ($this->isLeap ? " 闰" : ""), $nStr [$this->month], $this->cDay ( $this->day ) );
                //echo   sprintf("农历   %s%s月%s<br>",($this->isLeap?" 闰":""),$nStr[$this->month],$this->cDay($this->day)); 
                //echo   sprintf("%s年   %s月   %s 日",$this->cyclical($this->yearCyl),$this->cyclical($this->monCyl),$this->cyclical($this->dayCyl)); 
                RETURN $nl;
            }
       
            function cDay($d) {
                $nStr1 = array ('日', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十' );
                $nStr2 = array ('初', '十', '廿', '卅', ' ' );
               
                switch ($d) {
                    case 10 :
                        $s = '初十';
                        break;
                    case 20 :
                        $s = '二十';
                        break;
                    case 30 :
                        $s = '三十';
                        break;
                    default :
                        $s = $nStr2 [floor ( $d / 10 )];
                        $s .= $nStr1 [$d % 10];
                }
                return $s;
            }
        }

    Should be in english for users to know what they are doing.

    And a feature request to show birthdates in " 14th Feb 1978" this format would be great and separate access controls for year and rest of the birthdate(day and moth) So that we can just show "14th February " to public.

    Thanks for the great work anyway.

  • "甲寅(虎)年 三月十九" is your birthday in Chinese Lunar calendar }:)

    I'll add comments to the class Lunar.This class was write by somebody else.

    Year show toggle will add later,I'm hard to get time to do this for now.

  • And,I disabled profile item edit from admin page.

    As the customized profile item doesn't use '$shortname' for metadata name,that makes this problem:U setup a customize profile item name 'website',but it dosen't show the meta named 'website' that user saved before u do the customize.

  • thanks Snow...very great work!

    I'm agree with bosssumon :

    a better graphic in edit profile

    and more clear code for all....

    then i hope elggteam take this work as default for elgg.

    thanks again!

  • About graphic edit profile.Er...I not going to do that as codes is more friendly than to GUI for my self }:P

    About the codes in Chinese.All the Chinese char is just for Chinese Lunar birthday output.

Snow.Hellsing

This cat has travelled far far away and dont know when will come back.I still remember my promises.Sorry,guys.

Stats

  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 10216
  • Recommendations: 0

Other Projects

View Snow.Hellsing's plugins