本文整理汇总了PHP中sys::code方法的典型用法代码示例。如果您正苦于以下问题:PHP sys::code方法的具体用法?PHP sys::code怎么用?PHP sys::code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys
的用法示例。
在下文中一共展示了sys::code方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wurfl_init
/**
* Initialize WURFL
*
*/
function wurfl_init($args = array())
{
if (!isset($args['mode'])) {
$args['mode'] = 'performance';
}
sys::import('modules.wurfl.xarincludes.WURFL.Application');
$resourcesDir = sys::code() . 'modules/wurfl/xarincludes/resources';
$persistenceDir = $resourcesDir . '/storage/persistence';
$cacheDir = $resourcesDir . '/storage/cache';
// Create WURFL Configuration
$wurflConfig = new WURFL_Configuration_InMemoryConfig();
// Set location of the WURFL File
$wurflConfig->wurflFile($resourcesDir . '/wurfl.xml');
// Set the match mode for the API ('performance' or 'accuracy')
$wurflConfig->matchMode($args['mode']);
// Setup WURFL Persistence
$wurflConfig->persistence('file', array('dir' => $persistenceDir));
// Setup Caching
$wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
// Create a WURFL Manager Factory from the WURFL Configuration
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
// Create a WURFL Manager
/* @var $wurflManager WURFL_WURFLManager */
$wurflManager = $wurflManagerFactory->create();
return $wurflManager;
}
示例2: publications_admin_templates_page
function publications_admin_templates_page($args)
{
if (!xarSecurityCheck('AdminPublications')) {
return;
}
extract($args);
if (!xarVarFetch('confirm', 'int', $confirm, 0, XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('ptid', 'id', $data['ptid'], 0, XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('itemid', 'id', $data['itemid'], 0, XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('file', 'str', $data['file'], 'summary', XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('source_data', 'str', $data['source_data'], '', XARVAR_NOT_REQUIRED)) {
return;
}
if (empty($data['itemid']) || empty($data['ptid'])) {
return xarResponse::NotFound();
}
$pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
$pubtypeobject->getItem(array('itemid' => $data['ptid']));
$pubtype = explode('_', $pubtypeobject->properties['name']->value);
$pubtype = isset($pubtype[1]) ? $pubtype[1] : $pubtype[0];
$data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value));
$basepath = sys::code() . "modules/publications/xartemplates/objects/" . $pubtype;
$sourcefile = $basepath . "/" . $data['file'] . "_" . $data['itemid'] . ".xt";
$overridepath = "themes/" . xarModVars::get('themes', 'default_theme') . "/modules/publications/objects/" . $pubtype;
$overridefile = $overridepath . "/" . $data['file'] . "-" . $data['itemid'] . ".xt";
// If we are saving, write the file now
if ($confirm && !empty($data['source_data'])) {
xarMod::apiFunc('publications', 'admin', 'write_file', array('file' => $overridefile, 'data' => $data['source_data']));
}
// Let the template know what kind of file this is
if (file_exists($overridefile)) {
$data['filetype'] = 'theme';
$filepath = $overridefile;
$data['writable'] = is_writable($overridefile);
} else {
$data['filetype'] = 'module';
$filepath = $sourcefile;
$data['writable'] = is_writeable_dir($overridepath);
}
$data['source_data'] = trim(xarMod::apiFunc('publications', 'admin', 'read_file', array('file' => $filepath)));
// Initialize the template
if (empty($data['source_data'])) {
$data['source_data'] = '<xar:template xmlns:xar="http://xaraya.com/2004/blocklayout">';
$data['source_data'] .= "\n";
$data['source_data'] .= "\n" . '</xar:template>';
}
$data['files'] = array(array('id' => 'summary', 'name' => 'summary display'), array('id' => 'detail', 'name' => 'detail display'));
return $data;
}
示例3: publications_admin_stylesheet_type
function publications_admin_stylesheet_type($args)
{
if (!xarSecurityCheck('AdminPublications')) {
return;
}
extract($args);
if (!xarVarFetch('confirm', 'int', $confirm, 0, XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('ptid', 'id', $data['ptid'], xarModVars::get('publications', 'defaultpubtype'), XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('file', 'str', $data['file'], '', XARVAR_NOT_REQUIRED)) {
return;
}
if (!xarVarFetch('source_data', 'str', $data['source_data'], '', XARVAR_NOT_REQUIRED)) {
return;
}
$pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
$pubtypeobject->getItem(array('itemid' => $data['ptid']));
$pubtype = explode('_', $pubtypeobject->properties['name']->value);
$pubtype = isset($pubtype[1]) ? $pubtype[1] : $pubtype[0];
$data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value));
$basepath = sys::code() . "modules/publications/xarstyles";
$sourcefile = $basepath . "/" . $data['file'] . ".css";
$overridepath = "themes/" . xarModVars::get('themes', 'default_theme') . "/modules/publications/style";
$overridefile = $overridepath . "/" . $data['file'] . ".css";
// If we are saving, write the file now
if ($confirm && !empty($data['file']) && !empty($data['source_data'])) {
xarMod::apiFunc('publications', 'admin', 'write_file', array('file' => $overridefile, 'data' => $data['source_data']));
}
// Let the template know what kind of file this is
if (empty($data['file'])) {
$data['filetype'] = 'empty';
$filepath = '';
$data['writable'] = 0;
} elseif (file_exists($overridefile)) {
$data['filetype'] = 'theme';
$filepath = $overridefile;
$data['writable'] = is_writable($overridefile);
} elseif (file_exists($sourcefile)) {
$data['filetype'] = 'module';
$filepath = $sourcefile;
$data['writable'] = is_writeable_dir($overridepath);
} else {
$data['filetype'] = 'unknown';
$filepath = $overridefile;
$data['writable'] = is_writeable_dir($overridepath);
}
$data['source_data'] = trim(xarMod::apiFunc('publications', 'admin', 'read_file', array('file' => $filepath)));
return $data;
}
示例4: publications_admin_importpictures
/**
* import pictures into publications
*/
function publications_admin_importpictures()
{
if (!xarSecurityCheck('AdminPublications')) {
return;
}
// Get parameters
if (!xarVarFetch('basedir', 'isset', $basedir, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('baseurl', 'isset', $baseurl, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('thumbnail', 'isset', $thumbnail, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('filelist', 'isset', $filelist, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('refresh', 'isset', $refresh, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('ptid', 'isset', $ptid, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('title', 'isset', $title, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('summary', 'isset', $summary, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('content', 'isset', $content, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('usefilemtime', 'isset', $usefilemtime, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('cids', 'isset', $cids, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('test', 'isset', $test, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('import', 'isset', $import, NULL, XARVAR_DONT_SET)) {
return;
}
// Initialise the template variables
$data = array();
if (!isset($baseurl)) {
$data['baseurl'] = sys::code() . 'modules/publications/xarimages/';
} else {
$data['baseurl'] = $baseurl;
}
if (!isset($basedir)) {
$data['basedir'] = realpath($data['baseurl']);
} else {
$data['basedir'] = realpath($basedir);
}
if (!isset($thumbnail)) {
$data['thumbnail'] = 'tn_';
} else {
$data['thumbnail'] = $thumbnail;
}
$data['filelist'] = xarModAPIFunc('publications', 'admin', 'browse', array('basedir' => $data['basedir'], 'filetype' => '(gif|jpg|jpeg|png)'));
// try to match the thumbnails with the pictures
$data['thumblist'] = array();
if (!empty($data['thumbnail'])) {
foreach ($data['filelist'] as $file) {
// for subdir/myfile.jpg
$fileparts = pathinfo($file);
// jpg
$extension = $fileparts['extension'];
// subdir
$dirname = $fileparts['dirname'];
// myfile
$basename = $fileparts['basename'];
$basename = preg_replace("/\\.{$extension}/", '', $basename);
if (!empty($dirname) && $dirname != '.') {
$thumb = $dirname . '/' . $data['thumbnail'] . $basename;
} else {
$thumb = $data['thumbnail'] . $basename;
}
// subdir/tn_file.jpg
if (in_array($thumb . '.' . $extension, $data['filelist'])) {
$data['thumblist'][$file] = $thumb . '.' . $extension;
// subdir/tn_file_jpg.jpg
} elseif (in_array($thumb . '_' . $extension . '.' . $extension, $data['filelist'])) {
$data['thumblist'][$file] = $thumb . '_' . $extension . '.' . $extension;
// subdir/tn_file.jpg.jpg
} elseif (in_array($thumb . '.' . $extension . '.' . $extension, $data['filelist'])) {
$data['thumblist'][$file] = $thumb . '.' . $extension . '.' . $extension;
}
}
if (count($data['thumblist']) > 0) {
$deletelist = array_values($data['thumblist']);
$data['filelist'] = array_diff($data['filelist'], $deletelist);
}
}
//.........这里部分代码省略.........
示例5: publications_admin_importpages
/**
* manage publication types (all-in-one function for now)
*/
function publications_admin_importpages()
{
if (!xarSecurityCheck('AdminPublications')) {
return;
}
// Get parameters
if (!xarVarFetch('basedir', 'isset', $basedir, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('filelist', 'isset', $filelist, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('refresh', 'isset', $refresh, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('ptid', 'isset', $ptid, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('content', 'isset', $content, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('title', 'isset', $title, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('cids', 'isset', $cids, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('filterhead', 'isset', $filterhead, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('filtertail', 'isset', $filtertail, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('findtitle', 'isset', $findtitle, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('numrules', 'isset', $numrules, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('search', 'isset', $search, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('replace', 'isset', $replace, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('test', 'isset', $test, NULL, XARVAR_DONT_SET)) {
return;
}
if (!xarVarFetch('import', 'isset', $import, NULL, XARVAR_DONT_SET)) {
return;
}
// Initialise the template variables
$data = array();
if (empty($basedir)) {
$data['basedir'] = realpath(sys::code() . 'modules/publications');
} else {
$data['basedir'] = realpath($basedir);
}
$data['filelist'] = xarModAPIFunc('publications', 'admin', 'browse', array('basedir' => $data['basedir'], 'filetype' => 'html?'));
if (isset($refresh) || isset($test) || isset($import)) {
// Confirm authorisation code
if (!xarSecConfirmAuthKey()) {
return;
}
}
$data['authid'] = xarSecGenAuthKey();
// Get current publication types
$pubtypes = xarModAPIFunc('publications', 'user', 'get_pubtypes');
$data['pubtypes'] = $pubtypes;
$data['fields'] = array();
$data['cats'] = array();
if (!empty($ptid)) {
$data['ptid'] = $ptid;
$pubfields = xarModAPIFunc('publications', 'user', 'getpubfields');
$pubfieldtypes = xarModAPIFunc('publications', 'user', 'getpubfieldtypes');
$pubfieldformats = xarModAPIFunc('publications', 'user', 'getpubfieldformats');
foreach ($pubfields as $field => $dummy) {
if (($pubfieldtypes[$field] == 'text' || $pubfieldtypes[$field] == 'string') && !empty($pubtypes[$ptid]['config'][$field]['label']) && $pubtypes[$ptid]['config'][$field]['format'] != 'fileupload') {
$data['fields'][$field] = $pubtypes[$ptid]['config'][$field]['label'] . ' [' . $pubfieldformats[$pubtypes[$ptid]['config'][$field]['format']] . ']';
}
}
$catlist = array();
$rootcats = xarModAPIFunc('categories', 'user', 'getallcatbases', array('module' => 'publications', 'itemtype' => $ptid));
foreach ($rootcats as $catid) {
$catlist[$catid['category_id']] = 1;
}
$seencid = array();
if (isset($cids) && is_array($cids)) {
foreach ($cids as $catid) {
if (!empty($catid)) {
$seencid[$catid] = 1;
}
}
}
$cids = array_keys($seencid);
foreach (array_keys($catlist) as $catid) {
$data['cats'][] = xarModAPIFunc('categories', 'visual', 'makeselect', array('cid' => $catid, 'return_itself' => true, 'select_itself' => true, 'values' => &$seencid, 'multiple' => 1));
//.........这里部分代码省略.........