本文整理汇总了PHP中Base_ThemeCommon::parse_links方法的典型用法代码示例。如果您正苦于以下问题:PHP Base_ThemeCommon::parse_links方法的具体用法?PHP Base_ThemeCommon::parse_links怎么用?PHP Base_ThemeCommon::parse_links使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base_ThemeCommon
的用法示例。
在下文中一共展示了Base_ThemeCommon::parse_links方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_installed_applets_html
public static function get_installed_applets_html()
{
$colors = Base_DashboardCommon::get_available_colors();
$app_cap = ModuleManager::call_common_methods('applet_caption');
asort($app_cap);
$app_info = ModuleManager::call_common_methods('applet_info');
$html = '';
foreach ($app_cap as $name => $cap) {
if (!$cap) {
continue;
}
$th = Base_ThemeCommon::init_smarty();
$id = str_replace('_', '-', $name);
if (!isset($app_info[$name])) {
$app_info[$name] = '';
}
$th->assign('content', '<div class="content" style="padding:4px;" id="dashboard_applet_content_' . $id . '">' . $app_info[$name] . '</div>');
$th->assign('handle_class', 'handle');
$th->assign('caption', $cap);
$th->assign('color', $colors[0]['class']);
$remove_button = Base_DashboardCommon::get_remove_applet_button($id, false);
$th->assign('remove', $remove_button);
$th->assign('__link', array('remove' => Base_ThemeCommon::parse_links('remove', $remove_button)));
//print('<xmp>'.self::get_remove_applet_button(null, false).'</xmp><br>');
$th->assign('actions', array());
$th->assign('config_mode', true);
$html .= '<div class="applet" searchkey="' . strtolower($cap ? $cap : $name) . ';' . strtolower($app_info[$name]) . '" id="ab_item_' . 'new_' . $id . '">';
ob_start();
Base_ThemeCommon::display_smarty($th, 'Base_Dashboard', 'default');
$html .= ob_get_clean();
$html .= '</div>';
}
return $html;
}
示例2: assign
/**
* Assigns text to a smarty variable.
* Also parses the text looking for a link tag and if one is found,
* creates additinal smarty variables holding open, label and close for found tag.
*
* @param string name for smarty variable
* @param string variable contents
*/
public function assign($name, $val)
{
$new_links = Base_ThemeCommon::parse_links($name, $val);
$this->links[$name] = $new_links;
$this->smarty->assign($name, $val);
}
示例3: get_file_leightbox
public static function get_file_leightbox($row, & $view_link = '') {
static $th;
if(!isset($th)) $th = Base_ThemeCommon::init_smarty();
if($row['original']==='') return '';
$links = array();
$lid = 'get_file_'.md5(serialize($row));
if(isset($_GET['save_google_docs']) && $_GET['save_google_docs']==$lid) {
self::save_google_docs($row['id']);
}
if(isset($_GET['discard_google_docs']) && $_GET['discard_google_docs']==$lid) {
self::discard_google_docs($row['id']);
}
$close_leightbox_js = 'leightbox_deactivate(\''.$lid.'\');';
if (Variable::get('utils_attachments_google_user',false) && preg_match('/\.(xlsx?|docx?|txt|odt|ods|csv)$/i',$row['original'])) {
$label = __('Open with Google Docs');
$label = explode(' ', $label);
$mid = floor(count($label) / 2);
$label = implode(' ', array_slice($label, 0, $mid)).' '.implode(' ', array_slice($label, $mid));
$script = 'get_google_docs';
$onclick = '$(\'attachment_save_options_'.$row['id'].'\').style.display=\'\';$(\'attachment_download_options_'.$row['id'].'\').hide();';
$th->assign('save_options_id','attachment_save_options_'.$row['id']);
$links['save'] = '<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('save_google_docs'=>$lid)).'">'.__('Save Changes').'</a><br>';
$links['discard'] ='<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('discard_google_docs'=>$lid)).'">'.__('Discard Changes').'</a><br>';
} else {
$label = __('View');
$th->assign('save_options_id','');
$script = 'get';
$onclick = $close_leightbox_js;
}
$th->assign('download_options_id','attachment_download_options_'.$row['id']);
$view_link = 'modules/Utils/Attachment/'.$script.'.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID,'view'=>1));
$links['view'] = '<a href="'.$view_link.'" target="_blank" onClick="'.$onclick.'">'.$label.'</a><br>';
$links['download'] = '<a href="modules/Utils/Attachment/get.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID)).'" onClick="leightbox_deactivate(\''.$lid.'\')">'.__('Download').'</a><br>';
load_js('modules/Utils/Attachment/remote.js');
if(!$row['crypted']) {
$links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link('.$row['id'].', '.CID.',\'get link\');leightbox_deactivate(\''.$lid.'\')">'.__('Get link').'</a><br>';
}
$th->assign('filename',$row['original']);
$f_filename = DATA_DIR.'/Utils_Attachment/'.$row['aid'].'/'.$row['id'];
if(!file_exists($f_filename)) return 'missing file: '.$f_filename;
$th->assign('file_size',__('File size: %s',array(filesize_hr($f_filename))));
$th->assign('labels',array(
'filename'=>__('Filename'),
'file_size'=>__('File size')
));
foreach($links as $key=>&$l) {
$th->assign($key,$l);
$l = Base_ThemeCommon::parse_links($key, $l);
}
$th->assign('__link',$links);
$custom_getters = array();
if(!$row['crypted']) {
$getters = ModuleManager::call_common_methods('attachment_getters');
foreach($getters as $mod=>$arr) {
if (is_array($arr))
foreach($arr as $caption=>$func) {
$cus_id = md5($mod.$caption.serialize($func));
if(isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter']==$cus_id)
call_user_func_array(array($mod.'Common',$func['func']),array($f_filename,$row['original'],$row['id']));
$custom_getters[] = array('open'=>'<a href="javascript:void(0)" onClick="'.Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter'=>$cus_id)),true,false).';leightbox_deactivate(\''.$lid.'\')">','close'=>'</a>','text'=>$caption,'icon'=>$func['icon']);
}
}
}
$th->assign('custom_getters',$custom_getters);
ob_start();
Base_ThemeCommon::display_smarty($th,'Utils_Attachment','download');
$c = ob_get_clean();
Libs_LeightboxCommon::display($lid,$c,__('Attachment'));
return Libs_LeightboxCommon::get_open_href($lid);
}
示例4: parse_links
/**
* For internal use only.
*/
public static function parse_links($key, $val, $flat = true)
{
if (!is_array($val)) {
$val = trim($val);
$i = 0;
$count = 0;
$open = "";
$text = "";
$close = "";
$len = strlen($val);
if ($len > 2 && $val[0] === '<' && $val[1] === 'a') {
while ($i < $len - 1) {
if ($val[$i] === '<') {
if ($val[$i + 1] === 'a') {
if ($count === 0) {
while ($i < $len - 1 && $val[$i] !== '>') {
$open .= $val[$i];
$i++;
if ($val[$i] === '"') {
do {
$open .= $val[$i];
$i++;
} while ($i < $len && $val[$i] !== '"');
}
}
$open .= '>';
} else {
$text .= $val[$i];
}
$count++;
} else {
if (substr($val, $i + 1, 3) === '/a>') {
$count--;
if ($count === 0) {
$close = '</a>';
return array('open' => $open, 'text' => $text, 'close' => '</a>');
} else {
$text .= $val[$i];
}
} else {
$text .= $val[$i];
}
}
} else {
$text .= $val[$i];
}
$i++;
}
}
return array();
} else {
$result = array();
foreach ($val as $k => $v) {
$result[$k] = Base_ThemeCommon::parse_links($k, $v, false);
}
return $result;
}
}
示例5: get_file_leightbox
public static function get_file_leightbox($row, &$view_link = '')
{
static $th;
if (!isset($th)) {
$th = Base_ThemeCommon::init_smarty();
}
if ($row['original'] === '') {
return '';
}
$links = array();
$lid = 'get_file_' . md5(serialize($row));
$close_leightbox_js = 'leightbox_deactivate(\'' . $lid . '\');';
$label = __('View');
$th->assign('save_options_id', '');
$script = 'get';
$onclick = $close_leightbox_js;
$th->assign('download_options_id', 'attachment_download_options_' . $row['id']);
$view_link = 'modules/Utils/Attachment/' . $script . '.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID, 'view' => 1));
$links['view'] = '<a href="' . $view_link . '" target="_blank" onClick="' . $onclick . '">' . $label . '</a><br>';
$links['download'] = '<a href="modules/Utils/Attachment/get.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID)) . '" onClick="leightbox_deactivate(\'' . $lid . '\')">' . __('Download') . '</a><br>';
load_js('modules/Utils/Attachment/remote.js');
if (!$row['crypted']) {
$links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link(' . $row['id'] . ', ' . CID . ',\'get link\');leightbox_deactivate(\'' . $lid . '\')">' . __('Get link') . '</a><br>';
}
$th->assign('filename', $row['original']);
$meta = Utils_FileStorageCommon::meta($row['filestorage_id']);
$f_filename = $meta['file'];
if (!file_exists($f_filename)) {
return 'missing file: ' . $f_filename;
}
$th->assign('file_size', __('File size: %s', array(filesize_hr($f_filename))));
$th->assign('labels', array('filename' => __('Filename'), 'file_size' => __('File size')));
foreach ($links as $key => &$l) {
$th->assign($key, $l);
$l = Base_ThemeCommon::parse_links($key, $l);
}
$th->assign('__link', $links);
$custom_getters = array();
if (!$row['crypted']) {
$getters = ModuleManager::call_common_methods('attachment_getters');
foreach ($getters as $mod => $arr) {
if (is_array($arr)) {
foreach ($arr as $caption => $func) {
$cus_id = md5($mod . $caption . serialize($func));
if (isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter'] == $cus_id) {
call_user_func_array(array($mod . 'Common', $func['func']), array($f_filename, $row['original'], $row['id']));
}
$custom_getters[] = array('open' => '<a href="javascript:void(0)" onClick="' . Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter' => $cus_id)), true, false) . ';leightbox_deactivate(\'' . $lid . '\')">', 'close' => '</a>', 'text' => $caption, 'icon' => $func['icon']);
}
}
}
}
$th->assign('custom_getters', $custom_getters);
ob_start();
Base_ThemeCommon::display_smarty($th, 'Utils_Attachment', 'download');
$c = ob_get_clean();
Libs_LeightboxCommon::display($lid, $c, __('Attachment'));
return Libs_LeightboxCommon::get_open_href($lid);
}