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


PHP Feed::save方法代码示例

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


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

示例1: actionCreate

 public function actionCreate($location = null)
 {
     $project = new Project();
     $project->location_id = $location;
     $project->created_by_user_id = Yii::app()->user->id;
     $project->champs = array($project->created_by_user_id);
     if (!isset($_POST['Project'])) {
         $this->render('create', array('model' => $project));
         Yii::app()->end();
     }
     $project->attributes = $_POST['Project'];
     $project->slug = slugify($project->name);
     if (isset($_POST['ajax'])) {
         echo CActiveForm::validate($project, null, false);
         Yii::app()->end();
     }
     if (!$project->validate()) {
         $this->render('create', array('model' => $project));
         Yii::app()->end();
     }
     $feed = new Feed();
     $feed->followers = array($project->created_by_user_id);
     $feed->save();
     $project->feed_id = $feed->id;
     if (!$project->save()) {
         Yii::log('Project::save() failed. $errors = ' . print_r($project->getErrors(), true), 'error', 'app.project.create');
         $form->addError('save', 'Failed save the new project.');
         $this->render('create', array('model' => $project));
         $feed->delete();
         Yii::app()->end();
     }
     $this->renderText('window.parent.location = "' . $this->createUrl('view', array('id' => $project->id)) . '";');
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:33,代码来源:ProjectController.php

示例2: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aSite !== null) {
             if ($this->aSite->isModified() || $this->aSite->isNew()) {
                 $affectedRows += $this->aSite->save($con);
             }
             $this->setSite($this->aSite);
         }
         if ($this->aFeed !== null) {
             if ($this->aFeed->isModified() || $this->aFeed->isNew()) {
                 $affectedRows += $this->aFeed->save($con);
             }
             $this->setFeed($this->aFeed);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = SitefeedPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = SitefeedPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += SitefeedPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:BasMatthee,项目名称:symfony-profile,代码行数:57,代码来源:BaseSitefeed.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Location();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Location'])) {
         $model->attributes = $_POST['Location'];
         if (null === $model->slug || '' === $model->slug) {
             $model->slug = slugify($model->name);
         }
         $feed = new Feed();
         $feed->save();
         $model->feed_id = $feed->id;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:23,代码来源:LocationController.php

示例4: read

 function read($url)
 {
     $feed = new Feed();
     //gets xml from url
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $raw = curl_exec($ch);
     $feed->feed_url($url);
     $feed->time_to_live(500);
     //$feed->save();
     $xml = new SimpleXMLElement($raw);
     $items = array();
     foreach ($xml->channel->item as $xml_item) {
         //var_dump($xml_item);
         $item = new Item();
         $item->title((string) $xml_item->title);
         $item->body((string) $xml_item->description);
         //var_dump($item);
         $items[] = $item;
     }
     $feed->items($items);
     $feed->save();
 }
开发者ID:nitewol,项目名称:reader,代码行数:23,代码来源:feedreader.php

示例5: postTakecreate

 /**
  * create new feed
  * @return redir
  */
 public function postTakecreate()
 {
     User::onlyHas('feed-create');
     $general = Input::get('general');
     $feed = new Feed();
     $feed->name = $general['name'];
     $feed->enabled = isset($general['enabled']) ? 1 : 0;
     $feed->limit_type = $general['limit_type'];
     $feed->limit_value = $general['limit_value'];
     $feed->order_type = $general['order_type'];
     $feed->order_by = $general['order_by'];
     $feed->save();
     $fields = Input::get('fields');
     if (is_array($fields)) {
         foreach ($fields as $field) {
             $frel = new FeedRel();
             $frel->feed_id = $feed->id;
             $frel->feed_field_id = $field;
             $frel->save();
         }
     }
     Log::info("Create new feed '{$general['name']}'");
     return Redirect::to('feed/edit/' . $feed->id);
 }
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:28,代码来源:FeedController.php

示例6: save

 public function save()
 {
     $this->type = 'document';
     parent::save();
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:5,代码来源:document.php

示例7: import

 public static function import($strXml, $blnOverwrite = false, $blnKeepSettings = false)
 {
     global $objLiveAdmin, $intDefaultLanguage, $_CONF;
     $objReturn = NULL;
     $objSettings = NULL;
     $blnZip = false;
     //*** Init DOM object.
     $objDoc = new DOMDocument("1.0", "UTF-8");
     $objDoc->formatOutput = false;
     $objDoc->preserveWhiteSpace = true;
     if (is_file($strXml)) {
         $objZip = new dUnzip2($strXml);
         if (is_object($objZip)) {
             //*** Zip file.
             $strXml = $objZip->unzip('data.xml');
             if ($strXml !== false) {
                 //*** Fix a unicode bug. Replace forbidden characters (The first 8).
                 for ($intCount = 1; $intCount < 9; $intCount++) {
                     $strHex = str_pad(dechex($intCount), 4, "0", STR_PAD_LEFT);
                     $strXml = preg_replace('/\\x{' . $strHex . '}/u', "", $strXml);
                 }
                 $strXml = preg_replace('/\\x{001f}/u', "", $strXml);
                 $objDoc->loadXML($strXml);
                 $blnZip = true;
             }
         } else {
             //*** XML file.
             $objDoc->load($strXml);
         }
     } else {
         $objDoc->loadXML($strXml);
     }
     //*** Build data structure.
     foreach ($objDoc->childNodes as $rootNode) {
         if ($rootNode->nodeName == "Punch") {
             //*** Valid Punch XML.
             foreach ($rootNode->childNodes as $accountNode) {
                 if ($accountNode->nodeName == "account") {
                     //*** Account node.
                     if ($blnOverwrite) {
                         $objAccount = Account::getByPunchId($accountNode->getAttribute("punchId"));
                         if (is_object($objAccount) && $blnKeepSettings) {
                             //*** Save settings.
                             $objSettings = Settings::getByAccount($objAccount->getId());
                         }
                         //*** Remove account.
                         if (is_object($objAccount)) {
                             $objAccount->delete();
                         }
                     }
                     //*** Create account.
                     $objAccount = new Account();
                     $objAccount->setPunchId($accountNode->getAttribute("punchId"));
                     $objAccount->setName($accountNode->getAttribute("name"));
                     $objAccount->setUri($accountNode->getAttribute("uri"));
                     $objAccount->setTimeZoneId(42);
                     $objAccount->save();
                     //*** Create temporary account object.
                     $_CONF['app']['account'] = $objAccount;
                     foreach ($accountNode->childNodes as $childNode) {
                         $arrUserIds = array();
                         $arrGroupIds = array();
                         switch ($childNode->nodeName) {
                             case "acl":
                                 self::importAcl($childNode, $objAccount->getId(), $arrUserIds, $arrGroupIds);
                                 break;
                             case "products":
                                 //*** Add products to the account.
                                 foreach ($childNode->childNodes as $productNode) {
                                     switch ($productNode->nodeName) {
                                         case "pcms":
                                             //*** Add PunchCMS product to the account.
                                             $objAccountProduct = new AccountProduct();
                                             $objAccountProduct->setAccountId($objAccount->getId());
                                             $objAccountProduct->setProductId(PRODUCT_PCMS);
                                             $objAccountProduct->setExpires($productNode->getAttribute("expires"));
                                             $objAccountProduct->save();
                                             $arrStorageIds[0] = 0;
                                             $arrFeedIds[0] = 0;
                                             //*** Add PunchCMS data to the account.
                                             foreach ($productNode->childNodes as $pcmsNode) {
                                                 switch ($pcmsNode->nodeName) {
                                                     case "settings":
                                                         //*** Add settings to the account.
                                                         if ($blnKeepSettings && is_object($objSettings)) {
                                                             foreach ($objSettings as $objSetting) {
                                                                 $objSetting->setId(0);
                                                                 $objSetting->setAccountId($objAccount->getId());
                                                                 $objSetting->save();
                                                             }
                                                         } else {
                                                             foreach ($pcmsNode->childNodes as $settingNode) {
                                                                 $objSettingTemplate = SettingTemplate::selectByName($settingNode->getAttribute("name"));
                                                                 if (is_object($objSettingTemplate)) {
                                                                     $objSetting = new Setting();
                                                                     $objSetting->setAccountId($objAccount->getId());
                                                                     $objSetting->setSettingId($objSettingTemplate->getId());
                                                                     $objSetting->setValue($settingNode->getAttribute("value"));
                                                                     $objSetting->save();
                                                                 }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:class.impex.php

示例8: actionComment

 public function actionComment()
 {
     $comment = new LessonComment();
     if (isset($_POST['LessonComment'])) {
         $comment->attributes = $_POST['LessonComment'];
         $comment->userId = Yii::app()->user->id;
         $comment->addTime = time();
         if ($comment->save()) {
             $comment = LessonComment::model()->findByPk($comment->getPrimaryKey());
             if ($comment->referid) {
                 $notice = new Notice();
                 $notice->type = 'lesson_recomment';
                 $notice->setData(array('commentId' => $comment->commentId));
                 $notice->userId = $comment->refer->userId;
                 $result = $notice->save();
             }
             $commentDataProvider = new CArrayDataProvider($comment->lesson->comments, array('keyField' => 'commentId', 'pagination' => array('pageSize' => 20)));
             $feed = new Feed();
             $feed->type = 'lesson_comment';
             $feed->setData(array('commentId' => $comment->getPrimaryKey()));
             $feed->save();
             $feed->dispatch(array('user' => array('userId' => $comment->userId), 'course' => array('courseId' => $comment->lesson->courseId)));
             $this->renderPartial('_comment', array('commentDataProvider' => $commentDataProvider));
         }
     }
     //		$this->redirect(array('view','id'=>$comment->lessonid));
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:27,代码来源:NoteController.php

示例9: exit

     break;
 case 'addFeed':
     if ($myUser == false) {
         exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
     }
     require_once "SimplePie.class.php";
     if (!isset($_['newUrl'])) {
         break;
     }
     $newFeed = new Feed();
     $newFeed->setUrl(Functions::clean_url($_['newUrl']));
     if ($newFeed->notRegistered()) {
         ///@TODO: avertir l'utilisateur du doublon non ajouté
         $newFeed->getInfos();
         $newFeed->setFolder(isset($_['newUrlCategory']) ? $_['newUrlCategory'] : 1);
         $newFeed->save();
         $enableCache = $configurationManager->get('synchronisationEnableCache') == '' ? 0 : $configurationManager->get('synchronisationEnableCache');
         $forceFeed = $configurationManager->get('synchronisationForceFeed') == '' ? 0 : $configurationManager->get('synchronisationForceFeed');
         $newFeed->parse(time(), $_, $enableCache, $forceFeed);
         Plugin::callHook("action_after_addFeed", array(&$newFeed));
     }
     header('location: ./settings.php#manageBloc');
     break;
 case 'changeFeedFolder':
     if ($myUser == false) {
         exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
     }
     if (isset($_['feed'])) {
         $feedManager->change(array('folder' => $_['folder']), array('id' => $_['feed']));
     }
     header('location: ./settings.php');
开发者ID:Chouchen,项目名称:Leed,代码行数:31,代码来源:action.php

示例10: subscribeFeed

 public function subscribeFeed($feedlink, $options = array())
 {
     if ($this->countSubscriptions() >= SUBSCRUBE_LIMIT) {
         $msg = sprintf('SUBSCRIBE LIMIT: %s(%s) %s', $this->data['Member']['username'], $this->id, $feedlink);
         CakeLog::write(LOG_WARNING, $msg);
         return false;
     }
     $Feed = new Feed();
     $feed = $Feed->findByFeedlink($feedlink);
     if ($feed) {
         // subscribed..
         $Feed->set($feed);
     } elseif (isset($options['quick'])) {
         $data = array('feedlink' => $feedlink, 'link' => $feedlink, 'title' => $options['title'], 'description' => '');
         $Feed->set($data);
         $Feed->save();
         $Feed->createCrawlStatus();
     } else {
         $feeddata = FeedUtils::getFeed($feedlink);
         if (!$feeddata) {
             return false;
         }
         $data = array('subscribers_count' => 0, 'feedlink' => $feedlink, 'link' => $feeddata->get_permalink() ? $feeddata->get_permalink() : '', 'title' => $feeddata->get_title() ? $feeddata->get_title() : '');
         $Feed->set($data);
         $Feed->save();
         $Feed->createCrawlStatus();
     }
     unset($options['quick']);
     unset($options['title']);
     $conditions = array();
     $conditions[] = es('Subscription.member_id = %s', $this->id);
     $conditions[] = es('Subscription.feed_id = %s', $Feed->id);
     $sub = $this->Subscription->find($conditions);
     if ($sub) {
         return $sub;
     }
     $data = array('member_id' => $this->id, 'feed_id' => $Feed->id, 'has_unread' => true);
     $data = array_merge($data, $options);
     $this->Subscription->create($data);
     return $this->Subscription->save();
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:41,代码来源:member.php

示例11: checkHttpsCapability

 /**
  * Check HTTPS capability
  * @param Feed feed
  */
 public function checkHttpsCapability(Feed $feed)
 {
     $this->verbose('Checking HTTPS capability: ' . $feed->url);
     $url = preg_replace("/^http:/", "https:", $feed->url);
     $request = $this->makeRequest($url);
     $https_capable = false;
     if ($request['info']['http_code'] == 200) {
         $simplepie = new SimplePie();
         $simplepie->set_raw_data($request['html']);
         $success = $simplepie->init();
         if ($success !== false) {
             $https_capable = true;
         } else {
             // Capable but unable to parse feed, maybe shaarli only served on port 80
         }
     }
     if ($https_capable) {
         $feed->https = 1;
         $feed->url = $url;
     } else {
         $feed->https = 0;
         $feed->url = preg_replace("/^https:/", "http:", $feed->url);
     }
     $feed->save();
     unset($request);
 }
开发者ID:inscriptionweb,项目名称:shaarli-api,代码行数:30,代码来源:cron.php

示例12: parseFeeds

function parseFeeds($intFeedId, $strCommand)
{
    global $_PATHS, $_CLEAN_POST, $_CONF, $objLang, $objLiveUser;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("feed.tpl.htm");
    $blnError = false;
    switch ($strCommand) {
        case CMD_LIST:
        case CMD_ADD:
        case CMD_EDIT:
            //*** Post the profile form if submitted.
            if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editFeed") {
                //*** The element form has been posted.
                //*** Check sanitized input.
                if (is_null($_CLEAN_POST["frm_active"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_name"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_feed"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_basepath"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_refresh"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["dispatch"])) {
                    $blnError = true;
                }
                if ($blnError === true) {
                    //*** Display global error.
                    $objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : "");
                    $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]);
                    $objTpl->setVariable("FORM_FEED_VALUE", $_POST["frm_feed"]);
                    $objTpl->setVariable("FORM_BASEPATH_VALUE", $_POST["frm_basepath"]);
                    $objTpl->setVariable("FORM_REFRESH_VALUE", $_POST["frm_refresh"]);
                    $objTpl->setVariable("ERROR_FEED_MAIN", $objLang->get("main", "formerror"));
                } else {
                    //*** Input is valid. Save the feed.
                    if ($strCommand == CMD_EDIT) {
                        $objFeed = Feed::selectByPK($intFeedId);
                    } else {
                        $objFeed = new Feed();
                    }
                    $objFeed->setAccountId($_CONF['app']['account']->getId());
                    $objFeed->setActive($_POST["frm_active"] == "on" ? 1 : 0);
                    $objFeed->setName($_CLEAN_POST["frm_name"]);
                    $objFeed->setFeed($_CLEAN_POST["frm_feed"]);
                    $objFeed->setBasepath($_CLEAN_POST["frm_basepath"]);
                    $objFeed->setRefresh($_CLEAN_POST["frm_refresh"]);
                    $objFeed->setLastUpdate(Date::toMysql());
                    $objFeed->save();
                    //*** Cache feed.
                    $objFeed->cache();
                    header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_FEEDS);
                    exit;
                }
            }
            //*** Initiate child element loop.
            $objFeeds = Feed::selectSorted();
            $listCount = 0;
            $intPosition = request("pos");
            $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
            $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
            $objFeeds->seek($intPosition);
            foreach ($objFeeds as $objFeed) {
                $objTpl->setCurrentBlock("multiview-item");
                $objTpl->setVariable("MULTIITEM_VALUE", $objFeed->getId());
                $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Feed.remove({$objFeed->getId()});");
                $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
                $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_FEEDS . "&amp;eid={$objFeed->getId()}&amp;cmd=" . CMD_EDIT);
                $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "feed");
                $objTpl->setVariable("MULTIITEM_NAME", $objFeed->getName());
                $objTpl->setVariable("MULTIITEM_POINTS_TO", $objLang->get("pointsTo", "label"));
                $objTpl->setVariable("MULTIITEM_FEED", $objFeed->getFeed());
                $objTpl->setVariable("MULTIITEM_FEED_HREF", $objFeed->getFeed());
                if (!$objFeed->getActive()) {
                    $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\"");
                }
                $objTpl->parseCurrentBlock();
                $listCount++;
                if ($listCount >= $_SESSION["listCount"]) {
                    break;
                }
            }
            //*** Render page navigation.
            $pageCount = ceil($objFeeds->count() / $_SESSION["listCount"]);
            if ($pageCount > 0) {
                $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]);
                $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0;
                $nextPos = $intPosition + $_SESSION["listCount"] < $objFeeds->count() ? $intPosition + $_SESSION["listCount"] : $intPosition;
                $objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount));
                $objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button"));
                $objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_FEEDS . "&amp;pos={$previousPos}");
                $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button"));
                $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_FEEDS . "&amp;pos={$nextPos}");
                //*** Top page navigation.
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:inc.tplparse_feeds.php


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