本文整理汇总了PHP中Tiki_Profile::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Tiki_Profile::fromString方法的具体用法?PHP Tiki_Profile::fromString怎么用?PHP Tiki_Profile::fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tiki_Profile
的用法示例。
在下文中一共展示了Tiki_Profile::fromString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_parsed_template
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;
}
示例2: testGetObjects
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'));
}
示例3: read_module_file
/**
* @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;
}
示例4: action_edit_template
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' => '')));
}
示例5: str_replace
}
// 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);
}
示例6: action_import_profile
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());
}
示例7: upgrade_99999999_image_plugins_kill_tiki
//.........这里部分代码省略.........
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
示例8: applyTemplate
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.');
}
}
示例9: action_import_profile
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;
}
}
示例10: action_export_profile
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);
}