Ejemplo n.º 1
0
 function mt_setPostCategories($params)
 {
     list($postid, $username, $password, $categories) = $params;
     $txp = new TXP_Wrapper($username, $password);
     if (!$txp->loggedin) {
         return new IXR_Error(100, gTxt('bad_login'));
     }
     $Category1 = '';
     $Category2 = '';
     foreach ($categories as $category) {
         extract($category);
         $rs = $txp->getCategoryId($categoryId);
         if (!$rs) {
             return new IXR_Error(213, gTxt('trying_to_assign_unexisting_category_to_the_article'));
         }
         if (empty($Category1)) {
             $Category1 = $rs['name'];
         } else {
             $Category2 = $rs['name'];
         }
     }
     $ct1 = $txp->updateArticleField($postid, 'Category1', $Category1);
     $ct2 = $txp->updateArticleField($postid, 'Category2', $Category2);
     if (!$ct1 || !$ct2) {
         return new IXR_Error(214, gTxt('problem_saving_article_categories'));
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Apply Textile to the main article fields.
  *
  * This is duplicated from txp_article.php.
  *
  * @param  array $incoming    The incoming fields
  * @param  bool  $use_textile Use Textile or not
  * @return array The $incoming array formatted
  * @access private
  */
 public function textile_main_fields($incoming, $use_textile = 1)
 {
     global $txpcfg;
     $textile = new \Textpattern\Textile\Parser();
     if (!empty($event) and $event == 'article') {
         $incoming['Title_plain'] = $incoming['Title'];
     }
     if ($incoming['textile_body'] == USE_TEXTILE) {
         $incoming['Title'] = $textile->textileThis($incoming['Title'], '', 1);
     }
     $incoming['url_title'] = preg_replace('|[\\x00-\\x1f#%+/?\\x7f]|', '', $incoming['url_title']);
     $incoming['Body_html'] = TXP_Wrapper::format_field($incoming['Body'], $incoming['textile_body'], $textile);
     $incoming['Excerpt_html'] = TXP_Wrapper::format_field($incoming['Excerpt'], $incoming['textile_excerpt'], $textile);
     return $incoming;
 }
Ejemplo n.º 3
0
 /**
  * Apply textile to the main article fields
  * (duplicated from txp_article.php!)
  * @param array containing the $incoming vars array
  * @param global use_textile preference
  * @return array the same one containing the formatted fields
  */
 function textile_main_fields($incoming, $use_textile = 1)
 {
     global $txpcfg;
     include_once txpath . '/lib/classTextile.php';
     $textile = new Textile();
     if (!empty($event) and $event == 'article') {
         $incoming['Title_plain'] = $incoming['Title'];
     }
     if ($incoming['textile_body'] == USE_TEXTILE) {
         $incoming['Title'] = $textile->TextileThis($incoming['Title'], '', 1);
     }
     $incoming['url_title'] = preg_replace('|[\\x00-\\x1f#%+/?\\x7f]|', '', $incoming['url_title']);
     $incoming['Body_html'] = TXP_Wrapper::format_field($incoming['Body'], $incoming['textile_body'], $textile);
     $incoming['Excerpt_html'] = TXP_Wrapper::format_field($incoming['Excerpt'], $incoming['textile_excerpt'], $textile);
     return $incoming;
 }
Ejemplo n.º 4
0
function product_post()
{
    global $txp_user, $vars, $txpcfg, $prefs;
    extract($prefs);
    define("IMPATH", $path_to_site . '/' . $img_dir . '/');
    $incoming = psa($vars);
    $import = false;
    $message = '';
    $wrapper = new TXP_Wrapper();
    $incoming = $wrapper->textile_main_fields($incoming, $use_textile);
    extract(doSlash($incoming));
    extract(array_map('assert_int', psa(array('Status', 'textile_body', 'textile_excerpt'))));
    $Annotate = ps('Annotate') ? assert_int(ps('Annotate')) : 0;
    if ($import) {
        $Status = $product['Status'];
    }
    $when = 'now()';
    if ($Title or $Body or $Excerpt) {
        if (!has_privs('article.publish') && $Status >= 4) {
            $Status = 3;
        }
        if (empty($url_title)) {
            $url_title = stripSpace($Title_plain, 1);
        }
        if (!$Annotate) {
            $Annotate = 0;
        }
        if (isset($new_vendor_name) && !empty($new_vendor_name)) {
            $custom_5 = $new_vendor_name;
            cat_vendor_category_create($custom_5);
        } else {
            if (isset($vendor)) {
                $custom_5 = $vendor;
            }
        }
        safe_insert("textpattern", "Title           = '{$Title}',\n\t\t\t\tBody            = '{$Body}',\n\t\t\t\tBody_html       = '{$Body_html}',\n\t\t\t\tExcerpt         = '{$Excerpt}',\n\t\t\t\tExcerpt_html    = '{$Excerpt_html}',\n\t\t\t\tImage           = '{$Image}',\n\t\t\t\tKeywords        = '{$Keywords}',\n\t\t\t\tStatus          =  {$Status},\n\t\t\t\tPosted          =  {$when},\n\t\t\t\tLastMod         =  now(),\n\t\t\t\tAuthorID        = '{$txp_user}',\n\t\t\t\tSection         = '{$Section}',\n\t\t\t\tCategory1       = '{$Category1}',\n\t\t\t\tCategory2       = '{$Category2}',\n\t\t\t\ttextile_body    =  {$textile_body},\n\t\t\t\ttextile_excerpt =  {$textile_excerpt},\n\t\t\t\tAnnotate        =  {$Annotate},\n\t\t\t\toverride_form   = '{$override_form}',\n\t\t\t\turl_title       = '{$url_title}',\n\t\t\t\tAnnotateInvite  = '{$AnnotateInvite}',\n\t\t\t\tcustom_1        = '{$custom_1}',\n\t\t\t\tcustom_2        = '{$custom_2}',\n\t\t\t\tcustom_3        = '{$custom_3}',\n\t\t\t\tcustom_4        = '{$custom_4}',\n\t\t\t\tcustom_5        = '{$custom_5}',\n\t\t\t\tcustom_6        = '{$custom_6}',\n\t\t\t\tcustom_7        = '{$custom_7}',\n\t\t\t\tcustom_8        = '{$custom_8}',\n\t\t\t\tcustom_9        = '{$custom_9}',\n\t\t\t\tcustom_10       = '{$custom_10}',\n\t\t\t\tuid\t\t\t\t= '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\tfeed_time\t\t= now()");
        $GLOBALS['ID'] = mysql_insert_id();
        $ID = $GLOBALS['ID'];
        //print_r($_FILES);
        //CUSTOM FIELDS
        save_custom_fields($_REQUEST['custom_fields'], $ID);
        //IMAGE UPLOAD
        //=======================
        if ($_FILES["uploadFile"]["type"] == "image/gif" || $_FILES["uploadFile"]["type"] == "image/jpeg" || $_FILES["uploadFile"]["type"] == "image/png") {
            // prepare the image for insertion
            $img = $_FILES['uploadFile']['tmp_name'];
            upload_image($img, 1, $ID);
        }
        //END IMAGE UPLOAD
        //=======================
        if ($Status >= 4) {
            if (!function_exists("do_pings")) {
                require_once txpath . '/include/txp_article.php';
                do_pings();
            }
            update_lastmod();
        }
        product_edit("", "", "Product Saved");
    } else {
        product_edit();
    }
}