<?xml version="1.0" encoding="utf-8"?>
<dictionary>
<item key="data"><![CDATA[<dtml-comment>
##########################################################################################
# Author:   Dirk Nordmann <dn@hoffmannliebenberg.de>
# Company:  HOFFMANN+LIEBENBERG GmbH
# WWW:      http://www.hoffmannliebenberg.de
# Date:     2006-12-08
# Version:  0.4
# Comments: Action for checking links; 'richtext' added
##########################################################################################
</dtml-comment>

<dtml-comment>
------------------------------------------------------------------------------------------
-
- Check link
-
------------------------------------------------------------------------------------------
</dtml-comment>
<dtml-if "REQUEST.get('checkLink',0)==1">
 <dtml-call "REQUEST.set('append',0)">
 <dtml-unless "surl.find('<dtml-var')>=0">
 <dtml-call "REQUEST.set('href',surl)">
 <dtml-call "REQUEST.set('status','Unknown')">
 <dtml-if "surl.find('{$')==0 and surl.rfind('}')==_.len(surl)-1">
  <dtml-if ck_int>
   <dtml-let ob="getLinkObj(surl,REQUEST)">
    <dtml-if ob>
     <dtml-call "REQUEST.set('href',ob.absolute_url())">
     <dtml-call "REQUEST.set('status','<font color=green>OK</font>')">
    <dtml-else>
     <dtml-call "REQUEST.set('status','<font color=red>Broken</font>')">
    </dtml-if>
   </dtml-let>
   <dtml-call "REQUEST.set('append',1)">
  </dtml-if>
 <dtml-else>
  <dtml-if ck_ext>
   <dtml-try>
    <dtml-unless "surl.find('mailto:')==0">
     <dtml-if "surl.find('./')==0">
      <dtml-call "REQUEST.set('href',getSelf(PAGES).absolute_url()+'/'+surl)">
      <dtml-call "http_import(href)">
     <dtml-else>
      <dtml-call "http_import(surl)">
     </dtml-if>
     <dtml-call "REQUEST.set('status','<font color=green>OK</font>')">
    </dtml-unless>
   <dtml-except>
    <dtml-call "REQUEST.set('status','<font color=red>Broken</font>')">
   </dtml-try>
   <dtml-call "REQUEST.set('append',1)">
  </dtml-if>
 </dtml-if>
 <dtml-if append>
  <tr
   <dtml-if "count%2==0">
    class="zmiNeutralColorMedium0"
   <dtml-else>
    class="zmiNeutralColorWhite"
   </dtml-if>>
   <td class="form-small"><a href="<dtml-var absolute_url>/manage_main?lang=<dtml-var lang>&manage_lang=<dtml-var manage_lang>" target="_blank" class="zmi"><dtml-var "string_maxlen(getTitlealt(REQUEST),40)"></a></td>
   <td class="form-small"><i>(<dtml-var key>)</i></td>
   <td class="form-small"><a href="<dtml-var href>" target="_blank" class="zmi"><dtml-var "string_maxlen(surl,40)"></a></td>
   <td class="form-small"><dtml-var status></td>
  </tr>
  <dtml-call "REQUEST.set('count',count+1)">
 </dtml-if>
 </dtml-unless>
 <dtml-call "REQUEST.set('checkLink',0)">


<dtml-comment>
------------------------------------------------------------------------------------------
-
- Form
-
------------------------------------------------------------------------------------------
</dtml-comment>
<dtml-elif "REQUEST.get('process',0)==0">
<dtml-var manage_page_header>
<head>
 <title>Check links...</title>
</head>
<dtml-var "manage_tabs(_,_,my_manage_options=[{'label':'Check links...','action':''}])">
<dtml-var f_bo_area>
 <!--// ########## Form ########## //-->
 <p class="form-text">
  This action validates internal and external links.
  Validating external links may take several minutes as every url has to be retrieved.
  Links in url- and text-Attributes are handled by this action.
 </p>
 <form method="post">
  <input type="hidden" name="lang" value="<dtml-var lang>">
  <input type="hidden" name="manage_lang" value="<dtml-var manage_lang>">
  <table>
  <tr>
   <td class="form-label">Internal Links</td>
   <td class="form-checkbox"><input class="form-checkbox" type="checkbox" name="ck_int:int" value="1" <dtml-if "REQUEST.get('ck_int',1)==1">checked="checked"</dtml-if>></td>
  </tr>
  <tr>
   <td class="form-label">External Links</td>
   <td class="form-checkbox"><input class="form-checkbox" type="checkbox" name="ck_ext:int" value="1" <dtml-if "REQUEST.get('ck_ext',0)==1">checked="checked"</dtml-if>></td>
  </tr>
  <tr>
   <td class="form-label">Inline Links</td>
   <td class="form-checkbox"><input class="form-checkbox" type="checkbox" name="ck_inl:int" value="1" <dtml-if "REQUEST.get('ck_inl',0)==1">checked="checked"</dtml-if>></td>
  </tr>
  <tr>
   <td class="form-label"></td>
   <td class="form-element"><input class="form-element" type="submit" name="btn" value="Start!"></td>
  </tr>
  </table>
 </form>
 <!--// ########## Start! ########## //-->
 <dtml-if "REQUEST.get('btn','')=='Start!'">
  <dtml-call "REQUEST.set('process',1)">
  <dtml-call "REQUEST.set('count',0)">
  <hr size="1">
  <table cellspacing="1" cellpadding="1" border="0" class="zmiNeutralColorStrong0">
  <tr class="zmiNeutralColorStrong0">
   <th class="form-small">Object</th>
   <th class="form-small">Attribute</th>
   <th class="form-small">Link</th>
   <th class="form-small">Status</th>
  </tr>
  <dtml-var manage_checkLinks>
  </table>
 </dtml-if>
<dtml-var f_eo_area>
<dtml-var manage_page_footer>

<dtml-comment>
------------------------------------------------------------------------------------------
-
- Process tree
-
------------------------------------------------------------------------------------------
</dtml-comment>
<dtml-elif "REQUEST.get('process',0)==1">
 <dtml-in "getObjAttrs().keys()">
  <dtml-let key=sequence-item objAttr="getObjAttr(key)">
   <!--// ########## Text (Inline) ########## //-->
   <dtml-if "objAttr['datatype'] in ['string','text','richtext']">
    <dtml-if ck_inl>
    <dtml-call "REQUEST.set('v',getObjAttrValue(getObjAttr(key),REQUEST))">
    <dtml-if v>
     <dtml-let l="v.split('href=')">
      <dtml-if "_.len(l)>1">
       <dtml-in l>
        <dtml-unless sequence-start>
         <dtml-call "REQUEST.set('surl',_['sequence-item'])">
         <dtml-call "REQUEST.set('i',surl.find(_.chr(34)))">
         <dtml-if "i==0 and surl.find(_.chr(34),i+1)>0">
          <dtml-call "REQUEST.set('surl',surl[1:surl.find(_.chr(34),i+1)])">
         </dtml-if>
         <dtml-call "REQUEST.set('checkLink',1)">
         <dtml-var manage_checkLinks>
        </dtml-unless>
       </dtml-in>
      </dtml-if>
     </dtml-let>
     <dtml-let l="v.split('{$')">
      <dtml-if "_.len(l)>1">
       <dtml-in l>
        <dtml-unless sequence-start>
         <dtml-call "REQUEST.set('surl','{$'+_['sequence-item'])">
         <dtml-call "REQUEST.set('surl',surl[:surl.find('}')+1])">
         <dtml-call "REQUEST.set('checkLink',1)">
         <dtml-var manage_checkLinks>
        </dtml-unless>
       </dtml-in>
      </dtml-if>
     </dtml-let>
    </dtml-if>
    </dtml-if>
   <!--// ########## Url ########## //-->
   <dtml-elif "objAttr['datatype'] in ['url']">
    <dtml-call "REQUEST.set('v',getObjProperty(key,REQUEST))">
    <dtml-if v>
     <dtml-call "REQUEST.set('surl',getObjProperty(key,REQUEST))">
     <dtml-call "REQUEST.set('checkLink',1)">
     <dtml-var manage_checkLinks>
    </dtml-if>
   </dtml-if>
  </dtml-let>
 </dtml-in>
 <dtml-in "getObjChildren('',REQUEST)">
  <dtml-var manage_checkLinks>
 </dtml-in>

<dtml-comment>
------------------------------------------------------------------------------------------
</dtml-comment>
</dtml-if>]]></item>
<item key="description"></item>
<item key="exec" type="int">0</item>
<item key="id"><![CDATA[manage_checkLinks]]></item>
<item key="meta_type"><![CDATA[DTML Method]]></item>
<item key="meta_types" type="list"><list>
<item><![CDATA[ZMSDocument]]></item>
<item><![CDATA[ZMSFolder]]></item>
<item><![CDATA[ZMSRubrik]]></item>
<item><![CDATA[ZMS]]></item>
</list>
</item>
<item key="name"><![CDATA[Check links...]]></item>
<item key="roles" type="list"><list>
<item><![CDATA[ZMSAdministrator]]></item>
</list>
</item>
</dictionary>
