تضامنًا مع حق الشعب الفلسطيني |
وحدة:ملعب/Mr. Ibrahem/find2
< وحدة:ملعب | Mr. Ibrahem
توثيق الوحدة [أنشئ] [محو الاختزان][استخدامات] [قوالب]
local str = {}
function str.find33( frame )
--frame = frame:getParent()
local new_args = frame.args or frame:getParent().args
local source = new_args['source'] or new_args['source1'] or ""
local no = new_args['no'] or new_args.no or ""
local plain = true
if source == '' then return "" end
function findd(number)
local target = new_args["target" .. number] or ""
local target2 = new_args["target" .. number .. "a"] or ""
local yes = new_args["yes" .. number] or ""
if target == '' or yes == "" then return false end
local start = mw.ustring.find( source, target, 1, plain )
if start == 0 or start == nil then
local start2 = mw.ustring.find( source, target2, 1, plain )
if target2 == '' or start2 == 0 or start2 == nil
then
return false
else
return yes
end
else return yes
end
end
y1 = findd ( 1 )
y2 = findd ( 2 )
if findd ( 1 ) then
return findd ( 1 )
elseif findd ( 2 ) then return findd ( 2 )
elseif findd ( 3 ) then return findd ( 3 )
elseif findd ( 4 ) then return findd ( 4 )
elseif findd ( 5 ) then return findd ( 5 )
elseif findd ( 6 ) then return findd ( 6 )
elseif findd ( 7 ) then return findd ( 7 )
elseif findd ( 8 ) then return findd ( 8 )
elseif findd ( 9 ) then return findd ( 9 )
elseif findd ( 10 ) then return findd ( 10 )
elseif findd ( 11 ) then return findd ( 11 )
elseif findd ( 12 ) then return findd ( 12 )
elseif findd ( 13 ) then return findd ( 13 )
elseif findd ( 14 ) then return findd ( 14)
elseif findd ( 15 ) then return findd ( 15 )
elseif findd ( 16) then return findd ( 16 )
elseif findd ( 17 ) then return findd ( 17 )
elseif findd ( 18 ) then return findd ( 18 )
elseif findd ( 19 ) then return findd ( 19 )
elseif findd ( 20 ) then return findd ( 20 )
elseif findd ( 21 ) then return findd ( 21 )
elseif findd ( 22 ) then return findd ( 22 )
elseif findd ( 23 ) then return findd ( 23 )
elseif findd ( 24 ) then return findd ( 24 )
elseif findd ( 25 ) then return findd ( 25 )
else
return new_args["no"] or new_args.no ""
end
end
function str.find( frame )
local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } );
local source_str = new_args['source'] or '';
local pattern = new_args['target'] or '';
local start_pos = tonumber(new_args['start']) or 1;
local plain = true;
if source_str == '' or pattern == '' then
return 0;
end
local start = mw.ustring.find( source_str, pattern, start_pos, plain )
if start == nil then
start = 0
end
if start == 0 then
return frame.args["no"] or ""
else
return frame.args["yes"] or ""
end
--return start
end
function str._getParameters( frame_args, arg_list )
local new_args = {};
local index = 1;
local value;
for i,arg in ipairs( arg_list ) do
value = frame_args[arg]
if value == nil then
value = frame_args[index];
index = index + 1;
end
new_args[arg] = value;
end
return new_args;
end
function str.check( frame )
--frame = frame:getParent()
local new_args = frame.args or frame:getParent().args
local pagetext = new_args['pagetext'] or ""
--mw.log("pagetext" .. pagetext)
local talktext = new_args['talktext'] or ""
local plain = false
if pagetext == '' then return "" end
function findd(number)
local search_talk = new_args["search_talk" .. number] or ""
local search_page = new_args["search_page" .. number] or ""
local cat = new_args["cat" .. number] or ""
if search_talk == '' or search_page == "" then return "" end
local findportal = mw.ustring.find( pagetext , search_page , 1, plain )
mw.log(search_page)
mw.log(findportal)
if findportal ~= 0 and findportal ~= nil then
local findtalk = mw.ustring.find( talktext , search_talk , 1, plain )
if findtalk == 0 or findtalk == nil then
return '[[تصنيف:' .. cat .. ']]'
end
end
return ''
end
local Table = {}
table.insert(Table , findd ( 1 ) )
table.insert(Table , findd ( 2 ) )
table.insert(Table , findd ( 3 ) )
table.insert(Table , findd ( 4 ) )
table.insert(Table , findd ( 5 ) )
table.insert(Table , findd ( 6 ) )
table.insert(Table , findd ( 7 ) )
table.insert(Table , findd ( 8 ) )
table.insert(Table , findd ( 9 ) )
table.insert(Table , findd ( 10 ) )
table.insert(Table , findd ( 11 ) )
table.insert(Table , findd ( 12 ) )
table.insert(Table , findd ( 13 ) )
table.insert(Table , findd ( 14 ) )
table.insert(Table , findd ( 15 ) )
table.insert(Table , findd ( 16 ) )
table.insert(Table , findd ( 17 ) )
table.insert(Table , findd ( 18 ) )
table.insert(Table , findd ( 19 ) )
table.insert(Table , findd ( 20 ) )
return mw.text.listToText( Table , "", "" )
end
return str