示例#1
0
文件: lib.php 项目: laiello/waxphp
/**
 * HTTP Redirection Method
 * This method takes an action as an argument, then causes
 * execution to stop and 3 methods of redirection to be sent 
 * to the client:
 *    - HTTP Location Header
 *    - META tag refresh (failsafe in case the header fails)
 *    - Javascript location.href redirect
 * Note that this method does not allow redirection to 
 * a different controller.
 *
 * @param string $action The action to redirect to
 * @param array $args An array of additional arguments
 */
function redirect($method, $obj = NULL, $args = array())
{
    @ob_end_clean();
    // stop output buffering and disregard any data
    $url = url_to($method, $obj, $args);
    header("Location: {$url}");
    echo "<meta http-equiv='refresh' content='2'>";
    echo "<script type='text/javascript'>location.href='{$url}';</script>";
    die;
    exit;
}
示例#2
0
 function do_delete($id)
 {
     if (isPost()) {
         $comment = $this->get('Comment', $id);
         if ($comment && $comment->canEdit($this->currentUser)) {
             $comment->entry->get();
             $comment->delete();
         } else {
             $this->show_error('Permission denied');
         }
         redirect_back(url_to($comment->entry, 'show'));
     }
 }
示例#3
0
 function __get($k)
 {
     if ($k == 'friendly_created') {
         $ts = strtotime($this->created);
         return strftime('%b %e, %Y - %H:%M%P', $ts);
     } else {
         if ($k == 'from') {
             return $this->user->id ? $this->user->name : $this->name;
         } else {
             if ($k == 'from_link') {
                 return $this->user->id ? url_to($this->user, 'show') : "";
             }
         }
     }
     return parent::__get($k);
 }
示例#4
0
    <sy:updateFrequency>6</sy:updateFrequency> 

    <?php 
foreach ($entries->all as $entry) {
    ?>
      <item> 
        <title><?php 
    echo $entry->name;
    ?>
</title> 
        <guid><?php 
    echo url_to($entry, 'show');
    ?>
</guid>
        <link><?php 
    echo url_to($entry, 'show');
    ?>
</link> 
        <pubDate><?php 
    echo $entry->rssDate;
    ?>
</pubDate> 
        <description><![CDATA[<?php 
    echo $entry->descriptionHtml;
    ?>
]]></description> 
      </item> 
    <?php 
}
?>
示例#5
0
文件: Twig.php 项目: h1soft/h
 private function initFunctions()
 {
     $link_to = new \Twig_SimpleFunction('link_to', function ($_url, $_params = NULL) {
         return url_to($_url, $_params);
     });
     $this->_twigEnv->addFunction($link_to);
     $url_for = new \Twig_SimpleFunction('url_to', function ($_url, $_params = NULL) {
         return url_to($_url, $_params);
     });
     $this->_twigEnv->addFunction($url_for);
     $repeat = new \Twig_SimpleFunction('repeat', function ($_str, $_num = 0) {
         return str_repeat($_str, $_num);
     });
     $this->_twigEnv->addFunction($repeat);
     $url_ref = new \Twig_SimpleFunction('urlRef', function () {
         $rtn = Application::session()->get('hurlref');
         return $rtn ? $rtn : Application::app()->request()->curUrl();
     });
     $this->_twigEnv->addFunction($url_ref);
     $flash = new \Twig_SimpleFunction('flash', function ($_remove = true) {
         $flashmessage = Application::session()->get('hflash');
         if ($_remove) {
             Application::session()->remove('hflash');
         }
         return $flashmessage;
     });
     $this->_twigEnv->addFunction($flash);
     $flashCode = new \Twig_SimpleFunction('flashCode', function ($_remove = true) {
         $hcode = Application::session()->get('hcode');
         if ($_remove) {
             Application::session()->remove('hcode');
         }
         return $hcode;
     });
     $this->_twigEnv->addFunction($flashCode);
     $dateFormat = new \Twig_SimpleFunction('dateFormat', function ($_timestamp = NULL, $format = 'Y-m-d') {
         if ($_timestamp) {
             return date($format, $_timestamp);
         } else {
             return NULL;
         }
     });
     $this->_twigEnv->addFunction($dateFormat);
 }
示例#6
0
<form method='POST' action='<?php 
echo url_to("save");
?>
'>
    <table>
        <tr>
            <th>Attribute</th>
            <th>Value</th>
        </tr>
        
    <?php 
foreach ($record as $attr => $details) {
    ?>
        <tr>
        <?php 
    if ($attr == '_id') {
        continue;
    }
    ?>
        <td><?php 
    echo $attr;
    ?>
</td>
            <td>
            <?php 
    $attrctx = new AttrRenderCtx();
    echo $attrctx->Execute($details, "edit");
    ?>
            </td>
        </tr>
    <?php 
示例#7
0
    margin: 5px 0px 5px 30px;
  }
  .action {
    color: #555;
    font-weight: bold;
  }
  .action.update {color: #464;}
  .action.claim {color: #446;}
  .action.delete {color: #644;}
</style>
<ul id="comments">
<script>
function deleteComment(id) {
  if (confirm("Really delete comment #" + id + "?")) {
    postTo('<?php 
echo url_to('comments', 'delete');
?>
/' + id);
  }
}
</script>
<?php 
foreach ($comments as $comment) {
    $comment->user->get();
    $comment->entry->get();
    ?>
    <li class="comment">
      <div class="meta">
        <a href="<?php 
    echo $comment->from_link;
    ?>
示例#8
0
文件: tags.php 项目: broofa/socipedia
<h2>Entry Tags</h2>
<?php 
// Inspired by http://www.bytemycode.com/snippets/snippet/415/
$font_min = 12;
$font_max = 20;
$count_min = min(array_values($tags));
$count_max = max(array_values($tags));
$spread = min(1, $count_max - $count_min);
$step = ($font_max - $font_min) / $spread;
$tag_names = array_keys($tags);
sort($tag_names);
foreach ($tag_names as $tag) {
    $count = $tags[$tag];
    $size = round($font_min + ($count - $count_min) * $step);
    $url = url_to('entries', 'index', 'q=' . hashquery($tag));
    echo anchor($url, $tag . " ", array('title' => "{$tag} appears in {$count} entries", 'class' => "taglink", 'style' => "font-size:{$size}px;"));
}
示例#9
0
 function redirect($uri = '', $method = 'location', $http_response_code = 302, $https = NULL, $language = FALSE)
 {
     if (!preg_match('#^https?://#i', $uri)) {
         if (is_null($https)) {
             $https = is_https();
         }
         $uri = url_to($uri, $https, $language);
     }
     switch ($method) {
         case 'refresh':
             header("Refresh:0;url=" . $uri);
             break;
         default:
             header("Location: " . $uri, TRUE, $http_response_code);
             break;
     }
     exit;
 }
示例#10
0
    echo $resource;
    ?>
    <input type='hidden' name='record_id' value='<?php 
    echo $record_id;
    ?>
' />
    <input type='hidden' name='resource_id' value='<?php 
    echo $resource;
    ?>
' />
</form>
<?php 
}
?>
<hr />
<form method="POST" action="<?php 
echo url_to("give_permission");
?>
">
    <h3>Give Permission</h3>
    
    Resource:
    <input type='text' name='resource_id' />
    <input type='hidden' name='record_id' value='<?php 
echo $record_id;
?>
' />
    
    <br />
    <input type='submit' value='Save Permissions' />
</form>
示例#11
0
文件: edit.php 项目: broofa/socipedia
}
.hint {
  color: #642;
  font-size:10px;
  display:block;
  padding-top:2px;
}
</style>
  <h2><?php 
echo $user->id ? "Settings for {$user->html_hame}" : "Create New Account";
?>
</h2>
<p>
</p>
<form id="entry_form" method="POST" action="<?php 
echo $user->id ? url_to($user, 'update') : url_to('users', 'create');
?>
">
  <label>
    Email
    <input name="email" type="text" value="<?php 
echo $user->email;
?>
" />
    <div class="hint">Private. Not shared. No spam.</div> 
  </label>
  <label>
    Name 
    <input name="name" type="text" value="<?php 
echo $user->html_name;
?>
示例#12
0
<h2>Users</h2>
<ul>
<?php 
foreach ($users->all as $user) {
    ?>
  <li><a href="<?php 
    echo url_to($user, 'show');
    ?>
"><?php 
    echo $user->html_name;
    ?>
</a></li>
<?php 
}
?>
</ul>
示例#13
0
 function do_logout()
 {
     $this->session->sess_destroy();
     redirect_back(url_to());
 }
示例#14
0
    ?>
'>
        <?php 
    echo render_view($block, "DDM/attr_edit", array("attr" => $details, "types" => $attr_types));
    ?>
    </ul>
    <?php 
}
?>
</div>
<input type='submit' value='Save Model' />
</form>
<br />
<h3>Add An Attribute</h3>
<form method='post' action='<?php 
echo url_to('modify_add');
?>
'>
    <input type='text' name='attr[name]' />
    <select name='attr[type]'>
    <?php 
foreach ($attr_types as $type) {
    ?>
        <option value="<?php 
    echo $type;
    ?>
"><?php 
    echo $type;
    ?>
</option>
    <?php 
示例#15
0
 /**
  * Creates a link element
  *
  * @access	protected
  * @param	array menu item data
  * @param	string the active path if you want the active class rendered on the anchor (optional)
  * @return	string
  */
 protected function _create_link($val, $active = NULL)
 {
     $str = '';
     $label = $this->_get_label($val);
     $attrs = '';
     if (!empty($val['location'])) {
         if (!empty($val['attributes'])) {
             if (is_array($val['attributes'])) {
                 foreach ($val['attributes'] as $key2 => $val2) {
                     $attrs .= ' ' . $key2 . '="' . $val2 . '"';
                 }
             } else {
                 $attrs .= ' ' . $val['attributes'];
             }
         }
         if ($this->use_titles and (empty($attrs) or strpos($attrs, 'title=') === FALSE)) {
             $attrs .= ' title="' . strip_tags($val['label']) . '"';
         }
         if (!empty($active) and $this->active == $active) {
             $attrs .= ' class="' . $this->active_class . '"';
         }
         $location = preg_match('/^#/', $val['location']) ? $val['location'] : url_to($val['location']);
         $str .= '<a href="' . $location . '"' . $attrs . '>' . $label . '</a>';
     } else {
         if (!empty($active) and $this->active == $active) {
             $str .= '<span class="' . $this->active_class . '">';
             $has_active = TRUE;
         }
         $str .= $label;
         if (!empty($has_active)) {
             $str .= '</span>';
         }
     }
     return $str;
 }
示例#16
0
<h3>Create a New Data Model</h3>

<form method='post' action='<?php 
echo url_to('create_model');
?>
'>
    <input type='text' name='modelname' />
    <input type='submit' value='Create Model' />
</form>

<h3>Data Models:</h3>

<?php 
foreach ($types as $type => $attrs) {
    ?>
    <table style='width:500px;'>
        <tr>
            <th colspan='2'><?php 
    echo $type;
    ?>
</th>
        </tr>
        <?php 
    foreach ($attrs as $attr => $attr_type) {
        ?>
            <tr>
                <td style='width:50%;'><?php 
        echo $attr;
        ?>
</td>
                <td><?php 
示例#17
0
function _hashlinks($matches)
{
    return "<a class=\"hashtag\" href=\"" . url_to('entries', 'index', 'q=' . hashquery($matches[1])) . "\">" . $matches[0] . "</a>";
}
示例#18
0
文件: show.php 项目: broofa/socipedia
?>
</dl>

<?php 
if ($entry->comment->count() > 0) {
    ?>
<h3>Comments</h3>
<?php 
    echo $cmarkup;
}
?>

<p style="font-weight: bold">Add a comment / request action for this entry</p>

<form id="comment_ui" class="basic_form" action="<?php 
echo url_to($entry, 'comment');
?>
" method="POST">
  <?php 
if (!$currentUser) {
    ?>
    <div class="label">Name</div>
    <input name="name" type="text" value="" />
    <?php 
    echo cleer();
    ?>

    <div class="label">Email</div>
    <input name="email" type="text" value="" />
    <?php 
    echo cleer();
示例#19
0
文件: Common.php 项目: h1soft/h
function url_for($_url, $_params = NULL, $_type = false)
{
    return url_to($_url, $_params, $_type);
}
示例#20
0
?>

          <span class="sep" style="margin-left: 100px"></span>

          <?php 
echo link_to('entries', null, 'Browse', 'class="button left_cap"');
?>
          <?php 
echo link_to('entries', 'tags', 'Tags', 'class="button right_cap"');
?>

          <?php 
echo link_to('entries', 'new', 'Add Entry', 'class="button"');
?>
          <form action="<?php 
echo url_to('entries');
?>
" method="GET">
          <input type="text" id="q" name="q" onready="this.focus()" />
          </form>
        </div>
      </div>


      <div id="content">
        <?php 
echo $flash;
?>
        <?php 
echo $content;
?>
示例#21
0
<form method="POST" style="text-align: center;">
<?php 
if (isset($flash)) {
    ?>
<p class="message warn"><?php 
    echo $flash;
    ?>
<p><?php 
}
?>
<p>This entry is password protected.  Please provide the password:</p>
<input name="auth" type="password" />
<input type="submit" />
</form>
<form action="<?php 
echo url_to($entry, 'recover_password');
?>
" method="POST" onsubmit="return confirm('This will send an email with password recovery instructions to the owner of this entry. Is that okay?')" style="text-align: center;">
<p style="color:#666; font-size: 10px;">forgot your password?  <input type="submit" value="click here" style="border: none; text-decoration: underline; color: #00a; background: none; padding: 0px; margin: 0px;" /></p>
</form>
示例#22
0
 function do_comment($id)
 {
     $entry = $this->get('Entry', $id);
     if (isPost()) {
         $comment = new Comment();
         $comment->name = param('name');
         $comment->email = param('email');
         $comment->body = param('body');
         $comment->action = param('action');
         if (isSpam(null, null, $comment->body)) {
             $this->show_error('Yuck, that didn\'t taste very good!');
         }
         // Gather up relationships to save
         $rels = array($entry);
         if ($this->currentUser) {
             $rels[] = $this->currentUser;
         }
         // Save the entry
         $comment->save($rels);
     }
     redirect(url_to($entry, 'show'));
 }
示例#23
0
文件: Controller.php 项目: h1soft/h
 public function redirect($url, $httpCode = 302)
 {
     if (startWith($url, 'http://') || startWith($url, 'https://')) {
     } else {
         $url = url_to($url);
     }
     if ($httpCode == 301) {
         header('HTTP/1.1 301 Moved Permanently');
     }
     header("Location: {$url}");
     die;
 }
示例#24
0
        echo $cn;
        ?>
" style="background-image: url(<?php 
        echo $entry->thumbURL();
        ?>
)"><?php 
    } else {
        ?>
<li class="<?php 
        echo $cn;
        ?>
"><?php 
    }
    ?>
    <a href="<?php 
    echo url_to($entry);
    ?>
">
      <div class="name"><?php 
    echo $dn;
    ?>
</div>
      <div class="summary"><?php 
    echo $entry->descriptionSummary;
    ?>
</div>
      <?php 
    echo cleer();
    ?>
    </a>
    </li>