Beispiel #1
0
 public function run($args)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'ifcheck=:ifcheck';
     $criteria->params = array(':ifcheck' => '已通过');
     $news = Bl::model()->findAll($criteria);
     foreach ($news as $new) {
         $node = new stdClass();
         $node->title = $new->title;
         $node->field_phone['und'][0]['value'] = $new->phone;
         $node->type = "_xiansuo";
         $node->body['und'][0]['value'] = $new->content;
         $node->field_shimin['und'][0]['value'] = $new->name;
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 1;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         if ($new->img1 != "") {
             $suoluetu = 'e://wamp/www/epaper/assets/bl/b_' . $new->img1;
             $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
             $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://wm12.cn:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>";
             $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         unset($node);
     }
 }
 public function actionCreate()
 {
     $basic = new basic();
     if (isset($_POST['title']) & isset($_POST['content']) & isset($_POST['phone'])) {
         $node = new stdClass();
         $node->title = $_POST['title'];
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->uid = 1;
         $node->type = 'yijianfank';
         $node->language = 'zh-hans';
         $node->status = 1;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 0;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         $node = node_submit($node);
         // Prepare node for saving
         //print_r($node);
         node_save($node);
         $basic->error_code = 0;
         //$basic->error_msg="no input parameters";
     } else {
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
     }
     $jsonObj = CJSON::encode($basic);
     echo $jsonObj;
 }
Beispiel #3
0
function importo_save_node($node)
{
    $node = node_submit($node);
    if (!$node) {
        _die("FATAL [" . __FILE__ . " (" . __LINE__ . ")]: node_submit failed");
    }
    node_save($node);
    return $node;
}
function insertar_contenido($content_type, $archivo_datos)
{
    $handle = fopen($archivo_datos, "r");
    $theHeaders = fgetcsv($handle, 4096, "\t");
    $lineno = 0;
    while ($line = fgetcsv($handle, 4096, "\t")) {
        $output .= '';
        $valueno = 0;
        $lineno++;
        $output .= '<ul>L’nea: ' . $lineno;
        $observaciones = '';
        foreach ($line as $value) {
            if ($value) {
                $output .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
                $observaciones .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
            }
            $valueno++;
        }
        $output .= '</ul>';
        $node = array();
        $node['title'] = $line[3];
        $node['body'] = $observaciones;
        $node['type'] = $content_type;
        $node['format'] = 3;
        //$node['taxonomy'] = $_REQUEST['taxonomy'];
        $node['name'] = $content_name;
        //$node['date'] = $_REQUEST['date'];
        $node['status'] = 1;
        $node['promote'] = 0;
        $node['sticky'] = 0;
        $log = 'Importado por importar-contactos el ' . date('g:i:s a');
        $node['log'] = $log;
        $node['field_empresa'] = array(0 => array('nid' => db_result(db_query("SELECT nid FROM {node} WHERE title = '%s'", $line[2]))));
        $node['field_cargo'] = array(0 => array('value' => $line[22]));
        $node['field_saludo'] = array(0 => array('value' => $line[17]));
        $node['field_nombres'] = array(0 => array('value' => $line[54]));
        $node['field_apellidos'] = array(0 => array('value' => $line[55]));
        $node['field_mvil'] = array(0 => array('value' => $line[15]));
        $node['field_telfono_particular'] = array(0 => array('value' => $line[14]));
        $node['field_buscapersonas'] = array(0 => array('value' => $line[16]));
        $node['field_e_mail'] = array(0 => array('value' => $line[89]));
        /*
          // this code, from the autosave module, is unnecessary, since node_save will do it for us :)
          $node['nid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", 'node_nid')) + 1;
          $node['vid'] = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", 'node_revisions_vid')) + 1;
        */
        if ($node['title']) {
            $node = (object) $node;
            $node = node_submit($node);
            node_save($node);
            print $output;
            $nid = $node->nid;
            $tid = 6;
            db_query("INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)", $nid, $tid);
        }
    }
}
 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time']) & isset($_POST['uid'])) {
         //用户积分修改
         $u = user_load($_POST['uid']);
         $edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 3))));
         user_save($u, $edit);
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = $_POST['uid'];
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         //$node->field_riq['und'][0]['value'] =date('Y:m:d H:i:s');
         $node->field_riq['und'][0]['value'] = $_POST['create_time'];
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         //默认为匿名
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/urban/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/urban');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         $basic = new basic();
         $basic->error_code = 0;
         //$basic->error_msg="no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     } else {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     }
 }
Beispiel #6
0
 public function run($args)
 {
     //$news=Yw::model()->findAll();
     $criteria = new CDbCriteria();
     //	$criteria->select=array('content','create_time','nick');
     //	$criteria->condition='article_id=:article_id  AND ifcheck=:ifcheck';
     $criteria->order = 'id DESC';
     //降序 最新的总是在最前面
     //	$criteria->params=array(':article_id'=>$param['id'],':ifcheck'=>'已通过');
     $news = Zt::model()->findAll($criteria);
     foreach ($news as $key => $new) {
         if ($key < 2) {
             $node = new stdClass();
             $node->title = $new->title;
             $node->body['und'][0]['value'] = $new->content;
             $node->field_fubiaoti['und'][0]['value'] = $new->subTitle;
             $node->field_src['und'][0]['value'] = $new->src;
             $node->field_label['und'][0]['value'] = $new->label;
             $node->field_myspecial['und'][0]['tid'] = 98;
             $node->uid = 1;
             $node->type = 'article';
             $node->language = 'zh-hans';
             $node->status = 1;
             //(1 or 0): published or not
             $node->promote = 0;
             //(1 or 0): promoted to front page
             $node->comment = 2;
             // 0 = comments disabled, 1 = read only, 2 = read/write
             if ($new->img3 != "") {
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img3 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             if ($new->img2 != "") {
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img2 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             if ($new->img1 != "") {
                 $suoluetu = 'http://202.99.222.132:88/admin/assets/img/b_' . $new->img1;
                 $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
                 $file = file_copy($file, 'public://pictures/');
                 $node->field_image['und'][0] = (array) $file;
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             $node = node_submit($node);
             // Prepare node for saving
             //print_r($node);
             node_save($node);
         }
     }
 }
/**
 * Notifies of a newly saved instagram media item.
 *
 * @param $type  string
 *    The type of the instagram media (image, video)
 * @param $item
 *    The instagram media item object
 *   stdClass containing the instagram media item.
 * @see https://www.instagram.com/developer/endpoints/media/ for details about the contents of $item.
 */
function hook_instagram_media_save($type, $item)
{
    //
    // add a node for all new items
    $node = new stdClass();
    $node->type = 'instagram';
    $node->language = LANGUAGE_NONE;
    $node->uid = 1;
    $node->status = 1;
    node_object_prepare($node);
    // assign all fields
    $node->body[LANGUAGE_NONE][0]['value'] = $item->caption;
    // save node
    $node = node_submit($node);
    node_save($node);
}
/**
 * node save
 */
function _save_node($param_array = NULL)
{
    global $user;
    $node = new stdClass();
    $node->type = $param_array['type'];
    $node->title = $param_array['title'];
    $node->language = LANGUAGE_NONE;
    // Or any language code if Locale module is enabled. More on this below *
    node_object_prepare($node);
    // Set some default values.
    $node->uid = $user->uid;
    $node->field_chassis_dspl_chassis['und'][0]['product_id'] = $param_array['product_pid'];
    // $node->field_card_dspl_card['und'][0]['product_id'] = $param_array['product_pid'];
    $node = node_submit($node);
    // Prepare node for a submit
    node_save($node);
    // After this call we'll get a nid
    $node_nid = $node->nid;
    drupal_set_message(t('Save node as ') . $node_nid);
    return $node->nid;
}
Beispiel #9
0
 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time'])) {
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         $node->field_riq['und'][0]['value'] = date('Y:m:d H:i:s');
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/pic/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => 1, 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         echo '1';
     } else {
         echo '0';
     }
 }
/**
 * Funzione che consente di creare automaticamente un contenuto drupal con le immagini jpg caricate in temp_img
 * e i dati exif ricavati da esse.
 *
 * @param $lat
 * @param $lng
 * @param $fileName
 *
 */
function createContentFromImage($lat, $lng, $fileName)
{
    $node = new stdClass();
    // Create a new node object Or page, or whatever content type you like
    $node->type = "exif_data";
    // Set some default values
    node_object_prepare($node);
    $node->language = "en";
    $node->uid = 1;
    $coords = (object) array('lat' => $lat, 'lng' => $lng);
    $node->field_posizione['und'][0] = (array) $coords;
    //@ToDo here you have to substitute the path
    $file_path = "/var/www/.." . $fileName;
    $count_photo = count($file_path);
    for ($i = 0; $i < $count_photo; $i++) {
        if (getimagesize($file_path)) {
            $file_gallery = (object) array('uid' => 0, 'uri' => $file_path, 'filemime' => file_get_mimetype($file_path), 'status' => 1);
            //substitute "your_destination_folder" with a folder name
            try {
                file_copy($file_gallery, 'public://your_destination_folder');
                $node->field_image['und'][0] = (array) $file_gallery;
                echo "File correctly copied";
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
    }
    //$node = node_submit($node); // Prepare node for saving
    if ($node = node_submit($node)) {
        // Prepare node for saving
        node_save($node);
        //Drupal node saving function call
        $status = "Content created correctly" . "";
    } else {
        $status = "Something went wrong during the node submitting";
    }
    echo $status;
}
Beispiel #11
0
/**
 * Creating dummy content during the installation process.
 */
function inject_data()
{
    global $base_url;
    $tmp_base_url = variable_get("tmp_base_url");
    // Populate users fields of dummy users.
    $account = user_load(1);
    $account1 = user_load_by_name("user_administrator");
    $account2 = user_load_by_name("user_contributor");
    $account3 = user_load_by_name("user_editor");
    $account->field_firstname['und'][0]['value'] = 'John';
    $account->field_lastname['und'][0]['value'] = 'Doe';
    user_save($account);
    $account1->field_firstname['und'][0]['value'] = 'John';
    $account1->field_lastname['und'][0]['value'] = 'Smith';
    user_save($account1);
    $account2->field_firstname['und'][0]['value'] = 'John';
    $account2->field_lastname['und'][0]['value'] = 'Name';
    user_save($account2);
    $account3->field_firstname['und'][0]['value'] = 'John';
    $account3->field_lastname['und'][0]['value'] = 'Blake';
    user_save($account3);
    // Create content.
    $node = new stdClass();
    $node->type = 'page';
    node_object_prepare($node);
    $node->title = 'Welcome to your site !';
    $node->language = LANGUAGE_NONE;
    $node->path = array('alias' => 'content/welcome-your-site');
    $node->status = '1';
    $node->uid = '1';
    $node->promote = '0';
    $node->sticky = '0';
    $node->created = '1330594184';
    $node->comment = '1';
    $node->translate = '0';
    $node->revision = 1;
    $node->body[$node->language][0]['value'] = '<p>Notice:</p>
    <p>You have to login in order to perform any of the action described below &gt;&gt; ' . l(t('Login'), $tmp_base_url . '/user') . '</p>
    <p>&nbsp;</p>
    <p>To complete the configuration of your site, here are&nbsp;some additional&nbsp;steps :</p>
    <p>- to access the <strong>Feature set</strong> configuration page which helps you to choose the features you wish to install on your site &gt;&gt; ' . l(t('click here'), $tmp_base_url . '/admin/structure/feature-set') . '</p>
    <p>- to access the <strong>user creation</strong> page in order to add some users and to choose the role you wish to give them &gt;&gt; ' . l(t('click here'), $tmp_base_url . '/admin/people') . '</p>
    <p>&nbsp;</p>
    <p>Some information about&nbsp;roles&nbsp;:</p>
    <p>- admin user can do everything on the site, but will mainly be used to approve/refuse user account creation or community creation</p>
    <p>- community manager will act as admin in its community to approve/refuse membership requests and creation of contents inside the community</p>
    <p>Management will be done through the <strong>Workbench </strong>you can access thru this ' . l(t('link'), $tmp_base_url . '/admin/workbench') . '.</p>
    <p>For more information about the various functionalities,&nbsp;a contextual help exists and can be accessed&nbsp;thru the &quot;Help&quot; link.&nbsp;The help section depends on your localisation on the site and gives details about the page.</p>
    ';
    $node->body[$node->language][0]['summary'] = '';
    $node->body[$node->language][0]['format'] = 'full_html';
    $path = 'content/welcome-your-site';
    $node->path = array('alias' => $path);
    // Prepare node for saving.
    if ($node = node_submit($node)) {
        node_save($node);
        echo "Node saved!\n";
    }
    // Delete mails from the update manager module.
    variable_del("update_notify_emails");
    // Manually insert the password policy in database.
    // This process is temporary since the module password_policy.
    $exports = cce_basic_config_default_password_policy();
    db_delete('password_policy')->execute();
    db_insert('password_policy')->fields(array('name' => 'Example policy', 'config' => $exports['Example policy']->config))->execute();
}
 /**
  *
  * Creates an annotation by current user with values set:
  * | audience     | category      | tags       | text             |
  * | private, peer-groups, instructor, everyone|
  * @Given annotations on :document:
  */
 public function createAnnotations($document_title, TableNode $annotationsTable)
 {
     global $user;
     // Need to load the user from the Author field in this case
     $user = $this->user;
     // Needed for module's routines
     $document = $this->findNodeByTitle('document', $document_title);
     // Access the Annotation Store functions
     include_once DRUPAL_ROOT . '/sites/all/modules/custom/annotation/annotation.store.inc';
     foreach ($annotationsTable->getHash() as $data) {
         $annotation = (object) $data;
         if (isset($annotation->audience)) {
             // Special case for audience
             // default; must have all values set
             $audiences = array('private' => 0, 'instructor' => 0, 'peer-groups' => 0, 'everyone' => 0);
             $annotation->privacy_options['audience'] = $audiences;
             foreach (explode(',', $annotation->audience) as $audience) {
                 $annotation->privacy_options['audience'][strtolower($audience)] = 1;
             }
             unset($annotation->audience);
         }
         // Annotator.js formats the URI this way
         global $base_root;
         $uri = entity_uri('node', $document);
         $annotation->uri = $base_root . base_path() . $uri['path'];
         $annotation = annotation_drupal_format($annotation);
         $annotation->uid = $this->user->uid;
         $annotation = node_submit($annotation);
         node_save($annotation);
     }
 }
function insert_content($content_type, $data_archive)
{
    // Open the CSV file read only.
    $handle = fopen($data_archive, "r");
    // Read the headers from the first line.
    $theHeaders = fgetcsv($handle);
    // Keep count of how many lines we have processed.
    $lineno = 0;
    while ($line = fgetcsv($handle)) {
        $output = '';
        $valueno = 0;
        $lineno++;
        $output .= '<ul>Line: ' . $lineno;
        $observaciones = '';
        foreach ($line as $value) {
            if ($value) {
                $output .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
                $observaciones .= '<li>' . $theHeaders[$valueno] . ': ' . $value . '</li>';
            }
            $valueno++;
        }
        $output .= '</ul>';
        // Create new node
        $node = array();
        // Node is of type $content_type/$content_name
        $node['type'] = $content_type;
        $node['name'] = $content_name;
        // Formats on CCK nodes apply to fields, so no format set here.
        $node['format'] = 0;
        // Enable read/write comments.
        $node['comment'] = 2;
        // Published
        $node['status'] = 1;
        // Not promoted to front page.
        $node['promote'] = 0;
        // Not sticky.
        $node['sticky'] = 0;
        // Create a log entry for the first revision.
        $log = 'Imported from csv.' . date('g:i:s a');
        $node['log'] = $log;
        // Node fields here, mapped to CSV file data.
        $node['title'] = $line[1];
        $node['created'] = $line[4];
        $node['name'] = $line[7];
        $node['uid'] = $line[8];
        // CCK fields here, mapped to CSV file data.
        // For each, we set the value, and the desired input/output format.
        // In this case, format 4 is a non-html-filtering input type.
        $node['field_eis_action_items'] = array(0 => array('value' => $line[16], 'format' => 4));
        $node['field_eis_agenda'] = array(0 => array('value' => $line[14], 'format' => 4));
        $node['field_eis_attendees'] = array(0 => array('value' => $line[9], 'format' => 4));
        $node['field_eis_meeting_date'] = array(0 => array('value' => $line[10]));
        $node['field_eis_notes'] = array(0 => array('value' => $line[22], 'format' => 4));
        $node['field_eis_open_issues'] = array(0 => array('value' => $line[20], 'format' => 4));
        $node['field_eis_purpose'] = array(0 => array('value' => $line[12], 'format' => 4));
        $node['field_eis_requirements'] = array(0 => array('value' => $line[18], 'format' => 4));
        // Basic check for having a non-blank title.
        // Then submit/save node, and output the data we used for this node.
        if ($node['title']) {
            $node = (object) $node;
            // This is the unique TID from the taxonomy table. It can also be an array of values.
            // Set it here after we turn the node into an object...
            $node->taxonomy[] = 1;
            $node = node_submit($node);
            node_save($node);
            print $output;
        }
    }
}
Beispiel #14
0
/**
 * Creating dummy content during the installation process.
 */
function inject_data()
{
    global $base_path;
    $tmp_base_url = variable_get("tmp_base_url");
    $base_path = $tmp_base_url;
    // Populate users fields of dummy users.
    $account = user_load(1);
    $account1 = user_load_by_name("user_administrator");
    $account2 = user_load_by_name("user_contributor");
    $account3 = user_load_by_name("user_editor");
    $account->field_firstname['und'][0]['value'] = 'John';
    $account->field_lastname['und'][0]['value'] = 'Doe';
    user_save($account);
    $account1->field_firstname['und'][0]['value'] = 'John';
    $account1->field_lastname['und'][0]['value'] = 'Smith';
    user_save($account1);
    $account2->field_firstname['und'][0]['value'] = 'John';
    $account2->field_lastname['und'][0]['value'] = 'Name';
    user_save($account2);
    $account3->field_firstname['und'][0]['value'] = 'John';
    $account3->field_lastname['und'][0]['value'] = 'Blake';
    user_save($account3);
    module_enable(array("i18n_taxonomy"));
    // Create content.
    $node = new stdClass();
    $node->type = 'page';
    node_object_prepare($node);
    $node->title = 'Welcome to your site !';
    $node->language = LANGUAGE_NONE;
    $node->path = array('alias' => 'content/welcome-your-site');
    $node->status = '1';
    $node->uid = '1';
    $node->promote = '0';
    $node->sticky = '0';
    $node->created = '1330594184';
    $node->comment = '1';
    $node->translate = '0';
    $node->revision = 1;
    $node->body[$node->language][0]['value'] = '<p>Notice:</p>
    <p>You have to login in order to perform any of the action described below &gt;&gt; ' . l(t('Login'), 'user') . '</p>
    <p>&nbsp;</p>
    <p>To complete the configuration of your site, here are&nbsp;some additional&nbsp;steps :</p>
    <p>- to access the <strong>Feature set</strong> configuration page which helps you to choose the features you wish to install on your site &gt;&gt; ' . l(t('click here'), 'admin/structure/feature-set') . '</p>
    <p>- to access the <strong>user creation</strong> page in order to add some users and to choose the role you wish to give them &gt;&gt; ' . l(t('click here'), 'admin/people') . '</p>
    <p>&nbsp;</p>
    <p>Some information about&nbsp;roles&nbsp;:</p>
    <p>- admin user can do everything on the site, but will mainly be used to approve/refuse user account creation or community creation</p>
    <p>- community manager will act as admin in its community to approve/refuse membership requests and creation of contents inside the community</p>
    <p>Management will be done through the <strong>Workbench </strong>you can access through this ' . l(t('link'), 'admin/workbench') . '.</p>
    <p>For more information about the various functionalities,&nbsp;a contextual help exists and can be accessed&nbsp;thru the &quot;Help&quot; link.&nbsp;The help section depends on your localisation on the site and gives details about the page.</p>
    ';
    $node->body[$node->language][0]['summary'] = '';
    $node->body[$node->language][0]['format'] = 'full_html';
    $path = 'content/welcome-your-site';
    $node->path = array('alias' => $path);
    if ($node = node_submit($node)) {
        // Prepare node for saving.
        node_save($node);
        echo "Node saved!\n";
    }
    // Delete mails from the update manager module.
    variable_del("update_notify_emails");
    // Manually insert the password policy in database.
    // This process is temporary since the module password_policy.
    $exports = cce_basic_config_default_password_policy();
    db_delete('password_policy')->execute();
    db_insert('password_policy')->fields(array('name' => 'Example policy', 'config' => $exports['Example policy']->config))->execute();
    // Add solr facet blocks to the search context.
    global $theme_key;
    if ($theme_key == 'ec_resp') {
        $region = 'sidebar_left';
    } else {
        $region = 'sidebar_first';
    }
    multisite_drupal_toolbox_add_block_context('search', $value['info'], 'facetapi', $key, $region);
    multisite_drupal_toolbox_add_block_context('search', 'facetapi-8o8kdtP8CKjahDIu1Wy5LGxnDHg3ZYnT', 'facetapi', '8o8kdtP8CKjahDIu1Wy5LGxnDHg3ZYnT', $region, -14);
    multisite_drupal_toolbox_add_block_context('search', 'facetapi-wWWinJ0eOefOtAMbjo2yl86Mnf1rO12j', 'facetapi', 'wWWinJ0eOefOtAMbjo2yl86Mnf1rO12j', $region, -15);
    multisite_drupal_toolbox_add_block_context('search', 'facetapi-odQxTWyhGW1WU7Sl00ISAnQ21BCdJG3A', 'facetapi', 'odQxTWyhGW1WU7Sl00ISAnQ21BCdJG3A', $region, -17);
    multisite_drupal_toolbox_add_block_context('search', 'facetapi-GiIy4zr9Gu0ZSa0bumw1Y9qIIpIDf1wu', 'facetapi', 'GiIy4zr9Gu0ZSa0bumw1Y9qIIpIDf1wu', $region, -16);
}
Beispiel #15
0
function guifi_api_service_add($gapi, $parameters)
{
    global $user;
    if (!guifi_api_check_fields($gapi, array('name', 'server_id', 'service_type'), $parameters)) {
        return FALSE;
    }
    //Check if this service exist
    $server_type = $parameters['service_type'];
    $types = db_fetch_object(db_query("SELECT count(*) as cnt FROM {guifi_types} WHERE type='service' AND text='%s'", $server_type));
    if ($types->cnt == 0) {
        //This server type is not defined in guifi_db.
        $gapi->addError(403, "This server type is not defined.");
        return FALSE;
    }
    $server = guifi_device_load($parameters['server_id']);
    if (!is_array($server)) {
        //This server did not exist.
        $gapi->addError(403, "This server did not exist.");
        return FALSE;
    }
    //Need create drupal node (type guifi_service)
    global $user;
    $node = new stdClass();
    $node->type = 'guifi_service';
    $node->name = $user->name;
    $node->uid = $user->uid;
    $node->comment = variable_get('comment_' . $node->type, 2);
    $node->status = 1;
    $node->format = FILTER_FORMAT_DEFAULT;
    $node->title = $parameters['name'];
    $node = node_submit($node);
    $status_flag = isset($parameters['status']) ? $parameters['status'] : 'Working';
    $types = db_fetch_object(db_query("SELECT count(*) as cnt FROM {guifi_types} WHERE type='status' AND text='%s'", $status_flag));
    if ($types->cnt == 0) {
        //This status_flag is not defined in guifi_db.
        $gapi->addError(403, "This status is not defined.");
        return FALSE;
    }
    $service = array('new' => TRUE, 'title' => $parameters['name'], 'service_type' => $server_type, 'status_flag' => $status_flag, 'notification' => $user->mail, 'device_id' => $server['id']);
    // Nick assinged
    $nick = !isset($parameters['nick']) ? guifi_abbreviate($parameters['name']) : $parameters['nick'];
    $nick = _guifi_api_check_nick($nick, $node);
    if (is_array($nick)) {
        $gapi->addError($nick['error_code'], $nick['error_message']);
        return FALSE;
    }
    $service['nick'] = $nick;
    // Determine Zone
    $zone = _guifi_api_get_zone($server);
    if (is_array($zone)) {
        $gapi->addError($zone['error_code'], $zone['error_message']);
        return FALSE;
    }
    $service['zone_id'] = $zone;
    // Pass all parameters of service to node.
    foreach ($service as $k => $v) {
        $node->{$k} = $v;
    }
    $node->name = $node->title;
    node_save($node);
    $nservice = _guifi_db_sql('guifi_services', array('id' => $service->id), (array) $node);
    $gapi->addResponseField('service', $nservice);
    return TRUE;
}
    $node->field_xml['und'][0]['filemime'] = $fileObj->filemime;
    $node->field_xml['und'][0]['filesize'] = $fileObj->filesize;
    $node->field_xml['und'][0]['timestamp'] = $fileObj->timestamp;
    $node->field_xml['und'][0]['display'] = 1;
    //Sender Taxonomy
    $senderTid = TaxonomyUtils::checkTerms(VOCAB_SENDER_NAME, $tei->sender);
    $node->field_sender['und'][0]['tid'] = $senderTid;
    $senderIdTid = TaxonomyUtils::checkTerms(VOCAB_SENDER_ID, $tei->senderId);
    $node->field_sender_id['und'][0]['tid'] = $senderIdTid;
    //Receiver Taxonomy
    $receiverTid = TaxonomyUtils::checkTerms(VOCAB_RECEIVER_NAME, $tei->receiver);
    $node->field_receiver['und'][0]['tid'] = $receiverTid;
    $receiverIdTid = TaxonomyUtils::checkTerms(VOCAB_RECEIVER_ID, $tei->receiverId);
    $node->field_receiver_id['und'][0]['tid'] = $receiverIdTid;
    //Letter People NID Taxonomy
    $psnNodeIdTidArray = TaxonomyUtils::getTermsFromArray($tei->personNodeIds);
    $node->field_person_node['und'] = $psnNodeIdTidArray;
    //Letter Place NID Taxonomy
    $placeNodeIdTidArray = TaxonomyUtils::getTermsFromArray($tei->placeNodeIds);
    $node->field_place_node['und'] = $placeNodeIdTidArray;
    //Year Taxonomy
    $yearTid = TaxonomyUtils::checkTerms(VOCAB_YEAR_NAME, $tei->year);
    $node->field_year['und'][0]['tid'] = $yearTid;
    //Date Field
    $node->field_date['und'][0]['value'] = $tei->date . 'T00:00:00';
    //Alias
    $node->path = array('alias' => $tei->nodeAlias);
    //Save
    $node = node_submit($node);
    node_save($node);
}
Beispiel #17
0
 public function run($args)
 {
     date_default_timezone_set('Asia/Shanghai');
     //$date=date('Ymd');
     $date = '20150414';
     //echo $date;
     //echo date('Ymd',strtotime('-1 day'));
     $dir = DISK . 'npsite/tyrb/' . $date . '/';
     //echo $dir;
     if (is_dir($dir)) {
         //创建存放文件的文件夹
         $img_file = PC . '/epaper2/assets/article_img/' . $date;
         if (is_dir($img_file)) {
             echo 'exist ' . $date . ' epaper data';
         } else {
             if ($dh = opendir($dir)) {
                 // echo $img_file.'<bf>';
                 if (mkdir($img_file, 0777)) {
                     $filenames = scandir($dir);
                     $fl_array1 = preg_grep("/\\w*.xml/", $filenames);
                     $fl_array = preg_grep("/^((?!pages.xml).)*\$/", $fl_array1);
                     $xmlfile = array_values($fl_array);
                     //$xml=$xmlfile[0];
                     $pageCount = new Pagecount();
                     $pageCount->setAttributes(array('create_time' => $date, 'pageCount' => count($xmlfile)));
                     $pageCount->save(true);
                     foreach ($xmlfile as $xml) {
                         if (file_exists($dir . $xml)) {
                             $xml = simplexml_load_file($dir . $xml);
                             $PageNo = $xml->PageInfo[0]->attributes()[0];
                             $PageName = $xml->PageInfo[0]->attributes()[1];
                             $ppname = new Pname();
                             $ppname->setAttributes(array('create_time' => $date, 'pageNo' => $PageNo, 'pageName' => $PageName));
                             $ppname->save(true);
                             $ArticleList = $xml->children()[1];
                             foreach ($ArticleList->children() as $child) {
                                 //echo count($ArticleList->children());
                                 //$IntroTitle= $child->IntroTitle[0];
                                 $Title = $child->Title[0];
                                 //echo $Title;
                                 $Title = preg_replace('/(\\n)/', '', $Title);
                                 $SubTitle = $child->SubTitle[0];
                                 $SubTitle = preg_replace('/(\\n)/', '', $SubTitle);
                                 $Content = $child->Content[0];
                                 //$Content = preg_replace('/(\\n\s*){2,}/','',$Content);
                                 //$Content = preg_replace('/(\\n\s*){2,}/','',$Content);
                                 //$Content=nl2br($Content);
                                 $ImageList = $child->ImageList[0];
                                 $imageCount = count($ImageList->children());
                                 //$Image= $ImageList->Image[0]->attributes()[0];
                                 //echo $Title."<br>";
                                 $PointList = $child->PointList[0];
                                 $x1 = intval($PointList->Point[0]->attributes()[0]);
                                 $y1 = intval($PointList->Point[0]->attributes()[1]);
                                 $x2 = intval($PointList->Point[2]->attributes()[0]);
                                 $y2 = intval($PointList->Point[2]->attributes()[1]);
                                 //echo "x1=".$x1.",y1=".$y1."x2=".$x2.",y2=".$y2;
                                 $node = new stdClass();
                                 $node->title = $Title;
                                 $node->body['und'][0]['value'] = "<p>" . $Content . "</p>";
                                 $node->uid = 1;
                                 $node->type = '_xinwen';
                                 $node->language = 'zh-hans';
                                 $node->status = 1;
                                 //(1 or 0): published or not
                                 $node->promote = 0;
                                 //(1 or 0): promoted to front page
                                 $node->comment = 2;
                                 // 0 = comments disabled, 1 = read only, 2 = read/write
                                 $node->field_pageno['und'][0]['value'] = $PageNo;
                                 $node->field_pagename['und'][0]['value'] = $PageName;
                                 $SubTitle = str_replace(" ", "", $SubTitle);
                                 $node->field_subtitle['und'][0]['value'] = $SubTitle;
                                 $node->field_riq['und'][0]['value'] = $date;
                                 foreach ($ImageList->children() as $key => $image) {
                                     $imageUrl = $image->attributes()[0];
                                     $imageData = new Img();
                                     $imageData->setAttributes(array('url' => $imageUrl, 'article_id' => $article->id));
                                     $imageData->save(true);
                                     if (file_exists($dir . $imageUrl)) {
                                         $url = $dir . $imageUrl;
                                     } else {
                                         if (file_exists($dir . 'm_' . $imageUrl)) {
                                             $url = $dir . 'm_' . $imageUrl;
                                         }
                                     }
                                     Image::thumb($url, $img_file . '/s_' . $imageUrl, 137, 109);
                                     Image::thumb($url, $img_file . '/b_' . $imageUrl, 600, 400);
                                     //$htmlimg="<img  src=http://localhost/admin/assets/article_img/".$date.'/b_'.$imageUrl." style=\"width:100%\"/></a>";
                                     $htmlimg = "<p style=\"text-align: center;\"><img src=\"" . ImgRoot . $date . "/b_" . $imageUrl . " \" style=\"width: 100%;\"/></p>";
                                     //echo $htmlimg;
                                     $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
                                     //if($key==1)
                                     $node->field_suoluetu['und'][0]['value'] = ImgRoot . $date . '/b_' . $imageUrl;
                                     //echo $imageUrl;
                                 }
                                 //存完图片
                                 $node = node_submit($node);
                                 // Prepare node for saving
                                 //print_r($node);
                                 node_save($node);
                                 $coor = new Coor();
                                 $coor->setAttributes(array('create_time' => $date, 'pageNo' => $PageNo, 'nid' => $node->nid, 'x1' => $x1, 'x2' => $x2, 'y1' => $y1, 'y2' => $y2));
                                 $coor->save(true);
                             }
                             //处理完一版的新闻
                         }
                     }
                     //foreach ($xmlfile as $xml)
                 }
             }
             //开始新建图片文件夹
         }
         //还未更新数据
     }
     //电子报数据存在
 }
Beispiel #18
0
/**
 * Builds a new product node
 *
 * @param  node  $node - Starting node object to
 * @param  array $data - Array of data to add to product
 * @return int - node id of new product node
 */
function newproduct($node, $data)
{
    global $mniblogpub_props;
    $pnode = $node;
    $pnode['type'] = 'product';
    $pnode['comment'] = 0;
    $pnode['sell_price'] = $data['ucprice'];
    $pnode['sku'] = "alacarte";
    $pnode['model'] = "alacarte";
    $pnode['shippable'] = 0;
    $pnode = node_submit($pnode);
    node_save($pnode);
    $pnid = $pnode->nid;
    unset($pnode);
    return $pnid;
}
    $a9 = $row["randomfield29"];
    $mynode = array();
    $mynode['title'] = "{$a1}";
    $mynode['type'] = "yourcontenttype";
    // all content types have names which are given at the time of the content type creation. visible at content types page when you drag your mouse over the list of content types
    $mynode['name'] = "thenameoftheusersubmittingthepage";
    //not necessary
    $mynode['body'] = "{$a6}";
    // You can remove the body field from your content type if you want.
    $mynode['status'] = 1;
    //stands for published=1 or unpublished=0 content
    $mynode['uid'] = 121;
    //uid is user id, the user id 1 being the id of the one who makes first id after a drupal installation, uid 1 has all prvilleged, make sure your user id comes with all privileges,preferably use userid 1 to save yourself from the hassle.
    $mynode['promote'] = 0;
    // promote =0 doesn't promote the content to the front page , whereas promote=1 promotes the content to the front page
    $mynode['comment'] = '2';
    // comment 0=off , comment 1=readonly, comment 2=allowed
    $mynode['field_friendlytitle'] = array(array('value' => "{$a4}"));
    // field_friendlytitle is the field I presumably created using cck for the content type. Notice how I am filling in the value for field_friendlytitle using array in an array.
    $mynode['field_firstnameauthor'] = array(array('value' => "{$a2}"));
    $mynode['field_lastnameauthor'] = array(array('value' => "{$a3}"));
    $mynode['field_fieldIcreatedwithcck'] = array(array('value' => "{$a9}"));
    $mynode['field_fieldIcreatedwithcck1'] = array(array('value' => "{$a8}"));
    $mynode['field_fieldIcreatedwithcck2sjhdshjdj'] = array(array('value' => "{$a7}"));
    $mynode['format'] = '2';
    // inputformat, format=1 means Filtered HTML,format=1 means PHP code , format=2 means Full HTML
    //You can also specify $mynode['nid'] followed by a number which will be the nid but I presume that it wont be of use to you at the moment. Not mentioning it will lead to a sequential auto generation whereas mentioning a static number will overwrite the old content each type you save the node!;
    $mynode = node_submit($mynode);
    node_save($mynode);
    unset($mynode);
}
/**
 * Add followup files.
 */
function merci_import_2()
{
    global $user;
    // This determines how many content types will be created per page load.
    // A resonable default has been chosen, but feel free to tweak to suit your needs.
    $limit = 10;
    // No file uploaded, so skip the import.
    if (!$_SESSION['items_file']) {
        return array();
    }
    // Multi-part import
    if (!isset($_SESSION['merci_import_2'])) {
        $csv_file_array = file($_SESSION['items_file']);
        $_SESSION['merci_import_file_position'] = 0;
        $_SESSION['merci_import_2'] = 0;
        $_SESSION['merci_import_2_max'] = count($csv_file_array) - 1;
    }
    // Open import file.
    $handle = fopen($_SESSION['items_file'], 'r');
    fseek($handle, $_SESSION['merci_import_file_position']);
    $ret = array();
    $count = 0;
    while (($data = fgetcsv($handle)) !== FALSE) {
        $count++;
        $_SESSION['merci_import_2']++;
        // Only save if the row count for the data is right.
        if (count($data) == 7) {
            // Node data.
            $item = new stdClass();
            $item->type = $data[0];
            $item->name = $user->name;
            $item->uid = $user->uid;
            $item->title = $data[1];
            $item->body = $data[2];
            $item->status = 1;
            $item->promote = 0;
            $item->sticky = 0;
            // MERCI specific data.
            $merci_settings = merci_load_content_type_settings($item->type);
            $is_resource = $merci_settings->type_setting == 'resource' ? TRUE : FALSE;
            $item->merci_default_availability = $data[3];
            $item->merci_sub_type = MERCI_SUB_TYPE_ITEM;
            // Only resources get per item accounting data.
            $item->merci_late_fee_per_hour = $is_resource ? $data[4] : 0;
            $item->merci_rate_per_hour = $is_resource ? $data[5] : 0;
            $item->merci_fee_free_hours = $is_resource ? $data[6] : 0;
            $item = node_submit($item);
            node_save($item);
            if (isset($item->nid)) {
                drupal_set_message(t("The %type item %title has been added.", array('%type' => $item->type, '%title' => $item->title)));
            }
        }
        // Jump out of the loop here and do another cycle.  Save
        // where we're at in the CSV file.
        if ($count >= $limit) {
            $_SESSION['merci_import_file_position'] = ftell($handle);
            break;
        }
    }
    // No more lines in the file, import is done.  Clean up.
    if (!fgets($handle)) {
        fclose($handle);
        unset($_SESSION['merci_import_file_position']);
        unset($_SESSION['merci_import_2']);
        unset($_SESSION['merci_import_2_max']);
        file_delete($_SESSION['items_file']);
        unset($_SESSION['items_file']);
        return $ret;
    }
    fclose($handle);
    $ret['#finished'] = $_SESSION['merci_import_2'] / $_SESSION['merci_import_2_max'];
    return $ret;
}
Beispiel #21
0
$node->field_heart_problems['und'][0]['value'] = protect($heart);
// Stomach bowel problems
$node->field_stomach_bowel_problems['und'][0]['value'] = protect($stomach);
// Suffer from mirgraines
$node->field_suffer_from_migraines['und'][0]['value'] = protect($migraines);
// Urinary kidney problems
$node->field_urinary_kidney_problems['und'][0]['value'] = protect($urinary);
// Nervous system problems
$node->field_nervous_system_problems['und'][0]['value'] = protect($nervous);
// Muscle bone joint problems
$node->field_muscles_bone_joint_problem['und'][0]['value'] = protect($muscle);
// Eye problems
$node->field_eye_problems['und'][0]['value'] = protect($eye);
// Ear throat nose problems
$node->field_ear_throat_nose_problems['und'][0]['value'] = protect($ear);
// Tropical diseases
$node->field_tropical_diseases['und'][0]['value'] = protect($tropical);
// Any other problems
$node->field_any_other_problems['und'][0]['value'] = protect($otherproblems);
// Problem details
$node->field_problem_details['und'][0]['value'] = protect($medicalMore);
// End of fields
# $node->field_test['und'][0]['value'] = $ethnicorigin;
// I prefer using pathauto, which would override the below path
$path = 'node_created_on' . date('YmdHis');
$node->path = array('alias' => $path);
if ($node = node_submit($node)) {
    // Prepare node for saving
    node_save($node);
    echo "Node with nid " . $node->nid . " saved!\n";
}
function insert_content($archive_data)
{
    $handle = fopen($archive_data, "r");
    $headers = fgetcsv($handle, 4096);
    //print_r($theHeaders);
    while ($line = fgetcsv($handle, 4096)) {
        //print_r($line);
        $node = array();
        $postpone = array();
        foreach ($line as $key => $value) {
            translate_value($key, $value, $headers, $node, $postpone);
        }
        // defaults for all imported nodes. feel free to change
        $node['format'] = 3;
        $node['status'] = 1;
        $node['promote'] = 0;
        $node['sticky'] = 0;
        $log = 'Imported node using import script at ' . date('g:i:s a');
        $node['log'] = $log;
        if ($node['title']) {
            $node = (object) $node;
            $nodes_array['pre'][] = $node;
            // adding to node array for debug info
            node_validate($node);
            $error = form_get_errors();
            if (!$error) {
                $node = node_submit($node);
                // comment this out to test first before changing the database
                foreach ($postpone as $key => $value) {
                    switch ($key) {
                        case 'og_groups':
                            $node->og_public = 0;
                            $node->og_groups = $value;
                            break;
                        case 'og_groups_names':
                            $node->og_public = 0;
                            $node->og_groups_names = $value;
                            break;
                    }
                }
                node_save($node);
                // comment this out to test first before changing the database
            } else {
                print_r($error);
            }
            $nodes_array['post'][] = $node;
            // adding to "post" node array for debug info
        }
    }
    // end while
    /*
    The nodes_array variable includes two arrays: pre and post. This shows you how your nodes look before Drupal takes a look at them (pre), and after the node submission process takes place (post). This helps to debug any problems you're having with field values being stored inccorectly
    
    Of course, if you  commented out the node_submit and node_save comamnds, (post) will not be as useful.
    */
    return $nodes_array;
}