require_once 'auth_tutorial7.php';
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $cascade->getAsset(a\Page::TYPE, "389b03188b7ffe83164c931405d3704f")->dump();
    u\DebugUtility::out(u\StringUtility::boolToString($cascade->getAsset(a\DataBlock::TYPE, "ffa200f88b7ffe8330d802d73f3adfc3")->getMetadata()->isDynamicMetadataFieldRequired("checkbox")));
    $block_id = "388f033b8b7ffe83164c9314c23a3f8f";
    $block = $cascade->getAsset(a\FeedBlock::TYPE, $block_id);
    $m = $block->getMetadata();
    u\DebugUtility::out(u\StringUtility::boolToString($m->isAuthorFieldRequired()));
    u\DebugUtility::out(u\StringUtility::boolToString($m->isDescriptionFieldRequired()));
    // wired fields
    echo "Author: ", $m->getAuthor(), BR, "Display name: ", $m->getDisplayName(), BR, "End date: ", u\StringUtility::getCoalescedString($m->getEndDate()), BR . HR;
    // dynamic fields
    $ms = $block->getMetadataSet();
    // text
    $field_name = "text";
    echo "Testing {$field_name}", BR;
    if ($m->hasDynamicField($field_name)) {
        $text = $m->getDynamicField($field_name);
        u\DebugUtility::dump($text->getFieldValue()->getValues());
        // passing in a single string as value
        $m->setDynamicFieldValue($field_name, "New string used in text");
    }
    // radio
    /*
    <radio>
        <item>Male</item>
     u\DebugUtility::dump($tb->getProperty());
     echo $tb->getPropertyName() . BR;
     //u\DebugUtility::dump( $tb->getService() );
     echo $tb->getSiteId() . BR;
     echo $tb->getSiteName() . BR;
     u\DebugUtility::dump($tb->getSubscribers());
     echo $tb->getType() . BR;
     echo $tb->getText() . BR;
     echo $tb->getLastModifiedBy() . BR;
     echo $tb->getLastModifiedDate() . BR;
     // folder
     //$tb->getParentContainer()->dump( true );
     echo $tb->getParentContainerId() . BR;
     echo $tb->getParentContainerPath() . BR;
     echo u\StringUtility::getCoalescedString($tb->getExpirationFolderId()), BR;
     echo u\StringUtility::getCoalescedString($tb->getExpirationFolderPath()), BR;
     echo u\StringUtility::boolToString($tb->getExpirationFolderRecycled()), BR;
     if ($mode != 'all') {
         break;
     }
 case 'metadata':
     echo $tb->getCreatedBy() . BR;
     echo $tb->getCreatedDate() . BR;
     $field_name = "text";
     if ($tb->hasDynamicField($field_name)) {
         $df = $tb->getDynamicField($field_name);
     } else {
         echo "The dynamic field {$field_name} does not exist", BR;
     }
     if ($tb->hasDynamicFields()) {
         u\DebugUtility::dump($tb->getDynamicFields());
try {
    // create an identifier stdClass object
    $id_std = $service->createId(a\Folder::TYPE, "cc1e51808b7ffe8364375ac78ba27f05");
    u\DebugUtility::dump($id_std);
    // create a Child object
    $id_child = new p\Child($id_std);
    u\DebugUtility::dump($id_child);
    u\DebugUtility::dump($id_child->toStdClass());
    // read the asset
    $folder = $id_child->getAsset($service);
    // list the content of the folder
    $children = $folder->getChildren();
    u\DebugUtility::dump($children);
    // display each child
    foreach ($children as $child) {
        $child->display();
        echo $child->getId(), BR;
        echo $child->getType(), BR;
        echo $child->getPathPath(), BR;
        echo $child->getPathSiteId(), BR;
        echo u\StringUtility::getCoalescedString($child->getPathSiteName()), BR;
        echo u\StringUtility::boolToString($child->getRecycled()), BR;
        u\DebugUtility::dump($child->getPath()->toStdClass());
    }
    u\ReflectionUtility::showMethodSignatures("cascade_ws_property\\Identifier");
    u\ReflectionUtility::showMethodSignatures("cascade_ws_property\\Path");
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
     echo S_PRE;
     var_dump($t->getPageRegionStdForPageConfiguration());
     echo E_PRE;
     if ($mode != 'all') {
         break;
     }
 case 'get':
     echo $t->getCreatedBy(), BR;
     echo $t->getCreatedDate(), BR;
     echo u\StringUtility::getCoalescedString($t->getFormatId()), BR;
     echo u\StringUtility::getCoalescedString($t->getFormatPath()), BR;
     echo u\StringUtility::boolToString($t->getFormatRecycled()), BR;
     echo $t->getLastModifiedBy(), BR;
     echo $t->getLastModifiedDate(), BR;
     echo u\StringUtility::getCoalescedString($t->getTargetId()), BR;
     echo u\StringUtility::getCoalescedString($t->getTargetPath()), BR;
     $f = $t->getFormat();
     if ($f != NULL) {
         $f->display();
     }
     echo S_PRE;
     //u\DebugUtility::dump( $t->getPageRegion( 'STORAGE' ) );
     echo E_PRE;
     $block = $t->getPageRegionBlock('STORAGE');
     if (isset($block)) {
         $block->dump();
     }
     $format = $t->getPageRegionFormat('STORAGE');
     //echo $t->getXml(), BR;
     echo u\StringUtility::boolToString($t->hasPageRegion('STORAGE')), BR;
     if (isset($format)) {
 // folder-index
 $ifb = $cascade->getAsset(a\IndexBlock::TYPE, $id);
 switch ($mode) {
     case 'all':
     case 'display':
         $ifb->display();
         if ($mode != 'all') {
             break;
         }
     case 'dump':
         $ifb->dump(true);
         if ($mode != 'all') {
             break;
         }
     case 'get':
         echo c\L::ID . $ifb->getId() . BR . "Index type: " . $ifb->getIndexBlockType() . BR . "Append calling page data: " . u\StringUtility::boolToString($ifb->getAppendCallingPageData()) . BR . "Depth of index: " . $ifb->getDepthOfIndex() . BR . "Index access rights: " . u\StringUtility::boolToString($ifb->getIndexAccessRights()) . BR . "Index blocks: " . u\StringUtility::boolToString($ifb->getIndexBlocks()) . BR . "Indexed content type ID: " . u\StringUtility::getCoalescedString($ifb->getIndexedContentTypeId()) . BR . "Indexed content type path: " . u\StringUtility::getCoalescedString($ifb->getIndexedContentTypePath()) . BR . "Indexed folder ID: " . u\StringUtility::getCoalescedString($ifb->getIndexedFolderId()) . BR . "Indexed folder path: " . u\StringUtility::getCoalescedString($ifb->getIndexedFolderPath()) . BR . "Indexed folder recycled: " . u\StringUtility::boolToString($ifb->getIndexedFolderRecycled()) . BR . "Index files: " . u\StringUtility::boolToString($ifb->getIndexFiles()) . BR . "Index links: " . u\StringUtility::boolToString($ifb->getIndexLinks()) . BR . "Index pages: " . u\StringUtility::boolToString($ifb->getIndexPages()) . BR . "Index regular content: " . u\StringUtility::boolToString($ifb->getIndexRegularContent()) . BR . "Index system metadata: " . u\StringUtility::boolToString($ifb->getIndexSystemMetadata()) . BR . "Index user info: " . u\StringUtility::boolToString($ifb->getIndexUserInfo()) . BR . "Index user metadata: " . u\StringUtility::boolToString($ifb->getIndexUserMetadata()) . BR . "Index workflow info: " . u\StringUtility::boolToString($ifb->getIndexWorkflowInfo()) . BR . "Max rendered assets: " . $ifb->getMaxRenderedAssets() . BR . "Page xml: " . $ifb->getPageXML() . BR . "Rendering behavior: " . $ifb->getRenderingBehavior() . BR . "Sort method: " . $ifb->getSortMethod() . BR . "Sort order: " . $ifb->getSortOrder() . BR . "Is content: " . u\StringUtility::boolToString($ifb->isContent()) . BR . "Is folder: " . u\StringUtility::boolToString($ifb->isFolder()) . BR;
         $ifb->getFolder()->dump();
         if ($mode != 'all') {
             break;
         }
     case 'set':
         //$fid = '980d6d088b7f0856015997e451c5e052';
         //$folder = $cascade->getAsset( a\Folder::TYPE, $fid );
         $ifb->setDepthOfIndex(3)->edit()->dump(true);
         if ($mode != 'all') {
             break;
         }
     case 'raw':
         $ifb = $service->retrieve($service->createId(c\T::INDEXBLOCK, $id), c\P::INDEXBLOCK);
         echo S_PRE;
         var_dump($ifb);
 echo $af->setDescription("blah")->edit()->dump();
 //u\DebugUtility::dump( $service->getLastResponse() );
 switch ($mode) {
     case 'all':
     case 'display':
         $af->display();
         if ($mode != 'all') {
             break;
         }
     case 'dump':
         $af->dump(true);
         if ($mode != 'all') {
             break;
         }
     case 'get':
         echo c\L::ID . $af->getId() . BR . c\L::NAME . $af->getName() . BR . c\L::PATH . $af->getPath() . BR . c\L::PROPERTY_NAME . $af->getPropertyName() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . c\L::TYPE . $af->getType() . BR . "Allow subfolder placement: " . u\StringUtility::boolToString($af->getAllowSubfolderPlacement()) . BR . "Applicable groups: " . u\StringUtility::getCoalescedString($af->getApplicableGroups()) . BR . "Asset type: " . $af->getAssetType() . BR . "Base asset ID: " . u\StringUtility::getCoalescedString($af->getBaseAssetId()) . BR . "Base asset path: " . u\StringUtility::getCoalescedString($af->getBaseAssetPath()) . BR . "Base asset recycled: " . u\StringUtility::boolToString($af->getBaseAssetRecycled()) . BR . "Folder placement position: " . $af->getFolderPlacementPosition() . BR . "Overwrite: " . u\StringUtility::boolToString($af->getOverwrite()) . BR . c\L::PARENT_CONTAINER_ID . $af->getParentContainerId() . BR . c\L::PARENT_CONTAINER_PATH . $af->getParentContainerPath() . BR . "Placement folder ID: " . u\StringUtility::getCoalescedString($af->getPlacementFolderId()) . BR . "Placement folder path: " . u\StringUtility::getCoalescedString($af->getPlacementFolderPath()) . BR . "Placement folder recycled: " . u\StringUtility::boolToString($af->getPlacementFolderRecycled()) . BR . c\L::SITE_ID . $af->getSiteId() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . "Workflow definition ID: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionId()) . BR . "Workflow definition path: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionPath()) . BR . "Workflow mode: " . $af->getWorkflowMode() . BR;
         if ($af->hasPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN)) {
             u\DebugUtility::dump($af->getPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN));
         }
         u\DebugUtility::dump($af->getPluginNames());
         u\DebugUtility::dump($af->getPluginStd());
         if ($mode != 'all') {
             break;
         }
     case 'set':
         $group_name = "cru";
         $group = a\Asset::getAsset($service, a\Group::TYPE, $group_name);
         $af->addGroup($group)->edit();
         if ($af->isApplicableToGroup($group)) {
             echo "Applicable to ", $group->getName(), BR;
         } else {
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
$mode = 'all';
//$mode = 'display';
//$mode = 'dump';
//$mode = 'get';
//$mode = 'set';
//$mode = 'raw';
try {
    $id = "a14dd6578b7ffe830539acf0371e2f5f";
    // Default
    $afc = $cascade->getAsset(a\AssetFactoryContainer::TYPE, $id)->dump();
    //$afc->setDescription( "Upload" )->edit()->dump();
    echo u\StringUtility::getCoalescedString($afc->getDescription()), BR;
    switch ($mode) {
        case 'all':
        case 'display':
            $afc->display();
            if ($mode != 'all') {
                break;
            }
        case 'dump':
            $afc->dump(true);
            if ($mode != 'all') {
                break;
            }
        case 'get':
            echo c\L::ID . $afc->getId() . BR . c\L::NAME . $afc->getName() . BR . c\L::PATH . $afc->getPath() . BR . c\L::PROPERTY_NAME . $afc->getPropertyName() . BR . c\L::SITE_NAME . $afc->getSiteName() . BR . c\L::TYPE . $afc->getType() . BR . "";
            $children = $afc->getChildren();
require_once 'auth_tutorial7.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $pcs = $cascade->getAsset(a\PageConfigurationSet::TYPE, "255a2bd18b7ffe3b00a7e343711b563e");
    $pc = $pcs->getPageConfiguration("Desktop");
    //u\DebugUtility::dump( $pc->toStdClass() );
    //$pc->display();
    //$pc->dump();
    echo u\StringUtility::boolToString($pc->getDefaultConfiguration()), BR;
    echo u\StringUtility::getCoalescedString($pc->getFormatId()), BR;
    echo u\StringUtility::getCoalescedString($pc->getFormatPath()), BR;
    echo u\StringUtility::boolToString($pc->getFormatRecycled()), BR;
    echo $pc->getId(), BR;
    echo $pc->getName(), BR;
    echo u\StringUtility::boolToString($pc->getIncludeXMLDeclaration()), BR;
    echo $pc->getOutputExtension(), BR;
    //u\DebugUtility::dump( $pc->getPageRegion( "DEFAULT" ) );
    //u\DebugUtility::dump( $pc->getPageRegionNames() );
    //u\DebugUtility::dump( $pc->getPageRegions() );
    //u\DebugUtility::dump( $pc->getPageRegionBlock( "DEFAULT" ) );
    //u\DebugUtility::dump( $pc->getPageRegionFormat( "DEFAULT" ) );
    //echo u\StringUtility::boolToString( $pc->getPublishable() ), BR;
    //echo $pc->getSerializationType(), BR;
    //$pc->getTemplate()->dump();
    echo $pc->getTemplateId(), BR;
    echo $pc->getTemplatePath(), BR;
 /* === methods from Container == */
 $children = $f->getChildren();
 foreach ($children as $child) {
     u\DebugUtility::dump($child->toStdClass());
 }
 $folder_children_ids = $f->getFolderChildrenIds();
 echo "Number of folder children: " . count($folder_children_ids) . BR;
 foreach ($folder_children_ids as $folder_id) {
     u\DebugUtility::dump($folder_id);
 }
 echo c\L::PARENT_CONTAINER_ID . $f->getParentFolderId() . BR . c\L::PARENT_CONTAINER_PATH . $f->getParentFolderPath() . BR;
 echo HR;
 /* === methods from Folder == */
 echo c\L::CREATED_BY . $f->getCreatedBy() . BR . c\L::CREATED_DATE . $f->getCreatedDate() . BR . c\L::EXPIRATION_FOLDER_ID . u\StringUtility::getCoalescedString($f->getExpirationFolderId()) . BR . c\L::EXPIRATION_FOLDER_PATH . u\StringUtility::getCoalescedString($f->getExpirationFolderPath()) . BR . c\L::EXPIRATION_FOLDER_RECYCLED . u\StringUtility::boolToString($f->getExpirationFolderRecycled()) . BR . c\L::LAST_MODIFIED_BY . u\StringUtility::getCoalescedString($f->getLastModifiedBy()) . BR . c\L::LAST_MODIFIED_DATE . u\StringUtility::getCoalescedString($f->getLastModifiedDate()) . BR . c\L::LAST_PUBLISHED_BY . u\StringUtility::getCoalescedString($f->getLastPublishedBy()) . BR . c\L::LAST_PUBLISHED_DATE . u\StringUtility::getCoalescedString($f->getLastPublishedDate()) . BR . c\L::METADATA_SET_ID . $f->getMetadataSetId() . BR . c\L::METADATA_SET_PATH . $f->getMetadataSetPath() . BR . c\L::SHOULD_BE_INDEXED . u\StringUtility::boolToString($f->getShouldBeIndexed()) . BR . c\L::SHOULD_BE_PUBLISHED . u\StringUtility::boolToString($f->getShouldBePublished()) . BR . HR;
 echo "Parent folder ID: ", u\StringUtility::getCoalescedString($f->getParentFolderId()), BR;
 echo "Parent folder path: ", u\StringUtility::getCoalescedString($f->getParentFolderPath()), BR;
 echo "Is folder publishable: ", u\StringUtility::boolToString($f->isPublishable()), BR;
 u\DebugUtility::dump($f->getFolderChildrenIds());
 u\DebugUtility::dump($f->getMetadata()->toStdClass());
 u\DebugUtility::dump($f->getMetadataStdClass());
 $f->getMetadataSet()->dump();
 $field_name = 'exclude-from-left';
 echo "Dumping dynamic field {$field_name}:";
 if ($f->hasDynamicField($field_name)) {
     u\DebugUtility::dump($f->getDynamicField($field_name));
 }
 echo "Dumping dynamic fields:";
 u\DebugUtility::dump($f->getDynamicFields());
 if ($mode != 'all') {
     break;
 }
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $connector = $cascade->getAsset(a\TwitterConnector::TYPE, "017580c98b7f08ee707c11d62dc35154")->dump();
    $ct1 = $cascade->getAsset(a\ContentType::TYPE, "1378b3e38b7f08ee1890c1e4df869132");
    // RWD
    $ct2 = $cascade->getAsset(a\ContentType::TYPE, "5f4525208b7f08ee76b12c41beb6145a");
    /*
    $connector->addContentTypeLink(
        $cascade->getAsset( a\ContentType::TYPE, "1378b3e38b7f08ee1890c1e4df869132" ),
        "XML"
    )->edit() ->dump();
    */
    echo u\StringUtility::getCoalescedString($connector->getAuth1()), BR;
    echo u\StringUtility::getCoalescedString($connector->getAuth2()), BR;
    echo u\StringUtility::getCoalescedString($connector->getUrl()), BR;
    echo u\StringUtility::boolToString($connector->getVerified()), BR;
    echo u\StringUtility::getCoalescedString($connector->getVerifiedDate()), BR;
    echo u\StringUtility::boolToString($connector->hasContentType("_common_assets:RWD One Region")), BR;
    //$connector->removeContentTypeLink( $ct );
    //u\DebugUtility::dump( $connector->getConnectorContentTypeLinks() );
    //u\DebugUtility::dump( $connector->getConnectorParameters() );
    $destination = $cascade->getAsset(a\Destination::TYPE, "0755e15e8b7f08ee3295aa6d6c19fbe2");
    $connector->setDestination($destination)->edit();
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}