function get_parsed_template($templateId, $lang = null, $format = 'yaml')
 {
     $res = $this->get_template($templateId, $lang);
     if (!$res) {
         return false;
     }
     switch ($format) {
         case 'yaml':
             require_once 'lib/profilelib/profilelib.php';
             require_once 'lib/profilelib/installlib.php';
             $content = "{CODE(caption=>YAML)}objects:\n" . " -\n" . "  type: file_gallery\n" . "  data:\n" . "   " . implode("\n   ", explode("\n", $res['content'])) . "{CODE}";
             $profile = Tiki_Profile::fromString($content, $res['name']);
             $installer = new Tiki_Profile_Installer();
             $objects = $profile->getObjects();
             if (isset($objects[0])) {
                 $data = $installer->getInstallHandler($objects[0])->getData();
                 unset($data['galleryId'], $data['parentId'], $data['name'], $data['user']);
                 $res['content'] = $data;
             } else {
                 $res['content'] = array();
             }
             break;
     }
     return $res;
 }
Exemple #2
0
 function testGetObjects()
 {
     $builder = new Services_Workspace_ProfileBuilder();
     $builder->addObject('wiki_page', 'foo', array('name' => 'Foo', 'namespace' => $builder->user('namespace'), 'content' => 'Hello', 'categories' => $builder->user('category')));
     $builder->addObject('wiki_page', 'bar', array('name' => 'Bar', 'namespace' => $builder->user('namespace'), 'content' => 'World', 'categories' => $builder->user('category')));
     $profile = Tiki_Profile::fromString($builder->getContent());
     $analyser = new Services_Workspace_ProfileAnalyser($profile);
     $this->assertEquals(array(array('name' => 'Foo', 'namespace' => '{namespace}', 'content' => 'Hello'), array('name' => 'Bar', 'namespace' => '{namespace}', 'content' => 'World')), $analyser->getObjects('wiki_page'));
 }
Exemple #3
0
 /**
  * @param $filename
  * @return array|mixed
  */
 private function read_module_file($filename)
 {
     $cachelib = TikiLib::lib('cache');
     $expiry = filemtime($filename);
     if ($modules = $cachelib->getSerialized($filename, 'modules', $expiry)) {
         return $modules;
     }
     $content = file_get_contents($filename);
     if (!$content) {
         TikiLib::lib('errorreport')->report(tr('Module file "%0" not found.', $filename));
         return '';
     }
     $profile = Tiki_Profile::fromString("{CODE(caption=>YAML)}{$content}{CODE}");
     $out = array_fill_keys(array_values($this->module_zones), array());
     foreach ($profile->getObjects() as $object) {
         if ($object->getType() == 'module') {
             $handler = new Tiki_Profile_InstallHandler_Module($object, array());
             $data = $handler->getData();
             $object->replaceReferences($data);
             $data = $handler->formatData($data);
             $data['groups'] = unserialize($data['groups']);
             $position = $data['position'];
             $zone = $this->module_zones[$position];
             $out[$zone][] = $data;
         }
     }
     $cachelib->cacheItem($filename, serialize($out), 'modules');
     return $out;
 }
Exemple #4
0
 function action_edit_template($input)
 {
     if (!Perms::get()->admin) {
         throw new Services_Exception_Denied();
     }
     global $prefs;
     $template = $this->utilities->getTemplate($input->id->int());
     if ($template['is_advanced'] == 'y') {
         return array('FORWARD' => array('action' => 'advanced_edit', 'id' => $input->id->int()));
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $builder = new Services_Workspace_ProfileBuilder();
         if ($prefs['feature_areas'] == 'y' && $input->area->int()) {
             $builder->addObject('area_binding', 'binding', array('category' => $builder->user('category'), 'perspective' => $builder->user('perspective')));
         }
         foreach ($input->groups as $internal => $info) {
             $permissions = array_filter(preg_split('/\\W+/', $info->permissions->none()));
             $builder->addGroup($internal, $info->name->text(), $info->autojoin->int() > 0);
             $builder->setPermissions($internal, 'category', $builder->user('category'), $permissions);
         }
         $builder->setManagingGroup($input->managingGroup->word());
         foreach ($input->pages as $page) {
             $builder->addObject('wiki_page', uniqid(), array('name' => $page->name->pagename(), 'namespace' => $page->namespace->pagename(), 'content' => $page->content->wikicontent(), 'categories' => $builder->user('category')));
         }
         $this->utilities->replaceTemplate($input->id->int(), array('name' => $input->name->text(), 'definition' => $builder->getContent()));
     }
     $template = $this->utilities->getTemplate($input->id->int());
     $profile = Tiki_Profile::fromString($template['definition']);
     $analyser = new Services_Workspace_ProfileAnalyser($profile);
     $hasArea = $analyser->contains(array('type' => 'area_binding', 'ref' => 'binding', 'category' => $analyser->user('category'), 'perspective' => $analyser->user('perspective'))) ? 'y' : 'n';
     return array('title' => tr('Edit template %0', $template['name']), 'id' => $input->id->int(), 'name' => $template['name'], 'area' => $prefs['feature_areas'] == 'y' ? $hasArea : null, 'groups' => $analyser->getGroups('category', $analyser->user('category')), 'pages' => $analyser->getObjects('wiki_page', array('name' => '{namespace}', 'namespace' => null, 'content' => '')));
 }
Exemple #5
0
         }
         // need to reload sources as cache is cleared after install
         $sources = $list->getSources();
     }
 }
 if (isset($_POST['test'], $_POST['profile_tester'], $_POST['profile_tester_name'])) {
     $test_source = $_POST['profile_tester'];
     if (strpos($test_source, '{CODE}') === false) {
         // wrap in CODE tags if none there
         $test_source = "{CODE(caption=>YAML)}\n{$test_source}\n{CODE}";
     }
     // desanitize the input, prefs etc will filter as required in the profile installer
     $test_source = str_replace('<x>', '', $test_source);
     $smarty->assign('test_source', $test_source);
     $smarty->assign('profile_tester_name', $_POST['profile_tester_name']);
     $profile = Tiki_Profile::fromString($test_source, $_POST['profile_tester_name']);
     $profile->removeSymbols();
     $installer = new Tiki_Profile_Installer();
     $empty_cache = $_REQUEST['empty_cache'];
     $smarty->assign('empty_cache', $empty_cache);
     $installer->install($profile, $empty_cache);
     if ($target = $profile->getInstructionPage()) {
         $wikilib = TikiLib::lib('wiki');
         $target = $wikilib->sefurl($target);
         header('Location: ' . $target);
         exit;
     } else {
         $profilefeedback = $installer->getFeedback();
         if (count($profilefeedback) > 0) {
             $smarty->assign_by_ref('profilefeedback', $profilefeedback);
         }
Exemple #6
0
 public function action_import_profile($input)
 {
     $tikilib = TikiLib::lib('tiki');
     $perms = Perms::get();
     if (!$perms->admin) {
         throw new Services_Exception_Denied(tr('Reserved for administrators'));
     }
     unset($success);
     $confirm = $input->confirm->int();
     if ($confirm) {
         $transaction = $tikilib->begin();
         $installer = new Tiki_Profile_Installer();
         $yaml = $input->yaml->string();
         $name = "tracker_import:" . md5($yaml);
         $profile = Tiki_Profile::fromString('{CODE(caption="yaml")}' . "\n" . $yaml . "\n" . '{CODE}', $name);
         if ($installer->isInstallable($profile) == true) {
             if ($installer->isInstalled($profile) == true) {
                 $installer->forget($profile);
             }
             $installer->install($profile);
             $feedback = $installer->getFeedback();
             $transaction->commit();
             return $feedback;
             $success = 1;
         } else {
             return false;
         }
     }
     return array('title' => tr('Import Tracker From Profile/YAML'), 'modal' => $input->modal->int());
 }
/**
 * @param $installer
 */
function upgrade_99999999_image_plugins_kill_tiki($installer)
{
    global $tikilib, $prefs, $tikiroot, $user_overrider_prefs, $tiki_p_trust_input, $smarty, $access, $local_php;
    // globals are required here for tiki-setup_base.php
    require_once 'db/tiki-db.php';
    require_once 'lib/tikilib.php';
    $tikilib = new TikiLib();
    // ******************************** THUMB plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_thumb
  data:
   name: THUMB
   implementation: img
   description:
    name: Thumbnail
    documentation: PluginThumb
    description: Displays a thumbnail of an image that enlarges upon mouseover or links to a target
    prefs:
    params:
     file:
      required: false
      name: File ID
      description: File ID from the file gallery.
      filter: digits
     id:
      required: false
      name: Image ID
      description: Image ID from the image gallery.
      filter: digits
     image:
      required: false
      name: Image URL
      description: URL to the image.
      filter: url
     max:
      required: false
      name: Maximum Size
      description: Maximum width or height for the image.
      filter: int
     float:
      required: false
      name: Alignment
      description: Set alignment as left, right or none.
      filter: alpha
      options:
       none:
        text: None
       left:
        text: Left
       right:
        text: Right
     url:
      required: false
      name: Link Target
      description: Link target of the image.
      filter: url
   body:
    default: ''
   params:
    fileId:
     pattern: %file%
     params:
      file:
       token: file
    id:
     pattern: %id%
     params:
      id:
       token: id
    src:
     pattern: %image%
     params:
      image:
       token: image
    max:
     pattern: %max%
     params:
      max:
       token: max
    imalign:
     pattern: %float%
     params:
      float:
       token: float
    link:
     pattern: %url%
     params:
      url:
       token: url
    thumb: mouseover
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'THUMB');
    $profile->removeSymbols();
    $profile_installer->install($profile);
    // ********************************  IMAGE plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_image
  data:
   name: IMAGE
   implementation: img
   description:
    name: Image
    documentation: PluginImage
    description: Display images (transitional alias, use IMG plugin instead)
    params:
     fileId:
      required: false
      name: File ID
      description: Numeric ID of an image in a File Gallery (or comma-separated list). "fileId", "id" or "src" required.
     id:
      required: false
      name: Image ID
      description: Numeric ID of an image in an Image Gallery (or comma-separated list). "fileId", "id" or "src" required.
     src:
      required: false
      name: Image source
      description: Full URL to the image to display. "fileId", "id" or "src" required.
      filter: url
     scalesize:
      required: false
      name: Maximum size
      description: Maximum width or height for the image in pixels.
     height:
      required: false
      name: Image height
      description: Height in pixels.
      filter: int
     width:
      required: false
      name: Image width
      description: Width in pixels.
      filter: int
     link:
      required: false
      name: Link
      description: For making the image a hyperlink. Enter a url to the page the image should link to.
      filter: url
     rel:
      required: false
      name: Link relation
      description: Link relation attribute to add to the link.
     title:
      required: false
      name: Link title
      description: Link title that appears upon mouseover.
     alt:
      required: false
      name: Alternate text
      description: Alternate text that displays image doesn't load.
     align:
      required: false
      name: Align image block
      description: Enter right, left or center to align the box containing the image.
      options:
       left:
        text: Left
       right:
        text: Right
       center:
        text: Center
     block:
      required: false
      name: Wrapping control
      description: Whether to block items from wrapping next to image from the top or bottom. (top,bottom,both,none)
      options:
       '':
        text: None
       top:
        text: Top
       bottom:
        text: Bottom
       both:
        text: Both
     desc:
      required: false
      name: Description
      description: Image caption
     usemap:
      required: false
      name: Image map
      description: Name of the image map to use.
     class:
      required: false
      name: CSS class
      description: CSS class to apply to the image.
     style:
      required: false
      name: CSS syle
      description: CSS styling to apply.
     border:
      required: false
      name: Border options
      description: Border configuration for image block.
     descoptions:
      required: false
      name: Caption style
      description: Styling of image description. Use CSS syntax to override default setting.
     default:
      required: false
      name: Default configuration
      description: Default configuration definitions (usually set by admin).
     mandatory:
      required: false
      name: Mandatory configuration
      description: Mandatory configuration definitions (usually set by admin).
   body:
    default: ''
   params:
    fileId:
     pattern: %fileId%
     params:
      fileId:
       token: fileId
    id:
     pattern: %id%
     params:
      id:
       token: id
    src:
     pattern: %src%
     params:
      src:
       token: src
    max:
     pattern: %scalesize%
     params:
      scalesize:
       token: scalesize
       default: 200
    height:
     pattern: %height%
     params:
      height:
       token: height
    width:
     pattern: %width%
     params:
      width:
       token: width
    link:
     pattern: %link%
     params:
      link:
       token: link
    rel:
     pattern: %rel%
     params:
      rel:
       token: rel
    title:
     pattern: %title%
     params:
      title:
       token: title
    alt:
     pattern: %alt%
     params:
      alt:
       token: alt
    align:
     pattern: %align%
     params:
      align:
       token: align
    block:
     pattern: %block%
     params:
      block:
       token: block
    desc:
     pattern: %desc%
     params:
      desc:
       token: desc
    usemap:
     pattern: %usemap%
     params:
      usemap:
       token: usemap
    class:
     pattern: %class%
     params:
      class:
       token: class
    stylebox:
     pattern: %style%
     params:
      style:
       token: style
       default: border:3px double;padding:.1cm; font-size:12px; line-height:1.5em; margin-left:4px; width:200px;
    styledesc:
     pattern: %descoptions%
     params:
      descoptions:
       token: descoptions
    default:
     pattern: %default%
     params:
      default:
       token: default
    mandatory:
     pattern: %mandatory%
     params:
      mandatory:
       token: mandatory
    button: y 
    imalign: center  
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'IMAGE');
    $profile->removeSymbols();
    $profile_installer->install($profile);
    // ********************************  PICTURE plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_picture
  data:
   name: PICTURE
   implementation: img
   description:
    name: Picture
    description: Display uploaded pictures
    params:
     file:
      required: true
      name: File path
      description: File name or path of the image.
   body:
    default: ''
   params:
    src:
     pattern: %file%
     params:
      file:
       token: file
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'PICTURE');
    $profile->removeSymbols();
    $profile_installer->install($profile);
}
Exemple #8
0
 function applyTemplate(array $template, array $data)
 {
     $profile = Tiki_Profile::fromString($template['definition'], uniqid());
     $installer = new Tiki_Profile_Installer();
     $installer->setUserData($data);
     $value = $installer->install($profile);
     if (!$value) {
         throw new Services_Exception('Profile could not be installed.');
     }
 }
Exemple #9
0
 public function action_import_profile($input)
 {
     global $tikilib, $access;
     $access->check_permission('tiki_p_admin');
     $transaction = $tikilib->begin();
     $installer = new Tiki_Profile_Installer();
     $yaml = $input->yaml->string();
     $name = "tracker_import:" . md5($yaml);
     $profile = Tiki_Profile::fromString('{CODE(caption="yaml")}' . "\n" . $yaml . "\n" . '{CODE}', $name);
     if ($installer->isInstallable($profile) == true) {
         if ($installer->isInstalled($profile) == true) {
             $installer->forget($profile);
         }
         $installer->install($profile);
         $feedback = $installer->getFeedback();
         $transaction->commit();
         return $feedback;
     } else {
         return false;
     }
 }
 function action_export_profile($input)
 {
     if (!Perms::get()->admin_trackers) {
         throw new Services_Exception(tr('Reserved to tracker administrators'), 403);
     }
     $trackerId = $input->trackerId->int();
     include_once 'lib/profilelib/installlib.php';
     include_once 'lib/profilelib/profilelib.php';
     $profile = Tiki_Profile::fromString('dummy', '');
     $data = array();
     $profileObject = new Tiki_Profile_Object($data, $profile);
     $profileTrackerInstallHandler = new Tiki_Profile_InstallHandler_Tracker($profileObject, array());
     $export_yaml = $profileTrackerInstallHandler->_export($trackerId, $profileObject);
     include_once 'lib/wiki-plugins/wikiplugin_code.php';
     $export_yaml = wikiplugin_code($export_yaml, array('caption' => 'YAML', 'colors' => 'yaml'));
     $export_yaml = preg_replace('/~[\\/]?np~/', '', $export_yaml);
     return array('trackerId' => $trackerId, 'yaml' => $export_yaml);
 }