本文整理汇总了PHP中HtmlHelper类的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper类的具体用法?PHP HtmlHelper怎么用?PHP HtmlHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HtmlHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave($options = array())
{
Configure::write('debug', 2);
App::uses("HtmlHelper", "View/Helper");
$html = new HtmlHelper(new View());
if ($this->data[$this->alias]['image']['name'] != "") {
$ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
$image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
$destination = "files/recipe_images/" . $image_name;
if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) {
$bowl = $this->createBowl($destination);
$tmp = explode("/", $bowl);
$destination2 = "files/recipe_images/" . $tmp[1];
//unlink($destination);
rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]);
rename($bowl, $destination2);
}
$this->data[$this->alias]['image'] = $html->url("/" . $dt, true);
$this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true);
} else {
unset($this->data[$this->alias]['image']);
}
parent::beforeSave($options);
return true;
}
示例2: autoLinkText
public static function autoLinkText($text, $options = array())
{
static $Html;
if (!$Html) {
if (!class_exists('HtmlHelper', false)) {
\App::import('Helper', 'Html');
}
$Html = new \HtmlHelper();
$Html->tags = $Html->loadConfig();
}
// Email
$atom = '[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]';
$text = preg_replace_callback('/(' . $atom . '+(?:\\.' . $atom . '+)*@[a-z0-9-]+(?:\\.[a-z0-9-]+)*)/i', function ($matches) use($Html, $options) {
return $Html->link($matches[0], "mailto:" . $matches[0], $options);
}, $text);
// http / web
$text = preg_replace_callback('#(?<!href="|">)((?:https?|ftp|nntp)://[^\\s<>()]+)#i', function ($matches) use($Html, $options) {
return $Html->link($matches[0], $matches[0], $options);
}, $text);
// http / web - part 2
$text = preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\\.[^\\n\\%\\ <]+[^<\\n\\%\\,\\.\\ <])(?<!\\))#i', function ($matches) use($Html, $options) {
return $Html->link($matches[0], "http://" . $matches[0], $options);
}, $text);
return $text;
}
示例3: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
$events = array();
if ($text_reason) {
foreach ($this->events as $event) {
$events[] = $event['Event']['name'];
}
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
foreach ($this->events as $event) {
$url = array('controller' => 'events', 'action' => 'view', 'event' => $event['Event']['id']);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$events[] = $html->link($event['Event']['name'], $url);
}
}
$this->reason = __('have previously registered for the', true) . ' ' . implode(' ' . __('or', true) . ' ', $events);
if (is_array($params) && array_key_exists('Registration', $params)) {
$registered = Set::extract('/Registration/Event/id', $params);
$prereqs = array_intersect($registered, $this->config);
if (!empty($prereqs)) {
return true;
}
}
return false;
}
示例4: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
if ($text_reason) {
$this->reason = sprintf(__('have signed the %s waiver', true), $this->waiver);
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
$url = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$this->reason = $html->link(sprintf(__('have signed the %s waiver', true), $this->waiver), $url);
}
$this->redirect = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
if (!$strict) {
$this->invariant = true;
return true;
}
if (is_array($params) && array_key_exists('Waiver', $params)) {
$matches = array_intersect($this->config, Set::extract("/Waiver/WaiversPerson[valid_from<={$this->date}][valid_until>={$this->date}]/waiver_id", $params));
if (!empty($matches)) {
$this->invariant = true;
return true;
}
}
return false;
}
示例5: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
$matches = Set::extract("/Upload[type_id={$this->config[0]}]", $params['Upload']);
$unapproved = Set::extract('/Upload[approved=0]', $matches);
if (empty($unapproved)) {
if ($text_reason) {
$this->reason = sprintf(__('have uploaded the %s', true), $this->document);
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
$url = array('controller' => 'people', 'action' => 'document_upload', 'type' => $this->config[0]);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$this->reason = $html->link(sprintf(__('have uploaded the %s', true), $this->document), $url);
}
} else {
$this->reason = sprintf(__('wait until your %s is approved', true), $this->document);
}
if (!$strict) {
return true;
}
if (is_array($params) && array_key_exists('Upload', $params)) {
$date = date('Y-m-d', strtotime($this->config[1]));
$matches = Set::extract("/Upload[type_id={$this->config[0]}][valid_from<={$date}][valid_until>={$date}]", $params['Upload']);
if (!empty($matches)) {
return true;
}
}
return false;
}
示例6: _addScripts
/**
* _addScripts method
*
* Adds properties
*
* @param mixed $view
* @return boolean
*/
public function _addScripts($view)
{
if ($this->request->params['plugin'] == 'lil_invoices') {
App::uses('HtmlHelper', 'View/Helper');
$Html = new HtmlHelper($view);
$Html->css('/lil_invoices/css/lil_invoices.css', null, array('inline' => false));
}
return true;
}
示例7: _addScripts
/**
* _addScripts method
*
* Adds properties
*
* @param mixed $view
* @return boolean
*/
public function _addScripts($view)
{
if ($this->request->params['plugin'] == 'lil_tasks' || $this->request->params['plugin'] == 'lil' && $this->request->params['action'] == 'admin_dashboard') {
App::uses('HtmlHelper', 'View/Helper');
$Html = new HtmlHelper($view);
$Html->css('/lil_tasks/css/lil_tasks.css', null, array('inline' => false));
$Html->script('/lil_tasks/js/lil_tasks.js');
}
return true;
}
示例8: request
/**
* Sends HttpSocket requests. Builds your uri and formats the response too.
*
* @param Model $model Model object
* @param mixed $requestData Array of request or string uri
* @param string $requestMethod read, create, update, delete
*
* @return array|false $response
*/
public function request(Model $model = null, $requestData = null, $requestMethod = HttpSource::METHOD_READ)
{
if ($model === null) {
return parent::request($model, $requestData, $requestMethod);
}
$HtmlHelper = new HtmlHelper(new View());
unset($model->request['uri'], $model->request['virtual']);
$model->request['body'] = '<?xml version="1.0" encoding="utf-8"?>' . $HtmlHelper->tag('request', $model->request['body']);
return parent::request($model, $requestData, $requestMethod);
}
示例9: __toString
function __toString()
{
$help = new HtmlHelper();
$html = $help->css('/admin/custom/formtabs.css') . $help->javascript('/admin/custom/formtabs.js');
$html .= '<div id="tabs">';
foreach ($this->tabs as $tab) {
$html .= $help->absoluteLink($tab[0], '#' . $tab[1]);
}
$html .= '<div class="clear"></div></div>';
$html .= $this->getClientValidationHtml();
return $html;
}
示例10: add
function add()
{
//$this->view = "View"; //qdmailとdebug kitを併用するとエラー起きるのでその対策、本番環境では当然いらない
//Configure::write('debug',0);
$this->layout = 'ajax';
// ログインしていない、または自分のuser_idをフォローしようとしていたらjsonに何もセットせず、結果的にjasonでnullのみを返す
if (($id = $this->Auth->user('id')) === null || $this->Auth->user('id') === $this->params['follow_id']) {
//$this->cakeError('error404');
//$this->redirect($this->Auth->logout());
} else {
$res['login'] = TRUE;
//ちゃんとloginしている場合はjsonファイルに設定、というかここがtrueだと処理成功とjsonで判断される
}
//var_dump($this->Auth->user('id'));
$data['Follow'] = array('user_id' => $id, 'follow_user_id' => $this->params['follow_id']);
//var_dump($data);
//$this->data = $data;
$this->Follow->create();
if ($this->Follow->save($data)) {
//$this->Session->setFlash(__('The Follow has been saved', true));
//メールの送信準備
$this->User->unbindModel(array('hasMany' => array('Task')), false);
//twitter投稿用のuser情報だけ欲しいのでunbind
$user = $this->User->findAllById($this->params['follow_id']);
//pr($user);
if ($user[0]['User']['email'] && $user[0]['User']['follow_mail_enabled']) {
//followした人の名前情報
$following_name = $this->Auth->user('realname') ? $this->Auth->user('realname') : $this->Auth->user('username');
//followした人の詳しい名前情報
$following_2name = $this->Auth->user('realname') ? "{$this->Auth->user('realname')} ({$this->Auth->user('username')})" : $this->Auth->user('username');
//followされた人の名前情報
//$follower_name = $user[0]['User']['realname'] ? $user[0]['User']['realname'] : $user[0]['User']['username'] ;
//followされた人の詳しい名前情報
$follower_2name = $user[0]['User']['realname'] ? "{$user[0]['User']['realname']} ({$user[0]['User']['username']})" : $user[0]['User']['username'];
//ドメインを含んだ絶対URLの取得
App::import('Helper', 'Html');
$html = new HtmlHelper();
$base_url = $html->url(array('controller' => $this->Auth->user('username')), true);
//$res = array($user,$follow_username,$follow_realname,$following_username,$user[0]['User']['email'],);
//メールの送信
$this->QdmailWrap->address = $user[0]['User']['email'];
$this->QdmailWrap->subject = "{$following_name}があなたをフォローし始めました";
$this->QdmailWrap->message = "こんにちは、{$follower_2name}さん。\n\n{$following_2name} があなたをフォローし始めました。\n\n{$following_name}さんのプロフィールはこちらまで:\n {$base_url}\n\n{$following_name}をフォローするために、「フォロー」のボタンをクリックしてください\nりすったー。\n \n--\nリスッターから「follow notification」のメールを受信したくない場合は、今すぐ解除できます。リスッターからのメール選択について再度登録や変更をしたい場合は、自分のアカウントから「設定」へ行きお知らせ機能を操作してください。";
if ($this->QdmailWrap->post()) {
//メール送信に成功したら
}
}
}
//$res['test']='testdayo';
$this->set('result', json_encode($res));
$this->render(null, null, VIEWS . DS . 'ajax.ctp');
// Ajax 用共通 view
}
示例11: open_toggle_box
function open_toggle_box($title = null)
{
App::import('Helper', 'Html');
$html = new HtmlHelper();
if (!$title) {
$title = 'NONE';
} else {
$title = $html->link($title, '#', array("id" => 'toggle-' . strtolower($title)));
}
//print pr($title);die();
$text = '<div class="box">' . '<h2>' . $title . '</h2>' . '<div class="block" id="' . strtolower($title) . '">';
return $text;
}
示例12: parseMessage
function parseMessage($inventory, $message)
{
App::uses('HtmlHelper', 'View/Helper');
$htmlHelper = new HtmlHelper($this->_View);
$messageArray = explode(" ", $message);
for ($i = 0; $i < count($messageArray); $i++) {
$aString = trim($messageArray[$i]);
if (array_key_exists($aString, $inventory)) {
$messageArray[$i] = $htmlHelper->link($aString, '/inventory/moreInfo/' . $inventory[$aString]);
}
}
return implode(" ", $messageArray);
}
示例13: beforeSave
public function beforeSave($options = array())
{
App::uses("HtmlHelper", "View/Helper");
$html = new HtmlHelper(new View());
if ($this->data[$this->alias]['name'] != "") {
$ext = pathinfo($this->data[$this->alias]['name'], PATHINFO_EXTENSION);
$image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
$this->data[$this->alias]['path'] = $html->url("/files/sentdesigns/" . $image_name, true);
$destination = "files/sentdesigns/" . $image_name;
move_uploaded_file($this->data[$this->alias]['tmp_name'], $destination);
}
parent::beforeSave($options);
}
示例14: index
public function index()
{
$shortUrl = '';
if (!empty($this->data)) {
if ($shortUrl = $this->Shorturl->shortUrl($this->data)) {
App::import('Helper', 'Html');
$html = new HtmlHelper();
$this->Session->setFlash(sprintf(__('Your new Url is %s', true), $html->link($shortUrl['Shorturl']['short'], $shortUrl['Shorturl']['short'])), 'success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(sprintf(__('The %s could not be shortened. Please, try again.', true), __('Url', true)), 'error');
}
}
}
示例15: __toString
function __toString()
{
$this->_html_name = $this->_name . '[file]';
if ($this->current_filename == '') {
return parent::__toString();
}
$html = new HtmlHelper();
$id = $this->getAttribute('id');
$button = '<div id="editablebox_' . $id . '">' . $this->current_filename . ' ';
$button .= $html->absoluteLink('[X]', 'javascript:void(0)', array('id' => 'delete_' . $id));
$button .= $html->inlineJavascript('Phaxsi.Event.addEvent(document.getElementById("delete_' . $id . '"), "click", deleteFile.createDelegate(this, ["' . $id . '", "' . $this->input_hidden->getAttribute('id') . '"]));');
$button .= '</div>';
$this->beforeHTML = $html->javascript('/widgets/custom/editablefile.js') . $button . $this->input_hidden->__toString();
return parent::__toString();
}