当前位置: 首页>>代码示例>>PHP>>正文


PHP SpoonFilter::urlise方法代码示例

本文整理汇总了PHP中SpoonFilter::urlise方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::urlise方法的具体用法?PHP SpoonFilter::urlise怎么用?PHP SpoonFilter::urlise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpoonFilter的用法示例。


在下文中一共展示了SpoonFilter::urlise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($categoryTitle === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
     } else {
         // get the data
         // build array
         $item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
         $item['language'] = BL::getWorkingLanguage();
         $meta['keywords'] = $item['title'];
         $meta['keywords_overwrite'] = 'N';
         $meta['description'] = $item['title'];
         $meta['description_overwrite'] = 'N';
         $meta['title'] = $item['title'];
         $meta['title_overwrite'] = 'N';
         $meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
         // update
         $item['id'] = BackendBlogModel::insertCategory($item, $meta);
         // output
         $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:29,代码来源:AddCategory.php

示例2: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $id = SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     if ($tag === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
     }
     // check if tag exists
     if (BackendTagsModel::existsTag($tag)) {
         $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
     }
     // build array
     $item['id'] = $id;
     $item['tag'] = SpoonFilter::htmlspecialchars($tag);
     $item['url'] = BackendTagsModel::getURL(SpoonFilter::urlise(SpoonFilter::htmlspecialcharsDecode($item['tag'])), $id);
     // update
     BackendTagsModel::update($item);
     // output
     $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:29,代码来源:edit.php

示例3: addUTMParameters

 /**
  * Adds Google UTM GET Parameters to all anchor links in the mailing
  *
  * @return	string
  * @param	string $HTML	The HTML wherin the parameters will be added.
  */
 private function addUTMParameters($HTML)
 {
     // init var
     $matches = array();
     // search for all hrefs
     preg_match_all('/href="(.*)"/isU', $HTML, $matches);
     // reserve searhc vars
     $search = array();
     $replace = array();
     // check if we have matches
     if (!isset($matches[1]) || empty($matches[1])) {
         return $HTML;
     }
     // build the google vars query
     $params['utm_source'] = 'mailmotor';
     $params['utm_medium'] = 'email';
     $params['utm_campaign'] = SpoonFilter::urlise($this->mailing['name']);
     // build google vars query
     $googleQuery = http_build_query($params);
     // loop the matches
     foreach ($matches[1] as $match) {
         // ignore #
         if (strpos($match, '#') > -1) {
             continue;
         }
         // add results to search/replace stack
         $search[] = 'href="' . $match . '"';
         $replace[] = 'href="' . $match . (strpos($match, '?') !== false ? '&' : '?') . $googleQuery . '"';
     }
     // replace the content HTML with the replace values
     return str_replace($search, $replace, $HTML);
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:38,代码来源:save_content.php

示例4: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $isGod = BackendAuthentication::getUser()->isGod();
     // get possible languages
     if ($isGod) {
         $possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
     } else {
         $possibleLanguages = BL::getWorkingLanguages();
     }
     // get parameters
     $language = SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
     $module = SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
     $name = SpoonFilter::getPostValue('name', null, null, 'string');
     $type = SpoonFilter::getPostValue('type', BackendModel::getDB()->getEnumValues('locale', 'type'), null, 'string');
     $application = SpoonFilter::getPostValue('application', array('backend', 'frontend'), null, 'string');
     $value = SpoonFilter::getPostValue('value', null, null, 'string');
     // validate values
     if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'frontend' && $module != 'core') {
         $error = BL::err('InvalidValue');
     }
     // in case this is a 'act' type, there are special rules concerning possible values
     if ($type == 'act' && !isset($error)) {
         if (urlencode($value) != SpoonFilter::urlise($value)) {
             $error = BL::err('InvalidActionValue', $this->getModule());
         }
     }
     // no error?
     if (!isset($error)) {
         // build item
         $item['language'] = $language;
         $item['module'] = $module;
         $item['name'] = $name;
         $item['type'] = $type;
         $item['application'] = $application;
         $item['value'] = $value;
         $item['edited_on'] = BackendModel::getUTCDate();
         $item['user_id'] = BackendAuthentication::getUser()->getUserId();
         // does the translation exist?
         if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
             // add the id to the item
             $item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
             // update in db
             BackendLocaleModel::update($item);
         } else {
             // insert in db
             BackendLocaleModel::insert($item);
         }
         // output OK
         $this->output(self::OK);
     } else {
         $this->output(self::ERROR, null, $error);
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:57,代码来源:save_translation.php

示例5: getUrl

    /**
     * Retrieve the unique url for an item
     *
     * @param string $url
     * @param int[optional] $id
     * @return string
     */
    public static function getUrl($url, $id = null)
    {
        // redefine Url
        $url = \SpoonFilter::urlise((string) $url);
        // get db
        $db = BackendModel::get('database');
        // new item
        if ($id === null) {
            $numberOfItems = (int) $db->getVar('SELECT 1
				 FROM media AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE i.language = ? AND m.url = ?
				 LIMIT 1', array(Language::getWorkingLanguage(), $url));
            // already exists
            if ($numberOfItems != 0) {
                // add number
                $url = BackendModel::addNumber($url);
                // try again
                return self::getUrl($url);
            }
        } else {
            $numberOfItems = (int) $db->getVar('SELECT 1
				 FROM media AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE i.language = ? AND m.url = ? AND i.id != ?
				 LIMIT 1', array(Language::getWorkingLanguage(), $url, $id));
            // already exists
            if ($numberOfItems != 0) {
                // add number
                $url = BackendModel::addNumber($url);
                // try again
                return self::getUrl($url, $id);
            }
        }
        // return the unique Url!
        return $url;
    }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:44,代码来源:Model.php

示例6: getURLForCategory

    /**
     * Retrieve the unique URL for a category
     *
     * @param string $url
     * @param int[optional] $id The id of the category to ignore.
     * @return string
     */
    public static function getURLForCategory($url, $id = null)
    {
        $url = SpoonFilter::urlise((string) $url);
        $db = BackendModel::getDB();
        // new category
        if ($id === null) {
            // get number of categories with this URL
            $number = (int) $db->getVar('SELECT COUNT(i.id)
				 FROM faq_categories AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE i.language = ? AND m.url = ?', array(BL::getWorkingLanguage(), $url));
            // already exists
            if ($number != 0) {
                $url = BackendModel::addNumber($url);
                return self::getURLForCategory($url);
            }
        } else {
            // get number of items with this URL
            $number = (int) $db->getVar('SELECT COUNT(i.id)
				 FROM faq_categories AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE i.language = ? AND m.url = ? AND i.id != ?', array(BL::getWorkingLanguage(), $url, $id));
            // already exists
            if ($number != 0) {
                $url = BackendModel::addNumber($url);
                return self::getURLForCategory($url, $id);
            }
        }
        return $url;
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:37,代码来源:model.php

示例7: processXMLAsPost

 /**
  * Process the XML and treat it as a blogpost
  *
  * @return	bool
  * @param	SimpleXMLElement $xml	The XML to process.
  */
 private function processXMLAsPost(SimpleXMLElement $xml)
 {
     // init var
     $postID = substr((string) $xml->id, mb_strpos((string) $xml->id, 'post-') + 5);
     // validate
     if ($postID == '') {
         return false;
     }
     if ((string) $xml->title == '') {
         return false;
     }
     // build item
     $item['id'] = (int) BackendBlogModel::getMaximumId() + 1;
     $item['user_id'] = BackendAuthentication::getUser()->getUserId();
     $item['hidden'] = 'N';
     $item['allow_comments'] = 'Y';
     $item['num_comments'] = 0;
     $item['status'] = 'active';
     $item['language'] = BL::getWorkingLanguage();
     $item['publish_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->published));
     $item['created_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->published));
     $item['edited_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->updated));
     $item['category_id'] = 1;
     $item['title'] = (string) $xml->title;
     $item['text'] = (string) $xml->content;
     // set drafts hidden
     if (strtotime((string) $xml->published) > time()) {
         $item['hidden'] = 'Y';
         $item['status'] = 'draft';
     }
     // build meta
     $meta = array();
     $meta['keywords'] = $item['title'];
     $meta['keywords_overwrite'] = 'N';
     $meta['description'] = $item['title'];
     $meta['description_overwrite'] = 'N';
     $meta['title'] = $item['title'];
     $meta['title_overwrite'] = 'N';
     $meta['url'] = BackendBlogModel::getURL(SpoonFilter::urlise($item['title']));
     $meta['url_overwrite'] = 'N';
     // replace fucked up links
     $item['text'] = preg_replace('|<a(.*)onblur="(.*)"(.*)>|Ui', '<a$1$3>', $item['text']);
     // fix images
     $item['text'] = preg_replace('|<img(.*)border="(.*)"(.*)>|Ui', '<img$1$3>', $item['text']);
     // remove inline styles
     $item['text'] = preg_replace('|<(.*)style="(.*)"(.*)>|Ui', '<$1$3>', $item['text']);
     // whitespace
     $item['text'] = preg_replace('|\\s{2,}|', ' ', $item['text']);
     // cleanup
     $search = array('<br /><br />', '<div><br /></div>', '<div>', '</div>', '<i>', '</i>', '<b>', '</b>', '<p><object', '</object></p>', '<p><p>', '</p></p>', '...');
     $replace = array('</p><p>', '</p><p>', '', '', '<em>', '</em>', '<strong>', '</strong>', '<object', '</object>', '<p>', '</p>', '…');
     // cleanup
     $item['text'] = '<p>' . str_replace($search, $replace, SpoonFilter::htmlentitiesDecode($item['text'])) . '</p>';
     // get images
     $matches = array();
     preg_match_all('/<img.*src="(.*)".*\\/>/Ui', $item['text'], $matches);
     // any images?
     if (isset($matches[1]) && !empty($matches[1])) {
         // init var
         $imagesPath = FRONTEND_FILES_PATH . '/userfiles/images/blog';
         $imagesURL = FRONTEND_FILES_URL . '/userfiles/images/blog';
         // create dir if needed
         if (!SpoonDirectory::exists($imagesPath)) {
             SpoonDirectory::create($imagesPath);
         }
         // loop matches
         foreach ($matches[1] as $key => $file) {
             // get file info
             $fileInfo = SpoonFile::getInfo($file);
             // init var
             $destinationFile = $item['id'] . '_' . $fileInfo['basename'];
             try {
                 // download
                 SpoonFile::download($file, $imagesPath . '/' . $destinationFile);
                 // replace the old URL with the new one
                 $item['text'] = str_replace($file, $imagesURL . '/' . $destinationFile, $item['text']);
             } catch (Exception $e) {
                 // ignore
             }
         }
     }
     // get links
     $matches = array();
     preg_match_all('/<a.*href="(.*)".*\\/>/Ui', $item['text'], $matches);
     // any images?
     if (isset($matches[1]) && !empty($matches[1])) {
         // loop matches
         foreach ($matches[1] as $key => $file) {
             // get new link
             $replaceWith = self::download($file, $item['id']);
             // should we replace?
             if ($replaceWith !== false) {
                 // replace the old URL with the new one
                 $item['text'] = str_replace($file, $replaceWith, $item['text']);
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:forkcms,代码行数:101,代码来源:import_blogger.php

示例8: getURL

    /**
     * Get a unique URL for a tag
     *
     * @param string $URL The URL to use as a base.
     * @param int[optional] $id The ID to ignore.
     * @return string
     */
    public static function getURL($URL, $id = null)
    {
        $URL = SpoonFilter::urlise((string) $URL);
        $language = BL::getWorkingLanguage();
        // get db
        $db = BackendModel::getDB();
        // no specific id
        if ($id === null) {
            // get number of tags with the specified url
            $number = (int) $db->getVar('SELECT COUNT(i.id)
				 FROM tags AS i
				 WHERE i.url = ? AND i.language = ?', array($URL, $language));
            // there are items so, call this method again.
            if ($number != 0) {
                // add a number
                $URL = BackendModel::addNumber($URL);
                // recall this method, but with a new url
                $URL = self::getURL($URL, $id);
            }
        } else {
            // redefine
            $id = (int) $id;
            // get number of tags with the specified url
            $number = (int) $db->getVar('SELECT COUNT(i.id)
				 FROM tags AS i
				 WHERE i.url = ? AND i.language = ? AND i.id != ?', array($URL, $language, $id));
            // there are items so, call this method again.
            if ($number != 0) {
                // add a number
                $URL = BackendModel::addNumber($URL);
                // recall this method, but with a new url
                $URL = self::getURL($URL, $id);
            }
        }
        return $URL;
    }
开发者ID:richsage,项目名称:forkcms,代码行数:43,代码来源:model.php

示例9: addEmail

 /**
  * Adds an email to the queue.
  *
  * @return	int								The id of the inserted mail.
  * @param	string $subject					The subject for the email.
  * @param	string $template				The template to use.
  * @param	array[optional] $variables		Variables that should be assigned in the email.
  * @param	string[optional] $toEmail		The to-address for the email.
  * @param	string[optional] $toName		The to-name for the email.
  * @param	string[optional] $fromEmail		The from-address for the mail.
  * @param	string[optional] $fromName		The from-name for the mail.
  * @param	string[optional] $replyToEmail	The replyto-address for the mail.
  * @param	string[optional] $replyToName	The replyto-name for the mail.
  * @param	bool[optional] $queue			Should the mail be queued?
  * @param	int[optional] $sendOn			When should the email be send, only used when $queue is true.
  * @param	bool[optional] $isRawHTML		If this is true $template will be handled as raw HTML, so no parsing of $variables is done.
  * @param	string[optional] $plainText		The plain text version.
  * @param	array[optional] $attachments	Paths to attachments to include.
  */
 public static function addEmail($subject, $template, array $variables = null, $toEmail = null, $toName = null, $fromEmail = null, $fromName = null, $replyToEmail = null, $replyToName = null, $queue = false, $sendOn = null, $isRawHTML = false, $plainText = null, array $attachments = null)
 {
     // redefine
     $subject = (string) strip_tags($subject);
     $template = (string) $template;
     // set defaults
     $to = FrontendModel::getModuleSetting('core', 'mailer_to');
     $from = FrontendModel::getModuleSetting('core', 'mailer_from');
     $replyTo = FrontendModel::getModuleSetting('core', 'mailer_reply_to');
     $utm = array('utm_source' => 'mail', 'utm_medium' => 'email', 'utm_campaign' => SpoonFilter::urlise($subject));
     // set recipient/sender headers
     $email['to_email'] = empty($toEmail) ? (string) $to['email'] : $toEmail;
     $email['to_name'] = empty($toName) ? (string) $to['name'] : $toName;
     $email['from_email'] = empty($fromEmail) ? (string) $from['email'] : $fromEmail;
     $email['from_name'] = empty($fromName) ? (string) $from['name'] : $fromName;
     $email['reply_to_email'] = empty($replyToEmail) ? (string) $replyTo['email'] : $replyToEmail;
     $email['reply_to_name'] = empty($replyToName) ? (string) $replyTo['name'] : $replyToName;
     // validate
     if (!empty($email['to_email']) && !SpoonFilter::isEmail($email['to_email'])) {
         throw new FrontendException('Invalid e-mail address for recipient.');
     }
     if (!empty($email['from_email']) && !SpoonFilter::isEmail($email['from_email'])) {
         throw new FrontendException('Invalid e-mail address for sender.');
     }
     if (!empty($email['reply_to_email']) && !SpoonFilter::isEmail($email['reply_to_email'])) {
         throw new FrontendException('Invalid e-mail address for reply-to address.');
     }
     // build array
     $email['subject'] = SpoonFilter::htmlentitiesDecode($subject);
     if ($isRawHTML) {
         $email['html'] = $template;
     } else {
         $email['html'] = self::getTemplateContent($template, $variables);
     }
     if ($plainText !== null) {
         $email['plain_text'] = $plainText;
     }
     $email['created_on'] = FrontendModel::getUTCDate();
     // init var
     $matches = array();
     // get internal links
     preg_match_all('|href="/(.*)"|i', $email['html'], $matches);
     // any links?
     if (!empty($matches[0])) {
         // init vars
         $search = array();
         $replace = array();
         // loop the links
         foreach ($matches[0] as $key => $link) {
             $search[] = $link;
             $replace[] = 'href="' . SITE_URL . '/' . $matches[1][$key] . '"';
         }
         // replace
         $email['html'] = str_replace($search, $replace, $email['html']);
     }
     // init var
     $matches = array();
     // get internal urls
     preg_match_all('|src="/(.*)"|i', $email['html'], $matches);
     // any links?
     if (!empty($matches[0])) {
         // init vars
         $search = array();
         $replace = array();
         // loop the links
         foreach ($matches[0] as $key => $link) {
             $search[] = $link;
             $replace[] = 'src="' . SITE_URL . '/' . $matches[1][$key] . '"';
         }
         // replace
         $email['html'] = str_replace($search, $replace, $email['html']);
     }
     // init var
     $matches = array();
     // match links
     preg_match_all('/href="(http:\\/\\/(.*))"/iU', $email['html'], $matches);
     // any links?
     if (isset($matches[0]) && !empty($matches[0])) {
         // init vars
         $searchLinks = array();
         $replaceLinks = array();
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:forkcms,代码行数:101,代码来源:mailer.php

示例10: insertMeta

 /**
  * Insert meta for an item in the database
  *
  * @param array $data
  *
  * @return int
  */
 public static function insertMeta(array $data)
 {
     //--Replace special characters
     $data["url"] = strtr($data["url"], "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
     $data["url"] = str_replace(".", "", \SpoonFilter::urlise($data["url"]));
     //--Replace the values with utf8
     foreach ($data as &$value) {
         $value = utf8_encode($value);
     }
     $data['url'] = BackendAddressesModel::checkUrl($data['url']);
     return (int) BackendModel::getContainer()->get('database')->insert('meta', $data);
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:19,代码来源:Model.php

示例11: getURLForBrand

    /**
     * Retrieve the unique URL for a category
     *
     * @param string $url
     * @param int [optional] $id The id of the category to ignore.
     * @return string
     */
    public static function getURLForBrand($url, $id = null)
    {
        $url = \SpoonFilter::urlise((string) $url);
        $db = BackendModel::getContainer()->get('database');
        // new category
        if ($id === null) {
            if ((bool) $db->getVar('SELECT 1
				 FROM catalog_brands AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE m.url = ?
				 LIMIT 1', array($url))) {
                $url = BackendModel::addNumber($url);
                return self::getURLForCategory($url);
            }
        } else {
            // current category should be excluded
            if ((bool) $db->getVar('SELECT 1
				 FROM catalog_brands AS i
				 INNER JOIN meta AS m ON i.meta_id = m.id
				 WHERE m.url = ? AND i.id != ?
				 LIMIT 1', array($url, $id))) {
                $url = BackendModel::addNumber($url);
                return self::getURLForCategory($url, $id);
            }
        }
        return $url;
    }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:34,代码来源:Model.php

示例12: parse

 public function parse()
 {
     // more matches to be found than?
     if ($this->pagination['num_items'] > count($this->items)) {
         // remove last result (to add this reference)
         array_pop($this->items);
         // add reference to full search results page
         $this->items[] = array('title' => FL::lbl('More'), 'text' => FL::msg('MoreResults'), 'full_url' => FrontendNavigation::getURLForBlock('search') . '?form=search&q=' . $this->term);
     }
     // format data
     foreach ($this->items as &$item) {
         // full url is set?
         if (!isset($item['full_url'])) {
             continue;
         }
         // build utm array
         $utm['utm_source'] = SpoonFilter::urlise(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE));
         $utm['utm_medium'] = 'fork-search';
         $utm['utm_term'] = $this->term;
         // get parameters in url already
         if (strpos($item['full_url'], '?') !== false) {
             $glue = '&';
         } else {
             $glue = '?';
         }
         // add utm to url
         $item['full_url'] .= $glue . http_build_query($utm, '', '&');
         // format description
         $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, SPOON_CHARSET) . '…' : $item['text'] : '';
     }
     // output
     $this->output(self::OK, $this->items);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:33,代码来源:autosuggest.php

示例13: getURLForCategory

    /**
     * Retrieve the unique URL for a category
     *
     * @return	string
     * @param	string $URL			The string wheron the URL will be based.
     * @param	int[optional] $id	The id of the category to ignore.
     */
    public static function getURLForCategory($URL, $id = null)
    {
        // redefine URL
        $URL = SpoonFilter::urlise((string) $URL);
        // get db
        $db = BackendModel::getDB();
        // new category
        if ($id === null) {
            // get number of categories with this URL
            $number = (int) $db->getVar('SELECT COUNT(i.id)
											FROM blog_categories AS i
											INNER JOIN meta AS m ON i.meta_id = m.id
											WHERE i.language = ? AND m.url = ?', array(BL::getWorkingLanguage(), $URL));
            // already exists
            if ($number != 0) {
                // add number
                $URL = BackendModel::addNumber($URL);
                // try again
                return self::getURLForCategory($URL);
            }
        } else {
            // get number of items with this URL
            $number = (int) $db->getVar('SELECT COUNT(i.id)
											FROM blog_categories AS i
											INNER JOIN meta AS m ON i.meta_id = m.id
											WHERE i.language = ? AND m.url = ? AND i.id != ?', array(BL::getWorkingLanguage(), $URL, $id));
            // already exists
            if ($number != 0) {
                // add number
                $URL = BackendModel::addNumber($URL);
                // try again
                return self::getURLForCategory($URL, $id);
            }
        }
        // return the unique URL!
        return $URL;
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:44,代码来源:model.php

示例14: validateForm

 /**
  * Validate the form.
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtDisplayName = $this->frm->getField('display_name');
         $txtFirstName = $this->frm->getField('first_name');
         $txtLastName = $this->frm->getField('last_name');
         $txtCity = $this->frm->getField('city');
         $ddmCountry = $this->frm->getField('country');
         $ddmGender = $this->frm->getField('gender');
         $ddmDay = $this->frm->getField('day');
         $ddmMonth = $this->frm->getField('month');
         $ddmYear = $this->frm->getField('year');
         // get number of display name changes
         $nameChanges = (int) FrontendProfilesModel::getSetting($this->profile->getId(), 'display_name_changes');
         // has there been a valid display name change request?
         if ($this->profile->getDisplayName() !== $txtDisplayName->getValue() && $nameChanges <= FrontendProfilesModel::MAX_DISPLAY_NAME_CHANGES) {
             // display name filled in?
             if ($txtDisplayName->isFilled(FL::getError('FieldIsRequired'))) {
                 // display name exists?
                 if (FrontendProfilesModel::existsDisplayName($txtDisplayName->getValue(), $this->profile->getId())) {
                     // set error
                     $txtDisplayName->addError(FL::getError('DisplayNameExists'));
                 }
             }
         }
         // birthdate is not required but if one is filled we need all
         if ($ddmMonth->isFilled() || $ddmDay->isFilled() || $ddmYear->isFilled()) {
             // valid birth date?
             if (!checkdate($ddmMonth->getValue(), $ddmDay->getValue(), $ddmYear->getValue())) {
                 // set error
                 $ddmYear->addError(FL::getError('DateIsInvalid'));
             }
         }
         // validate avatar when given
         $this->frm->getField('avatar')->isFilled();
         // no errors
         if ($this->frm->isCorrect()) {
             // init
             $values = array();
             $settings = array();
             // has there been a valid display name change request?
             if ($this->profile->getDisplayName() !== $txtDisplayName->getValue() && $nameChanges <= FrontendProfilesModel::MAX_DISPLAY_NAME_CHANGES) {
                 // get display name value
                 $values['display_name'] = $txtDisplayName->getValue();
                 // update url based on the new display name
                 $values['url'] = FrontendProfilesModel::getUrl($txtDisplayName->getValue(), $this->profile->getId());
                 // update display name count
                 $settings['display_name_changes'] = $nameChanges + 1;
             }
             // update values
             if (!empty($values)) {
                 FrontendProfilesModel::update($this->profile->getId(), $values);
             }
             // build settings
             $settings['first_name'] = $txtFirstName->getValue();
             $settings['last_name'] = $txtLastName->getValue();
             $settings['city'] = $txtCity->getValue();
             $settings['country'] = $ddmCountry->getValue();
             $settings['gender'] = $ddmGender->getValue();
             // birthday is filled in
             if ($ddmYear->isFilled()) {
                 // mysql format
                 $settings['birth_date'] = $ddmYear->getValue() . '-';
                 $settings['birth_date'] .= str_pad($ddmMonth->getValue(), 2, '0', STR_PAD_LEFT) . '-';
                 $settings['birth_date'] .= str_pad($ddmDay->getValue(), 2, '0', STR_PAD_LEFT);
             } else {
                 // not filled in
                 $settings['birth_date'] = null;
             }
             // avatar
             $settings['avatar'] = $this->profile->getSetting('avatar');
             // create new filename
             if ($this->frm->getField('avatar')->isFilled()) {
                 // field value
                 $settings['avatar'] = \SpoonFilter::urlise($this->profile->getDisplayName()) . '.' . $this->frm->getField('avatar')->getExtension();
                 // move the file
                 $this->frm->getField('avatar')->generateThumbnails(FRONTEND_FILES_PATH . '/Profiles/Avatars/', $settings['avatar']);
             }
             // save settings
             $this->profile->setSettings($settings);
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_saved_settings', array('id' => $this->profile->getId()));
             // redirect
             $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('Profiles', 'Settings') . '?sent=true');
         } else {
             $this->tpl->assign('updateSettingsHasFormError', true);
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:94,代码来源:Settings.php

示例15: __construct

 /**
  * Default constructor.
  *
  * @param string $title The title for the item.
  * @param string $link The link for the item.
  * @param string $description The content for the item.
  */
 public function __construct($title, $link, $description)
 {
     // set UTM-campaign
     $this->utm['utm_campaign'] = SpoonFilter::urlise($title);
     // convert to plain text
     $description = FrontendModel::convertToPlainText($description);
     // set title
     $this->setSummary($title);
     // set url
     $this->setUrl(FrontendModel::addURLParameters($link, $this->utm));
     // set description
     $this->setDescription($this->processLinks($description));
     // set identifier
     $this->setUniqueIdentifier(md5($link));
     // build properties
     $properties['X-GOOGLE-CALENDAR-CONTENT-TITLE'] = $title;
     $properties['X-GOOGLE-CALENDAR-CONTENT-ICON'] = SITE_URL . '/favicon.ico';
     $properties['X-GOOGLE-CALENDAR-CONTENT-URL'] = $this->getUrl();
     // set properties
     $this->setXProperties($properties);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:28,代码来源:ical.php


注:本文中的SpoonFilter::urlise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。