PageRenderTime 81ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/acs-content-repository/tcl/content-item-procs.tcl

https://github.com/iuri/PWTI
TCL | 896 lines | 766 code | 101 blank | 29 comment | 36 complexity | 955cae0e4ec1d5fe2cefee9cbec30614 MD5 | raw file
  1. ad_library {
  2. Tcl API for cr_items in the content repository
  3. @author Dave Bauer (dave@thedesignexperience.org)
  4. @author Jun Yamog
  5. @creation-date 2004-05-28
  6. @cvs-id $Id: content-item-procs.tcl,v 1.21.4.1 2010/06/09 16:56:31 daveb Exp $
  7. }
  8. namespace eval ::content::item {}
  9. ad_proc -public ::content::item::new {
  10. -name:required
  11. {-parent_id ""}
  12. {-item_id ""}
  13. {-locale ""}
  14. {-creation_date ""}
  15. {-creation_user ""}
  16. {-context_id ""}
  17. {-package_id ""}
  18. {-creation_ip ""}
  19. {-item_subtype "content_item"}
  20. {-content_type "content_revision"}
  21. {-title ""}
  22. {-description ""}
  23. {-mime_type ""}
  24. {-nls_language ""}
  25. {-text ""}
  26. {-data ""}
  27. {-relation_tag ""}
  28. {-is_live "f"}
  29. {-storage_type "file"}
  30. {-attributes ""}
  31. {-tmp_filename ""}
  32. } {
  33. @author Dave Bauer (dave@thedesignexperience.org)
  34. @creation-date 2004-05-28
  35. Create a new content item This proc creates versioned content
  36. items where content_type iscontent_revision or subtypes of content
  37. revision. There are procedures for each other base content
  38. item. This procdedure uses package_instantiate object. Under
  39. PostgreSQL the object_type new function must be registered with
  40. define_function_args.
  41. @param name
  42. @param item_id - item_id of this content_item. If this is not
  43. specified an item_id will be generated automatically
  44. @param parent_id - parent object of this content_item
  45. @param item_subtype
  46. @param content_type - content_revision or subtype of content_revision
  47. @param context_id - Context of the item. usually used in conjunction with permissions.
  48. @param package_id - Package ID of the object
  49. @param creation_user -
  50. @param creation_ip -
  51. @param creation_date - defaults to current date and time
  52. @param storage_type - file, lob, or text (postgresql only)
  53. @param locale -
  54. @param title - title of content_revision to be created
  55. @param description of content_revision to be created
  56. @param text - text of content revision to be created
  57. @param tmp_filename file containing content to be added to new revision. Caller is responsible to handle cleaning up the tmp file
  58. @param nls_language - ???
  59. @param data - ???
  60. @param attributes - A list of lists ofpairs of additional attributes and
  61. their values to pass to the constructor. Each pair is a list of two
  62. elements: key => value such as
  63. [list [list attribute value] [list attribute value]]
  64. @return item_id of the new content item
  65. @see content::symlink::new content::extlink::new content::folder::new
  66. } {
  67. if {$creation_user eq ""} {
  68. set creation_user [ad_conn user_id]
  69. }
  70. if {$creation_ip eq ""} {
  71. set creation_ip [ad_conn peeraddr]
  72. }
  73. if {$package_id eq ""} {
  74. set package_id [ad_conn package_id]
  75. }
  76. set var_list [list]
  77. lappend var_list \
  78. [list name $name] \
  79. [list parent_id $parent_id ] \
  80. [list item_id $item_id ] \
  81. [list locale $locale ] \
  82. [list creation_date $creation_date ] \
  83. [list creation_user $creation_user ] \
  84. [list context_id $context_id ] \
  85. [list package_id $package_id ] \
  86. [list creation_ip $creation_ip ] \
  87. [list item_subtype $item_subtype ] \
  88. [list content_type $content_type ] \
  89. [list mime_type $mime_type ] \
  90. [list nls_language $nls_language ] \
  91. [list relation_tag $relation_tag ] \
  92. [list is_live $is_live ] \
  93. [list storage_type $storage_type]
  94. # we don't pass title, text, or data to content_item__new
  95. # because the magic revision creation of the pl/sql proc does
  96. # not create a proper subtype of content revision, also it
  97. # can't set attributes of an extended type
  98. # the content type is not the object type of the cr_item so we pass in
  99. # the cr_item subtype here and content_type as part of
  100. # var_list
  101. db_transaction {
  102. # An explict lock was necessary for PostgreSQL between 8.0 and
  103. # 8.2; left the following statement here for documentary purposes
  104. #
  105. # db_dml lock_objects "LOCK TABLE acs_objects IN SHARE ROW EXCLUSIVE MODE"
  106. set item_id [package_exec_plsql \
  107. -var_list $var_list \
  108. content_item new]
  109. # if we have attributes we pass in everything
  110. # and create a revision with all subtype attributes that were
  111. # passed in
  112. # since we can't rely on content_item__new to create a revision
  113. # we have to pass is_live to content::revision::new and
  114. # set the live revision there
  115. if {[exists_and_not_null title] \
  116. || [exists_and_not_null text] \
  117. || [exists_and_not_null data] \
  118. || [exists_and_not_null tmp_filename] \
  119. || [llength $attributes]} {
  120. content::revision::new \
  121. -item_id $item_id \
  122. -title $title \
  123. -description $description \
  124. -content $text \
  125. -mime_type $mime_type \
  126. -content_type $content_type \
  127. -is_live $is_live \
  128. -package_id $package_id \
  129. -creation_user $creation_user \
  130. -creation_ip $creation_ip \
  131. -creation_date $creation_date \
  132. -nls_language $nls_language \
  133. -tmp_filename $tmp_filename \
  134. -attributes $attributes
  135. }
  136. }
  137. return $item_id
  138. }
  139. ad_proc -public ::content::item::delete {
  140. -item_id:required
  141. } {
  142. @author Dave Bauer (dave@thedesignexperience.org)
  143. @creation-date 2004-05-28
  144. Delete a content item from the database. If the content item
  145. to delete has children content items referencing its parent
  146. via acs_objects.context_id then this proc will fail.
  147. @param item_id
  148. } {
  149. return [package_exec_plsql \
  150. -var_list [list [list item_id $item_id]] \
  151. content_item del]
  152. }
  153. ad_proc -public ::content::item::rename {
  154. -item_id:required
  155. -name:required
  156. } {
  157. @author Dave Bauer (dave@thedesignexperience.org)
  158. @creation-date 2004-05-28
  159. Rename a content item.
  160. @param item_id
  161. @param name
  162. } {
  163. return [package_exec_plsql \
  164. -var_list [list \
  165. [list item_id $item_id] \
  166. [list name $name]
  167. ] \
  168. content_item edit_name]
  169. }
  170. ad_proc -public ::content::item::move {
  171. -item_id:required
  172. -target_folder_id:required
  173. {-name}
  174. } {
  175. @author Dave Bauer (dave@thedesignexperience.org)
  176. @creation-date 2004-05-28
  177. @param item_id item to move
  178. @param new_parent_id new parent item
  179. @param name new name, allows move with rename
  180. } {
  181. set var_list [list \
  182. [list item_id $item_id] \
  183. [list target_folder_id $target_folder_id] ]
  184. if {[exists_and_not_null name]} {
  185. lappend var_list [list name $name]
  186. }
  187. return [package_exec_plsql \
  188. -var_list $var_list \
  189. content_item move]
  190. }
  191. ad_proc -public ::content::item::get {
  192. -item_id:required
  193. {-revision "live"}
  194. {-array_name "content_item"}
  195. } {
  196. @author Dave Bauer (dave@thedesignexperience.org)
  197. @creation-date 2004-05-28
  198. @param item_id
  199. @param revision live, latest, or best (live if it exists, otherwise latest)
  200. @param array_name name of array to upvar content into
  201. @return upvars array_name containing all attributes of the content
  202. type except content
  203. @return returns 0 if item does not exists or 1 if query was sucessful
  204. @error
  205. } {
  206. upvar $array_name local_array
  207. if {[lsearch {live latest} $revision] == -1} {
  208. error "content::item::get revision was '${revision}'. It must be 'live' or 'latest'"
  209. }
  210. set content_type [content_type -item_id $item_id]
  211. if {$content_type eq ""} {
  212. # content_type query was unsucessful, item does not exist
  213. return 0
  214. }
  215. if {"content_folder" eq $content_type} {
  216. return [db_0or1row get_item_folder "" -column_array local_array]
  217. }
  218. set table_name [db_string get_table_name "select table_name from acs_object_types where object_type=:content_type"]
  219. set table_name "${table_name}x"
  220. # get attributes of the content_item use the content_typex view
  221. return [db_0or1row get_item "" -column_array local_array]
  222. }
  223. ad_proc -public ::content::item::update {
  224. -item_id:required
  225. -attributes:required
  226. } {
  227. Update standard non-versioned content item attributes (cr_items)
  228. Valid attributes: name parent_id latest_revision live_revision locale publish_status
  229. @author Dave Bauer (dave@thedesignexperience.org)
  230. @creation-date 2004-06-04
  231. @param item_id item to update
  232. @param attributes A list of pairs of additional attributes and their values to get. Each pair is a list of two elements: key => value
  233. @return
  234. @error
  235. } {
  236. # do not allow update of item_id, storage_location, storage_type,
  237. # content_type, or tree_sortkey
  238. set valid_attributes [list name parent_id latest_revision live_revision locale publish_status]
  239. set update_text ""
  240. foreach {attribute_list} $attributes {
  241. set attribute [lindex $attribute_list 0]
  242. set value [lindex $attribute_list 1]
  243. if {[lsearch $valid_attributes $attribute] > -1} {
  244. # create local variable to use for binding
  245. set $attribute $value
  246. if {$update_text ne ""} {
  247. append update_text ","
  248. }
  249. append update_text " ${attribute} = :${attribute} "
  250. }
  251. }
  252. if {$update_text ne ""} {
  253. # we have valid attributes, update them
  254. set query_text "update cr_items set ${update_text} where item_id=:item_id"
  255. db_dml item_update $query_text
  256. }
  257. }
  258. ad_proc -public ::content::item::content_type {
  259. -item_id:required
  260. } {
  261. @public get_content_type
  262. Retrieves the content type of the item. If the item does not exist,
  263. returns an empty string.
  264. @param item_id The item_id of the content item
  265. @return The content type of the item, or an empty string if no such
  266. item exists
  267. } {
  268. return [package_exec_plsql \
  269. -var_list [list [list item_id $item_id]] \
  270. content_item get_content_type]
  271. }
  272. ad_proc -public content::item::get_content_type {
  273. -item_id:required
  274. } {
  275. Retrieves the content type of the item. If the item does not exist,
  276. returns an empty string.
  277. @param item_id The item_id of the content item
  278. @return The content type of the item, or an empty string if no such
  279. item exists
  280. } {
  281. return [package_exec_plsql -var_list [list \
  282. [list item_id $item_id ] \
  283. ] content_item get_content_type]
  284. }
  285. ad_proc -public content::item::get_context {
  286. -item_id:required
  287. } {
  288. @param item_id
  289. @return NUMBER(38)
  290. } {
  291. return [package_exec_plsql -var_list [list \
  292. [list item_id $item_id ] \
  293. ] content_item get_context]
  294. }
  295. ad_proc -public content::item::get_id {
  296. -item_path:required
  297. {-root_folder_id ""}
  298. {-resolve_index ""}
  299. } {
  300. Looks up the item_path starting with the root folder and returns item_id for that
  301. content item or empty, if none exists
  302. @param item_path
  303. @param root_folder_id
  304. @param resolve_index
  305. @return The item_id of the found item, or the empty string on failure
  306. } {
  307. return [package_exec_plsql -var_list [list \
  308. [list item_path $item_path ] \
  309. [list root_folder_id $root_folder_id ] \
  310. [list resolve_index $resolve_index ] \
  311. ] content_item get_id]
  312. }
  313. ad_proc -public content::item::get_best_revision {
  314. -item_id:required
  315. } {
  316. Attempts to retrieve the live revision for the item. If no live revision
  317. exists, attempts to retrieve the latest revision. If the item has no
  318. revisions, returns an empty string.
  319. @param item_id The item_id of the content item
  320. @return The best revision_id for the item, or an empty string if no
  321. revisions exist
  322. @see content::revision::item_id
  323. @see content::item::get_live_revision
  324. @see content::item::get_latest_revision
  325. } {
  326. return [package_exec_plsql -var_list [list \
  327. [list item_id $item_id ] \
  328. ] content_item get_best_revision]
  329. }
  330. ad_proc -public content::item::get_latest_revision {
  331. -item_id:required
  332. } {
  333. Retrieves the latest revision for the item. If the item has no live
  334. revision, returns an empty string.
  335. @param item_id The item_id of the content item
  336. @return The latest revision_id for the item, or an empty string if no
  337. revisions exist
  338. @see content::revision::item_id
  339. @see content::item::get_best_revision
  340. @see content::item::get_live_revision
  341. } {
  342. return [package_exec_plsql -var_list [list \
  343. [list item_id $item_id ] \
  344. ] content_item get_latest_revision]
  345. }
  346. ad_proc -public content::item::get_live_revision {
  347. -item_id:required
  348. } {
  349. Retrieves the live revision for the item. If the item has no live
  350. revision, returns an empty string.
  351. @param item_id The item_id of the content item
  352. @return The live revision_id for the item, or an empty string if no
  353. live revision exists
  354. @see content::revision::item_id
  355. @see content::item::get_best_revision
  356. @see content::item::get_latest_revision
  357. } {
  358. return [package_exec_plsql -var_list [list \
  359. [list item_id $item_id ] \
  360. ] content_item get_live_revision]
  361. }
  362. ad_proc -public content::item::get_parent_folder {
  363. -item_id:required
  364. } {
  365. @param item_id
  366. @return NUMBER(38)
  367. } {
  368. return [package_exec_plsql -var_list [list \
  369. [list item_id $item_id ] \
  370. ] content_item get_parent_folder]
  371. }
  372. ad_proc -public content::item::get_path {
  373. -item_id:required
  374. {-root_folder_id ""}
  375. } {
  376. @param item_id
  377. @param root_folder_id
  378. @return VARCHAR2
  379. } {
  380. return [package_exec_plsql -var_list [list \
  381. [list item_id $item_id ] \
  382. [list root_folder_id $root_folder_id ] \
  383. ] content_item get_path]
  384. }
  385. ad_proc -public content::item::get_publish_date {
  386. -item_id:required
  387. {-is_live ""}
  388. } {
  389. @param item_id
  390. @param is_live
  391. @return DATE
  392. } {
  393. return [package_exec_plsql -var_list [list \
  394. [list item_id $item_id ] \
  395. [list is_live $is_live ] \
  396. ] content_item get_publish_date]
  397. }
  398. ad_proc -public content::item::get_revision_count {
  399. -item_id:required
  400. } {
  401. @param item_id
  402. @return NUMBER
  403. } {
  404. return [package_exec_plsql -var_list [list \
  405. [list item_id $item_id ] \
  406. ] content_item get_revision_count]
  407. }
  408. ad_proc -public content::item::get_root_folder {
  409. {-item_id ""}
  410. } {
  411. @param item_id
  412. @return NUMBER(38)
  413. } {
  414. return [package_exec_plsql -var_list [list \
  415. [list item_id $item_id ] \
  416. ] content_item get_root_folder]
  417. }
  418. ad_proc -public content::item::get_template {
  419. -item_id:required
  420. -use_context:required
  421. } {
  422. Retrieves the template which can be used to render the item. If there is
  423. a template registered directly to the item, returns the id of that template.
  424. Otherwise, returns the id of the default template registered to the item's
  425. content_type. Returns an empty string on failure.
  426. @param item_id The item_id
  427. @param context The context in which the template will be used (e.g. public)
  428. @return The template_id of the template which can be used to render the
  429. item, or an empty string on failure
  430. } {
  431. return [package_exec_plsql -var_list [list \
  432. [list item_id $item_id ] \
  433. [list use_context $use_context ] \
  434. ] content_item get_template]
  435. }
  436. ad_proc -public content::item::get_title {
  437. -item_id:required
  438. {-is_live ""}
  439. } {
  440. Get the title for the item. If a live revision for the item exists,
  441. use the live revision. Otherwise, use the latest revision.
  442. @param item_id The item_id of the content item
  443. @param is_live
  444. @return The title of the item
  445. @see content::item::get_best_revision
  446. @see content::item::get_title
  447. } {
  448. return [package_exec_plsql -var_list [list \
  449. [list item_id $item_id ] \
  450. [list is_live $is_live ] \
  451. ] content_item get_title]
  452. }
  453. ad_proc -public content::item::get_virtual_path {
  454. -item_id:required
  455. {-root_folder_id ""}
  456. } {
  457. Retrieves the relative path to the item. The path is relative to the
  458. page root, and has no extension (Example: "/foo/bar/baz").
  459. @param item_id The item_id for the item, for which the path is computed
  460. @param root_folder_id Starts path resolution from this folder.
  461. Defaults to the root of the sitemap (when null).
  462. @return The path to the item, or an empty string on failure
  463. } {
  464. return [package_exec_plsql -var_list [list \
  465. [list item_id $item_id ] \
  466. [list root_folder_id $root_folder_id ] \
  467. ] content_item get_virtual_path]
  468. }
  469. ad_proc -public content::item::is_index_page {
  470. -item_id:required
  471. -folder_id:required
  472. } {
  473. @param item_id
  474. @param folder_id
  475. @return VARCHAR2
  476. } {
  477. return [package_exec_plsql -var_list [list \
  478. [list item_id $item_id ] \
  479. [list folder_id $folder_id ] \
  480. ] content_item is_index_page]
  481. }
  482. ad_proc -public content::item::is_publishable {
  483. -item_id:required
  484. } {
  485. Determine if the item is publishable. The item is publishable only
  486. if:
  487. <ul>
  488. <li>All child relations, as well as item relations, are satisfied
  489. (according to min_n and max_n)</li>
  490. <li>The workflow (if any) for the item is finished</li>
  491. </ul>
  492. @param item_id The item_id of the content item
  493. @see content::item::is_publishable
  494. @return 't' if the item is publishable, 'f' otherwise
  495. } {
  496. return [package_exec_plsql -var_list [list \
  497. [list item_id $item_id ] \
  498. ] content_item is_publishable]
  499. }
  500. ad_proc -public content::item::is_published {
  501. -item_id:required
  502. } {
  503. @param item_id
  504. @return CHAR
  505. } {
  506. return [package_exec_plsql -var_list [list \
  507. [list item_id $item_id ] \
  508. ] content_item is_published]
  509. }
  510. ad_proc -public content::item::is_subclass {
  511. -object_type:required
  512. -supertype:required
  513. } {
  514. @param object_type
  515. @param supertype
  516. @return CHAR
  517. } {
  518. return [package_exec_plsql -var_list [list \
  519. [list object_type $object_type ] \
  520. [list supertype $supertype ] \
  521. ] content_item is_subclass]
  522. }
  523. ad_proc -public content::item::is_valid_child {
  524. -item_id:required
  525. -content_type:required
  526. {-relation_tag ""}
  527. } {
  528. @param item_id
  529. @param content_type
  530. @param relation_tag
  531. @return CHAR
  532. } {
  533. return [package_exec_plsql -var_list [list \
  534. [list item_id $item_id ] \
  535. [list content_type $content_type ] \
  536. [list relation_tag $relation_tag ] \
  537. ] content_item is_valid_child]
  538. }
  539. ad_proc -public content::item::register_template {
  540. -item_id:required
  541. -template_id:required
  542. -use_context:required
  543. } {
  544. @param item_id
  545. @param template_id
  546. @param use_context
  547. } {
  548. return [package_exec_plsql -var_list [list \
  549. [list item_id $item_id ] \
  550. [list template_id $template_id ] \
  551. [list use_context $use_context ] \
  552. ] content_item register_template]
  553. }
  554. ad_proc -public content::item::relate {
  555. -item_id:required
  556. -object_id:required
  557. {-relation_tag ""}
  558. {-order_n ""}
  559. {-relation_type "cr_item_rel"}
  560. } {
  561. @param item_id
  562. @param object_id
  563. @param relation_tag
  564. @param order_n
  565. @param relation_type
  566. @return NUMBER(38)
  567. } {
  568. return [package_exec_plsql -var_list [list \
  569. [list item_id $item_id ] \
  570. [list object_id $object_id ] \
  571. [list relation_tag $relation_tag ] \
  572. [list order_n $order_n ] \
  573. [list relation_type $relation_type ] \
  574. ] content_item relate]
  575. }
  576. ad_proc -public content::item::set_live_revision {
  577. -revision_id:required
  578. {-publish_status "ready"}
  579. } {
  580. @param revision_id
  581. @param publish_status
  582. } {
  583. return [package_exec_plsql -var_list [list \
  584. [list revision_id $revision_id ] \
  585. [list publish_status $publish_status ] \
  586. ] content_item set_live_revision]
  587. }
  588. ad_proc -public content::item::set_release_period {
  589. -item_id:required
  590. {-start_when ""}
  591. {-end_when ""}
  592. } {
  593. @param item_id
  594. @param start_when
  595. @param end_when
  596. } {
  597. return [package_exec_plsql -var_list [list \
  598. [list item_id $item_id ] \
  599. [list start_when $start_when ] \
  600. [list end_when $end_when ] \
  601. ] content_item set_release_period]
  602. }
  603. ad_proc -public content::item::unregister_template {
  604. -item_id:required
  605. {-template_id ""}
  606. {-use_context ""}
  607. } {
  608. @param item_id
  609. @param template_id
  610. @param use_context
  611. } {
  612. return [package_exec_plsql -var_list [list \
  613. [list item_id $item_id ] \
  614. [list template_id $template_id ] \
  615. [list use_context $use_context ] \
  616. ] content_item unregister_template]
  617. }
  618. ad_proc -public content::item::unrelate {
  619. -rel_id:required
  620. } {
  621. @param rel_id
  622. } {
  623. return [package_exec_plsql -var_list [list \
  624. [list rel_id $rel_id ] \
  625. ] content_item unrelate]
  626. }
  627. ad_proc -public content::item::unset_live_revision {
  628. -item_id:required
  629. } {
  630. @param item_id
  631. } {
  632. return [package_exec_plsql -var_list [list \
  633. [list item_id $item_id ] \
  634. ] content_item unset_live_revision]
  635. }
  636. ad_proc -public content::item::copy {
  637. -item_id:required
  638. -target_folder_id:required
  639. {-creation_user ""}
  640. {-creation_ip ""}
  641. {-name ""}
  642. } {
  643. @author Jun Yamog
  644. @creation-date 2004-06-27
  645. copy a content item to a new content item
  646. @param item_id - item_id of the content to be copied from. source content item
  647. @param target_folder_id - destination folder where the new content item is be passed
  648. @param creation_user -
  649. @param creation_ip -
  650. @param name - the name of the new item, useful if you are copying in the same folder.
  651. @return item_id of the new copied item
  652. } {
  653. return [package_exec_plsql \
  654. -var_list [list \
  655. [list item_id $item_id] \
  656. [list target_folder_id $target_folder_id] \
  657. [list creation_user $creation_user] \
  658. [list creation_ip $creation_ip] \
  659. [list name $name]] \
  660. content_item copy]
  661. }
  662. ad_proc -public content::item::upload_file {
  663. {-upload_file:required}
  664. {-parent_id:required}
  665. {-package_id ""}
  666. } {
  667. Store the file uploaded under the parent_id if a file was uploaded
  668. @author Malte Sussdorff (sussdorff@sussdorff.de)
  669. @creation-date 2005-06-21
  670. @param upload_file
  671. @param parent_id
  672. @return the revision_id of the generated item
  673. @error
  674. } {
  675. set filename [template::util::file::get_property filename $upload_file]
  676. if {$filename ne "" } {
  677. set tmp_filename [template::util::file::get_property tmp_filename $upload_file]
  678. set mime_type [template::util::file::get_property mime_type $upload_file]
  679. set tmp_size [file size $tmp_filename]
  680. set extension [file extension $filename]
  681. if {![exists_and_not_null title]} {
  682. # maltes: The following regsub garbles the title and consequently the filename as well.
  683. # "info_c+w.zip" will become "info_c+"
  684. # This is bad, first of all because a letter is missing entirely. Additionally
  685. # the title in itself should be the original filename, after all this is what
  686. # the user uploaded, not something stripped of its extension.
  687. # So I commented this out until someone can either fix the regsub but more importantly
  688. # can explain why the title should not contain the extension.
  689. # DRB: removing the explicit "." isn't sufficient because the "." in the
  690. # extension also matches any char unless it is escaped. Like Malte, I
  691. # see no reason to get rid of the extension in the title anyway ...
  692. # regsub -all ".${extension}\$" $filename "" title
  693. set title $filename
  694. }
  695. set existing_filenames [db_list get_parent_existing_filenames {}]
  696. set filename [util_text_to_url \
  697. -text ${title} -existing_urls "$existing_filenames" -replacement "_"]
  698. set revision_id [cr_import_content \
  699. -storage_type "file" -title $title -package_id $package_id $parent_id $tmp_filename $tmp_size $mime_type $filename]
  700. content::item::set_live_revision -revision_id $revision_id
  701. return $revision_id
  702. }
  703. }
  704. ad_proc -public content::item::get_id_by_name {
  705. {-name:required}
  706. {-parent_id:required}
  707. } {
  708. Returns The item_id of the a content item with the passed in name
  709. @param name Name of the content item
  710. @param parent_id Parent_id of the content item
  711. @return The item_id belonging to the name, empty string if no item_id was found
  712. } {
  713. return [db_string get_item_id_by_name {} -default ""]
  714. }
  715. #
  716. #
  717. #
  718. ad_proc -public ::content::item::get_publish_status {
  719. -item_id:required
  720. } {
  721. Get the publish status of the item. The publish status will be one of
  722. the following:
  723. <ul>
  724. <li><tt>production</tt> - The item is still in production. The workflow
  725. (if any) is not finished, and the item has no live revision.</li>
  726. <li><tt>ready</tt> - The item is ready for publishing</li>
  727. <li><tt>live</tt> - The item has been published</li>
  728. <li><tt>expired</tt> - The item has been published in the past, but
  729. its publication has expired</li>
  730. </ul>
  731. @param item_id The item_id of the content item
  732. @return The publish status of the item, or the empty string on failure
  733. @see proc content::item::is_publishable
  734. } {
  735. set publish_status [db_string gps_get_publish_status \
  736. "select publish_status from cr_items where item_id = :item_id"]
  737. return $publish_status
  738. }