وحدة:نمط

من أرابيكا، الموسوعة الحرة
اذهب إلى التنقل اذهب إلى البحث
_p ={}
 
local datefunctions = require "Module:DateFunctions"
local monthdays = 0
local firstday = 0
--إنشاء إطار مستقل frame (expensive?)
--القدرة على تشغيل وحدة اختبار 
local framehere = mw.getCurrentFrame()

--تظهر الان المخرجات مثل كلمة اليوم أو حدث في مثل هذا اليوم
function leksi (hmera)
    if hmera<1 or hmera>31 then return '' end
    local leksinum = 'يوم' .. d
    local leksi = framehere:expandTemplate{ title = leksinum, args = { } }
    return leski
end 

function forweek1(keli)    
    if keli < firstday then
        return ''
    else
        local d = keli - firstday + 1 
        return "'''" .. d .. "''' <br> '''[[" ..  leksi(d) .. "]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=قالب:يوم" .. d .. "&action=edit تعديل] - [http://el.wiktionary.org/w/index.php?title=Πρقالب:يوم".. d .. "&action=history السجل ]</small>"
    end
end

function forweek2to4(keli)    
    local d = keli - firstday + 1 
    return "'''" .. d .. "''' <br> '''[[" ..  leksi(d) .. "]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit تعديل] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history السجل ]</small>"
end 

function forweek1(keli)    
    if keli < firstday then
        return ''
    else
        local d = keli - firstday + 1 
        return "'''" .. d .. "''' <br> '''[[{{كلمة اليوم" ..  d .. "}}]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit تعديل] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history السجل ]</small>"
    end
end
 
function forweek2to4(keli)    
    local d = keli - firstday + 1 
    return "'''" .. d .. "''' <br> '''[[{{ΛτΗ" ..  d .. "}}]]''' <br> <small>[http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=edit تعديل] - [http://el.wiktionary.org/w/index.php?title=Πρότυπο:ΛτΗ" .. d .. "&action=history السجل ]</small>"
end
 
function _p.daystable(frame)
-- χρησιμοποίησε το δημιουργημένο εδώ frame και όχι αυτό που πήραμε
    monthdays = datefunctions.getMonthDays(frame)
    firstday = datefunctions.getfirstDayNum(frame)
--    monthdays = 28
--    firstday = 1
    local dayssum = monthdays + firstday -1
    local rowstart = '|style=\'width:100px\' align=\'center\' | '
    t = [=[<center>
{|style="float:center; border:1px solid #cedff2; background:#f5faff;" rules="all" class=plainlinks
|- 
! bgcolor="#008B8B" colspan="1" | السبت
! bgcolor="#008B8B" colspan="1" | الجمعة
! bgcolor="#008B8B" colspan="1" | الخميس
! bgcolor="#008B8B" colspan="1" | الأربعاء
! bgcolor="#008B8B" colspan="1" | الثلاثاء
! bgcolor="#008B8B" colspan="1" | الإثنين
! bgcolor="#008B8B" colspan="1" | الأحد
|- 
]=] 
    for xcounter = 1,7 do
        t = t .. rowstart .. forweek1(xcounter) .. '\n'
    end
    --إضافة صف جديد
    t = t .. '\n|-\n'
    for ycounter = 1, 3 do
        for xcounter = ((7*ycounter)+1),((7*ycounter)+7) do
            t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
        end
        --إضافة سطر جديد في نهاية كل صف
        t = t .. '\n|-\n'
    end
 
    if dayssum > 28 then		
		for xcounter = 29,35 do
            if dayssum >= xcounter then
                t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
            else
                t = t .. '| &nbsp;' .. '\n'
            end
        end
    end
    --حل مؤقت
    if dayssum > 35 then
        t = t .. '\n' .. '|-' .. '\n'
        for xcounter = 36,42 do
            if dayssum >= xcounter then
                t = t .. rowstart .. forweek2to4(xcounter) .. '\n'
            else
                t = t .. '| &nbsp;' .. '\n'
            end
        end    
        --إضافة صف جديد
        t = t .. '\n|-\n'
    end
 	--إلغاء سطر
 	t = mw.ustring.sub(t, 1, -2)
 	--نهاية الجدول وتوسيطه
    t = t .. '\n|}</center>'
    return frame:preprocess(t)  
--    return t
end
 
return _p