本文整理汇总了PHP中ParserFactory类的典型用法代码示例。如果您正苦于以下问题:PHP ParserFactory类的具体用法?PHP ParserFactory怎么用?PHP ParserFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($preview = false)
{
$packageName = !empty($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
$subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null;
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName, $subpanelName);
/* BEGIN - SECURITY GROUPS */
$groupLayout = "";
if (!empty($_REQUEST['grpLayout'])) {
$groupLayout = $_REQUEST['grpLayout'];
}
global $groupName;
$groupName = "Default";
if (!isset($groupLayout) || empty($groupLayout)) {
$groupLayout = "";
} else {
//Get group name for display
require_once 'modules/SecurityGroups/SecurityGroup.php';
$groupFocus = new SecurityGroup();
$groupFocus->retrieve($groupLayout);
$groupName = $groupFocus->name;
}
/* END - SECURITY GROUPS */
$smarty = $this->constructSmarty($parser);
//SECURITY GROUPS
$smarty->assign('grpLayout', $groupLayout);
if ($preview) {
echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl");
} else {
$ajax = $this->constructAjax();
$ajax->addSection('center', $this->translatedViewType, $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl"));
echo $ajax->getJavascript();
}
}
示例2: Update
/**
* 删除缓存,从新生成所有文章
* 只有在登录后才有效,但是当前尚未实现登录
*
* @return $this
* @throws Exception
*/
public function Update()
{
global $postHelper;
// 删除所有缓存的文章
$files = glob(CACHE_DIR . '/*.post');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
$postHelper->Clear();
// 生成所有文章
$list = $this->getPostFileList();
foreach ($list as $file) {
if (mb_check_encoding($file, 'gbk')) {
echo "add post ", mb_convert_encoding($file, 'utf-8', 'gbk'), " <br>\n";
}
$post = ParserFactory::TryParseFile($file);
if ($post) {
$postHelper->addPost($post);
} else {
throw new Exception("Parse file '{$file}' to post filed.");
}
}
return $this;
}
示例3: display
function display()
{
$this->parser = ParserFactory::getParser(MB_PORTAL . strtolower($this->editLayout), $this->editModule, null, null, MB_PORTAL);
$smarty = new Sugar_Smarty();
//Add in the module we are viewing to our current mod strings
global $mod_strings, $current_language;
$editModStrings = return_module_language($current_language, $this->editModule);
$mod_strings = sugarArrayMerge($editModStrings, $mod_strings);
$smarty->assign('mod', $mod_strings);
$smarty->assign('MOD', $mod_strings);
// assign buttons
$images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone');
foreach ($images as $image => $file) {
$smarty->assign($image, SugarThemeRegistry::current()->getImage($file, '', null, null, '.gif', $file));
}
$smarty->assign('icon_delete', SugarThemeRegistry::current()->getImage('icon_Delete', '', 48, 48, '.gif', $mod_strings['LBL_MB_DELETE']));
$buttons = array();
$buttons[] = array('id' => 'saveBtn', 'image' => SugarThemeRegistry::current()->getImage($images['icon_save'], '', null, null, '.gif', $mod_strings['LBL_BTN_SAVE']), 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(Studio2.checkCalcFields(\"{$_REQUEST['view']}\", \"ERROR_CALCULATED_PORTAL_FIELDS\"))Studio2.handleSave();'");
$buttons[] = array('id' => 'publishBtn', 'image' => SugarThemeRegistry::current()->getImage($images['icon_publish'], '', null, null, '.gif', $mod_strings['LBL_BTN_PUBLISH']), 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVEPUBLISH'], 'actionScript' => "onclick='if(Studio2.checkCalcFields(\"{$_REQUEST['view']}\", \"ERROR_CALCULATED_PORTAL_FIELDS\"))Studio2.handlePublish();'");
$html = "";
foreach ($buttons as $button) {
if ($button['id'] == "spacer") {
$html .= "<td style='width:{$button['width']}'> </td>";
} else {
$html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' " . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' " . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}' ></td>";
}
}
$smarty->assign('buttons', $html);
// assign fields and layout
$smarty->assign('available_fields', $this->parser->getAvailableFields());
$smarty->assign('field_defs', $this->parser->getFieldDefs());
$smarty->assign('layout', $this->parser->getLayout());
$smarty->assign('view_module', $this->editModule);
$smarty->assign('calc_field_list', json_encode($this->parser->getCalculatedFields()));
$smarty->assign('view', $this->editLayout);
$smarty->assign('maxColumns', $this->parser->getMaxColumns());
$smarty->assign('fieldwidth', '150px');
$smarty->assign('translate', true);
$smarty->assign('fromPortal', true);
// flag for form submittal - when the layout is submitted the actions are the same for layouts and portal layouts, but the parsers must be different...
if (!empty($this->parser->usingWorkingFile)) {
$smarty->assign('layouttitle', $GLOBALS['mod_strings']['LBL_LAYOUT_PREVIEW']);
} else {
$smarty->assign('layouttitle', $GLOBALS['mod_strings']['LBL_CURRENT_LAYOUT']);
}
$ajax = new AjaxCompose();
$ajax->addCrumb(translate('LBL_SUGARPORTAL', 'ModuleBuilder'), 'ModuleBuilder.main("sugarportal")');
$ajax->addCrumb(translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&portal=1&layout=1")');
$ajax->addCrumb(ucwords(translate('LBL_MODULE_NAME', $this->editModule)), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&portal=1&view_module=' . $this->editModule . '")');
$ajax->addCrumb(ucwords($this->editLayout), '');
// set up language files
$smarty->assign('language', $this->parser->getLanguage());
// for sugar_translate in the smarty template
//navjeet- assistant logic has changed
//include('modules/ModuleBuilder/language/en_us.lang.php');
//$smarty->assign('assistantBody', $mod_strings['assistantHelp']['module']['editView'] );
$ajax->addSection('center', $GLOBALS['mod_strings']['LBL_EDIT_LAYOUT'], $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl'));
echo $ajax->getJavascript();
}
示例4: setUp
public function setUp()
{
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
$GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$this->_parser = ParserFactory::getParser('EditView', 'Accounts');
}
示例5: ListAvailableParsers
public function ListAvailableParsers()
{
$logger = \Swiftriver\Core\Setup::GetLogger();
$logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method invoked]", \PEAR_LOG_DEBUG);
$logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [START: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG);
$parsers = ParserFactory::ReturnAllAvailablePushParsers();
$logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [END: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG);
$logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method finished]", \PEAR_LOG_DEBUG);
return $parsers;
}
示例6: removeAllCreatedFields
public static function removeAllCreatedFields()
{
foreach (self::$_fieldsAdded as $module_name => $views) {
foreach ($views as $view => $fields) {
$parser = ParserFactory::getParser($view, $module_name);
foreach ($fields as $field_name) {
$parser->removeField($field_name);
}
$parser->handleSave(false);
unset($parser);
}
}
}
示例7: FetchContentFromChannel
/**
* This method will take the information prvided in the
* instance of a Swiftriver\Core\ObjectModel\Channel object
* and will make a call to the channel to fetch and content
* that can be fetched and then parse the content into an array
* of Swiftriver\Core\ObjectModel\Content items
*
* @param Swiftriver\Core\ObjectModel\Channel $channel
* @return Swiftriver\Core\ObjectModel\Content[] $contentItems
*/
public function FetchContentFromChannel($channel)
{
//get the type of the channel
$channelType = $channel->GetType();
//Get a Parser from the ParserFactory based on the channel type
$factory = ParserFactory::GetParser($channelType);
//Extract the parameters from the channel object
$parameters = $channel->GetParameters();
//Get and parse all avaliable content items from the parser
$contentItems = $factory->GetAndParse($parameters);
//Return the content items
return $contentItems;
}
示例8: display
function display($preview = false)
{
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->editPackage);
$smarty = $this->constructSmarty($parser);
if ($preview) {
echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl");
} else {
$ajax = $this->constructAjax();
$ajax->addSection('center', translate('LBL_DASHLET'), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl"));
echo $ajax->getJavascript();
}
}
示例9: display
function display()
{
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$parser = ParserFactory::getParser(MB_PORTALLISTVIEW, $this->editModule, null, null, MB_PORTAL);
$smarty = $this->constructSmarty($parser);
$smarty->assign('fromPortal', true);
// flag for form submittal - when the layout is submitted the actions are the same for layouts and portal layouts, but the parsers must be different...
//Override the list view buttons to remove references to the history feature as the portal editors do not support it.
$buttons = array(array('id' => 'savebtn', 'name' => 'savebtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");" . "if (countListFields()==0) ModuleBuilder.layoutValidation.popup() ; else ModuleBuilder.handleSave(\"edittabs\" )'"));
$smarty->assign('buttons', $this->_buildImageButtons($buttons));
$ajax = $this->constructAjax();
$ajax->addSection('center', translate('LBL_EDIT_LAYOUT', 'ModuleBuilder'), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl"));
echo $ajax->getJavascript();
}
示例10: display
function display($preview = false)
{
$packageName = !empty($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
$subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null;
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName, $subpanelName);
$smarty = $this->constructSmarty($parser);
if ($preview) {
echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl");
} else {
$ajax = $this->constructAjax();
$ajax->addSection('center', $this->translatedViewType, $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl"));
echo $ajax->getJavascript();
}
}
示例11: display
function display()
{
$this->layout = strtolower($_REQUEST['view']);
$subpanelName = null;
if (strtolower($this->layout) == 'listview' && !empty($_REQUEST['subpanel'])) {
$subpanelName = $_REQUEST['subpanel'];
}
$packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null;
$this->module = $_REQUEST['view_module'];
$this->parser = ParserFactory::getParser($this->layout, $this->module, $packageName, $subpanelName);
$this->history = $this->parser->getHistory();
$action = !empty($_REQUEST['histAction']) ? $_REQUEST['histAction'] : 'browse';
$GLOBALS['log']->debug(get_class($this) . "->display(): performing History action {$action}");
$this->{$action}();
}
示例12: display
function display($preview = false)
{
$packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : '';
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName);
$smarty = parent::constructSmarty($parser);
$smarty->assign('action', 'searchViewSave');
$smarty->assign('view', $this->editLayout);
$smarty->assign('helpName', 'searchViewEditor');
$smarty->assign('helpDefault', 'modify');
if ($preview) {
echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl");
} else {
$ajax = $this->constructAjax();
$ajax->addSection('center', translate($this->title), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl"));
echo $ajax->getJavascript();
}
}
示例13: run
/**
* Upgrade Task to Run
*/
public function run()
{
if (version_compare($this->from_version, '7.0.0', '<') && $this->toFlavor('ent')) {
$settings = Opportunity::getSettings();
if ($settings['opps_view_by'] !== 'RevenueLineItems') {
$this->log('Not using Revenue Line Items; Skipping Upgrade Script');
return;
}
$fields = array('sales_stage', 'probability', 'commit_stage');
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$this->log('Processing Opportunity RecordView');
$recordViewDefsParser = ParserFactory::getParser(MB_RECORDVIEW, 'Opportunities', null, null, 'base');
if ($this->removeFields($recordViewDefsParser, $fields)) {
$recordViewDefsParser->handleSave(false);
}
$this->log('Processing Opportunity ListView');
$recordViewDefsParser = ParserFactory::getParser(MB_LISTVIEW, 'Opportunities', null, null, 'base');
if ($this->removeFields($recordViewDefsParser, $fields)) {
$recordViewDefsParser->handleSave(false);
}
$modules = array('Accounts', 'Contacts', 'Campaigns', 'Documents');
global $modInvisList;
if (array_search('Project', $modInvisList)) {
$modules[] = 'Project';
}
foreach ($modules as $module) {
$this->log('Processing Opportunity SubPanel for ' . $module . ' module');
if (isModuleBWC($module)) {
require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php';
$pf = new SubpanelMetaDataParser('opportunities', $module);
} else {
$pf = ParserFactory::getParser(MB_LISTVIEW, $module, null, 'opportunities');
}
if ($this->removeFields($pf, $fields)) {
$pf->handleSave(false);
}
}
}
}
示例14: __autoload
<?php
function __autoload($class_name)
{
include $class_name . '.php';
}
$file = __DIR__ . "/file.json";
$obj = ParserFactory::getParser($file);
var_dump($obj->parseFile());
示例15: addNewFieldsToLayout
/**
* Walk through default record view lookng for fields that did not exist on the original pre-sidecar layout defs
* Any such fields should be appended to the final defs
*
* @param array $newDefs
* @param array $defaultDefs
*/
protected function addNewFieldsToLayout(array $newDefs)
{
$defaultDefs = $this->loadDefaultMetadata();
$parser = ParserFactory::getParser($this->viewtype, $this->module, $this->package, null, $this->client);
$defaultFields = $parser->getFieldsFromPanels($defaultDefs['panels'], $parser->_fielddefs);
$currentFields = $parser->getFieldsFromPanels($newDefs['panels'], $parser->_fielddefs);
$origFields = array();
foreach ($this->originalLegacyViewdefs as $lViewtype => $data) {
// We will need a parser no matter what
if ($this->sidecar) {
$legacyParser = ParserFactory::getParser($lViewtype, $this->module, $this->package, null, $this->client);
} else {
$legacyParser = ParserFactory::getParser($lViewtype, $this->module, $this->package);
}
// replace viewdefs with defaults, since parser's viewdefs can be already customized by other parts
// of the upgrade
$legacyParser->_viewdefs['panels'] = $legacyParser->convertFromCanonicalForm($data['panels'], $legacyParser->_fielddefs);
// get field list
$origData = $legacyParser->getFieldsFromPanels($data['panels'], $legacyParser->_fielddefs);
$origFields = array_merge($origFields, $origData);
}
//Add fields always defaults to the bottom of the first panel.
//In this case the 'first panel' is the first non-header panel, AKA panel[1]
if (empty($newDefs['panels'][1]['fields'])) {
$this->logUpgradeStatus("Unable to find panels to add to");
}
foreach ($defaultFields as $field => $def) {
// If the special field was not present on legacy layout we shouldn't add it.
if ($this->isSpecialFieldBySidecarName($field) && empty($currentFields[$field])) {
continue;
}
//If a field wasn't on the lagacy layout, add it to the custom one.
if (empty($origFields[$field]) && empty($currentFields[$field]) && !empty($newDefs['panels'][1]['fields'])) {
$newDefs['panels'][1]['fields'][] = $def;
}
}
return $newDefs;
}