本文整理汇总了PHP中PerchUtil::urlify方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::urlify方法的具体用法?PHP PerchUtil::urlify怎么用?PHP PerchUtil::urlify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::urlify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
}
}
示例2: update
public function update($data)
{
$PerchEvents_Events = new PerchEvents_Events();
if (isset($data['eventDescRaw'])) {
$data['eventDescHTML'] = $PerchEvents_Events->text_to_html($data['eventDescRaw']);
} else {
$data['eventDescHTML'] = false;
}
if (isset($data['eventTitle'])) {
$data['eventSlug'] = PerchUtil::urlify(date('Y m d', strtotime($data['eventDateTime'])) . ' ' . $data['eventTitle']);
}
if (isset($data['cat_ids'])) {
$catIDs = $data['cat_ids'];
unset($data['cat_ids']);
} else {
$catIDs = false;
}
// Update the event itself
parent::update($data);
// Delete existing categories
$this->db->delete(PERCH_DB_PREFIX . 'events_to_categories', $this->pk, $this->id());
// Add new categories
if (is_array($catIDs)) {
for ($i = 0; $i < sizeOf($catIDs); $i++) {
$tmp = array();
$tmp['eventID'] = $this->id();
$tmp['categoryID'] = $catIDs[$i];
$this->db->insert(PERCH_DB_PREFIX . 'events_to_categories', $tmp);
}
}
return true;
}
示例3: parse_string
/**
* Parse a string of entered tags (e.g. "this, that, the other") into an array of tags
* @param [type] $str [description]
* @return [type] [description]
*/
public function parse_string($str)
{
$tags = explode(',', $str);
$out = array();
if (PerchUtil::count($tags)) {
foreach ($tags as $tag) {
$out[] = array('tag' => PerchUtil::urlify(trim($tag)), 'tagDisplay' => trim($tag));
}
}
return $out;
}
示例4: parse_string_to_ids
public function parse_string_to_ids($tag_string)
{
$tags = $this->_tag_parse($tag_string);
PerchUtil::debug($tags);
$ids = array();
if (PerchUtil::count($tags)) {
foreach ($tags as $tag) {
$Tag = $this->find_or_create(PerchUtil::urlify($tag), $tag);
if ($Tag) {
$ids[] = $Tag->id();
}
}
}
return $ids;
}
示例5: find_or_create
/**
* Find an author based on their email address. If not found, create a new one.
* @param Object $User Instance of a user object - usually CurrentUser.
* @return Object Instance of an author object
*/
public function find_or_create($User)
{
$sql = 'SELECT * FROM ' . $this->table . ' WHERE authorEmail=' . $this->db->pdb($User->userEmail()) . ' LIMIT 1';
$row = $this->db->get_row($sql);
if (PerchUtil::count($row)) {
return $this->return_instance($row);
}
// Author wasn't found, so create a new one and return it. (It? Him or her.)
$data = array();
$data['authorEmail'] = $User->userEmail();
$data['authorGivenName'] = $User->userGivenName();
$data['authorFamilyName'] = $User->userFamilyName();
$data['authorSlug'] = PerchUtil::urlify($data['authorGivenName'] . ' ' . $data['authorFamilyName']);
$Author = $this->create($data);
return $Author;
}
示例6: array
$campaign_id = $_POST['data']['id'];
if ($status == 'sent') {
$log = array('logEvent' => 'Campaign sent: ' . $campaign_id, 'logDate' => date('Y-m-d H:i:s'));
$api_key = $Settings->get('perch_mailchimp_api_key')->settingValue();
$list_id = $Settings->get('perch_mailchimp_list_id')->settingValue();
$MailChimp = new MailChimp($api_key);
$opts = array('apikey' => $api_key, 'filters' => array('campaign_id' => $campaign_id));
$new_campaign = $MailChimp->call('campaigns/list', $opts);
if ($new_campaign) {
//get the content
$content_opts = array('apikey' => $api_key, 'cid' => $campaign_id);
$content = $MailChimp->call('campaigns/content', $content_opts);
if (isset($content['html'])) {
$campaignHTML = $content['html'];
}
if (isset($content['text'])) {
$campaignText = $content['text'];
}
$campaign = array('campaignCID' => $campaign_id, 'campaignWebID' => $new_campaign['data'][0]['web_id'], 'campaignTitle' => $new_campaign['data'][0]['title'], 'campaignCreateTime' => $new_campaign['data'][0]['create_time'], 'campaignSendTime' => $new_campaign['data'][0]['send_time'], 'campaignSent' => $new_campaign['data'][0]['emails_sent'], 'campaignSubject' => $new_campaign['data'][0]['subject'], 'campaignArchiveURL' => $new_campaign['data'][0]['archive_url'], 'campaignHTML' => $campaignHTML, 'campaignText' => $campaignText, 'campaignSlug' => PerchUtil::urlify(date('d M Y', strtotime($new_campaign['data'][0]['create_time'])) . ' ' . $new_campaign['data'][0]['subject']));
//insert into our table
if ($db->insert(PERCH_DB_PREFIX . 'mailchimp_campaigns', $campaign)) {
$log['logType'] = 'success';
} else {
$log['logType'] = 'failure';
}
//add to log
$db->insert(PERCH_DB_PREFIX . 'mailchimp_log', $log);
}
}
}
}
示例7: register_with_form
public function register_with_form($SubmittedForm)
{
$key = $SubmittedForm->id . (isset($SubmittedForm->form_attributes['type']) ? '.' . $SubmittedForm->form_attributes['type'] : '');
$Forms = new PerchMembers_Forms($this->api);
$Form = $Forms->find_or_create($key);
$do_login = false;
if (is_object($Form)) {
$form_settings = PerchUtil::json_safe_decode($Form->formSettings(), true);
$member = array('memberAuthType' => 'native', 'memberEmail' => '', 'memberPassword' => '', 'memberStatus' => 'pending', 'memberCreated' => date('Y-m-d H:i:s'));
$data = $SubmittedForm->data;
$properties = array();
foreach ($data as $key => $val) {
if (array_key_exists($key, $this->field_aliases)) {
$member[$this->field_aliases[$key]] = $val;
$key = $this->field_aliases[$key];
}
if (!in_array($key, $this->static_fields)) {
$properties[$key] = $val;
}
}
$member['memberProperties'] = PerchUtil::json_safe_encode($properties);
// Password
$clear_pwd = $member['memberPassword'];
if (defined('PERCH_NONPORTABLE_HASHES') && PERCH_NONPORTABLE_HASHES) {
$portable_hashes = false;
} else {
$portable_hashes = true;
}
$Hasher = new PasswordHash(8, $portable_hashes);
$member['memberPassword'] = $Hasher->HashPassword($clear_pwd);
$Member = $this->create($member);
$member = array('memberAuthID' => $Member->memberID());
if (isset($form_settings['moderate']) && $form_settings['moderate'] == '1') {
if (isset($form_settings['moderator_email'])) {
$this->_email_moderator($form_settings['moderator_email'], $Member);
}
} else {
$member['memberStatus'] = 'active';
$do_login = true;
}
$Member->update($member);
if (isset($form_settings['default_tags']) && $form_settings['default_tags'] != '') {
$tags = explode(',', $form_settings['default_tags']);
if (PerchUtil::count($tags)) {
foreach ($tags as $tagDisplay) {
$expiry = false;
if (strpos($tagDisplay, '|') > 0) {
$parts = explode('|', $tagDisplay);
$tagDisplay = $parts[0];
$expiry = $parts[1];
}
$tagDisplay = trim($tagDisplay);
$tag = PerchUtil::urlify($tagDisplay);
$Member->add_tag($tag, $tagDisplay, $expiry);
}
}
}
if (is_object($Member) && $do_login) {
$key = base64_encode('login:perch_members:login/login_form.html');
$data = array('email' => $Member->memberEmail(), 'password' => $clear_pwd, 'pos');
$files = array();
$Perch = Perch::fetch();
$Perch->dispatch_form($key, $data, $files);
}
if (is_object($Member) && $clear_pwd === '__auto__') {
$Member->update(array('memberPassword' => null));
}
}
}
示例8: map_fields
private function map_fields($campaign)
{
return ['campaignMailChimpID' => $campaign['id'], 'campaignSendTime' => $campaign['send_time'] ? date('Y-m-d H:i:s', strtotime($campaign['send_time'])) : null, 'campaignArchiveURL' => $campaign['archive_url'], 'campaignStatus' => $campaign['status'], 'campaignEmailsSent' => $campaign['emails_sent'], 'campaignSubject' => $campaign['settings']['subject_line'], 'campaignTitle' => $campaign['settings']['title'] ? $campaign['settings']['title'] : $campaign['settings']['subject_line'], 'campaignSlug' => PerchUtil::urlify($campaign['settings']['subject_line']), 'campaignCreated' => $campaign['create_time'] ? date('Y-m-d H:i:s', strtotime($campaign['create_time'])) : null];
}
示例9: create
/**
* overwriting create to add URL slug creation.
* @see PerchFactory::create()
* @param array $data
* @return album object
*/
public function create($data)
{
if (isset($data['imageAlt'])) {
$data['imageSlug'] = PerchUtil::urlify($data['imageAlt']);
$data['imageSlug'] = $this->check_slug_unique($data['imageSlug']);
}
if (!isset($data['imageOrder']) && isset($data['albumID'])) {
$sql = 'SELECT COUNT(*) FROM ' . $this->table . ' WHERE albumID=' . $this->db->pdb($data['albumID']);
$count = $this->db->get_value($sql);
$data['imageOrder'] = $count + 1;
}
if ($imageID = $this->db->insert($this->table, $data)) {
return $this->find($imageID);
}
return false;
}
示例10: array
$Form->handle_empty_block_generation($Template);
$tags = $Template->find_all_tags_and_repeaters();
$Form->require_field('sectionTitle', 'Required');
$Form->set_required_fields_from_template($Template, $details);
if ($Form->submitted()) {
$postvars = array('sectionTitle');
$data = $Form->receive($postvars);
$data['blogID'] = $Blog->id();
$prev = false;
if (isset($details['sectionDynamicFields'])) {
$prev = PerchUtil::json_safe_decode($details['sectionDynamicFields'], true);
}
$dynamic_fields = $Form->receive_from_template_fields($Template, $prev, $Sections, $Section);
$data['sectionDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields);
if (!is_object($Section)) {
$data['sectionSlug'] = PerchUtil::urlify($data['sectionTitle']);
$Section = $Sections->create($data);
PerchUtil::redirect($API->app_path() . '/sections/edit/?id=' . $Section->id() . '&created=1');
}
$Section->update($data);
if (is_object($Section)) {
$message = $HTML->success_message('Your section has been successfully edited. Return to %ssection listing%s', '<a href="' . $API->app_path() . '/sections">', '</a>');
} else {
$message = $HTML->failure_message('Sorry, that section could not be edited.');
}
// clear the caches
PerchBlog_Cache::expire_all();
$details = $Section->to_array();
}
if (isset($_GET['created']) && !$message) {
$message = $HTML->success_message('Your section has been successfully created. Return to %ssection listing%s', '<a href="' . $API->app_path() . '/sections">', '</a>');
示例11: create
/**
* takes the event data and inserts it as a new row in the database.
*/
public function create($data)
{
if (isset($data['eventDescRaw'])) {
$data['eventDescHTML'] = $this->text_to_html($data['eventDescRaw']);
} else {
$data['eventDescHTML'] = false;
}
if (isset($data['eventTitle'])) {
$data['eventSlug'] = PerchUtil::urlify(date('Y m d', strtotime($data['eventDateTime'])) . ' ' . $data['eventTitle']);
}
if (isset($data['cat_ids']) && is_array($data['cat_ids'])) {
$cat_ids = $data['cat_ids'];
} else {
$cat_ids = false;
}
unset($data['cat_ids']);
$eventID = $this->db->insert($this->table, $data);
if ($eventID) {
if (is_array($cat_ids)) {
for ($i = 0; $i < sizeOf($cat_ids); $i++) {
$tmp = array();
$tmp['eventID'] = $eventID;
$tmp['categoryID'] = $cat_ids[$i];
$this->db->insert(PERCH_DB_PREFIX . 'events_to_categories', $tmp);
}
}
return $this->find($eventID);
}
return false;
}
示例12: PerchForm
} else {
$groupID = false;
$NavGroup = false;
}
$Form = new PerchForm('editpage');
$req = array();
$req['groupTitle'] = "Required";
$Form->set_required($req);
if ($Form->posted() && $Form->validate()) {
$postvars = array('groupTitle');
$data = $Form->receive($postvars);
if (is_object($NavGroup)) {
$NavGroup->update($data);
$Alert->set('success', PerchLang::get('Your navigation group has been successfully updated.'));
} else {
$data['groupSlug'] = PerchUtil::urlify($data['groupTitle']);
$NavGroup = $NavGroups->create($data);
if (is_object($NavGroup)) {
PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/navigation/edit/?id=' . $NavGroup->id() . '&created=1');
} else {
$Alert->set('failure', PerchLang::get('There was a problem creating the navigation group.'));
}
}
}
if (isset($_GET['created'])) {
$Alert->set('success', PerchLang::get('Your navigation group has been successfully created.'));
}
if (is_object($NavGroup)) {
$details = $NavGroup->to_array();
} else {
$details = array();
示例13: check_title_exists
public static function check_title_exists($listingTitle, $listingID = false)
{
$API = new PerchAPI(1.0, 'listing');
$db = $API->get('DB');
$sql = 'SELECT COUNT(*) FROM ' . PERCH_DB_PREFIX . 'listings WHERE listingSlug=' . $db->pdb(PerchUtil::urlify($listingTitle)) . ' AND listingID!=' . $db->pdb($listingID);
$count = $db->get_count($sql);
PerchUtil::debug($sql);
if ($count) {
return false;
}
return true;
}
示例14: get_raw
public function get_raw($post = false, $Item = false)
{
$value = false;
if ($post === false) {
$post = $_POST;
}
$id = $this->Tag->id();
if (isset($post[$id])) {
$this->raw_item = trim(PerchUtil::safe_stripslashes($post[$id]));
$value = $this->raw_item;
}
// Indelible?
if ($this->Tag->indelible()) {
// if it's indelible, just return the previous value.
$prev_value = false;
if (is_object($Item)) {
$json = PerchUtil::json_safe_decode($Item->itemJSON(), true);
if (PerchUtil::count($json) && isset($json[$this->Tag->id()])) {
$prev_value = $json[$this->Tag->id()];
}
} elseif (is_array($Item)) {
$json = $Item;
if (PerchUtil::count($json) && isset($json[$this->Tag->id()])) {
$prev_value = $json[$this->Tag->id()];
}
}
if ($prev_value) {
return $prev_value;
}
}
// Editable + value?
if ($this->Tag->editable() && $value) {
// return the user's value
return $value;
}
if ($this->Tag->for()) {
$parts = $this->break_for_string($this->Tag->for());
if (PerchUtil::count($parts)) {
$str = array();
foreach ($parts as $part) {
if (isset($post[$part])) {
$str[] = trim(PerchUtil::safe_stripslashes($post[$part]));
}
}
return PerchUtil::urlify(implode(' ', $str));
}
if (isset($post[$this->Tag->for()])) {
return PerchUtil::urlify(trim(PerchUtil::safe_stripslashes($post[$this->Tag->for()])));
}
}
return '';
}
示例15: filter_input
<?php
include '../runtime/runtime.php';
$s = filter_input(INPUT_GET, 's', FILTER_SANITIZE_STRING);
if ($s) {
echo PerchUtil::urlify($s);
}