本文整理汇总了PHP中PerchAPI::get方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchAPI::get方法的具体用法?PHP PerchAPI::get怎么用?PHP PerchAPI::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchAPI
的用法示例。
在下文中一共展示了PerchAPI::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Import data from CSV file into database
*/
public function import()
{
$API = new PerchAPI(1.0, 'root_locator');
$Lang = $API->get('Lang');
$Template = $API->get('Template');
$Template->set('locator/address.html', 'locator');
$Addresses = new RootLocator_Addresses($API);
$Tasks = new RootLocator_Tasks($API);
$data = $this->reader->fetchAssoc();
foreach ($data as $row) {
$errors = $this->getRowErrors($row);
$warnings = $this->getRowWarnings($row);
if ($errors) {
$this->addError($row, $Lang->get('‘%s’ columns are missing required data', $errors));
continue;
}
if ($warnings) {
$this->addWarning($row, $Lang->get('‘%s’ columns are recommended to prevent geocoding errors.', $warnings));
}
$imported = $Addresses->create(['addressTitle' => $row['addressTitle'], 'addressBuilding' => $row['addressBuilding'], 'addressStreet' => $row['addressStreet'], 'addressTown' => $row['addressTown'], 'addressRegion' => $row['addressRegion'], 'addressPostcode' => $row['addressPostcode'], 'addressCountry' => $row['addressCountry']]);
$imported->index($Template);
$Tasks->add('address.geocode', $imported->id());
$this->addSuccess($row);
}
}
示例2: set_status
public function set_status($status)
{
$API = new PerchAPI(1.0, 'perch_blog');
$Settings = $API->get('Settings');
$akismet_api_key = $Settings->get('perch_blog_akismet_key')->val();
// Are we using akismet?
if ($akismet_api_key) {
if ($this->commentStatus() == 'SPAM' && $status == 'LIVE') {
// was marked as spam, but isn't. So tell askismet.
$spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);
if (PerchUtil::count($spam_data)) {
PerchBlog_Akismet::submit_ham($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
}
}
if ($status == 'SPAM') {
// was marked as not spam, but is spam.
$spam_data = PerchUtil::json_safe_decode($this->commentSpamData(), true);
if (PerchUtil::count($spam_data)) {
PerchBlog_Akismet::submit_spam($akismet_api_key, $spam_data['fields'], $spam_data['environment']);
}
}
}
$data = array('commentStatus' => $status);
$this->update($data);
$Posts = new PerchBlog_Posts();
$Post = $Posts->find($this->postID());
if (is_object($Post)) {
$Post->update_comment_count();
}
}
示例3: populate
/**
* get campaign data from the API and store it in our table
*/
public function populate($api_key, $list_id, $echo_feedback = false)
{
$MailChimp = new MailChimp($api_key);
if ($echo_feedback) {
$API = new PerchAPI(1.0, 'perch_mailchimp');
$Lang = $API->get('Lang');
}
$opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id, 'status' => 'sent'));
$result = $MailChimp->call('campaigns/list', $opts);
if ($result && isset($result['total']) && $result['total'] > 0) {
foreach ($result['data'] as $item) {
$campaignID = $item['id'];
//get the content
$content_opts = array('apikey' => $api_key, 'cid' => $campaignID);
$content = $MailChimp->call('campaigns/content', $content_opts);
if (isset($content['html'])) {
$campaignHTML = $content['html'];
}
if (isset($content['text'])) {
$campaignText = $content['text'];
}
// array for insertion
$campaign = array('campaignCID' => $campaignID, 'campaignWebID' => $item['web_id'], 'campaignTitle' => $item['title'], 'campaignCreateTime' => $item['create_time'], 'campaignSendTime' => $item['send_time'], 'campaignSent' => $item['emails_sent'], 'campaignSubject' => $item['subject'], 'campaignArchiveURL' => $item['archive_url'], 'campaignHTML' => $campaignHTML, 'campaignText' => $campaignText, 'campaignSlug' => PerchUtil::urlify(date('d M Y', strtotime($item['create_time'])) . ' ' . $item['subject']));
//insert into our table
$this->db->insert($this->table, $campaign);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing campaign %s (%s)', $item['title'], $item['create_time']);
echo '</li>';
flush();
}
}
}
}
示例4: jw_activity_log_prune
function jw_activity_log_prune($last_run_date)
{
include_once 'JwActivityLog_Actions.class.php';
include_once 'JwActivityLog_Action.class.php';
$API = new PerchAPI(1.0, 'jw_activity_log');
$Settings = $API->get('Settings');
$Actions = new JwActivityLog_Actions($API);
$total_pruned = $Actions->prune_logs((int) $Settings->get('jw_activity_log_prune_time')->settingValue());
return array('result' => 'OK', 'message' => $total_pruned . ' logs pruned');
}
示例5: update
public function update($data, $do_cats = true, $do_tags = true)
{
$PerchBlog_Posts = new PerchBlog_Posts();
if (isset($data['cat_ids'])) {
$catIDs = $data['cat_ids'];
unset($data['cat_ids']);
} else {
$catIDs = false;
}
// Update the post itself
parent::update($data);
// slug
if (isset($data['postTitle'])) {
$API = new PerchAPI(1.0, 'perch_blog');
$Settings = $API->get('Settings');
$format = $Settings->get('perch_blog_slug_format')->val();
if (!$format) {
$format = '%Y-%m-%d-{postTitle}';
}
$this->tmp_slug_vars = $this->details;
$slug = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array($this, "substitute_slug_vars"), $format);
$this->tmp_slug_vars = array();
$data['postSlug'] = strtolower(strftime($slug, strtotime($data['postDateTime'])));
parent::update($data);
}
if ($do_tags) {
// Delete existing tags
$this->db->delete(PERCH_DB_PREFIX . 'blog_posts_to_tags', $this->pk, $this->id());
// Split tag string into array
if (isset($data['postTags']) && $data['postTags'] != '') {
$a = explode(',', $data['postTags']);
if (is_array($a)) {
for ($i = 0; $i < sizeOf($a); $i++) {
$tmp = array();
$tmp['postID'] = $this->id();
$tag_str = trim($a[$i]);
//does this tag exist
$sql = 'SELECT tagID, tagTitle FROM ' . PERCH_DB_PREFIX . 'blog_tags WHERE tagTitle = ' . $this->db->pdb($tag_str) . ' LIMIT 1';
$row = $this->db->get_row($sql);
if (is_array($row)) {
$tmp['tagID'] = $row['tagID'];
} else {
$tag = array();
$tag['tagTitle'] = $tag_str;
$tag['tagSlug'] = PerchUtil::urlify($tag_str);
$tmp['tagID'] = $this->db->insert(PERCH_DB_PREFIX . 'blog_tags', $tag);
}
$this->db->insert(PERCH_DB_PREFIX . 'blog_posts_to_tags', $tmp);
}
}
}
}
return true;
}
示例6: perch_mailchimp_form
function perch_mailchimp_form($template, $content = array(), $return = false)
{
$API = new PerchAPI(1.0, 'perch_mailchimp');
$Template = $API->get('Template');
$Template->set('mailchimp/' . $template, 'mailchimp');
$html = $Template->render($content);
$html = $Template->apply_runtime_post_processing($html, $content);
if ($return) {
return $html;
}
echo $html;
}
示例7: perch_form
function perch_form($template, $return = false)
{
$API = new PerchAPI(1.0, 'perch_forms');
$Template = $API->get('Template');
$Template->set('forms' . DIRECTORY_SEPARATOR . $template, 'forms');
$html = $Template->render(array());
$html = $Template->apply_runtime_post_processing($html);
if ($return) {
return $html;
}
echo $html;
}
示例8: get_backup_search_sql
public static function get_backup_search_sql($key)
{
$API = new PerchAPI(1.0, 'perch_blog');
$db = $API->get('DB');
$sql = 'SELECT \'' . __CLASS__ . '\' AS source, campaignSendTime AS score, campaignSubject, campaignSlug, campaignSendTime, campaignText, campaignID, "", "", ""
FROM ' . PERCH_DB_PREFIX . 'mailchimp_campaigns
WHERE (
concat(" ", campaignSubject, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", campaignHTML, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
) ';
return $sql;
}
示例9: get_backup_search_sql
public static function get_backup_search_sql($key)
{
$API = new PerchAPI(1.0, 'perch_event');
$db = $API->get('DB');
$sql = 'SELECT \'' . __CLASS__ . '\' AS source, eventDateTime AS score, eventTitle, eventSlug, eventDateTime, eventDescHTML, eventID, "", "", ""
FROM ' . PERCH_DB_PREFIX . 'events
WHERE eventDateTime>' . $db->pdb(date('Y-m-d H:i:s')) . '
AND (
concat(" ", eventTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", eventDescRaw, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
) ';
return $sql;
}
示例10: pinboard_bookmarks
function pinboard_bookmarks($tag)
{
$API = new PerchAPI(1.0, 'pinboard');
$Settings = $API->get('Settings');
$username = $Settings->get('pinboard_username')->settingValue();
$password = $Settings->get('pinboard_password')->settingValue();
$pinboard = new PinboardAPI($username, $password);
$items = $pinboard->search_by_tag($tag);
$result = [];
foreach ($items as $key => $value) {
$result[$key] = array('title' => $value->title, 'description' => $value->description, 'url' => $value->url, 'date' => gmdate("l dS F Y", $value->timestamp));
}
return $result;
}
示例11: get_backup_search_sql
/**
* Perform a basic search if no results are returned from primary search
*
* @param string $key
*
* @return string
*/
public static function get_backup_search_sql($key)
{
$API = new PerchAPI(1.0, 'root_locator');
$db = $API->get('DB');
$sql = '
SELECT \'' . __CLASS__ . '\' AS source, addressTitle AS score, addressTitle, addressBuilding, addressStreet, addressPostcode, addressID, "", "", ""
FROM ' . PERCH_DB_PREFIX . 'root_locator_addresses
WHERE addressLatitude IS NOT NULL AND addressLongitude IS NOT NULL
AND (
concat(" ", addressTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", addressBuilding, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", addressStreet, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", addressPostcode, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . ')';
return $sql;
}
示例12: get_backup_search_sql
public static function get_backup_search_sql($key)
{
$API = new PerchAPI(1.0, 'perch_blog');
$db = $API->get('DB');
$sql = 'SELECT \'' . __CLASS__ . '\' AS source, postDateTime AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", ""
FROM ' . PERCH_DB_PREFIX . 'blog_posts p, ' . PERCH_DB_PREFIX . 'blog_sections s
WHERE postStatus=\'Published\'
AND postDateTime<' . $db->pdb(date('Y-m-d H:i:s')) . '
AND p.sectionID=s.sectionID
AND (
concat(" ", postTitle, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", postDescRaw, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
OR concat(" ", postTags, " ") REGEXP ' . $db->pdb('[[:<:]]' . $key . '[[:>:]]') . '
) ';
return $sql;
}
示例13: scheduled_comments_delete_spam
function scheduled_comments_delete_spam($last_run)
{
$API = new PerchAPI(1.0, 'perch_comments');
$Settings = $API->get('Settings');
$days = $Settings->get('perch_comments_max_spam_days')->val();
if (!$days) {
return array('result' => 'OK', 'message' => 'Spam message deletion not configured.');
}
$count = perch_comments_delete_old_spam($days);
if ($count == 1) {
$comments = 'comment';
} else {
$comments = 'comments';
}
return array('result' => 'OK', 'message' => $count . ' old spam ' . $comments . ' deleted.');
}
示例14: populate
/**
*
*/
public function populate($api_key, $list_id, $echo_feedback = false)
{
$MailChimp = new MailChimp($api_key);
if ($echo_feedback) {
$API = new PerchAPI(1.0, 'perch_mailchimp');
$Lang = $API->get('Lang');
}
$opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id));
$result = $MailChimp->call('lists/list', $opts);
if ($result) {
$this->db->execute('TRUNCATE TABLE ' . $this->table);
//store title in data array
$stats_array = array('title' => $result['data'][0]['name'], 'total' => $result['data'][0]['stats']['member_count']);
$list_opts = array('apikey' => $api_key, 'id' => $list_id);
$activity = $MailChimp->call('lists/activity', $list_opts);
PerchUtil::debug($activity);
foreach ($activity as $stat) {
if ($stat['day'] == date('Y-m-d', strtotime('-1 days'))) {
$stats_array['yesterday'] = $stat['subs'] + $stat['other_adds'];
} elseif ($stat['day'] == date('Y-m-d')) {
$stats_array['today'] = $stat['subs'] + $stat['other_adds'];
}
}
//insert stats array
$this->db->insert($this->table, $stats_array);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing statistics for list %s', $list_id);
echo '</li>';
flush();
}
// history table
$sql = 'SELECT * FROM ' . PERCH_DB_PREFIX . 'mailchimp_history WHERE historyDate = ' . $this->db->pdb(date('Y-m-d', strtotime('-1 days'))) . ' LIMIT 1';
if (!($row = $this->db->get_row($sql))) {
//insert a row for yesterday
$history_data = array('historyDate' => date('Y-m-d', strtotime('-1 days')), 'historyTotal' => $stats_array['yesterday']);
$this->db->insert(PERCH_DB_PREFIX . 'mailchimp_history', $history_data);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing history for list %s', $list_id);
echo '</li>';
flush();
}
}
}
return true;
}
示例15: update_perch_mailchimp
function update_perch_mailchimp($last_update)
{
$API = new PerchAPI(1.0, 'perch_mailchimp');
include 'PerchMailchimp_Stats.class.php';
include 'PerchMailchimp_Stat.class.php';
$Settings = $API->get('Settings');
$api_key = $Settings->get('perch_mailchimp_api_key')->settingValue();
$list_id = $Settings->get('perch_mailchimp_list_id')->settingValue();
$Stats = new PerchMailchimp_Stats($API);
if (!$api_key || $api_key == '' || !$list_id || $list_id == '') {
return array('result' => 'FAILED', 'message' => 'API key or list ID not provided in Settings.');
} else {
if ($Stats->populate($api_key, $list_id)) {
return array('result' => 'OK', 'message' => 'List statistics updated.');
} else {
return array('result' => 'WARNING', 'message' => 'Unable to update list statistics.');
}
}
}