作者:radicalsu
项目:am
function check_authen_credentials()
{
// First check for an existing authentication token.
if (isset($_COOKIE[$this->_cookie_name])) {
$this->notice('cookie exists');
if ($result = $this->_handler->check_cookie($_COOKIE[$this->_cookie_name])) {
return $result;
}
}
//Check for a temporary auth token
if (isset($_GET[$this->_cookie_name]) && isset($_GET['authtype']) && $_GET['authtype'] == 'temp') {
if ($result = $this->_handler->check_cookie($_GET[$this->_cookie_name])) {
$cookie_bits = explode(':', $_GET[$this->_cookie_name]);
$hash = $cookie_bits[0];
$this->_handler->set_authen_tokens();
$this->_dbcon->Execute('DELETE FROM users_sessions where hash=' . $this->_dbcon->qstr($hash));
if (isset($_GET['auth_action']) && $_GET['auth_action'] == 'reset') {
trigger_error('redirecting to :' . AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
ampredirect(AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
exit;
}
return $result;
}
}
if (isset($_REQUEST[$this->_login_username_field]) || isset($_SERVER['PHP_AUTH_USER'])) {
$this->notice('checking password');
return $this->_handler->check_password();
}
$this->error('neither cookie nor password found');
return false;
}
作者:radicalsu
项目:am
function get_url_edit()
{
if (!(isset($this->id) && $this->id)) {
return AMP_SYSTEM_URL_FAQ;
}
return AMP_url_update(AMP_SYSTEM_URL_FAQ, array('id' => $this->id));
}
作者:radicaldesign
项目:am
function nav_articles_by_date()
{
$page =& AMPContent_Page::instance();
if ($class = $page->getClassId()) {
$date_values = AMP_lookup('classArticlesByDate', $class);
} else {
$date_values = AMP_lookup('articlesByDate');
}
if (!$date_values) {
return false;
}
$output = array();
$renderer = AMP_get_renderer();
foreach ($date_values as $pretty_date => $qty) {
$real_date = strtotime($pretty_date);
$url['year'] = date('Y', $real_date);
$url['month'] = date('m', $real_date);
$url['offset'] = false;
$url['qty'] = false;
$new_url = AMP_url_update($_SERVER['REQUEST_URI'], $url);
$output[] = $renderer->link($new_url, $pretty_date, array('class' => AMP_CONTENT_CSS_CLASS_NAV_LINK));
if (count($output) == AMP_CONTENT_NAV_ARCHIVE_LIMIT) {
break;
}
}
return join($renderer->newline(), $output);
}
作者:radicaldesign
项目:am
function onDelete(&$controller, $args = array())
{
$model = $controller->get_model();
$nav_layout = $model->getLayoutId();
if ($nav_layout) {
ampredirect(AMP_url_update(AMP_SYSTEM_URL_NAV_LAYOUT, array('id' => $nav_layout)));
}
}
作者:radicaldesign
项目:am
function temp_auth_actions()
{
if (isset($_GET['auth_action']) && $_GET['auth_action'] == 'reset') {
trigger_error('redirecting to :' . AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
ampredirect(AMP_url_update('/system/' . AMP_SYSTEM_URL_USER, array('id' => $this->_handler->userid, 'action' => 'reset')));
exit;
}
}
作者:radicaldesign
项目:am
function render_url_for_scaled($source, $width_limit)
{
if ($source->width <= $width_limit) {
return $this->render_url_for($source);
}
$img_class = end(split(DIRECTORY_SEPARATOR, dirname($source->getPath())));
return AMP_url_update(AMP_CONTENT_URL_IMAGE, array('filename' => $source->getName(), 'class' => $img_class, 'action' => 'resize', 'width' => $width_limit));
}
作者:radicaldesign
项目:am
function buildUrlArray()
{
foreach ($this->section_keys as $id) {
$this->urls[] = AMP_url_update(AMP_CONTENT_URL_LIST_SECTION, array('type' => $id));
}
foreach ($this->article_keys as $id) {
$this->urls[] = AMP_url_update(AMP_CONTENT_URL_ARTICLE, array('id' => $id));
}
}
作者:radicaldesign
项目:am
function get_url_edit()
{
$badge = $this->getBadgeId();
if ($badge) {
return AMP_url_update(AMP_SYSTEM_URL_BADGE, array('id' => $badge));
}
$nav = $this->getNavId();
if ($nav) {
return AMP_url_update(AMP_SYSTEM_URL_NAV, array('id' => $nav));
}
return false;
}
作者:radicaldesign
项目:am
function render_sections($source)
{
$section_list = $this->load_live_sections($source);
$sections = array();
foreach ($section_list as $section_id => $section_name) {
$sections[] = $this->_renderer->link(AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('type' => $section_id, 'class' => AMP_CONTENT_CLASS_BLOG)), $section_name);
}
$result = join(", ", $sections);
if (!$result) {
return false;
}
return AMP_TEXT_POSTED_IN . $this->_renderer->space() . $result;
}
作者:radicaldesign
项目:am
function _dbEdit($source, $column_name)
{
$db_images = AMP_lookup('db_images');
if (!$db_images) {
return false;
}
$image_db_id = array_search($source->getName(), $db_images);
if ($image_db_id === FALSE) {
return false;
}
$renderer =& $this->_getRenderer();
return $renderer->link(AMP_url_update(AMP_SYSTEM_URL_IMAGES, array('id' => $image_db_id)), AMP_TEXT_EDIT);
}
作者:radicaldesign
项目:am
function render_nav_links($data, $fieldname)
{
if (!(isset($data['id']) && $data['id'])) {
return false;
}
$linked_navs = AMP_lookup('navs_by_badge', $data['id']);
if (!$linked_navs) {
return false;
}
$renderer = AMP_get_renderer();
foreach ($linked_navs as $id => $name) {
$links[$id] = $renderer->link(AMP_url_update(AMP_SYSTEM_URL_NAV, array('id' => $id)), $name);
}
return 'Linked Navs:' . $renderer->UL($links);
}
作者:radicaldesign
项目:am
function link_to_layouts($data, $fieldname)
{
if (!(isset($data['id']) && $data['id'])) {
return false;
}
$linked_layouts = AMP_lookup('nav_layouts_by_nav', $data['id']);
if (!$linked_layouts) {
return false;
}
$renderer = AMP_get_renderer();
asort($linked_layouts);
foreach ($linked_layouts as $id => $name) {
if (!$name) {
continue;
}
$links[$id] = $renderer->link(AMP_url_update(AMP_SYSTEM_URL_NAV_LAYOUT, array('id' => $id)), $name);
}
return 'Used in Layouts:' . $renderer->UL($links, array('class' => 'linked_items'));
}
作者:radicaldesign
项目:am
function _init_criteria()
{
if (!isset($this->_pager)) {
return;
}
$pager_target = false;
$section = isset($this->_source_criteria['section']) && $this->_source_criteria['section'] && !is_array($this->_source_criteria['section']) ? $this->_source_criteria['section'] : false;
$class = isset($this->_source_criteria['class']) && $this->_source_criteria['class'] && !is_array($this->_source_criteria['class']) ? $this->_source_criteria['class'] : false;
if ($section && $class) {
$pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('type' => $section, 'class' => $class));
} elseif ($section) {
$pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_SECTION, array('type' => $section));
} elseif ($class) {
$pager_target = AMP_url_update(AMP_CONTENT_URL_LIST_CLASS, array('class' => $class));
}
if ($pager_target) {
$this->_pager->set_target($pager_target);
}
}
作者:radicalsu
项目:am
function restore()
{
$target_id = $this->getData('id');
if (!$target_id) {
return false;
}
require_once 'AMP/Content/Template.inc.php';
$template =& new AMPContent_Template($this->dbcon, $target_id);
$template->save_version();
$template->mergeData($this->getData());
$result = $template->save();
if (!$result) {
return false;
}
AMP_flush_common_cache();
$flash =& AMP_System_Flash::instance();
$flash->add_message(sprintf(AMP_TEXT_DATA_RESTORE_SUCCESS, $this->getName()));
ampredirect(AMP_url_update(AMP_SYSTEM_URL_TEMPLATE, array('id' => $target_id)));
return $result;
}
作者:radicalsu
项目:am
function _make_event_list_field()
{
$uid = $this->udm->uid;
if (!$uid) {
$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
}
if (!$uid) {
return;
}
$events = AMP_lookup('eventsByOwner', $uid);
if (!$events) {
return;
}
$event_list = '';
$renderer = AMP_get_renderer();
foreach ($events as $event_id => $event_name) {
$event_list .= $renderer->link(AMP_url_update(AMP_SYSTEM_URL_EVENT, array('id' => $event_id)), $event_name) . $renderer->newline();
}
$this->fields['events_list'] = array('type' => 'static', 'enabled' => true, 'default' => $event_list, 'public' => false);
$this->fields['events_list_header'] = array('type' => 'header', 'label' => 'All Events Created By this User', 'public' => false, 'enabled' => true);
$this->insertAfterFieldOrder(array('events_list_header', 'events_list'));
}
作者:radicaldesign
项目:am
function nav_sub_section($type, $sort)
{
$finder = new Section(AMP_Registry::getDbcon());
if (isset($sort) && $sort) {
$finder_source =& $finder->getSearchSource();
$finder_source->addSort($sort);
}
$sections = $finder->find(array('parent' => $type, 'displayable' => '1'));
if (!$sections) {
return;
}
$html = '<ul>';
foreach ($sections as $section) {
if (AMP_CONTENT_HUMANIZE_URLS) {
$sectionURL = AMP_url_update('section.php', array('id' => $section->id));
} else {
$sectionURL = 'section.php?id=' . $section->id;
}
$html .= '<li><a href="' . $sectionURL . '">' . $section->getName() . '</a><img src="img/spacer.gif" height="4" width="3" align="left"> </li>';
}
$html .= '</ul>';
return $html;
}
作者:radicaldesign
项目:am
/**
* amp_badge_articles archive
* class: default( blank ) set to a value to limit the archive to one class ( accepts comma-separated set )
* limit: default( 24 ) set a max # of links to archived months. 2 years is the max and the default.
*/
function amp_badge_articles_archive($options)
{
$renderer = AMP_get_renderer();
$class = isset($options['class']) && $options['class'] ? $options['class'] : false;
$limit = isset($options['limit']) && $options['limit'] ? $options['limit'] : 24;
$articles_archive = $class ? AMP_lookup('article_archives_by_month_by_class', $class) : AMP_lookup('article_archives_by_month');
if (!$articles_archive) {
return false;
}
$articles_archive = array_slice(array_keys($articles_archive), 0, $limit);
$links = array();
$url_vars = array();
if ($class) {
$url_vars['class'] = $class;
}
foreach ($articles_archive as $date) {
$datetime = strtotime($date);
$url_vars['date[M]'] = date('m', $datetime);
$url_vars['date[Y]'] = date('Y', $datetime);
$links[] = $renderer->link(AMP_url_update('list.php', $url_vars), $date);
}
return $renderer->UL($links, array('class' => 'article-archives'));
}
作者:radicalsu
项目:am
function &to_akismet($item_data)
{
$false = false;
if (!AKISMET_KEY) {
return $false;
}
$options = $this->getOptions();
if (isset($options['akismet_body_field']) && $options['akismet_body_field']) {
return $false;
}
$all_data = $this->udm->getData();
if (!isset($all_data[$options['akismet_body_field']])) {
return $false;
}
$body_field = $all_data[$options['akismet_body_field']];
$ak_data = array();
$ak_data['author'] = $item_data['First_Name'] . ' ' . $item_data['Last_Name'];
$ak_data['email'] = $item_data['Email'];
$ak_data['type'] = 'form_input';
$ak_data['website'] = $item_data['Website'];
$ak_data['body'] = $item_data[$body_field];
$ak_data['permalink'] = isset($item_data['modin']) && $item_data['modin'] ? AMP_url_update(AMP_SITE_URL . '/' . AMP_CONTENT_URL_FORM, array('modin' => $item_data['modin'])) : false;
require_once 'akismet/akismet.class.php';
$akismet = new Akismet(AMP_SITE_URL, AKISMET_KEY, $ak_data);
if ($akismet->isError(AKISMET_SERVER_NOT_FOUND)) {
trigger_error('Akismet: Server Not Found');
return $false;
}
if ($akismet->isError(AKISMET_RESPONSE_FAILED)) {
trigger_error('Akismet: Response Failed');
return $false;
}
if ($akismet->isError(AKISMET_INVALID_KEY)) {
trigger_error('Akismet: Invalid Key');
return $false;
}
return $akismet;
}
作者:radicaldesign
项目:am
function do_request()
{
if (!$this->_request->execute()) {
return false;
}
if (!AMP_DISPLAYMODE_DEBUG) {
ampredirect(AMP_url_update($_SERVER['REQUEST_URI']));
}
if ($affected_qty = $this->_request->getAffectedQty()) {
$this->message(sprintf(AMP_TEXT_LIST_ACTION_SUCCESS, ucfirst(AMP_PastParticiple($this->_request->getPerformedAction())), $affected_qty));
AMP_flush_common_cache();
} else {
$this->message(sprintf(AMP_TEXT_LIST_ACTION_FAIL, AMP_PastParticiple($this->_request->getPerformedAction())));
}
$this->_after_request();
}
作者:radicaldesign
项目:am
function render_comments($source)
{
if (!$source->allowsComments()) {
return false;
}
require_once 'AMP/Content/Article/Comment/Public/List.php';
$comments = new Article_Comment_Public_List(null, array('article' => $source->id));
$comment_header = '<p class="subtitle comment_header"><a name="comments"></a>Comments</p>';
$add_link = $this->_renderer->link(AMP_url_update(AMP_CONTENT_URL_COMMENT_ADD, array('articleid' => $source->id)), AMP_TEXT_ADD_A_COMMENT);
return $comment_header . $comments->execute() . ($source->acceptingNewComments() ? $add_link : $this->_renderer->p(AMP_TEXT_COMMENTS_CLOSED));
}