Пример #1
0
 /**
  * Adds a template to be exported
  *
  * @param id
  *		template ID
  * @result false when no such ID exists
  */
 function addTemplate($id)
 {
     if (!TEMPLATE::existsID($id)) {
         return 0;
     }
     $this->templates[$id] = TEMPLATE::getNameFromId($id);
     return 1;
 }
Пример #2
0
 /**
  * @todo document this
  */
 function action_templateclone()
 {
     global $member;
     $templateid = intRequestVar('templateid');
     $member->isAdmin() or $this->disallow();
     // 1. read old template
     $name = TEMPLATE::getNameFromId($templateid);
     $desc = TEMPLATE::getDesc($templateid);
     // 2. create desc thing
     $name = "cloned" . $name;
     // if a template with that name already exists:
     if (TEMPLATE::exists($name)) {
         $i = 1;
         while (TEMPLATE::exists($name . $i)) {
             $i++;
         }
         $name .= $i;
     }
     $newid = TEMPLATE::createNew($name, $desc);
     // 3. create clone
     // go through parts of old template and add them to the new one
     $res = sql_query('SELECT tpartname, tcontent FROM ' . sql_table('template') . ' WHERE tdesc=' . $templateid);
     while ($o = sql_fetch_object($res)) {
         $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
     }
     $this->action_templateoverview();
 }