本文整理汇总了PHP中Link类的典型用法代码示例。如果您正苦于以下问题:PHP Link类的具体用法?PHP Link怎么用?PHP Link使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Link类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
parent::initContent();
$params = KwixoURLCallFrontController::ManageUrlCall();
$payment_ok = $params['payment_status'];
$errors = $params['errors'];
$id_order = $params['id_order'];
if ($id_order != false) {
$order = new Order($id_order);
$cart = new Cart($order->id_cart);
$products = $cart->getProducts();
$amount = $order->total_paid_tax_incl;
$total_shipping = $order->total_shipping;
} else {
$products = false;
$amount = false;
$total_shipping = false;
}
$link = new Link();
$this->context->smarty->assign('payment_ok', $payment_ok);
$this->context->smarty->assign('errors', $errors);
$this->context->smarty->assign('amount', $amount);
$this->context->smarty->assign('total_shipping', $total_shipping);
$this->context->smarty->assign('products', $products);
$this->context->smarty->assign('path_order', $link->getPageLink('order', true));
$this->context->smarty->assign('path_history', $link->getPageLink('history', true));
$this->context->smarty->assign('path_contact', $link->getPageLink('contact', true));
$this->setTemplate('urlcall.tpl');
}
示例2: _prepareHook
protected function _prepareHook($params)
{
$languages = Language::getLanguages(true, $this->context->shop->id);
if (!count($languages)) {
return false;
}
$link = new Link();
if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
$default_rewrite = array();
if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
$rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
}
}
if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
$rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
}
}
if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
$rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
foreach ($rewrite_infos as $infos) {
$arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
$default_rewrite[$infos['id_lang']] = $arr_link;
}
}
$this->smarty->assign('lang_rewrite_urls', $default_rewrite);
}
return true;
}
示例3: countLinks
function countLinks($categoryName)
{
App::import('Model', 'Link');
$link = new Link();
$settings = array('conditions' => array('LinkCategory.name' => $categoryName));
return $link->find('count', $settings);
}
示例4: getUserprofileForUserId
/**
* Liefert das Userprofil zur klein-Anzeige (neben Posts)
*
* @param $id ID des Users
*/
function getUserprofileForUserId($id)
{
$sql = "SELECT * FROM user where id = '" . $id . "' ";
$res = $_SESSION['config']->DBCONNECT->executeQuery($sql);
$retRow = mysql_fetch_array($res);
$ft = new FontType();
$ft->setBold(true);
$ft->setFontsize(3);
$picLnk = new Link("includes/user/show_userprofil.php?showUserId=" . $id, getUserImageSourceByPicname($retRow['pic'], 80));
$picLnk->setPopup(true);
$status = new Text("<b>Status:</b> " . $retRow['Status']);
$status->setFilter(false);
$posts = new Text("<b>Posts:</b> " . $retRow['Posts']);
$posts->setFilter(false);
$tbl = new Table(array(""));
$r1 = $tbl->createRow();
$r1->setFonttype($ft);
$r1->setAttribute(0, $retRow['Vorname'] . " " . $retRow['Nachname']);
$tbl->addRow($r1);
$r2 = $tbl->createRow();
$r2->setAttribute(0, $picLnk);
$tbl->addRow($r2);
$r3 = $tbl->createRow();
$r3->setAttribute(0, $status);
$tbl->addRow($r3);
$r4 = $tbl->createRow();
$r4->setAttribute(0, $posts);
$tbl->addRow($r4);
return $tbl;
}
示例5: sendQuestion
public function sendQuestion()
{
if (Tools::getValue('enviar_mensaje')) {
$params = array();
$params['nombre'] = pSQL(Tools::getValue('nombre', ''));
$params['email'] = pSQL(Tools::getValue('email', ''));
$params['ciudad'] = pSQL(Tools::getValue('ciudad', ''));
$params['provincia'] = pSQL(Tools::getValue('provincia', ''));
$params['consulta'] = pSQL(Tools::getValue('consulta', ''));
$params['id_producto'] = (int) Tools::getValue('id_producto', 0);
$params['date_add'] = date('Y-m-d H:i:s', strtotime('now'));
$params['validado'] = 0;
DB::getInstance()->insert('lgconsultas', $params);
$id_consulta = Db::getInstance()->Insert_ID();
if ($id_consulta) {
$consulta = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'lgconsultas` WHERE id_consulta=' . (int) $id_consulta);
$producto = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'product_lang WHERE id_product=' . (int) $consulta['id_producto'] . ' AND id_lang=' . (int) Configuration::get('PS_LANG_DEFAULT'));
$enlace = new Link();
$urlproducto = $enlace->getProductLink($consulta['id_producto']);
$templateVars = array('id_consulta' => $id_consulta, '{consulta}' => pSQL($consulta['consulta']), '{nombre}' => pSQL($consulta['nombre']), '{email}' => pSQL($consulta['email']), '{provincia}' => pSQL($consulta['provincia']), '{ciudad}' => pSQL($consulta['ciudad']), '{producto}' => $producto, '{urlproducto}' => $urlproducto);
if (!Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'consulta_enviada', $this->l('You have received a new question about a product'), $templateVars, Configuration::get('LG_CONSULTAS_EMAIL'), null, Configuration::get('LG_CONSULTAS_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'lgconsultas/mails/')) {
$out = array('status' => 'nok', 'msg' => $this->l('An error occurred while sending your question'));
} else {
$out = array('status' => 'ok', 'msg' => $this->l('Your question has been sent'));
}
} else {
$out = array('status' => 'nok', 'msg' => $this->l('An error occurred while trying to add your question'));
}
echo Tools::jsonEncode($out);
die;
}
}
示例6: status_comment_submit
function status_comment_submit($vars)
{
global $db, $main_smarty;
if (get_misc_data('status_switch') != '1') {
return;
}
$comment = $vars['comment'];
if (!$comment->id) {
return;
}
$user = new User();
$user->id = $comment->author;
$linkres = new Link();
$linkres->id = $comment->link;
if ($user->read() && $linkres->read()) {
if (!status_is_allowed($user) || !$user->extra_field['status_switch'] || !$user->extra_field['status_comment']) {
return;
}
$main_smarty->config_load(status_lang_conf);
$text = $main_smarty->get_config_vars('PLIGG_Status_Comment_Update');
$limit = get_misc_data('status_max_chars');
if ($limit > 0 && strlen($text) + strlen($user->username) + strlen($linkres->title) - 4 > $limit) {
$linkres->title = substr($linkres->title, 0, max($limit + 4 - strlen($text) - strlen($user->username) - 3, 10)) . '...';
}
$text = sprintf($text, $user->username, '<a href="' . $linkres->get_internal_url() . '">' . $linkres->title . '</a>');
$db->query($sql = "INSERT INTO " . table_prefix . "updates SET update_time=UNIX_TIMESTAMP(), \r\n\t\t\t\t\t\t\t update_type='c',\r\n\t\t\t\t\t\t\t update_user_id='{$comment->author}',\r\n\t\t\t\t\t\t\t update_link_id='{$comment->id}',\r\n\t\t\t\t\t\t\t update_text='{$text}'\r\n\t\t\t\t\t\t\t ");
}
}
示例7: postShorten
/**
* Shorten a new URL
*
* @return Response
*/
public function postShorten()
{
// No big url
if (!\Input::has('bigurl')) {
return \Response::json(array('error' => array('code' => 'MISSING-PARAMETERS', 'http_code' => '400', 'message' => 'Bad Request')), 400);
}
$bigURL = \Input::get('bigurl');
$user = $this->apiKey->user;
// No user linked to API key - SHOULD NEVER HAPPEN
if (!isset($user)) {
return \Response::json(array('error' => array('code' => 'NOT-AUTH', 'http_code' => '403', 'message' => 'Forbidden: SHOULD NEVER HAPPEN!')), 403);
}
// User has gone over quota so cant shorten
if ($user->quota_max != 0 && $user->quota_used + 1 > $user->quota_max) {
return \Response::json(array('error' => array('code' => 'QUOTA-USED', 'http_code' => '400', 'message' => 'Bad Request')), 403);
}
if (filter_var($bigURL, FILTER_VALIDATE_URL) === false) {
return \Response::json(array('error' => array('code' => 'URL-INVALID', 'http_code' => '400', 'message' => 'Bad Request')), 400);
}
$dbLink = \Link::where('destination', '=', $bigURL)->first();
if (!isset($dbLink)) {
$dbLink = new \Link();
$dbLink->user_id = $user->id;
$dbLink->code = $dbLink->generateCode();
$dbLink->destination = $bigURL;
$dbLink->clicks = "0";
$dbLink->save();
$user->quota_used += 1;
$user->save();
}
$linkCode = $dbLink->code;
$linkURL = \Request::root() . '/' . $linkCode;
return \Response::json(array('ok' => array('code' => 'LINK-SHORTENED', 'http_code' => '200', 'message' => 'OK', 'data' => array('url' => $linkURL, 'url_code' => $linkCode))), 200);
}
示例8: initContent
public function initContent()
{
parent::initContent();
$id = $_GET['id'];
$id_lang = $this->context->language->id;
$product = new Product((int) $id);
$link = new Link();
$url = $link->getProductLink($product);
$features = Db::getInstance()->ExecuteS('
SELECT fl.name feature_name, fvl.value feature_value
FROM ' . _DB_PREFIX_ . 'feature_product fp
LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' )
LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ')
WHERE fp.id_product=' . $id);
// print_r($features);
$images = Image::getImages((int) $id_lang, (int) $product->id);
//Limitamos el numero de fotos a cuatro solamente
while (count($images) > 3) {
$var = array_pop($images);
}
$this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND')));
$html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl');
$dompdf = new DOMPDF();
$dompdf->set_option('enable_remote', TRUE);
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();
$dompdf->stream('producto');
//$this->setTemplate('custom_template_content.tpl');
//file_put_contents($filename, $dompdf->output());
//$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty);
//$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg';
//$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
//$pdf->render();
}
示例9: displayEditForm
function displayEditForm()
{
global $wgOut, $wgRequest;
$url = $wgRequest->getVal('_url');
$title = $wgRequest->getVal('_title');
$l = new Link();
$link = $l->getLinkByPageID($wgRequest->getInt('id'));
if (is_array($link)) {
$url = htmlspecialchars($link['url'], ENT_QUOTES);
$description = htmlspecialchars($link['description'], ENT_QUOTES);
} else {
$title = SpecialPage::getTitleFor('LinkSubmit');
$wgOut->redirect($title->getFullURL());
}
$wgOut->setPageTitle(wfMsg('linkfilter-edit-title', $link['title']));
$_SESSION['alreadysubmitted'] = false;
$output = '<div class="lr-left">
<div class="link-home-navigation">
<a href="' . Link::getHomeLinkURL() . '">' . wfMsg('linkfilter-home-button') . '</a>';
if (Link::canAdmin()) {
$output .= ' <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
}
$output .= '<div class="cleared"></div>
</div>
<form name="link" id="linksubmit" method="post" action="">
<div class="link-submit-title">
<label>' . wfMsg('linkfilter-url') . '</label>
</div>
<input tabindex="2" class="lr-input" type="text" name="lf_URL" id="lf_URL" value="' . $url . '"/>
<div class="link-submit-title">
<label>' . wfMsg('linkfilter-description') . '</label>
</div>
<div class="link-characters-left">' . wfMsg('linkfilter-description-max') . ' - ' . wfMsg('linkfilter-description-left', '<span id="desc-remaining">300</span>') . '</div>
<textarea tabindex="3" class="lr-input" rows="4" name="lf_desc" id="lf_desc">' . $description . '</textarea>
<div class="link-submit-title">
<label>' . wfMsg('linkfilter-type') . '</label>
</div>
<select tabindex="4" name="lf_type" id="lf_type">
<option value="">-</option>';
$linkTypes = Link::getLinkTypes();
foreach ($linkTypes as $id => $type) {
$selected = '';
if ($link['type'] == $id) {
$selected = ' selected="selected"';
}
$output .= "<option value=\"{$id}\"{$selected}>{$type}</option>";
}
$output .= '</select>
<div class="link-submit-button">
<input tabindex="5" class="site-button" type="button" id="link-submit-button" value="' . wfMsg('linkfilter-submit-button') . '" />
</div>
</form>
</div>';
$output .= '<div class="lr-right">' . wfMsgExt('linkfilter-instructions', 'parse') . '</div>
<div class="cleared"></div>';
return $output;
}
示例10: related_stories
function related_stories($storyid, $related_tags, $category)
{
// this returns similar stories based on tags in common and in the same category
global $db;
if (!is_numeric($storyid)) {
die;
}
$related_tags = "'" . preg_replace('/,\\s*/', "','", addslashes($related_tags)) . "'";
// This gives us the proper string structure for IN SQL statement
// Select 20 stories that share tags with the current story and order them by number of tags they share
$sql = "SELECT tag_link_id, COUNT(tag_link_id) AS relevance\n\t\t\tFROM " . table_tags . "\n\t\t\tWHERE tag_words IN ({$related_tags}) AND tag_link_id!={$storyid}\n\t\t\tGROUP BY tag_link_id \n\t\t\tORDER BY relevance DESC \n\t\t\tLIMIT 20";
$related_story = $db->get_results($sql);
$related_story = object_2_array($related_story);
$stories = array();
foreach ($related_story as $id => $rs) {
$rs2 = new Link();
$rs2->id = $rs['tag_link_id'];
if ($rs2->read() && ($rs2->status == 'new' || $rs2->status == 'published')) {
$related_story[$id] = array_merge($related_story[$id], array('link_id' => $rs2->id, 'link_category' => $rs2->category, 'link_title' => $rs2->title, 'link_title_url' => $rs2->title_url));
if ($rs2->title_url == "") {
$related_story[$id]['url'] = getmyurl("story", $rs2->id);
} else {
$related_story[$id]['url'] = getmyurl("storyURL", $rs2->category_safe_names(), urlencode($rs2->title_url), $rs2->id);
}
$stories[] = $related_story[$id];
}
}
return $stories;
}
示例11: render
/**
* Method render
* @access public
* @param boolean $ajax_render [default value: false]
* @return object generate html box with country flag
* @since 1.0.35
*/
public function render($ajax_render = false)
{
$lang_link = BASE_URL . $this->language . "/" . str_replace($this->getPage()->getBaseLanguageURL(), "", $this->getPage()->getCurrentURL());
$lang_link_obj = new Link($lang_link, Link::TARGET_NONE, new Picture("wsp/img/lang/" . $this->language . ".png", 24, 24, 0, Picture::ALIGN_ABSMIDDLE));
$this->object_change = false;
return $lang_link_obj->render();
}
示例12: attach
public function attach(Link $link)
{
//I attach it first to a list in case I want to dynamically add or remove items
//perhaps later I'll want to delete in an ACL ?
$this->items[$link->getText()] = $link;
$this->body->appendChild($this->items[$link->getText()]->getDOMNode());
}
示例13: test_it_gets_link
public function test_it_gets_link()
{
$Framework = new \Devise\Support\Framework();
$cookie = [];
$Link = new Link($Framework);
$output = $Link->getLink($cookie);
assertEquals('<a href="http://localhost?dir=asc" class="page-sort"></a> ', $output);
}
示例14: testSettingRequest
public function testSettingRequest()
{
$request = $this->makeRequest();
$request->expects($this->once())->method('getScriptName')->will($this->returnValue('/htdocs/test.php'));
$link = new Link('test');
$link->setRequest($request);
$this->assertEquals('/htdocs/test.php?r=test', $link->getLink());
}
示例15: isPhpClass
private function isPhpClass(Link $link)
{
$className = $link->getDestination();
if (!class_exists($className, false)) {
return false;
}
$classReflection = new \ReflectionClass($link->getDestination());
return $classReflection->isInternal();
}